3 * @file include/common.php
7 use Friendica\Content\ContactSelector;
8 use Friendica\Core\L10n;
9 use Friendica\Database\DBA;
10 use Friendica\Model\Contact;
11 use Friendica\Model\GContact;
12 use Friendica\Model\Profile;
14 require_once 'include/dba.php';
15 require_once 'mod/contacts.php';
17 function common_content(App $a)
22 $uid = intval($a->argv[2]);
23 $cid = intval($a->argv[3]);
27 notice(L10n::t('Permission denied.') . EOL);
31 if ($cmd !== 'loc' && $cmd != 'rem') {
39 if ($cmd === 'loc' && $cid) {
40 $contact = DBA::selectFirst('contact', ['name', 'url', 'photo'], ['id' => $cid, 'uid' => $uid]);
42 if (DBA::isResult($contact)) {
43 $a->page['aside'] = "";
44 Profile::load($a, "", 0, Contact::getDetailsByURL($contact["url"]));
47 $contact = DBA::selectFirst('contact', ['name', 'url', 'photo'], ['self' => true, 'uid' => $uid]);
49 if (DBA::isResult($contact)) {
50 $vcard_widget = replace_macros(get_markup_template("vcard-widget.tpl"), [
51 '$name' => htmlentities($contact['name']),
52 '$photo' => $contact['photo'],
53 'url' => 'contacts/' . $cid
56 if (!x($a->page, 'aside')) {
57 $a->page['aside'] = '';
59 $a->page['aside'] .= $vcard_widget;
63 if (!DBA::isResult($contact)) {
67 if (!$cid && Profile::getMyURL()) {
68 $contact = DBA::selectFirst('contact', ['id'], ['nurl' => normalise_link(Profile::getMyURL()), 'uid' => $uid]);
69 if (DBA::isResult($contact)) {
70 $cid = $contact['id'];
72 $gcontact = DBA::selectFirst('gcontact', ['id'], ['nurl' => normalise_link(Profile::getMyURL())]);
73 if (DBA::isResult($gcontact)) {
74 $zcid = $gcontact['id'];
79 if ($cid == 0 && $zcid == 0) {
84 $t = GContact::countCommonFriends($uid, $cid);
86 $t = GContact::countCommonFriendsZcid($uid, $zcid);
90 $a->set_pager_total($t);
92 notice(L10n::t('No contacts in common.') . EOL);
97 $r = GContact::commonFriends($uid, $cid, $a->pager['start'], $a->pager['itemspage']);
99 $r = GContact::commonFriendsZcid($uid, $zcid, $a->pager['start'], $a->pager['itemspage']);
102 if (!DBA::isResult($r)) {
109 foreach ($r as $rr) {
110 //get further details of the contact
111 $contact_details = Contact::getDetailsByURL($rr['url'], $uid);
113 // $rr['id'] is needed to use contact_photo_menu()
114 /// @TODO Adding '/" here avoids E_NOTICE on missing constants
115 $rr['id'] = $rr['cid'];
117 $photo_menu = Contact::photoMenu($rr);
121 'itemurl' => defaults($contact_details, 'addr', $rr['url']),
122 'name' => $contact_details['name'],
123 'thumb' => proxy_url($contact_details['thumb'], false, PROXY_SIZE_THUMB),
124 'img_hover' => htmlentities($contact_details['name']),
125 'details' => $contact_details['location'],
126 'tags' => $contact_details['keywords'],
127 'about' => $contact_details['about'],
128 'account_type' => Contact::getAccountType($contact_details),
129 'network' => ContactSelector::networkToName($contact_details['network'], $contact_details['url']),
130 'photo_menu' => $photo_menu,
138 if ($cmd === 'loc' && $cid && local_user() == $uid) {
139 $tab_str = contacts_tab($a, $cid, 4);
141 $title = L10n::t('Common Friends');
144 $tpl = get_markup_template('viewcontact_template.tpl');
146 $o .= replace_macros($tpl, [
148 '$tab_str' => $tab_str,
149 '$contacts' => $entries,
150 '$paginate' => paginate($a),