aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/channel.php17
-rw-r--r--include/perm_upgrade.php85
-rw-r--r--include/zot.php21
3 files changed, 83 insertions, 40 deletions
diff --git a/include/channel.php b/include/channel.php
index bec7d11d6..de0ac70e8 100644
--- a/include/channel.php
+++ b/include/channel.php
@@ -379,8 +379,21 @@ function create_identity($arr) {
set_pconfig($newuid,'system','permissions_role',$arr['permissions_role']);
if(array_key_exists('online',$role_permissions))
set_pconfig($newuid,'system','hide_presence',1-intval($role_permissions['online']));
- if(array_key_exists('perms_auto',$role_permissions))
- set_pconfig($newuid,'system','autoperms',(($role_permissions['perms_auto']) ? $role_permissions['perms_accept'] : 0));
+ if(array_key_exists('perms_auto',$role_permissions)) {
+ $autoperms = intval($role_permissions['perms_auto']);
+ set_pconfig($newuid,'system','autoperms',$autoperms);
+ if($autoperms) {
+ $x = \Zotlabs\Access\Permissions::FilledPerms($role_permissions['connect']);
+ foreach($x as $k => $v) {
+ set_pconfig($newuid,'autoperms',$k,$v);
+ }
+ }
+ else {
+ $r = q("delete from pconfig where uid = %d and cat = 'autoperms'",
+ intval($newuid)
+ );
+ }
+ }
}
// Create a group with yourself as a member. This allows somebody to use it
diff --git a/include/perm_upgrade.php b/include/perm_upgrade.php
index 9892adb07..5be1ffbb2 100644
--- a/include/perm_upgrade.php
+++ b/include/perm_upgrade.php
@@ -19,44 +19,58 @@ function perm_limits_upgrade($channel) {
set_pconfig($channel['channel_id'],'perm_limits','delegate',$channel['channel_a_delegate']);
}
+function perms_int_to_array($p) {
+
+ $ret = [];
+
+ $ret['view_stream'] = (($p & PERMS_R_STREAM) ? 1 : 0);
+ $ret['view_profile'] = (($p & PERMS_R_PROFILE) ? 1 : 0);
+ $ret['view_contacts'] = (($p & PERMS_R_ABOOK) ? 1 : 0);
+ $ret['view_storage'] = (($p & PERMS_R_STORAGE) ? 1 : 0);
+ $ret['view_pages'] = (($p & PERMS_R_PAGES) ? 1 : 0);
+ $ret['send_stream'] = (($p & PERMS_W_STREAM) ? 1 : 0);
+ $ret['post_wall'] = (($p & PERMS_W_WALL) ? 1 : 0);
+ $ret['post_comments'] = (($p & PERMS_W_COMMENT) ? 1 : 0);
+ $ret['post_mail'] = (($p & PERMS_W_MAIL) ? 1 : 0);
+ $ret['post_like'] = (($p & PERMS_W_LIKE) ? 1 : 0);
+ $ret['tag_deliver'] = (($p & PERMS_W_TAGWALL) ? 1 : 0);
+ $ret['chat'] = (($p & PERMS_W_CHAT) ? 1 : 0);
+ $ret['write_storage'] = (($p & PERMS_W_STORAGE) ? 1 : 0);
+ $ret['write_pages'] = (($p & PERMS_W_PAGES) ? 1 : 0);
+ $ret['republish'] = (($p & PERMS_A_REPUBLISH) ? 1 : 0);
+ $ret['delegate'] = (($p & PERMS_A_DELEGATE) ? 1 : 0);
+
+ return $ret;
+}
+
+function autoperms_upgrade($channel) {
+ $x = get_pconfig($channel['channel_id'],'system','autoperms');
+ if(intval($x)) {
+ $y = perms_int_to_array($x);
+ if($y) {
+ foreach($y as $k => $v) {
+ set_pconfig($channel['channel_id'],'autoperms',$k,$v);
+ }
+ }
+ }
+}
+
function perm_abook_upgrade($abook) {
- set_abconfig($abook['abook_channel'],$abook['abook_xchan'],'their_perms','view_stream',intval(($abook['abook_their_perms'] & PERMS_R_STREAM)? 1 : 0));
- set_abconfig($abook['abook_channel'],$abook['abook_xchan'],'their_perms','view_profile',intval(($abook['abook_their_perms'] & PERMS_R_PROFILE)? 1 : 0));
- set_abconfig($abook['abook_channel'],$abook['abook_xchan'],'their_perms','view_contacts',intval(($abook['abook_their_perms'] & PERMS_R_ABOOK)? 1 : 0));
- set_abconfig($abook['abook_channel'],$abook['abook_xchan'],'their_perms','view_storage',intval(($abook['abook_their_perms'] & PERMS_R_STORAGE)? 1 : 0));
- set_abconfig($abook['abook_channel'],$abook['abook_xchan'],'their_perms','view_pages',intval(($abook['abook_their_perms'] & PERMS_R_PAGES)? 1 : 0));
- set_abconfig($abook['abook_channel'],$abook['abook_xchan'],'their_perms','send_stream',intval(($abook['abook_their_perms'] & PERMS_W_STREAM)? 1 : 0));
- set_abconfig($abook['abook_channel'],$abook['abook_xchan'],'their_perms','post_wall',intval(($abook['abook_their_perms'] & PERMS_W_WALL)? 1 : 0));
- set_abconfig($abook['abook_channel'],$abook['abook_xchan'],'their_perms','post_comments',intval(($abook['abook_their_perms'] & PERMS_W_COMMENT)? 1 : 0));
- set_abconfig($abook['abook_channel'],$abook['abook_xchan'],'their_perms','post_mail',intval(($abook['abook_their_perms'] & PERMS_W_MAIL)? 1 : 0));
- set_abconfig($abook['abook_channel'],$abook['abook_xchan'],'their_perms','post_like',intval(($abook['abook_their_perms'] & PERMS_W_LIKE)? 1 : 0));
- set_abconfig($abook['abook_channel'],$abook['abook_xchan'],'their_perms','tag_deliver',intval(($abook['abook_their_perms'] & PERMS_W_TAGWALL)? 1 : 0));
- set_abconfig($abook['abook_channel'],$abook['abook_xchan'],'their_perms','chat',intval(($abook['abook_their_perms'] & PERMS_W_CHAT)? 1 : 0));
- set_abconfig($abook['abook_channel'],$abook['abook_xchan'],'their_perms','write_storage',intval(($abook['abook_their_perms'] & PERMS_W_STORAGE)? 1 : 0));
- set_abconfig($abook['abook_channel'],$abook['abook_xchan'],'their_perms','write_pages',intval(($abook['abook_their_perms'] & PERMS_W_PAGES)? 1 : 0));
- set_abconfig($abook['abook_channel'],$abook['abook_xchan'],'their_perms','republish',intval(($abook['abook_their_perms'] & PERMS_A_REPUBLISH)? 1 : 0));
- set_abconfig($abook['abook_channel'],$abook['abook_xchan'],'their_perms','delegate',intval(($abook['abook_their_perms'] & PERMS_A_DELEGATE)? 1 : 0));
-
-
- set_abconfig($abook['abook_channel'],$abook['abook_xchan'],'my_perms','view_stream',intval(($abook['abook_my_perms'] & PERMS_R_STREAM)? 1 : 0));
- set_abconfig($abook['abook_channel'],$abook['abook_xchan'],'my_perms','view_profile',intval(($abook['abook_my_perms'] & PERMS_R_PROFILE)? 1 : 0));
- set_abconfig($abook['abook_channel'],$abook['abook_xchan'],'my_perms','view_contacts',intval(($abook['abook_my_perms'] & PERMS_R_ABOOK)? 1 : 0));
- set_abconfig($abook['abook_channel'],$abook['abook_xchan'],'my_perms','view_storage',intval(($abook['abook_my_perms'] & PERMS_R_STORAGE)? 1 : 0));
- set_abconfig($abook['abook_channel'],$abook['abook_xchan'],'my_perms','view_pages',intval(($abook['abook_my_perms'] & PERMS_R_PAGES)? 1 : 0));
- set_abconfig($abook['abook_channel'],$abook['abook_xchan'],'my_perms','send_stream',intval(($abook['abook_my_perms'] & PERMS_W_STREAM)? 1 : 0));
- set_abconfig($abook['abook_channel'],$abook['abook_xchan'],'my_perms','post_wall',intval(($abook['abook_my_perms'] & PERMS_W_WALL)? 1 : 0));
- set_abconfig($abook['abook_channel'],$abook['abook_xchan'],'my_perms','post_comments',intval(($abook['abook_my_perms'] & PERMS_W_COMMENT)? 1 : 0));
- set_abconfig($abook['abook_channel'],$abook['abook_xchan'],'my_perms','post_mail',intval(($abook['abook_my_perms'] & PERMS_W_MAIL)? 1 : 0));
- set_abconfig($abook['abook_channel'],$abook['abook_xchan'],'my_perms','post_like',intval(($abook['abook_my_perms'] & PERMS_W_LIKE)? 1 : 0));
- set_abconfig($abook['abook_channel'],$abook['abook_xchan'],'my_perms','tag_deliver',intval(($abook['abook_my_perms'] & PERMS_W_TAGWALL)? 1 : 0));
- set_abconfig($abook['abook_channel'],$abook['abook_xchan'],'my_perms','chat',intval(($abook['abook_my_perms'] & PERMS_W_CHAT)? 1 : 0));
- set_abconfig($abook['abook_channel'],$abook['abook_xchan'],'my_perms','write_storage',intval(($abook['abook_my_perms'] & PERMS_W_STORAGE)? 1 : 0));
- set_abconfig($abook['abook_channel'],$abook['abook_xchan'],'my_perms','write_pages',intval(($abook['abook_my_perms'] & PERMS_W_PAGES)? 1 : 0));
- set_abconfig($abook['abook_channel'],$abook['abook_xchan'],'my_perms','republish',intval(($abook['abook_my_perms'] & PERMS_A_REPUBLISH)? 1 : 0));
- set_abconfig($abook['abook_channel'],$abook['abook_xchan'],'my_perms','delegate',intval(($abook['abook_my_perms'] & PERMS_A_DELEGATE)? 1 : 0));
+ $x = perms_int_to_array($abook['abook_their_perms']);
+ if($x) {
+ foreach($x as $k => $v) {
+ set_abconfig($abook['abook_channel'],$abook['abook_xchan'],'their_perms',$k, $v);
+ }
+ }
+ $x = perms_int_to_array($abook['abook_my_perms']);
+ if($x) {
+ foreach($x as $k => $v) {
+ set_abconfig($abook['abook_channel'],$abook['abook_xchan'],'my_perms',$k, $v);
+ }
+ }
}
function translate_channel_perms_outbound(&$channel) {
@@ -217,3 +231,6 @@ function translate_abook_perms_inbound($channel,$abook) {
}
}
+
+
+
diff --git a/include/zot.php b/include/zot.php
index 0a835a909..47bdce568 100644
--- a/include/zot.php
+++ b/include/zot.php
@@ -456,15 +456,28 @@ function zot_refresh($them, $channel = null, $force = false) {
// new connection
+ $my_perms = null;
+
$role = get_pconfig($channel['channel_id'],'system','permissions_role');
if($role) {
$xx = get_role_perms($role);
- if($xx['perms_auto'])
+ if($xx['perms_auto']) {
$default_perms = $xx['perms_connect'];
+ $my_perms = \Zotlabs\Access\Permissions::FilledPerms($default_perms);
+ }
+
+ if(! $my_perms) {
+ $x = \Zotlabs\Access\Permissions::FilledAutoperms($channel['channel_id']);
+ if($x) {
+ $my_perms = $x;
+ }
}
- if(! $default_perms)
- $default_perms = get_pconfig($channel['channel_id'],'system','autoperms');
+ if($my_perms) {
+ foreach($my_perms as $k => $v) {
+ set_abconfig($channel['channel_id'],$x['hash'],'my_perms',$k,$v);
+ }
+ }
// Keep original perms to check if we need to notify them
$previous_perms = get_all_perms($channel['channel_id'],$x['hash']);
@@ -497,7 +510,7 @@ function zot_refresh($them, $channel = null, $force = false) {
);
if($new_connection) {
- if($new_perms != $previous_perms)
+ if(! \Zotlabs\Access\Permissions::PermsCompare($new_perms,$previous_perms))
Zotlabs\Daemon\Master::Summon(array('Notifier','permission_create',$new_connection[0]['abook_id']));
Zotlabs\Lib\Enotify::submit(array(
'type' => NOTIFY_INTRO,