shuffle results of remote_common_friends widget
This commit is contained in:
parent
1b1f56f556
commit
a42a475e10
|
@ -146,6 +146,12 @@ function common_friends_visitor_widget($profile_uid) {
|
|||
$cid = local_user();
|
||||
else {
|
||||
if(get_my_url()) {
|
||||
$r = q("select id from contact where nurl = '%s' and uid = %d limit 1",
|
||||
dbesc(normalise_link(get_my_url()))
|
||||
);
|
||||
if(count($r))
|
||||
$cid = $r[0]['id'];
|
||||
else {
|
||||
$r = q("select id from gcontact where nurl = '%s' limit 1",
|
||||
dbesc(normalise_link(get_my_url()))
|
||||
);
|
||||
|
@ -153,6 +159,7 @@ function common_friends_visitor_widget($profile_uid) {
|
|||
$zcid = $r[0]['id'];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if($cid == 0 && $zcid == 0)
|
||||
return;
|
||||
|
@ -167,9 +174,9 @@ function common_friends_visitor_widget($profile_uid) {
|
|||
return;
|
||||
|
||||
if($cid)
|
||||
$r = common_friends($profile_uid,$cid,5);
|
||||
$r = common_friends($profile_uid,$cid,5,true);
|
||||
else
|
||||
$r = common_friends_zcid($profile_uid,$zcid);
|
||||
$r = common_friends_zcid($profile_uid,$zcid,5,true);
|
||||
|
||||
return replace_macros(get_markup_template('remote_friends_common.tpl'), array(
|
||||
'$desc' => sprintf( tt("%d friend in common", "%d friends in common", $t), $t),
|
||||
|
|
|
@ -182,13 +182,18 @@ function count_common_friends($uid,$cid) {
|
|||
}
|
||||
|
||||
|
||||
function common_friends($uid,$cid,$limit=9999) {
|
||||
function common_friends($uid,$cid,$limit=9999,$shuffle = false) {
|
||||
|
||||
if($shuffle)
|
||||
$sql_extra = " order by rand() ";
|
||||
else
|
||||
$sql_extra = " order by `gcontact`.`name` asc ";
|
||||
|
||||
$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 limit 0, %d",
|
||||
sql_extra limit 0, %d",
|
||||
intval($cid),
|
||||
intval($uid),
|
||||
intval($uid),
|
||||
|
@ -217,13 +222,18 @@ function count_common_friends_zcid($uid,$zcid) {
|
|||
|
||||
}
|
||||
|
||||
function common_friends_zcid($uid,$zcid,$limit = 6) {
|
||||
function common_friends_zcid($uid,$zcid,$limit = 9999,$shuffle) {
|
||||
|
||||
if($shuffle)
|
||||
$sql_extra = " order by rand() ";
|
||||
else
|
||||
$sql_extra = " order by `gcontact`.`name` asc ";
|
||||
|
||||
$r = q("SELECT `gcontact`.*
|
||||
FROM `glink` left join `gcontact` on `glink`.`gcid` = `gcontact`.`id`
|
||||
where `glink`.`zcid` = %d
|
||||
and `gcontact`.`nurl` in (select nurl from contact where uid = %d and self = 0 )
|
||||
order by `gcontact`.`name` asc limit 0, %d",
|
||||
$sql_extra limit 0, %d",
|
||||
intval($zcid),
|
||||
intval($uid),
|
||||
intval($limit)
|
||||
|
|
Loading…
Reference in New Issue
Block a user