Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

BUGFIX AssetAdmin->delete() is now allowed, and redirects to parent f…

…older automatically
  • Loading branch information...
commit a64cf8c27b4a4a33e2550baed42a52d5eb4c3e19 1 parent eaf05a6
@chillu chillu authored
Showing with 16 additions and 0 deletions.
  1. +16 −0 code/controllers/AssetAdmin.php
View
16 code/controllers/AssetAdmin.php
@@ -24,6 +24,7 @@ class AssetAdmin extends LeftAndMain implements PermissionProvider{
public static $allowed_actions = array(
'addfolder',
+ 'delete',
'DeleteItemsForm',
'getsubtree',
'movemarked',
@@ -305,6 +306,21 @@ public function addfolder($request) {
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() {
$context = singleton('File')->getDefaultSearchContext();
Please sign in to comment.
Something went wrong with that request. Please try again.