]> git.mxchange.org Git - friendica.git/blobdiff - src/Module/Profile/Common.php
Merge pull request #12469 from MrPetovan/bug/12462-tos-rules
[friendica.git] / src / Module / Profile / Common.php
index a9d00fce5f50a15b1be288fa13b70652d45768b1..5056758603814f450de00c962817a804b6bf863f 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 /**
- * @copyright Copyright (C) 2020, Friendica
+ * @copyright Copyright (C) 2010-2022, the Friendica project
  *
  * @license GNU AGPL version 3 or any later version
  *
@@ -25,7 +25,6 @@ use Friendica\Content\Nav;
 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;
@@ -35,9 +34,9 @@ use Friendica\Network\HTTPException;
 
 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.'));
                }
 
@@ -45,30 +44,29 @@ class Common extends BaseProfile
 
                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,
@@ -78,7 +76,7 @@ class Common extends BaseProfile
 
                $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());
 
@@ -87,7 +85,7 @@ class Common extends BaseProfile
                $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');