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 +++++++++++++++++++++ plugins/TaskIntervalButton/LICENSE | 21 ++++++++++ .../Locale/en_GB/translations.php | 3 ++ .../Locale/pl_PL/translations.php | 9 +++++ plugins/TaskIntervalButton/Makefile | 5 +++ plugins/TaskIntervalButton/Plugin.php | 47 ++++++++++++++++++++++ plugins/TaskIntervalButton/README.md | 31 ++++++++++++++ .../task_add_interval/add_interval_button.php | 5 +++ .../task_add_interval/add_interval_confirm.php | 15 +++++++ plugins/TaskIntervalButton/Test/PluginTest.php | 20 +++++++++ 10 files changed, 201 insertions(+) create mode 100644 plugins/TaskIntervalButton/Controller/TaskIntervalController.php create mode 100644 plugins/TaskIntervalButton/LICENSE create mode 100644 plugins/TaskIntervalButton/Locale/en_GB/translations.php create mode 100644 plugins/TaskIntervalButton/Locale/pl_PL/translations.php create mode 100644 plugins/TaskIntervalButton/Makefile create mode 100644 plugins/TaskIntervalButton/Plugin.php create mode 100644 plugins/TaskIntervalButton/README.md create mode 100644 plugins/TaskIntervalButton/Template/task_add_interval/add_interval_button.php create mode 100644 plugins/TaskIntervalButton/Template/task_add_interval/add_interval_confirm.php create mode 100644 plugins/TaskIntervalButton/Test/PluginTest.php (limited to 'plugins/TaskIntervalButton') 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 diff --git a/plugins/TaskIntervalButton/LICENSE b/plugins/TaskIntervalButton/LICENSE new file mode 100644 index 00000000..88d0052e --- /dev/null +++ b/plugins/TaskIntervalButton/LICENSE @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) 2016 Igor Mroz + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/plugins/TaskIntervalButton/Locale/en_GB/translations.php b/plugins/TaskIntervalButton/Locale/en_GB/translations.php new file mode 100644 index 00000000..eed6d54d --- /dev/null +++ b/plugins/TaskIntervalButton/Locale/en_GB/translations.php @@ -0,0 +1,3 @@ + 'Dodaj spędzony czas', + 'Interval added.' => 'Czas dodany.', + 'Unable to add interval.' => 'Nie udało się dodać czasu.', + 'Add interval' => 'Dodaj czas', + 'Do you really want to add interval (30 minutes) to this task: "%s"?' => 'Czy na pewno chcesz dodać czas (30 minut) do zadania: "%s"?', +); diff --git a/plugins/TaskIntervalButton/Makefile b/plugins/TaskIntervalButton/Makefile new file mode 100644 index 00000000..7a80e681 --- /dev/null +++ b/plugins/TaskIntervalButton/Makefile @@ -0,0 +1,5 @@ +plugin=TaskIntervalButton + +all: + @ echo "Build archive for plugin ${plugin} version=${version}" + @ git archive HEAD --prefix=${plugin}/ --format=zip -o ${plugin}-${version}.zip diff --git a/plugins/TaskIntervalButton/Plugin.php b/plugins/TaskIntervalButton/Plugin.php new file mode 100644 index 00000000..ea73cf11 --- /dev/null +++ b/plugins/TaskIntervalButton/Plugin.php @@ -0,0 +1,47 @@ +projectAccessMap->add('TaskIntervalController', array("confirm", "addInterval"), Role::PROJECT_MEMBER); + $this->template->hook->attach('template:task:sidebar:actions', 'TaskIntervalButton:task_add_interval/add_interval_button'); + } + + public function onStartup() + { + Translator::load($this->languageModel->getCurrentLanguage(), __DIR__.'/Locale'); + } + + public function getPluginName() + { + return 'Task Interval Button'; + } + + public function getPluginDescription() + { + return t('Simple plugins which adds button to incrementally change time spent on task.'); + } + + public function getPluginAuthor() + { + return 'Igor Mroz'; + } + + public function getPluginVersion() + { + return '0.9.0'; + } + + public function getPluginHomepage() + { + return 'https://github.com/mrozigor/kanboard-add-time-interval-plugin'; + } +} + diff --git a/plugins/TaskIntervalButton/README.md b/plugins/TaskIntervalButton/README.md new file mode 100644 index 00000000..7ab86ab0 --- /dev/null +++ b/plugins/TaskIntervalButton/README.md @@ -0,0 +1,31 @@ +Task Interval Button +============================== + +Simple plugins which adds button to incrementally change time spent on task. + +Author +------ + +- Igor Mroz +- License MIT + +Requirements +------------ + +- Kanboard >= 1.0.35 + +Installation +------------ + +You have the choice between 3 methods: + +1. Install the plugin from the Kanboard plugin manager in one click +2. Download the zip file and decompress everything under the directory `plugins/IM` +3. Clone this repository into the folder `plugins/IM` + +Note: Plugin folder is case-sensitive. + +Documentation +------------- + +On task summary page, in the sidebar there is button "Add time interval" which adds 30 minutes to time actually spent on this task. You have to confirm this. diff --git a/plugins/TaskIntervalButton/Template/task_add_interval/add_interval_button.php b/plugins/TaskIntervalButton/Template/task_add_interval/add_interval_button.php new file mode 100644 index 00000000..faf1996a --- /dev/null +++ b/plugins/TaskIntervalButton/Template/task_add_interval/add_interval_button.php @@ -0,0 +1,5 @@ + +
  • +modal->confirm('clock-o', t('Add time interval'), 'TaskIntervalController', 'confirm', array('plugin' => 'TaskIntervalButton', 'task_id' => $task['id'], 'project_id' => $task['project_id'])) ?> +
  • + diff --git a/plugins/TaskIntervalButton/Template/task_add_interval/add_interval_confirm.php b/plugins/TaskIntervalButton/Template/task_add_interval/add_interval_confirm.php new file mode 100644 index 00000000..21789f77 --- /dev/null +++ b/plugins/TaskIntervalButton/Template/task_add_interval/add_interval_confirm.php @@ -0,0 +1,15 @@ + + +
    +

    + text->e($task['title'])) ?> +

    + + modal->confirmButtons( + 'TaskIntervalController', + 'addInterval', + array('plugin' => 'TaskIntervalButton', 'task_id' => $task['id'], 'project_id' => $task['project_id']) + ) ?> +
    \ No newline at end of file diff --git a/plugins/TaskIntervalButton/Test/PluginTest.php b/plugins/TaskIntervalButton/Test/PluginTest.php new file mode 100644 index 00000000..7640c814 --- /dev/null +++ b/plugins/TaskIntervalButton/Test/PluginTest.php @@ -0,0 +1,20 @@ +container); + $this->assertSame(null, $plugin->initialize()); + $this->assertSame(null, $plugin->onStartup()); + $this->assertNotEmpty($plugin->getPluginName()); + $this->assertNotEmpty($plugin->getPluginDescription()); + $this->assertNotEmpty($plugin->getPluginAuthor()); + $this->assertNotEmpty($plugin->getPluginVersion()); + $this->assertNotEmpty($plugin->getPluginHomepage()); + } +} -- cgit v1.2.3