<?php
/**
- * @copyright Copyright (C) 2020, Friendica
+ * @copyright Copyright (C) 2010-2022, the Friendica project
*
* @license GNU AGPL version 3 or any later version
*
use Friendica\Content\Pager;
use Friendica\Core\Protocol;
use Friendica\Core\Renderer;
-use Friendica\Core\Session;
use Friendica\Module;
use Friendica\DI;
use Friendica\Model\Contact;
class Common extends BaseProfile
{
- public static function content(array $parameters = [])
+ protected function content(array $request = []): string
{
- if (DI::config()->get('system', 'block_public') && !Session::isAuthenticated()) {
+ if (DI::config()->get('system', 'block_public') && !DI::userSession()->isAuthenticated()) {
throw new HTTPException\NotFoundException(DI::l10n()->t('User not found.'));
}
Nav::setSelected('home');
- $nickname = $parameters['nickname'];
+ $nickname = $this->parameters['nickname'];
- Profile::load($a, $nickname);
-
- if (empty($a->profile)) {
+ $profile = Profile::load($a, $nickname);
+ if (empty($profile)) {
throw new HTTPException\NotFoundException(DI::l10n()->t('User not found.'));
}
- if (!empty($a->profile['hide-friends'])) {
+ if (!empty($profile['hide-friends'])) {
throw new HTTPException\ForbiddenException(DI::l10n()->t('Permission denied.'));
}
- $displayCommonTab = Session::isAuthenticated() && $a->profile['uid'] != local_user();
+ $displayCommonTab = DI::userSession()->isAuthenticated() && $profile['uid'] != DI::userSession()->getLocalUserId();
if (!$displayCommonTab) {
$a->redirect('profile/' . $nickname . '/contacts');
};
- $o = self::getTabsHTML($a, 'contacts', false, $nickname);
+ $o = self::getTabsHTML('contacts', false, $profile['nickname'], $profile['hide-friends']);
$tabs = self::getContactFilterTabs('profile/' . $nickname, 'common', $displayCommonTab);
$sourceId = Contact::getIdForURL(Profile::getMyURL());
- $targetId = Contact::getPublicIdByUserId($a->profile['uid']);
+ $targetId = Contact::getPublicIdByUserId($profile['uid']);
$condition = [
'blocked' => false,
$total = Contact\Relation::countCommon($sourceId, $targetId, $condition);
- $pager = new Pager(DI::l10n(), DI::args()->getQueryString());
+ $pager = new Pager(DI::l10n(), DI::args()->getQueryString(), 30);
$commonFollows = Contact\Relation::listCommon($sourceId, $targetId, $condition, $pager->getItemsPerPage(), $pager->getStart());
$title = DI::l10n()->tt('Common contact (%s)', 'Common contacts (%s)', $total);
$desc = DI::l10n()->t(
'Both <strong>%s</strong> and yourself have publicly interacted with these contacts (follow, comment or likes on public posts).',
- htmlentities($a->profile['name'], ENT_COMPAT, 'UTF-8')
+ htmlentities($profile['name'], ENT_COMPAT, 'UTF-8')
);
$tpl = Renderer::getMarkupTemplate('profile/contacts.tpl');