diff options
Diffstat (limited to 'models')
-rw-r--r-- | models/base.php | 3 | ||||
-rw-r--r-- | models/board.php | 8 | ||||
-rw-r--r-- | models/schema.php | 13 |
3 files changed, 17 insertions, 7 deletions
diff --git a/models/base.php b/models/base.php index 0a565f51..c8e4cf19 100644 --- a/models/base.php +++ b/models/base.php @@ -11,13 +11,14 @@ require __DIR__.'/../vendor/SimpleValidator/Validators/MinLength.php'; require __DIR__.'/../vendor/SimpleValidator/Validators/Integer.php'; require __DIR__.'/../vendor/SimpleValidator/Validators/Equals.php'; require __DIR__.'/../vendor/SimpleValidator/Validators/AlphaNumeric.php'; +require __DIR__.'/../vendor/SimpleValidator/Validators/GreaterThan.php'; require __DIR__.'/../vendor/PicoDb/Database.php'; require __DIR__.'/schema.php'; abstract class Base { const APP_VERSION = 'master'; - const DB_VERSION = 5; + const DB_VERSION = 6; const DB_FILENAME = 'data/db.sqlite'; private static $dbInstance = null; diff --git a/models/board.php b/models/board.php index d213f257..1a5b8b81 100644 --- a/models/board.php +++ b/models/board.php @@ -61,8 +61,10 @@ class Board extends Base { $this->db->startTransaction(); - foreach ($values as $column_id => $column_title) { - $this->db->table(self::TABLE)->eq('id', $column_id)->update(array('title' => $column_title)); + foreach (array('title', 'task_limit') as $field) { + foreach ($values[$field] as $column_id => $field_value) { + $this->db->table(self::TABLE)->eq('id', $column_id)->update(array($field => $field_value)); + } } $this->db->closeTransaction(); @@ -140,6 +142,8 @@ class Board extends Base $rules = array(); foreach ($columns as $column_id => $column_title) { + $rules[] = new Validators\Integer('task_limit['.$column_id.']', t('This value must be an integer')); + $rules[] = new Validators\GreaterThan('task_limit['.$column_id.']', t('This value must be greater than %d', 0), 0); $rules[] = new Validators\Required('title['.$column_id.']', t('The title is required')); $rules[] = new Validators\MaxLength('title['.$column_id.']', t('The maximum length is %d characters', 50), 50); } diff --git a/models/schema.php b/models/schema.php index e06271b3..4aa2a265 100644 --- a/models/schema.php +++ b/models/schema.php @@ -2,19 +2,24 @@ namespace Schema; +function version_6($pdo) +{ + $pdo->exec("ALTER TABLE columns ADD COLUMN task_limit INTEGER DEFAULT '0'"); +} + function version_5($pdo) { - $pdo->exec("ALTER TABLE tasks ADD column score INTEGER"); + $pdo->exec("ALTER TABLE tasks ADD COLUMN score INTEGER"); } function version_4($pdo) { - $pdo->exec("ALTER TABLE config ADD column timezone TEXT DEFAULT 'UTC'"); + $pdo->exec("ALTER TABLE config ADD COLUMN timezone TEXT DEFAULT 'UTC'"); } function version_3($pdo) { - $pdo->exec('ALTER TABLE projects ADD column token TEXT'); + $pdo->exec('ALTER TABLE projects ADD COLUMN token TEXT'); // For each existing project, assign a different token $rq = $pdo->prepare("SELECT id FROM projects WHERE token IS NULL"); @@ -32,7 +37,7 @@ function version_3($pdo) function version_2($pdo) { - $pdo->exec('ALTER TABLE tasks ADD column date_completed INTEGER'); + $pdo->exec('ALTER TABLE tasks ADD COLUMN date_completed INTEGER'); $pdo->exec('UPDATE tasks SET date_completed=date_creation WHERE is_active=0'); } |