From 5e10d2d29faaf0cce4274a5b7ffa0735a0aa04a1 Mon Sep 17 00:00:00 2001 From: Frédéric Guillot Date: Tue, 19 Aug 2014 17:43:01 -0700 Subject: Fix a bug and improve project cloning code --- app/Model/Board.php | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) (limited to 'app/Model/Board.php') diff --git a/app/Model/Board.php b/app/Model/Board.php index 168b185f..74e29040 100644 --- a/app/Model/Board.php +++ b/app/Model/Board.php @@ -51,19 +51,20 @@ class Board extends Base * * @access public * @param integer $project_id Project id - * @param array $columns List of columns title ['column1', 'column2', ...] + * @param array $columns Column parameters [ 'title' => 'boo', 'task_limit' => 2 ... ] * @return boolean */ public function create($project_id, array $columns) { $position = 0; - foreach ($columns as $title) { + foreach ($columns as $column) { $values = array( - 'title' => $title, + 'title' => $column['title'], 'position' => ++$position, 'project_id' => $project_id, + 'task_limit' => $column['task_limit'], ); if (! $this->db->table(self::TABLE)->save($values)) { @@ -74,6 +75,25 @@ class Board extends Base return true; } + /** + * Copy board columns from a project to another one + * + * @author Antonio Rabelo + * @param integer $project_from Project Template + * @return integer $project_to Project that receives the copy + * @return boolean + */ + public function duplicate($project_from, $project_to) + { + $columns = $this->db->table(Board::TABLE) + ->columns('title', 'task_limit') + ->eq('project_id', $project_from) + ->asc('position') + ->findAll(); + + return $this->board->create($project_to, $columns); + } + /** * Add a new column to the board * -- cgit v1.2.3