@@ -29,7 +29,7 @@ class CategoriesController extends VanillaController {
29
29
public $ Category ;
30
30
31
31
/** @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 ;
33
33
34
34
const SORT_LAST_POST = 'new ' ;
35
35
const SORT_OLDEST_POST = 'old ' ;
@@ -264,15 +264,23 @@ private function getOptions($category) {
264
264
public function index ($ categoryIdentifier = '' , $ page = '0 ' ) {
265
265
// Figure out which category layout to choose (Defined on "Homepage" settings page).
266
266
$ 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 ;
272
280
}
273
281
274
- $ followed = Gdn::session ()->getPreference ('FollowedCategories ' , false );
275
282
$ this ->setData ('Followed ' , $ followed );
283
+ $ this ->setData ('EnableFollowingFilter ' , $ this ->enableFollowingFilter );
276
284
277
285
$ sort = Gdn::request ()->get ('sort ' , null );
278
286
$ saveSorting = $ sort !== null && Gdn::request ()->get ('save ' ) && Gdn::session ()->validateTransientKey (Gdn::request ()->get ('TransientKey ' , '' ));
@@ -283,13 +291,11 @@ public function index($categoryIdentifier = '', $page = '0') {
283
291
$ this ->setData ('CategorySort ' , $ sort );
284
292
285
293
if ($ categoryIdentifier == '' ) {
286
- $ this ->enableFollowingFilter = true ;
287
294
$ this ->fireEvent ('EnableFollowingFilter ' , [
288
295
'CategoryIdentifier ' => $ categoryIdentifier ,
289
296
'EnableFollowingFilter ' => &$ this ->enableFollowingFilter
290
297
]);
291
- $ this ->setData ('EnableFollowingFilter ' , $ this ->enableFollowingFilter );
292
- switch ($ layout ) {
298
+ switch ($ layout ) {
293
299
case 'mixed ' :
294
300
$ this ->View = 'discussions ' ;
295
301
$ this ->discussions ();
@@ -316,12 +322,14 @@ public function index($categoryIdentifier = '', $page = '0') {
316
322
317
323
Gdn_Theme::section ($ category ->CssClass );
318
324
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
+ }
325
333
326
334
// Load the breadcrumbs.
327
335
$ this ->setData ('Breadcrumbs ' , CategoryModel::getAncestors (val ('CategoryID ' , $ category )));
0 commit comments