final touches - show friends in common with total strangers from different sites

This commit is contained in:
friendica 2012-05-01 21:22:27 -07:00
parent 1fab28c413
commit becdb1f508
2 changed files with 13 additions and 7 deletions

View file

@ -154,17 +154,22 @@ function common_friends_visitor_widget($profile_uid) {
} }
} }
if($zcid == 0) if($cid == 0 && $zcid == 0)
return; return;
require_once('include/socgraph.php'); require_once('include/socgraph.php');
if($cid)
$t = count_common_friends_zcid($profile_uid,$zcid); $t = count_common_friends($profile_uid,$cid);
else
$t = count_common_friends($profile_uid,$cid);
if(! $t) if(! $t)
return; 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( return replace_macros(get_markup_template('remote_friends_common.tpl'), array(
'$desc' => sprintf( tt("%d friend in common", "%d friends in common", $t), $t), '$desc' => sprintf( tt("%d friend in common", "%d friends in common", $t), $t),

View 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`.* $r = q("SELECT `gcontact`.*
FROM `glink` left join `gcontact` on `glink`.`gcid` = `gcontact`.`id` FROM `glink` left join `gcontact` on `glink`.`gcid` = `gcontact`.`id`
where `glink`.`cid` = %d and `glink`.`uid` = %d 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 ", order by `gcontact`.`name` asc limit 0, %d",
intval($cid), intval($cid),
intval($uid), intval($uid),
intval($uid), intval($uid),
intval($cid) intval($cid),
intval($limit)
); );
return $r; return $r;