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
This commit is contained in:
Andrew O'Neil 2007-08-10 04:33:02 +00:00
parent d5a0cf374f
commit ca4a3b91d8

View File

@ -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;