Skip to content

Commit 664f738

Browse files
committed
Render a quote link if user has proper permissions
1 parent 2f7d0d1 commit 664f738

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

vanilla/plugins/Quotes/class.quotes.plugin.php

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -264,16 +264,18 @@ protected function addQuoteButton($sender, $args) {
264264
return;
265265
}
266266

267-
$isClosed = ((int)$discussion->Closed) == 1;
268-
if ($isClosed) {
269-
return;
270-
}
271-
272267
if (!Gdn::session()->UserID) {
273268
return;
274269
}
275270

276-
if (!Gdn::session()->checkPermission('Vanilla.Comments.Add', false, 'Category', $discussion->PermissionCategoryID)) {
271+
//Check permission
272+
$CategoryID = val('PermissionCategoryID', $discussion)? val('PermissionCategoryID', $discussion):val('CategoryID', $discussion);
273+
$userCanClose = CategoryModel::checkPermission($CategoryID, 'Vanilla.Discussions.Close');
274+
$userCanComment = CategoryModel::checkPermission($CategoryID, 'Vanilla.Comments.Add');
275+
276+
// See the 'writeCommentForm' method vanilla/applications/vanilla/views/discussion/helper_functions.php
277+
$canAddComment = ($discussion->Closed == '1' && $userCanClose) || ($discussion->Closed == '0' && $userCanComment);
278+
if (!$canAddComment) {
277279
return;
278280
}
279281

0 commit comments

Comments
 (0)