summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorFrédéric Guillot <fred@kanboard.net>2014-09-12 17:35:48 +0200
committerFrédéric Guillot <fred@kanboard.net>2014-09-12 17:35:48 +0200
commit2e6a8d435f4fa73882224b465716360ee2e7c693 (patch)
tree9839a499905c350cd02d56454a25b90a79ede41f /app
parentc3a0cf43430438bfe7e7b0ccccfadb72a74331d6 (diff)
Add settings field to control project columns (pull-request #244)
Diffstat (limited to 'app')
-rw-r--r--app/Controller/Config.php2
-rw-r--r--app/Locales/de_DE/translations.php2
-rw-r--r--app/Locales/es_ES/translations.php2
-rw-r--r--app/Locales/fi_FI/translations.php2
-rw-r--r--app/Locales/fr_FR/translations.php2
-rw-r--r--app/Locales/it_IT/translations.php2
-rw-r--r--app/Locales/pl_PL/translations.php2
-rw-r--r--app/Locales/pt_BR/translations.php2
-rw-r--r--app/Locales/ru_RU/translations.php2
-rw-r--r--app/Locales/sv_SE/translations.php2
-rw-r--r--app/Locales/zh_CN/translations.php2
-rw-r--r--app/Model/Board.php11
-rw-r--r--app/Model/Config.php2
-rw-r--r--app/Model/Project.php17
-rw-r--r--app/Schema/Mysql.php12
-rw-r--r--app/Schema/Postgres.php11
-rw-r--r--app/Schema/Sqlite.php18
-rw-r--r--app/Templates/config_index.php4
18 files changed, 78 insertions, 19 deletions
diff --git a/app/Controller/Config.php b/app/Controller/Config.php
index a364c5f4..4c3018c1 100644
--- a/app/Controller/Config.php
+++ b/app/Controller/Config.php
@@ -25,6 +25,7 @@ class Config extends Base
'menu' => 'config',
'title' => t('Settings'),
'timezones' => $this->config->getTimezones(),
+ 'default_columns' => implode(', ', $this->board->getDefaultColumns()),
)));
}
@@ -58,6 +59,7 @@ class Config extends Base
'menu' => 'config',
'title' => t('Settings'),
'timezones' => $this->config->getTimezones(),
+ 'default_columns' => implode(', ', $this->board->getDefaultColumns()),
)));
}
diff --git a/app/Locales/de_DE/translations.php b/app/Locales/de_DE/translations.php
index fc36b235..2bd0fabb 100644
--- a/app/Locales/de_DE/translations.php
+++ b/app/Locales/de_DE/translations.php
@@ -494,4 +494,6 @@ return array(
// '%s moved the task #%d to the column "%s"' => '',
// '%s moved the task #%d to the position %d in the column "%s"' => '',
// 'Activity' => '',
+ // 'Default values are "%s"' => '',
+ // 'Default columns for new projects (Comma-separated)' => '',
);
diff --git a/app/Locales/es_ES/translations.php b/app/Locales/es_ES/translations.php
index 2cb19e1b..7374b274 100644
--- a/app/Locales/es_ES/translations.php
+++ b/app/Locales/es_ES/translations.php
@@ -494,4 +494,6 @@ return array(
// '%s moved the task #%d to the column "%s"' => '',
// '%s moved the task #%d to the position %d in the column "%s"' => '',
// 'Activity' => '',
+ // 'Default values are "%s"' => '',
+ // 'Default columns for new projects (Comma-separated)' => '',
);
diff --git a/app/Locales/fi_FI/translations.php b/app/Locales/fi_FI/translations.php
index 4481078d..5f4b2c4e 100644
--- a/app/Locales/fi_FI/translations.php
+++ b/app/Locales/fi_FI/translations.php
@@ -494,4 +494,6 @@ return array(
// '%s moved the task #%d to the column "%s"' => '',
// '%s moved the task #%d to the position %d in the column "%s"' => '',
// 'Activity' => '',
+ // 'Default values are "%s"' => '',
+ // 'Default columns for new projects (Comma-separated)' => '',
);
diff --git a/app/Locales/fr_FR/translations.php b/app/Locales/fr_FR/translations.php
index 1e725a7e..2cb65b76 100644
--- a/app/Locales/fr_FR/translations.php
+++ b/app/Locales/fr_FR/translations.php
@@ -494,4 +494,6 @@ return array(
'%s moved the task #%d to the column "%s"' => '%s a déplacé la tâche n°%d dans la colonne « %s »',
'%s moved the task #%d to the position %d in the column "%s"' => '%s a déplacé la tâche n°%d à la position n°%d dans la colonne « %s »',
'Activity' => 'Activité',
+ 'Default values are "%s"' => 'Les valeurs par défaut sont « %s »',
+ 'Default columns for new projects (Comma-separated)' => 'Colonnes par défaut pour les nouveaux projets (séparé par des virgules)',
);
diff --git a/app/Locales/it_IT/translations.php b/app/Locales/it_IT/translations.php
index 5834faf2..43613e4d 100644
--- a/app/Locales/it_IT/translations.php
+++ b/app/Locales/it_IT/translations.php
@@ -494,4 +494,6 @@ return array(
// '%s moved the task #%d to the column "%s"' => '',
// '%s moved the task #%d to the position %d in the column "%s"' => '',
// 'Activity' => '',
+ // 'Default values are "%s"' => '',
+ // 'Default columns for new projects (Comma-separated)' => '',
);
diff --git a/app/Locales/pl_PL/translations.php b/app/Locales/pl_PL/translations.php
index ca48f2e6..bedcfd71 100644
--- a/app/Locales/pl_PL/translations.php
+++ b/app/Locales/pl_PL/translations.php
@@ -494,4 +494,6 @@ return array(
// '%s moved the task #%d to the column "%s"' => '',
// '%s moved the task #%d to the position %d in the column "%s"' => '',
// 'Activity' => '',
+ // 'Default values are "%s"' => '',
+ // 'Default columns for new projects (Comma-separated)' => '',
);
diff --git a/app/Locales/pt_BR/translations.php b/app/Locales/pt_BR/translations.php
index b72fbb62..4c273077 100644
--- a/app/Locales/pt_BR/translations.php
+++ b/app/Locales/pt_BR/translations.php
@@ -494,4 +494,6 @@ return array(
// '%s moved the task #%d to the column "%s"' => '',
// '%s moved the task #%d to the position %d in the column "%s"' => '',
// 'Activity' => '',
+ // 'Default values are "%s"' => '',
+ // 'Default columns for new projects (Comma-separated)' => '',
);
diff --git a/app/Locales/ru_RU/translations.php b/app/Locales/ru_RU/translations.php
index a663a33a..b230853c 100644
--- a/app/Locales/ru_RU/translations.php
+++ b/app/Locales/ru_RU/translations.php
@@ -494,4 +494,6 @@ return array(
// '%s moved the task #%d to the column "%s"' => '',
// '%s moved the task #%d to the position %d in the column "%s"' => '',
// 'Activity' => '',
+ // 'Default values are "%s"' => '',
+ // 'Default columns for new projects (Comma-separated)' => '',
);
diff --git a/app/Locales/sv_SE/translations.php b/app/Locales/sv_SE/translations.php
index aa63f6aa..b762aedb 100644
--- a/app/Locales/sv_SE/translations.php
+++ b/app/Locales/sv_SE/translations.php
@@ -494,4 +494,6 @@ return array(
// '%s moved the task #%d to the column "%s"' => '',
// '%s moved the task #%d to the position %d in the column "%s"' => '',
// 'Activity' => '',
+ // 'Default values are "%s"' => '',
+ // 'Default columns for new projects (Comma-separated)' => '',
);
diff --git a/app/Locales/zh_CN/translations.php b/app/Locales/zh_CN/translations.php
index 9c45809a..d4bd084c 100644
--- a/app/Locales/zh_CN/translations.php
+++ b/app/Locales/zh_CN/translations.php
@@ -494,4 +494,6 @@ return array(
// '%s moved the task #%d to the column "%s"' => '',
// '%s moved the task #%d to the position %d in the column "%s"' => '',
// 'Activity' => '',
+ // 'Default values are "%s"' => '',
+ // 'Default columns for new projects (Comma-separated)' => '',
);
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;
diff --git a/app/Schema/Mysql.php b/app/Schema/Mysql.php
index 2d3f993e..86685067 100644
--- a/app/Schema/Mysql.php
+++ b/app/Schema/Mysql.php
@@ -4,7 +4,12 @@ namespace Schema;
use Core\Security;
-const VERSION = 25;
+const VERSION = 26;
+
+function version_26($pdo)
+{
+ $pdo->exec("ALTER TABLE config ADD COLUMN default_columns VARCHAR(255) DEFAULT ''");
+}
function version_25($pdo)
{
@@ -100,7 +105,8 @@ function version_20($pdo)
function version_19($pdo)
{
- $pdo->exec("ALTER TABLE config ADD COLUMN api_token VARCHAR(255) DEFAULT '".Security::generateToken()."'");
+ $pdo->exec("ALTER TABLE config ADD COLUMN api_token VARCHAR(255) DEFAULT ''");
+ $pdo->exec("UPDATE config SET api_token='".Security::generateToken()."'");
}
function version_18($pdo)
@@ -205,7 +211,7 @@ function version_1($pdo)
$pdo->exec("
CREATE TABLE config (
language CHAR(5) DEFAULT 'en_US',
- webhooks_token VARCHAR(255),
+ webhooks_token VARCHAR(255) DEFAULT '',
timezone VARCHAR(50) DEFAULT 'UTC'
) ENGINE=InnoDB CHARSET=utf8
");
diff --git a/app/Schema/Postgres.php b/app/Schema/Postgres.php
index b58b9bb3..a7e57d66 100644
--- a/app/Schema/Postgres.php
+++ b/app/Schema/Postgres.php
@@ -4,7 +4,12 @@ namespace Schema;
use Core\Security;
-const VERSION = 6;
+const VERSION = 7;
+
+function version_7($pdo)
+{
+ $pdo->exec("ALTER TABLE config ADD COLUMN default_columns VARCHAR(255) DEFAULT ''");
+}
function version_6($pdo)
{
@@ -95,9 +100,9 @@ function version_1($pdo)
$pdo->exec("
CREATE TABLE config (
language CHAR(5) DEFAULT 'en_US',
- webhooks_token VARCHAR(255),
+ webhooks_token VARCHAR(255) DEFAULT '',
timezone VARCHAR(50) DEFAULT 'UTC',
- api_token VARCHAR(255)
+ api_token VARCHAR(255) DEFAULT ''
);
CREATE TABLE users (
diff --git a/app/Schema/Sqlite.php b/app/Schema/Sqlite.php
index ecd62c97..cab69fa0 100644
--- a/app/Schema/Sqlite.php
+++ b/app/Schema/Sqlite.php
@@ -4,7 +4,12 @@ namespace Schema;
use Core\Security;
-const VERSION = 25;
+const VERSION = 26;
+
+function version_26($pdo)
+{
+ $pdo->exec("ALTER TABLE config ADD COLUMN default_columns TEXT DEFAULT ''");
+}
function version_25($pdo)
{
@@ -97,7 +102,8 @@ function version_20($pdo)
function version_19($pdo)
{
- $pdo->exec("ALTER TABLE config ADD COLUMN api_token TEXT DEFAULT '".Security::generateToken()."'");
+ $pdo->exec("ALTER TABLE config ADD COLUMN api_token TEXT DEFAULT ''");
+ $pdo->exec("UPDATE config SET api_token='".Security::generateToken()."'");
}
function version_18($pdo)
@@ -307,8 +313,8 @@ function version_1($pdo)
{
$pdo->exec("
CREATE TABLE config (
- language TEXT,
- webhooks_token TEXT
+ language TEXT DEFAULT 'en_US',
+ webhooks_token TEXT DEFAULT ''
)
");
@@ -366,7 +372,7 @@ function version_1($pdo)
$pdo->exec("
INSERT INTO config
- (language, webhooks_token)
- VALUES ('en_US', '".Security::generateToken()."')
+ (webhooks_token)
+ VALUES ('".Security::generateToken()."')
");
}
diff --git a/app/Templates/config_index.php b/app/Templates/config_index.php
index 98b8b28d..2d9ce116 100644
--- a/app/Templates/config_index.php
+++ b/app/Templates/config_index.php
@@ -20,6 +20,10 @@
<?= Helper\form_label(t('Webhook URL for task modification'), 'webhooks_url_task_modification') ?>
<?= Helper\form_text('webhooks_url_task_modification', $values, $errors) ?><br/>
+ <?= Helper\form_label(t('Default columns for new projects (Comma-separated)'), 'default_columns') ?>
+ <?= Helper\form_text('default_columns', $values, $errors) ?><br/>
+ <p class="form-help"><?= t('Default values are "%s"', $default_columns) ?></p>
+
<div class="form-actions">
<input type="submit" value="<?= t('Save') ?>" class="btn btn-blue"/>
</div>