$r = q("SELECT `gcontact`.*
FROM `glink` left join `gcontact` on `glink`.`gcid` = `gcontact`.`id`
where `glink`.`cid` = %d and `glink`.`uid` = %d
- and `gcontact`.`nurl` in (select nurl from contact where uid = %d and self = 0 and id != %d ) ",
+ and `gcontact`.`nurl` in (select nurl from contact where uid = %d and self = 0 and id != %d )
+ order by `gcontact`.`name` asc ",
intval($cid),
intval($uid),
intval($uid),
}
+function count_all_friends($uid,$cid) {
+
+ $r = q("SELECT count(*) as `total`
+ FROM `glink` left join `gcontact` on `glink`.`gcid` = `gcontact`.`id`
+ where `glink`.`cid` = %d and `glink`.`uid` = %d ",
+ intval($cid),
+ intval($uid)
+ );
+
+ if(count($r))
+ return $r[0]['total'];
+ return 0;
+
+}
+
+
+function all_friends($uid,$cid,$start = 0, $limit = 80) {
+
+ $r = q("SELECT `gcontact`.*
+ FROM `glink` left join `gcontact` on `glink`.`gcid` = `gcontact`.`id`
+ where `glink`.`cid` = %d and `glink`.`uid` = %d
+ order by `gcontact`.`name` asc LIMIT %d, %d ",
+ intval($cid),
+ intval($uid),
+ intval($start),
+ intval($limit)
+ );
+
+ return $r;
+}
+
function suggestion_query($uid, $start = 0, $limit = 40) {
$r = q("SELECT count(glink.gcid) as `total`, gcontact.* from gcontact
left join glink on glink.gcid = gcontact.id
where uid = %d and not gcontact.nurl in ( select nurl from contact where uid = %d)
+ and not gcontact.id in ( select gcid from gcign where uid = %d )
group by glink.gcid order by total desc limit %d, %d ",
intval($uid),
intval($uid),
+ intval($uid),
intval($start),
intval($limit)
);