3 namespace Friendica\Module;
5 use Friendica\BaseModule;
6 use Friendica\Content\ContactSelector;
7 use Friendica\Content\Pager;
8 use Friendica\Core\L10n;
9 use Friendica\Core\Renderer;
12 use Friendica\Network\HTTPException;
13 use Friendica\Util\Proxy as ProxyUtils;
16 * This module shows all public friends of the selected contact
18 class AllFriends extends BaseModule
20 public static function content(array $parameters = [])
25 throw new HTTPException\ForbiddenException();
30 // @TODO: Replace with parameter from router
32 $cid = intval($app->argv[1]);
36 throw new HTTPException\BadRequestException(L10n::t('Invalid contact.'));
39 $uid = $app->user['uid'];
41 $contact = Model\Contact::getContactForUser($cid, local_user(), ['name', 'url', 'photo', 'uid', 'id']);
43 if (empty($contact)) {
44 throw new HTTPException\BadRequestException(L10n::t('Invalid contact.'));
47 $app->page['aside'] = "";
48 Model\Profile::load($app, "", 0, Model\Contact::getDetailsByURL($contact["url"]));
50 $total = Model\GContact::countAllFriends(local_user(), $cid);
52 $pager = new Pager(DI::args()->getQueryString());
54 $friends = Model\GContact::allFriends(local_user(), $cid, $pager->getStart(), $pager->getItemsPerPage());
55 if (empty($friends)) {
56 return L10n::t('No friends to display.');
62 foreach ($friends as $friend) {
63 //get further details of the contact
64 $contactDetails = Model\Contact::getDetailsByURL($friend['url'], $uid, $friend);
67 // $friend[cid] is only available for common contacts. So if the contact is a common one, use contact_photo_menu to generate the photoMenu
68 // If the contact is not common to the user, Connect/Follow' will be added to the photo menu
70 $friend['id'] = $friend['cid'];
71 $photoMenu = Model\Contact::photoMenu($friend);
73 $connlnk = DI::baseUrl()->get() . '/follow/?url=' . $friend['url'];
75 'profile' => [L10n::t('View Profile'), Model\Contact::magicLinkbyId($friend['id'], $friend['url'])],
76 'follow' => [L10n::t('Connect/Follow'), $connlnk]
81 'url' => Model\Contact::magicLinkbyId($friend['id'], $friend['url']),
82 'itemurl' => ($contactDetails['addr'] ?? '') ?: $friend['url'],
83 'name' => $contactDetails['name'],
84 'thumb' => ProxyUtils::proxifyUrl($contactDetails['thumb'], false, ProxyUtils::SIZE_THUMB),
85 'img_hover' => $contactDetails['name'],
86 'details' => $contactDetails['location'],
87 'tags' => $contactDetails['keywords'],
88 'about' => $contactDetails['about'],
89 'account_type' => Model\Contact::getAccountType($contactDetails),
90 'network' => ContactSelector::networkToName($contactDetails['network'], $contactDetails['url']),
91 'photoMenu' => $photoMenu,
92 'conntxt' => L10n::t('Connect'),
93 'connlnk' => $connlnk,
99 $tab_str = Contact::getTabsHTML($app, $contact, 4);
101 $tpl = Renderer::getMarkupTemplate('viewcontact_template.tpl');
102 return Renderer::replaceMacros($tpl, [
103 '$tab_str' => $tab_str,
104 '$contacts' => $entries,
105 '$paginate' => $pager->renderFull($total),