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
This commit is contained in:
Andrew O'Neil 2007-08-13 00:39:37 +00:00
parent 3d5d9200ca
commit 3c4b53030b

View File

@ -78,6 +78,10 @@ class CommentAdmin extends LeftAndMain {
$actions->push(new FormAction('deletemarked', 'Delete')); $actions->push(new FormAction('deletemarked', 'Delete'));
if($section == 'spam') {
$actions->push(new FormAction('deleteall', 'Delete All'));
}
$form = new Form($this, "EditForm", $fields, $actions); $form = new Form($this, "EditForm", $fields, $actions);
return $form; return $form;
@ -107,6 +111,25 @@ class CommentAdmin extends LeftAndMain {
JS; JS;
} }
function deleteall() {
$numComments = 0;
$spam = DataObject::get('PageComment', "PageComment.IsSpam=1");
if($spam) {
$numComments = $spam->Count();
foreach($spam as $comment) {
$comment->delete();
}
}
echo <<<JS
$('Form_EditForm').getPageFromServer($('Form_EditForm_ID').value);
statusMessage("Deleted $numComments comments.");
JS;
}
function spammarked() { function spammarked() {
$numComments = 0; $numComments = 0;
$folderID = 0; $folderID = 0;