Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion config/vanilla/config.php
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,10 @@
$Configuration['Vanilla']['SSO']['Debug'] = true;
$Configuration['Vanilla']['Activity']['ShowDiscussionBody'] = true;
$Configuration['Vanilla']['Activity']['ShowCommentBody'] = true;
$Configuration['Vanilla']['EnableCategoryFollowing'] = 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';


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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', ''));
Expand All @@ -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();
Expand All @@ -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)));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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', ''));
Expand All @@ -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);

Expand Down