summaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
Diffstat (limited to 'plugins')
-rw-r--r--plugins/InternalID/.gitignore1
-rw-r--r--plugins/InternalID/.travis.yml35
-rw-r--r--plugins/InternalID/LICENSE21
-rw-r--r--plugins/InternalID/Locale/fr_FR/translations.php3
-rw-r--r--plugins/InternalID/Makefile5
-rw-r--r--plugins/InternalID/Model/InternalTaskIDModel.php58
-rw-r--r--plugins/InternalID/Plugin.php58
-rw-r--r--plugins/InternalID/README.md31
-rw-r--r--plugins/InternalID/Schema/Sqlite.php11
-rw-r--r--plugins/InternalID/Test/PluginTest.php20
10 files changed, 243 insertions, 0 deletions
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 @@
+<?php
+
+return array();
diff --git a/plugins/InternalID/Makefile b/plugins/InternalID/Makefile
new file mode 100644
index 00000000..1f307581
--- /dev/null
+++ b/plugins/InternalID/Makefile
@@ -0,0 +1,5 @@
+plugin=InternalID
+
+all:
+ @ echo "Build archive for plugin ${plugin} version=${version}"
+ @ git archive HEAD --prefix=${plugin}/ --format=zip -o ${plugin}-${version}.zip
diff --git a/plugins/InternalID/Model/InternalTaskIDModel.php b/plugins/InternalID/Model/InternalTaskIDModel.php
new file mode 100644
index 00000000..55a68192
--- /dev/null
+++ b/plugins/InternalID/Model/InternalTaskIDModel.php
@@ -0,0 +1,58 @@
+<?php
+
+namespace Kanboard\Plugin\InternalID\Model;
+
+use Kanboard\Core\Base;
+
+/**
+ * Internal Task ID Model
+ *
+ * @package InternalID\Model
+ * @author mkl
+ */
+class InternalTaskIDModel extends Base
+{
+ /**
+ * Table name
+ *
+ * @var string
+ */
+ const TABLE = 'internal_task_id';
+
+ /**
+ * Get the table
+ *
+ * @abstract
+ * @access protected
+ * @return string
+ */
+ public function getTable()
+ {
+ return self::TABLE;
+ }
+
+ /**
+ * Define the path prefix
+ *
+ * @abstract
+ * @access protected
+ * @return string
+ */
+ public function getPathPrefix()
+ {
+ return 'internalid';
+ }
+
+ /**
+ * Get by the Task ID
+ *
+ * @access public
+ * @param integer $task_id Task ID (global)
+ * @return array
+ */
+ public function getById($task_id)
+ {
+ return $this->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 @@
+<?php
+
+namespace Kanboard\Plugin\InternalID;
+
+use Kanboard\Core\Plugin\Base;
+use Kanboard\Core\Translator;
+
+class Plugin extends Base
+{
+ public function initialize()
+ {
+ $queryHook = function($query) {
+ $query
+ ->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 @@
+<?php
+
+namespace Kanboard\Plugin\InternalID\Schema;
+
+const VERSION = 1;
+
+function version_1($pdo) {
+
+ $pdo->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 @@
+<?php
+
+require_once 'tests/units/Base.php';
+
+use Kanboard\Plugin\InternalID\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());
+ }
+}