diff options
author | zottel <github@zottel.net> | 2016-07-26 08:43:28 +0200 |
---|---|---|
committer | zottel <github@zottel.net> | 2016-07-26 08:43:28 +0200 |
commit | 11b97af250d8c5db015a736e9349f29efb6662d7 (patch) | |
tree | 3fa43a2a23fffce85dac45343a4e9f8c24e0a1a3 /boot.php | |
parent | dcf2c07f298eec277b342f0ab3a5fa637285f0c0 (diff) | |
parent | 70dae328b5174543363163f8ca1c88c3c0af3cd8 (diff) | |
download | volse-hubzilla-11b97af250d8c5db015a736e9349f29efb6662d7.tar.gz volse-hubzilla-11b97af250d8c5db015a736e9349f29efb6662d7.tar.bz2 volse-hubzilla-11b97af250d8c5db015a736e9349f29efb6662d7.zip |
Merge remote-tracking branch 'upstream/dev' into dev
Diffstat (limited to 'boot.php')
-rwxr-xr-x | boot.php | 64 |
1 files changed, 64 insertions, 0 deletions
@@ -1551,6 +1551,9 @@ function check_config(&$a) { load_hooks(); + + check_for_new_perms(); + check_cron_broken(); } @@ -2440,6 +2443,67 @@ function cert_bad_email() { } +function check_for_new_perms() { + + $pregistered = get_config('system','perms'); + $pcurrent = array_keys(\Zotlabs\Access\Permissions::Perms()); + + if(! $pregistered) { + set_config('system','perms',$pcurrent); + return; + } + + $found_new_perm = false; + + foreach($pcurrent as $p) { + if(! in_array($p,$pregistered)) { + $found_new_perm = true; + // for all channels + $c = q("select channel_id from channel where true"); + if($c) { + foreach($c as $cc) { + // get the permission role + $r = q("select v from pconfig where uid = %d and cat = 'system' and k = 'permissions_role'", + intval($cc['uid']) + ); + if($r) { + // get a list of connections + $x = q("select abook_xchan from abook where abook_channel = %d and abook_self = 0", + intval($cc['uid']) + ); + // get the permissions role details + $rp = \Zotlabs\Access\PermissionRoles::role_perms($r[0]['v']); + if($rp) { + // set the channel limits if appropriate or 0 + if(array_key_exists('limits',$rp) && array_key_exists($p,$rp['limits'])) { + \Zotlabs\Access\PermissionLimits::Set($cc['uid'],$p,$rp['limits'][$p]); + } + else { + \Zotlabs\Access\PermissionLimits::Set($cc['uid'],$p,0); + } + + $set = ((array_key_exists('perms_connect',$rp) && array_key_exists($p,$rp['perms_connect'])) ? true : false); + // foreach connection set to the perms_connect value + if($x) { + foreach($x as $xx) { + set_abconfig($cc['uid'],$xx['abook_xchan'],'my_perms',$p,intval($set)); + } + } + } + } + } + } + } + } + + // We should probably call perms_refresh here, but this should get pushed in 24 hours and there is no urgency + if($found_new_perm) + set_config('system','perms',$pcurrent); + +} + + + /** * @brief Send warnings every 3-5 days if cron is not running. */ |