aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorredmatrix <git@macgirvin.com>2016-07-03 17:10:00 -0700
committerredmatrix <git@macgirvin.com>2016-07-03 17:10:00 -0700
commitc918bbba255c4566dcd6c85c06e19646bd178183 (patch)
tree29b07f41c3528c9249b8e4035a2103859705e10a
parent57226b2e1378c2769709a2b2407249cc4e3b14f4 (diff)
downloadvolse-hubzilla-c918bbba255c4566dcd6c85c06e19646bd178183.tar.gz
volse-hubzilla-c918bbba255c4566dcd6c85c06e19646bd178183.tar.bz2
volse-hubzilla-c918bbba255c4566dcd6c85c06e19646bd178183.zip
more work on x permissions
-rw-r--r--install/perm_upgrade.php71
-rw-r--r--install/schema_mysql.sql13
-rw-r--r--install/update.php55
3 files changed, 139 insertions, 0 deletions
diff --git a/install/perm_upgrade.php b/install/perm_upgrade.php
new file mode 100644
index 000000000..2a853ea37
--- /dev/null
+++ b/install/perm_upgrade.php
@@ -0,0 +1,71 @@
+<?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']);
+}
+
+
+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) {
+ set_abconfig($abook['abook_channel'],$abook['abook_hash'],'their_perms','view_stream',intval(($abook['their_perms'] & PERMS_R_STREAM)? 1 : 0));
+ set_abconfig($abook['abook_channel'],$abook['abook_hash'],'their_perms','view_profile',intval(($abook['their_perms'] & PERMS_R_PROFILE)? 1 : 0));
+ set_abconfig($abook['abook_channel'],$abook['abook_hash'],'their_perms','view_contacts',intval(($abook['their_perms'] & PERMS_R_ABOOK)? 1 : 0));
+ set_abconfig($abook['abook_channel'],$abook['abook_hash'],'their_perms','view_storage',intval(($abook['their_perms'] & PERMS_R_STORAGE)? 1 : 0));
+ set_abconfig($abook['abook_channel'],$abook['abook_hash'],'their_perms','view_pages',intval(($abook['their_perms'] & PERMS_R_PAGES)? 1 : 0));
+ set_abconfig($abook['abook_channel'],$abook['abook_hash'],'their_perms','send_stream',intval(($abook['their_perms'] & PERMS_W_STREAM)? 1 : 0));
+ set_abconfig($abook['abook_channel'],$abook['abook_hash'],'their_perms','post_wall',intval(($abook['their_perms'] & PERMS_W_WALL)? 1 : 0));
+ set_abconfig($abook['abook_channel'],$abook['abook_hash'],'their_perms','post_comments',intval(($abook['their_perms'] & PERMS_W_COMMENT)? 1 : 0));
+ set_abconfig($abook['abook_channel'],$abook['abook_hash'],'their_perms','post_mail',intval(($abook['their_perms'] & PERMS_W_MAIL)? 1 : 0));
+ set_abconfig($abook['abook_channel'],$abook['abook_hash'],'their_perms','post_like',intval(($abook['their_perms'] & PERMS_W_LIKE)? 1 : 0));
+ set_abconfig($abook['abook_channel'],$abook['abook_hash'],'their_perms','tag_deliver',intval(($abook['their_perms'] & PERMS_W_TAGWALL)? 1 : 0));
+ set_abconfig($abook['abook_channel'],$abook['abook_hash'],'their_perms','chat',intval(($abook['their_perms'] & PERMS_W_CHAT)? 1 : 0));
+ set_abconfig($abook['abook_channel'],$abook['abook_hash'],'their_perms','write_storage',intval(($abook['their_perms'] & PERMS_W_STORAGE)? 1 : 0));
+ set_abconfig($abook['abook_channel'],$abook['abook_hash'],'their_perms','write_pages',intval(($abook['their_perms'] & PERMS_W_PAGES)? 1 : 0));
+ set_abconfig($abook['abook_channel'],$abook['abook_hash'],'their_perms','republish',intval(($abook['their_perms'] & PERMS_A_REPUBLISH)? 1 : 0));
+ set_abconfig($abook['abook_channel'],$abook['abook_hash'],'their_perms','delegate',intval(($abook['their_perms'] & PERMS_A_DELEGATE)? 1 : 0));
+
+
+
+ set_abconfig($abook['abook_channel'],$abook['abook_hash'],'my_perms','view_stream',intval(($abook['my_perms'] & PERMS_R_STREAM)? 1 : 0));
+ set_abconfig($abook['abook_channel'],$abook['abook_hash'],'my_perms','view_profile',intval(($abook['my_perms'] & PERMS_R_PROFILE)? 1 : 0));
+ set_abconfig($abook['abook_channel'],$abook['abook_hash'],'my_perms','view_contacts',intval(($abook['my_perms'] & PERMS_R_ABOOK)? 1 : 0));
+ set_abconfig($abook['abook_channel'],$abook['abook_hash'],'my_perms','view_storage',intval(($abook['my_perms'] & PERMS_R_STORAGE)? 1 : 0));
+ set_abconfig($abook['abook_channel'],$abook['abook_hash'],'my_perms','view_pages',intval(($abook['my_perms'] & PERMS_R_PAGES)? 1 : 0));
+ set_abconfig($abook['abook_channel'],$abook['abook_hash'],'my_perms','send_stream',intval(($abook['my_perms'] & PERMS_W_STREAM)? 1 : 0));
+ set_abconfig($abook['abook_channel'],$abook['abook_hash'],'my_perms','post_wall',intval(($abook['my_perms'] & PERMS_W_WALL)? 1 : 0));
+ set_abconfig($abook['abook_channel'],$abook['abook_hash'],'my_perms','post_comments',intval(($abook['my_perms'] & PERMS_W_COMMENT)? 1 : 0));
+ set_abconfig($abook['abook_channel'],$abook['abook_hash'],'my_perms','post_mail',intval(($abook['my_perms'] & PERMS_W_MAIL)? 1 : 0));
+ set_abconfig($abook['abook_channel'],$abook['abook_hash'],'my_perms','post_like',intval(($abook['my_perms'] & PERMS_W_LIKE)? 1 : 0));
+ set_abconfig($abook['abook_channel'],$abook['abook_hash'],'my_perms','tag_deliver',intval(($abook['my_perms'] & PERMS_W_TAGWALL)? 1 : 0));
+ set_abconfig($abook['abook_channel'],$abook['abook_hash'],'my_perms','chat',intval(($abook['my_perms'] & PERMS_W_CHAT)? 1 : 0));
+ set_abconfig($abook['abook_channel'],$abook['abook_hash'],'my_perms','write_storage',intval(($abook['my_perms'] & PERMS_W_STORAGE)? 1 : 0));
+ set_abconfig($abook['abook_channel'],$abook['abook_hash'],'my_perms','write_pages',intval(($abook['my_perms'] & PERMS_W_PAGES)? 1 : 0));
+ set_abconfig($abook['abook_channel'],$abook['abook_hash'],'my_perms','republish',intval(($abook['my_perms'] & PERMS_A_REPUBLISH)? 1 : 0));
+ set_abconfig($abook['abook_channel'],$abook['abook_hash'],'my_perms','delegate',intval(($abook['my_perms'] & PERMS_A_DELEGATE)? 1 : 0));
+
+
+} \ No newline at end of file
diff --git a/install/schema_mysql.sql b/install/schema_mysql.sql
index d2a5ac85e..223f94162 100644
--- a/install/schema_mysql.sql
+++ b/install/schema_mysql.sql
@@ -903,6 +903,19 @@ CREATE TABLE IF NOT EXISTS `pconfig` (
UNIQUE KEY `access` (`uid`,`cat`,`k`)
) 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/update.php b/install/update.php
index 3cb5010eb..865555b00 100644
--- a/install/update.php
+++ b/install/update.php
@@ -2360,4 +2360,59 @@ function update_r1178() {
if($r1)
return UPDATE_SUCCESS;
return UPDATE_FAILED;
+}
+
+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 )");
+ $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) {
+ perm_limits_upgrade($rr);
+ }
+ }
+
+ $r2 = q("select * from abook where true");
+ if($r2) {
+ foreach($r2 as $rr) {
+ perm_abook_upgrade($rr);
+ }
+ }
+
+ $r = $r && $r1 && $r2;
+ if($r)
+ return UPDATE_SUCCESS;
+ return UPDATE_FAILED;
+
+
} \ No newline at end of file