3 * @file include/common.php
6 use Friendica\Content\ContactSelector;
7 use Friendica\Core\L10n;
8 use Friendica\Database\DBM;
9 use Friendica\Model\Contact;
10 use Friendica\Model\GContact;
11 use Friendica\Model\Profile;
13 require_once 'include/dba.php';
14 require_once 'mod/contacts.php';
16 function common_content(App $a)
21 $uid = intval($a->argv[2]);
22 $cid = intval($a->argv[3]);
26 notice(L10n::t('Permission denied.') . EOL);
30 if ($cmd !== 'loc' && $cmd != 'rem') {
38 if ($cmd === 'loc' && $cid) {
39 $contact = dba::selectFirst('contact', ['name', 'url', 'photo'], ['id' => $cid, 'uid' => $uid]);
41 if (DBM::is_result($contact)) {
42 $a->page['aside'] = "";
43 Profile::load($a, "", 0, Contact::getDetailsByURL($contact["url"]));
46 $contact = dba::selectFirst('contact', ['name', 'url', 'photo'], ['self' => true, 'uid' => $uid]);
48 if (DBM::is_result($contact)) {
49 $vcard_widget = replace_macros(get_markup_template("vcard-widget.tpl"), [
50 '$name' => htmlentities($contact['name']),
51 '$photo' => $contact['photo'],
52 'url' => 'contacts/' . $cid
55 if (!x($a->page, 'aside')) {
56 $a->page['aside'] = '';
58 $a->page['aside'] .= $vcard_widget;
62 if (!DBM::is_result($contact)) {
66 if (!$cid && Profile::getMyURL()) {
67 $contact = dba::selectFirst('contact', ['id'], ['nurl' => normalise_link(Profile::getMyURL()), 'uid' => $uid]);
68 if (DBM::is_result($contact)) {
69 $cid = $contact['id'];
71 $gcontact = dba::selectFirst('gcontact', ['id'], ['nurl' => normalise_link(Profile::getMyURL())]);
72 if (DBM::is_result($gcontact)) {
73 $zcid = $gcontact['id'];
78 if ($cid == 0 && $zcid == 0) {
83 $t = GContact::countCommonFriends($uid, $cid);
85 $t = GContact::countCommonFriendsZcid($uid, $zcid);
89 $a->set_pager_total($t);
91 notice(L10n::t('No contacts in common.') . EOL);
96 $r = GContact::commonFriends($uid, $cid, $a->pager['start'], $a->pager['itemspage']);
98 $r = GContact::commonFriendsZcid($uid, $zcid, $a->pager['start'], $a->pager['itemspage']);
101 if (!DBM::is_result($r)) {
108 foreach ($r as $rr) {
109 //get further details of the contact
110 $contact_details = Contact::getDetailsByURL($rr['url'], $uid);
112 // $rr['id'] is needed to use contact_photo_menu()
113 /// @TODO Adding '/" here avoids E_NOTICE on missing constants
114 $rr['id'] = $rr['cid'];
116 $photo_menu = Contact::photoMenu($rr);
120 'itemurl' => defaults($contact_details, 'addr', $rr['url']),
121 'name' => $contact_details['name'],
122 'thumb' => proxy_url($contact_details['thumb'], false, PROXY_SIZE_THUMB),
123 'img_hover' => htmlentities($contact_details['name']),
124 'details' => $contact_details['location'],
125 'tags' => $contact_details['keywords'],
126 'about' => $contact_details['about'],
127 'account_type' => Contact::getAccountType($contact_details),
128 'network' => ContactSelector::networkToName($contact_details['network'], $contact_details['url']),
129 'photo_menu' => $photo_menu,
137 if ($cmd === 'loc' && $cid && local_user() == $uid) {
138 $tab_str = contacts_tab($a, $cid, 4);
140 $title = L10n::t('Common Friends');
143 $tpl = get_markup_template('viewcontact_template.tpl');
145 $o .= replace_macros($tpl, [
147 '$tab_str' => $tab_str,
148 '$contacts' => $entries,
149 '$paginate' => paginate($a),