]> git.mxchange.org Git - friendica.git/blobdiff - include/socgraph.php
Merge https://github.com/friendica/friendica into pull
[friendica.git] / include / socgraph.php
index b9f53d6a6d0c0862d49814547d1f7d998363fdc4..87a7543de783e27c3d045dade8a3b5aeeb120691 100644 (file)
@@ -150,7 +150,8 @@ function common_friends($uid,$cid) {
        $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),
@@ -161,6 +162,37 @@ function common_friends($uid,$cid) {
 
 }
 
+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) {
@@ -171,9 +203,11 @@ 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)
        );