3 * @file include/common.php
6 use Friendica\Database\DBM;
7 use Friendica\Model\GlobalContact;
8 use Friendica\Object\Contact;
10 require_once 'include/Contact.php';
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, get_contact_details_by_url($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()
50 $vcard_widget .= replace_macros(get_markup_template("vcard-widget.tpl"),array(
51 '$name' => htmlentities($c[0]['name']),
52 '$photo' => $c[0]['photo'],
53 'url' => 'contacts/' . $cid
56 if (! x($a->page,'aside')) {
57 $a->page['aside'] = '';
59 $a->page['aside'] .= $vcard_widget;
62 if (! DBM::is_result($c)) {
68 $r = q("SELECT `id` FROM `contact` WHERE `nurl` = '%s' AND `uid` = %d LIMIT 1",
69 dbesc(normalise_link(get_my_url())),
72 if (DBM::is_result($r))
75 $r = q("SELECT `id` FROM `gcontact` WHERE `nurl` = '%s' LIMIT 1",
76 dbesc(normalise_link(get_my_url()))
78 if (DBM::is_result($r))
84 if ($cid == 0 && $zcid == 0) {
89 $t = GlobalContact::countCommonFriends($uid, $cid);
91 $t = GlobalContact::countCommonFriendsZcid($uid, $zcid);
95 $a->set_pager_total($t);
97 notice(t('No contacts in common.') . EOL);
103 $r = GlobalContact::commonFriends($uid, $cid, $a->pager['start'], $a->pager['itemspage']);
105 $r = GlobalContact::commonFriendsZcid($uid, $zcid, $a->pager['start'], $a->pager['itemspage']);
109 if (! DBM::is_result($r)) {
115 foreach ($r as $rr) {
117 //get further details of the contact
118 $contact_details = get_contact_details_by_url($rr['url'], $uid);
120 // $rr['id'] is needed to use contact_photo_menu()
121 /// @TODO Adding '/" here avoids E_NOTICE on missing constants
122 $rr['id'] = $rr['cid'];
125 $photo_menu = contact_photo_menu($rr);
129 'itemurl' => (($contact_details['addr'] != "") ? $contact_details['addr'] : $rr['url']),
130 'name' => $contact_details['name'],
131 'thumb' => proxy_url($contact_details['thumb'], false, PROXY_SIZE_THUMB),
132 'img_hover' => htmlentities($contact_details['name']),
133 'details' => $contact_details['location'],
134 'tags' => $contact_details['keywords'],
135 'about' => $contact_details['about'],
136 'account_type' => account_type($contact_details),
137 'network' => network_to_name($contact_details['network'], $contact_details['url']),
138 'photo_menu' => $photo_menu,
144 if ($cmd === 'loc' && $cid && $uid == local_user()) {
145 $tab_str = contacts_tab($a, $cid, 4);
147 $title = t('Common Friends');
150 $tpl = get_markup_template('viewcontact_template.tpl');
152 $o .= replace_macros($tpl,array(
154 '$tab_str' => $tab_str,
155 '$contacts' => $entries,
156 '$paginate' => paginate($a),