filter by contact type
This commit is contained in:
parent
bcb672e7ff
commit
155a09cfdf
1 changed files with 69 additions and 54 deletions
17
mod/acl.php
17
mod/acl.php
|
@ -10,6 +10,8 @@ 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)."%%'";
|
||||
|
@ -17,10 +19,16 @@ function acl_init(&$a){
|
|||
}
|
||||
|
||||
// count groups and contacts
|
||||
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
|
||||
|
@ -28,12 +36,17 @@ function acl_init(&$a){
|
|||
intval(local_user())
|
||||
);
|
||||
$contact_count = (int)$r[0]['c'];
|
||||
} else {
|
||||
$contact_count = 0;
|
||||
}
|
||||
|
||||
$tot = $group_count+$contact_count;
|
||||
|
||||
$groups = array();
|
||||
$contacts = array();
|
||||
|
||||
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
|
||||
|
@ -58,7 +71,9 @@ function acl_init(&$a){
|
|||
"link" => ''
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
if ($type=='' || $type=='c'){
|
||||
|
||||
$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` != ''
|
||||
|
@ -78,7 +93,7 @@ function acl_init(&$a){
|
|||
);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
$items = array_merge($groups, $contacts);
|
||||
|
|
Loading…
Reference in a new issue