]> git.mxchange.org Git - friendica.git/blobdiff - include/socgraph.php
Merge https://github.com/friendica/friendica into pull
[friendica.git] / include / socgraph.php
index 84cfe4468a50223777c0e2849876f70842198837..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) {