BUG: Fixing moderation on the comments module

This commit is contained in:
Kirk Mayo 2012-08-08 12:51:14 +12:00 committed by Will Rossiter
parent 86d417bff0
commit 7689623503
3 changed files with 26 additions and 3 deletions

View File

@ -357,6 +357,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);
@ -384,4 +390,4 @@ class CommentingController extends Controller {
return ($url) ? $this->redirect($url .'#'. $hash) : $this->redirectBack();
}
}
}

View File

@ -68,9 +68,19 @@ class CommentsExtension extends DataExtension {
$controller = Controller::curr();
$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(
@ -111,6 +121,9 @@ class CommentsExtension extends DataExtension {
$controller->setOwnerRecord($this->owner);
$controller->setBaseClass($this->ownerBaseClass);
$controller->setOwnerController(Controller::curr());
$moderatedSubmitted = Session::get('CommentsModerated');
Session::clear('CommentsModerated');
$form = ($enabled) ? $controller->CommentsForm() : false;
@ -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()
)));
}
@ -148,4 +162,4 @@ class CommentsExtension extends DataExtension {
return $this->CommentsForm();
}
}
}

View File

@ -4,6 +4,9 @@
<% if AddCommentForm %>
<% if CanPost %>
<% if ModeratedSubmitted %>
<p id="$CommentHolderID_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 %>.