aboutsummaryrefslogtreecommitdiffstats
path: root/Zotlabs/Module/Permcat.php
diff options
context:
space:
mode:
authorzotlabs <mike@macgirvin.com>2017-02-07 16:08:27 -0800
committerzotlabs <mike@macgirvin.com>2017-02-07 16:08:27 -0800
commitb2bae867d02b62708e09e5abf0ebd03a4d2b095e (patch)
tree10e0c03f1a054ffd262c70a8860474a9b6977b0f /Zotlabs/Module/Permcat.php
parent1cef3f15d5174636b59c86bb816a0009940201ef (diff)
downloadvolse-hubzilla-b2bae867d02b62708e09e5abf0ebd03a4d2b095e.tar.gz
volse-hubzilla-b2bae867d02b62708e09e5abf0ebd03a4d2b095e.tar.bz2
volse-hubzilla-b2bae867d02b62708e09e5abf0ebd03a4d2b095e.zip
more background work for permcat support
Diffstat (limited to 'Zotlabs/Module/Permcat.php')
-rw-r--r--Zotlabs/Module/Permcat.php61
1 files changed, 61 insertions, 0 deletions
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