diff --git a/Zotlabs/Access/Permissions.php b/Zotlabs/Access/Permissions.php index cf8eddb2e..c3c915bd5 100644 --- a/Zotlabs/Access/Permissions.php +++ b/Zotlabs/Access/Permissions.php @@ -228,7 +228,7 @@ class Permissions // If a default permcat exists, use that - $pc = ((feature_enabled($channel_id, 'permcats')) ? get_pconfig($channel_id, 'system', 'default_permcat') : 'default'); + $pc = ((Zlib\Apps::system_app_installed($channel_id, 'Roles')) ? get_pconfig($channel_id, 'system', 'default_permcat') : 'default'); if (! in_array($pc, [ '','default' ])) { $pcp = new Zlib\Permcat($channel_id); $permcat = $pcp->fetch($pc); diff --git a/Zotlabs/Lib/Apps.php b/Zotlabs/Lib/Apps.php index b77cc46ce..352e40d92 100644 --- a/Zotlabs/Lib/Apps.php +++ b/Zotlabs/Lib/Apps.php @@ -395,6 +395,7 @@ class Apps 'Random Channel' => t('Random Channel'), 'Remote Diagnostics' => t('Remote Diagnostics'), 'Report Bug' => t('Report Bug'), + 'Roles' => t('Roles'), 'Search' => t('Search'), 'Secrets' => t('Secrets'), 'Settings' => t('Settings'), diff --git a/Zotlabs/Lib/Permcat.php b/Zotlabs/Lib/Permcat.php index c94061586..b2bed9263 100644 --- a/Zotlabs/Lib/Permcat.php +++ b/Zotlabs/Lib/Permcat.php @@ -52,7 +52,7 @@ class Permcat // if no role perms it may be a custom role, see if there any autoperms if (! $perms) { - $perms = Permissions::FilledAutoPerms($channel_id); + $perms = Permissions::FilledAutoperms($channel_id); } // if no autoperms it may be a custom role with manual perms @@ -60,7 +60,7 @@ class Permcat if (! $perms) { $c = channelx_by_n($channel_id); if ($c) { - $perms = Permissions::FilledPerms(get_abconfig($channel_id, $c['channel_hash'], 'system', 'my_perms', EMPTY_STR)); + $perms = Permissions::FilledPerms(explode(',',get_abconfig($channel_id, $c['channel_hash'], 'system', 'my_perms', EMPTY_STR))); } } @@ -148,7 +148,7 @@ class Permcat ); if ($x) { foreach ($x as $xv) { - $value = ((preg_match('|^a:[0-9]+:{.*}$|s', $xv['v'])) ? unserialize($xv['v']) : $xv['v']); + $value = unserialise($xv['v']); $permcats[] = [ $xv['k'], $xv['k'], $value, 0 ]; } } diff --git a/Zotlabs/Module/Connedit.php b/Zotlabs/Module/Connedit.php index d4af7e233..1d299a006 100644 --- a/Zotlabs/Module/Connedit.php +++ b/Zotlabs/Module/Connedit.php @@ -768,7 +768,7 @@ class Connedit extends Controller $thisperm = "1"; } - $perms[] = array('perms_' . $k, $v, ((array_key_exists($k, $their_perms)) ? intval($their_perms[$k]) : ''), $thisperm, 1, (($checkinherited & PERMS_SPECIFIC) ? '' : '1'), '', $checkinherited); + $perms[] = array('perms_' . $k, $v, ((array_key_exists($k, $their_perms)) ? intval($their_perms[$k]) : ''), $thisperm, $yes_no, (($checkinherited & PERMS_SPECIFIC) ? '' : '1'), '', $checkinherited); } $pcat = new Permcat(local_channel()); @@ -806,7 +806,7 @@ class Connedit extends Controller '$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'), + '$permcat_enable' => Apps::system_app_installed(local_channel(),'Roles'), '$addr' => unpunify($contact['xchan_addr']), '$primeurl' => unpunify($contact['xchan_url']), '$block_announce' => ['block_announce', t('Ignore shares and repeats this connection posts'), get_abconfig(local_channel(), $contact['xchan_hash'], 'system', 'block_announce', false), t('Note: This is not recommended for Groups.'), [t('No'), t('Yes')]], @@ -840,7 +840,7 @@ class Connedit extends Controller '$pending_label' => t('Connection Pending Approval'), '$is_pending' => (intval($contact['abook_pending']) ? 1 : ''), '$unapproved' => $unapproved, - '$inherited' => t('inherited'), + '$inherited' => '', // t('inherited'), '$submit' => t('Submit'), '$lbl_vis2' => sprintf(t('Please choose the profile you would like to display to %s when viewing your profile securely.'), $contact['xchan_name']), '$close' => (($contact['abook_closeness']) ? $contact['abook_closeness'] : 80), @@ -848,8 +848,8 @@ class Connedit extends Controller '$me' => t('My Settings'), '$perms' => $perms, '$permlbl' => t('Individual Permissions'), - '$permnote' => t('Some permissions may be inherited from your channel\'s privacy settings, which have higher priority than individual settings. You can not change those settings here.'), - '$permnote_self' => t('Some permissions may be inherited from your channel\'s privacy settings, which have higher priority than individual settings. You can change those settings here but they wont have any impact unless the inherited setting changes.'), + '$permnote' => t('Some individual permissions may have been preset or locked based on your channel type and privacy settings.'), + '$permnote_self' => t('Some individual permissions may have been preset or locked based on your channel type and privacy settings.'), '$lastupdtext' => t('Last update:'), '$last_update' => relative_date($contact['abook_connected']), '$profile_select' => contact_profile_assign($contact['abook_profile']), diff --git a/Zotlabs/Module/Defperms.php b/Zotlabs/Module/Defperms.php index ec714b10e..e4b02f8ba 100644 --- a/Zotlabs/Module/Defperms.php +++ b/Zotlabs/Module/Defperms.php @@ -5,6 +5,7 @@ namespace Zotlabs\Module; use App; use Zotlabs\Lib\Permcat; use Zotlabs\Lib\Libsync; +use Zotlabs\Lib\Apps; use Zotlabs\Web\Controller; use Zotlabs\Access\Permissions; use Zotlabs\Access\PermissionLimits; @@ -248,7 +249,7 @@ class Defperms extends Controller '$autoperms' => array('autoperms', t('Apply these permissions automatically'), ((get_pconfig(local_channel(), 'system', 'autoperms')) ? 1 : 0), t('If enabled, 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'), + '$permcat_enable' => Apps::system_app_installed($channel_id, 'Roles'), '$section' => $section, '$sections' => $sections, '$autolbl' => t('The permissions indicated on this page will be applied to all new connections.'), diff --git a/Zotlabs/Module/Settings/Channel.php b/Zotlabs/Module/Settings/Channel.php index 8c9d83145..73256f961 100644 --- a/Zotlabs/Module/Settings/Channel.php +++ b/Zotlabs/Module/Settings/Channel.php @@ -3,6 +3,7 @@ namespace Zotlabs\Module\Settings; use App; +use Zotlabs\Lib\Apps; use Zotlabs\Lib\Libsync; use Zotlabs\Lib\AccessList; use Zotlabs\Access\Permissions; @@ -670,7 +671,7 @@ class Channel '$permissions_role' => $permissions_role, '$role' => array('permissions_role', t('Channel type and privacy'), $permissions_role, '', $perm_roles, ' onchange="update_role_text(); return false;"'), '$defpermcat' => ['defpermcat', t('Default Permissions Group'), $default_permcat, '', $permcats], - '$permcat_enable' => feature_enabled(local_channel(), 'permcats'), + '$permcat_enable' => Apps::system_app_installed(local_channel(), 'Roles'), '$profile_in_dir' => $profile_in_dir, '$hide_friends' => $hide_friends, '$hide_wall' => $hide_wall, diff --git a/Zotlabs/Module/Settings/Permcats.php b/Zotlabs/Module/Settings/Permcats.php index a4294db31..da132184e 100644 --- a/Zotlabs/Module/Settings/Permcats.php +++ b/Zotlabs/Module/Settings/Permcats.php @@ -13,7 +13,8 @@ class Permcats public function post() { - + //logger('$_REQUEST: ' . print_r($_REQUEST,true)); + if (!local_channel()) { return; } @@ -46,7 +47,7 @@ class Permcats Libsync::build_sync_packet(); - info(t('Permission category saved.') . EOL); + info(t('Permission role saved.') . EOL); return; } @@ -91,24 +92,39 @@ class Permcats } } + $hidden_perms = []; $global_perms = Permissions::Perms(); foreach ($global_perms as $k => $v) { $thisperm = Permcat::find_permcat($existing, $k); + $checkinherited = PermissionLimits::Get(local_channel(), $k); - if ($existing[$k]) { - $thisperm = "1"; + $inherited = (($checkinherited & PERMS_SPECIFIC) ? false : true); + + $thisperm = 0; + if ($existing) { + foreach ($existing as $ex) { + if ($ex['name'] === $k) { + $thisperm = $ex['value']; + break; + } + } + } + + $perms[] = [ 'perms_' . $k, $v, $inherited ? 1 : intval($thisperm), '', [ t('No'), t('Yes') ], (($inherited) ? ' disabled="disabled" ' : '' )]; + + if ($inherited) { + $hidden_perms[] = ['perms_' . $k, 1 ]; } - $perms[] = array('perms_' . $k, $v, '', $thisperm, 1, (($checkinherited & PERMS_SPECIFIC) ? '' : '1'), '', $checkinherited); } - + $tpl = get_markup_template("settings_permcats.tpl"); $o .= replace_macros($tpl, array( '$form_security_token' => get_form_security_token("settings_permcats"), - '$title' => t('Permission Categories'), + '$title' => t('Permission Roles'), '$desc' => $desc, '$desc2' => $desc2, '$tokens' => $t, @@ -116,14 +132,15 @@ class Permcats '$atoken' => $atoken, '$url1' => z_root() . '/channel/' . $channel['channel_address'], '$url2' => z_root() . '/photos/' . $channel['channel_address'], - '$name' => array('name', t('Permission Name') . ' *', (($name) ? $name : ''), ''), + '$name' => array('name', t('Role name') . ' *', (($name) ? $name : ''), ''), '$me' => t('My Settings'), '$perms' => $perms, + '$hidden_perms' => $hidden_perms, '$inherited' => t('inherited'), '$notself' => 0, '$self' => 1, '$permlbl' => t('Individual Permissions'), - '$permnote' => t('Some permissions may be inherited from your channel\'s privacy settings, which have higher priority than individual settings. You can not change those settings here.'), + '$permnote' => t('Some individual permissions may have been preset or locked based on your channel type and privacy settings.'), '$submit' => t('Submit') )); return $o; diff --git a/Zotlabs/Widget/Settings_menu.php b/Zotlabs/Widget/Settings_menu.php index afd869b76..2eb1b1451 100644 --- a/Zotlabs/Widget/Settings_menu.php +++ b/Zotlabs/Widget/Settings_menu.php @@ -105,13 +105,13 @@ class Settings_menu // ); // } -// if(feature_enabled(local_channel(),'permcats')) { -// $tabs[] = array( -// 'label' => t('Permission Categories'), -// 'url' => z_root() . '/settings/permcats', -// 'selected' => ((argv(1) === 'permcats') ? 'active' : ''), -// ); -// } + if(Apps::system_app_installed(local_channel(),'Roles')) { + $tabs[] = array( + 'label' => t('Permission Roles'), + 'url' => z_root() . '/settings/permcats', + 'selected' => ((argv(1) === 'permcats') ? 'active' : ''), + ); + } // if($role === false || $role === 'custom') { diff --git a/app/roles.apd b/app/roles.apd new file mode 100644 index 000000000..6ed732416 --- /dev/null +++ b/app/roles.apd @@ -0,0 +1,6 @@ +version: 1 +url: $baseurl/settings/permcats +requires: local_channel +name: Roles +photo: icon:users +categories: Networking diff --git a/include/features.php b/include/features.php index 6514857d2..8380cec71 100644 --- a/include/features.php +++ b/include/features.php @@ -247,14 +247,14 @@ function get_features($filtered = true, $level = (-1)) // ], -// [ -// 'permcats', -// t('Permission Categories'), -// t('Create custom connection permission limits'), -// false, -// get_config('feature_lock','permcats'), -// feature_level('permcats',2), -// ], + [ + 'permcats', + t('Permission Categories'), + t('Create custom connection permission limits'), + true, + get_config('feature_lock','permcats'), + feature_level('permcats',2), + ], // [ // 'oauth_clients', diff --git a/view/tpl/abook_edit.tpl b/view/tpl/abook_edit.tpl index fa180e8fe..39d374738 100755 --- a/view/tpl/abook_edit.tpl +++ b/view/tpl/abook_edit.tpl @@ -238,7 +238,7 @@ {{include file="field_select.tpl" field=$permcat}} {{/if}} - +
{{if $notself}} diff --git a/view/tpl/field_acheckbox.tpl b/view/tpl/field_acheckbox.tpl index 1810e1ee1..99daa9832 100755 --- a/view/tpl/field_acheckbox.tpl +++ b/view/tpl/field_acheckbox.tpl @@ -1,21 +1,29 @@ - + {{if $notself}} - {{/if}} -

{{$field.6}}
- {{if $field.2 === 1}}{{/if}} - {{if $field.2 === 0}}{{/if}} + +
+
+ {{if $self || !$field.5 }} - +
+ + +
{{/if}} {{if $notself && $field.5}} +
- {{if $field.3}}{{else}}{{/if}} + +
+ + {{*if $field.3}}{{else}}{{/if*}} {{/if}}
diff --git a/view/tpl/settings_permcats.tpl b/view/tpl/settings_permcats.tpl index bbbd41669..4d99bf590 100644 --- a/view/tpl/settings_permcats.tpl +++ b/view/tpl/settings_permcats.tpl @@ -20,25 +20,29 @@
-
+
{{$permnote}}
- - - - - {{foreach $perms as $prm}} - {{include file="field_acheckbox.tpl" field=$prm}} - {{/foreach}} -
{{$me}}
+ +
+ {{foreach $perms as $prm}} + {{include file="field_checkbox.tpl" field=$prm}} + {{/foreach}} +
+ + {{if $hidden_perms}} + {{foreach $hidden_perms as $prm}} + + {{/foreach}} + {{/if}}