diff options
author | emkael <emkael@tlen.pl> | 2020-05-05 14:25:42 +0200 |
---|---|---|
committer | emkael <emkael@tlen.pl> | 2020-05-05 14:25:42 +0200 |
commit | 62827e6cf470449c117624058fb36ad94804bcc0 (patch) | |
tree | 10cd1e4d36c34b694acfadaa69fc7f6ae2b1eabd /plugins/TaskIntervalButton/Controller/TaskIntervalController.php | |
parent | 7b66ddf2e4fbdb837e78d8b7dbaa9fc38391bc32 (diff) |
Diffstat (limited to 'plugins/TaskIntervalButton/Controller/TaskIntervalController.php')
-rw-r--r-- | plugins/TaskIntervalButton/Controller/TaskIntervalController.php | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/plugins/TaskIntervalButton/Controller/TaskIntervalController.php b/plugins/TaskIntervalButton/Controller/TaskIntervalController.php new file mode 100644 index 00000000..27b9395d --- /dev/null +++ b/plugins/TaskIntervalButton/Controller/TaskIntervalController.php @@ -0,0 +1,45 @@ +<?php + +namespace Kanboard\Plugin\TaskIntervalButton\Controller; + +use Kanboard\Controller\BaseController; +use Kanboard\Core\Controller\AccessForbiddenException; + +class TaskIntervalController extends BaseController +{ + public function confirm() + { + $task = $this->getTask(); + $user = $this->getUser(); + + if ($user['username'] !== $task["assignee_username"]) { + throw new AccessForbiddenException(); + } + + $this->response->html($this->template->render('TaskIntervalButton:task_add_interval/add_interval_confirm', array( + 'task' => $task, + 'user' => $user + ))); + } + + public function addInterval() + { + $task = $this->getTask(); + $user = $this->getUser(); + $this->checkCSRFParam(); + + if ($user['username'] !== $task["assignee_username"]) { + throw new AccessForbiddenException(); + } + + $values = array('id' => $task['id'], 'time_spent' => $task['time_spent'] + 0.5); + + if ($this->taskModificationModel->update($values, false)) { + $this->flash->success(t("Interval added.")); + } else { + $this->flash->failure(t("Unable to add interval.")); + } + + return $this->response->redirect($this->helper->url->to('TaskViewController', 'show', array('task_id' => $task['id'], 'project_id' => $task['project_id'])), true); + } +}
\ No newline at end of file |