]> git.mxchange.org Git - friendica.git/blobdiff - src/Module/Conversation/Network.php
spelling: however
[friendica.git] / src / Module / Conversation / Network.php
index ce2afbfc7571b2b71716807c92c6d3a0a7564e02..5f8f925a367222cf7b0754e78ba72321c7a92d70 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 /**
- * @copyright Copyright (C) 2010-2022, the Friendica project
+ * @copyright Copyright (C) 2010-2023, the Friendica project
  *
  * @license GNU AGPL version 3 or any later version
  *
@@ -23,13 +23,16 @@ namespace Friendica\Module\Conversation;
 
 use Friendica\BaseModule;
 use Friendica\Content\BoundariesPager;
+use Friendica\Content\Conversation;
 use Friendica\Content\ForumManager;
 use Friendica\Content\Nav;
 use Friendica\Content\Widget;
 use Friendica\Content\Text\HTML;
 use Friendica\Core\ACL;
 use Friendica\Core\Hook;
+use Friendica\Core\PConfig\Capability\IManagePersonalConfigValues;
 use Friendica\Core\Renderer;
+use Friendica\Core\Session\Capability\IHandleUserSessions;
 use Friendica\Database\DBA;
 use Friendica\DI;
 use Friendica\Model\Contact;
@@ -117,7 +120,7 @@ class Network extends BaseModule
                        $content = '';
 
                        if (self::$forumContactId) {
-                               // If self::$forumContactId belongs to a communitity forum or a privat goup,.add a mention to the status editor
+                               // If self::$forumContactId belongs to a community forum or a privat goup,.add a mention to the status editor
                                $condition = ["`id` = ? AND `contact-type` = ?", self::$forumContactId, Contact::TYPE_COMMUNITY];
                                $contact = DBA::selectFirst('contact', ['addr'], $condition);
                                if (!empty($contact['addr'])) {
@@ -178,7 +181,7 @@ class Network extends BaseModule
                } elseif (self::$forumContactId) {
                        $contact = Contact::getById(self::$forumContactId);
                        if (DBA::isResult($contact)) {
-                               $o = Renderer::replaceMacros(Renderer::getMarkupTemplate('viewcontact_template.tpl'), [
+                               $o = Renderer::replaceMacros(Renderer::getMarkupTemplate('contact/list.tpl'), [
                                        'contacts' => [ModuleContact::getContactTemplateVars($contact)],
                                        'id' => DI::args()->get(0),
                                ]) . $o;
@@ -198,7 +201,7 @@ class Network extends BaseModule
                        $ordering = '`commented`';
                }
 
-               $o .= DI::conversation()->create($items, 'network', false, false, $ordering, DI::userSession()->getLocalUserId());
+               $o .= DI::conversation()->create($items, Conversation::MODE_NETWORK, false, false, $ordering, DI::userSession()->getLocalUserId());
 
                if (DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'system', 'infinite_scroll')) {
                        $o .= HTML::scrollLoader();
@@ -306,7 +309,7 @@ class Network extends BaseModule
 
                self::$forumContactId = $this->parameters['contact_id'] ?? 0;
 
-               self::$selectedTab = DI::session()->get('network-tab', DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'network.view', 'selected_tab', ''));
+               self::$selectedTab = self::getTimelineOrderBySession(DI::userSession(), DI::pConfig());
 
                if (!empty($get['star'])) {
                        self::$selectedTab = 'star';
@@ -411,7 +414,7 @@ class Network extends BaseModule
                if (self::$groupId) {
                        $conditionStrings = DBA::mergeConditions($conditionStrings, ["`contact-id` IN (SELECT `contact-id` FROM `group_member` WHERE `gid` = ?)", self::$groupId]);
                } elseif (self::$forumContactId) {
-                       $conditionStrings = DBA::mergeConditions($conditionStrings, 
+                       $conditionStrings = DBA::mergeConditions($conditionStrings,
                                ["((`contact-id` = ?) OR `uri-id` IN (SELECT `parent-uri-id` FROM `post-user-view` WHERE (`contact-id` = ? AND `gravity` = ? AND `vid` = ? AND `uid` = ?)))",
                                self::$forumContactId, self::$forumContactId, Item::GRAVITY_ACTIVITY, Verb::getID(Activity::ANNOUNCE), DI::userSession()->getLocalUserId()]);
                }
@@ -486,4 +489,18 @@ class Network extends BaseModule
 
                return $items;
        }
+
+       /**
+        * Returns the selected network tab of the currently logged-in user
+        *
+        * @param IHandleUserSessions         $session
+        * @param IManagePersonalConfigValues $pconfig
+        * @return string
+        */
+       public static function getTimelineOrderBySession(IHandleUserSessions $session, IManagePersonalConfigValues $pconfig): string
+       {
+               return $session->get('network-tab')
+                       ?? $pconfig->get($session->getLocalUserId(), 'network.view', 'selected_tab')
+                       ?? '';
+       }
 }