4 * @file include/common.php
7 use Friendica\Content\ContactSelector;
8 use Friendica\Database\DBM;
9 use Friendica\Model\Contact;
10 use Friendica\Model\GContact;
12 require_once 'mod/contacts.php';
14 function common_content(App $a)
19 $uid = intval($a->argv[2]);
20 $cid = intval($a->argv[3]);
24 notice(t('Permission denied.') . EOL);
28 if ($cmd !== 'loc' && $cmd != 'rem') {
36 if ($cmd === 'loc' && $cid) {
37 $c = q("SELECT `name`, `url`, `photo` FROM `contact` WHERE `id` = %d AND `uid` = %d LIMIT 1",
41 /// @TODO Handle $c with DBM::is_result()
42 $a->page['aside'] = "";
43 profile_load($a, "", 0, Contact::getDetailsByURL($c[0]["url"]));
45 $c = q("SELECT `name`, `url`, `photo` FROM `contact` WHERE `self` = 1 AND `uid` = %d LIMIT 1",
48 /// @TODO Handle $c with DBM::is_result()
49 $vcard_widget = replace_macros(get_markup_template("vcard-widget.tpl"), array(
50 '$name' => htmlentities($c[0]['name']),
51 '$photo' => $c[0]['photo'],
52 'url' => 'contacts/' . $cid
55 if (!x($a->page, 'aside')) {
56 $a->page['aside'] = '';
58 $a->page['aside'] .= $vcard_widget;
61 if (!DBM::is_result($c)) {
65 if (!$cid && get_my_url()) {
66 $contact = dba::selectFirst('contact', ['id'], ['nurl' => normalise_link(get_my_url()), 'uid' => $uid]);
67 if (DBM::is_result($contact)) {
68 $cid = $contact['id'];
70 $gcontact = dba::selectFirst('gcontact', ['id'], ['nurl' => normalise_link(get_my_url())]);
71 if (DBM::is_result($gcontact)) {
72 $zcid = $gcontact['id'];
77 if ($cid == 0 && $zcid == 0) {
82 $t = GContact::countCommonFriends($uid, $cid);
84 $t = GContact::countCommonFriendsZcid($uid, $zcid);
88 $a->set_pager_total($t);
90 notice(t('No contacts in common.') . EOL);
95 $r = GContact::commonFriends($uid, $cid, $a->pager['start'], $a->pager['itemspage']);
97 $r = GContact::commonFriendsZcid($uid, $zcid, $a->pager['start'], $a->pager['itemspage']);
100 if (!DBM::is_result($r)) {
107 foreach ($r as $rr) {
108 //get further details of the contact
109 $contact_details = Contact::getDetailsByURL($rr['url'], $uid);
111 // $rr['id'] is needed to use contact_photo_menu()
112 /// @TODO Adding '/" here avoids E_NOTICE on missing constants
113 $rr['id'] = $rr['cid'];
115 $photo_menu = Contact::photoMenu($rr);
119 'itemurl' => defaults($contact_details, 'addr', $rr['url']),
120 'name' => $contact_details['name'],
121 'thumb' => proxy_url($contact_details['thumb'], false, PROXY_SIZE_THUMB),
122 'img_hover' => htmlentities($contact_details['name']),
123 'details' => $contact_details['location'],
124 'tags' => $contact_details['keywords'],
125 'about' => $contact_details['about'],
126 'account_type' => Contact::getAccountType($contact_details),
127 'network' => ContactSelector::networkToName($contact_details['network'], $contact_details['url']),
128 'photo_menu' => $photo_menu,
136 if ($cmd === 'loc' && $cid && local_user() == $uid) {
137 $tab_str = contacts_tab($a, $cid, 4);
139 $title = t('Common Friends');
142 $tpl = get_markup_template('viewcontact_template.tpl');
144 $o .= replace_macros($tpl, array(
146 '$tab_str' => $tab_str,
147 '$contacts' => $entries,
148 '$paginate' => paginate($a),