From 62827e6cf470449c117624058fb36ad94804bcc0 Mon Sep 17 00:00:00 2001 From: emkael Date: Tue, 5 May 2020 14:25:42 +0200 Subject: Time tracking related plugins --- .../Controller/TaskIntervalController.php | 45 ++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 plugins/TaskIntervalButton/Controller/TaskIntervalController.php (limited to 'plugins/TaskIntervalButton/Controller') 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 @@ +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 -- cgit v1.2.3