diff options
author | Frederic Guillot <fred@kanboard.net> | 2016-05-28 13:41:54 -0400 |
---|---|---|
committer | Frederic Guillot <fred@kanboard.net> | 2016-05-28 13:41:54 -0400 |
commit | 1353929a7dbd3f2e897fa7d3ab88e959ca573f9f (patch) | |
tree | 30bdbac4e466e74c3dfb4d451422f03c62bcbe41 /app/Controller/ProjectCreation.php | |
parent | ab48a09f0d674b703467975b376c5ac7352670ae (diff) |
Rename controllers
Diffstat (limited to 'app/Controller/ProjectCreation.php')
-rw-r--r-- | app/Controller/ProjectCreation.php | 129 |
1 files changed, 0 insertions, 129 deletions
diff --git a/app/Controller/ProjectCreation.php b/app/Controller/ProjectCreation.php deleted file mode 100644 index 0ffa2174..00000000 --- a/app/Controller/ProjectCreation.php +++ /dev/null @@ -1,129 +0,0 @@ -<?php - -namespace Kanboard\Controller; - -/** - * Project Creation Controller - * - * @package controller - * @author Frederic Guillot - */ -class ProjectCreation extends BaseController -{ - /** - * Display a form to create a new project - * - * @access public - * @param array $values - * @param array $errors - */ - public function create(array $values = array(), array $errors = array()) - { - $is_private = isset($values['is_private']) && $values['is_private'] == 1; - $projects_list = array(0 => t('Do not duplicate anything')) + $this->projectUserRole->getActiveProjectsByUser($this->userSession->getId()); - - $this->response->html($this->helper->layout->app('project_creation/create', array( - 'values' => $values, - 'errors' => $errors, - 'is_private' => $is_private, - 'projects_list' => $projects_list, - 'title' => $is_private ? t('New private project') : t('New project'), - ))); - } - - /** - * Display a form to create a private project - * - * @access public - * @param array $values - * @param array $errors - */ - public function createPrivate(array $values = array(), array $errors = array()) - { - $values['is_private'] = 1; - $this->create($values, $errors); - } - - /** - * Validate and save a new project - * - * @access public - */ - public function save() - { - $values = $this->request->getValues(); - list($valid, $errors) = $this->projectValidator->validateCreation($values); - - if ($valid) { - $project_id = $this->createOrDuplicate($values); - - if ($project_id > 0) { - $this->flash->success(t('Your project have been created successfully.')); - return $this->response->redirect($this->helper->url->to('ProjectViewController', 'show', array('project_id' => $project_id))); - } - - $this->flash->failure(t('Unable to create your project.')); - } - - return $this->create($values, $errors); - } - - /** - * Create or duplicate a project - * - * @access private - * @param array $values - * @return boolean|integer - */ - private function createOrDuplicate(array $values) - { - if (empty($values['src_project_id'])) { - return $this->createNewProject($values); - } - - return $this->duplicateNewProject($values); - } - - /** - * Save a new project - * - * @access private - * @param array $values - * @return boolean|integer - */ - private function createNewProject(array $values) - { - $project = array( - 'name' => $values['name'], - 'is_private' => $values['is_private'], - ); - - return $this->project->create($project, $this->userSession->getId(), true); - } - - /** - * Creatte from another project - * - * @access private - * @param array $values - * @return boolean|integer - */ - private function duplicateNewProject(array $values) - { - $selection = array(); - - foreach ($this->projectDuplication->getOptionalSelection() as $item) { - if (isset($values[$item]) && $values[$item] == 1) { - $selection[] = $item; - } - } - - return $this->projectDuplication->duplicate( - $values['src_project_id'], - $selection, - $this->userSession->getId(), - $values['name'], - $values['is_private'] == 1 - ); - } -} |