ENHANCEMENT Removed unused LeftAndMain->DeleteItemsForm

ENHANCEMENT Moved LeftAndMain->deleteitems() into SecurityAdmin, its the only place where its not replaced by CMSBatchAction yet

git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/cms/trunk@92743 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
Ingo Schommer 2009-11-21 03:16:38 +00:00
parent 420d0a5c57
commit 64e042a2a3
3 changed files with 24 additions and 48 deletions

View File

@ -34,8 +34,6 @@ class CMSMain extends LeftAndMain implements CurrentPageIdentifier, PermissionPr
'createtranslation', 'createtranslation',
'delete', 'delete',
'deletefromlive', 'deletefromlive',
'deleteitems',
'DeleteItemsForm',
'duplicate', 'duplicate',
'duplicatewithchildren', 'duplicatewithchildren',
'getpagecount', 'getpagecount',
@ -978,26 +976,6 @@ JS;
function batchactions() { function batchactions() {
return new CMSBatchActionHandler($this, 'batchactions'); return new CMSBatchActionHandler($this, 'batchactions');
} }
/**
* @return Form
*/
function DeleteItemsForm() {
$form = new Form(
$this,
'DeleteItemsForm',
new FieldSet(
new LiteralField('SelectedPagesNote',
sprintf('<p>%s</p>', _t('CMSMain_left.ss.SELECTPAGESACTIONS','Select the pages that you want to change &amp; then click an action:'))
),
new HiddenField('csvIDs')
),
new FieldSet(
new FormAction('deleteitems', _t('CMSMain_left.ss.DELETECONFIRM','Delete the selected pages'))
)
);
$form->addExtraClass('actionparams');
return $form;
}
function buildbrokenlinks() { function buildbrokenlinks() {
if($this->urlParams['ID']) { if($this->urlParams['ID']) {

View File

@ -39,7 +39,6 @@ class LeftAndMain extends Controller {
'ajaxupdateparent', 'ajaxupdateparent',
'ajaxupdatesort', 'ajaxupdatesort',
'callPageMethod', 'callPageMethod',
'deleteitems',
'getitem', 'getitem',
'getsubtree', 'getsubtree',
'myprofile', 'myprofile',
@ -790,29 +789,6 @@ JS;
return !Permission::check('SITETREE_REORGANISE') && !Permission::check('ADMIN') ? false : true; return !Permission::check('SITETREE_REORGANISE') && !Permission::check('ADMIN') ? false : true;
} }
/**
* Delete a number of items
*/
public function deleteitems() {
$ids = split(' *, *', $_REQUEST['csvIDs']);
$script = "st = \$('sitetree'); \n";
foreach($ids as $id) {
if(is_numeric($id)) {
$record = DataObject::get_by_id($this->stat('tree_class'), $id);
if($record && !$record->canDelete()) return Security::permissionFailure($this);
DataObject::delete_by_id($this->stat('tree_class'), $id);
$script .= "node = st.getTreeNodeByIdx($id); if(node) node.parentTreeNode.removeTreeNode(node); $('Form_EditForm').closeIfSetTo($id); \n";
if ($id == $this->currentPageID()) FormResponse::add('CurrentPage.isDeleted = 1;');
}
}
FormResponse::add($script);
return FormResponse::respond();
}
/** /**
* Uses {@link getEditForm()} to retrieve an edit form * Uses {@link getEditForm()} to retrieve an edit form
* based on the submitted data. Used for form submissions, * based on the submitted data. Used for form submissions,

View File

@ -24,7 +24,8 @@ class SecurityAdmin extends LeftAndMain implements PermissionProvider {
'savemember', 'savemember',
'AddRecordForm', 'AddRecordForm',
'MemberForm', 'MemberForm',
'EditForm' 'EditForm',
'deleteitems',
); );
public function init() { public function init() {
@ -217,6 +218,27 @@ class SecurityAdmin extends LeftAndMain implements PermissionProvider {
return FormResponse::respond(); return FormResponse::respond();
} }
/**
* Delete a number of items
*/
public function deleteitems() {
$ids = split(' *, *', $_REQUEST['csvIDs']);
$script = "st = \$('sitetree'); \n";
foreach($ids as $id) {
if(is_numeric($id)) {
$record = DataObject::get_by_id($this->stat('tree_class'), $id);
if($record && !$record->canDelete()) return Security::permissionFailure($this);
DataObject::delete_by_id($this->stat('tree_class'), $id);
$script .= "node = st.getTreeNodeByIdx($id); if(node) node.parentTreeNode.removeTreeNode(node); $('Form_EditForm').closeIfSetTo($id); \n";
}
}
FormResponse::add($script);
return FormResponse::respond();
}
/** /**
* Return the entire site tree as a nested set of ULs. * Return the entire site tree as a nested set of ULs.
* @return string Unordered list <UL> HTML * @return string Unordered list <UL> HTML