diff options
author | zotlabs <mike@macgirvin.com> | 2016-11-14 20:59:10 -0800 |
---|---|---|
committer | zotlabs <mike@macgirvin.com> | 2016-11-14 20:59:10 -0800 |
commit | 3e286f4f196584bc6a4db6bc9dc2eb3e655a1d3c (patch) | |
tree | 6f3d542d0dfa82d70038639abddf05e43937ce3c | |
parent | e0a83b4b94d50a69d787ba7484683941238596ab (diff) | |
download | volse-hubzilla-3e286f4f196584bc6a4db6bc9dc2eb3e655a1d3c.tar.gz volse-hubzilla-3e286f4f196584bc6a4db6bc9dc2eb3e655a1d3c.tar.bz2 volse-hubzilla-3e286f4f196584bc6a4db6bc9dc2eb3e655a1d3c.zip |
update api perm_allowed to return all perms if no perm specified
-rw-r--r-- | include/api_zot.php | 21 |
1 files changed, 16 insertions, 5 deletions
diff --git a/include/api_zot.php b/include/api_zot.php index 49a3f1077..ff3bc6dc5 100644 --- a/include/api_zot.php +++ b/include/api_zot.php @@ -311,9 +311,6 @@ return false; $perm = ((array_key_exists('perm',$_REQUEST)) ? $_REQUEST['perm'] : ''); - // possibly should return all perms - if(! $perm) - return false; if(array_key_exists('abook_id',$_REQUEST) && intval($_REQUEST['abook_id'])) { $r = q("select abook_xchan as xchan_hash from abook where abook_id = %d and abook_channel = %d limit 1", @@ -324,10 +321,24 @@ else { $r = xchan_fetch($_REQUEST); } - if($r) - $x = [ [ 'perm' => $perm, 'allowed' => perm_is_allowed(api_user(), $r[0]['xchan_hash'], $perm)] ]; + $x = false; + + if($r) { + if($perm) + $x = [ [ 'perm' => $perm, 'allowed' => perm_is_allowed(api_user(), $r[0]['xchan_hash'], $perm)] ]; + else { + $x = []; + $p = get_all_perms(api_user(),$r[0]['xchan_hash']); + if($p) { + foreach($p as $k => $v) + $x[] = [ 'perm' => $k, 'allowed' => $v ]; + } + } + } + json_return_and_die($x); + } function red_item_new($type) { |