File modules/cms/action/folder/FolderRemoveAction.class.php
Last commit: Wed Mar 9 13:28:52 2022 +0100 dankert Refactoring: Checkbox values are always sent to the server. In the actions we must test the value with 'isTrue()'
1 <?php 2 namespace cms\action\folder; 3 use cms\action\FolderAction; 4 use cms\action\Method; 5 use cms\model\Permission; 6 use language\Messages; 7 use util\exception\ValidationException; 8 9 10 class FolderRemoveAction extends FolderAction implements Method { 11 12 public function getRequiredPermission() { 13 return Permission::ACL_DELETE; 14 } 15 16 17 public function view() { 18 $this->setTemplateVar( 'name',$this->folder->filename ); 19 $this->setTemplateVar( 'hasChildren', $this->folder->hasChildren() ); 20 } 21 22 23 public function post() { 24 25 if ( $this->folder->isRoot() ) 26 // Could not delete the root folder on user request. 27 throw new ValidationException("parent",Messages::FOLDER_ROOT); 28 29 if ( $this->folder->hasChildren() ) { 30 if ($this->request->isTrue('withChildren')) 31 $this->folder->deleteAll(); // Delete with children 32 else 33 throw new ValidationException("withChildren",Messages::CONTAINS_CHILDREN); 34 35 } 36 else 37 $this->folder->delete(); // Only delete current folder. 38 39 $this->addNoticeFor($this->folder, Messages::DELETED); 40 } 41 }
Downloadmodules/cms/action/folder/FolderRemoveAction.class.php
History Wed, 9 Mar 2022 13:28:52 +0100 dankert Refactoring: Checkbox values are always sent to the server. In the actions we must test the value with 'isTrue()' Mon, 6 Dec 2021 22:33:10 +0100 dankert Some fixes for deleting objects. Sat, 6 Mar 2021 03:42:38 +0100 Jan Dankert New: Better permission checks. Fri, 26 Feb 2021 01:06:01 +0100 Jan Dankert Refactoring accessing the request parameter values. Tue, 17 Nov 2020 23:51:00 +0100 Jan Dankert Refactoring: Every Actionmethod has now its own class.