diff --git a/code/CMSMain.php b/code/CMSMain.php index 3c72b08b..896ea717 100755 --- a/code/CMSMain.php +++ b/code/CMSMain.php @@ -34,8 +34,6 @@ class CMSMain extends LeftAndMain implements CurrentPageIdentifier, PermissionPr 'createtranslation', 'delete', 'deletefromlive', - 'deleteitems', - 'DeleteItemsForm', 'duplicate', 'duplicatewithchildren', 'getpagecount', @@ -978,26 +976,6 @@ JS; function batchactions() { return new CMSBatchActionHandler($this, 'batchactions'); } - /** - * @return Form - */ - function DeleteItemsForm() { - $form = new Form( - $this, - 'DeleteItemsForm', - new FieldSet( - new LiteralField('SelectedPagesNote', - sprintf('
%s
', _t('CMSMain_left.ss.SELECTPAGESACTIONS','Select the pages that you want to change & 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() { if($this->urlParams['ID']) { diff --git a/code/LeftAndMain.php b/code/LeftAndMain.php index 69f69ee0..e16578bb 100644 --- a/code/LeftAndMain.php +++ b/code/LeftAndMain.php @@ -39,7 +39,6 @@ class LeftAndMain extends Controller { 'ajaxupdateparent', 'ajaxupdatesort', 'callPageMethod', - 'deleteitems', 'getitem', 'getsubtree', 'myprofile', @@ -785,33 +784,10 @@ JS; return Convert::raw2json($statusUpdates); } - + public function CanOrganiseSitetree() { 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 diff --git a/code/SecurityAdmin.php b/code/SecurityAdmin.php index 78584a8b..48191bc7 100644 --- a/code/SecurityAdmin.php +++ b/code/SecurityAdmin.php @@ -24,7 +24,8 @@ class SecurityAdmin extends LeftAndMain implements PermissionProvider { 'savemember', 'AddRecordForm', 'MemberForm', - 'EditForm' + 'EditForm', + 'deleteitems', ); public function init() { @@ -216,6 +217,27 @@ class SecurityAdmin extends LeftAndMain implements PermissionProvider { 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.