From 2bd6cff5509b41adc0861478dc23ebbc2c90648d Mon Sep 17 00:00:00 2001 From: Bogdanova Olga Date: Fri, 5 Feb 2021 16:33:48 +0300 Subject: [PATCH 1/2] Issues-372: Fixed enabled/disabled category following,this feature is disabled by default --- config/vanilla/config.php | 3 +- .../class.categoriescontroller.php | 40 +++++++++++-------- .../class.discussionscontroller.php | 7 ++-- 3 files changed, 30 insertions(+), 20 deletions(-) diff --git a/config/vanilla/config.php b/config/vanilla/config.php index a85d7ce..5a65581 100644 --- a/config/vanilla/config.php +++ b/config/vanilla/config.php @@ -144,7 +144,8 @@ $Configuration['Vanilla']['SSO']['Debug'] = true; $Configuration['Vanilla']['Activity']['ShowDiscussionBody'] = true; $Configuration['Vanilla']['Activity']['ShowCommentBody'] = true; -$Configuration['Vanilla']['EnableCategoryFollowing'] = true; +// Allow users to follow categories. Users will be able to see a feed of discussions of only their followed categories. +$Configuration['Vanilla']['EnableCategoryFollowing'] = false; $Configuration['Vanilla']['Version'] = '3.0'; diff --git a/vanilla/applications/vanilla/controllers/class.categoriescontroller.php b/vanilla/applications/vanilla/controllers/class.categoriescontroller.php index 0547cf7..288035f 100644 --- a/vanilla/applications/vanilla/controllers/class.categoriescontroller.php +++ b/vanilla/applications/vanilla/controllers/class.categoriescontroller.php @@ -29,7 +29,7 @@ class CategoriesController extends VanillaController { public $Category; /** @var bool Value indicating if the category-following filter should be displayed when rendering a view */ - public $enableFollowingFilter = true;//false; + public $enableFollowingFilter = false; const SORT_LAST_POST = 'new'; const SORT_OLDEST_POST = 'old'; @@ -264,15 +264,23 @@ private function getOptions($category) { public function index($categoryIdentifier = '', $page = '0') { // Figure out which category layout to choose (Defined on "Homepage" settings page). $layout = c('Vanilla.Categories.Layout'); - $followed = Gdn::request()->get('followed', null); - $saveFollowing = $followed !== null && Gdn::request()->get('save') && Gdn::session()->validateTransientKey(Gdn::request()->get('TransientKey', '')); - if($saveFollowing) { - $followed = Gdn::request()->get('followed'); - Gdn::session()->setPreference('FollowedCategories', $followed); + + if ($this->CategoryModel->followingEnabled()) { + $followed = Gdn::request()->get('followed', null); + $saveFollowing = $followed !== null && Gdn::request()->get('save') && Gdn::session()->validateTransientKey(Gdn::request()->get('TransientKey', '')); + if ($saveFollowing) { + $followed = Gdn::request()->get('followed'); + Gdn::session()->setPreference('FollowedCategories', $followed); + } + + $followed = Gdn::session()->getPreference('FollowedCategories', false); + $this->enableFollowingFilter = true; + } else { + $this->enableFollowingFilter = $followed = false; } - $followed = Gdn::session()->getPreference('FollowedCategories', false); $this->setData('Followed', $followed); + $this->setData('EnableFollowingFilter', $this->enableFollowingFilter); $sort = Gdn::request()->get('sort', null); $saveSorting = $sort !== null && Gdn::request()->get('save') && Gdn::session()->validateTransientKey(Gdn::request()->get('TransientKey', '')); @@ -283,13 +291,11 @@ public function index($categoryIdentifier = '', $page = '0') { $this->setData('CategorySort', $sort); if ($categoryIdentifier == '') { - $this->enableFollowingFilter = true; $this->fireEvent('EnableFollowingFilter', [ 'CategoryIdentifier' => $categoryIdentifier, 'EnableFollowingFilter' => &$this->enableFollowingFilter ]); - $this->setData('EnableFollowingFilter', $this->enableFollowingFilter); - switch ($layout) { + switch ($layout) { case 'mixed': $this->View = 'discussions'; $this->discussions(); @@ -316,12 +322,14 @@ public function index($categoryIdentifier = '', $page = '0') { Gdn_Theme::section($category->CssClass); - // The view filter is shown always if category type != 'discussions' - $this->enableFollowingFilter = strtolower( val('DisplayAs', $category, '')) != 'discussions'; - $this->fireEvent('EnableFollowingFilter', [ - 'CategoryIdentifier' => $categoryIdentifier, - 'EnableFollowingFilter' => &$this->enableFollowingFilter - ]); + if($this->CategoryModel->followingEnabled()) { + // The view filter is shown always if category type != 'discussions' + $this->enableFollowingFilter = strtolower(val('DisplayAs', $category, '')) != 'discussions'; + $this->fireEvent('EnableFollowingFilter', [ + 'CategoryIdentifier' => $categoryIdentifier, + 'EnableFollowingFilter' => &$this->enableFollowingFilter + ]); + } // Load the breadcrumbs. $this->setData('Breadcrumbs', CategoryModel::getAncestors(val('CategoryID', $category))); diff --git a/vanilla/applications/vanilla/controllers/class.discussionscontroller.php b/vanilla/applications/vanilla/controllers/class.discussionscontroller.php index c9c0a28..8b4b4c1 100644 --- a/vanilla/applications/vanilla/controllers/class.discussionscontroller.php +++ b/vanilla/applications/vanilla/controllers/class.discussionscontroller.php @@ -123,8 +123,7 @@ public function index($Page = false) { $this->setData('Breadcrumbs', [['Name' => t('Recent Discussions'), 'Url' => '/discussions']]); $categoryModel = new CategoryModel(); - //FIX: the module is always enabled to show the view filter - $followingEnabled = true;//$categoryModel->followingEnabled(); + $followingEnabled = $categoryModel->followingEnabled(); if ($followingEnabled) { $followed = Gdn::request()->get('followed', null); $saveFollowing = Gdn::request()->get('followed') !== null && Gdn::request()->get('save') && Gdn::session()->validateTransientKey(Gdn::request()->get('TransientKey', '')); @@ -134,9 +133,11 @@ public function index($Page = false) { if ($this->SelfUrl === "discussions") { $this->enableFollowingFilter = true; } + $followed = Gdn::session()->getPreference('FollowedCategories', false); + } else { + $followed = false; } - $followed = Gdn::session()->getPreference('FollowedCategories', false); $this->setData('EnableFollowingFilter', $this->enableFollowingFilter); $this->setData('Followed', $followed); From 02564e54dbe0f4339e8f54fb8a7b80344999e0e0 Mon Sep 17 00:00:00 2001 From: Bogdanova Olga Date: Fri, 5 Feb 2021 16:34:21 +0300 Subject: [PATCH 2/2] Issues-372:Hide My Discussion in the left nav by default --- config/vanilla/config.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/config/vanilla/config.php b/config/vanilla/config.php index 5a65581..53a12e2 100644 --- a/config/vanilla/config.php +++ b/config/vanilla/config.php @@ -144,6 +144,8 @@ $Configuration['Vanilla']['SSO']['Debug'] = true; $Configuration['Vanilla']['Activity']['ShowDiscussionBody'] = true; $Configuration['Vanilla']['Activity']['ShowCommentBody'] = true; +// Show 'My Discussions' in the left nav +$Configuration['Vanilla']['Discussions']['ShowMineTab'] = false; // Allow users to follow categories. Users will be able to see a feed of discussions of only their followed categories. $Configuration['Vanilla']['EnableCategoryFollowing'] = false; $Configuration['Vanilla']['Version'] = '3.0';