mirror of
https://github.com/silverstripe/silverstripe-comments
synced 2024-10-22 11:05:49 +02:00
BUG: Fixing moderation on the comments module
This commit is contained in:
parent
86d417bff0
commit
008780387f
@ -358,6 +358,12 @@ class CommentingController extends Controller {
|
||||
// is moderation turned on
|
||||
$moderated = Commenting::get_config_value($class, 'require_moderation');
|
||||
|
||||
// we want to show a notification if comments are moderated
|
||||
if ($moderated) {
|
||||
Session::set('CommentsModerated', 1);
|
||||
}
|
||||
|
||||
|
||||
$comment = new Comment();
|
||||
$form->saveInto($comment);
|
||||
|
||||
|
@ -69,8 +69,18 @@ class CommentsExtension extends DataExtension {
|
||||
|
||||
$order = Commenting::get_config_value($this->ownerBaseClass, 'order_comments_by');
|
||||
|
||||
// has moderation been turned on if it has amend the sql query
|
||||
$moderation = '';
|
||||
if (Commenting::get_config_value($this->ownerBaseClass, 'require_moderation')) {
|
||||
|
||||
$member = new Member();
|
||||
if ($member->currentUser() == false) {
|
||||
$moderation = 'Moderated = 1 AND ';
|
||||
}
|
||||
}
|
||||
|
||||
$list = new PaginatedList(Comment::get()->where(sprintf(
|
||||
"ParentID = '%s' AND BaseClass = '%s'", $this->owner->ID, $this->ownerBaseClass
|
||||
$moderation . "ParentID = '%s' AND BaseClass = '%s'", $this->owner->ID, $this->ownerBaseClass
|
||||
))->sort($order));
|
||||
|
||||
$list->setPageLength(Commenting::get_config_value(
|
||||
@ -112,6 +122,9 @@ class CommentsExtension extends DataExtension {
|
||||
$controller->setBaseClass($this->ownerBaseClass);
|
||||
$controller->setOwnerController(Controller::curr());
|
||||
|
||||
$moderatedSubmitted = Session::get('CommentsModerated');
|
||||
Session::clear('CommentsModerated');
|
||||
|
||||
$form = ($enabled) ? $controller->CommentsForm() : false;
|
||||
|
||||
// a little bit all over the show but to ensure a slightly easier upgrade for users
|
||||
@ -124,6 +137,7 @@ class CommentsExtension extends DataExtension {
|
||||
'RssLinkPage' => "CommentingController/rss/". $this->ownerBaseClass . '/'.$this->owner->ID,
|
||||
'CommentsEnabled' => $enabled,
|
||||
'AddCommentForm' => $form,
|
||||
'ModeratedSubmitted' => $moderatedSubmitted,
|
||||
'Comments' => $this->Comments()
|
||||
)));
|
||||
}
|
||||
|
@ -4,6 +4,9 @@
|
||||
|
||||
<% if AddCommentForm %>
|
||||
<% if CanPost %>
|
||||
<% if ModeratedSubmitted %>
|
||||
<p id="PageCommentInterface_Form_PostCommentForm_error" class="message good"><% _t('AWAITINGMODERATION', 'Your comment has been submitted and is now awaiting moderation.') %></p>
|
||||
<% end_if %>
|
||||
$AddCommentForm
|
||||
<% else %>
|
||||
<p><% _t('COMMENTLOGINERROR', 'You cannot post comments until you have logged in') %><% if PostingRequiresPermission %>,<% _t('COMMENTPERMISSIONERROR', 'and that you have an appropriate permission level') %><% end_if %>.
|
||||
|
Loading…
Reference in New Issue
Block a user