@@ -29,7 +29,7 @@ class CategoriesController extends VanillaController {
2929 public $ Category ;
3030
3131 /** @var bool Value indicating if the category-following filter should be displayed when rendering a view */
32- public $ enableFollowingFilter = true ; // false;
32+ public $ enableFollowingFilter = false ;
3333
3434 const SORT_LAST_POST = 'new ' ;
3535 const SORT_OLDEST_POST = 'old ' ;
@@ -264,15 +264,23 @@ private function getOptions($category) {
264264 public function index ($ categoryIdentifier = '' , $ page = '0 ' ) {
265265 // Figure out which category layout to choose (Defined on "Homepage" settings page).
266266 $ layout = c ('Vanilla.Categories.Layout ' );
267- $ followed = Gdn::request ()->get ('followed ' , null );
268- $ saveFollowing = $ followed !== null && Gdn::request ()->get ('save ' ) && Gdn::session ()->validateTransientKey (Gdn::request ()->get ('TransientKey ' , '' ));
269- if ($ saveFollowing ) {
270- $ followed = Gdn::request ()->get ('followed ' );
271- Gdn::session ()->setPreference ('FollowedCategories ' , $ followed );
267+
268+ if ($ this ->CategoryModel ->followingEnabled ()) {
269+ $ followed = Gdn::request ()->get ('followed ' , null );
270+ $ saveFollowing = $ followed !== null && Gdn::request ()->get ('save ' ) && Gdn::session ()->validateTransientKey (Gdn::request ()->get ('TransientKey ' , '' ));
271+ if ($ saveFollowing ) {
272+ $ followed = Gdn::request ()->get ('followed ' );
273+ Gdn::session ()->setPreference ('FollowedCategories ' , $ followed );
274+ }
275+
276+ $ followed = Gdn::session ()->getPreference ('FollowedCategories ' , false );
277+ $ this ->enableFollowingFilter = true ;
278+ } else {
279+ $ this ->enableFollowingFilter = $ followed = false ;
272280 }
273281
274- $ followed = Gdn::session ()->getPreference ('FollowedCategories ' , false );
275282 $ this ->setData ('Followed ' , $ followed );
283+ $ this ->setData ('EnableFollowingFilter ' , $ this ->enableFollowingFilter );
276284
277285 $ sort = Gdn::request ()->get ('sort ' , null );
278286 $ saveSorting = $ sort !== null && Gdn::request ()->get ('save ' ) && Gdn::session ()->validateTransientKey (Gdn::request ()->get ('TransientKey ' , '' ));
@@ -283,13 +291,11 @@ public function index($categoryIdentifier = '', $page = '0') {
283291 $ this ->setData ('CategorySort ' , $ sort );
284292
285293 if ($ categoryIdentifier == '' ) {
286- $ this ->enableFollowingFilter = true ;
287294 $ this ->fireEvent ('EnableFollowingFilter ' , [
288295 'CategoryIdentifier ' => $ categoryIdentifier ,
289296 'EnableFollowingFilter ' => &$ this ->enableFollowingFilter
290297 ]);
291- $ this ->setData ('EnableFollowingFilter ' , $ this ->enableFollowingFilter );
292- switch ($ layout ) {
298+ switch ($ layout ) {
293299 case 'mixed ' :
294300 $ this ->View = 'discussions ' ;
295301 $ this ->discussions ();
@@ -316,12 +322,14 @@ public function index($categoryIdentifier = '', $page = '0') {
316322
317323 Gdn_Theme::section ($ category ->CssClass );
318324
319- // The view filter is shown always if category type != 'discussions'
320- $ this ->enableFollowingFilter = strtolower ( val ('DisplayAs ' , $ category , '' )) != 'discussions ' ;
321- $ this ->fireEvent ('EnableFollowingFilter ' , [
322- 'CategoryIdentifier ' => $ categoryIdentifier ,
323- 'EnableFollowingFilter ' => &$ this ->enableFollowingFilter
324- ]);
325+ if ($ this ->CategoryModel ->followingEnabled ()) {
326+ // The view filter is shown always if category type != 'discussions'
327+ $ this ->enableFollowingFilter = strtolower (val ('DisplayAs ' , $ category , '' )) != 'discussions ' ;
328+ $ this ->fireEvent ('EnableFollowingFilter ' , [
329+ 'CategoryIdentifier ' => $ categoryIdentifier ,
330+ 'EnableFollowingFilter ' => &$ this ->enableFollowingFilter
331+ ]);
332+ }
325333
326334 // Load the breadcrumbs.
327335 $ this ->setData ('Breadcrumbs ' , CategoryModel::getAncestors (val ('CategoryID ' , $ category )));
0 commit comments