diff options
| author | Frédéric Guillot <fred@kanboard.net> | 2014-09-12 17:35:48 +0200 |
|---|---|---|
| committer | Frédéric Guillot <fred@kanboard.net> | 2014-09-12 17:35:48 +0200 |
| commit | 2e6a8d435f4fa73882224b465716360ee2e7c693 (patch) | |
| tree | 9839a499905c350cd02d56454a25b90a79ede41f /app/Model | |
| parent | c3a0cf43430438bfe7e7b0ccccfadb72a74331d6 (diff) | |
Add settings field to control project columns (pull-request #244)
Diffstat (limited to 'app/Model')
| -rw-r--r-- | app/Model/Board.php | 11 | ||||
| -rw-r--r-- | app/Model/Config.php | 2 | ||||
| -rw-r--r-- | app/Model/Project.php | 17 |
3 files changed, 23 insertions, 7 deletions
diff --git a/app/Model/Board.php b/app/Model/Board.php index 07020600..f8df4069 100644 --- a/app/Model/Board.php +++ b/app/Model/Board.php @@ -21,6 +21,17 @@ class Board extends Base const TABLE = 'columns'; /** + * Get Kanboard default columns + * + * @access public + * @return array + */ + public function getDefaultColumns() + { + return array(t('Backlog'), t('Ready'), t('Work in progress'), t('Done')); + } + + /** * Create a board with default columns, must be executed inside a transaction * * @access public diff --git a/app/Model/Config.php b/app/Model/Config.php index 89bcb58b..f411e3e2 100644 --- a/app/Model/Config.php +++ b/app/Model/Config.php @@ -72,7 +72,7 @@ class Config extends Base $_SESSION['config'] = $this->getAll(); } - if (isset($_SESSION['config'][$name])) { + if (! empty($_SESSION['config'][$name])) { return $_SESSION['config'][$name]; } diff --git a/app/Model/Project.php b/app/Model/Project.php index 6e75838c..0ba18498 100644 --- a/app/Model/Project.php +++ b/app/Model/Project.php @@ -496,14 +496,19 @@ class Project extends Base } $project_id = $this->db->getConnection()->getLastId(); + $column_names = explode(',', $this->config->get('default_columns', implode(',', $this->board->getDefaultColumns()))); + $columns = array(); - $this->board->create($project_id, array( - array('title' => t('Backlog'), 'task_limit' => 0), - array('title' => t('Ready'), 'task_limit' => 0), - array('title' => t('Work in progress'), 'task_limit' => 0), - array('title' => t('Done'), 'task_limit' => 0), - )); + foreach ($column_names as $column_name) { + + $column_name = trim($column_name); + + if (! empty($column_name)) { + $columns[] = array('title' => $column_name, 'task_limit' => 0); + } + } + $this->board->create($project_id, $columns); $this->db->closeTransaction(); return (int) $project_id; |
