openrat-cms

# OpenRat Content Management System
git clone http://git.code.weiherhei.de/openrat-cms.git
Log | Files | Refs

commit a51d1c9b91cb27285e2f40170c11d731464f70fb
parent e87e2f234986946305036c06c56d51bd5d50f8a0
Author: Jan Dankert <develop@jandankert.de>
Date:   Thu,  7 Nov 2019 23:12:51 +0100

Default: Create an empty project.

Diffstat:
modules/cms-core/action/ProjectlistAction.class.php | 57+++++++++++++++++++++++----------------------------------
1 file changed, 23 insertions(+), 34 deletions(-)

diff --git a/modules/cms-core/action/ProjectlistAction.class.php b/modules/cms-core/action/ProjectlistAction.class.php @@ -92,40 +92,29 @@ class ProjectlistAction extends Action if( !$this->userIsAdmin()) throw new \SecurityException("user is not allowed to add a project"); - if ( !$this->hasRequestVar('type') ) - { - $this->addValidationError('type'); - $this->callSubAction('add'); - return; - } - else - { - switch( $this->getRequestVar('type') ) - { - case 'empty': - if ( !$this->hasRequestVar('name') ) - { - $this->addValidationError('name'); - $this->callSubAction('add'); - return; - } - $project = new Project(); - $project->name = $this->getRequestVar('name'); - $project->add(); - $this->addNotice('project',$project->name,'ADDED'); - break; - case 'copy': - $db = db_connection(); - $project = new Project($this->getRequestVar('projectid')); - $project->load(); - $project->export($db->id); - $this->addNotice('project',$project->name,'DONE'); - break; - default: - throw new \LogicException('Unknown type while adding project '.$this->getRequestVar('type') ); - } - - } + switch( $this->getRequestVar('type') ) + { + case 'empty': + case '': + if ( !$this->hasRequestVar('name') ) + throw new \ValidationException('name'); + + $project = new Project(); + $project->name = $this->getRequestVar('name'); + $project->add(); + $this->addNotice('project',$project->name,'ADDED'); + break; + case 'copy': + $db = db_connection(); + $project = new Project($this->getRequestVar('projectid')); + $project->load(); + $project->export($db->id); + $this->addNotice('project',$project->name,'DONE'); + break; + default: + throw new \LogicException('Unknown type while adding project '.$this->getRequestVar('type') ); + } + }