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 | |
parent | 7b66ddf2e4fbdb837e78d8b7dbaa9fc38391bc32 (diff) |
Diffstat (limited to 'plugins/TaskIntervalButton')
10 files changed, 201 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 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 @@ +<?php + +return array();
\ No newline at end of file diff --git a/plugins/TaskIntervalButton/Locale/pl_PL/translations.php b/plugins/TaskIntervalButton/Locale/pl_PL/translations.php new file mode 100644 index 00000000..a880d442 --- /dev/null +++ b/plugins/TaskIntervalButton/Locale/pl_PL/translations.php @@ -0,0 +1,9 @@ +<?php + +return array( + 'Add time interval' => '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 @@ +<?php + +namespace Kanboard\Plugin\TaskIntervalButton; + +use Kanboard\Core\Plugin\Base; +use Kanboard\Core\Translator; +use Kanboard\Core\Security\Role; + +class Plugin extends Base +{ + public function initialize() + { + $this->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 @@ +<?php if ($task['is_active'] == 1): ?> +<li> +<?= $this->modal->confirm('clock-o', t('Add time interval'), 'TaskIntervalController', 'confirm', array('plugin' => 'TaskIntervalButton', 'task_id' => $task['id'], 'project_id' => $task['project_id'])) ?> +</li> +<?php endif ?> 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 @@ +<div class="page-header"> + <h2><?= t('Add interval') ?></h2> +</div> + +<div class="confirm"> + <p class="alert alert-info"> + <?= t('Do you really want to add interval (30 minutes) to this task: "%s"?', $this->text->e($task['title'])) ?> + </p> + + <?= $this->modal->confirmButtons( + 'TaskIntervalController', + 'addInterval', + array('plugin' => 'TaskIntervalButton', 'task_id' => $task['id'], 'project_id' => $task['project_id']) + ) ?> +</div>
\ 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 @@ +<?php + +require_once 'tests/units/Base.php'; + +use Kanboard\Plugin\TaskIntervalButton\Plugin; + +class PluginTest extends Base +{ + public function testPlugin() + { + $plugin = new Plugin($this->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()); + } +} |