diff --git a/include/items.php b/include/items.php index ad121bbf5..2af2b5f55 100644 --- a/include/items.php +++ b/include/items.php @@ -1263,7 +1263,7 @@ function consume_feed($xml,$importer,&$contact, &$hub, $datedir = 0, $pass = 0) $when = datetime_convert('UTC','UTC','now','Y-m-d H:i:s'); } if($deleted && is_array($contact)) { - $r = q("SELECT `item`.*, `contact`.`self` FROM `item` left join `contact` on `item`.`contact-id` = `contact`.id` + $r = q("SELECT `item`.*, `contact`.`self` FROM `item` left join `contact` on `item`.`contact-id` = `contact`.`id` WHERE `uri` = '%s' AND `item`.`uid` = %d AND `contact-id` = %d LIMIT 1", dbesc($uri), intval($importer['uid']), diff --git a/include/socgraph.php b/include/socgraph.php index 3e9c00633..c81c7b695 100644 --- a/include/socgraph.php +++ b/include/socgraph.php @@ -123,4 +123,40 @@ function poco_load($cid,$uid = 0,$url = null) { intval($uid) ); +} + + +function count_common_friends($uid,$cid) { + + $r = q("SELECT count(*) as `total` + 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 ) ", + intval($cid), + intval($uid), + intval($uid), + intval($cid) + ); + + if(count($r)) + return $r[0]['total']; + return 0; + +} + + +function common_friends($uid,$cid) { + + $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 ) ", + intval($cid), + intval($uid), + intval($uid), + intval($cid) + ); + + return $r; + } \ No newline at end of file diff --git a/mod/common.php b/mod/common.php new file mode 100644 index 000000000..852388c14 --- /dev/null +++ b/mod/common.php @@ -0,0 +1,61 @@ +argc > 1) + $cid = intval($a->argv[1]); + if(! $cid) + return; + + $c = q("select name, url, photo from contact where id = %d and uid = %d limit 1", + intval($cid), + intval(local_user()) + ); + + $a->page['aside'] .= '
'; + + + if(! count($c)) + return; + + $o .= '