4 * @file include/common.php
7 use Friendica\Database\DBM;
8 use Friendica\Model\Contact;
9 use Friendica\Model\GContact;
11 require_once 'include/contact_selectors.php';
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 /// @todo : Initialize $profile_uid
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);
101 $r = GContact::commonFriends($uid, $cid, $a->pager['start'], $a->pager['itemspage']);
103 $r = GContact::commonFriendsZcid($uid, $zcid, $a->pager['start'], $a->pager['itemspage']);
106 if (!DBM::is_result($r)) {
113 foreach ($r as $rr) {
114 //get further details of the contact
115 $contact_details = Contact::getDetailsByURL($rr['url'], $uid);
117 // $rr['id'] is needed to use contact_photo_menu()
118 /// @TODO Adding '/" here avoids E_NOTICE on missing constants
119 $rr['id'] = $rr['cid'];
121 $photo_menu = Contact::photoMenu($rr);
125 'itemurl' => defaults($contact_details, 'addr', $rr['url']),
126 'name' => $contact_details['name'],
127 'thumb' => proxy_url($contact_details['thumb'], false, PROXY_SIZE_THUMB),
128 'img_hover' => htmlentities($contact_details['name']),
129 'details' => $contact_details['location'],
130 'tags' => $contact_details['keywords'],
131 'about' => $contact_details['about'],
132 'account_type' => Contact::getAccountType($contact_details),
133 'network' => network_to_name($contact_details['network'], $contact_details['url']),
134 'photo_menu' => $photo_menu,
142 if ($cmd === 'loc' && $cid && local_user() == $uid) {
143 $tab_str = contacts_tab($a, $cid, 4);
145 $title = t('Common Friends');
148 $tpl = get_markup_template('viewcontact_template.tpl');
150 $o .= replace_macros($tpl, array(
152 '$tab_str' => $tab_str,
153 '$contacts' => $entries,
154 '$paginate' => paginate($a),