From fcfc232ca7c86a490506e787af1a0d90daf34d56 Mon Sep 17 00:00:00 2001 From: Dennis Eichhorn Date: Wed, 15 Mar 2017 19:48:39 +0100 Subject: [PATCH] Kanban placeholder module --- Admin/Activate.php | 44 ++++++ Admin/Deactivate.php | 44 ++++++ Admin/Install/Navigation.install.json | 18 +++ Admin/Install/Navigation.php | 41 ++++++ Admin/Installer.php | 156 ++++++++++++++++++++++ Admin/Routes/Web/Backend.php | 24 ++++ Admin/Uninstall.php | 45 +++++++ Admin/Update.php | 47 +++++++ Controller.php | 120 +++++++++++++++++ Models/CardType.php | 42 ++++++ Theme/Backend/Lang/Navigation.en.lang.php | 19 +++ Theme/Backend/Lang/en.lang.php | 18 +++ info.json | 45 +++++++ 13 files changed, 663 insertions(+) create mode 100644 Admin/Activate.php create mode 100644 Admin/Deactivate.php create mode 100644 Admin/Install/Navigation.install.json create mode 100644 Admin/Install/Navigation.php create mode 100644 Admin/Installer.php create mode 100644 Admin/Routes/Web/Backend.php create mode 100644 Admin/Uninstall.php create mode 100644 Admin/Update.php create mode 100644 Controller.php create mode 100644 Models/CardType.php create mode 100644 Theme/Backend/Lang/Navigation.en.lang.php create mode 100644 Theme/Backend/Lang/en.lang.php create mode 100644 info.json diff --git a/Admin/Activate.php b/Admin/Activate.php new file mode 100644 index 0000000..e3e960a --- /dev/null +++ b/Admin/Activate.php @@ -0,0 +1,44 @@ + + * @author Dennis Eichhorn + * @copyright Dennis Eichhorn + * @license OMS License 1.0 + * @version 1.0.0 + * @link http://orange-management.com + */ +declare(strict_types=1); +namespace Modules\Kanban\Admin; + +use phpOMS\DataStorage\Database\DatabasePool; +use phpOMS\Module\ActivateAbstract; +use phpOMS\Module\InfoManager; + +/** + * Navigation class. + * + * @category Modules + * @package Modules\Admin + * @author OMS Development Team + * @author Dennis Eichhorn + * @license OMS License 1.0 + * @link http://orange-management.com + * @since 1.0.0 + */ +class Activate extends ActivateAbstract +{ + + /** + * {@inheritdoc} + */ + public static function activate(DatabasePool $dbPool, InfoManager $info) + { + parent::activate($dbPool, $info); + } +} diff --git a/Admin/Deactivate.php b/Admin/Deactivate.php new file mode 100644 index 0000000..f894507 --- /dev/null +++ b/Admin/Deactivate.php @@ -0,0 +1,44 @@ + + * @author Dennis Eichhorn + * @copyright Dennis Eichhorn + * @license OMS License 1.0 + * @version 1.0.0 + * @link http://orange-management.com + */ +declare(strict_types=1); +namespace Modules\Kanban\Admin; + +use phpOMS\DataStorage\Database\DatabasePool; +use phpOMS\Module\DeactivateAbstract; +use phpOMS\Module\InfoManager; + +/** + * Navigation class. + * + * @category Modules + * @package Modules\Admin + * @author OMS Development Team + * @author Dennis Eichhorn + * @license OMS License 1.0 + * @link http://orange-management.com + * @since 1.0.0 + */ +class Deactivate extends DeactivateAbstract +{ + + /** + * {@inheritdoc} + */ + public static function deactivate(DatabasePool $dbPool, InfoManager $info) + { + parent::deactivate($dbPool, $info); + } +} diff --git a/Admin/Install/Navigation.install.json b/Admin/Install/Navigation.install.json new file mode 100644 index 0000000..277ddd4 --- /dev/null +++ b/Admin/Install/Navigation.install.json @@ -0,0 +1,18 @@ +[ + { + "id": 1005801001, + "pid": "754a08ddf8bcb1cf22f310f09206dd783d42f7dd", + "type": 2, + "subtype": 1, + "name": "Kanban", + "uri": "/{/lang}/backend/kanban/dashboard?{?}", + "target": "self", + "icon": null, + "order": 45, + "from": "Kanban", + "permission": null, + "parent": 1000101001, + "children": [ + ] + } +] diff --git a/Admin/Install/Navigation.php b/Admin/Install/Navigation.php new file mode 100644 index 0000000..edf8e1e --- /dev/null +++ b/Admin/Install/Navigation.php @@ -0,0 +1,41 @@ + + * @author Dennis Eichhorn + * @copyright Dennis Eichhorn + * @license OMS License 1.0 + * @version 1.0.0 + * @link http://orange-management.com + */ +declare(strict_types=1); +namespace Modules\Kanban\Admin\Install; +use phpOMS\DataStorage\Database\DatabasePool; + +/** + * Navigation class. + * + * @category Modules + * @package Modules\Kanban + * @author OMS Development Team + * @author Dennis Eichhorn + * @license OMS License 1.0 + * @link http://orange-management.com + * @since 1.0.0 + */ +class Navigation +{ + public static function install(string $path, DatabasePool $dbPool) + { + $navData = json_decode(file_get_contents(__DIR__ . '/Navigation.install.json'), true); + + $class = '\\Modules\\Navigation\\Admin\\Installer'; + /** @var $class \Modules\Navigation\Admin\Installer */ + $class::installExternal($dbPool, $navData); + } +} diff --git a/Admin/Installer.php b/Admin/Installer.php new file mode 100644 index 0000000..7be1e54 --- /dev/null +++ b/Admin/Installer.php @@ -0,0 +1,156 @@ + + * @author Dennis Eichhorn + * @copyright Dennis Eichhorn + * @license OMS License 1.0 + * @version 1.0.0 + * @link http://orange-management.com + */ +declare(strict_types=1); +namespace Modules\Job\Admin; + +use phpOMS\DataStorage\Database\DatabaseType; +use phpOMS\DataStorage\Database\DatabasePool; +use phpOMS\Module\InfoManager; +use phpOMS\Module\InstallerAbstract; + +/** + * Tasks install class. + * + * @category Modules + * @package Modules\Tasks + * @author OMS Development Team + * @author Dennis Eichhorn + * @license OMS License 1.0 + * @link http://orange-management.com + * @since 1.0.0 + */ +class Installer extends InstallerAbstract +{ + + /** + * {@inheritdoc} + */ + public static function install(string $path, DatabasePool $dbPool, InfoManager $info) + { + parent::install($path, $dbPool, $info); + + switch ($dbPool->get('core')->getType()) { + case DatabaseType::MYSQL: + $dbPool->get('core')->con->prepare( + 'CREATE TABLE if NOT EXISTS `' . $dbPool->get('core')->prefix . 'kanban_board` ( + `kanban_board_id` int(11) NOT NULL AUTO_INCREMENT, + `kanban_board_name` varchar(50) NOT NULL, + `kanban_board_status` int(11) NOT NULL, + `kanban_board_desc` varchar(100) DEFAULT NULL, + `kanban_board_created_at` datetime DEFAULT NULL, + `kanban_board_created_by` int(11) DEFAULT NULL, + PRIMARY KEY (`kanban_board_id`), + KEY `kanban_board_created_by` (`kanban_board_created_by`) + )ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1;' + )->execute(); + + $dbPool->get('core')->con->prepare( + 'CREATE TABLE if NOT EXISTS `' . $dbPool->get('core')->prefix . 'kanban_column` ( + `kanban_column_id` int(11) NOT NULL AUTO_INCREMENT, + `kanban_column_name` varchar(50) NOT NULL, + `kanban_column_order` int(11) NOT NULL, + `kanban_column_board` int(11) NOT NULL, + PRIMARY KEY (`kanban_column_id`), + KEY `kanban_column_board` (`kanban_column_board`) + )ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1;' + )->execute(); + + $dbPool->get('core')->con->prepare( + 'CREATE TABLE if NOT EXISTS `' . $dbPool->get('core')->prefix . 'kanban_card` ( + `kanban_card_id` int(11) NOT NULL AUTO_INCREMENT, + `kanban_card_name` varchar(50) NOT NULL, + `kanban_card_description` text NOT NULL, + `kanban_card_type` int(2) NOT NULL, + `kanban_card_status` int(2) NOT NULL, + `kanban_card_ref` int(11) NOT NULL, + `kanban_card_column` int(11) NOT NULL, + `kanban_card_media` int(11) NOT NULL, + `kanban_card_created_at` datetime DEFAULT NULL, + `kanban_card_created_by` int(11) DEFAULT NULL, + PRIMARY KEY (`kanban_card_id`), + KEY `kanban_card_column` (`kanban_card_column`), + KEY `kanban_card_created_by` (`kanban_card_created_by`), + KEY `kanban_card_media` (`kanban_card_created_by`) + )ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1;' + )->execute(); + + // Task comments and these comments need to be merged which is bad but not every kanban card is a task and task info should be here as well. + $dbPool->get('core')->con->prepare( + 'CREATE TABLE if NOT EXISTS `' . $dbPool->get('core')->prefix . 'kanban_card_comment` ( + `kanban_card_comment_id` int(11) NOT NULL AUTO_INCREMENT, + `kanban_card_comment_description` text NOT NULL, + `kanban_card_comment_created_at` datetime DEFAULT NULL, + `kanban_card_comment_created_by` int(11) DEFAULT NULL, + `kanban_card_comment_media` int(11) DEFAULT NULL, + PRIMARY KEY (`kanban_card_comment_id`), + KEY `kanban_card_comment_column` (`kanban_card_comment_column`), + KEY `kanban_card_comment_created_by` (`kanban_card_comment_created_by`), + KEY `kanban_card_comment_media` (`kanban_card_comment_media`) + )ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1;' + )->execute(); + + $dbPool->get('core')->con->prepare( + 'CREATE TABLE if NOT EXISTS `' . $dbPool->get('core')->prefix . 'kanban_activity` ( + `kanban_activity_id` int(11) NOT NULL AUTO_INCREMENT, + `kanban_activity_type` varchar(50) NOT NULL, + `kanban_activity_subtype` int(2) NOT NULL, + `kanban_activity_board` int(11) NOT NULL, + `kanban_activity_old` varchar(255) NOT NULL, + `kanban_activity_new` varchar(255) NOT NULL, + `kanban_activity_by` int(11) DEFAULT NULL, + PRIMARY KEY (`kanban_activity_id`), + KEY `kanban_activity` (`kanban_activity`), + KEY `kanban_activity_by` (`kanban_activity_by`) + )ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1;' + )->execute(); + + $dbPool->get('core')->con->prepare( + 'CREATE TABLE if NOT EXISTS `' . $dbPool->get('core')->prefix . 'kanban_label` ( + `kanban_label_id` int(11) NOT NULL AUTO_INCREMENT, + `kanban_label_name` varchar(50) NOT NULL, + `kanban_label_color` int(11) NOT NULL, + `kanban_label_board` int(11) NOT NULL, + PRIMARY KEY (`kanban_label_id`), + KEY `kanban_label_board` (`kanban_label_board`) + )ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1;' + )->execute(); + + $dbPool->get('core')->con->prepare( + 'CREATE TABLE if NOT EXISTS `' . $dbPool->get('core')->prefix . 'kanban_label_relation` ( + `kanban_label_relation_id` int(11) NOT NULL AUTO_INCREMENT, + `kanban_label_relation_card` int(11) NOT NULL, + `kanban_label_relation_label` int(11) NOT NULL, + PRIMARY KEY (`kanban_label_relation_id`), + KEY `kanban_label_relation_card` (`kanban_label_relation_card`), + KEY `kanban_label_relation_label` (`kanban_label_relation_label`) + )ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1;' + )->execute(); + + $dbPool->get('core')->con->prepare( + 'CREATE TABLE if NOT EXISTS `' . $dbPool->get('core')->prefix . 'kanban_permission` ( + `kanban_permission_id` int(11) NOT NULL AUTO_INCREMENT, + `kanban_permission_permission` int(11) NOT NULL, + `kanban_permission_board` int(11) NOT NULL, + `kanban_permission_account` int(11) NOT NULL, + PRIMARY KEY (`kanban_permission_id`), + KEY `kanban_permission_board` (`kanban_permission_board`), + KEY `kanban_permission_account` (`kanban_permission_account`) + )ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1;' + )->execute(); + break; + } + } +} diff --git a/Admin/Routes/Web/Backend.php b/Admin/Routes/Web/Backend.php new file mode 100644 index 0000000..05f13d3 --- /dev/null +++ b/Admin/Routes/Web/Backend.php @@ -0,0 +1,24 @@ + [ + [ + 'dest' => '\Modules\Kanban\Controller:viewKanbanDashboard', + 'verb' => RouteVerb::GET, + ], + ], + '^.*/backend/kanban/board.*$' => [ + [ + 'dest' => '\Modules\Kanban\Controller:viewKanbanBoard', + 'verb' => RouteVerb::GET, + ], + ], + '^.*/backend/kanban/create.*$' => [ + [ + 'dest' => '\Modules\Kanban\Controller:viewKanbanCreate', + 'verb' => RouteVerb::GET, + ], + ], +]; diff --git a/Admin/Uninstall.php b/Admin/Uninstall.php new file mode 100644 index 0000000..b08ec64 --- /dev/null +++ b/Admin/Uninstall.php @@ -0,0 +1,45 @@ + + * @author Dennis Eichhorn + * @copyright Dennis Eichhorn + * @license OMS License 1.0 + * @version 1.0.0 + * @link http://orange-management.com + */ +declare(strict_types=1); +namespace Modules\Kanban\Admin; + +use phpOMS\DataStorage\Database\DatabasePool; +use phpOMS\DataStorage\Database\Schema\Builder; +use phpOMS\Module\InfoManager; +use phpOMS\Module\UninstallAbstract; + +/** + * Navigation class. + * + * @category Modules + * @package Modules\Admin + * @author OMS Development Team + * @author Dennis Eichhorn + * @license OMS License 1.0 + * @link http://orange-management.com + * @since 1.0.0 + */ +class Uninstall extends UninstallAbstract +{ + + /** + * {@inheritdoc} + */ + public static function uninstall(DatabasePool $dbPool, InfoManager $info) + { + parent::uninstall($dbPool, $info); + } +} diff --git a/Admin/Update.php b/Admin/Update.php new file mode 100644 index 0000000..cc3db95 --- /dev/null +++ b/Admin/Update.php @@ -0,0 +1,47 @@ + + * @author Dennis Eichhorn + * @copyright Dennis Eichhorn + * @license OMS License 1.0 + * @version 1.0.0 + * @link http://orange-management.com + */ +declare(strict_types=1); +namespace Modules\Kanban\Admin; + +use phpOMS\DataStorage\Database\DatabasePool; +use phpOMS\Module\InfoManager; +use phpOMS\Module\UpdateAbstract; +use phpOMS\System\File\Directory; + +/** + * Navigation class. + * + * @category Modules + * @package Modules\Admin + * @author OMS Development Team + * @author Dennis Eichhorn + * @license OMS License 1.0 + * @link http://orange-management.com + * @since 1.0.0 + */ +class Update extends UpdateAbstract +{ + + /** + * {@inheritdoc} + */ + public static function update(DatabasePool $dbPool, InfoManager $info) + { + Directory::deletePath(__DIR__ . '/Update'); + mkdir('Update'); + parent::update($dbPool, $info); + } +} diff --git a/Controller.php b/Controller.php new file mode 100644 index 0000000..8172508 --- /dev/null +++ b/Controller.php @@ -0,0 +1,120 @@ + + * @author Dennis Eichhorn + * @copyright Dennis Eichhorn + * @license OMS License 1.0 + * @version 1.0.0 + * @link http://orange-management.com + */ +declare(strict_types=1); +namespace Modules\Kanban; + +use phpOMS\Message\RequestAbstract; +use phpOMS\Message\ResponseAbstract; +use phpOMS\Module\ModuleAbstract; +use phpOMS\Module\WebInterface; +use phpOMS\Views\View; +use phpOMS\Utils\TaskSchedule\SchedulerFactory; +use phpOMS\Utils\TaskSchedule\SchedulerAbstract; + +/** + * Task class. + * + * @category Modules + * @package Modules\Kanban + * @author OMS Development Team + * @author Dennis Eichhorn + * @license OMS License 1.0 + * @link http://orange-management.com + * @since 1.0.0 + */ +class Controller extends ModuleAbstract implements WebInterface +{ + + /** + * Module path. + * + * @var string + * @since 1.0.0 + */ + /* public */ const MODULE_PATH = __DIR__; + + /** + * Module version. + * + * @var string + * @since 1.0.0 + */ + /* public */ const MODULE_VERSION = '1.0.0'; + + /** + * Module name. + * + * @var string + * @since 1.0.0 + */ + /* public */ const MODULE_NAME = 'Kanban'; + + /** + * Providing. + * + * @var string + * @since 1.0.0 + */ + protected static $providing = []; + + /** + * Dependencies. + * + * @var string + * @since 1.0.0 + */ + protected static $dependencies = [ + ]; + + /** + * @param RequestAbstract $request Request + * @param ResponseAbstract $response Response + * @param mixed $data Generic data + * + * @return \Serializable + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ + public function viewKanbanDashboard(RequestAbstract $request, ResponseAbstract $response, $data = null) : \Serializable + { + $view = new View($this->app, $request, $response); + $view->setTemplate('/Modules/Kanban/Theme/Backend/kanban-dashboard'); + $view->addData('nav', $this->app->moduleManager->get('Navigation')->createNavigationMid(1005801001, $request, $response)); + + return $view; + } + + /** + * @param RequestAbstract $request Request + * @param ResponseAbstract $response Response + * @param mixed $data Generic data + * + * @return \Serializable + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ + public function viewKanbanBoard(RequestAbstract $request, ResponseAbstract $response, $data = null) : \Serializable + { + $view = new View($this->app, $request, $response); + $view->setTemplate('/Modules/Kanban/Theme/Backend/kanban-board'); + $view->addData('nav', $this->app->moduleManager->get('Navigation')->createNavigationMid(1005801001, $request, $response)); + + return $view; + } + +} diff --git a/Models/CardType.php b/Models/CardType.php new file mode 100644 index 0000000..10c79ab --- /dev/null +++ b/Models/CardType.php @@ -0,0 +1,42 @@ + + * @author Dennis Eichhorn + * @copyright Dennis Eichhorn + * @license OMS License 1.0 + * @version 1.0.0 + * @link http://orange-management.com + */ +declare(strict_types=1); + +namespace Modules\Kanban\Models; + +use phpOMS\Datatypes\Enum; + +/** + * Area type enum. + * + * @category Framework + * @package phpOMS\Utils\Converter + * @author OMS Development Team + * @author Dennis Eichhorn + * @license OMS License 1.0 + * @link http://orange-management.com + * @since 1.0.0 + */ +abstract class CardType extends Enum +{ + /* public */ const TEXT = 1; /* Markdown -> Image, links, charts etc */ + /* public */ const CALENDAR = 2; + /* public */ const CALENDAR_EVENT = 4; + /* public */ const TASK = 8; + /* public */ const TASK_CHECKLIST = 16; + /* public */ const MEDIA = 32; + /* public */ const SURVEY = 64; +} \ No newline at end of file diff --git a/Theme/Backend/Lang/Navigation.en.lang.php b/Theme/Backend/Lang/Navigation.en.lang.php new file mode 100644 index 0000000..89bf8d1 --- /dev/null +++ b/Theme/Backend/Lang/Navigation.en.lang.php @@ -0,0 +1,19 @@ + + * @author Dennis Eichhorn + * @copyright Dennis Eichhorn + * @license OMS License 1.0 + * @version 1.0.0 + * @link http://orange-management.com + */ +return ['Navigation' => [ + 'Kanban' => 'Kanban', + 'Create' => 'Create', +]]; diff --git a/Theme/Backend/Lang/en.lang.php b/Theme/Backend/Lang/en.lang.php new file mode 100644 index 0000000..a37d23b --- /dev/null +++ b/Theme/Backend/Lang/en.lang.php @@ -0,0 +1,18 @@ + + * @author Dennis Eichhorn + * @copyright Dennis Eichhorn + * @license OMS License 1.0 + * @version 1.0.0 + * @link http://orange-management.com + */ +return ['Kanban' => [ + 'Dashboard' => 'Dashboard', +]]; diff --git a/info.json b/info.json new file mode 100644 index 0000000..9055e7f --- /dev/null +++ b/info.json @@ -0,0 +1,45 @@ +{ + "name": { + "id": 1005800000, + "internal": "Kanban", + "external": "Kanban" + }, + "category": "Tools", + "version": "1.0.0", + "requirements": { + "phpOMS": "1.0.0", + "phpOMS-db": "1.0.0" + }, + "creator": { + "name": "Orange Management", + "website": "www.spl1nes.com" + }, + "description": "Kanban module.", + "directory": "Kanban", + "dependencies": { + "Admin" : "1.0.0" + }, + "providing": { + "Navigation": "*" + }, + "load": [ + { + "pid": [ + "7322d5765c8b18b14c20d406e89c628fd0998688" + ], + "type": 4, + "for": 0, + "from": "Kanban", + "file": "Kanban" + }, + { + "pid": [ + "754a08ddf8bcb1cf22f310f09206dd783d42f7dd" + ], + "type": 5, + "from": "Kanban", + "for": "Navigation", + "file": "Navigation" + } + ] +}