From b2bae867d02b62708e09e5abf0ebd03a4d2b095e Mon Sep 17 00:00:00 2001 From: zotlabs Date: Tue, 7 Feb 2017 16:08:27 -0800 Subject: more background work for permcat support --- Zotlabs/Access/PermissionRoles.php | 10 +++--- Zotlabs/Access/Permissions.php | 12 +++++++ Zotlabs/Module/Permcat.php | 61 +++++++++++++++++++++++++++++++++++ vendor/composer/autoload_classmap.php | 2 -- view/js/mod_connedit.js | 23 ++++++++++++- 5 files changed, 100 insertions(+), 8 deletions(-) create mode 100644 Zotlabs/Module/Permcat.php diff --git a/Zotlabs/Access/PermissionRoles.php b/Zotlabs/Access/PermissionRoles.php index d7e162197..dd9a49d05 100644 --- a/Zotlabs/Access/PermissionRoles.php +++ b/Zotlabs/Access/PermissionRoles.php @@ -281,22 +281,22 @@ class PermissionRoles { $permcats = [ [ 'follower', t('follower','permcat'), - [ 'view_stream','view_profile','view_contacts','view_storage','view_pages', + [ 'view_stream','view_profile','view_contacts','view_storage','view_pages','view_wiki', 'post_like' ] ], [ 'contributor', t('contributor','permcat'), - [ 'view_stream','view_profile','view_contacts','view_storage','view_pages', - 'post_wall','post_comments','post_like','tag_deliver','chat' ] + [ 'view_stream','view_profile','view_contacts','view_storage','view_pages','view_wiki', + 'post_wall','post_comments','write_wiki','post_like','tag_deliver','chat' ] ], [ 'trusted', t('trusted','permcat'), [ 'view_stream','view_profile','view_contacts','view_storage','view_pages', - 'write_storage','post_wall','post_comments','post_like','tag_deliver', + 'write_storage','post_wall','write_pages','write_wiki','post_comments','post_like','tag_deliver', 'chat', 'republish' ] ], [ 'moderator', t('moderator','permcat'), [ 'view_stream','view_profile','view_contacts','view_storage','view_pages', - 'write_storage','post_wall','post_comments','post_like','tag_deliver', + 'write_storage','post_wall','wite_pages','write_wiki','post_comments','post_like','tag_deliver', 'chat', 'republish' ] ] ]; diff --git a/Zotlabs/Access/Permissions.php b/Zotlabs/Access/Permissions.php index 81408f122..b4b2e4d44 100644 --- a/Zotlabs/Access/Permissions.php +++ b/Zotlabs/Access/Permissions.php @@ -106,6 +106,18 @@ class Permissions { } + static public function OPerms($arr) { + $ret = []; + if($arr) { + foreach($arr as $k => $v) { + $ret[] = [ 'name' => $k, 'value' => $v ]; + } + } + return $ret; + } + + + static public function FilledAutoperms($channel_id) { if(! intval(get_pconfig($channel_id,'system','autoperms'))) return false; diff --git a/Zotlabs/Module/Permcat.php b/Zotlabs/Module/Permcat.php new file mode 100644 index 000000000..e118f8aee --- /dev/null +++ b/Zotlabs/Module/Permcat.php @@ -0,0 +1,61 @@ +permcats[] = [ + 'name' => $name, + 'localname' => $localname, + 'perms' => Zaccess\Permissions::Operms($perms) + ]; + + + $p = Zaccess\PermissionRoles::permcats(local_channel()); + if($p) { + for($x = 0; $x < count($p); $x++) { + $this->permcats[] = [ + 'name' => $p[$x][0], + 'localname' => $p[$x][1], + 'perms' => Zaccess\Permissions::Operms(Zaccess\Permissions::FilledPerms($p[$x][2])) + ]; + } + } + + if(argc() > 1 && $this->permcats) { + foreach($this->permcats as $permcat) { + if(strcasecmp($permcat['name'],argv(1)) === 0) { + json_return_and_die($permcat); + } + } + json_return_and_die(['error' => true]); + } + + json_return_and_die($this->permcats); + + } + +} \ No newline at end of file diff --git a/vendor/composer/autoload_classmap.php b/vendor/composer/autoload_classmap.php index ad3291349..54b09f68b 100644 --- a/vendor/composer/autoload_classmap.php +++ b/vendor/composer/autoload_classmap.php @@ -450,7 +450,6 @@ return array( 'Zotlabs\\Module\\Events' => $baseDir . '/Zotlabs/Module/Events.php', 'Zotlabs\\Module\\Fbrowser' => $baseDir . '/Zotlabs/Module/Fbrowser.php', 'Zotlabs\\Module\\Feed' => $baseDir . '/Zotlabs/Module/Feed.php', - 'Zotlabs\\Module\\Ffsapi' => $baseDir . '/Zotlabs/Module/Ffsapi.php', 'Zotlabs\\Module\\Fhublocs' => $baseDir . '/Zotlabs/Module/Fhublocs.php', 'Zotlabs\\Module\\File_upload' => $baseDir . '/Zotlabs/Module/File_upload.php', 'Zotlabs\\Module\\Filer' => $baseDir . '/Zotlabs/Module/Filer.php', @@ -494,7 +493,6 @@ return array( 'Zotlabs\\Module\\Oep' => $baseDir . '/Zotlabs/Module/Oep.php', 'Zotlabs\\Module\\Oexchange' => $baseDir . '/Zotlabs/Module/Oexchange.php', 'Zotlabs\\Module\\Online' => $baseDir . '/Zotlabs/Module/Online.php', - 'Zotlabs\\Module\\Opensearch' => $baseDir . '/Zotlabs/Module/Opensearch.php', 'Zotlabs\\Module\\Page' => $baseDir . '/Zotlabs/Module/Page.php', 'Zotlabs\\Module\\Pconfig' => $baseDir . '/Zotlabs/Module/Pconfig.php', 'Zotlabs\\Module\\Pdledit' => $baseDir . '/Zotlabs/Module/Pdledit.php', diff --git a/view/js/mod_connedit.js b/view/js/mod_connedit.js index 252ed9e7c..d750f3a2f 100644 --- a/view/js/mod_connedit.js +++ b/view/js/mod_connedit.js @@ -1,6 +1,7 @@ $(document).ready(function() { - $('form').areYouSure({'addRemoveFieldsMarksDirty':true, 'message': aStr['leavethispage'] }); // Warn user about unsaved settings + // Warn member about unsaved settings + $('form').areYouSure({'addRemoveFieldsMarksDirty':true, 'message': aStr['leavethispage'] }); if(typeof(after_following) !== 'undefined' && after_following) { if(typeof(connectDefaultShare) !== 'undefined') @@ -102,3 +103,23 @@ function connectFullShare() { $('#me_id_perms_republish').attr('checked','checked'); $('#me_id_perms_post_like').attr('checked','checked'); } + +function loadAbookRole(name) { + + if(! name) + name = 'default'; + + $('.abook-edit-me').each(function() { + if(! $(this).is(':disabled')) + $(this).removeAttr('checked'); + }); + + $.get('permcat/' + name, function(data) { + $(data.perms).each(function() { + if(this.value) + $('#me_id_perms_' + this.name).attr('checked','checked'); + }); + }); +} + + -- cgit v1.2.3