From 158028a0ac00e388347ac366c88ad07c0fe4bfb9 Mon Sep 17 00:00:00 2001 From: Friendika Date: Tue, 1 Nov 2011 20:29:55 -0700 Subject: [PATCH] first cut friend suggestions --- include/socgraph.php | 20 +++++++++++++++++++- mod/suggest.php | 38 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 57 insertions(+), 1 deletion(-) create mode 100644 mod/suggest.php diff --git a/include/socgraph.php b/include/socgraph.php index c81c7b6952..04e9a9a64b 100644 --- a/include/socgraph.php +++ b/include/socgraph.php @@ -159,4 +159,22 @@ function common_friends($uid,$cid) { return $r; -} \ No newline at end of file +} + + + +function suggestion_query($uid, $start = 0, $limit = 40) { + + $r = q("SELECT count(glink.gcid) as `total`, gcontact.* from gcontact + left join glink on glink.gcid = gcontact.id + where uid = %d and not gcontact.nurl in ( select nurl from contact where uid = %d) + group by glink.gcid order by total desc limit %d, %d ", + intval($uid), + intval($uid), + intval($start), + intval($limit) + ); + + return $r; + +} diff --git a/mod/suggest.php b/mod/suggest.php new file mode 100644 index 0000000000..f8b8981263 --- /dev/null +++ b/mod/suggest.php @@ -0,0 +1,38 @@ +' . t('Friend Suggestions') . ''; + + + $r = suggestion_query(local_user()); + + if(! count($r)) { + $o .= t('No suggestions. This works best when you have more than one contact/friend.'); + return $o; + } + + $tpl = get_markup_template('common_friends.tpl'); + + foreach($r as $rr) { + + $o .= replace_macros($tpl,array( + '$url' => $rr['url'], + '$name' => $rr['name'], + '$photo' => $rr['photo'], + '$tags' => '' + )); + } + + $o .= cleardiv(); +// $o .= paginate($a); + return $o; +}