diff options
-rw-r--r-- | ChangeLog | 8 | ||||
-rw-r--r-- | app/Api/Procedure/TaskProcedure.php | 6 | ||||
-rw-r--r-- | app/Controller/ConfigController.php | 28 | ||||
-rw-r--r-- | app/Model/ConfigModel.php | 13 | ||||
-rw-r--r-- | app/Model/SubtaskModel.php | 2 | ||||
-rw-r--r-- | app/Template/config/about.php | 3 | ||||
-rw-r--r-- | app/Template/config/upload_db.php | 18 | ||||
-rw-r--r-- | doc/en_US/api-task-procedures.markdown | 2 | ||||
-rw-r--r-- | tests/units/Pagination/SubtaskPaginationTest.php | 17 |
9 files changed, 95 insertions, 2 deletions
@@ -1,10 +1,18 @@ Version 1.0.40 (unreleased) --------------------------- +New features: + +* Upload Sqlite database from user interface + Improvements: * Use contextual menu instead of action column in users management +Bug fixes: + +* Hiding subtasks from hidden tasks in dashboard + Version 1.0.39 (Feb 12, 2017) ----------------------------- diff --git a/app/Api/Procedure/TaskProcedure.php b/app/Api/Procedure/TaskProcedure.php index af67f3de..c43e5876 100644 --- a/app/Api/Procedure/TaskProcedure.php +++ b/app/Api/Procedure/TaskProcedure.php @@ -89,7 +89,7 @@ class TaskProcedure extends BaseProcedure public function createTask($title, $project_id, $color_id = '', $column_id = 0, $owner_id = 0, $creator_id = 0, $date_due = '', $description = '', $category_id = 0, $score = 0, $swimlane_id = 0, $priority = 0, $recurrence_status = 0, $recurrence_trigger = 0, $recurrence_factor = 0, $recurrence_timeframe = 0, - $recurrence_basedate = 0, $reference = '', array $tags = array()) + $recurrence_basedate = 0, $reference = '', array $tags = array(), $date_started = '') { ProjectAuthorization::getInstance($this->container)->check($this->getClassName(), 'createTask', $project_id); @@ -121,6 +121,7 @@ class TaskProcedure extends BaseProcedure 'reference' => $reference, 'priority' => $priority, 'tags' => $tags, + 'date_started' => $date_started, ); list($valid, ) = $this->taskValidator->validateCreation($values); @@ -131,7 +132,7 @@ class TaskProcedure extends BaseProcedure public function updateTask($id, $title = null, $color_id = null, $owner_id = null, $date_due = null, $description = null, $category_id = null, $score = null, $priority = null, $recurrence_status = null, $recurrence_trigger = null, $recurrence_factor = null, - $recurrence_timeframe = null, $recurrence_basedate = null, $reference = null, $tags = null) + $recurrence_timeframe = null, $recurrence_basedate = null, $reference = null, $tags = null, $date_started = null) { TaskAuthorization::getInstance($this->container)->check($this->getClassName(), 'updateTask', $id); $project_id = $this->taskFinderModel->getProjectId($id); @@ -161,6 +162,7 @@ class TaskProcedure extends BaseProcedure 'reference' => $reference, 'priority' => $priority, 'tags' => $tags, + 'date_started' => $date_started, )); list($valid) = $this->taskValidator->validateApiModification($values); diff --git a/app/Controller/ConfigController.php b/app/Controller/ConfigController.php index 8572316e..62ae8201 100644 --- a/app/Controller/ConfigController.php +++ b/app/Controller/ConfigController.php @@ -201,6 +201,34 @@ class ConfigController extends BaseController } /** + * Display the Sqlite database upload page + * + * @access public + */ + public function uploadDb() + { + $this->response->html($this->template->render('config/upload_db')); + } + + /** + * Replace current Sqlite db with uploaded file + * + * @access public + */ + public function saveUploadedDb() + { + $filename = $this->request->getFilePath('file'); + + if (!file_exists($filename) || !$this->configModel->uploadDatabase($filename)) { + $this->flash->failure(t('Unable to read uploaded file.')); + } else { + $this->flash->success(t('Database upload done.')); + } + + $this->response->redirect($this->helper->url->to('ConfigController', 'index')); + } + + /** * Regenerate webhook token * * @access public diff --git a/app/Model/ConfigModel.php b/app/Model/ConfigModel.php index 945c5e6f..7f48f34f 100644 --- a/app/Model/ConfigModel.php +++ b/app/Model/ConfigModel.php @@ -49,6 +49,19 @@ class ConfigModel extends SettingModel } /** + * Replace database file with uploaded one + * + * @access public + * @param string $file + * @return bool + */ + public function uploadDatabase($file) + { + $this->db->closeConnection(); + return file_put_contents(DB_FILENAME, gzdecode(file_get_contents($file))) !== false; + } + + /** * Get the Sqlite database size in bytes * * @access public diff --git a/app/Model/SubtaskModel.php b/app/Model/SubtaskModel.php index 737a933d..ca2c8488 100644 --- a/app/Model/SubtaskModel.php +++ b/app/Model/SubtaskModel.php @@ -90,9 +90,11 @@ class SubtaskModel extends Base ->subquery($this->subtaskTimeTrackingModel->getTimerQuery($user_id), 'timer_start_date') ->eq('user_id', $user_id) ->eq(ProjectModel::TABLE.'.is_active', ProjectModel::ACTIVE) + ->eq(ColumnModel::TABLE.'.hide_in_dashboard', 0) ->in(SubtaskModel::TABLE.'.status', $status) ->join(TaskModel::TABLE, 'id', 'task_id') ->join(ProjectModel::TABLE, 'id', 'project_id', TaskModel::TABLE) + ->join(ColumnModel::TABLE, 'id', 'column_id', TaskModel::TABLE) ->callback(array($this, 'addStatusName')); } diff --git a/app/Template/config/about.php b/app/Template/config/about.php index 3f078c3d..23a3e6c0 100644 --- a/app/Template/config/about.php +++ b/app/Template/config/about.php @@ -69,6 +69,9 @@ <?= t('(Gzip compressed Sqlite file)') ?> </li> <li> + <?= $this->url->link(t('Upload the database'), 'ConfigController', 'uploadDb', array(), false, 'js-modal-medium') ?> + </li> + <li> <?= $this->url->link(t('Optimize the database'), 'ConfigController', 'optimizeDb', array(), true) ?> <?= t('(VACUUM command)') ?> </li> diff --git a/app/Template/config/upload_db.php b/app/Template/config/upload_db.php new file mode 100644 index 00000000..d7aaac86 --- /dev/null +++ b/app/Template/config/upload_db.php @@ -0,0 +1,18 @@ +<div class="page-header"> + <h2><?= t('Upload the Sqlite database') ?></h2> +</div> + +<div class="alert"> + <p> + <?= t('You can upload the Gzip compressed Sqlite database previously downloaded.') ?> + </p> +</div> + +<form action="<?= $this->url->href('ConfigController', 'saveUploadedDb') ?>" method="post" enctype="multipart/form-data"> + <?= $this->form->csrf() ?> + + <?= $this->form->label(t('Database file'), 'file') ?> + <?= $this->form->file('file') ?> + + <?= $this->modal->submitButtons(array('submitLabel' => t('Upload'))) ?> +</form> diff --git a/doc/en_US/api-task-procedures.markdown b/doc/en_US/api-task-procedures.markdown index db106f74..b847eb54 100644 --- a/doc/en_US/api-task-procedures.markdown +++ b/doc/en_US/api-task-procedures.markdown @@ -23,6 +23,7 @@ API Task Procedures - **recurrence_timeframe** (integer, optional) - **recurrence_basedate** (integer, optional) - **tags** ([]string, optional) + - **date_started**: d/m/Y H:i format (string, optional) - Result on success: **task_id** - Result on failure: **false** @@ -407,6 +408,7 @@ Response example: - **recurrence_timeframe** (integer, optional) - **recurrence_basedate** (integer, optional) - **tags** ([]string, optional) + - **date_started**: ISO8601 format (string, optional) - Result on success: **true** - Result on failure: **false** diff --git a/tests/units/Pagination/SubtaskPaginationTest.php b/tests/units/Pagination/SubtaskPaginationTest.php index 26a51a8b..1e16c985 100644 --- a/tests/units/Pagination/SubtaskPaginationTest.php +++ b/tests/units/Pagination/SubtaskPaginationTest.php @@ -1,5 +1,6 @@ <?php +use Kanboard\Model\ColumnModel; use Kanboard\Model\ProjectModel; use Kanboard\Model\SubtaskModel; use Kanboard\Model\TaskCreationModel; @@ -33,4 +34,20 @@ class SubtaskPaginationTest extends Base $this->assertCount(3, $subtaskPagination->getDashboardPaginator(1, 'subtasks', 5)->setOrder('task_name')->getCollection()); $this->assertCount(3, $subtaskPagination->getDashboardPaginator(1, 'subtasks', 5)->setOrder(SubtaskModel::TABLE.'.title')->getCollection()); } + + public function testWhenColumnIsHidden() + { + $columnModel = new ColumnModel($this->container); + $taskCreationModel = new TaskCreationModel($this->container); + $projectModel = new ProjectModel($this->container); + $subtaskModel = new SubtaskModel($this->container); + $subtaskPagination = new SubtaskPagination($this->container); + + $this->assertEquals(1, $projectModel->create(array('name' => 'Project #1'))); + $this->assertTrue($columnModel->update(1, 'test', 0, '', 1)); + $this->assertEquals(1, $taskCreationModel->create(array('title' => 'Task #1', 'project_id' => 1, 'column_id' => 1))); + $this->assertEquals(1, $subtaskModel->create(array('task_id' => 1, 'title' => 'subtask #1', 'user_id' => 1))); + + $this->assertCount(0, $subtaskPagination->getDashboardPaginator(1, 'subtasks', 5)->getCollection()); + } } |