File modules/cms/action/model/ModelRemoveAction.class.php

Last commit: Tue Feb 14 21:48:16 2023 +0100	Jan Dankert	Fix: Be sure that there are at least 1 language and 1 model.
1 <?php 2 namespace cms\action\model; 3 use cms\action\Method; 4 use cms\action\ModelAction; 5 use cms\model\Project; 6 use language\Messages; 7 use util\exception\ClientException; 8 9 10 class ModelRemoveAction extends ModelAction implements Method { 11 public function view() { 12 $this->model->load(); 13 14 $project = Project::create( $this->model->projectid ); 15 16 // There must be at least 1 model 17 if ( count( $project->getModelIds() ) <= 1 ) 18 throw new ClientException('There must be at least 1 model.'); 19 20 $this->setTemplateVar( 'name',$this->model->name ); 21 } 22 23 24 25 public function post() { 26 27 if ( $this->request->isTrue('confirm') ) 28 { 29 $project = Project::create( $this->model->projectid ); 30 31 // There must be at least 1 model 32 if ( count( $project->getModelIds() ) > 1 ) { 33 $this->model->delete(); 34 $this->addNoticeFor($this->model, Messages::DONE); 35 }else { 36 $this->addWarningFor( $this->model, Messages::NOTHING_DONE); 37 } 38 } 39 else 40 { 41 $this->addWarningFor( $this->model, Messages::NOTHING_DONE); 42 } 43 } 44 }
Download modules/cms/action/model/ModelRemoveAction.class.php
History Tue, 14 Feb 2023 21:48:16 +0100 Jan Dankert Fix: Be sure that there are at least 1 language and 1 model. 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()' 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.