5 require_once('include/socgraph.php');
6 require_once('include/Contact.php');
7 require_once('include/contact_selectors.php');
8 require_once('mod/contacts.php');
10 function common_content(App $a) {
15 $uid = intval($a->argv[2]);
16 $cid = intval($a->argv[3]);
20 notice( t('Permission denied.') . EOL);
24 if ($cmd !== 'loc' && $cmd != 'rem') {
32 if ($cmd === 'loc' && $cid) {
33 $c = q("SELECT `name`, `url`, `photo` FROM `contact` WHERE `id` = %d AND `uid` = %d LIMIT 1",
37 /// @TODO Handle $c with dbm::is_result()
38 $a->page['aside'] = "";
39 profile_load($a, "", 0, get_contact_details_by_url($c[0]["url"]));
41 $c = q("SELECT `name`, `url`, `photo` FROM `contact` WHERE `self` = 1 AND `uid` = %d LIMIT 1",
44 /// @TODO Handle $c with dbm::is_result()
46 $vcard_widget .= replace_macros(get_markup_template("vcard-widget.tpl"),array(
47 '$name' => htmlentities($c[0]['name']),
48 '$photo' => $c[0]['photo'],
49 'url' => 'contacts/' . $cid
52 if (! x($a->page,'aside')) {
53 $a->page['aside'] = '';
55 $a->page['aside'] .= $vcard_widget;
58 if (! dbm::is_result($c)) {
64 $r = q("SELECT `id` FROM `contact` WHERE `nurl` = '%s' AND `uid` = %d LIMIT 1",
65 dbesc(normalise_link(get_my_url())),
68 if (dbm::is_result($r))
71 $r = q("SELECT `id` FROM `gcontact` WHERE `nurl` = '%s' LIMIT 1",
72 dbesc(normalise_link(get_my_url()))
74 if (dbm::is_result($r))
80 if ($cid == 0 && $zcid == 0) {
85 $t = count_common_friends($uid, $cid);
87 $t = count_common_friends_zcid($uid, $zcid);
91 $a->set_pager_total($t);
93 notice( t('No contacts in common.') . EOL);
99 $r = common_friends($uid, $cid, $a->pager['start'], $a->pager['itemspage']);
101 $r = common_friends_zcid($uid, $zcid, $a->pager['start'], $a->pager['itemspage']);
105 if (! dbm::is_result($r)) {
111 foreach ($r as $rr) {
113 //get further details of the contact
114 $contact_details = get_contact_details_by_url($rr['url'], $uid);
116 // $rr['id'] is needed to use contact_photo_menu()
117 /// @TODO Adding '/" here avoids E_NOTICE on missing constants
118 $rr['id'] = $rr['cid'];
121 $photo_menu = contact_photo_menu($rr);
125 'itemurl' => (($contact_details['addr'] != "") ? $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' => account_type($contact_details),
133 'network' => network_to_name($contact_details['network'], $contact_details['url']),
134 'photo_menu' => $photo_menu,
140 if ($cmd === 'loc' && $cid && $uid == local_user()) {
141 $tab_str = contacts_tab($a, $cid, 4);
143 $title = t('Common Friends');
146 $tpl = get_markup_template('viewcontact_template.tpl');
148 $o .= replace_macros($tpl,array(
150 '$tab_str' => $tab_str,
151 '$contacts' => $entries,
152 '$paginate' => paginate($a),