MINOR added batch deletion back for workflow (from r88916)

git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/cms/branches/2.4@96789 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
Sam Minnee 2010-01-12 23:59:49 +00:00
parent 430f30b7c4
commit 2cf10e76fe
2 changed files with 9 additions and 7 deletions

View File

@ -107,11 +107,14 @@ class CMSBatchAction_Delete extends CMSBatchAction {
}
function run(DataObjectSet $pages) {
$failures = 0;
foreach($pages as $page) {
$id = $page->ID;
// Perform the action
if($page->canDelete()) $page->delete();
else $failures++;
// check to see if the record exists on the live site, if it doesn't remove the tree node
$liveRecord = Versioned::get_one_by_stage( 'SiteTree', 'Live', "\"SiteTree\".\"ID\"=$id");
@ -130,7 +133,7 @@ class CMSBatchAction_Delete extends CMSBatchAction {
unset($page);
}
$message = sprintf(_t('CMSBatchActions.DELETED_DRAFT_PAGES', 'Deleted %d pages from the draft site'), $pages->Count());
$message = sprintf(_t('CMSBatchActions.DELETED_DRAFT_PAGES', 'Deleted %d pages from the draft site'), $pages->Count()-$failures);
FormResponse::add('statusMessage("'.$message.'","good");');
return FormResponse::respond();
@ -160,7 +163,7 @@ class CMSBatchAction_DeleteFromLive extends CMSBatchAction {
foreach($ids as $pageID) {
$id = $pageID;
// check to see if the record exists on the live site, if it doesn't remove the tree node
// check to see if the record exists on the stage site, if it doesn't remove the tree node
$stageRecord = Versioned::get_one_by_stage( 'SiteTree', 'Stage', "\"SiteTree\".\"ID\"=$id");
if($stageRecord) {
$stageRecord->IsAddedToStage = true;
@ -173,11 +176,10 @@ class CMSBatchAction_DeleteFromLive extends CMSBatchAction {
FormResponse::add("$('Form_EditForm').reloadIfSetTo($id);");
}
}
$message = sprintf(_t('CMSBatchActions.DELETED_PAGES', 'Deleted %d pages from the published site'), $pages->Count());
FormResponse::add('statusMessage("'.$message.'","good");');
return FormResponse::respond();
}
}

View File

@ -69,7 +69,7 @@ class CMSBatchActionHandler extends RequestHandler {
if($pages) foreach($pages as $page) unset($idsFromLive[$page->ID]);
$idsFromLive = array_keys($idsFromLive);
Debug::message("\"SiteTree\".\"ID\" IN (" . implode(", ", $idsFromLive) . ")");
// Debug::message("\"SiteTree\".\"ID\" IN (" . implode(", ", $idsFromLive) . ")");
$livePages = Versioned::get_by_stage('SiteTree', 'Live', "\"SiteTree\".\"ID\" IN (" . implode(", ", $idsFromLive) . ")");
if($pages) $pages->merge($livePages);
else $pages = $livePages;