3 require_once('include/socgraph.php');
4 require_once('include/Contact.php');
5 require_once('include/contact_selectors.php');
6 require_once('mod/contacts.php');
8 function common_content(App $a) {
13 $uid = intval($a->argv[2]);
14 $cid = intval($a->argv[3]);
18 notice( t('Permission denied.') . EOL);
22 if ($cmd !== 'loc' && $cmd != 'rem') {
30 if ($cmd === 'loc' && $cid) {
31 $c = q("SELECT `name`, `url`, `photo` FROM `contact` WHERE `id` = %d AND `uid` = %d LIMIT 1",
35 /// @TODO Handle $c with dbm::is_result()
36 $a->page['aside'] = "";
37 profile_load($a, "", 0, get_contact_details_by_url($c[0]["url"]));
39 $c = q("SELECT `name`, `url`, `photo` FROM `contact` WHERE `self` = 1 AND `uid` = %d LIMIT 1",
42 /// @TODO Handle $c with dbm::is_result()
44 $vcard_widget .= replace_macros(get_markup_template("vcard-widget.tpl"),array(
45 '$name' => htmlentities($c[0]['name']),
46 '$photo' => $c[0]['photo'],
47 'url' => 'contacts/' . $cid
50 if (! x($a->page,'aside')) {
51 $a->page['aside'] = '';
53 $a->page['aside'] .= $vcard_widget;
56 if (! dbm::is_result($c)) {
62 $r = q("SELECT `id` FROM `contact` WHERE `nurl` = '%s' AND `uid` = %d LIMIT 1",
63 dbesc(normalise_link(get_my_url())),
66 if (dbm::is_result($r)) {
69 $r = q("SELECT `id` FROM `gcontact` WHERE `nurl` = '%s' LIMIT 1",
70 dbesc(normalise_link(get_my_url()))
72 if (dbm::is_result($r)) {
79 if ($cid == 0 && $zcid == 0) {
84 $t = count_common_friends($uid, $cid);
86 $t = count_common_friends_zcid($uid, $zcid);
90 $a->set_pager_total($t);
92 notice( t('No contacts in common.') . EOL);
98 $r = common_friends($uid, $cid, $a->pager['start'], $a->pager['itemspage']);
100 $r = common_friends_zcid($uid, $zcid, $a->pager['start'], $a->pager['itemspage']);
104 if (! dbm::is_result($r)) {
110 foreach ($r as $rr) {
112 //get further details of the contact
113 $contact_details = get_contact_details_by_url($rr['url'], $uid);
115 // $rr['id'] is needed to use contact_photo_menu()
116 /// @TODO Adding '/" here avoids E_NOTICE on missing constants
117 $rr['id'] = $rr['cid'];
120 $photo_menu = contact_photo_menu($rr);
124 'itemurl' => (($contact_details['addr'] != "") ? $contact_details['addr'] : $rr['url']),
125 'name' => $contact_details['name'],
126 'thumb' => proxy_url($contact_details['thumb'], false, PROXY_SIZE_THUMB),
127 'img_hover' => htmlentities($contact_details['name']),
128 'details' => $contact_details['location'],
129 'tags' => $contact_details['keywords'],
130 'about' => $contact_details['about'],
131 'account_type' => account_type($contact_details),
132 'network' => network_to_name($contact_details['network'], $contact_details['url']),
133 'photo_menu' => $photo_menu,
139 if ($cmd === 'loc' && $cid && $uid == local_user()) {
140 $tab_str = contacts_tab($a, $cid, 4);
142 $title = t('Common Friends');
145 $tpl = get_markup_template('viewcontact_template.tpl');
147 $o .= replace_macros($tpl,array(
149 '$tab_str' => $tab_str,
150 '$contacts' => $entries,
151 '$paginate' => paginate($a),