From d3231c7a7d562ff3bb4ba355f4a9a984f2c484f4 Mon Sep 17 00:00:00 2001 From: Michael Date: Sun, 3 Sep 2023 14:01:46 +0000 Subject: [PATCH] Use language filtering on all channels, rearranged channels --- src/Module/Conversation/Channel.php | 78 +++++++++++++++-------------- 1 file changed, 40 insertions(+), 38 deletions(-) diff --git a/src/Module/Conversation/Channel.php b/src/Module/Conversation/Channel.php index 73eb00976..dfe8871f1 100644 --- a/src/Module/Conversation/Channel.php +++ b/src/Module/Conversation/Channel.php @@ -135,15 +135,6 @@ class Channel extends BaseModule 'accesskey' => 'y' ]; - $tabs[] = [ - 'label' => $this->l10n->t('Followers'), - 'url' => 'channel/' . self::FOLLOWERS, - 'sel' => self::$content == self::FOLLOWERS ? 'active' : '', - 'title' => $this->l10n->t('Posts from your followers that you don\'t follow'), - 'id' => 'channel-followers-tab', - 'accesskey' => 'f' - ]; - $tabs[] = [ 'label' => $this->l10n->t('What\'s Hot'), 'url' => 'channel/' . self::WHATSHOT, @@ -153,33 +144,6 @@ class Channel extends BaseModule 'accesskey' => 'h' ]; - $tabs[] = [ - 'label' => $this->l10n->t('Images'), - 'url' => 'channel/' . self::IMAGE, - 'sel' => self::$content == self::IMAGE ? 'active' : '', - 'title' => $this->l10n->t('Posts with images'), - 'id' => 'channel-image-tab', - 'accesskey' => 'i' - ]; - - $tabs[] = [ - 'label' => $this->l10n->t('Videos'), - 'url' => 'channel/' . self::VIDEO, - 'sel' => self::$content == self::VIDEO ? 'active' : '', - 'title' => $this->l10n->t('Posts with videos'), - 'id' => 'channel-video-tab', - 'accesskey' => 'v' - ]; - - $tabs[] = [ - 'label' => $this->l10n->t('Audio'), - 'url' => 'channel/' . self::AUDIO, - 'sel' => self::$content == self::AUDIO ? 'active' : '', - 'title' => $this->l10n->t('Posts with audio'), - 'id' => 'channel-audio-tab', - 'accesskey' => 'd' - ]; - $language = User::getLanguageCode($this->session->getLocalUserId(), false); $languages = $this->l10n->getAvailableLanguages(); @@ -192,6 +156,42 @@ class Channel extends BaseModule 'accesskey' => 'g' ]; + $tabs[] = [ + 'label' => $this->l10n->t('Followers'), + 'url' => 'channel/' . self::FOLLOWERS, + 'sel' => self::$content == self::FOLLOWERS ? 'active' : '', + 'title' => $this->l10n->t('Posts from your followers that you don\'t follow'), + 'id' => 'channel-followers-tab', + 'accesskey' => 'f' + ]; + + $tabs[] = [ + 'label' => $this->l10n->t('Images'), + 'url' => 'channel/' . self::IMAGE, + 'sel' => self::$content == self::IMAGE ? 'active' : '', + 'title' => $this->l10n->t('Posts with images'), + 'id' => 'channel-image-tab', + 'accesskey' => 'i' + ]; + + $tabs[] = [ + 'label' => $this->l10n->t('Audio'), + 'url' => 'channel/' . self::AUDIO, + 'sel' => self::$content == self::AUDIO ? 'active' : '', + 'title' => $this->l10n->t('Posts with audio'), + 'id' => 'channel-audio-tab', + 'accesskey' => 'd' + ]; + + $tabs[] = [ + 'label' => $this->l10n->t('Videos'), + 'url' => 'channel/' . self::VIDEO, + 'sel' => self::$content == self::VIDEO ? 'active' : '', + 'title' => $this->l10n->t('Posts with videos'), + 'id' => 'channel-video-tab', + 'accesskey' => 'v' + ]; + $tab_tpl = Renderer::getMarkupTemplate('common_tabs.tpl'); $o .= Renderer::replaceMacros($tab_tpl, ['$tabs' => $tabs]); @@ -327,8 +327,6 @@ class Channel extends BaseModule } else { $condition = ["(`comments` >= ? OR `activities` >= ?) AND `contact-type` != ?", $this->getMedianComments(4), $this->getMedianActivities(4), Contact::TYPE_COMMUNITY]; } - - $condition = $this->addLanguageCondition($condition); } elseif (self::$content == self::FORYOU) { $cid = Contact::getPublicIdByUserId($this->session->getLocalUserId()); @@ -349,6 +347,10 @@ class Channel extends BaseModule $condition = ["JSON_EXTRACT(JSON_KEYS(language), '$[0]') = ?", User::getLanguageCode($this->session->getLocalUserId(), true)]; } + if (self::$content != self::LANGUAGE) { + $condition = $this->addLanguageCondition($condition); + } + $condition[0] .= " AND NOT EXISTS(SELECT `cid` FROM `user-contact` WHERE `uid` = ? AND `cid` = `post-engagement`.`owner-id` AND (`ignored` OR `blocked` OR `collapsed`))"; $condition[] = $this->session->getLocalUserId();