diff options
-rw-r--r-- | Zotlabs/Access/PermissionLimits.php | 39 | ||||
-rw-r--r-- | install/perm_upgrade.php | 32 | ||||
-rw-r--r-- | install/schema_mysql.sql | 12 | ||||
-rw-r--r-- | install/schema_postgres.sql | 10 | ||||
-rw-r--r-- | 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 @@ <?php function perm_limits_upgrade($channel) { - perm_limits_upgrade_create($channel['channel_id'],'view_stream',$channel['channel_r_stream']); - perm_limits_upgrade_create($channel['channel_id'],'view_profile',$channel['channel_r_profile']); - perm_limits_upgrade_create($channel['channel_id'],'view_contacts',$channel['channel_r_abook']); - perm_limits_upgrade_create($channel['channel_id'],'view_storage',$channel['channel_r_storage']); - perm_limits_upgrade_create($channel['channel_id'],'view_pages',$channel['channel_r_pages']); - perm_limits_upgrade_create($channel['channel_id'],'send_stream',$channel['channel_w_stream']); - perm_limits_upgrade_create($channel['channel_id'],'post_wall',$channel['channel_w_wall']); - perm_limits_upgrade_create($channel['channel_id'],'post_comments',$channel['channel_w_comment']); - perm_limits_upgrade_create($channel['channel_id'],'post_mail',$channel['channel_w_mail']); - perm_limits_upgrade_create($channel['channel_id'],'post_like',$channel['channel_w_like']); - perm_limits_upgrade_create($channel['channel_id'],'tag_deliver',$channel['channel_w_tagwall']); - perm_limits_upgrade_create($channel['channel_id'],'chat',$channel['channel_w_chat']); - perm_limits_upgrade_create($channel['channel_id'],'write_storage',$channel['channel_w_storage']); - perm_limits_upgrade_create($channel['channel_id'],'write_pages',$channel['channel_w_pages']); - perm_limits_upgrade_create($channel['channel_id'],'republish',$channel['channel_a_republish']); - perm_limits_upgrade_create($channel['channel_id'],'delegate',$channel['channel_a_delegate']); + set_pconfig($channel['channel_id'],'perm_limits','view_stream',$channel['channel_r_stream']); + set_pconfig($channel['channel_id'],'perm_limits','view_profile',$channel['channel_r_profile']); + set_pconfig($channel['channel_id'],'perm_limits','view_contacts',$channel['channel_r_abook']); + set_pconfig($channel['channel_id'],'perm_limits','view_storage',$channel['channel_r_storage']); + set_pconfig($channel['channel_id'],'perm_limits','view_pages',$channel['channel_r_pages']); + set_pconfig($channel['channel_id'],'perm_limits','send_stream',$channel['channel_w_stream']); + set_pconfig($channel['channel_id'],'perm_limits','post_wall',$channel['channel_w_wall']); + set_pconfig($channel['channel_id'],'perm_limits','post_comments',$channel['channel_w_comment']); + set_pconfig($channel['channel_id'],'perm_limits','post_mail',$channel['channel_w_mail']); + set_pconfig($channel['channel_id'],'perm_limits','post_like',$channel['channel_w_like']); + set_pconfig($channel['channel_id'],'perm_limits','tag_deliver',$channel['channel_w_tagwall']); + set_pconfig($channel['channel_id'],'perm_limits','chat',$channel['channel_w_chat']); + set_pconfig($channel['channel_id'],'perm_limits','write_storage',$channel['channel_w_storage']); + set_pconfig($channel['channel_id'],'perm_limits','write_pages',$channel['channel_w_pages']); + set_pconfig($channel['channel_id'],'perm_limits','republish',$channel['channel_a_republish']); + set_pconfig($channel['channel_id'],'perm_limits','delegate',$channel['channel_a_delegate']); } diff --git a/install/schema_mysql.sql b/install/schema_mysql.sql index 223f94162..9a67cada0 100644 --- a/install/schema_mysql.sql +++ b/install/schema_mysql.sql @@ -904,18 +904,6 @@ CREATE TABLE IF NOT EXISTS `pconfig` ( ) ENGINE=MyISAM DEFAULT CHARSET=utf8; -create table if not exists perm_limits { - id int(10) not null AUTO_INCREMENT, - perm varchar(64) not null default '', - channel_id int(10) unsigned not null default 0, - perm_limit int(10) unsigned not null default 0, - PRIMARY KEY (`id`), - KEY `perm` (`perm`), - KEY `channel_id` (`channel_id`), - KEY `perm_limit` (`perm_limit`) -) ENGINE=MyISAM DEFAULT CHARSET=utf8; - - CREATE TABLE IF NOT EXISTS `photo` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, `aid` int(10) unsigned NOT NULL DEFAULT '0', diff --git a/install/schema_postgres.sql b/install/schema_postgres.sql index 36018de3e..a86102b53 100644 --- a/install/schema_postgres.sql +++ b/install/schema_postgres.sql @@ -888,16 +888,6 @@ CREATE TABLE "pconfig" ( PRIMARY KEY ("id"), UNIQUE ("uid","cat","k") ); -create table perm_limits ( - id serial NOT NULL, - perm varchar(64) not null default '', - channel_id int(10) unsigned not null default 0, - perm_limit int(10) unsigned not null default 0, - primary key id -); -create index "idx_perm" on perm_limits ("perm"); -create index "idx_channel_id" on perm_limits ("channel_id"); -create index "idx_perm_limit" on perm_limits ("perm_limit"); CREATE TABLE "photo" ( "id" serial NOT NULL, diff --git a/install/update.php b/install/update.php index c87971913..f1d9adbd7 100644 --- a/install/update.php +++ b/install/update.php @@ -2366,36 +2366,6 @@ function update_r1179() { require_once('install/perm_upgrade.php'); - if(ACTIVE_DBTYPE == DBTYPE_POSTGRES) { - $r1 = q("create table perm_limits ( - id serial NOT NULL, - perm varchar(64) not null default '', - channel_id int(10) unsigned not null default 0, - perm_limit int(10) unsigned not null default 0 - primary_key id )"); - $r2 = q("create index \"idx_perm\" on perm_limits (\"perm\") "); - $r3 = q("create index \"idx_channel_id\" on perm_limits (\"channel_id\") "); - $r4 = q("create index \"idx_perm_limit\" on perm_limits (\"perm_limit\") "); - - - $r = $r1 && $r2 && $r3 && $r4; - } - - else { - $r1 = q("create table if not exists perm_limits { - id int(10) not null AUTO_INCREMENT, - perm varchar(64) not null default '', - channel_id int(10) unsigned not null default 0, - perm_limit int(10) unsigned not null default 0, - PRIMARY KEY (`id`), - KEY `perm` (`perm`), - KEY `channel_id` (`channel_id`), - KEY `perm_limit` (`perm_limit`) - ) ENGINE=MyISAM DEFAULT CHARSET=utf8 "); - - $r = $r1; - } - $r1 = q("select * from channel where true"); if($r1) { foreach($r1 as $rr) { @@ -2410,7 +2380,7 @@ function update_r1179() { } } - $r = $r && $r1 && $r2; + $r = $r1 && $r2; if($r) return UPDATE_SUCCESS; return UPDATE_FAILED; |