3 * @file include/common.php
7 use Friendica\Content\ContactSelector;
8 use Friendica\Core\L10n;
9 use Friendica\Database\DBA;
11 use Friendica\Module\Contact;
12 use Friendica\Util\Proxy as ProxyUtils;
15 require_once 'include/dba.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', 'uid', 'id'], ['id' => $cid, 'uid' => $uid]);
42 if (DBA::isResult($contact)) {
43 $a->page['aside'] = "";
44 Model\Profile::load($a, "", 0,Model\Contact::getDetailsByURL($contact["url"]));
47 $contact = DBA::selectFirst('contact', ['name', 'url', 'photo', 'uid', 'id'], ['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 &&Model\Profile::getMyURL()) {
68 $contact = DBA::selectFirst('contact', ['id'], ['nurl' => normalise_link(Model\Profile::getMyURL()), 'uid' => $uid]);
69 if (DBA::isResult($contact)) {
70 $cid = $contact['id'];
72 $gcontact = DBA::selectFirst('gcontact', ['id'], ['nurl' => normalise_link(Model\Profile::getMyURL())]);
73 if (DBA::isResult($gcontact)) {
74 $zcid = $gcontact['id'];
79 if ($cid == 0 && $zcid == 0) {
84 $t =Model\GContact::countCommonFriends($uid, $cid);
86 $t =Model\GContact::countCommonFriendsZcid($uid, $zcid);
90 $a->setPagerTotal($t);
92 notice(L10n::t('No contacts in common.') . EOL);
97 $r =Model\GContact::commonFriends($uid, $cid, $a->pager['start'], $a->pager['itemspage']);
99 $r =Model\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 =Model\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 =Model\Contact::photoMenu($rr);
121 'itemurl' => defaults($contact_details, 'addr', $rr['url']),
122 'name' => $contact_details['name'],
123 'thumb' => ProxyUtils::proxifyUrl($contact_details['thumb'], false, ProxyUtils::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' =>Model\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 = Contact::getTabsHTML($a, $contact, 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),