diff options
author | Friendika <info@friendika.com> | 2011-10-26 12:51:08 -0700 |
---|---|---|
committer | Friendika <info@friendika.com> | 2011-10-26 12:51:08 -0700 |
commit | 1aba538c96628468b84136386496ccc69050e810 (patch) | |
tree | 102830d438afcc8552db79a9284dc1555c8f9247 /mod/acl.php | |
parent | 9f5d7b254b4edef7e7d2ffa14eb7c3c03ea516fe (diff) | |
parent | 6a8b96709e13b04a0657c25b4538c160e2118131 (diff) | |
download | volse-hubzilla-1aba538c96628468b84136386496ccc69050e810.tar.gz volse-hubzilla-1aba538c96628468b84136386496ccc69050e810.tar.bz2 volse-hubzilla-1aba538c96628468b84136386496ccc69050e810.zip |
Merge branch 'pull'
Diffstat (limited to 'mod/acl.php')
-rw-r--r-- | mod/acl.php | 115 |
1 files changed, 66 insertions, 49 deletions
diff --git a/mod/acl.php b/mod/acl.php index f2d2456a6..07ca096e5 100644 --- a/mod/acl.php +++ b/mod/acl.php @@ -10,73 +10,90 @@ function acl_init(&$a){ $start = (x($_POST,'start')?$_POST['start']:0); $count = (x($_POST,'count')?$_POST['count']:100); $search = (x($_POST,'search')?$_POST['search']:""); + $type = (x($_POST,'type')?$_POST['type']:""); + if ($search!=""){ $sql_extra = "AND `name` LIKE '%%".dbesc($search)."%%'"; + $sql_extra2 = "AND (`name` LIKE '%%".dbesc($search)."%%' OR `nick` LIKE '%%".dbesc($search)."%%')"; } // count groups and contacts - $r = q("SELECT COUNT(`id`) AS g FROM `group` WHERE `deleted` = 0 AND `uid` = %d $sql_extra", - intval(local_user()) - ); - $group_count = (int)$r[0]['g']; - $r = q("SELECT COUNT(`id`) AS c FROM `contact` - WHERE `uid` = %d AND `self` = 0 - AND `blocked` = 0 AND `pending` = 0 - AND `notify` != '' $sql_extra" , - intval(local_user()) - ); - $contact_count = (int)$r[0]['c']; + if ($type=='' || $type=='g'){ + $r = q("SELECT COUNT(`id`) AS g FROM `group` WHERE `deleted` = 0 AND `uid` = %d $sql_extra", + intval(local_user()) + ); + $group_count = (int)$r[0]['g']; + } else { + $group_count = 0; + } + + if ($type=='' || $type=='c'){ + $r = q("SELECT COUNT(`id`) AS c FROM `contact` + WHERE `uid` = %d AND `self` = 0 + AND `blocked` = 0 AND `pending` = 0 + AND `notify` != '' $sql_extra" , + intval(local_user()) + ); + $contact_count = (int)$r[0]['c']; + } else { + $contact_count = 0; + } $tot = $group_count+$contact_count; $groups = array(); $contacts = array(); - $r = q("SELECT `group`.`id`, `group`.`name`, GROUP_CONCAT(DISTINCT `group_member`.`contact-id` SEPARATOR ',') as uids - FROM `group`,`group_member` - WHERE `group`.`deleted` = 0 AND `group`.`uid` = %d - AND `group_member`.`gid`=`group`.`id` - $sql_extra - GROUP BY `group`.`id` - ORDER BY `group`.`name` - LIMIT %d,%d", - intval(local_user()), - intval($start), - intval($count) - ); - - - foreach($r as $g){ - $groups[] = array( - "type" => "g", - "photo" => "images/default-group-mm.png", - "name" => $g['name'], - "id" => intval($g['id']), - "uids" => array_map("intval", explode(",",$g['uids'])), - "link" => '' + if ($type=='' || $type=='g'){ + + $r = q("SELECT `group`.`id`, `group`.`name`, GROUP_CONCAT(DISTINCT `group_member`.`contact-id` SEPARATOR ',') as uids + FROM `group`,`group_member` + WHERE `group`.`deleted` = 0 AND `group`.`uid` = %d + AND `group_member`.`gid`=`group`.`id` + $sql_extra + GROUP BY `group`.`id` + ORDER BY `group`.`name` + LIMIT %d,%d", + intval(local_user()), + intval($start), + intval($count) ); + + + foreach($r as $g){ + $groups[] = array( + "type" => "g", + "photo" => "images/default-group-mm.png", + "name" => $g['name'], + "id" => intval($g['id']), + "uids" => array_map("intval", explode(",",$g['uids'])), + "link" => '' + ); + } } + if ($type=='' || $type=='c'){ - $r = q("SELECT `id`, `name`, `micro`, `network`, `url` FROM `contact` - WHERE `uid` = %d AND `self` = 0 AND `blocked` = 0 AND `pending` = 0 AND `notify` != '' - $sql_extra - ORDER BY `name` ASC ", - intval(local_user()) - ); - foreach($r as $g){ - $contacts[] = array( - "type" => "c", - "photo" => $g['micro'], - "name" => $g['name'], - "id" => intval($g['id']), - "network" => $g['network'], - "link" => $g['url'], + $r = q("SELECT `id`, `name`, `nick`, `micro`, `network`, `url` FROM `contact` + WHERE `uid` = %d AND `self` = 0 AND `blocked` = 0 AND `pending` = 0 AND `notify` != '' + $sql_extra2 + ORDER BY `name` ASC ", + intval(local_user()) ); + foreach($r as $g){ + $contacts[] = array( + "type" => "c", + "photo" => $g['micro'], + "name" => $g['name'], + "id" => intval($g['id']), + "network" => $g['network'], + "link" => $g['url'], + "nick" => $g['nick'], + ); + } + } - - $items = array_merge($groups, $contacts); |