Skip to content

Commit

Permalink
Added the ability to include announcements in the /categories/discuss…
Browse files Browse the repository at this point in the history
…ions page.
  • Loading branch information
tburry committed Nov 6, 2011
1 parent bc67476 commit ab2aa9e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ public function Discussions() {
$this->CategoryDiscussionData = array();
foreach ($this->CategoryData->Result() as $Category) {
if ($Category->CategoryID > 0)
$this->CategoryDiscussionData[$Category->CategoryID] = $DiscussionModel->Get(0, $this->DiscussionsPerCategory, array('d.CategoryID' => $Category->CategoryID, 'd.Announce' => 0));
$this->CategoryDiscussionData[$Category->CategoryID] = $DiscussionModel->Get(0, $this->DiscussionsPerCategory, array('d.CategoryID' => $Category->CategoryID, 'Announce' => 'all'));
}

// Add modules
Expand Down
12 changes: 10 additions & 2 deletions applications/vanilla/models/class.discussionmodel.php
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,12 @@ public function Get($Offset = '0', $Limit = '', $Wheres = '', $AdditionalFields
$this->EventArguments['SortDirection'] = C('Vanilla.Discussions.SortDirection', 'desc');
$this->EventArguments['Wheres'] = &$Wheres;
$this->FireEvent('BeforeGet'); // @see 'BeforeGetCount' for consistency in results vs. counts

$IncludeAnnouncements = FALSE;
if (strtolower(GetValue('Announce', $Wheres)) == 'all') {
$IncludeAnnouncements = TRUE;
unset($Wheres['Announce']);
}

if (is_array($Wheres))
$this->SQL->Where($Wheres);
Expand All @@ -181,8 +187,10 @@ public function Get($Offset = '0', $Limit = '', $Wheres = '', $AdditionalFields
$Data = $this->SQL->Get();

// If not looking at discussions filtered by bookmarks or user, filter announcements out.
if (!isset($Wheres['w.Bookmarked']) && !isset($Wheres['d.InsertUserID']))
$this->RemoveAnnouncements($Data);
if (!$IncludeAnnouncements) {
if (!isset($Wheres['w.Bookmarked']) && !isset($Wheres['d.InsertUserID']))
$this->RemoveAnnouncements($Data);
}

// Change discussions returned based on additional criteria
$this->AddDiscussionColumns($Data);
Expand Down

0 comments on commit ab2aa9e

Please sign in to comment.