4 use Friendica\Database\DBM;
6 require_once('include/socgraph.php');
7 require_once('include/Contact.php');
8 require_once('include/contact_selectors.php');
9 require_once('mod/contacts.php');
11 function common_content(App $a) {
16 $uid = intval($a->argv[2]);
17 $cid = intval($a->argv[3]);
21 notice( t('Permission denied.') . EOL);
25 if ($cmd !== 'loc' && $cmd != 'rem') {
33 if ($cmd === 'loc' && $cid) {
34 $c = q("SELECT `name`, `url`, `photo` FROM `contact` WHERE `id` = %d AND `uid` = %d LIMIT 1",
38 /// @TODO Handle $c with DBM::is_result()
39 $a->page['aside'] = "";
40 profile_load($a, "", 0, get_contact_details_by_url($c[0]["url"]));
42 $c = q("SELECT `name`, `url`, `photo` FROM `contact` WHERE `self` = 1 AND `uid` = %d LIMIT 1",
45 /// @TODO Handle $c with DBM::is_result()
47 $vcard_widget .= replace_macros(get_markup_template("vcard-widget.tpl"),array(
48 '$name' => htmlentities($c[0]['name']),
49 '$photo' => $c[0]['photo'],
50 'url' => 'contacts/' . $cid
53 if (! x($a->page,'aside')) {
54 $a->page['aside'] = '';
56 $a->page['aside'] .= $vcard_widget;
59 if (! DBM::is_result($c)) {
65 $r = q("SELECT `id` FROM `contact` WHERE `nurl` = '%s' AND `uid` = %d LIMIT 1",
66 dbesc(normalise_link(get_my_url())),
69 if (DBM::is_result($r))
72 $r = q("SELECT `id` FROM `gcontact` WHERE `nurl` = '%s' LIMIT 1",
73 dbesc(normalise_link(get_my_url()))
75 if (DBM::is_result($r))
81 if ($cid == 0 && $zcid == 0) {
86 $t = count_common_friends($uid, $cid);
88 $t = count_common_friends_zcid($uid, $zcid);
92 $a->set_pager_total($t);
94 notice( t('No contacts in common.') . EOL);
100 $r = common_friends($uid, $cid, $a->pager['start'], $a->pager['itemspage']);
102 $r = common_friends_zcid($uid, $zcid, $a->pager['start'], $a->pager['itemspage']);
106 if (! DBM::is_result($r)) {
112 foreach ($r as $rr) {
114 //get further details of the contact
115 $contact_details = get_contact_details_by_url($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'];
122 $photo_menu = contact_photo_menu($rr);
126 'itemurl' => (($contact_details['addr'] != "") ? $contact_details['addr'] : $rr['url']),
127 'name' => $contact_details['name'],
128 'thumb' => proxy_url($contact_details['thumb'], false, PROXY_SIZE_THUMB),
129 'img_hover' => htmlentities($contact_details['name']),
130 'details' => $contact_details['location'],
131 'tags' => $contact_details['keywords'],
132 'about' => $contact_details['about'],
133 'account_type' => account_type($contact_details),
134 'network' => network_to_name($contact_details['network'], $contact_details['url']),
135 'photo_menu' => $photo_menu,
141 if ($cmd === 'loc' && $cid && $uid == local_user()) {
142 $tab_str = contacts_tab($a, $cid, 4);
144 $title = t('Common Friends');
147 $tpl = get_markup_template('viewcontact_template.tpl');
149 $o .= replace_macros($tpl,array(
151 '$tab_str' => $tab_str,
152 '$contacts' => $entries,
153 '$paginate' => paginate($a),