diff options
author | redmatrix <git@macgirvin.com> | 2016-07-18 21:37:34 -0700 |
---|---|---|
committer | redmatrix <git@macgirvin.com> | 2016-07-18 21:37:34 -0700 |
commit | b63165b6e0d856848b20d184783bfdf358210f9b (patch) | |
tree | cdfb1bf415c1d99f52d0d835f84aff147f3e0dac /Zotlabs/Access/Permissions.php | |
parent | 32ce790717f39ecb6cbd7371b631753652c77ee3 (diff) | |
download | volse-hubzilla-b63165b6e0d856848b20d184783bfdf358210f9b.tar.gz volse-hubzilla-b63165b6e0d856848b20d184783bfdf358210f9b.tar.bz2 volse-hubzilla-b63165b6e0d856848b20d184783bfdf358210f9b.zip |
more perms work (a lot more)
Diffstat (limited to 'Zotlabs/Access/Permissions.php')
-rw-r--r-- | Zotlabs/Access/Permissions.php | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/Zotlabs/Access/Permissions.php b/Zotlabs/Access/Permissions.php index b389fc229..61ea51a48 100644 --- a/Zotlabs/Access/Permissions.php +++ b/Zotlabs/Access/Permissions.php @@ -70,5 +70,47 @@ class Permissions { } + // converts [ 0 => 'view_stream', ... ] + // to [ 'view_stream' => 1 ] + // for any permissions in $arr; + // Undeclared permissions are set to 0 + + static public function FilledPerms($arr) { + $everything = self::Perms(); + $ret = []; + foreach($everything as $k => $v) { + if(in_array($k,$arr)) + $ret[$k] = 1; + else + $ret[$k] = 0; + } + return $ret; + + } + static public function FilledAutoperms($channel_id) { + if(! intval(get_pconfig($channel_id,'system','autoperms'))) + return false; + + $arr = []; + $r = q("select * from pconfig where uid = %d and cat = 'autoperms'", + intval($channel_id) + ); + if($r) { + foreach($r as $rr) { + $arr[$rr['k']] = $arr[$rr['v']]; + } + } + return $arr; + } + + static public function PermsCompare($p1,$p2) { + foreach($p1 as $k => $v) { + if(! array_key_exists($k,$p2)) + return false; + if($p1[$k] != $p2[$k]) + return false; + } + return true; + } }
\ No newline at end of file |