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