3 namespace Friendica\Module\Contact;
5 use Friendica\BaseModule;
6 use Friendica\Content\Pager;
7 use Friendica\Core\Renderer;
8 use Friendica\Core\Session;
12 use Friendica\Network\HTTPException;
14 class Contacts extends BaseModule
16 public static function content(array $parameters = [])
21 throw new HTTPException\ForbiddenException();
24 $cid = $parameters['id'];
25 $type = $parameters['type'] ?? 'all';
28 throw new HTTPException\BadRequestException(DI::l10n()->t('Invalid contact.'));
31 $contact = Model\Contact::getById($cid, []);
32 if (empty($contact)) {
33 throw new HTTPException\NotFoundException(DI::l10n()->t('Contact not found.'));
36 $localContactId = Model\Contact::getPublicIdByUserId(local_user());
38 Model\Profile::load($app, '', $contact);
46 $noresult_label = DI::l10n()->t('No known contacts.');
50 $total = Model\Contact\Relation::countFollowers($cid, $condition);
53 $total = Model\Contact\Relation::countFollows($cid, $condition);
56 $total = Model\Contact\Relation::countMutuals($cid, $condition);
60 'NOT `self` AND NOT `blocked` AND NOT `hidden` AND `id` != ?',
63 $total = Model\Contact\Relation::countCommon($localContactId, $cid, $condition);
64 $noresult_label = DI::l10n()->t('No common contacts.');
67 $total = Model\Contact\Relation::countAll($cid, $condition);
70 $pager = new Pager(DI::l10n(), DI::args()->getQueryString(), 30);
75 $friends = Model\Contact\Relation::listFollowers($cid, $condition, $pager->getItemsPerPage(), $pager->getStart());
76 $title = DI::l10n()->tt('Follower (%s)', 'Followers (%s)', $total);
79 $friends = Model\Contact\Relation::listFollows($cid, $condition, $pager->getItemsPerPage(), $pager->getStart());
80 $title = DI::l10n()->tt('Following (%s)', 'Following (%s)', $total);
83 $friends = Model\Contact\Relation::listMutuals($cid, $condition, $pager->getItemsPerPage(), $pager->getStart());
84 $title = DI::l10n()->tt('Mutual friend (%s)', 'Mutual friends (%s)', $total);
85 $desc = DI::l10n()->t(
86 'These contacts both follow and are followed by <strong>%s</strong>.',
87 htmlentities($contact['name'], ENT_COMPAT, 'UTF-8')
91 $friends = Model\Contact\Relation::listCommon($localContactId, $cid, $condition, $pager->getItemsPerPage(), $pager->getStart());
92 $title = DI::l10n()->tt('Common contact (%s)', 'Common contacts (%s)', $total);
93 $desc = DI::l10n()->t(
94 'Both <strong>%s</strong> and yourself have publicly interacted with these contacts (follow, comment or likes on public posts).',
95 htmlentities($contact['name'], ENT_COMPAT, 'UTF-8')
99 $friends = Model\Contact\Relation::listAll($cid, $condition, $pager->getItemsPerPage(), $pager->getStart());
100 $title = DI::l10n()->tt('Contact (%s)', 'Contacts (%s)', $total);
103 $o = Module\Contact::getTabsHTML($contact, Module\Contact::TAB_CONTACTS);
105 $tabs = self::getContactFilterTabs('contact/' . $cid, $type, true);
107 $contacts = array_map([Module\Contact::class, 'getContactTemplateVars'], $friends);
109 $tpl = Renderer::getMarkupTemplate('profile/contacts.tpl');
110 $o .= Renderer::replaceMacros($tpl, [
115 '$noresult_label' => $noresult_label,
117 '$contacts' => $contacts,
118 '$paginate' => $pager->renderFull($total),