]> git.mxchange.org Git - friendica.git/commitdiff
final touches - show friends in common with total strangers from different sites
authorfriendica <info@friendica.com>
Wed, 2 May 2012 04:22:27 +0000 (21:22 -0700)
committerfriendica <info@friendica.com>
Wed, 2 May 2012 04:22:27 +0000 (21:22 -0700)
include/contact_widgets.php
include/socgraph.php

index 3fd311e4a2f6aef5292db5c5220342875295b347..cfe27c5c9ba36997b4bb52e1583decd39360910b 100644 (file)
@@ -154,17 +154,22 @@ function common_friends_visitor_widget($profile_uid) {
                }
        }
 
-       if($zcid == 0)
+       if($cid == 0 && $zcid == 0)
                return; 
 
        require_once('include/socgraph.php');
 
-
-       $t = count_common_friends_zcid($profile_uid,$zcid);
+       if($cid)
+               $t = count_common_friends($profile_uid,$cid);
+       else
+               $t = count_common_friends($profile_uid,$cid);
        if(! $t)
                return;
 
-       $r = common_friends_zcid($profile_uid,$zcid);
+       if($cid)
+               $r = common_friends($profile_uid,$cid,5);
+       else
+               $r = common_friends_zcid($profile_uid,$zcid);
 
        return replace_macros(get_markup_template('remote_friends_common.tpl'), array(
                '$desc' =>  sprintf( tt("%d friend in common", "%d friends in common", $t), $t),
index cf00422560251117fc11d14db58468f4f92d5270..a08d58074187eead84b196a7263671c302a169ab 100644 (file)
@@ -182,17 +182,18 @@ function count_common_friends($uid,$cid) {
 }
 
 
-function common_friends($uid,$cid) {
+function common_friends($uid,$cid,$limit=9999) {
 
        $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 ) 
-               order by `gcontact`.`name` asc ",
+               order by `gcontact`.`name` asc limit 0, %d",
                intval($cid),
                intval($uid),
                intval($uid),
-               intval($cid)
+               intval($cid),
+               intval($limit)
        );
 
        return $r;