summaryrefslogtreecommitdiff
path: root/app/Controller
diff options
context:
space:
mode:
authorFrédéric Guillot <fred@kanboard.net>2014-09-01 19:36:40 -0800
committerFrédéric Guillot <fred@kanboard.net>2014-09-01 19:36:40 -0800
commite6d0658a0eedeb6a641c003d1c492af0f9a7502c (patch)
tree31004fe37246e39e438fb2dc7f1d07996634f1f3 /app/Controller
parente4965546543be040da29dc341900fa9511a158be (diff)
Add the possibility to duplicate a task to another project
Diffstat (limited to 'app/Controller')
-rw-r--r--app/Controller/Task.php33
1 files changed, 27 insertions, 6 deletions
diff --git a/app/Controller/Task.php b/app/Controller/Task.php
index 6936185f..35ef6965 100644
--- a/app/Controller/Task.php
+++ b/app/Controller/Task.php
@@ -433,6 +433,26 @@ class Task extends Base
*/
public function move()
{
+ $this->toAnotherProject('move');
+ }
+
+ /**
+ * Duplicate a task to another project
+ *
+ * @access public
+ */
+ public function copy()
+ {
+ $this->toAnotherProject('duplicate');
+ }
+
+ /**
+ * Common methods between the actions "move" and "copy"
+ *
+ * @access private
+ */
+ private function toAnotherProject($action)
+ {
$task = $this->getTask();
$values = $task;
$errors = array();
@@ -446,23 +466,24 @@ class Task extends Base
list($valid, $errors) = $this->task->validateProjectModification($values);
if ($valid) {
- if ($this->task->moveToAnotherProject($values['project_id'], $task)) {
- $this->session->flash(t('Task updated successfully.'));
- $this->response->redirect('?controller=task&action=show&task_id='.$values['id']);
+ $task_id = $this->task->{$action.'ToAnotherProject'}($values['project_id'], $task);
+ if ($task_id) {
+ $this->session->flash(t('Task created successfully.'));
+ $this->response->redirect('?controller=task&action=show&task_id='.$task_id);
}
else {
- $this->session->flashError(t('Unable to update your task.'));
+ $this->session->flashError(t('Unable to create your task.'));
}
}
}
- $this->response->html($this->taskLayout('task_move_project', array(
+ $this->response->html($this->taskLayout('task_'.$action.'_project', array(
'values' => $values,
'errors' => $errors,
'task' => $task,
'projects_list' => $projects_list,
'menu' => 'tasks',
- 'title' => t('Move the task to another project')
+ 'title' => t(ucfirst($action).' the task to another project')
)));
}
}