summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
Diffstat (limited to 'app')
-rw-r--r--app/Action/TaskDuplicateAnotherProject.php4
-rw-r--r--app/Model/Board.php12
-rwxr-xr-xapp/Model/TaskDuplication.php14
3 files changed, 27 insertions, 3 deletions
diff --git a/app/Action/TaskDuplicateAnotherProject.php b/app/Action/TaskDuplicateAnotherProject.php
index 55ebc76e..7b7c6bf6 100644
--- a/app/Action/TaskDuplicateAnotherProject.php
+++ b/app/Action/TaskDuplicateAnotherProject.php
@@ -64,7 +64,9 @@ class TaskDuplicateAnotherProject extends Base
*/
public function doAction(array $data)
{
- return (bool) $this->taskDuplication->duplicateToProject($data['task_id'], $this->getParam('project_id'));
+ $destination_column_id = $this->board->getFirstColumn($this->getParam('project_id'));
+
+ return (bool) $this->taskDuplication->duplicateToProject($data['task_id'], $this->getParam('project_id'), null, $destination_column_id);
}
/**
diff --git a/app/Model/Board.php b/app/Model/Board.php
index 0e2cbaaa..7217542d 100644
--- a/app/Model/Board.php
+++ b/app/Model/Board.php
@@ -403,6 +403,18 @@ class Board extends Base
}
/**
+ * Get a column title by the id
+ *
+ * @access public
+ * @param integer $column_id
+ * @return integer
+ */
+ public function getColumnTitleById($column_id)
+ {
+ return $this->db->table(self::TABLE)->eq('id', $column_id)->findOneColumn('title');
+ }
+
+ /**
* Get the position of the last column for a given project
*
* @access public
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;
}