From e11330a5c8e5111d08d6aee1f4dc6dda6f7c7f2a Mon Sep 17 00:00:00 2001 From: redmatrix Date: Thu, 7 Jul 2016 16:44:58 -0700 Subject: revise how we store perm_limits --- Zotlabs/Access/PermissionLimits.php | 39 ++++++++----------------------------- install/perm_upgrade.php | 32 +++++++++++++++--------------- install/schema_mysql.sql | 12 ------------ install/schema_postgres.sql | 10 ---------- install/update.php | 32 +----------------------------- 5 files changed, 25 insertions(+), 100 deletions(-) diff --git a/Zotlabs/Access/PermissionLimits.php b/Zotlabs/Access/PermissionLimits.php index ef254c3cf..909b654d5 100644 --- a/Zotlabs/Access/PermissionLimits.php +++ b/Zotlabs/Access/PermissionLimits.php @@ -2,6 +2,8 @@ namespace Zotlabs\Access; +use \Zotlabs\Lib as ZLib; + class PermissionLimits { static public function Std_Limits() { @@ -17,43 +19,18 @@ 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) - ); - } + ZLib\PConfig::Set($channel_id,'perm_limits',$perm,$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; + return Zlib\PConfig::Get($channel_id,'perm_limits',$perm); } else { - return q("select * from perm_limits where channel_id = %d", - intval($channel_id) - ); + Zlib\PConfig::Load($channel_id); + if(array_key_exists($channel_id,\App::$config) && array_key_exists('perm_limits',\App::$config[$channel_id])) + return \App::$config[$channel_id]['perm_limits']; + return false; } } - } \ No newline at end of file diff --git a/install/perm_upgrade.php b/install/perm_upgrade.php index b5412b942..fffed9503 100644 --- a/install/perm_upgrade.php +++ b/install/perm_upgrade.php @@ -1,22 +1,22 @@