aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/items.php2
-rw-r--r--include/socgraph.php36
-rw-r--r--mod/common.php61
-rw-r--r--mod/contacts.php5
-rw-r--r--view/common_friends.tpl12
-rw-r--r--view/contact_edit.tpl9
-rw-r--r--view/profile_vcard.tpl2
7 files changed, 125 insertions, 2 deletions
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 @@
+<?php
+
+require_once('include/socgraph.php');
+
+function common_content(&$a) {
+
+ $o = '';
+ if(! local_user()) {
+ notice( t('Permission denied.') . EOL);
+ return;
+ }
+
+ if($a->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'] .= '<div class="vcard">'
+ . '<div class="fn label">' . $c[0]['name'] . '</div>'
+ . '<div id="profile-photo-wrapper">'
+ . '<a href="/contacts/' . $cid . '"><img class="photo" width="175" height="175"
+ src="' . $c[0]['photo'] . '" alt="' . $c[0]['name'] . '" /></div>'
+ . '</div>';
+
+
+ if(! count($c))
+ return;
+
+ $o .= '<h2>' . t('Common Friends') . '</h2>';
+
+// $o .= '<h3>' . sprintf( t('You and %s'),$c[0]['name']) . '</h3>';
+
+
+ $r = common_friends(local_user(),$cid);
+
+ if(! count($r)) {
+ $o .= t('No friends in common.');
+ 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;
+}
diff --git a/mod/contacts.php b/mod/contacts.php
index 9bbcea07d..ecfbe6c2c 100644
--- a/mod/contacts.php
+++ b/mod/contacts.php
@@ -1,6 +1,7 @@
<?php
require_once('include/Contact.php');
+require_once('include/socgraph.php');
function contacts_init(&$a) {
if(! local_user())
@@ -265,6 +266,8 @@ function contacts_content(&$a) {
$nettype = '<div id="contact-edit-nettype">' . sprintf( t('Network type: %s'),network_to_name($r[0]['network'])) . '</div>';
+ $common = count_common_friends(local_user(),$r[0]['id']);
+ $common_text = (($common) ? sprintf( tt('%d friends in common','%d friends in common', $common),$common) : '');
$o .= replace_macros($tpl,array(
'$header' => t('Contact Editor'),
'$submit' => t('Submit'),
@@ -275,6 +278,8 @@ function contacts_content(&$a) {
'$lbl_rep2' => t('Occasionally your friends may wish to inquire about this person\'s online legitimacy.'),
'$lbl_rep3' => t('You may help them choose whether or not to interact with this person by providing a <em>reputation</em> to guide them.'),
'$lbl_rep4' => t('Please take a moment to elaborate on this selection if you feel it could be helpful to others.'),
+ '$common_text' => $common_text,
+ '$common_link' => $a->get_baseurl() . '/common/' . $r[0]['id'],
'$visit' => sprintf( t('Visit %s\'s profile [%s]'),$r[0]['name'],$r[0]['url']),
'$blockunblock' => t('Block/Unblock contact'),
'$ignorecont' => t('Ignore contact'),
diff --git a/view/common_friends.tpl b/view/common_friends.tpl
new file mode 100644
index 000000000..1f610d8c4
--- /dev/null
+++ b/view/common_friends.tpl
@@ -0,0 +1,12 @@
+<div class="profile-match-wrapper">
+ <div class="profile-match-photo">
+ <a href="$url">
+ <img src="$photo" alt="$name" width="80" height="80" title="$name [$url]" />
+ </a>
+ </div>
+ <div class="profile-match-break"></div>
+ <div class="profile-match-name">
+ <a href="$url" title="$name[$tags]">$name</a>
+ </div>
+ <div class="profile-match-end"></div>
+</div> \ No newline at end of file
diff --git a/view/contact_edit.tpl b/view/contact_edit.tpl
index 248140a6b..c2e3e36fb 100644
--- a/view/contact_edit.tpl
+++ b/view/contact_edit.tpl
@@ -19,6 +19,7 @@ $nettype
</div>
<div id="contact-edit-nav-wrapper" >
+
<div id="contact-edit-links" >
<a href="contacts/$contact_id/block" class="icon block" id="contact-edit-block-link" title="$block_text"></a>
<a href="contacts/$contact_id/ignore" class="icon no" id="contact-edit-ignore-link" title="$ignore_text"></a>
@@ -41,6 +42,14 @@ $nettype
</div>
<div id="contact-edit-end" ></div>
+
+ {{ if $common_text }}
+ <div id="contact-edit-common">
+ <a href="$common_link">$common_text</a>
+ </a>
+ {{ endif }}
+
+
$insecure
$blocked
$ignored
diff --git a/view/profile_vcard.tpl b/view/profile_vcard.tpl
index d65b65784..c78eb9b7f 100644
--- a/view/profile_vcard.tpl
+++ b/view/profile_vcard.tpl
@@ -21,7 +21,7 @@
{{ if $pdesc }}<div class="title">$profile.pdesc</div>{{ endif }}
- <div id="profile-photo-wrapper"><img class="photo" width="175" height="175" src="$profile.photo" alt="$profile.name"></div>
+ <div id="profile-photo-wrapper"><img class="photo" width="175" height="175" src="$profile.photo" alt="$profile.name" /></div>