3 * @file include/common.php
6 use Friendica\Database\DBM;
7 use Friendica\Model\Contact;
8 use Friendica\Model\GContact;
10 require_once 'include/contact_selectors.php';
11 require_once 'mod/contacts.php';
13 function common_content(App $a) {
18 $uid = intval($a->argv[2]);
19 $cid = intval($a->argv[3]);
23 notice( t('Permission denied.') . EOL);
27 if ($cmd !== 'loc' && $cmd != 'rem') {
35 if ($cmd === 'loc' && $cid) {
36 $c = q("SELECT `name`, `url`, `photo` FROM `contact` WHERE `id` = %d AND `uid` = %d LIMIT 1",
40 /// @TODO Handle $c with DBM::is_result()
41 $a->page['aside'] = "";
42 profile_load($a, "", 0, Contact::getDetailsByURL($c[0]["url"]));
44 $c = q("SELECT `name`, `url`, `photo` FROM `contact` WHERE `self` = 1 AND `uid` = %d LIMIT 1",
47 /// @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)) {
67 $r = q("SELECT `id` FROM `contact` WHERE `nurl` = '%s' AND `uid` = %d LIMIT 1",
68 dbesc(normalise_link(get_my_url())),
71 if (DBM::is_result($r))
74 $r = q("SELECT `id` FROM `gcontact` WHERE `nurl` = '%s' LIMIT 1",
75 dbesc(normalise_link(get_my_url()))
77 if (DBM::is_result($r))
83 if ($cid == 0 && $zcid == 0) {
88 $t = GContact::countCommonFriends($uid, $cid);
90 $t = GContact::countCommonFriendsZcid($uid, $zcid);
94 $a->set_pager_total($t);
96 notice(t('No contacts in common.') . EOL);
102 $r = GContact::commonFriends($uid, $cid, $a->pager['start'], $a->pager['itemspage']);
104 $r = GContact::commonFriendsZcid($uid, $zcid, $a->pager['start'], $a->pager['itemspage']);
108 if (! DBM::is_result($r)) {
114 foreach ($r as $rr) {
116 //get further details of the contact
117 $contact_details = Contact::getDetailsByURL($rr['url'], $uid);
119 // $rr['id'] is needed to use contact_photo_menu()
120 /// @TODO Adding '/" here avoids E_NOTICE on missing constants
121 $rr['id'] = $rr['cid'];
124 $photo_menu = Contact::photoMenu($rr);
128 'itemurl' => (($contact_details['addr'] != "") ? $contact_details['addr'] : $rr['url']),
129 'name' => $contact_details['name'],
130 'thumb' => proxy_url($contact_details['thumb'], false, PROXY_SIZE_THUMB),
131 'img_hover' => htmlentities($contact_details['name']),
132 'details' => $contact_details['location'],
133 'tags' => $contact_details['keywords'],
134 'about' => $contact_details['about'],
135 'account_type' => Contact::getAccountType($contact_details),
136 'network' => network_to_name($contact_details['network'], $contact_details['url']),
137 'photo_menu' => $photo_menu,
143 if ($cmd === 'loc' && $cid && $uid == local_user()) {
144 $tab_str = contacts_tab($a, $cid, 4);
146 $title = t('Common Friends');
149 $tpl = get_markup_template('viewcontact_template.tpl');
151 $o .= replace_macros($tpl,array(
153 '$tab_str' => $tab_str,
154 '$contacts' => $entries,
155 '$paginate' => paginate($a),