From 3c4b53030b431b9190ffc1442a2a06d32b902c12 Mon Sep 17 00:00:00 2001 From: Andrew O'Neil Date: Mon, 13 Aug 2007 00:39:37 +0000 Subject: [PATCH] Added a delete all button in the spam folder git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/cms/trunk@39906 467b73ca-7a2a-4603-9d3b-597d59a354a9 --- code/CommentAdmin.php | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/code/CommentAdmin.php b/code/CommentAdmin.php index 9bb3adb5..e23bbec1 100644 --- a/code/CommentAdmin.php +++ b/code/CommentAdmin.php @@ -78,6 +78,10 @@ class CommentAdmin extends LeftAndMain { $actions->push(new FormAction('deletemarked', 'Delete')); + if($section == 'spam') { + $actions->push(new FormAction('deleteall', 'Delete All')); + } + $form = new Form($this, "EditForm", $fields, $actions); return $form; @@ -107,6 +111,25 @@ class CommentAdmin extends LeftAndMain { JS; } + function deleteall() { + $numComments = 0; + $spam = DataObject::get('PageComment', "PageComment.IsSpam=1"); + + if($spam) { + $numComments = $spam->Count(); + + foreach($spam as $comment) { + $comment->delete(); + } + } + + echo <<