diff options
Diffstat (limited to 'app/Model/Swimlane.php')
-rw-r--r-- | app/Model/Swimlane.php | 33 |
1 files changed, 32 insertions, 1 deletions
diff --git a/app/Model/Swimlane.php b/app/Model/Swimlane.php index 71b95ae9..c9bc43e1 100644 --- a/app/Model/Swimlane.php +++ b/app/Model/Swimlane.php @@ -183,7 +183,7 @@ class Swimlane extends Base * @access public * @param integer $project_id * @param string $name - * @return bool + * @return integer|boolean */ public function create($project_id, $name) { @@ -413,6 +413,37 @@ class Swimlane extends Base } /** + * Duplicate Swimlane to project + * + * @access public + * @param integer $project_from Project Template + * @param integer $project_to Project that receives the copy + * @return integer|boolean + */ + + public function duplicate($project_from, $project_to) + { + $swimlanes = $this->getAll($project_from); + + foreach ($swimlanes as $swimlane) { + + unset($swimlane['id']); + $swimlane['project_id'] = $project_to; + + if (! $this->db->table(self::TABLE)->save($swimlane)) { + return false; + } + } + + $default_swimlane = $this->getDefault($project_from); + $default_swimlane['id'] = $project_to; + + $this->updateDefault($default_swimlane); + + return true; + } + + /** * Validate creation * * @access public |