diff --git a/README.markdown b/README.markdown index 56c8a9390..c2ee88750 100644 --- a/README.markdown +++ b/README.markdown @@ -148,8 +148,8 @@ Contributors: - Alex Butum - [Aleix Pol](https://github.com/aleixpol) -- [Ashish Kulkarni](https://github.com/ashkulz) - [Ashbike](https://github.com/ashbike) +- [Ashish Kulkarni](https://github.com/ashkulz) - [Chorgroup](https://github.com/chorgroup) - Claudio Lobo - [Cluxter](https://github.com/cluxter) diff --git a/app/Controller/Board.php b/app/Controller/Board.php index 48f2b5189..f4d17f927 100644 --- a/app/Controller/Board.php +++ b/app/Controller/Board.php @@ -205,6 +205,7 @@ class Board extends Base foreach ($columns as $column) { $values['title['.$column['id'].']'] = $column['title']; + $values['description['.$column['id'].']'] = $column['description']; $values['task_limit['.$column['id'].']'] = $column['task_limit'] ?: null; } @@ -218,28 +219,39 @@ class Board extends Base } /** - * Validate and update a board + * Display a form to edit a board * * @access public */ - public function update() + public function editColumn(array $values = array(), array $errors = array()) { $project = $this->getProject(); - $columns = $this->board->getColumns($project['id']); - $data = $this->request->getValues(); - $values = $columns_list = array(); + $column = $this->board->getColumn($this->request->getIntegerParam('column_id')); - foreach ($columns as $column) { - $columns_list[$column['id']] = $column['title']; - $values['title['.$column['id'].']'] = isset($data['title'][$column['id']]) ? $data['title'][$column['id']] : ''; - $values['task_limit['.$column['id'].']'] = isset($data['task_limit'][$column['id']]) ? $data['task_limit'][$column['id']] : 0; - } + $this->response->html($this->projectLayout('board/edit_column', array( + 'errors' => $errors, + 'values' => $values ?: $column, + 'project' => $project, + 'column' => $column, + 'title' => t('Edit column "%s"', $column['title']) + ))); + } - list($valid, $errors) = $this->board->validateModification($columns_list, $values); + /** + * Validate and update a column + * + * @access public + */ + public function updateColumn() + { + $project = $this->getProject(); + $values = $this->request->getValues(); + + list($valid, $errors) = $this->board->validateModification($values); if ($valid) { - if ($this->board->update($data)) { + if ($this->board->updateColumn($values['id'], $values['title'], $values['task_limit'], $values['description'])) { $this->session->flash(t('Board updated successfully.')); $this->response->redirect('?controller=board&action=edit&project_id='.$project['id']); } @@ -248,7 +260,7 @@ class Board extends Base } } - $this->edit($values, $errors); + $this->editcolumn($values, $errors); } /** @@ -271,7 +283,7 @@ class Board extends Base if ($valid) { - if ($this->board->addColumn($project['id'], $data['title'])) { + if ($this->board->addColumn($project['id'], $data['title'],$data['description'])) { $this->session->flash(t('Board updated successfully.')); $this->response->redirect('?controller=board&action=edit&project_id='.$project['id']); } @@ -449,7 +461,7 @@ class Board extends Base } /** - * Display the description + * Display task description * * @access public */ diff --git a/app/Model/Acl.php b/app/Model/Acl.php index 91680248e..d1757a851 100644 --- a/app/Model/Acl.php +++ b/app/Model/Acl.php @@ -50,7 +50,7 @@ class Acl extends Base private $manager_acl = array( 'action' => '*', 'analytic' => '*', - 'board' => array('movecolumn', 'edit', 'update', 'add', 'remove'), + 'board' => array('movecolumn', 'edit', 'editcolumn', 'updatecolumn', 'add', 'remove'), 'category' => '*', 'export' => array('tasks', 'subtasks', 'summary'), 'project' => array('edit', 'update', 'share', 'integration', 'users', 'alloweverybody', 'allow', 'setowner', 'revoke', 'duplicate', 'disable', 'enable'), diff --git a/app/Model/Board.php b/app/Model/Board.php index 030f1efeb..2b07ca46d 100644 --- a/app/Model/Board.php +++ b/app/Model/Board.php @@ -47,7 +47,7 @@ class Board extends Base $column_name = trim($column_name); if (! empty($column_name)) { - $columns[] = array('title' => $column_name, 'task_limit' => 0); + $columns[] = array('title' => $column_name, 'task_limit' => 0, 'description' => ''); } } @@ -73,6 +73,7 @@ class Board extends Base 'position' => ++$position, 'project_id' => $project_id, 'task_limit' => $column['task_limit'], + 'description' => $column['description'], ); if (! $this->db->table(self::TABLE)->save($values)) { @@ -94,7 +95,7 @@ class Board extends Base public function duplicate($project_from, $project_to) { $columns = $this->db->table(Board::TABLE) - ->columns('title', 'task_limit') + ->columns('title', 'task_limit', 'description') ->eq('project_id', $project_from) ->asc('position') ->findAll(); @@ -109,48 +110,22 @@ class Board extends Base * @param integer $project_id Project id * @param string $title Column title * @param integer $task_limit Task limit + * @param string $description Column description * @return boolean|integer */ - public function addColumn($project_id, $title, $task_limit = 0) + public function addColumn($project_id, $title, $task_limit = 0, $description = '') { $values = array( 'project_id' => $project_id, 'title' => $title, 'task_limit' => $task_limit, 'position' => $this->getLastColumnPosition($project_id) + 1, + 'description' => $description, ); return $this->persist(self::TABLE, $values); } - /** - * Update columns - * - * @access public - * @param array $values Form values - * @return boolean - */ - public function update(array $values) - { - $columns = array(); - - foreach (array('title', 'task_limit') as $field) { - foreach ($values[$field] as $column_id => $value) { - $columns[$column_id][$field] = $value; - } - } - - $this->db->startTransaction(); - - foreach ($columns as $column_id => $values) { - $this->updateColumn($column_id, $values['title'], (int) $values['task_limit']); - } - - $this->db->closeTransaction(); - - return true; - } - /** * Update a column * @@ -158,13 +133,15 @@ class Board extends Base * @param integer $column_id Column id * @param string $title Column title * @param integer $task_limit Task limit + * @param string $description Optional description * @return boolean */ - public function updateColumn($column_id, $title, $task_limit = 0) + public function updateColumn($column_id, $title, $task_limit = 0, $description = '') { return $this->db->table(self::TABLE)->eq('id', $column_id)->update(array( 'title' => $title, 'task_limit' => $task_limit, + 'description' => $description, )); } @@ -369,22 +346,16 @@ class Board extends Base * Validate column modification * * @access public - * @param array $columns Original columns List * @param array $values Required parameters to update a column * @return array $valid, $errors [0] = Success or not, [1] = List of errors */ - public function validateModification(array $columns, array $values) + public function validateModification(array $values) { - $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); - } - - $v = new Validator($values, $rules); + $v = new Validator($values, array( + new Validators\Integer('task_limit', t('This value must be an integer')), + new Validators\Required('title', t('The title is required')), + new Validators\MaxLength('title', t('The maximum length is %d characters', 50), 50), + )); return array( $v->execute(), diff --git a/app/Schema/Mysql.php b/app/Schema/Mysql.php index 05e8f14c3..54aa748ec 100644 --- a/app/Schema/Mysql.php +++ b/app/Schema/Mysql.php @@ -5,7 +5,12 @@ namespace Schema; use PDO; use Core\Security; -const VERSION = 41; +const VERSION = 42; + +function version_42($pdo) +{ + $pdo->exec('ALTER TABLE columns ADD COLUMN description TEXT'); +} function version_41($pdo) { diff --git a/app/Schema/Postgres.php b/app/Schema/Postgres.php index 12aa5203e..eb094f177 100644 --- a/app/Schema/Postgres.php +++ b/app/Schema/Postgres.php @@ -5,7 +5,12 @@ namespace Schema; use PDO; use Core\Security; -const VERSION = 22; +const VERSION = 23; + +function version_23($pdo) +{ + $pdo->exec('ALTER TABLE columns ADD COLUMN description TEXT'); +} function version_22($pdo) { diff --git a/app/Schema/Sqlite.php b/app/Schema/Sqlite.php index c61560654..16143646a 100644 --- a/app/Schema/Sqlite.php +++ b/app/Schema/Sqlite.php @@ -5,7 +5,12 @@ namespace Schema; use Core\Security; use PDO; -const VERSION = 40; +const VERSION = 41; + +function version_41($pdo) +{ + $pdo->exec('ALTER TABLE columns ADD COLUMN description TEXT'); +} function version_40($pdo) { diff --git a/app/Template/board/edit.php b/app/Template/board/edit.php index f30a65c19..25a8ededd 100644 --- a/app/Template/board/edit.php +++ b/app/Template/board/edit.php @@ -1,50 +1,44 @@