2 /* ACL selector json backend */
3 require_once("include/acl_selectors.php");
5 function acl_init(&$a){
10 $start = (x($_POST,'start')?$_POST['start']:0);
11 $count = (x($_POST,'count')?$_POST['count']:100);
12 $search = (x($_POST,'search')?$_POST['search']:"");
15 $sql_extra = "AND `name` LIKE '%%".dbesc($search)."%%'";
18 // count groups and contacts
19 $r = q("SELECT COUNT(`id`) AS g FROM `group` WHERE `deleted` = 0 AND `uid` = %d $sql_extra",
22 $group_count = (int)$r[0]['g'];
23 $r = q("SELECT COUNT(`id`) AS c FROM `contact`
24 WHERE `uid` = %d AND `self` = 0
25 AND `blocked` = 0 AND `pending` = 0
26 AND `notify` != '' $sql_extra" ,
29 $contact_count = (int)$r[0]['c'];
31 $tot = $group_count+$contact_count;
36 $r = q("SELECT `group`.`id`, `group`.`name`, GROUP_CONCAT(DISTINCT `group_member`.`contact-id` SEPARATOR ',') as uids
37 FROM `group`,`group_member`
38 WHERE `group`.`deleted` = 0 AND `group`.`uid` = %d
39 AND `group_member`.`gid`=`group`.`id`
42 ORDER BY `group`.`name`
53 "photo" => "images/default-group-mm.png",
55 "id" => intval($g['id']),
56 "uids" => array_map("intval", explode(",",$g['uids']))
61 $r = q("SELECT `id`, `name`, `micro`, `network` FROM `contact`
62 WHERE `uid` = %d AND `self` = 0 AND `blocked` = 0 AND `pending` = 0 AND `notify` != ''
64 ORDER BY `name` ASC ",
70 "photo" => $g['micro'],
72 "id" => intval($g['id']),
73 "network" => $g['network']
80 $items = array_merge($groups, $contacts);