From 9ebbe3da56914c408327997cea4eb00db2f88e0c Mon Sep 17 00:00:00 2001 From: Frederic Guillot Date: Thu, 26 May 2016 21:38:43 -0400 Subject: Rename task controllers --- app/Controller/TaskImport.php | 75 ------------ app/Controller/TaskImportController.php | 75 ++++++++++++ app/Controller/TaskInternalLink.php | 167 -------------------------- app/Controller/TaskInternalLinkController.php | 167 ++++++++++++++++++++++++++ app/Controller/TaskModificationController.php | 130 ++++++++++++++++++++ app/Controller/TaskPopover.php | 100 --------------- app/Controller/TaskPopoverController.php | 100 +++++++++++++++ app/Controller/TaskRecurrence.php | 65 ---------- app/Controller/TaskRecurrenceController.php | 65 ++++++++++ app/Controller/TaskStatusController.php | 62 ++++++++++ app/Controller/Taskmodification.php | 130 -------------------- app/Controller/Taskstatus.php | 62 ---------- 12 files changed, 599 insertions(+), 599 deletions(-) delete mode 100644 app/Controller/TaskImport.php create mode 100644 app/Controller/TaskImportController.php delete mode 100644 app/Controller/TaskInternalLink.php create mode 100644 app/Controller/TaskInternalLinkController.php create mode 100644 app/Controller/TaskModificationController.php delete mode 100644 app/Controller/TaskPopover.php create mode 100644 app/Controller/TaskPopoverController.php delete mode 100644 app/Controller/TaskRecurrence.php create mode 100644 app/Controller/TaskRecurrenceController.php create mode 100644 app/Controller/TaskStatusController.php delete mode 100644 app/Controller/Taskmodification.php delete mode 100644 app/Controller/Taskstatus.php (limited to 'app/Controller') diff --git a/app/Controller/TaskImport.php b/app/Controller/TaskImport.php deleted file mode 100644 index 5e37fb2f..00000000 --- a/app/Controller/TaskImport.php +++ /dev/null @@ -1,75 +0,0 @@ -getProject(); - - $this->response->html($this->helper->layout->project('task_import/step1', array( - 'project' => $project, - 'values' => $values, - 'errors' => $errors, - 'max_size' => ini_get('upload_max_filesize'), - 'delimiters' => Csv::getDelimiters(), - 'enclosures' => Csv::getEnclosures(), - 'title' => t('Import tasks from CSV file'), - ))); - } - - /** - * Process CSV file - * - */ - public function step2() - { - $project = $this->getProject(); - $values = $this->request->getValues(); - $filename = $this->request->getFilePath('file'); - - if (! file_exists($filename)) { - $this->step1($values, array('file' => array(t('Unable to read your file')))); - } - - $this->taskImport->projectId = $project['id']; - - $csv = new Csv($values['delimiter'], $values['enclosure']); - $csv->setColumnMapping($this->taskImport->getColumnMapping()); - $csv->read($filename, array($this->taskImport, 'import')); - - if ($this->taskImport->counter > 0) { - $this->flash->success(t('%d task(s) have been imported successfully.', $this->taskImport->counter)); - } else { - $this->flash->failure(t('Nothing have been imported!')); - } - - $this->response->redirect($this->helper->url->to('taskImport', 'step1', array('project_id' => $project['id']))); - } - - /** - * Generate template - * - */ - public function template() - { - $this->response->withFileDownload('tasks.csv'); - $this->response->csv(array($this->taskImport->getColumnMapping())); - } -} diff --git a/app/Controller/TaskImportController.php b/app/Controller/TaskImportController.php new file mode 100644 index 00000000..a4c39f84 --- /dev/null +++ b/app/Controller/TaskImportController.php @@ -0,0 +1,75 @@ +getProject(); + + $this->response->html($this->helper->layout->project('task_import/step1', array( + 'project' => $project, + 'values' => $values, + 'errors' => $errors, + 'max_size' => ini_get('upload_max_filesize'), + 'delimiters' => Csv::getDelimiters(), + 'enclosures' => Csv::getEnclosures(), + 'title' => t('Import tasks from CSV file'), + ))); + } + + /** + * Process CSV file + * + */ + public function step2() + { + $project = $this->getProject(); + $values = $this->request->getValues(); + $filename = $this->request->getFilePath('file'); + + if (! file_exists($filename)) { + $this->step1($values, array('file' => array(t('Unable to read your file')))); + } + + $this->taskImport->projectId = $project['id']; + + $csv = new Csv($values['delimiter'], $values['enclosure']); + $csv->setColumnMapping($this->taskImport->getColumnMapping()); + $csv->read($filename, array($this->taskImport, 'import')); + + if ($this->taskImport->counter > 0) { + $this->flash->success(t('%d task(s) have been imported successfully.', $this->taskImport->counter)); + } else { + $this->flash->failure(t('Nothing have been imported!')); + } + + $this->response->redirect($this->helper->url->to('TaskImportController', 'step1', array('project_id' => $project['id']))); + } + + /** + * Generate template + * + */ + public function template() + { + $this->response->withFileDownload('tasks.csv'); + $this->response->csv(array($this->taskImport->getColumnMapping())); + } +} diff --git a/app/Controller/TaskInternalLink.php b/app/Controller/TaskInternalLink.php deleted file mode 100644 index 6ff20252..00000000 --- a/app/Controller/TaskInternalLink.php +++ /dev/null @@ -1,167 +0,0 @@ -taskLink->getById($this->request->getIntegerParam('link_id')); - - if (empty($link)) { - throw new PageNotFoundException(); - } - - return $link; - } - - /** - * Creation form - * - * @access public - * @param array $values - * @param array $errors - * @throws PageNotFoundException - * @throws \Kanboard\Core\Controller\AccessForbiddenException - */ - public function create(array $values = array(), array $errors = array()) - { - $task = $this->getTask(); - - $this->response->html($this->template->render('task_internal_link/create', array( - 'values' => $values, - 'errors' => $errors, - 'task' => $task, - 'labels' => $this->link->getList(0, false), - ))); - } - - /** - * Validation and creation - * - * @access public - */ - public function save() - { - $task = $this->getTask(); - $values = $this->request->getValues(); - - list($valid, $errors) = $this->taskLinkValidator->validateCreation($values); - - if ($valid) { - if ($this->taskLink->create($values['task_id'], $values['opposite_task_id'], $values['link_id'])) { - $this->flash->success(t('Link added successfully.')); - return $this->response->redirect($this->helper->url->to('task', 'show', array('task_id' => $task['id'], 'project_id' => $task['project_id'])), true); - } - - $errors = array('title' => array(t('The exact same link already exists'))); - $this->flash->failure(t('Unable to create your link.')); - } - - return $this->create($values, $errors); - } - - /** - * Edit form - * - * @access public - * @param array $values - * @param array $errors - * @throws PageNotFoundException - * @throws \Kanboard\Core\Controller\AccessForbiddenException - */ - public function edit(array $values = array(), array $errors = array()) - { - $task = $this->getTask(); - $task_link = $this->getTaskLink(); - - if (empty($values)) { - $opposite_task = $this->taskFinder->getById($task_link['opposite_task_id']); - $values = $task_link; - $values['title'] = '#'.$opposite_task['id'].' - '.$opposite_task['title']; - } - - $this->response->html($this->template->render('task_internal_link/edit', array( - 'values' => $values, - 'errors' => $errors, - 'task_link' => $task_link, - 'task' => $task, - 'labels' => $this->link->getList(0, false) - ))); - } - - /** - * Validation and update - * - * @access public - */ - public function update() - { - $task = $this->getTask(); - $values = $this->request->getValues(); - - list($valid, $errors) = $this->taskLinkValidator->validateModification($values); - - if ($valid) { - if ($this->taskLink->update($values['id'], $values['task_id'], $values['opposite_task_id'], $values['link_id'])) { - $this->flash->success(t('Link updated successfully.')); - return $this->response->redirect($this->helper->url->to('task', 'show', array('task_id' => $task['id'], 'project_id' => $task['project_id'])).'#links'); - } - - $this->flash->failure(t('Unable to update your link.')); - } - - return $this->edit($values, $errors); - } - - /** - * Confirmation dialog before removing a link - * - * @access public - */ - public function confirm() - { - $task = $this->getTask(); - $link = $this->getTaskLink(); - - $this->response->html($this->template->render('task_internal_link/remove', array( - 'link' => $link, - 'task' => $task, - ))); - } - - /** - * Remove a link - * - * @access public - */ - public function remove() - { - $this->checkCSRFParam(); - $task = $this->getTask(); - - if ($this->taskLink->remove($this->request->getIntegerParam('link_id'))) { - $this->flash->success(t('Link removed successfully.')); - } else { - $this->flash->failure(t('Unable to remove this link.')); - } - - $this->response->redirect($this->helper->url->to('task', 'show', array('task_id' => $task['id'], 'project_id' => $task['project_id']))); - } -} diff --git a/app/Controller/TaskInternalLinkController.php b/app/Controller/TaskInternalLinkController.php new file mode 100644 index 00000000..f97426c6 --- /dev/null +++ b/app/Controller/TaskInternalLinkController.php @@ -0,0 +1,167 @@ +taskLink->getById($this->request->getIntegerParam('link_id')); + + if (empty($link)) { + throw new PageNotFoundException(); + } + + return $link; + } + + /** + * Creation form + * + * @access public + * @param array $values + * @param array $errors + * @throws PageNotFoundException + * @throws \Kanboard\Core\Controller\AccessForbiddenException + */ + public function create(array $values = array(), array $errors = array()) + { + $task = $this->getTask(); + + $this->response->html($this->template->render('task_internal_link/create', array( + 'values' => $values, + 'errors' => $errors, + 'task' => $task, + 'labels' => $this->link->getList(0, false), + ))); + } + + /** + * Validation and creation + * + * @access public + */ + public function save() + { + $task = $this->getTask(); + $values = $this->request->getValues(); + + list($valid, $errors) = $this->taskLinkValidator->validateCreation($values); + + if ($valid) { + if ($this->taskLink->create($values['task_id'], $values['opposite_task_id'], $values['link_id'])) { + $this->flash->success(t('Link added successfully.')); + return $this->response->redirect($this->helper->url->to('task', 'show', array('task_id' => $task['id'], 'project_id' => $task['project_id'])), true); + } + + $errors = array('title' => array(t('The exact same link already exists'))); + $this->flash->failure(t('Unable to create your link.')); + } + + return $this->create($values, $errors); + } + + /** + * Edit form + * + * @access public + * @param array $values + * @param array $errors + * @throws PageNotFoundException + * @throws \Kanboard\Core\Controller\AccessForbiddenException + */ + public function edit(array $values = array(), array $errors = array()) + { + $task = $this->getTask(); + $task_link = $this->getTaskLink(); + + if (empty($values)) { + $opposite_task = $this->taskFinder->getById($task_link['opposite_task_id']); + $values = $task_link; + $values['title'] = '#'.$opposite_task['id'].' - '.$opposite_task['title']; + } + + $this->response->html($this->template->render('task_internal_link/edit', array( + 'values' => $values, + 'errors' => $errors, + 'task_link' => $task_link, + 'task' => $task, + 'labels' => $this->link->getList(0, false) + ))); + } + + /** + * Validation and update + * + * @access public + */ + public function update() + { + $task = $this->getTask(); + $values = $this->request->getValues(); + + list($valid, $errors) = $this->taskLinkValidator->validateModification($values); + + if ($valid) { + if ($this->taskLink->update($values['id'], $values['task_id'], $values['opposite_task_id'], $values['link_id'])) { + $this->flash->success(t('Link updated successfully.')); + return $this->response->redirect($this->helper->url->to('task', 'show', array('task_id' => $task['id'], 'project_id' => $task['project_id'])).'#links'); + } + + $this->flash->failure(t('Unable to update your link.')); + } + + return $this->edit($values, $errors); + } + + /** + * Confirmation dialog before removing a link + * + * @access public + */ + public function confirm() + { + $task = $this->getTask(); + $link = $this->getTaskLink(); + + $this->response->html($this->template->render('task_internal_link/remove', array( + 'link' => $link, + 'task' => $task, + ))); + } + + /** + * Remove a link + * + * @access public + */ + public function remove() + { + $this->checkCSRFParam(); + $task = $this->getTask(); + + if ($this->taskLink->remove($this->request->getIntegerParam('link_id'))) { + $this->flash->success(t('Link removed successfully.')); + } else { + $this->flash->failure(t('Unable to remove this link.')); + } + + $this->response->redirect($this->helper->url->to('task', 'show', array('task_id' => $task['id'], 'project_id' => $task['project_id']))); + } +} diff --git a/app/Controller/TaskModificationController.php b/app/Controller/TaskModificationController.php new file mode 100644 index 00000000..47c07511 --- /dev/null +++ b/app/Controller/TaskModificationController.php @@ -0,0 +1,130 @@ +getTask(); + $this->taskModification->update(array('id' => $task['id'], 'date_started' => time())); + $this->response->redirect($this->helper->url->to('task', 'show', array('project_id' => $task['project_id'], 'task_id' => $task['id']))); + } + + /** + * Edit description form + * + * @access public + * @param array $values + * @param array $errors + * @throws \Kanboard\Core\Controller\AccessForbiddenException + * @throws \Kanboard\Core\Controller\PageNotFoundException + */ + public function description(array $values = array(), array $errors = array()) + { + $task = $this->getTask(); + + if (empty($values)) { + $values = array('id' => $task['id'], 'description' => $task['description']); + } + + $this->response->html($this->template->render('task_modification/edit_description', array( + 'values' => $values, + 'errors' => $errors, + 'task' => $task, + ))); + } + + /** + * Update description + * + * @access public + */ + public function updateDescription() + { + $task = $this->getTask(); + $values = $this->request->getValues(); + + list($valid, $errors) = $this->taskValidator->validateDescriptionCreation($values); + + if ($valid) { + if ($this->taskModification->update($values)) { + $this->flash->success(t('Task updated successfully.')); + } else { + $this->flash->failure(t('Unable to update your task.')); + } + + return $this->response->redirect($this->helper->url->to('task', 'show', array('project_id' => $task['project_id'], 'task_id' => $task['id'])), true); + } + + return $this->description($values, $errors); + } + + /** + * Display a form to edit a task + * + * @access public + * @param array $values + * @param array $errors + * @throws \Kanboard\Core\Controller\AccessForbiddenException + * @throws \Kanboard\Core\Controller\PageNotFoundException + */ + public function edit(array $values = array(), array $errors = array()) + { + $task = $this->getTask(); + $project = $this->project->getById($task['project_id']); + + if (empty($values)) { + $values = $task; + $values = $this->hook->merge('controller:task:form:default', $values, array('default_values' => $values)); + $values = $this->hook->merge('controller:task-modification:form:default', $values, array('default_values' => $values)); + } + + $values = $this->dateParser->format($values, array('date_due'), $this->config->get('application_date_format', DateParser::DATE_FORMAT)); + $values = $this->dateParser->format($values, array('date_started'), $this->config->get('application_datetime_format', DateParser::DATE_TIME_FORMAT)); + + $this->response->html($this->template->render('task_modification/edit_task', array( + 'project' => $project, + 'values' => $values, + 'errors' => $errors, + 'task' => $task, + 'users_list' => $this->projectUserRole->getAssignableUsersList($task['project_id']), + 'colors_list' => $this->color->getList(), + 'categories_list' => $this->category->getList($task['project_id']), + ))); + } + + /** + * Validate and update a task + * + * @access public + */ + public function update() + { + $task = $this->getTask(); + $values = $this->request->getValues(); + + list($valid, $errors) = $this->taskValidator->validateModification($values); + + if ($valid && $this->taskModification->update($values)) { + $this->flash->success(t('Task updated successfully.')); + $this->response->redirect($this->helper->url->to('task', 'show', array('project_id' => $task['project_id'], 'task_id' => $task['id'])), true); + } else { + $this->flash->failure(t('Unable to update your task.')); + $this->edit($values, $errors); + } + } +} diff --git a/app/Controller/TaskPopover.php b/app/Controller/TaskPopover.php deleted file mode 100644 index 0e47cffe..00000000 --- a/app/Controller/TaskPopover.php +++ /dev/null @@ -1,100 +0,0 @@ -getTask(); - $project = $this->project->getById($task['project_id']); - - $this->response->html($this->template->render('task_popover/change_assignee', array( - 'values' => $task, - 'users_list' => $this->projectUserRole->getAssignableUsersList($project['id']), - 'project' => $project, - ))); - } - - /** - * Validate an assignee modification - * - * @access public - */ - public function updateAssignee() - { - $values = $this->request->getValues(); - - list($valid,) = $this->taskValidator->validateAssigneeModification($values); - - if ($valid && $this->taskModification->update($values)) { - $this->flash->success(t('Task updated successfully.')); - } else { - $this->flash->failure(t('Unable to update your task.')); - } - - $this->response->redirect($this->helper->url->to('board', 'show', array('project_id' => $values['project_id'])), true); - } - - /** - * Change a task category directly from the board - * - * @access public - */ - public function changeCategory() - { - $task = $this->getTask(); - $project = $this->project->getById($task['project_id']); - - $this->response->html($this->template->render('task_popover/change_category', array( - 'values' => $task, - 'categories_list' => $this->category->getList($project['id']), - 'project' => $project, - ))); - } - - /** - * Validate a category modification - * - * @access public - */ - public function updateCategory() - { - $values = $this->request->getValues(); - - list($valid,) = $this->taskValidator->validateCategoryModification($values); - - if ($valid && $this->taskModification->update($values)) { - $this->flash->success(t('Task updated successfully.')); - } else { - $this->flash->failure(t('Unable to update your task.')); - } - - $this->response->redirect($this->helper->url->to('board', 'show', array('project_id' => $values['project_id'])), true); - } - - /** - * Screenshot popover - * - * @access public - */ - public function screenshot() - { - $task = $this->getTask(); - - $this->response->html($this->template->render('task_file/screenshot', array( - 'task' => $task, - ))); - } -} diff --git a/app/Controller/TaskPopoverController.php b/app/Controller/TaskPopoverController.php new file mode 100644 index 00000000..9bac2206 --- /dev/null +++ b/app/Controller/TaskPopoverController.php @@ -0,0 +1,100 @@ +getTask(); + $project = $this->project->getById($task['project_id']); + + $this->response->html($this->template->render('task_popover/change_assignee', array( + 'values' => $task, + 'users_list' => $this->projectUserRole->getAssignableUsersList($project['id']), + 'project' => $project, + ))); + } + + /** + * Validate an assignee modification + * + * @access public + */ + public function updateAssignee() + { + $values = $this->request->getValues(); + + list($valid,) = $this->taskValidator->validateAssigneeModification($values); + + if ($valid && $this->taskModification->update($values)) { + $this->flash->success(t('Task updated successfully.')); + } else { + $this->flash->failure(t('Unable to update your task.')); + } + + $this->response->redirect($this->helper->url->to('board', 'show', array('project_id' => $values['project_id'])), true); + } + + /** + * Change a task category directly from the board + * + * @access public + */ + public function changeCategory() + { + $task = $this->getTask(); + $project = $this->project->getById($task['project_id']); + + $this->response->html($this->template->render('task_popover/change_category', array( + 'values' => $task, + 'categories_list' => $this->category->getList($project['id']), + 'project' => $project, + ))); + } + + /** + * Validate a category modification + * + * @access public + */ + public function updateCategory() + { + $values = $this->request->getValues(); + + list($valid,) = $this->taskValidator->validateCategoryModification($values); + + if ($valid && $this->taskModification->update($values)) { + $this->flash->success(t('Task updated successfully.')); + } else { + $this->flash->failure(t('Unable to update your task.')); + } + + $this->response->redirect($this->helper->url->to('board', 'show', array('project_id' => $values['project_id'])), true); + } + + /** + * Screenshot popover + * + * @access public + */ + public function screenshot() + { + $task = $this->getTask(); + + $this->response->html($this->template->render('task_file/screenshot', array( + 'task' => $task, + ))); + } +} diff --git a/app/Controller/TaskRecurrence.php b/app/Controller/TaskRecurrence.php deleted file mode 100644 index 72dce3a5..00000000 --- a/app/Controller/TaskRecurrence.php +++ /dev/null @@ -1,65 +0,0 @@ -getTask(); - - if (empty($values)) { - $values = $task; - } - - $this->response->html($this->template->render('task_recurrence/edit', array( - 'values' => $values, - 'errors' => $errors, - 'task' => $task, - 'recurrence_status_list' => $this->task->getRecurrenceStatusList(), - 'recurrence_trigger_list' => $this->task->getRecurrenceTriggerList(), - 'recurrence_timeframe_list' => $this->task->getRecurrenceTimeframeList(), - 'recurrence_basedate_list' => $this->task->getRecurrenceBasedateList(), - ))); - } - - /** - * Update recurrence form - * - * @access public - */ - public function update() - { - $task = $this->getTask(); - $values = $this->request->getValues(); - - list($valid, $errors) = $this->taskValidator->validateEditRecurrence($values); - - if ($valid) { - if ($this->taskModification->update($values)) { - $this->flash->success(t('Task updated successfully.')); - } else { - $this->flash->failure(t('Unable to update your task.')); - } - - return $this->response->redirect($this->helper->url->to('task', 'show', array('project_id' => $task['project_id'], 'task_id' => $task['id'])), true); - } - - return $this->edit($values, $errors); - } -} diff --git a/app/Controller/TaskRecurrenceController.php b/app/Controller/TaskRecurrenceController.php new file mode 100644 index 00000000..1acf4038 --- /dev/null +++ b/app/Controller/TaskRecurrenceController.php @@ -0,0 +1,65 @@ +getTask(); + + if (empty($values)) { + $values = $task; + } + + $this->response->html($this->template->render('task_recurrence/edit', array( + 'values' => $values, + 'errors' => $errors, + 'task' => $task, + 'recurrence_status_list' => $this->task->getRecurrenceStatusList(), + 'recurrence_trigger_list' => $this->task->getRecurrenceTriggerList(), + 'recurrence_timeframe_list' => $this->task->getRecurrenceTimeframeList(), + 'recurrence_basedate_list' => $this->task->getRecurrenceBasedateList(), + ))); + } + + /** + * Update recurrence form + * + * @access public + */ + public function update() + { + $task = $this->getTask(); + $values = $this->request->getValues(); + + list($valid, $errors) = $this->taskValidator->validateEditRecurrence($values); + + if ($valid) { + if ($this->taskModification->update($values)) { + $this->flash->success(t('Task updated successfully.')); + } else { + $this->flash->failure(t('Unable to update your task.')); + } + + return $this->response->redirect($this->helper->url->to('task', 'show', array('project_id' => $task['project_id'], 'task_id' => $task['id'])), true); + } + + return $this->edit($values, $errors); + } +} diff --git a/app/Controller/TaskStatusController.php b/app/Controller/TaskStatusController.php new file mode 100644 index 00000000..fca168ec --- /dev/null +++ b/app/Controller/TaskStatusController.php @@ -0,0 +1,62 @@ +changeStatus('close', 'task_status/close', t('Task closed successfully.'), t('Unable to close this task.')); + } + + /** + * Open a task + * + * @access public + */ + public function open() + { + $this->changeStatus('open', 'task_status/open', t('Task opened successfully.'), t('Unable to open this task.')); + } + + /** + * Common method to change status + * + * @access private + * @param string $method + * @param string $template + * @param string $success_message + * @param string $failure_message + */ + private function changeStatus($method, $template, $success_message, $failure_message) + { + $task = $this->getTask(); + + if ($this->request->getStringParam('confirmation') === 'yes') { + $this->checkCSRFParam(); + + if ($this->taskStatus->$method($task['id'])) { + $this->flash->success($success_message); + } else { + $this->flash->failure($failure_message); + } + + return $this->response->redirect($this->helper->url->to('task', 'show', array('task_id' => $task['id'], 'project_id' => $task['project_id'])), true); + } + + return $this->response->html($this->template->render($template, array( + 'task' => $task, + ))); + } +} diff --git a/app/Controller/Taskmodification.php b/app/Controller/Taskmodification.php deleted file mode 100644 index e8eafe20..00000000 --- a/app/Controller/Taskmodification.php +++ /dev/null @@ -1,130 +0,0 @@ -getTask(); - $this->taskModification->update(array('id' => $task['id'], 'date_started' => time())); - $this->response->redirect($this->helper->url->to('task', 'show', array('project_id' => $task['project_id'], 'task_id' => $task['id']))); - } - - /** - * Edit description form - * - * @access public - * @param array $values - * @param array $errors - * @throws \Kanboard\Core\Controller\AccessForbiddenException - * @throws \Kanboard\Core\Controller\PageNotFoundException - */ - public function description(array $values = array(), array $errors = array()) - { - $task = $this->getTask(); - - if (empty($values)) { - $values = array('id' => $task['id'], 'description' => $task['description']); - } - - $this->response->html($this->template->render('task_modification/edit_description', array( - 'values' => $values, - 'errors' => $errors, - 'task' => $task, - ))); - } - - /** - * Update description - * - * @access public - */ - public function updateDescription() - { - $task = $this->getTask(); - $values = $this->request->getValues(); - - list($valid, $errors) = $this->taskValidator->validateDescriptionCreation($values); - - if ($valid) { - if ($this->taskModification->update($values)) { - $this->flash->success(t('Task updated successfully.')); - } else { - $this->flash->failure(t('Unable to update your task.')); - } - - return $this->response->redirect($this->helper->url->to('task', 'show', array('project_id' => $task['project_id'], 'task_id' => $task['id'])), true); - } - - return $this->description($values, $errors); - } - - /** - * Display a form to edit a task - * - * @access public - * @param array $values - * @param array $errors - * @throws \Kanboard\Core\Controller\AccessForbiddenException - * @throws \Kanboard\Core\Controller\PageNotFoundException - */ - public function edit(array $values = array(), array $errors = array()) - { - $task = $this->getTask(); - $project = $this->project->getById($task['project_id']); - - if (empty($values)) { - $values = $task; - $values = $this->hook->merge('controller:task:form:default', $values, array('default_values' => $values)); - $values = $this->hook->merge('controller:task-modification:form:default', $values, array('default_values' => $values)); - } - - $values = $this->dateParser->format($values, array('date_due'), $this->config->get('application_date_format', DateParser::DATE_FORMAT)); - $values = $this->dateParser->format($values, array('date_started'), $this->config->get('application_datetime_format', DateParser::DATE_TIME_FORMAT)); - - $this->response->html($this->template->render('task_modification/edit_task', array( - 'project' => $project, - 'values' => $values, - 'errors' => $errors, - 'task' => $task, - 'users_list' => $this->projectUserRole->getAssignableUsersList($task['project_id']), - 'colors_list' => $this->color->getList(), - 'categories_list' => $this->category->getList($task['project_id']), - ))); - } - - /** - * Validate and update a task - * - * @access public - */ - public function update() - { - $task = $this->getTask(); - $values = $this->request->getValues(); - - list($valid, $errors) = $this->taskValidator->validateModification($values); - - if ($valid && $this->taskModification->update($values)) { - $this->flash->success(t('Task updated successfully.')); - $this->response->redirect($this->helper->url->to('task', 'show', array('project_id' => $task['project_id'], 'task_id' => $task['id'])), true); - } else { - $this->flash->failure(t('Unable to update your task.')); - $this->edit($values, $errors); - } - } -} diff --git a/app/Controller/Taskstatus.php b/app/Controller/Taskstatus.php deleted file mode 100644 index eeaf8513..00000000 --- a/app/Controller/Taskstatus.php +++ /dev/null @@ -1,62 +0,0 @@ -changeStatus('close', 'task_status/close', t('Task closed successfully.'), t('Unable to close this task.')); - } - - /** - * Open a task - * - * @access public - */ - public function open() - { - $this->changeStatus('open', 'task_status/open', t('Task opened successfully.'), t('Unable to open this task.')); - } - - /** - * Common method to change status - * - * @access private - * @param string $method - * @param string $template - * @param string $success_message - * @param string $failure_message - */ - private function changeStatus($method, $template, $success_message, $failure_message) - { - $task = $this->getTask(); - - if ($this->request->getStringParam('confirmation') === 'yes') { - $this->checkCSRFParam(); - - if ($this->taskStatus->$method($task['id'])) { - $this->flash->success($success_message); - } else { - $this->flash->failure($failure_message); - } - - return $this->response->redirect($this->helper->url->to('task', 'show', array('task_id' => $task['id'], 'project_id' => $task['project_id'])), true); - } - - return $this->response->html($this->template->render($template, array( - 'task' => $task, - ))); - } -} -- cgit v1.2.3