api: allow group member list to use a group name or id

This commit is contained in:
zotlabs 2016-11-13 23:28:03 -08:00
parent 3c302bae5a
commit cf5c803fe0

View File

@ -47,8 +47,6 @@
return false; return false;
} }
require_once('include/channel.php');
json_return_and_die(identity_basic_export(api_user(),(($_REQUEST['posts']) ? intval($_REQUEST['posts']) : 0 ))); json_return_and_die(identity_basic_export(api_user(),(($_REQUEST['posts']) ? intval($_REQUEST['posts']) : 0 )));
} }
@ -215,30 +213,34 @@
killme(); killme();
} }
function api_group_members($type) { function api_group_members($type) {
if(api_user() === false) if(api_user() === false)
return false; return false;
$r = null;
if($_REQUEST['group_id']) { if($_REQUEST['group_id']) {
$r = q("select * from groups where uid = %d and id = %d limit 1", $r = q("select * from groups where uid = %d and id = %d limit 1",
intval(api_user()), intval(api_user()),
intval($_REQUEST['group_id']) intval($_REQUEST['group_id'])
); );
}
elseif($_REQUEST['group_name']) {
$r = q("select * from groups where uid = %d and gname = '%s' limit 1",
intval(api_user()),
dbesc($_REQUEST['group_name'])
);
}
if($r) { if($r) {
$x = q("select * from group_member left join xchan on group_member.xchan = xchan.xchan_hash $x = q("select * from group_member left join xchan on group_member.xchan = xchan.xchan_hash
left join abook on abook_xchan = xchan_hash where gid = %d", left join abook on abook_xchan = xchan_hash where gid = %d",
intval($_REQUEST['group_id']) intval($r[0]['id'])
); );
json_return_and_die($x); json_return_and_die($x);
} }
} }
}
function api_group($type) { function api_group($type) {
if(api_user() === false) if(api_user() === false)