From ca4a3b91d8db7e3beebd51d4f26b1ef3db7302f4 Mon Sep 17 00:00:00 2001 From: Andrew O'Neil Date: Fri, 10 Aug 2007 04:33:02 +0000 Subject: [PATCH] Only show unmoderated comments if the user is an admin git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/cms/trunk@39834 467b73ca-7a2a-4603-9d3b-597d59a354a9 --- code/sitefeatures/PageCommentInterface.php | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/code/sitefeatures/PageCommentInterface.php b/code/sitefeatures/PageCommentInterface.php index 16cdfcf8..71bad90e 100755 --- a/code/sitefeatures/PageCommentInterface.php +++ b/code/sitefeatures/PageCommentInterface.php @@ -65,11 +65,9 @@ class PageCommentInterface extends ViewableData { $limit = "0,".PageComment::$comments_per_page; } - if(isset($_GET['showspam'])) { - $comments = DataObject::get("PageComment", "ParentID = '" . Convert::raw2sql($this->page->ID) . "'", "Created DESC", "", $limit); - } else { - $comments = DataObject::get("PageComment", "ParentID = '" . Convert::raw2sql($this->page->ID) . "' AND IsSpam = 0", "Created DESC", "", $limit); - } + $spamfilter = isset($_GET['showspam']) ? '' : 'AND IsSpam=0'; + $unmoderatedfilter = Permission::check('ADMIN') ? '' : 'AND NeedsModeration = 0'; + $comments = DataObject::get("PageComment", "ParentID = '" . Convert::raw2sql($this->page->ID) . "' $spamfilter $unmoderatedfilter", "Created DESC", "", $limit); if(is_null($comments)) { return;