Skip to content

Commit e675f37

Browse files
committed
Issues-490: Add reply link in comment/discission options
1 parent c1d2628 commit e675f37

File tree

2 files changed

+40
-38
lines changed

2 files changed

+40
-38
lines changed

ReplyTo/class.replyto.plugin.php

Lines changed: 38 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -91,39 +91,6 @@ public function base_InlineDiscussionOptionsLeft_handler($sender, $args){
9191
echo '</span>';
9292
}
9393

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'));
125-
}
126-
12794
/**
12895
* Set the tree order of all comments in the model as soon as it is instantiated.
12996
* It is not clear if there are other plugins that may also wish to change the ordering.
@@ -242,9 +209,8 @@ public function base_commentOptions_handler($sender, $args) {
242209
return;
243210
}
244211

245-
/*
246212
$options = &$args['CommentOptions'];
247-
$comment = &$args['Comment'];
213+
$comment = $args['Comment'];
248214
$options['ReplyToComment'] = [
249215
'Label' => t('Reply'),
250216
'Url' => '/?ParentCommentID='.$comment->CommentID,
@@ -264,7 +230,43 @@ public function base_commentOptions_handler($sender, $args) {
264230
$options[$key]['Url'] = $currentUrl.'?view='.$viewMode;
265231
}
266232
}
267-
*/
233+
}
234+
235+
/**
236+
* Add 'Reply' option to discussion.
237+
*
238+
* @param Gdn_Controller $sender
239+
* @param array $args
240+
*/
241+
public function base_inlineDiscussionOptions_handler($sender, $args) {
242+
$discussion = $args['Discussion'];
243+
if (!$discussion) {
244+
return;
245+
}
246+
247+
$isClosed = ((int)$discussion->Closed) == 1;
248+
if ($isClosed) {
249+
return;
250+
}
251+
252+
if (!Gdn::session()->UserID) {
253+
return;
254+
}
255+
256+
//Check permission
257+
if (isset($discussion->PermissionCategoryID)) {
258+
$CategoryID = val('PermissionCategoryID', $discussion);
259+
} else {
260+
$CategoryID = $discussion->CategoryID;
261+
}
262+
263+
// Can the user comment on this category, and is the discussion open for comments?
264+
if (!Gdn::Session()->CheckPermission('Vanilla.Comments.Add', TRUE, 'Category', $CategoryID)) {
265+
return;
266+
}
267+
// DropdownModule options
268+
$options = & $args['DiscussionOptions'];
269+
$options->addLink('Reply', url("/", true), 'reply', 'ReplyComment');
268270
}
269271

270272
/**

ReplyTo/design/replyto.css

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11

22
.ReplyViewOptions {
3+
font-family: roboto, Segoe UI, Helvetica Neue, Helvetica, Raleway, Arial, sans-serif;
34
display: inline-block;
45
line-height: 1.5;
56
}
@@ -8,8 +9,7 @@
89
}
910

1011
.MessageList .ItemDiscussion .Item-Body .Controls a.ReplyViewOptionLink.Active, .ReplyViewOptions .ReplyViewOptionLink.Active {
11-
color: #696969;
12-
font-weight: 800;
12+
color: #555555;
1313
}
1414
/*
1515
Indent comments according to their depth.

0 commit comments

Comments
 (0)