Skip to content

Commit e7d2bf5

Browse files
authored
Merge pull request #34 from topcoder-platform/issues-244
Issues-218:default category
2 parents deaf0bf + 78ba142 commit e7d2bf5

File tree

3 files changed

+26
-16
lines changed

3 files changed

+26
-16
lines changed

class.groups.plugin.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -602,7 +602,7 @@ public function discussionModel_beforeRecordAdvancedNotification_handler($sender
602602
}
603603
$data["HeadlineFormat"] = $headline;
604604
// Format to Html
605-
$story = condense(Gdn_Format::to($discussion['Body'], $discussion['Format']));
605+
$story = Gdn::formatService()->renderHTML($discussion['Body'], $discussion['Format']);
606606
$message = $story; // htmlspecialchars(Gdn_Format::plainText($story, 'Html'));
607607
// We just converted it to HTML. Make sure everything downstream knows it.
608608
// Taking this HTML and feeding it into the Rich Format for example, would be invalid.
@@ -659,7 +659,7 @@ public function commentModel_beforeRecordAdvancedNotification($sender, $args){
659659
// $data["HeadlineFormat"] = 'The new discussion has been posted in the category ' . $categoryName . '.';
660660
// Format to Html
661661
$discussionStory = condense(Gdn_Format::to($discussion['Body'], $discussion['Format']));
662-
$commentStory = condense(Gdn_Format::to($comment['Body'], $comment['Format']));
662+
$commentStory = Gdn::formatService()->renderHTML($comment['Body'],$comment['Format']);
663663
// We just converted it to HTML. Make sure everything downstream knows it.
664664
// Taking this HTML and feeding it into the required format for example, would be invalid.
665665
$data['Format'] = 'Html';

controllers/class.groupcontroller.php

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,27 @@ public function index($GroupID = '') {
8989
$this->setData('Leaders', $this->GroupModel->getLeaders($GroupID));
9090
$this->setData('Members', $this->GroupModel->getMembers($GroupID,[],'',30,0));
9191

92+
$groupDiscussions = $this->GroupModel->getGroupDiscussionCategories($Group);
93+
$defaultDiscussionUrl = '/post/discussion/';
94+
if($Group->Type == GroupModel::TYPE_REGULAR) {
95+
if(count($groupDiscussions) > 0) {
96+
$defaultDiscussionUrl .= $groupDiscussions[0]['UrlCode'];
97+
}
98+
} else if($Group->Type == GroupModel::TYPE_CHALLENGE) {
99+
if(count($groupDiscussions) == 1) {
100+
$defaultDiscussionUrl .= $groupDiscussions[0]['UrlCode'];
101+
} else {
102+
foreach ($groupDiscussions as $groupDiscussion) {
103+
if ($groupDiscussion['Name'] == 'Code Questions') {
104+
$defaultDiscussionUrl .= $groupDiscussion['UrlCode'];
105+
break;
106+
}
107+
}
108+
}
109+
}
110+
111+
$this->setData('DefaultDiscussionUrl', $defaultDiscussionUrl);
112+
92113
// Find all discussions with content from after DateMarkedRead.
93114
$discussionModel = new DiscussionModel();
94115
$categoryIDs = $this->GroupModel->getAllGroupCategoryIDs($Group->GroupID);

views/group/index.php

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
$groupModel = new GroupModel();
1919
$currentTopcoderProjectRoles = Gdn::controller()->data('ChallengeCurrentUserProjectRoles');
2020
$groupModel->setCurrentUserTopcoderProjectRoles($currentTopcoderProjectRoles);
21-
$discussionCategories = $groupModel->getGroupDiscussionCategories($Group);
21+
2222
?>
2323
<?php echo writeGroupHeader($Group, true, $Owner, $Leaders, $TotalMembers);?>
2424

@@ -30,13 +30,7 @@
3030
<?php
3131

3232
if($groupModel->canAddAnnouncement($Group)) {
33-
if(count($discussionCategories) > 0 && $Group->Type == GroupModel::TYPE_REGULAR) {
34-
// The group category is selected automatically
35-
$firstCategory = $discussionCategories[0];
36-
echo anchor('New Announcement', '/post/discussion/'.$firstCategory['UrlCode'], 'Button Primary', '');
37-
} else {
38-
echo anchor('New Announcement', '/post/discussion/', 'Button Primary', '');
39-
}
33+
echo anchor('New Announcement', $this->data('DefaultDiscussionUrl'), 'Button Primary', '');
4034
}
4135
?>
4236
</div>
@@ -60,12 +54,7 @@
6054
<?php
6155
if($groupModel->canAddDiscussion($Group)) {
6256
// The group category is selected automatically
63-
if (count($discussionCategories) > 0 && $Group->Type == GroupModel::TYPE_REGULAR) {
64-
$firstCategory = $discussionCategories[0];
65-
echo anchor('New Discussion', '/post/discussion/' . $firstCategory['UrlCode'], 'Button Primary', '');
66-
} else {
67-
echo anchor('New Discussion', '/post/discussion/', 'Button Primary', '');
68-
}
57+
echo anchor('New Discussion', $this->data('DefaultDiscussionUrl'), 'Button Primary', '');
6958
}
7059
?>
7160
</div>

0 commit comments

Comments
 (0)