mirror of
https://github.com/silverstripe/silverstripe-cms
synced 2024-10-02 06:08:27 +02:00
BUGFIX AssetAdmin->delete() is now allowed, and redirects to parent folder automatically
This commit is contained in:
parent
eaf05a6a7c
commit
a64cf8c27b
@ -24,6 +24,7 @@ class AssetAdmin extends LeftAndMain implements PermissionProvider{
|
|||||||
|
|
||||||
public static $allowed_actions = array(
|
public static $allowed_actions = array(
|
||||||
'addfolder',
|
'addfolder',
|
||||||
|
'delete',
|
||||||
'DeleteItemsForm',
|
'DeleteItemsForm',
|
||||||
'getsubtree',
|
'getsubtree',
|
||||||
'movemarked',
|
'movemarked',
|
||||||
@ -305,6 +306,21 @@ JS
|
|||||||
return $content;
|
return $content;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function delete($data, $form) {
|
||||||
|
$className = $this->stat('tree_class');
|
||||||
|
|
||||||
|
$record = DataObject::get_by_id($className, Convert::raw2sql($data['ID']));
|
||||||
|
if($record && !$record->canDelete()) return Security::permissionFailure();
|
||||||
|
if(!$record || !$record->ID) throw new HTTPResponse_Exception("Bad record ID #" . (int)$data['ID'], 404);
|
||||||
|
$parentID = $record->ParentID;
|
||||||
|
$record->delete();
|
||||||
|
$this->setCurrentPageID(null);
|
||||||
|
|
||||||
|
$this->response->addHeader('X-Status', rawurlencode(_t('LeftAndMain.DELETED', 'Deleted.')));
|
||||||
|
$this->response->addHeader('X-Pjax', 'Content');
|
||||||
|
return $this->redirect(Controller::join_links($this->Link('show'), $parentID ? $parentID : 0));
|
||||||
|
}
|
||||||
|
|
||||||
public function getSearchContext() {
|
public function getSearchContext() {
|
||||||
$context = singleton('File')->getDefaultSearchContext();
|
$context = singleton('File')->getDefaultSearchContext();
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user