summaryrefslogtreecommitdiff
path: root/app/Model/TaskDuplication.php
diff options
context:
space:
mode:
authorFrederic Guillot <fred@kanboard.net>2015-10-07 19:01:08 -0400
committerFrederic Guillot <fred@kanboard.net>2015-10-07 19:01:08 -0400
commit4785174e43d61b20e9248c8bfe9b5b50c61a5ae6 (patch)
treef72a8a3a27401a6b074c92a7457d324962bfdc61 /app/Model/TaskDuplication.php
parent6dba53317c202c56ba60cf490084630de42b939c (diff)
Duplicate a project with tasks will copy the new tasks in the same columns
Diffstat (limited to 'app/Model/TaskDuplication.php')
-rwxr-xr-xapp/Model/TaskDuplication.php14
1 files changed, 12 insertions, 2 deletions
diff --git a/app/Model/TaskDuplication.php b/app/Model/TaskDuplication.php
index 8048f036..958b2b3e 100755
--- a/app/Model/TaskDuplication.php
+++ b/app/Model/TaskDuplication.php
@@ -105,7 +105,7 @@ class TaskDuplication extends Base
{
$values = $this->copyFields($task_id);
$values['project_id'] = $project_id;
- $values['column_id'] = $column_id !== null ? $column_id : $this->board->getFirstColumn($project_id);
+ $values['column_id'] = $column_id !== null ? $column_id : $values['column_id'];
$values['swimlane_id'] = $swimlane_id !== null ? $swimlane_id : $values['swimlane_id'];
$values['category_id'] = $category_id !== null ? $category_id : $values['category_id'];
$values['owner_id'] = $owner_id !== null ? $owner_id : $values['owner_id'];
@@ -134,7 +134,7 @@ class TaskDuplication extends Base
$values = array();
$values['is_active'] = 1;
$values['project_id'] = $project_id;
- $values['column_id'] = $column_id !== null ? $column_id : $this->board->getFirstColumn($project_id);
+ $values['column_id'] = $column_id !== null ? $column_id : $task['column_id'];
$values['position'] = $this->taskFinder->countByColumnId($project_id, $values['column_id']) + 1;
$values['swimlane_id'] = $swimlane_id !== null ? $swimlane_id : $task['swimlane_id'];
$values['category_id'] = $category_id !== null ? $category_id : $task['category_id'];
@@ -181,6 +181,16 @@ class TaskDuplication extends Base
);
}
+ // Check if the column exists for the destination project
+ if ($values['column_id'] > 0) {
+ $values['column_id'] = $this->board->getColumnIdByTitle(
+ $values['project_id'],
+ $this->board->getColumnTitleById($values['column_id'])
+ );
+
+ $values['column_id'] = $values['column_id'] ?: $this->board->getFirstColumn($values['project_id']);
+ }
+
return $values;
}