diff --git a/code/controllers/CommentingController.php b/code/controllers/CommentingController.php index 8c4bfdf..d2f6faa 100644 --- a/code/controllers/CommentingController.php +++ b/code/controllers/CommentingController.php @@ -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(); } -} \ No newline at end of file +} diff --git a/code/extensions/CommentsExtension.php b/code/extensions/CommentsExtension.php index 767ee8e..9e9b6e8 100644 --- a/code/extensions/CommentsExtension.php +++ b/code/extensions/CommentsExtension.php @@ -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(); } -} \ No newline at end of file +} diff --git a/templates/CommentsInterface.ss b/templates/CommentsInterface.ss index e331631..f42f969 100755 --- a/templates/CommentsInterface.ss +++ b/templates/CommentsInterface.ss @@ -4,6 +4,9 @@ <% if AddCommentForm %> <% if CanPost %> + <% if ModeratedSubmitted %> +
+ <% end_if %> $AddCommentForm <% else %><% _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 %>.