summaryrefslogtreecommitdiff
path: root/app/Controller
diff options
context:
space:
mode:
authorFrédéric Guillot <fred@kanboard.net>2014-11-23 18:23:20 -0500
committerFrédéric Guillot <fred@kanboard.net>2014-11-23 18:23:20 -0500
commit81df22de238bc36d810b95ad67a4426db095fbab (patch)
tree53231a3d46b6b7c54eaec515016247984cf7a4e4 /app/Controller
parentf684602ebedc0adc4a329693ba524ad46d5cd8b0 (diff)
Create TaskDuplication model
Diffstat (limited to 'app/Controller')
-rw-r--r--app/Controller/Base.php1
-rw-r--r--app/Controller/Task.php47
2 files changed, 34 insertions, 14 deletions
diff --git a/app/Controller/Base.php b/app/Controller/Base.php
index 8dd96c56..9b8ca0ec 100644
--- a/app/Controller/Base.php
+++ b/app/Controller/Base.php
@@ -35,6 +35,7 @@ use Model\LastLogin;
* @property \Model\Task $task
* @property \Model\TaskCreation $taskCreation
* @property \Model\TaskModification $taskModification
+ * @property \Model\TaskDuplication $taskDuplication
* @property \Model\TaskHistory $taskHistory
* @property \Model\TaskExport $taskExport
* @property \Model\TaskFinder $taskFinder
diff --git a/app/Controller/Task.php b/app/Controller/Task.php
index 6c6eaf90..8dbd8429 100644
--- a/app/Controller/Task.php
+++ b/app/Controller/Task.php
@@ -352,7 +352,7 @@ class Task extends Base
if ($this->request->getStringParam('confirmation') === 'yes') {
$this->checkCSRFParam();
- $task_id = $this->task->duplicateToSameProject($task);
+ $task_id = $this->taskDuplication->duplicate($task['id']);
if ($task_id) {
$this->session->flash(t('Task created successfully.'));
@@ -428,7 +428,36 @@ class Task extends Base
*/
public function move()
{
- $this->toAnotherProject('move');
+ $task = $this->getTask();
+ $values = $task;
+ $errors = array();
+ $projects_list = $this->projectPermission->getMemberProjects($this->acl->getUserId());
+
+ unset($projects_list[$task['project_id']]);
+
+ if ($this->request->isPost()) {
+
+ $values = $this->request->getValues();
+ list($valid, $errors) = $this->taskValidator->validateProjectModification($values);
+
+ if ($valid) {
+
+ if ($this->taskDuplication->moveToProject($task['id'], $values['project_id'])) {
+ $this->session->flash(t('Task updated successfully.'));
+ $this->response->redirect('?controller=task&action=show&task_id='.$task['id']);
+ }
+ else {
+ $this->session->flashError(t('Unable to update your task.'));
+ }
+ }
+ }
+
+ $this->response->html($this->taskLayout('task_move_project', array(
+ 'values' => $values,
+ 'errors' => $errors,
+ 'task' => $task,
+ 'projects_list' => $projects_list,
+ )));
}
/**
@@ -438,16 +467,6 @@ class Task extends Base
*/
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();
@@ -461,7 +480,7 @@ class Task extends Base
list($valid, $errors) = $this->taskValidator->validateProjectModification($values);
if ($valid) {
- $task_id = $this->task->{$action.'ToAnotherProject'}($values['project_id'], $task);
+ $task_id = $this->taskDuplication->duplicateToProject($task['id'], $values['project_id']);
if ($task_id) {
$this->session->flash(t('Task created successfully.'));
$this->response->redirect('?controller=task&action=show&task_id='.$task_id);
@@ -472,7 +491,7 @@ class Task extends Base
}
}
- $this->response->html($this->taskLayout('task_'.$action.'_project', array(
+ $this->response->html($this->taskLayout('task_duplicate_project', array(
'values' => $values,
'errors' => $errors,
'task' => $task,