aboutsummaryrefslogtreecommitdiffstats
path: root/Zotlabs
diff options
context:
space:
mode:
Diffstat (limited to 'Zotlabs')
-rw-r--r--Zotlabs/Access/PermissionRoles.php10
-rw-r--r--Zotlabs/Access/Permissions.php12
-rw-r--r--Zotlabs/Module/Permcat.php61
3 files changed, 78 insertions, 5 deletions
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 @@
+<?php
+
+namespace Zotlabs\Module;
+
+use \Zotlabs\Access as Zaccess;
+
+class Permcat extends \Zotlabs\Web\Controller {
+
+ private $permcats = [];
+
+ public function init() {
+ if(! local_channel())
+ return;
+
+ $name = 'default';
+ $localname = t('default','permcat');
+
+ $perms = Zaccess\Permissions::FilledAutoPerms(local_channel());
+ if(! $perms) {
+ $role = get_pconfig(local_channel(),'system','permissions_role');
+ if($role) {
+ $x = Zaccess\PermissionRoles::role_perms($role);
+ $perms = Zaccess\Permissions::FilledPerms($x['perms_connect']);
+ }
+ if(! $perms) {
+ $perms = Zaccess\Permissions::FilledPerms([]);
+ }
+ }
+
+ $this->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