diff options
Diffstat (limited to 'Zotlabs/Module')
-rw-r--r-- | Zotlabs/Module/Connedit.php | 2 | ||||
-rw-r--r-- | Zotlabs/Module/Settings/Permcats.php | 42 |
2 files changed, 26 insertions, 18 deletions
diff --git a/Zotlabs/Module/Connedit.php b/Zotlabs/Module/Connedit.php index 8f382246a..ccaf5cd5b 100644 --- a/Zotlabs/Module/Connedit.php +++ b/Zotlabs/Module/Connedit.php @@ -827,6 +827,8 @@ class Connedit extends \Zotlabs\Web\Controller { '$header' => (($self) ? t('Connection Default Permissions') : sprintf( t('Connection: %s'),$contact['xchan_name'])), '$autoperms' => array('autoperms',t('Apply these permissions automatically'), ((get_pconfig(local_channel(),'system','autoperms')) ? 1 : 0), t('Connection requests will be approved without your interaction'), $yes_no), '$permcat' => [ 'permcat', t('Permission role'), '', '',$permcats ], + '$permcat_new' => t('Add permission role'), + '$permcat_enable' => feature_enabled(local_channel(),'permcats'), '$addr' => $contact['xchan_addr'], '$section' => $section, '$sections' => $sections, diff --git a/Zotlabs/Module/Settings/Permcats.php b/Zotlabs/Module/Settings/Permcats.php index 82ee45bf7..35d533196 100644 --- a/Zotlabs/Module/Settings/Permcats.php +++ b/Zotlabs/Module/Settings/Permcats.php @@ -42,6 +42,8 @@ class Permcats { function get() { +logger('cmd: ' . \App::$cmd); + if(! local_channel()) return; @@ -51,30 +53,33 @@ class Permcats { if(argc() > 2) $name = argv(2); + if(argc() > 3 && argv(3) === 'drop') { + \Zotlabs\Lib\Permcat::delete(local_channel(),$name); + build_sync_packet(); + json_return_and_die([ 'success' => true ]); + } - $desc = t('Use this form to create permission rules for various classes of people or connections.'); - - $global_perms = \Zotlabs\Access\Permissions::Perms(); - - $their_perms = []; - $existing = get_all_perms(local_channel(),(($atoken_xchan) ? $atoken_xchan : '')); + $desc = t('Use this form to create permission rules for various classes of people or connections.'); - if($atoken_xchan) { - $theirs = q("select * from abconfig where chan = %d and xchan = '%s' and cat = 'their_perms'", - intval(local_channel()), - dbesc($atoken_xchan) - ); - if($theirs) { - foreach($theirs as $t) { - $their_perms[$t['k']] = $t['v']; - } + $existing = []; + + $pcat = new \Zotlabs\Lib\Permcat(local_channel()); + $pcatlist = $pcat->listing(); + $permcats = []; + if($pcatlist) { + foreach($pcatlist as $pc) { + if(($pc['name']) && ($name) && ($pc['name'] == $name)) + $existing = $pc['perms']; + if(! $pc['system']) + $permcats[$pc['name']] = $pc['localname']; } } - foreach($global_perms as $k => $v) { - $thisperm = get_abconfig(local_channel(),$contact['abook_xchan'],'my_perms',$k); -//fixme + $global_perms = \Zotlabs\Access\Permissions::Perms(); + + foreach($global_perms as $k => $v) { + $thisperm = \Zotlabs\Lib\Permcat::find_permcat($existing,$k); $checkinherited = \Zotlabs\Access\PermissionLimits::Get(local_channel(),$k); if($existing[$k]) @@ -92,6 +97,7 @@ class Permcats { '$desc' => $desc, '$desc2' => $desc2, '$tokens' => $t, + '$permcats' => $permcats, '$atoken' => $atoken, '$url1' => z_root() . '/channel/' . $channel['channel_address'], '$url2' => z_root() . '/photos/' . $channel['channel_address'], |