]> git.mxchange.org Git - friendica.git/blobdiff - src/Module/Profile/Status.php
Merge pull request #11452 from atjn/manifest-icons
[friendica.git] / src / Module / Profile / Status.php
index 3c1ed8c5ac8ad6fb35dd361d9afc04e76753b45f..f3015692f328439e41633f464b016ff2ab623093 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 /**
- * @copyright Copyright (C) 2010-2021, the Friendica project
+ * @copyright Copyright (C) 2010-2022, the Friendica project
  *
  * @license GNU AGPL version 3 or any later version
  *
@@ -29,6 +29,7 @@ use Friendica\Core\Protocol;
 use Friendica\Core\Session;
 use Friendica\Database\DBA;
 use Friendica\DI;
+use Friendica\Model\Contact;
 use Friendica\Model\Item;
 use Friendica\Model\Post;
 use Friendica\Model\Post\Category;
@@ -46,13 +47,13 @@ use Friendica\Util\XML;
 
 class Status extends BaseProfile
 {
-       public static function content(array $parameters = [])
+       protected function content(array $request = []): string
        {
                $args = DI::args();
 
                $a = DI::app();
 
-               $profile = ProfileModel::load($a, $parameters['nickname']);
+               $profile = ProfileModel::load($a, $this->parameters['nickname']);
 
                if (empty($profile)) {
                        throw new HTTPException\NotFoundException(DI::l10n()->t('User not found.'));
@@ -62,10 +63,10 @@ class Status extends BaseProfile
                        DI::page()['htmlhead'] .= '<meta content="noindex, noarchive" name="robots" />' . "\n";
                }
 
-               DI::page()['htmlhead'] .= '<link rel="alternate" type="application/atom+xml" href="' . DI::baseUrl() . '/dfrn_poll/' . $parameters['nickname'] . '" title="DFRN: ' . DI::l10n()->t('%s\'s timeline', $profile['name']) . '"/>' . "\n";
-               DI::page()['htmlhead'] .= '<link rel="alternate" type="application/atom+xml" href="' . DI::baseUrl() . '/feed/' . $parameters['nickname'] . '/" title="' . DI::l10n()->t('%s\'s posts', $profile['name']) . '"/>' . "\n";
-               DI::page()['htmlhead'] .= '<link rel="alternate" type="application/atom+xml" href="' . DI::baseUrl() . '/feed/' . $parameters['nickname'] . '/comments" title="' . DI::l10n()->t('%s\'s comments', $profile['name']) . '"/>' . "\n";
-               DI::page()['htmlhead'] .= '<link rel="alternate" type="application/atom+xml" href="' . DI::baseUrl() . '/feed/' . $parameters['nickname'] . '/activity" title="' . DI::l10n()->t('%s\'s timeline', $profile['name']) . '"/>' . "\n";
+               DI::page()['htmlhead'] .= '<link rel="alternate" type="application/atom+xml" href="' . DI::baseUrl() . '/dfrn_poll/' . $this->parameters['nickname'] . '" title="DFRN: ' . DI::l10n()->t('%s\'s timeline', $profile['name']) . '"/>' . "\n";
+               DI::page()['htmlhead'] .= '<link rel="alternate" type="application/atom+xml" href="' . DI::baseUrl() . '/feed/' . $this->parameters['nickname'] . '/" title="' . DI::l10n()->t('%s\'s posts', $profile['name']) . '"/>' . "\n";
+               DI::page()['htmlhead'] .= '<link rel="alternate" type="application/atom+xml" href="' . DI::baseUrl() . '/feed/' . $this->parameters['nickname'] . '/comments" title="' . DI::l10n()->t('%s\'s comments', $profile['name']) . '"/>' . "\n";
+               DI::page()['htmlhead'] .= '<link rel="alternate" type="application/atom+xml" href="' . DI::baseUrl() . '/feed/' . $this->parameters['nickname'] . '/activity" title="' . DI::l10n()->t('%s\'s timeline', $profile['name']) . '"/>' . "\n";
 
                $category = $datequery = $datequery2 = '';
 
@@ -118,7 +119,7 @@ class Status extends BaseProfile
                $commvisitor = $commpage && $remote_contact;
 
                DI::page()['aside'] .= Widget::postedByYear(DI::baseUrl() . '/profile/' . $profile['nickname'] . '/status', $profile['profile_uid'] ?? 0, true);
-               DI::page()['aside'] .= Widget::categories(DI::baseUrl() . '/profile/' . $profile['nickname'] . '/status', XML::escape($category));
+               DI::page()['aside'] .= Widget::categories($profile['uid'], DI::baseUrl() . '/profile/' . $profile['nickname'] . '/status', $category);
                DI::page()['aside'] .= Widget::tagCloud($profile['uid']);
 
                if (Security::canWriteToUserWall($profile['uid'])) {
@@ -151,15 +152,15 @@ class Status extends BaseProfile
                }
 
                if (!empty($datequery)) {
-                       $condition = DBA::mergeConditions($condition, ["`received` <= ?", DateTimeFormat::convert($datequery, 'UTC', date_default_timezone_get())]);
+                       $condition = DBA::mergeConditions($condition, ["`received` <= ?", DateTimeFormat::convert($datequery, 'UTC', $a->getTimeZone())]);
                }
                if (!empty($datequery2)) {
-                       $condition = DBA::mergeConditions($condition, ["`received` >= ?", DateTimeFormat::convert($datequery2, 'UTC', date_default_timezone_get())]);
+                       $condition = DBA::mergeConditions($condition, ["`received` >= ?", DateTimeFormat::convert($datequery2, 'UTC', $a->getTimeZone())]);
                }
 
                // Does the profile page belong to a forum?
                // If not then we can improve the performance with an additional condition
-               $condition2 = ['uid' => $profile['uid'], 'page-flags' => [User::PAGE_FLAGS_COMMUNITY, User::PAGE_FLAGS_PRVGROUP]];
+               $condition2 = ['uid' => $profile['uid'], 'account-type' => User::ACCOUNT_TYPE_COMMUNITY];
                if (!DBA::exists('user', $condition2)) {
                        $condition = DBA::mergeConditions($condition, ['contact-id' => $profile['id']]);
                }
@@ -207,20 +208,8 @@ class Status extends BaseProfile
                $items = Post::toArray($items_stmt);
 
                if ($pager->getStart() == 0 && !empty($profile['uid'])) {
-                       $condition = ['private' => [Item::PUBLIC, Item::UNLISTED]];
-                       $remote_user = Session::getRemoteContactID($profile['uid']);
-                       if (!empty($remote_user)) {
-                               $permissionSets = DI::permissionSet()->selectByContactId($remote_user, $profile['uid']);
-                               if (!empty($permissionSets)) {
-                                       $condition = ['psid' => array_merge($permissionSets->column('id'),
-                                                       [DI::permissionSet()->getIdFromACL($profile['uid'], '', '', '', '')])];
-                               }
-                       } elseif ($profile['uid'] == local_user()) {
-                               $condition = [];
-                       }
-       
-                       $pinned_items = Post::selectPinned($profile['uid'], ['uri-id', 'pinned'], $condition);
-                       $pinned = Post::toArray($pinned_items);
+                       $pcid = Contact::getPublicIdByUserId($profile['uid']);
+                       $pinned = Post\Collection::selectToArrayForContact($pcid, Post\Collection::FEATURED);
                        $items = array_merge($items, $pinned);
                }