common friends
This commit is contained in:
parent
0975ea8610
commit
3d9a9614e2
7 changed files with 125 additions and 2 deletions
|
@ -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']),
|
||||
|
|
|
@ -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;
|
||||
|
||||
}
|
61
mod/common.php
Normal file
61
mod/common.php
Normal file
|
@ -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;
|
||||
}
|
|
@ -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'),
|
||||
|
|
12
view/common_friends.tpl
Normal file
12
view/common_friends.tpl
Normal file
|
@ -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>
|
|
@ -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
|
||||
|
|
|
@ -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>
|
||||
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue