From 858e877858de81acfee54a5d6de3dc684fe0528c Mon Sep 17 00:00:00 2001 From: Andrew O'Neil Date: Fri, 10 Aug 2007 01:29:09 +0000 Subject: [PATCH] Don't show unmoderated comments unless user is admin, add link to accept comment git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@39818 467b73ca-7a2a-4603-9d3b-597d59a354a9 --- core/model/SiteTree.php | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/core/model/SiteTree.php b/core/model/SiteTree.php index 79d1194be..364ca8089 100644 --- a/core/model/SiteTree.php +++ b/core/model/SiteTree.php @@ -88,11 +88,9 @@ class SiteTree extends DataObject { * @return DataObjectSet Comments on this page. */ public function Comments() { - if(isset($_GET['showspam'])) { - $comments = DataObject::get("PageComment", "ParentID = '" . Convert::raw2sql($this->ID) . "'", "Created DESC"); - } else { - $comments = DataObject::get("PageComment", "ParentID = '" . Convert::raw2sql($this->ID) . "' AND IsSpam = 0", "Created DESC"); - } + $spamfilter = isset($_GET['showspam']) ? '' : 'AND IsSpam=0'; + $unmoderatedfilter = Permission::check('ADMIN') ? '' : 'AND NeedsModeration = 0'; + $comments = DataObject::get("PageComment", "ParentID = '" . Convert::raw2sql($this->ID) . "' $spamfilter $unmoderatedfilter", "Created DESC"); return $comments ? $comments : new DataObjectSet(); }