aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorredmatrix <git@macgirvin.com>2016-07-03 18:20:15 -0700
committerredmatrix <git@macgirvin.com>2016-07-03 18:20:15 -0700
commit916e088462ec46044ce18b83eb5271968d1c132b (patch)
treebbe11191642a4200c90c6704eabec21e1d60a553
parentc918bbba255c4566dcd6c85c06e19646bd178183 (diff)
downloadvolse-hubzilla-916e088462ec46044ce18b83eb5271968d1c132b.tar.gz
volse-hubzilla-916e088462ec46044ce18b83eb5271968d1c132b.tar.bz2
volse-hubzilla-916e088462ec46044ce18b83eb5271968d1c132b.zip
make permissionlimits into a class
-rw-r--r--Zotlabs/Access/PermissionLimits.php46
-rw-r--r--install/perm_upgrade.php8
2 files changed, 46 insertions, 8 deletions
diff --git a/Zotlabs/Access/PermissionLimits.php b/Zotlabs/Access/PermissionLimits.php
new file mode 100644
index 000000000..ddea919aa
--- /dev/null
+++ b/Zotlabs/Access/PermissionLimits.php
@@ -0,0 +1,46 @@
+<?php
+
+namespace Zotlabs\Access;
+
+class PermissionLimits {
+ static public function Set($channel_id,$perm,$perm_limit) {
+ $r = q("select * from perm_limits where channel_id = %d and perm = '%s' limit 1",
+ intval($channel_id),
+ dbesc($perm)
+ );
+ if($r) {
+ if($r[0]['perm_limit'] != $perm_limit) {
+ $x = q("update perm_limits set perm_limit = %d where id = %d",
+ dbesc($perm_limit)
+ intval($r[0]['id'])
+ );
+ }
+ }
+ else {
+ $r = q("insert into perm_limits ( perm, channel_id, perm_limit )
+ values ( '%s', %d, %d ) ",
+ dbesc($perm),
+ intval($channel_id),
+ intval($perm_limit)
+ );
+ }
+ }
+
+ static public function Get($channel_id,$perm = '') {
+ if($perm) {
+ $r = q("select * from perm_limits where channel_id = %d and perm = '%s' limit 1",
+ intval($channel_id)
+ dbesc($perm)
+ );
+ if($r)
+ return $r[0];
+ return false;
+ }
+ else {
+ return q("select * from perm_limits where channel_id = %d",
+ intval($channel_id)
+ );
+ }
+ }
+
+} \ No newline at end of file
diff --git a/install/perm_upgrade.php b/install/perm_upgrade.php
index 2a853ea37..ff6cda2e2 100644
--- a/install/perm_upgrade.php
+++ b/install/perm_upgrade.php
@@ -20,14 +20,6 @@ function perm_limits_upgrade($channel) {
}
-function perm_limits_upgrade_create($channel_id,$perm,$perm_limit) {
- $r = q("insert into perm_limits ( perm, channel_id, perm_limit )
- values ( '%s', %d, %d ) ",
- dbesc($perm),
- intval($channel_id),
- intval($perm_limit)
- );
-}
function perm_abook_upgrade($abook) {