Skip to content

Commit d4f442b

Browse files
authored
Merge pull request #374 from topcoder-platform/issues-372
Issues-372
2 parents b535af1 + 02564e5 commit d4f442b

File tree

3 files changed

+32
-20
lines changed

3 files changed

+32
-20
lines changed

config/vanilla/config.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,10 @@
144144
$Configuration['Vanilla']['SSO']['Debug'] = true;
145145
$Configuration['Vanilla']['Activity']['ShowDiscussionBody'] = true;
146146
$Configuration['Vanilla']['Activity']['ShowCommentBody'] = true;
147-
$Configuration['Vanilla']['EnableCategoryFollowing'] = true;
147+
// Show 'My Discussions' in the left nav
148+
$Configuration['Vanilla']['Discussions']['ShowMineTab'] = false;
149+
// Allow users to follow categories. Users will be able to see a feed of discussions of only their followed categories.
150+
$Configuration['Vanilla']['EnableCategoryFollowing'] = false;
148151
$Configuration['Vanilla']['Version'] = '3.0';
149152

150153

vanilla/applications/vanilla/controllers/class.categoriescontroller.php

Lines changed: 24 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -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)));

vanilla/applications/vanilla/controllers/class.discussionscontroller.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -123,8 +123,7 @@ public function index($Page = false) {
123123
$this->setData('Breadcrumbs', [['Name' => t('Recent Discussions'), 'Url' => '/discussions']]);
124124

125125
$categoryModel = new CategoryModel();
126-
//FIX: the module is always enabled to show the view filter
127-
$followingEnabled = true;//$categoryModel->followingEnabled();
126+
$followingEnabled = $categoryModel->followingEnabled();
128127
if ($followingEnabled) {
129128
$followed = Gdn::request()->get('followed', null);
130129
$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) {
134133
if ($this->SelfUrl === "discussions") {
135134
$this->enableFollowingFilter = true;
136135
}
136+
$followed = Gdn::session()->getPreference('FollowedCategories', false);
137+
} else {
138+
$followed = false;
137139
}
138140

139-
$followed = Gdn::session()->getPreference('FollowedCategories', false);
140141
$this->setData('EnableFollowingFilter', $this->enableFollowingFilter);
141142
$this->setData('Followed', $followed);
142143

0 commit comments

Comments
 (0)