aboutsummaryrefslogtreecommitdiffstats
path: root/Zotlabs/Lib/Permcat.php
diff options
context:
space:
mode:
authorzotlabs <mike@macgirvin.com>2017-02-09 19:52:13 -0800
committerzotlabs <mike@macgirvin.com>2017-02-09 19:52:13 -0800
commit1fb37f93ccf4739a6f92f3f36c1ee4ec8ef66a07 (patch)
tree2fdf66b9da436e25510384a1670ae2e341f961fc /Zotlabs/Lib/Permcat.php
parentfce33402e74f7ff6066ef859e7801a9201db28e1 (diff)
downloadvolse-hubzilla-1fb37f93ccf4739a6f92f3f36c1ee4ec8ef66a07.tar.gz
volse-hubzilla-1fb37f93ccf4739a6f92f3f36c1ee4ec8ef66a07.tar.bz2
volse-hubzilla-1fb37f93ccf4739a6f92f3f36c1ee4ec8ef66a07.zip
more permissions optimisations
Diffstat (limited to 'Zotlabs/Lib/Permcat.php')
-rw-r--r--Zotlabs/Lib/Permcat.php52
1 files changed, 40 insertions, 12 deletions
diff --git a/Zotlabs/Lib/Permcat.php b/Zotlabs/Lib/Permcat.php
index 7988aff97..505ee2cfc 100644
--- a/Zotlabs/Lib/Permcat.php
+++ b/Zotlabs/Lib/Permcat.php
@@ -10,24 +10,52 @@ class Permcat {
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 = [];
+
+ // first check role perms for a perms_connect setting
+
+ $role = get_pconfig($channel_id,'system','permissions_role');
+ if($role) {
+ $x = Zaccess\PermissionRoles::role_perms($role);
+ if($x['perms_connect']) {
$perms = Zaccess\Permissions::FilledPerms($x['perms_connect']);
}
- if(! $perms) {
- $perms = Zaccess\Permissions::FilledPerms([]);
+ }
+
+ // if no role perms it may be a custom role, see if there any autoperms
+
+ if(! $perms) {
+ $perms = Zaccess\Permissions::FilledAutoPerms($channel_id);
+ }
+
+ // if no autoperms it may be a custom role with manual perms
+
+ if(! $perms) {
+ $r = q("select channel_hash from channel where channel_id = %d",
+ intval($channel_id)
+ );
+ if($r) {
+ $x = q("select * from abconfig where chan = %d and xchan = '%s' and cat = 'my_perms'",
+ intval($channel_id),
+ dbesc($r[0]['channel_hash'])
+ );
+ if($x) {
+ foreach($x as $xv) {
+ $perms[$xv['k']] = intval($xv['v']);
+ }
+ }
}
}
+ // nothing was found - create a filled permission array where all permissions are 0
+
+ if(! $perms) {
+ $perms = Zaccess\Permissions::FilledPerms([]);
+ }
+
$this->permcats[] = [
- 'name' => $name,
- 'localname' => $localname,
+ 'name' => 'default',
+ 'localname' => t('default','permcat'),
'perms' => Zaccess\Permissions::Operms($perms),
'system' => 1
];