]> git.mxchange.org Git - friendica.git/commitdiff
common friends
authorFriendika <info@friendika.com>
Wed, 2 Nov 2011 02:16:33 +0000 (19:16 -0700)
committerFriendika <info@friendika.com>
Wed, 2 Nov 2011 02:16:33 +0000 (19:16 -0700)
include/items.php
include/socgraph.php
mod/common.php [new file with mode: 0644]
mod/contacts.php
view/common_friends.tpl [new file with mode: 0644]
view/contact_edit.tpl
view/profile_vcard.tpl

index ad121bbf5f2c26b931f99903c64bb06e495b93f7..2af2b5f55c8ec41b149b8e1d119dc2164638070f 100644 (file)
@@ -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']),
index 3e9c00633b78f2cd975da1ae93c7604502c84dc2..c81c7b695229ae60dd7ccb9f786128e992a7658e 100644 (file)
@@ -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 (file)
index 0000000..852388c
--- /dev/null
@@ -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;
+}
index 9bbcea07d3a98ab25fe62d1f63a91676de1329ff..ecfbe6c2c7181e76890ab907d210587e39ced993 100644 (file)
@@ -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 (file)
index 0000000..1f610d8
--- /dev/null
@@ -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
index 248140a6bd0524e909e9487bdfd4e6a9b2849467..c2e3e36fba74962d8820b49ae827f10c04964099 100644 (file)
@@ -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
index d65b65784c7bea0f2979697cb0bf0f4d2f7666fb..c78eb9b7f5e14a43879d0affa6a041b5fb1064a7 100644 (file)
@@ -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>