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

@ -358,6 +358,12 @@ class CommentingController extends Controller {
// is moderation turned on // is moderation turned on
$moderated = Commenting::get_config_value($class, 'require_moderation'); $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(); $comment = new Comment();
$form->saveInto($comment); $form->saveInto($comment);

View File

@ -69,8 +69,18 @@ class CommentsExtension extends DataExtension {
$order = Commenting::get_config_value($this->ownerBaseClass, 'order_comments_by'); $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( $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)); ))->sort($order));
$list->setPageLength(Commenting::get_config_value( $list->setPageLength(Commenting::get_config_value(
@ -112,6 +122,9 @@ class CommentsExtension extends DataExtension {
$controller->setBaseClass($this->ownerBaseClass); $controller->setBaseClass($this->ownerBaseClass);
$controller->setOwnerController(Controller::curr()); $controller->setOwnerController(Controller::curr());
$moderatedSubmitted = Session::get('CommentsModerated');
Session::clear('CommentsModerated');
$form = ($enabled) ? $controller->CommentsForm() : false; $form = ($enabled) ? $controller->CommentsForm() : false;
// a little bit all over the show but to ensure a slightly easier upgrade for users // 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, 'RssLinkPage' => "CommentingController/rss/". $this->ownerBaseClass . '/'.$this->owner->ID,
'CommentsEnabled' => $enabled, 'CommentsEnabled' => $enabled,
'AddCommentForm' => $form, 'AddCommentForm' => $form,
'ModeratedSubmitted' => $moderatedSubmitted,
'Comments' => $this->Comments() 'Comments' => $this->Comments()
))); )));
} }

View File

@ -4,6 +4,9 @@
<% if AddCommentForm %> <% if AddCommentForm %>
<% if CanPost %> <% 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 $AddCommentForm
<% else %> <% 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 %>. <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 %>.