summaryrefslogtreecommitdiff
path: root/app/Controller
diff options
context:
space:
mode:
authorFrédéric Guillot <fred@kanboard.net>2014-09-01 20:40:02 -0800
committerFrédéric Guillot <fred@kanboard.net>2014-09-01 20:40:02 -0800
commit457e181ffb915e36e5da77317a6c824e10f5d5b3 (patch)
treeeb5443ac4cdbd92278359fcd15d888752c70bc77 /app/Controller
parente6d0658a0eedeb6a641c003d1c492af0f9a7502c (diff)
Improve task duplication
Diffstat (limited to 'app/Controller')
-rw-r--r--app/Controller/Task.php33
1 files changed, 16 insertions, 17 deletions
diff --git a/app/Controller/Task.php b/app/Controller/Task.php
index 35ef6965..e905ef30 100644
--- a/app/Controller/Task.php
+++ b/app/Controller/Task.php
@@ -332,7 +332,7 @@ class Task extends Base
}
/**
- * Duplicate a task (fill the form for a new task)
+ * Duplicate a task
*
* @access public
*/
@@ -340,25 +340,24 @@ class Task extends Base
{
$task = $this->getTask();
- if (! empty($task['date_due'])) {
- $task['date_due'] = date(t('m/d/Y'), $task['date_due']);
- }
- else {
- $task['date_due'] = '';
- }
+ if ($this->request->getStringParam('confirmation') === 'yes') {
- $task['score'] = $task['score'] ?: '';
+ $this->checkCSRFParam();
+ $task_id = $this->task->duplicateSameProject($task);
- $this->response->html($this->template->layout('task_new', array(
- 'errors' => array(),
- 'values' => $task,
- 'columns_list' => $this->board->getColumnsList($task['project_id']),
- 'users_list' => $this->project->getUsersList($task['project_id']),
- 'colors_list' => $this->task->getColors(),
- 'categories_list' => $this->category->getList($task['project_id']),
- 'duplicate' => true,
+ 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 create this task.'));
+ $this->response->redirect('?controller=task&action=duplicate&task_id='.$task['id']);
+ }
+ }
+
+ $this->response->html($this->taskLayout('task_duplicate', array(
+ 'task' => $task,
'menu' => 'tasks',
- 'title' => t('New task')
+ 'title' => t('Duplicate a task')
)));
}