From 95e7b1498f2c178383699f8d30208cc326b7a37b Mon Sep 17 00:00:00 2001 From: "Dzial Techniczny WMW Projekt s.c" Date: Wed, 15 Jan 2020 16:07:19 +0100 Subject: Displaying internal project ID for tasks --- plugins/InternalID/.gitignore | 1 + plugins/InternalID/.travis.yml | 35 ++++++++++++++ plugins/InternalID/LICENSE | 21 +++++++++ plugins/InternalID/Locale/fr_FR/translations.php | 3 ++ plugins/InternalID/Makefile | 5 ++ plugins/InternalID/Model/InternalTaskIDModel.php | 58 ++++++++++++++++++++++++ plugins/InternalID/Plugin.php | 58 ++++++++++++++++++++++++ plugins/InternalID/README.md | 31 +++++++++++++ plugins/InternalID/Schema/Sqlite.php | 11 +++++ plugins/InternalID/Test/PluginTest.php | 20 ++++++++ 10 files changed, 243 insertions(+) create mode 100644 plugins/InternalID/.gitignore create mode 100644 plugins/InternalID/.travis.yml create mode 100644 plugins/InternalID/LICENSE create mode 100644 plugins/InternalID/Locale/fr_FR/translations.php create mode 100644 plugins/InternalID/Makefile create mode 100644 plugins/InternalID/Model/InternalTaskIDModel.php create mode 100644 plugins/InternalID/Plugin.php create mode 100644 plugins/InternalID/README.md create mode 100644 plugins/InternalID/Schema/Sqlite.php create mode 100644 plugins/InternalID/Test/PluginTest.php (limited to 'plugins/InternalID') diff --git a/plugins/InternalID/.gitignore b/plugins/InternalID/.gitignore new file mode 100644 index 00000000..c4c4ffc6 --- /dev/null +++ b/plugins/InternalID/.gitignore @@ -0,0 +1 @@ +*.zip diff --git a/plugins/InternalID/.travis.yml b/plugins/InternalID/.travis.yml new file mode 100644 index 00000000..9753d0b6 --- /dev/null +++ b/plugins/InternalID/.travis.yml @@ -0,0 +1,35 @@ +language: php +sudo: false + +php: + - 7.1 + - 7.0 + - 5.6 + - 5.5 + - 5.4 + - 5.3 + +env: + global: + - PLUGIN=InternalID + - KANBOARD_REPO=https://github.com/kanboard/kanboard.git + matrix: + - DB=sqlite + - DB=mysql + - DB=postgres + +matrix: + fast_finish: true + +install: + - git clone --depth 1 $KANBOARD_REPO + - ln -s $TRAVIS_BUILD_DIR kanboard/plugins/$PLUGIN + +before_script: + - cd kanboard + - phpenv config-add tests/php.ini + - composer install + - ls -la plugins/ + +script: + - phpunit -c tests/units.$DB.xml plugins/$PLUGIN/Test/ diff --git a/plugins/InternalID/LICENSE b/plugins/InternalID/LICENSE new file mode 100644 index 00000000..f26a989e --- /dev/null +++ b/plugins/InternalID/LICENSE @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) 2020 mkl + +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/InternalID/Locale/fr_FR/translations.php b/plugins/InternalID/Locale/fr_FR/translations.php new file mode 100644 index 00000000..d5be5de2 --- /dev/null +++ b/plugins/InternalID/Locale/fr_FR/translations.php @@ -0,0 +1,3 @@ +db->table($this->getTable())->eq('id', $task_id)->findOne(); + } + +} diff --git a/plugins/InternalID/Plugin.php b/plugins/InternalID/Plugin.php new file mode 100644 index 00000000..02c6adca --- /dev/null +++ b/plugins/InternalID/Plugin.php @@ -0,0 +1,58 @@ +addColumns(Model\InternalTaskIDModel::TABLE.'.internal_task_id') + ->join(Model\InternalTaskIDModel::TABLE, 'id', 'id', $this->taskModel::TABLE); + return $query; + }; + $this->hook->on('task:query:extended', $queryHook); + } + + public function onStartup() + { + Translator::load($this->languageModel->getCurrentLanguage(), __DIR__.'/Locale'); + } + + public function getPluginName() + { + return 'Internal ID'; + } + + public function getPluginDescription() + { + return t('Internal (per-project) task numbers'); + } + + public function getPluginAuthor() + { + return 'mkl'; + } + + public function getPluginVersion() + { + return '1.0.0'; + } + + public function getPluginHomepage() + { + return 'https://kanban.intranet/'; + } + + public function getClasses() { + return array( + 'Plugin\InternalID\Model' => array( + 'InternalTaskIDModel', + ) + ); + } +} diff --git a/plugins/InternalID/README.md b/plugins/InternalID/README.md new file mode 100644 index 00000000..afa0f77c --- /dev/null +++ b/plugins/InternalID/README.md @@ -0,0 +1,31 @@ +Internal ID +============================== + +Internal (per-project) task numbers + +Author +------ + +- mkl +- 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/InternalID` +3. Clone this repository into the folder `plugins/InternalID` + +Note: Plugin folder is case-sensitive. + +Documentation +------------- + +TODO. diff --git a/plugins/InternalID/Schema/Sqlite.php b/plugins/InternalID/Schema/Sqlite.php new file mode 100644 index 00000000..2c1f4f27 --- /dev/null +++ b/plugins/InternalID/Schema/Sqlite.php @@ -0,0 +1,11 @@ +exec('CREATE VIEW task_internal_id AS SELECT COUNT(t1.id) internal_id, t1.id id, t1.project_id project_id FROM tasks t1 JOIN tasks t2 ON t1.id >= t2.id AND t1.project_id = t2.project_id GROUP BY t1.id, t1.project_id;'); + +} diff --git a/plugins/InternalID/Test/PluginTest.php b/plugins/InternalID/Test/PluginTest.php new file mode 100644 index 00000000..973506e7 --- /dev/null +++ b/plugins/InternalID/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