summaryrefslogtreecommitdiff
path: root/app/Model/Board.php
diff options
context:
space:
mode:
authorFrédéric Guillot <fred@kanboard.net>2014-08-19 17:43:01 -0700
committerFrédéric Guillot <fred@kanboard.net>2014-08-19 17:43:01 -0700
commit5e10d2d29faaf0cce4274a5b7ffa0735a0aa04a1 (patch)
tree979d41628f961e281d1c37221bdd76c7196e4313 /app/Model/Board.php
parent532b16cbdd58d3d7083eb14886a0ae826629d645 (diff)
Fix a bug and improve project cloning code
Diffstat (limited to 'app/Model/Board.php')
-rw-r--r--app/Model/Board.php26
1 files changed, 23 insertions, 3 deletions
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)) {
@@ -75,6 +76,25 @@ class Board extends Base
}
/**
+ * 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
*
* @access public