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
This commit is contained in:
Andrew O'Neil 2007-08-10 01:29:09 +00:00
parent bae1e1757d
commit 858e877858

View File

@ -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();
}