Permalink
Browse files

BUG: Fixing moderation on the comments module

  • Loading branch information...
1 parent 86d417b commit 7689623503ae16c02be22268a3c824546e104449 @kmayo-ss kmayo-ss committed with wilr Aug 8, 2012
@@ -357,6 +357,12 @@ public function doPostComment($data, $form) {
// 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 @@ public function doPostComment($data, $form) {
return ($url) ? $this->redirect($url .'#'. $hash) : $this->redirectBack();
}
-}
+}
@@ -68,9 +68,19 @@ public function Comments() {
$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 @@ public function CommentsForm() {
$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 @@ public function CommentsForm() {
'RssLinkPage' => "CommentingController/rss/". $this->ownerBaseClass . '/'.$this->owner->ID,
'CommentsEnabled' => $enabled,
'AddCommentForm' => $form,
+ 'ModeratedSubmitted' => $moderatedSubmitted,
'Comments' => $this->Comments()
)));
}
@@ -148,4 +162,4 @@ public function PageComments() {
return $this->CommentsForm();
}
-}
+}
@@ -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 %>.

0 comments on commit 7689623

Please sign in to comment.