diff --git a/ReplyTo/class.replyto.plugin.php b/ReplyTo/class.replyto.plugin.php index 530fafb..075e229 100644 --- a/ReplyTo/class.replyto.plugin.php +++ b/ReplyTo/class.replyto.plugin.php @@ -71,7 +71,7 @@ public function postController_render_before($sender) { * @param $sender * @param $args */ - public function base_Replies_handler($sender, $args){ + public function base_InlineDiscussionOptionsLeft_handler($sender, $args){ $discussion = $sender->data('Discussion'); if (!$discussion) { return; @@ -84,10 +84,44 @@ public function base_Replies_handler($sender, $args){ $discussionUrl = discussionUrl($discussion, '', '/'); $viewMode = self::getViewMode(); - echo '
View: '; - echo anchor('Threaded', $discussionUrl.'?'.self::QUERY_PARAMETER_VIEW.'='.self::VIEW_THREADED, $viewMode == self::VIEW_THREADED?'Active':'').'  |  '; - echo anchor('Flat', $discussionUrl.'?'.self::QUERY_PARAMETER_VIEW.'='.self::VIEW_FLAT, $viewMode == self::VIEW_FLAT?'Active':''); - echo '
'; + echo ''; + echo 'View: '; + echo anchor('Threaded', $discussionUrl.'?'.self::QUERY_PARAMETER_VIEW.'='.self::VIEW_THREADED, $viewMode == self::VIEW_THREADED?'ReplyViewOptionLink Active':'ReplyViewOptionLink').'  |  '; + echo anchor('Flat', $discussionUrl.'?'.self::QUERY_PARAMETER_VIEW.'='.self::VIEW_FLAT, $viewMode == self::VIEW_FLAT?'ReplyViewOptionLink Active':'ReplyViewOptionLink'); + echo ''; + } + + public function base_inlineCommentOptionsRight_handler($sender, $args) { + ReplyToPlugin::log('base_inlineCommentOptionsRight_handler', []); + + if (!Gdn::Session()->isValid()) { + return; + } + + $discussion = $sender->data('Discussion'); + $isClosed = ((int)$discussion->Closed) == 1; + if ($isClosed) { + return; + } + + //Check permission + $CategoryID = val('PermissionCategoryID', $discussion) ? val('PermissionCategoryID', $discussion) : val('CategoryID', $discussion); + + // Can the user comment on this category, and is the discussion open for comments? + if (!Gdn::Session()->CheckPermission('Vanilla.Comments.Add', TRUE, 'Category', $CategoryID)) { + return; + } + + $viewMode = self::getViewMode(); + $comment = &$args['Comment']; + $items = & $args['Items']; + $commentID = val('CommentID', $comment); + if(empty($items)) { + $items = []; + } + array_push( $items, anchor( + t('Reply'), + url("/?ParentCommentID=".$commentID."&view=".$viewMode, false), 'ReplyComment')); } /** @@ -208,6 +242,7 @@ public function base_commentOptions_handler($sender, $args) { return; } + /* $options = &$args['CommentOptions']; $comment = &$args['Comment']; $options['ReplyToComment'] = [ @@ -229,6 +264,7 @@ public function base_commentOptions_handler($sender, $args) { $options[$key]['Url'] = $currentUrl.'?view='.$viewMode; } } + */ } /** diff --git a/ReplyTo/design/replyto.css b/ReplyTo/design/replyto.css index 81027a2..7b8916a 100644 --- a/ReplyTo/design/replyto.css +++ b/ReplyTo/design/replyto.css @@ -3,8 +3,11 @@ display: inline-block; line-height: 1.5; } +.MessageList .ItemDiscussion .Item-Body .Controls a.ReplyViewOptionLink, .ReplyViewOptions .ReplyViewOptionLink { + color: #137d60; +} -.ReplyViewOptions a.Active { +.MessageList .ItemDiscussion .Item-Body .Controls a.ReplyViewOptionLink.Active, .ReplyViewOptions .ReplyViewOptionLink.Active { color: #696969; font-weight: 800; }