Skip to content

Commit fd0cffc

Browse files
authored
Merge pull request #70 from topcoder-platform/issues-490
Issues-490: Move reply to comment block
2 parents 3a8e472 + ac2acb1 commit fd0cffc

File tree

2 files changed

+45
-6
lines changed

2 files changed

+45
-6
lines changed

ReplyTo/class.replyto.plugin.php

Lines changed: 41 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ public function postController_render_before($sender) {
7171
* @param $sender
7272
* @param $args
7373
*/
74-
public function base_Replies_handler($sender, $args){
74+
public function base_InlineDiscussionOptionsLeft_handler($sender, $args){
7575
$discussion = $sender->data('Discussion');
7676
if (!$discussion) {
7777
return;
@@ -84,10 +84,44 @@ public function base_Replies_handler($sender, $args){
8484
$discussionUrl = discussionUrl($discussion, '', '/');
8585
$viewMode = self::getViewMode();
8686

87-
echo '<div class="ReplyViewOptions"><span class="MLabel">View:&nbsp</span>';
88-
echo anchor('Threaded', $discussionUrl.'?'.self::QUERY_PARAMETER_VIEW.'='.self::VIEW_THREADED, $viewMode == self::VIEW_THREADED?'Active':'').'&nbsp;&nbsp;|&nbsp;&nbsp;';
89-
echo anchor('Flat', $discussionUrl.'?'.self::QUERY_PARAMETER_VIEW.'='.self::VIEW_FLAT, $viewMode == self::VIEW_FLAT?'Active':'');
90-
echo '</div>';
87+
echo '<span class="ReplyViewOptions">';
88+
echo '<span class="MLabel">View:&nbsp</span>';
89+
echo anchor('Threaded', $discussionUrl.'?'.self::QUERY_PARAMETER_VIEW.'='.self::VIEW_THREADED, $viewMode == self::VIEW_THREADED?'ReplyViewOptionLink Active':'ReplyViewOptionLink').'&nbsp;&nbsp;|&nbsp;&nbsp;';
90+
echo anchor('Flat', $discussionUrl.'?'.self::QUERY_PARAMETER_VIEW.'='.self::VIEW_FLAT, $viewMode == self::VIEW_FLAT?'ReplyViewOptionLink Active':'ReplyViewOptionLink');
91+
echo '</span>';
92+
}
93+
94+
public function base_inlineCommentOptionsRight_handler($sender, $args) {
95+
ReplyToPlugin::log('base_inlineCommentOptionsRight_handler', []);
96+
97+
if (!Gdn::Session()->isValid()) {
98+
return;
99+
}
100+
101+
$discussion = $sender->data('Discussion');
102+
$isClosed = ((int)$discussion->Closed) == 1;
103+
if ($isClosed) {
104+
return;
105+
}
106+
107+
//Check permission
108+
$CategoryID = val('PermissionCategoryID', $discussion) ? val('PermissionCategoryID', $discussion) : val('CategoryID', $discussion);
109+
110+
// Can the user comment on this category, and is the discussion open for comments?
111+
if (!Gdn::Session()->CheckPermission('Vanilla.Comments.Add', TRUE, 'Category', $CategoryID)) {
112+
return;
113+
}
114+
115+
$viewMode = self::getViewMode();
116+
$comment = &$args['Comment'];
117+
$items = & $args['Items'];
118+
$commentID = val('CommentID', $comment);
119+
if(empty($items)) {
120+
$items = [];
121+
}
122+
array_push( $items, anchor(
123+
t('Reply'),
124+
url("/?ParentCommentID=".$commentID."&view=".$viewMode, false), 'ReplyComment'));
91125
}
92126

93127
/**
@@ -208,6 +242,7 @@ public function base_commentOptions_handler($sender, $args) {
208242
return;
209243
}
210244

245+
/*
211246
$options = &$args['CommentOptions'];
212247
$comment = &$args['Comment'];
213248
$options['ReplyToComment'] = [
@@ -229,6 +264,7 @@ public function base_commentOptions_handler($sender, $args) {
229264
$options[$key]['Url'] = $currentUrl.'?view='.$viewMode;
230265
}
231266
}
267+
*/
232268
}
233269

234270
/**

ReplyTo/design/replyto.css

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,11 @@
33
display: inline-block;
44
line-height: 1.5;
55
}
6+
.MessageList .ItemDiscussion .Item-Body .Controls a.ReplyViewOptionLink, .ReplyViewOptions .ReplyViewOptionLink {
7+
color: #137d60;
8+
}
69

7-
.ReplyViewOptions a.Active {
10+
.MessageList .ItemDiscussion .Item-Body .Controls a.ReplyViewOptionLink.Active, .ReplyViewOptions .ReplyViewOptionLink.Active {
811
color: #696969;
912
font-weight: 800;
1013
}

0 commit comments

Comments
 (0)