diff options
author | Simon L'nu <simon.lnu@gmail.com> | 2012-05-02 12:49:00 -0400 |
---|---|---|
committer | Simon L'nu <simon.lnu@gmail.com> | 2012-05-02 12:49:00 -0400 |
commit | 02dc116a9c646ea5683b8df199a7ff492ae6cfcb (patch) | |
tree | ae81849bd1bcd92acd2040cb65e3b193ec5aabb8 /include | |
parent | b3680c0d266f06d2474cb45750b0486d246a8315 (diff) | |
parent | 6875f54647cbbdb66e6d570cbf357a8b83644fad (diff) | |
download | volse-hubzilla-02dc116a9c646ea5683b8df199a7ff492ae6cfcb.tar.gz volse-hubzilla-02dc116a9c646ea5683b8df199a7ff492ae6cfcb.tar.bz2 volse-hubzilla-02dc116a9c646ea5683b8df199a7ff492ae6cfcb.zip |
Merge branch 'master', remote-tracking branch 'remotes/upstream/master'
* remotes/upstream/master:
diabook-themes: more improvements in theme.php, add titles to bbcode under coment-box
diabook-theme: tryied to improve performance a bit
diabook-theme: fix footer/impressum
missing param
provide "service_class" identifier which will let us provide service_class limits such as number of FB friends, etc.
delineate the new profile changes from the rest of the text
how did that happen?
shuffle results of remote_common_friends widget
only validate once
perform basic validation
* master:
Diffstat (limited to 'include')
-rw-r--r-- | include/contact_widgets.php | 20 | ||||
-rw-r--r-- | include/socgraph.php | 18 |
2 files changed, 28 insertions, 10 deletions
diff --git a/include/contact_widgets.php b/include/contact_widgets.php index cfe27c5c9..bf3a86958 100644 --- a/include/contact_widgets.php +++ b/include/contact_widgets.php @@ -146,11 +146,19 @@ function common_friends_visitor_widget($profile_uid) { $cid = local_user(); else { if(get_my_url()) { - $r = q("select id from gcontact where nurl = '%s' limit 1", - dbesc(normalise_link(get_my_url())) + $r = q("select id from contact where nurl = '%s' and uid = %d limit 1", + dbesc(normalise_link(get_my_url())), + intval($profile_uid) ); if(count($r)) - $zcid = $r[0]['id']; + $cid = $r[0]['id']; + else { + $r = q("select id from gcontact where nurl = '%s' limit 1", + dbesc(normalise_link(get_my_url())) + ); + if(count($r)) + $zcid = $r[0]['id']; + } } } @@ -162,14 +170,14 @@ function common_friends_visitor_widget($profile_uid) { if($cid) $t = count_common_friends($profile_uid,$cid); else - $t = count_common_friends($profile_uid,$cid); + $t = count_common_friends_zcid($profile_uid,$zcid); if(! $t) 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), diff --git a/include/socgraph.php b/include/socgraph.php index a08d58074..35d754cad 100644 --- a/include/socgraph.php +++ b/include/socgraph.php @@ -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) |