3 * @file include/common.php
7 use Friendica\Content\ContactSelector;
8 use Friendica\Content\Pager;
9 use Friendica\Core\L10n;
10 use Friendica\Database\DBA;
13 use Friendica\Util\Proxy as ProxyUtils;
16 require_once 'include/dba.php';
18 function common_content(App $a)
23 $uid = intval($a->argv[2]);
24 $cid = intval($a->argv[3]);
28 notice(L10n::t('Permission denied.') . EOL);
32 if ($cmd !== 'loc' && $cmd != 'rem') {
40 if ($cmd === 'loc' && $cid) {
41 $contact = DBA::selectFirst('contact', ['name', 'url', 'photo', 'uid', 'id'], ['id' => $cid, 'uid' => $uid]);
43 if (DBA::isResult($contact)) {
44 $a->page['aside'] = "";
45 Model\Profile::load($a, "", 0, Model\Contact::getDetailsByURL($contact["url"]));
48 $contact = DBA::selectFirst('contact', ['name', 'url', 'photo', 'uid', 'id'], ['self' => true, 'uid' => $uid]);
50 if (DBA::isResult($contact)) {
51 $vcard_widget = replace_macros(get_markup_template("vcard-widget.tpl"), [
52 '$name' => htmlentities($contact['name']),
53 '$photo' => $contact['photo'],
54 'url' => 'contact/' . $cid
57 if (!x($a->page, 'aside')) {
58 $a->page['aside'] = '';
60 $a->page['aside'] .= $vcard_widget;
64 if (!DBA::isResult($contact)) {
68 if (!$cid && Model\Profile::getMyURL()) {
69 $contact = DBA::selectFirst('contact', ['id'], ['nurl' => normalise_link(Model\Profile::getMyURL()), 'uid' => $uid]);
70 if (DBA::isResult($contact)) {
71 $cid = $contact['id'];
73 $gcontact = DBA::selectFirst('gcontact', ['id'], ['nurl' => normalise_link(Model\Profile::getMyURL())]);
74 if (DBA::isResult($gcontact)) {
75 $zcid = $gcontact['id'];
80 if ($cid == 0 && $zcid == 0) {
85 $t = Model\GContact::countCommonFriends($uid, $cid);
87 $t = Model\GContact::countCommonFriendsZcid($uid, $zcid);
91 $pager = new Pager($a->query_string, $t);
93 notice(L10n::t('No contacts in common.') . EOL);
98 $r = Model\GContact::commonFriends($uid, $cid, $pager->getStart(), $pager->getItemsPerPage());
100 $r = Model\GContact::commonFriendsZcid($uid, $zcid, $pager->getStart(), $pager->getItemsPerPage());
103 if (!DBA::isResult($r)) {
110 foreach ($r as $rr) {
111 //get further details of the contact
112 $contact_details = Model\Contact::getDetailsByURL($rr['url'], $uid);
114 // $rr['id'] is needed to use contact_photo_menu()
115 /// @TODO Adding '/" here avoids E_NOTICE on missing constants
116 $rr['id'] = $rr['cid'];
118 $photo_menu = Model\Contact::photoMenu($rr);
122 'itemurl' => defaults($contact_details, 'addr', $rr['url']),
123 'name' => $contact_details['name'],
124 'thumb' => ProxyUtils::proxifyUrl($contact_details['thumb'], false, ProxyUtils::SIZE_THUMB),
125 'img_hover' => htmlentities($contact_details['name']),
126 'details' => $contact_details['location'],
127 'tags' => $contact_details['keywords'],
128 'about' => $contact_details['about'],
129 'account_type' => Model\Contact::getAccountType($contact_details),
130 'network' => ContactSelector::networkToName($contact_details['network'], $contact_details['url']),
131 'photo_menu' => $photo_menu,
139 if ($cmd === 'loc' && $cid && local_user() == $uid) {
140 $tab_str = Module\Contact::getTabsHTML($a, $contact, 4);
142 $title = L10n::t('Common Friends');
145 $tpl = get_markup_template('viewcontact_template.tpl');
147 $o .= replace_macros($tpl, [
149 '$tab_str' => $tab_str,
150 '$contacts' => $entries,
151 '$paginate' => $pager->renderFull(),