blob: e118f8aee3280cfa4b415ca4eb70220d9a6cb3d5 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
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);
}
}
|