summaryrefslogtreecommitdiff
path: root/app/Controller/Project.php
diff options
context:
space:
mode:
authorFrederic Guillot <fred@kanboard.net>2016-01-31 17:46:19 -0500
committerFrederic Guillot <fred@kanboard.net>2016-01-31 17:46:19 -0500
commitfc21d3873e3ac63222ad4065a593c715bef4c251 (patch)
treeb1795031eda0774aeb1af9fb20606fe38611e0eb /app/Controller/Project.php
parent1500ff92b2dc3d3932c8e06755bec23f9017e8a4 (diff)
When creating a new project, have the possibility to select another project to duplicate
Diffstat (limited to 'app/Controller/Project.php')
-rw-r--r--app/Controller/Project.php60
1 files changed, 4 insertions, 56 deletions
diff --git a/app/Controller/Project.php b/app/Controller/Project.php
index ffd62b09..661fd68b 100644
--- a/app/Controller/Project.php
+++ b/app/Controller/Project.php
@@ -171,14 +171,15 @@ class Project extends Base
$project = $this->getProject();
if ($this->request->getStringParam('duplicate') === 'yes') {
- $values = array_keys($this->request->getValues());
- if ($this->projectDuplication->duplicate($project['id'], $values) !== false) {
+ $project_id = $this->projectDuplication->duplicate($project['id'], array_keys($this->request->getValues()), $this->userSession->getId());
+
+ if ($project_id !== false) {
$this->flash->success(t('Project cloned successfully.'));
} else {
$this->flash->failure(t('Unable to clone this project.'));
}
- $this->response->redirect($this->helper->url->to('project', 'index'));
+ $this->response->redirect($this->helper->url->to('project', 'show', array('project_id' => $project_id)));
}
$this->response->html($this->projectLayout('project/duplicate', array(
@@ -240,57 +241,4 @@ class Project extends Base
'title' => t('Project activation')
)));
}
-
- /**
- * Display a form to create a new project
- *
- * @access public
- */
- public function create(array $values = array(), array $errors = array())
- {
- $is_private = isset($values['is_private']) && $values['is_private'] == 1;
-
- $this->response->html($this->template->layout('project/new', array(
- 'board_selector' => $this->projectUserRole->getActiveProjectsByUser($this->userSession->getId()),
- 'values' => $values,
- 'errors' => $errors,
- 'is_private' => $is_private,
- 'title' => $is_private ? t('New private project') : t('New project'),
- )));
- }
-
- /**
- * Display a form to create a private project
- *
- * @access public
- */
- 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->project->create($values, $this->userSession->getId(), true);
-
- if ($project_id > 0) {
- $this->flash->success(t('Your project have been created successfully.'));
- $this->response->redirect($this->helper->url->to('project', 'show', array('project_id' => $project_id)));
- }
-
- $this->flash->failure(t('Unable to create your project.'));
- }
-
- $this->create($values, $errors);
- }
}