Skip to content
This repository
Browse code

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

…older automatically
  • Loading branch information...
commit a64cf8c27b4a4a33e2550baed42a52d5eb4c3e19 1 parent eaf05a6
Ingo Schommer authored June 14, 2012

Showing 1 changed file with 16 additions and 0 deletions. Show diff stats Hide diff stats

  1. 16  code/controllers/AssetAdmin.php
16  code/controllers/AssetAdmin.php
@@ -24,6 +24,7 @@ class AssetAdmin extends LeftAndMain implements PermissionProvider{
24 24
 	
25 25
 	public static $allowed_actions = array(
26 26
 		'addfolder',
  27
+		'delete',
27 28
 		'DeleteItemsForm',
28 29
 		'getsubtree',
29 30
 		'movemarked',
@@ -305,6 +306,21 @@ public function addfolder($request) {
305 306
 		return $content;
306 307
 	}
307 308
 
  309
+	public function delete($data, $form) {
  310
+		$className = $this->stat('tree_class');
  311
+		
  312
+		$record = DataObject::get_by_id($className, Convert::raw2sql($data['ID']));
  313
+		if($record && !$record->canDelete()) return Security::permissionFailure();
  314
+		if(!$record || !$record->ID) throw new HTTPResponse_Exception("Bad record ID #" . (int)$data['ID'], 404);
  315
+		$parentID = $record->ParentID;
  316
+		$record->delete();
  317
+		$this->setCurrentPageID(null);
  318
+
  319
+		$this->response->addHeader('X-Status', rawurlencode(_t('LeftAndMain.DELETED', 'Deleted.')));
  320
+		$this->response->addHeader('X-Pjax', 'Content');
  321
+		return $this->redirect(Controller::join_links($this->Link('show'), $parentID ? $parentID : 0));
  322
+	}
  323
+
308 324
 	public function getSearchContext() {
309 325
 		$context = singleton('File')->getDefaultSearchContext();
310 326
 		

0 notes on commit a64cf8c

Please sign in to comment.
Something went wrong with that request. Please try again.