Skip to content

Commit 9b706de

Browse files
authored
Merge pull request #565 from topcoder-platform/issues-475
Issues-475: Voting plugin is enabled, Added Discussion sorts
2 parents 0c140c8 + 0c1d202 commit 9b706de

File tree

3 files changed

+24
-11
lines changed

3 files changed

+24
-11
lines changed

config/vanilla/bootstrap.before.php

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -883,26 +883,30 @@ function writeInlineDiscussionOptions($discussionRow) {
883883
echo '<div class="center"></div>';
884884
echo '<div class="right">';
885885

886-
// Write the items.
886+
$sender = Gdn::controller();
887+
888+
$sender->EventArguments['Object'] = $discussionRow;
889+
$sender->EventArguments['Type'] = 'Discussion';
890+
$sender->fireEvent('BeforeInlineDiscussionOptions');
891+
887892
// DropdownModule
888893
$discussionDropdown = getDiscussionOptionsDropdown($discussionRow);
889894

890895
// Allow plugins to edit the dropdown.
891-
$sender = Gdn::controller();
892896
$sender->EventArguments['DiscussionOptions'] = &$discussionDropdown ;
893897
$sender->EventArguments['Discussion'] = $discussionRow;
894898
$sender->fireEvent('InlineDiscussionOptions');
895899

896-
$discussionDropdownItems = $discussionDropdown->toArray()['items'];
900+
$discussionDropdownItems = $discussionDropdown->toArray()['items'];
897901

898-
unset($discussionDropdownItems['announce']);
899-
unset($discussionDropdownItems['sink']);
900-
unset($discussionDropdownItems['close']);
901-
unset($discussionDropdownItems['dismiss']);
902-
unset($discussionDropdownItems['move']);
903-
unset($discussionDropdownItems['tag']);
902+
unset($discussionDropdownItems['announce']);
903+
unset($discussionDropdownItems['sink']);
904+
unset($discussionDropdownItems['close']);
905+
unset($discussionDropdownItems['dismiss']);
906+
unset($discussionDropdownItems['move']);
907+
unset($discussionDropdownItems['tag']);
904908

905-
if (!empty($discussionDropdownItems) && is_array($discussionDropdownItems)) {
909+
if (!empty($discussionDropdownItems) && is_array($discussionDropdownItems)) {
906910
array_walk($discussionDropdownItems, function(&$value, $key) {
907911
$anchor = anchor($value['text'], $value['url'], val('cssClass', $value, $key));
908912
$value = '<span class="" style="">'.$anchor.'</span>';
@@ -926,6 +930,11 @@ function writeInlineCommentOptions($comment) {
926930
echo '<div class="center"></div>';
927931
echo '<div class="right">';
928932

933+
$sender = Gdn::controller();
934+
$sender->EventArguments['Object'] = $comment;
935+
$sender->EventArguments['Type'] = 'Comment';
936+
$sender->fireEvent('BeforeInlineCommentOptions');
937+
929938
// Write the items.
930939
$items = getCommentOptions($comment);
931940
if (!empty($items) && is_array($items)) {

config/vanilla/config.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
$Configuration['EnabledPlugins']['stubcontent'] = false;
2727
$Configuration['EnabledPlugins']['Topcoder'] = true;
2828
$Configuration['EnabledPlugins']['TopcoderEditor'] = true;
29+
$Configuration['EnabledPlugins']['Voting'] = true;
2930
$Configuration['EnabledPlugins']['rich-editor'] = true;
3031
$Configuration['EnabledPlugins']['editor'] = false;
3132
$Configuration['EnabledPlugins']['emojiextender'] = true;

vanilla/applications/vanilla/models/class.discussionmodel.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,11 @@ class DiscussionModel extends Gdn_Model {
6464
protected static $allowedSorts = [
6565
'hot' => ['key' => 'hot', 'name' => 'Hot', 'orderBy' => ['DateLastComment' => 'desc']],
6666
'top' => ['key' => 'top', 'name' => 'Top', 'orderBy' => ['Score' => 'desc', 'DateInserted' => 'desc']],
67+
'views' => ['key' => 'views', 'name' => 'Top Views', 'orderBy' => ['CountViews' => 'desc', 'DateInserted' => 'desc']],
68+
'comments' => ['key' => 'comments', 'name' => 'Top Comments', 'orderBy' => ['CountComments' => 'desc', 'DateInserted' => 'desc']],
6769
'new' => ['key' => 'new', 'name' => 'New', 'orderBy' => ['LastDiscussionCommentsDate' => 'desc']],
68-
'old' => ['key' => 'old', 'name' => 'Old', 'orderBy' => ['LastDiscussionCommentsDate' => 'asc']]
70+
'old' => ['key' => 'old', 'name' => 'Old', 'orderBy' => ['LastDiscussionCommentsDate' => 'asc']],
71+
'name' => ['key' => 'name', 'name' => 'Title', 'orderBy' => ['Name' => 'asc']]
6972
];
7073

7174
/**

0 commit comments

Comments
 (0)