Skip to content

Issues-218:default category #34

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 30, 2020
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
4 changes: 2 additions & 2 deletions class.groups.plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -602,7 +602,7 @@ public function discussionModel_beforeRecordAdvancedNotification_handler($sender
}
$data["HeadlineFormat"] = $headline;
// Format to Html
$story = condense(Gdn_Format::to($discussion['Body'], $discussion['Format']));
$story = Gdn::formatService()->renderHTML($discussion['Body'], $discussion['Format']);
$message = $story; // htmlspecialchars(Gdn_Format::plainText($story, 'Html'));
// We just converted it to HTML. Make sure everything downstream knows it.
// Taking this HTML and feeding it into the Rich Format for example, would be invalid.
Expand Down Expand Up @@ -659,7 +659,7 @@ public function commentModel_beforeRecordAdvancedNotification($sender, $args){
// $data["HeadlineFormat"] = 'The new discussion has been posted in the category ' . $categoryName . '.';
// Format to Html
$discussionStory = condense(Gdn_Format::to($discussion['Body'], $discussion['Format']));
$commentStory = condense(Gdn_Format::to($comment['Body'], $comment['Format']));
$commentStory = Gdn::formatService()->renderHTML($comment['Body'],$comment['Format']);
// We just converted it to HTML. Make sure everything downstream knows it.
// Taking this HTML and feeding it into the required format for example, would be invalid.
$data['Format'] = 'Html';
Expand Down
21 changes: 21 additions & 0 deletions controllers/class.groupcontroller.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,27 @@ public function index($GroupID = '') {
$this->setData('Leaders', $this->GroupModel->getLeaders($GroupID));
$this->setData('Members', $this->GroupModel->getMembers($GroupID,[],'',30,0));

$groupDiscussions = $this->GroupModel->getGroupDiscussionCategories($Group);
$defaultDiscussionUrl = '/post/discussion/';
if($Group->Type == GroupModel::TYPE_REGULAR) {
if(count($groupDiscussions) > 0) {
$defaultDiscussionUrl .= $groupDiscussions[0]['UrlCode'];
}
} else if($Group->Type == GroupModel::TYPE_CHALLENGE) {
if(count($groupDiscussions) == 1) {
$defaultDiscussionUrl .= $groupDiscussions[0]['UrlCode'];
} else {
foreach ($groupDiscussions as $groupDiscussion) {
if ($groupDiscussion['Name'] == 'Code Questions') {
$defaultDiscussionUrl .= $groupDiscussion['UrlCode'];
break;
}
}
}
}

$this->setData('DefaultDiscussionUrl', $defaultDiscussionUrl);

// Find all discussions with content from after DateMarkedRead.
$discussionModel = new DiscussionModel();
$categoryIDs = $this->GroupModel->getAllGroupCategoryIDs($Group->GroupID);
Expand Down
17 changes: 3 additions & 14 deletions views/group/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
$groupModel = new GroupModel();
$currentTopcoderProjectRoles = Gdn::controller()->data('ChallengeCurrentUserProjectRoles');
$groupModel->setCurrentUserTopcoderProjectRoles($currentTopcoderProjectRoles);
$discussionCategories = $groupModel->getGroupDiscussionCategories($Group);

?>
<?php echo writeGroupHeader($Group, true, $Owner, $Leaders, $TotalMembers);?>

Expand All @@ -30,13 +30,7 @@
<?php

if($groupModel->canAddAnnouncement($Group)) {
if(count($discussionCategories) > 0 && $Group->Type == GroupModel::TYPE_REGULAR) {
// The group category is selected automatically
$firstCategory = $discussionCategories[0];
echo anchor('New Announcement', '/post/discussion/'.$firstCategory['UrlCode'], 'Button Primary', '');
} else {
echo anchor('New Announcement', '/post/discussion/', 'Button Primary', '');
}
echo anchor('New Announcement', $this->data('DefaultDiscussionUrl'), 'Button Primary', '');
}
?>
</div>
Expand All @@ -60,12 +54,7 @@
<?php
if($groupModel->canAddDiscussion($Group)) {
// The group category is selected automatically
if (count($discussionCategories) > 0 && $Group->Type == GroupModel::TYPE_REGULAR) {
$firstCategory = $discussionCategories[0];
echo anchor('New Discussion', '/post/discussion/' . $firstCategory['UrlCode'], 'Button Primary', '');
} else {
echo anchor('New Discussion', '/post/discussion/', 'Button Primary', '');
}
echo anchor('New Discussion', $this->data('DefaultDiscussionUrl'), 'Button Primary', '');
}
?>
</div>
Expand Down