From 4a82abe27c8ea3f417bdb091f94f189395a53be1 Mon Sep 17 00:00:00 2001 From: Dennis Eichhorn Date: Mon, 20 Mar 2017 20:21:24 +0100 Subject: [PATCH] Kowledgebase draft --- Admin/Activate.php | 44 ++++++ Admin/Deactivate.php | 44 ++++++ Admin/Install/Navigation.install.json | 18 +++ Admin/Install/Navigation.php | 41 +++++ Admin/Installer.php | 111 ++++++++++++++ Admin/Routes/Web/Backend.php | 30 ++++ Admin/Uninstall.php | 45 ++++++ Admin/Update.php | 47 ++++++ Controller.php | 80 ++++++++++ Models/WikiBadge.php | 60 ++++++++ Models/WikiBadgeMapper.php | 111 ++++++++++++++ Models/WikiCategory.php | 72 +++++++++ Models/WikiCategoryMapper.php | 112 ++++++++++++++ Models/WikiDoc.php | 139 +++++++++++++++++ Models/WikiDocMapper.php | 173 ++++++++++++++++++++++ Models/WikiStatus.php | 39 +++++ Theme/Backend/Lang/Navigation.en.lang.php | 18 +++ Theme/Backend/Lang/en.lang.php | 18 +++ Theme/Backend/wiki-dashboard.tpl.php | 0 info.json | 47 ++++++ 20 files changed, 1249 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/WikiBadge.php create mode 100644 Models/WikiBadgeMapper.php create mode 100644 Models/WikiCategory.php create mode 100644 Models/WikiCategoryMapper.php create mode 100644 Models/WikiDoc.php create mode 100644 Models/WikiDocMapper.php create mode 100644 Models/WikiStatus.php create mode 100644 Theme/Backend/Lang/Navigation.en.lang.php create mode 100644 Theme/Backend/Lang/en.lang.php create mode 100644 Theme/Backend/wiki-dashboard.tpl.php create mode 100644 info.json diff --git a/Admin/Activate.php b/Admin/Activate.php new file mode 100644 index 0000000..8ac88fa --- /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\Knowledgebase\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..b4991fb --- /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\Knowledgebase\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..63da67f --- /dev/null +++ b/Admin/Install/Navigation.install.json @@ -0,0 +1,18 @@ +[ + { + "id": 1005901001, + "pid": "754a08ddf8bcb1cf22f310f09206dd783d42f7dd", + "type": 2, + "subtype": 1, + "name": "Wiki", + "uri": "/{/lang}/backend/knowledgebase/dashboard?{?}", + "target": "self", + "icon": null, + "order": 50, + "from": "Knowledgebase", + "permission": null, + "parent": 1003301001, + "children": [ + ] + } +] diff --git a/Admin/Install/Navigation.php b/Admin/Install/Navigation.php new file mode 100644 index 0000000..ba42044 --- /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\Knowledgebase\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..4ff0573 --- /dev/null +++ b/Admin/Installer.php @@ -0,0 +1,111 @@ + + * @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\Knowledgebase\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 . 'wiki_category` ( + `wiki_category_id` int(11) NOT NULL AUTO_INCREMENT, + `wiki_category_name` varchar(255) NOT NULL, + `wiki_category_parent` int(11) DEFAULT NULL, + PRIMARY KEY (`wiki_category_id`), + KEY `wiki_category_parent` (`wiki_category_parent`) + )ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1;' + )->execute(); + + $dbPool->get('core')->con->prepare( + 'ALTER TABLE `' . $dbPool->get('core')->prefix . 'wiki_category` + ADD CONSTRAINT `' . $dbPool->get('core')->prefix . 'wiki_category_ibfk_1` FOREIGN KEY (`wiki_category_parent`) REFERENCES `' . $dbPool->get('core')->prefix . 'wiki_category` (`wiki_category_id`)' + )->execute(); + + $dbPool->get('core')->con->prepare( + 'CREATE TABLE if NOT EXISTS `' . $dbPool->get('core')->prefix . 'wiki_badge` ( + `wiki_badge_id` int(11) NOT NULL AUTO_INCREMENT, + `wiki_badge_name` varchar(255) NOT NULL, + PRIMARY KEY (`wiki_category_id`) + )ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1;' + )->execute(); + + $dbPool->get('core')->con->prepare( + 'CREATE TABLE if NOT EXISTS `' . $dbPool->get('core')->prefix . 'wiki_article` ( + `wiki_article_id` int(11) NOT NULL AUTO_INCREMENT, + `wiki_article_status` int(11) NOT NULL, + `wiki_article_title` varchar(255) NOT NULL, + `wiki_article_language` varchar(3) NOT NULL, + `wiki_article_doc` text NOT NULL, + `wiki_article_created_by` int(11) NOT NULL, + `wiki_article_created_at` datetime NOT NULL, + `wiki_article_category` int(11) DEFAULT NULL, + PRIMARY KEY (`wiki_article_id`), + KEY `wiki_article_created_by` (`wiki_article_created_by`), + KEY `wiki_article_category` (`wiki_article_category`) + )ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1;' + )->execute(); + + $dbPool->get('core')->con->prepare( + 'ALTER TABLE `' . $dbPool->get('core')->prefix . 'wiki_article` + ADD CONSTRAINT `' . $dbPool->get('core')->prefix . 'wiki_article_ibfk_1` FOREIGN KEY (`wiki_article_created_by`) REFERENCES `' . $dbPool->get('core')->prefix . 'account` (`account_id`), + ADD CONSTRAINT `' . $dbPool->get('core')->prefix . 'wiki_article_ibfk_2` FOREIGN KEY (`wiki_article_category`) REFERENCES `' . $dbPool->get('core')->prefix . 'wiki_category` (`wiki_category_id`);' + )->execute(); + + $dbPool->get('core')->con->prepare( + 'CREATE TABLE if NOT EXISTS `' . $dbPool->get('core')->prefix . 'wiki_article_badge` ( + `wiki_article_badge_id` int(11) NOT NULL AUTO_INCREMENT, + `wiki_article_badge_article` varchar(255) NOT NULL, + `wiki_article_badge_badge` int(11) DEFAULT NULL, + PRIMARY KEY (`wiki_category_id`), + KEY `wiki_article_badge_article` (`wiki_article_badge_article`), + KEY `wiki_article_badge_badge` (`wiki_article_badge_badge`) + )ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1;' + )->execute(); + + $dbPool->get('core')->con->prepare( + 'ALTER TABLE `' . $dbPool->get('core')->prefix . 'wiki_article_badge` + ADD CONSTRAINT `' . $dbPool->get('core')->prefix . 'wiki_article_badge_ibfk_1` FOREIGN KEY (`wiki_article_badge_article`) REFERENCES `' . $dbPool->get('core')->prefix . 'wiki_article` (`wiki_article_id`), + ADD CONSTRAINT `' . $dbPool->get('core')->prefix . 'wiki_article_badge_ibfk_2` FOREIGN KEY (`wiki_article_badge_badge`) REFERENCES `' . $dbPool->get('core')->prefix . 'wiki_badge` (`wiki_badge_id`)' + )->execute(); + break; + } + } +} diff --git a/Admin/Routes/Web/Backend.php b/Admin/Routes/Web/Backend.php new file mode 100644 index 0000000..52d2e6d --- /dev/null +++ b/Admin/Routes/Web/Backend.php @@ -0,0 +1,30 @@ + [ + [ + 'dest' => '\Modules\Knowledgebase\Controller:viewKnowledgebaseDashboard', + 'verb' => RouteVerb::GET, + ], + ], + '^.*/backend/wiki/category.*$' => [ + [ + 'dest' => '\Modules\Knowledgebase\Controller:viewKnowledgebaseCategory', + 'verb' => RouteVerb::GET, + ], + ], + '^.*/backend/wiki/doc.*$' => [ + [ + 'dest' => '\Modules\Knowledgebase\Controller:viewKnowledgebaseDoc', + 'verb' => RouteVerb::GET, + ], + ], + '^.*/backend/wiki/create.*$' => [ + [ + 'dest' => '\Modules\Knowledgebase\Controller:viewKnowledgebaseCreate', + 'verb' => RouteVerb::GET, + ], + ], +]; diff --git a/Admin/Uninstall.php b/Admin/Uninstall.php new file mode 100644 index 0000000..c067b61 --- /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\Knowledgebase\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..6131548 --- /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\Knowledgebase\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..d134161 --- /dev/null +++ b/Controller.php @@ -0,0 +1,80 @@ + + * @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\Knowledgebase; + +use phpOMS\Message\RequestAbstract; +use phpOMS\Message\ResponseAbstract; +use phpOMS\Module\ModuleAbstract; +use phpOMS\Module\WebInterface; +use phpOMS\Views\View; + +/** + * Task class. + * + * @category Modules + * @package Modules\Knowledgebase + * @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 = 'Knowledgebase'; + + /** + * Providing. + * + * @var string + * @since 1.0.0 + */ + protected static $providing = []; + + /** + * Dependencies. + * + * @var string + * @since 1.0.0 + */ + protected static $dependencies = [ + ]; + +} diff --git a/Models/WikiBadge.php b/Models/WikiBadge.php new file mode 100644 index 0000000..33f03a1 --- /dev/null +++ b/Models/WikiBadge.php @@ -0,0 +1,60 @@ + + * @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\Knowledgebase\Models; + +/** + * Task class. + * + * @category Kanban + * @package Modules + * @author OMS Development Team + * @author Dennis Eichhorn + * @license OMS License 1.0 + * @link http://orange-management.com + * @since 1.0.0 + */ +class WikiBadge implements \JsonSerializable +{ + private $id = 0; + + private $name = ''; + + public function __construct() + { + $this->createdAt = new \DateTime('now'); + } + + public function getId() : int + { + return $this->id; + } + + public function getName() : string + { + return $this->name; + } + + public function setName(string $name) /* : void */ + { + $this->name = $name; + } + + public function jsonSerialize() : array + { + return []; + } +} \ No newline at end of file diff --git a/Models/WikiBadgeMapper.php b/Models/WikiBadgeMapper.php new file mode 100644 index 0000000..d456740 --- /dev/null +++ b/Models/WikiBadgeMapper.php @@ -0,0 +1,111 @@ + + * @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\Knowledgebase\Models; + +use phpOMS\DataStorage\Database\DataMapperAbstract; +use phpOMS\DataStorage\Database\Query\Builder; +use phpOMS\DataStorage\Database\Query\Column; +use phpOMS\DataStorage\Database\RelationType; + +/** + * Mapper class. + * + * @category Knowledgebase + * @package Modules + * @author OMS Development Team + * @author Dennis Eichhorn + * @license OMS License 1.0 + * @link http://orange-management.com + * @since 1.0.0 + */ +class WikiBadgeMapper extends DataMapperAbstract +{ + + /** + * Columns. + * + * @var array + * @since 1.0.0 + */ + protected static $columns = [ + 'wiki_badge_id' => ['name' => 'wiki_badge_id', 'type' => 'int', 'internal' => 'id'], + 'wiki_badge_name' => ['name' => 'wiki_badge_name', 'type' => 'string', 'internal' => 'name'], + ]; + + /** + * Primary table. + * + * @var string + * @since 1.0.0 + */ + protected static $table = 'wiki_badge'; + + /** + * Primary field name. + * + * @var string + * @since 1.0.0 + */ + protected static $primaryField = 'wiki_badge_id'; + + /** + * Create object. + * + * @param mixed $obj Object + * @param int $relations Behavior for relations creation + * + * @return mixed + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ + public static function create($obj, int $relations = RelationType::ALL) + { + try { + $objId = parent::create($obj, $relations); + + if($objId === null || !is_scalar($objId)) { + return $objId; + } + } catch (\Exception $e) { + var_dump($e->getMessage()); + + return false; + } + + return $objId; + } + + /** + * Find. + * + * @param array $columns Columns to select + * + * @return Builder + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ + public static function find(...$columns) : Builder + { + return parent::find(...$columns)->from('account_permission') + ->where('account_permission.account_permission_for', '=', 'task') + ->where('account_permission.account_permission_id1', '=', 1) + ->where('task.task_id', '=', new Column('account_permission.account_permission_id2')) + ->where('account_permission.account_permission_r', '=', 1); + } +} diff --git a/Models/WikiCategory.php b/Models/WikiCategory.php new file mode 100644 index 0000000..d201bbb --- /dev/null +++ b/Models/WikiCategory.php @@ -0,0 +1,72 @@ + + * @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\Knowledgebase\Models; + +/** + * Task class. + * + * @category Kanban + * @package Modules + * @author OMS Development Team + * @author Dennis Eichhorn + * @license OMS License 1.0 + * @link http://orange-management.com + * @since 1.0.0 + */ +class WikiCategory implements \JsonSerializable +{ + private $id = 0; + + private $name = ''; + + private $parent = 0; + + public function __construct() + { + $this->createdAt = new \DateTime('now'); + } + + public function getId() : int + { + return $this->id; + } + + public function getName() : string + { + return $this->name; + } + + public function setName(string $name) /* : void */ + { + $this->name = $name; + } + + public function getParent() : int + { + return $this->parent; + } + + public function setParent(int $parent) /* : void */ + { + $this->parent = $parent; + } + + public function jsonSerialize() : array + { + return []; + } +} \ No newline at end of file diff --git a/Models/WikiCategoryMapper.php b/Models/WikiCategoryMapper.php new file mode 100644 index 0000000..ef036b3 --- /dev/null +++ b/Models/WikiCategoryMapper.php @@ -0,0 +1,112 @@ + + * @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\Knowledgebase\Models; + +use phpOMS\DataStorage\Database\DataMapperAbstract; +use phpOMS\DataStorage\Database\Query\Builder; +use phpOMS\DataStorage\Database\Query\Column; +use phpOMS\DataStorage\Database\RelationType; + +/** + * Mapper class. + * + * @category Tasks + * @package Modules + * @author OMS Development Team + * @author Dennis Eichhorn + * @license OMS License 1.0 + * @link http://orange-management.com + * @since 1.0.0 + */ +class WikiCategoryMapper extends DataMapperAbstract +{ + + /** + * Columns. + * + * @var array + * @since 1.0.0 + */ + protected static $columns = [ + 'wiki_category_id' => ['name' => 'wiki_category_id', 'type' => 'int', 'internal' => 'id'], + 'wiki_category_name' => ['name' => 'wiki_category_name', 'type' => 'string', 'internal' => 'name'], + 'wiki_category_parent' => ['name' => 'wiki_category_parent', 'type' => 'int', 'internal' => 'parent'], + ]; + + /** + * Primary table. + * + * @var string + * @since 1.0.0 + */ + protected static $table = 'wiki_category'; + + /** + * Primary field name. + * + * @var string + * @since 1.0.0 + */ + protected static $primaryField = 'wiki_category_id'; + + /** + * Create object. + * + * @param mixed $obj Object + * @param int $relations Behavior for relations creation + * + * @return mixed + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ + public static function create($obj, int $relations = RelationType::ALL) + { + try { + $objId = parent::create($obj, $relations); + + if($objId === null || !is_scalar($objId)) { + return $objId; + } + } catch (\Exception $e) { + var_dump($e->getMessage()); + + return false; + } + + return $objId; + } + + /** + * Find. + * + * @param array $columns Columns to select + * + * @return Builder + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ + public static function find(...$columns) : Builder + { + return parent::find(...$columns)->from('account_permission') + ->where('account_permission.account_permission_for', '=', 'task') + ->where('account_permission.account_permission_id1', '=', 1) + ->where('task.task_id', '=', new Column('account_permission.account_permission_id2')) + ->where('account_permission.account_permission_r', '=', 1); + } +} diff --git a/Models/WikiDoc.php b/Models/WikiDoc.php new file mode 100644 index 0000000..392ec63 --- /dev/null +++ b/Models/WikiDoc.php @@ -0,0 +1,139 @@ + + * @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\Knowledgebase\Models; + +/** + * Task class. + * + * @category Kanban + * @package Modules + * @author OMS Development Team + * @author Dennis Eichhorn + * @license OMS License 1.0 + * @link http://orange-management.com + * @since 1.0.0 + */ +class WikiDoc implements \JsonSerializable +{ + private $id = 0; + + private $name = ''; + + private $status = WikiStatus::ACTIVE; + + private $doc = ''; + + private $category = 0; + + private $language = ''; + + private $createdBy = 0; + + private $createdAt = null; + + private $badges = []; + + public function __construct() + { + $this->createdAt = new \DateTime('now'); + } + + public function getId() : int + { + return $this->id; + } + + public function getLanguage() : string + { + return $this->language; + } + + public function setLanguage(string $language) /* : void */ + { + $this->language = $language; + } + + public function getName() : string + { + return $this->name; + } + + public function setName(string $name) /* : void */ + { + $this->name = $name; + } + + public function getDoc() : string + { + return $this->doc; + } + + public function setDoc(string $doc) /* : void */ + { + $this->doc = $doc; + } + + public function getStatus() : int + { + return $this->status; + } + + public function setStatus(int $status) /* : void */ + { + $this->status = $status; + } + + public function getCategory() : int + { + return $this->category; + } + + public function setCategory(int $category) /* : void */ + { + $this->category = $category; + } + + public function getCreatedBy() : int + { + return $this->createdBy; + } + + public function setCreatedBy(int $id) /* : void */ + { + $this->createdBy = $id; + } + + public function getCreatedAt() : \DateTime + { + return $this->createdAt; + } + + public function getBadges() : array + { + return $this->badges; + } + + public function addBadge($badge) /* : void */ + { + $this->badges[] = $badge; + } + + public function jsonSerialize() : array + { + return []; + } +} \ No newline at end of file diff --git a/Models/WikiDocMapper.php b/Models/WikiDocMapper.php new file mode 100644 index 0000000..07ce429 --- /dev/null +++ b/Models/WikiDocMapper.php @@ -0,0 +1,173 @@ + + * @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\Knowledgebase\Models; + +use phpOMS\DataStorage\Database\DataMapperAbstract; +use phpOMS\DataStorage\Database\Query\Builder; +use phpOMS\DataStorage\Database\Query\Column; +use phpOMS\DataStorage\Database\RelationType; + +/** + * Mapper class. + * + * @category Tasks + * @package Modules + * @author OMS Development Team + * @author Dennis Eichhorn + * @license OMS License 1.0 + * @link http://orange-management.com + * @since 1.0.0 + */ +class WikiDocMapper extends DataMapperAbstract +{ + + /** + * Columns. + * + * @var array + * @since 1.0.0 + */ + protected static $columns = [ + 'wiki_article_id' => ['name' => 'wiki_article_id', 'type' => 'int', 'internal' => 'id'], + 'wiki_article_title' => ['name' => 'wiki_article_title', 'type' => 'string', 'internal' => 'name'], + 'wiki_article_language' => ['name' => 'wiki_article_language', 'type' => 'string', 'internal' => 'language'], + 'wiki_article_doc' => ['name' => 'wiki_article_doc', 'type' => 'string', 'internal' => 'doc'], + 'wiki_article_status' => ['name' => 'wiki_article_status', 'type' => 'int', 'internal' => 'status'], + 'wiki_article_category' => ['name' => 'wiki_article_category', 'type' => 'int', 'internal' => 'category'], + 'wiki_article_created_by' => ['name' => 'wiki_article_created_by', 'type' => 'int', 'internal' => 'createdBy'], + 'wiki_article_created_at' => ['name' => 'wiki_article_created_at', 'type' => 'DateTime', 'internal' => 'createdAt'], + ]; + + /** + * Has many relation. + * + * @var array + * @since 1.0.0 + */ + protected static $hasMany = [ + 'badges' => [ + 'mapper' => WikiBadgeMapper::class, + 'table' => 'wiki_article_badge', + 'dst' => 'wiki_article_badge_badge', + 'src' => 'wiki_article_badge_article', + ], + ]; + + /** + * Has many relation. + * + * @var array + * @since 1.0.0 + */ + protected static $ownsOne = [ + 'category' => [ + 'mapper' => WikiCategoryMapper::class, + 'dst' => 'wiki_article_category', + ], + ]; + + /** + * Primary table. + * + * @var string + * @since 1.0.0 + */ + protected static $table = 'wiki_article'; + + /** + * Created at. + * + * @var string + * @since 1.0.0 + */ + protected static $createdAt = 'wiki_article_created_at'; + + /** + * Primary field name. + * + * @var string + * @since 1.0.0 + */ + protected static $primaryField = 'wiki_article_id'; + + /** + * Create object. + * + * @param mixed $obj Object + * @param int $relations Behavior for relations creation + * + * @return mixed + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ + public static function create($obj, int $relations = RelationType::ALL) + { + try { + $objId = parent::create($obj, $relations); + + if($objId === null || !is_scalar($objId)) { + return $objId; + } + + $query = new Builder(self::$db); + + $query->prefix(self::$db->getPrefix()) + ->insert( + 'account_permission_account', + 'account_permission_from', + 'account_permission_for', + 'account_permission_id1', + 'account_permission_id2', + 'account_permission_r', + 'account_permission_w', + 'account_permission_m', + 'account_permission_d', + 'account_permission_p' + ) + ->into('account_permission') + ->values($obj->getCreatedBy(), 'task', 'task', 1, $objId, 1, 1, 1, 1, 1); + + self::$db->con->prepare($query->toSql())->execute(); + } catch (\Exception $e) { + var_dump($e->getMessage()); + + return false; + } + + return $objId; + } + + /** + * Find. + * + * @param array $columns Columns to select + * + * @return Builder + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ + public static function find(...$columns) : Builder + { + return parent::find(...$columns)->from('account_permission') + ->where('account_permission.account_permission_for', '=', 'task') + ->where('account_permission.account_permission_id1', '=', 1) + ->where('task.task_id', '=', new Column('account_permission.account_permission_id2')) + ->where('account_permission.account_permission_r', '=', 1); + } +} diff --git a/Models/WikiStatus.php b/Models/WikiStatus.php new file mode 100644 index 0000000..110bd98 --- /dev/null +++ b/Models/WikiStatus.php @@ -0,0 +1,39 @@ + + * @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\Knowledgebase\Models; + +use phpOMS\Datatypes\Enum; + +/** + * Task status enum. + * + * @category Knowledgebase + * @package Modules + * @author OMS Development Team + * @author Dennis Eichhorn + * @license OMS License 1.0 + * @link http://orange-management.com + * @since 1.0.0 + */ +abstract class WikiStauts extends Enum +{ + /* public */ const ACTIVE = 1; + + /* public */ const INACTIVE = 2; + + /* public */ const DRAFT = 3; +} diff --git a/Theme/Backend/Lang/Navigation.en.lang.php b/Theme/Backend/Lang/Navigation.en.lang.php new file mode 100644 index 0000000..7fc9627 --- /dev/null +++ b/Theme/Backend/Lang/Navigation.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 ['Navigation' => [ + 'Wiki' => 'Wiki', +]]; diff --git a/Theme/Backend/Lang/en.lang.php b/Theme/Backend/Lang/en.lang.php new file mode 100644 index 0000000..3050c35 --- /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 ['Knowledgebase' => [ + 'Wiki' => 'Wiki', +]]; diff --git a/Theme/Backend/wiki-dashboard.tpl.php b/Theme/Backend/wiki-dashboard.tpl.php new file mode 100644 index 0000000..e69de29 diff --git a/info.json b/info.json new file mode 100644 index 0000000..1494edd --- /dev/null +++ b/info.json @@ -0,0 +1,47 @@ +{ + "name": { + "id": 1005900000, + "internal": "Knowledgebase", + "external": "Knowledgebase" + }, + "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": "Knowledgebase module.", + "directory": "Knowledgebase", + "dependencies": { + "Admin" : "1.0.0", + "Tasks" : "1.0.0", + "Calendar" : "1.0.0" + }, + "providing": { + "Navigation": "*" + }, + "load": [ + { + "pid": [ + "7322d5765c8b18b14c20d406e89c628fd0998688" + ], + "type": 4, + "for": 0, + "from": "Knowledgebase", + "file": "Knowledgebase" + }, + { + "pid": [ + "754a08ddf8bcb1cf22f310f09206dd783d42f7dd" + ], + "type": 5, + "from": "Knowledgebase", + "for": "Navigation", + "file": "Navigation" + } + ] +}