diff options
author | zotlabs <mike@macgirvin.com> | 2017-02-07 16:43:00 -0800 |
---|---|---|
committer | zotlabs <mike@macgirvin.com> | 2017-02-07 16:43:00 -0800 |
commit | a6160e30262107ff73c253ecc46fffaa2986f79b (patch) | |
tree | ea8c1d57ce77d2d81caa905f94a60fd1a3e562a5 /Zotlabs | |
parent | ecca69442d28cc8f328809f0589c79159639fefc (diff) | |
download | volse-hubzilla-a6160e30262107ff73c253ecc46fffaa2986f79b.tar.gz volse-hubzilla-a6160e30262107ff73c253ecc46fffaa2986f79b.tar.bz2 volse-hubzilla-a6160e30262107ff73c253ecc46fffaa2986f79b.zip |
move permcat library functions to Zlib
Diffstat (limited to 'Zotlabs')
-rw-r--r-- | Zotlabs/Lib/Permcat.php | 63 | ||||
-rw-r--r-- | Zotlabs/Module/Permcat.php | 52 |
2 files changed, 71 insertions, 44 deletions
diff --git a/Zotlabs/Lib/Permcat.php b/Zotlabs/Lib/Permcat.php new file mode 100644 index 000000000..d677cd704 --- /dev/null +++ b/Zotlabs/Lib/Permcat.php @@ -0,0 +1,63 @@ +<?php + +namespace Zotlabs\Lib; + +use \Zotlabs\Access as Zaccess; + +class Permcat { + + private $permcats = []; + + public function __construct($channel_id) { + + $name = 'default'; + $localname = t('default','permcat'); + + $perms = Zaccess\Permissions::FilledAutoPerms($channel_id); + if(! $perms) { + $role = get_pconfig($channel_id,'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($channel_id); + 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])) + ]; + } + } + } + + + public function listing() { + return $this->permcats; + } + + public function fetch($name) { + if($name && $this->permcats) { + foreach($this->permcats as $permcat) { + if(strcasecmp($permcat['name'],$name) === 0) { + return $permcat; + } + } + } + return ['error' => true]; + } + +}
\ No newline at end of file diff --git a/Zotlabs/Module/Permcat.php b/Zotlabs/Module/Permcat.php index e118f8aee..064c9cefb 100644 --- a/Zotlabs/Module/Permcat.php +++ b/Zotlabs/Module/Permcat.php @@ -2,7 +2,7 @@ namespace Zotlabs\Module; -use \Zotlabs\Access as Zaccess; +use \Zotlabs\Lib as Zlib; class Permcat extends \Zotlabs\Web\Controller { @@ -12,50 +12,14 @@ class Permcat extends \Zotlabs\Web\Controller { 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); + $permcat = new Zlib\Permcat(local_channel()); + + if(argc() > 1) + json_return_and_die($permcat->fetch(argv(1))); + + json_return_and_die($permcat->listing()); } + }
\ No newline at end of file |