diff --git a/Admin/Activate.php b/Admin/Activate.php new file mode 100644 index 0000000..35d20f3 --- /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 + */ +namespace Modules\Admin\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..7de3621 --- /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 + */ +namespace Modules\Admin\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..6704c84 --- /dev/null +++ b/Admin/Install/Navigation.install.json @@ -0,0 +1,233 @@ +[ + { + "id": 1000101001, + "pid": "754a08ddf8bcb1cf22f310f09206dd783d42f7dd", + "type": 2, + "subtype": 0, + "name": "Admin", + "uri": null, + "target": "self", + "icon": "fa fa-lock", + "order": 1, + "from": "Admin", + "permission": null, + "parent": 0, + "children": [ + { + "id": 1000102001, + "pid": "754a08ddf8bcb1cf22f310f09206dd783d42f7dd", + "type": 2, + "subtype": 1, + "name": "General", + "uri": "/{/lang}/backend/admin/settings/general?{?}", + "target": "self", + "icon": null, + "order": 1, + "from": "Admin", + "permission": null, + "parent": 1000101001, + "children": [] + }, + { + "id": 1000103001, + "pid": "754a08ddf8bcb1cf22f310f09206dd783d42f7dd", + "type": 2, + "subtype": 1, + "name": "Groups", + "uri": "/{/lang}/backend/admin/group/list?{?}", + "target": "self", + "icon": null, + "order": 2, + "from": "Admin", + "permission": null, + "parent": 1000101001, + "children": [ + { + "id": 1000103103, + "pid": "a82970f4c32b56731c03b912cd0ebc161272d088", + "type": 3, + "subtype": 1, + "name": "List", + "uri": "/{/lang}/backend/admin/group/list?{?}", + "target": "self", + "icon": null, + "order": 1, + "from": "Admin", + "permission": null, + "parent": 1000103001, + "children": [] + }, + { + "id": 1000103104, + "pid": "a82970f4c32b56731c03b912cd0ebc161272d088", + "type": 3, + "subtype": 1, + "name": "Create", + "uri": "/{/lang}/backend/admin/group/create?{?}", + "target": "self", + "icon": null, + "order": 5, + "from": "Admin", + "permission": null, + "parent": 1000103001, + "children": [] + }, + { + "id": 1000103201, + "pid": "faf868d821cd23e7e3981cf4270c3880da584027", + "type": 0, + "subtype": 1, + "name": "Front", + "uri": "/{/lang}/backend/admin/group/single/front?{?}", + "target": "self", + "icon": null, + "order": 1, + "from": "Admin", + "permission": null, + "parent": 1000103001, + "children": [ + { + "id": 1000103211, + "pid": "faf868d821cd23e7e3981cf4270c3880da584027", + "type": 3, + "subtype": 1, + "name": "Front", + "uri": "/{/lang}/backend/admin/group/single/front?{?}", + "target": "self", + "icon": null, + "order": 1, + "from": "Admin", + "permission": null, + "parent": 1000103201, + "children": [] + }, + { + "id": 1000103212, + "pid": "faf868d821cd23e7e3981cf4270c3880da584027", + "type": 3, + "subtype": 1, + "name": "Members", + "uri": "/{/lang}/backend/admin/group/single/members?{?}", + "target": "self", + "icon": null, + "order": 2, + "from": "Admin", + "permission": null, + "parent": 1000103201, + "children": [] + } + ] + } + ] + }, + { + "id": 1000104001, + "pid": "754a08ddf8bcb1cf22f310f09206dd783d42f7dd", + "type": 2, + "subtype": 1, + "name": "Accounts", + "uri": "/{/lang}/backend/admin/account/list?{?}", + "target": "self", + "icon": null, + "order": 3, + "from": "Admin", + "permission": null, + "parent": 1000101001, + "children": [ + { + "id": 1000104101, + "pid": "06c40f113551672720d8251eeff5c3a2dbc168c2", + "type": 3, + "subtype": 1, + "name": "List", + "uri": "/{/lang}/backend/admin/account/list?{?}", + "target": "self", + "icon": null, + "order": 1, + "from": "Admin", + "permission": null, + "parent": 1000104001, + "children": [] + }, + { + "id": 1000104202, + "pid": "06c40f113551672720d8251eeff5c3a2dbc168c2", + "type": 3, + "subtype": 1, + "name": "Create", + "uri": "/{/lang}/backend/admin/account/create?{?}", + "target": "self", + "icon": null, + "order": 5, + "from": "Admin", + "permission": null, + "parent": 1000104001, + "children": [] + }, + { + "id": 1000104300, + "pid": "f277f11a122129a52d36f788f42e5c09766cf4ae", + "type": 0, + "subtype": 0, + "name": "Front", + "uri": "/{/lang}/backend/admin/account/single/front?{?}", + "target": "self", + "icon": null, + "order": 3, + "from": "Admin", + "permission": null, + "parent": 1000104001, + "children": [ + { + "id": 1000104301, + "pid": "f277f11a122129a52d36f788f42e5c09766cf4ae", + "type": 3, + "subtype": 1, + "name": "Front", + "uri": "/{/lang}/backend/admin/account/single/front?{?}", + "target": "self", + "icon": null, + "order": 3, + "from": "Admin", + "permission": null, + "parent": 1000104300, + "children": [] + } + ] + } + ] + }, + { + "id": 1000105001, + "pid": "754a08ddf8bcb1cf22f310f09206dd783d42f7dd", + "type": 2, + "subtype": 1, + "name": "Modules", + "uri": "/{/lang}/backend/admin/module/list?{?}", + "target": "self", + "icon": null, + "order": 4, + "from": "Admin", + "permission": null, + "parent": 1000101001, + "children": [ + { + "id": 1000105101, + "pid": "6f43051bccfc2ded5ab2baf8b1b7cff2c0f2b2aa", + "type": 3, + "subtype": 1, + "name": "Settings", + "uri": "/{/lang}/backend/admin/module/setting?{?}", + "target": "self", + "icon": null, + "order": 4, + "from": "Admin", + "permission": null, + "parent": 1000105001, + "children": [] + } + ] + } + ] + } +] diff --git a/Admin/Install/Navigation.php b/Admin/Install/Navigation.php new file mode 100644 index 0000000..2805621 --- /dev/null +++ b/Admin/Install/Navigation.php @@ -0,0 +1,40 @@ + + * @author Dennis Eichhorn + * @copyright Dennis Eichhorn + * @license OMS License 1.0 + * @version 1.0.0 + * @link http://orange-management.com + */ +namespace Modules\Admin\Admin\Install; +use phpOMS\DataStorage\Database\DatabasePool; + +/** + * 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 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..c1383d8 --- /dev/null +++ b/Admin/Installer.php @@ -0,0 +1,280 @@ + + * @author Dennis Eichhorn + * @copyright Dennis Eichhorn + * @license OMS License 1.0 + * @version 1.0.0 + * @link http://orange-management.com + */ +namespace Modules\Admin\Admin; + +use phpOMS\DataStorage\Database\DatabaseType; +use phpOMS\DataStorage\Database\DatabasePool; +use phpOMS\Module\InfoManager; +use phpOMS\Module\InstallerAbstract; + +/** + * Admin install 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 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->beginTransaction(); + + /* Create group table */ + $dbPool->get('core')->con->prepare( + 'CREATE TABLE if NOT EXISTS `' . $dbPool->get('core')->prefix . 'group` ( + `group_id` int(11) NOT NULL AUTO_INCREMENT, + `group_name` varchar(50) NOT NULL, + `group_status` int(11) NOT NULL, + `group_desc` varchar(100) DEFAULT NULL, + `group_created` datetime DEFAULT NULL, + PRIMARY KEY (`group_id`) + )ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1;' + )->execute(); + + /* Create group relations table */ + $dbPool->get('core')->con->prepare( + 'CREATE TABLE if NOT EXISTS `' . $dbPool->get('core')->prefix . 'group_relations` ( + `group_relations_id` int(11) NOT NULL AUTO_INCREMENT, + `group_relations_group` int(11) DEFAULT NULL, + `group_relations_parent` int(11) DEFAULT NULL, + PRIMARY KEY (`group_relations_id`), + KEY `group_relations_group` (`group_relations_group`) + ) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1;' + )->execute(); + + $dbPool->get('core')->con->prepare( + 'ALTER TABLE `' . $dbPool->get('core')->prefix . 'group_relations` + ADD CONSTRAINT `' . $dbPool->get('core')->prefix . 'group_relations_ibfk_1` FOREIGN KEY (`group_relations_group`) REFERENCES `' . $dbPool->get('core')->prefix . 'group` (`group_id`);' + )->execute(); + + /* Create group permission table */ + /* + * idx = module specific element id (since one module can have multiple things that need permissions) + * e.g. + * id1 = report_template (since it could also be a permission for a report) + * id2 = report_template_id + */ + $dbPool->get('core')->con->prepare( + 'CREATE TABLE if NOT EXISTS `' . $dbPool->get('core')->prefix . 'group_permission` ( + `group_permission_id` int(11) NOT NULL AUTO_INCREMENT, + `group_permission_group` int(11) NOT NULL, + `group_permission_from` varchar(50) DEFAULT NULL, + `group_permission_for` varchar(50) DEFAULT NULL, + `group_permission_id1` int(11) DEFAULT NULL, + `group_permission_id2` int(11) DEFAULT NULL, + `group_permission_id3` int(11) DEFAULT NULL, + `group_permission_r` int(1) DEFAULT NULL, + `group_permission_w` int(1) DEFAULT NULL, + `group_permission_m` int(1) DEFAULT NULL, + `group_permission_d` int(1) DEFAULT NULL, + `group_permission_p` int(1) DEFAULT NULL, + PRIMARY KEY (`group_permission_id`), + KEY `group_permission_group` (`group_permission_group`) + ) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1;' + )->execute(); + + $dbPool->get('core')->con->prepare( + 'ALTER TABLE `' . $dbPool->get('core')->prefix . 'group_permission` + ADD CONSTRAINT `' . $dbPool->get('core')->prefix . 'group_permission_ibfk_1` FOREIGN KEY (`group_permission_group`) REFERENCES `' . $dbPool->get('core')->prefix . 'group` (`group_id`);' + )->execute(); + + /* Create ips table + This gets used in order to prevent unauthorized access for user group. */ + $dbPool->get('core')->con->prepare( + 'CREATE TABLE if NOT EXISTS `' . $dbPool->get('core')->prefix . 'ips` ( + `ips_id` int(11) NOT NULL AUTO_INCREMENT, + `ips_begin` bigint(20) NOT NULL, + `ips_end` bigint(20) NOT NULL, + `ips_group` int(11) DEFAULT NULL, + PRIMARY KEY (`ips_id`), + KEY `ips_group` (`ips_group`) + ) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1;' + )->execute(); + + $dbPool->get('core')->con->prepare( + 'ALTER TABLE `' . $dbPool->get('core')->prefix . 'ips` + ADD CONSTRAINT `' . $dbPool->get('core')->prefix . 'ips_ibfk_1` FOREIGN KEY (`ips_group`) REFERENCES `' . $dbPool->get('core')->prefix . 'group` (`group_id`);' + )->execute(); + + $dbPool->get('core')->con->prepare( + 'CREATE TABLE if NOT EXISTS `' . $dbPool->get('core')->prefix . 'l11n` ( + `l11n_id` int(11) NOT NULL AUTO_INCREMENT, + `l11n_country` varchar(20) NOT NULL, + `l11n_language` varchar(20) NOT NULL, + `l11n_currency` varchar(20) NOT NULL, + `l11n_number_thousand` varchar(20) NOT NULL, + `l11n_number_decimal` varchar(20) NOT NULL, + `l11n_angle` varchar(20) NOT NULL, + `l11n_temperature` varchar(20) NOT NULL, + `l11n_weight_very_light` varchar(20) NOT NULL, + `l11n_weight_light` varchar(20) NOT NULL, + `l11n_weight_medium` varchar(20) NOT NULL, + `l11n_weight_heavy` varchar(20) NOT NULL, + `l11n_weight_very_heavy` varchar(20) NOT NULL, + `l11n_speed_very_slow` varchar(20) NOT NULL, + `l11n_speed_slow` varchar(20) NOT NULL, + `l11n_speed_medium` varchar(20) NOT NULL, + `l11n_speed_fast` varchar(20) NOT NULL, + `l11n_speed_very_fast` varchar(20) NOT NULL, + `l11n_speed_sea` varchar(20) NOT NULL, + `l11n_length_very_short` varchar(20) NOT NULL, + `l11n_length_short` varchar(20) NOT NULL, + `l11n_length_medium` varchar(20) NOT NULL, + `l11n_length_long` varchar(20) NOT NULL, + `l11n_length_very_long` varchar(20) NOT NULL, + `l11n_length_sea` varchar(20) NOT NULL, + `l11n_area_very_small` varchar(20) NOT NULL, + `l11n_area_small` varchar(20) NOT NULL, + `l11n_area_medium` varchar(20) NOT NULL, + `l11n_area_large` varchar(20) NOT NULL, + `l11n_area_very_large` varchar(20) NOT NULL, + `l11n_volume_very_small` varchar(20) NOT NULL, + `l11n_volume_small` varchar(20) NOT NULL, + `l11n_volume_medium` varchar(20) NOT NULL, + `l11n_volume_large` varchar(20) NOT NULL, + `l11n_volume_very_large` varchar(20) NOT NULL, + `l11n_volume_teaspoon` varchar(20) NOT NULL, + `l11n_volume_tablespoon` varchar(20) NOT NULL, + `l11n_volume_glass` varchar(20) NOT NULL, + PRIMARY KEY (`l11n_id`) + ) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1;' + )->execute(); + + /* Create account table */ + $dbPool->get('core')->con->prepare( + 'CREATE TABLE if NOT EXISTS `' . $dbPool->get('core')->prefix . 'account` ( + `account_id` int(11) NOT NULL AUTO_INCREMENT, + `account_status` tinyint(2) NOT NULL, + `account_type` tinyint(2) NOT NULL, + `account_login` varchar(30) NOT NULL, + `account_name1` varchar(50) NOT NULL, + `account_name2` varchar(50) NOT NULL, + `account_name3` varchar(50) NOT NULL, + `account_password` varchar(64) DEFAULT NULL, + `account_email` varchar(70) NOT NULL, + `account_tries` tinyint(2) NOT NULL DEFAULT 0, + `account_lactive` datetime DEFAULT NULL, + `account_localization` int(11) DEFAULT NULL, + `account_created_at` datetime NOT NULL, + PRIMARY KEY (`account_id`), + KEY `account_localization` (`account_localization`) + ) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1;' + )->execute(); + + $dbPool->get('core')->con->prepare( + 'ALTER TABLE `' . $dbPool->get('core')->prefix . 'account` + ADD CONSTRAINT `' . $dbPool->get('core')->prefix . 'account_ibfk_1` FOREIGN KEY (`account_localization`) REFERENCES `' . $dbPool->get('core')->prefix . 'l11n` (`l11n_id`);' + )->execute(); + + /* Create account group table */ + $dbPool->get('core')->con->prepare( + 'CREATE TABLE if NOT EXISTS `' . $dbPool->get('core')->prefix . 'account_group` ( + `account_group_id` bigint(20) NOT NULL AUTO_INCREMENT, + `account_group_group` int(11) NOT NULL, + `account_group_account` int(11) NOT NULL, + PRIMARY KEY (`account_group_id`), + KEY `account_group_group` (`account_group_group`), + KEY `account_group_account` (`account_group_account`) + ) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1;' + )->execute(); + + $dbPool->get('core')->con->prepare( + 'ALTER TABLE `' . $dbPool->get('core')->prefix . 'account_group` + ADD CONSTRAINT `' . $dbPool->get('core')->prefix . 'account_group_ibfk_1` FOREIGN KEY (`account_group_group`) REFERENCES `' . $dbPool->get('core')->prefix . 'group` (`group_id`), + ADD CONSTRAINT `' . $dbPool->get('core')->prefix . 'account_group_ibfk_2` FOREIGN KEY (`account_group_account`) REFERENCES `' . $dbPool->get('core')->prefix . 'account` (`account_id`);' + )->execute(); + + /* Create account permission table */ + $dbPool->get('core')->con->prepare( + 'CREATE TABLE if NOT EXISTS `' . $dbPool->get('core')->prefix . 'account_permission` ( + `account_permission_id` int(11) NOT NULL AUTO_INCREMENT, + `account_permission_account` int(11) NOT NULL, + `account_permission_from` varchar(50) DEFAULT NULL, + `account_permission_for` varchar(50) DEFAULT NULL, + `account_permission_id1` int(11) DEFAULT NULL, + `account_permission_id2` int(11) DEFAULT NULL, + `account_permission_id3` int(11) DEFAULT NULL, + `account_permission_r` int(1) DEFAULT NULL, + `account_permission_w` int(1) DEFAULT NULL, + `account_permission_m` int(1) DEFAULT NULL, + `account_permission_d` int(1) DEFAULT NULL, + `account_permission_p` int(1) DEFAULT NULL, + PRIMARY KEY (`account_permission_id`), + KEY `account_permission_account` (`account_permission_account`) + ) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1;' + )->execute(); + + $dbPool->get('core')->con->prepare( + 'ALTER TABLE `' . $dbPool->get('core')->prefix . 'account_permission` + ADD CONSTRAINT `' . $dbPool->get('core')->prefix . 'account_permission_ibfk_1` FOREIGN KEY (`account_permission_account`) REFERENCES `' . $dbPool->get('core')->prefix . 'account` (`account_id`);' + )->execute(); + + /* Create account settings table */ + $dbPool->get('core')->con->prepare( + 'CREATE TABLE if NOT EXISTS `' . $dbPool->get('core')->prefix . 'account_settings` ( + `account_settings_id` int(11) NOT NULL AUTO_INCREMENT, + `account_settings_name` varchar(30) NOT NULL, + `account_settings_content` varchar(250) NOT NULL, + `account_settings_account` int(11) NOT NULL, + PRIMARY KEY (`account_settings_id`), + UNIQUE KEY `account_settings_name` (`account_settings_name`), + KEY `account_settings_account` (`account_settings_account`) + ) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1;' + )->execute(); + + $dbPool->get('core')->con->prepare( + 'ALTER TABLE `' . $dbPool->get('core')->prefix . 'account_settings` + ADD CONSTRAINT `' . $dbPool->get('core')->prefix . 'account_settings_ibfk_1` FOREIGN KEY (`account_settings_account`) REFERENCES `' . $dbPool->get('core')->prefix . 'account` (`account_id`);' + )->execute(); + + /* Create settings table */ + $dbPool->get('core')->con->prepare( + 'CREATE TABLE if NOT EXISTS `' . $dbPool->get('core')->prefix . 'settings` ( + `settings_id` int(11) NOT NULL AUTO_INCREMENT, + `settings_module` varchar(255) DEFAULT NULL, + `settings_name` varchar(100) NOT NULL, + `settings_content` varchar(255) NOT NULL, + `settings_group` int(11) DEFAULT NULL, + PRIMARY KEY (`settings_id`), + KEY `settings_module` (`settings_module`), + KEY `settings_group` (`settings_group`) + ) ENGINE=InnoDB DEFAULT CHARSET=utf8;' + )->execute(); + + $dbPool->get('core')->con->prepare( + 'ALTER TABLE `' . $dbPool->get('core')->prefix . 'settings` + ADD CONSTRAINT `' . $dbPool->get('core')->prefix . 'settings_ibfk_1` FOREIGN KEY (`settings_module`) REFERENCES `' . $dbPool->get('core')->prefix . 'module` (`module_id`), + ADD CONSTRAINT `' . $dbPool->get('core')->prefix . 'settings_ibfk_2` FOREIGN KEY (`settings_group`) REFERENCES `' . $dbPool->get('core')->prefix . 'group` (`group_id`);' + )->execute(); + + $dbPool->get('core')->con->commit(); + break; + } + } +} diff --git a/Admin/Routes/Web/Api.php b/Admin/Routes/Web/Api.php new file mode 100644 index 0000000..f14f21f --- /dev/null +++ b/Admin/Routes/Web/Api.php @@ -0,0 +1,62 @@ + [ + [ + 'dest' => '\Modules\Admin\Controller:apiSettingsSet', + 'verb' => RouteVerb::SET, + ], + [ + 'dest' => '\Modules\Admin\Controller:apiSettingsGet', + 'verb' => RouteVerb::GET, + ], + ], + + '^.*/api/admin/group.*$' => [ + [ + 'dest' => '\Modules\Admin\Controller:apiGroupCreate', + 'verb' => RouteVerb::PUT, + ], + [ + 'dest' => '\Modules\Admin\Controller:apiGroupUpdate', + 'verb' => RouteVerb::SET, + ], + [ + 'dest' => '\Modules\Admin\Controller:apiGroupDelete', + 'verb' => RouteVerb::DELETE, + ], + [ + 'dest' => '\Modules\Admin\Controller:apiGroupGet', + 'verb' => RouteVerb::GET, + ], + ], + + '^.*/api/admin/account.*$' => [ + [ + 'dest' => '\Modules\Admin\Controller:apiAccountCreate', + 'verb' => RouteVerb::PUT, + ], + [ + 'dest' => '\Modules\Admin\Controller:apiAccountUpdate', + 'verb' => RouteVerb::SET, + ], + [ + 'dest' => '\Modules\Admin\Controller:apiAccountDelete', + 'verb' => RouteVerb::DELETE, + ], + [ + 'dest' => '\Modules\Admin\Controller:apiAccountGet', + 'verb' => RouteVerb::GET, + ], + ], + + '^.*/api/admin/module/status.*$' => [ + [ + 'dest' => '\Modules\Admin\Controller:apiModuleStatusUpdate', + 'verb' => RouteVerb::SET, + ], + ], +]; diff --git a/Admin/Routes/Web/Backend.php b/Admin/Routes/Web/Backend.php new file mode 100644 index 0000000..cb99b59 --- /dev/null +++ b/Admin/Routes/Web/Backend.php @@ -0,0 +1,60 @@ + [ + [ + 'dest' => '\Modules\Admin\Controller:viewSettingsGeneral', + 'verb' => RouteVerb::GET, + ], + ], + '^.*/backend/admin/account/list.*$' => [ + [ + 'dest' => '\Modules\Admin\Controller:viewAccountList', + 'verb' => RouteVerb::GET, + ], + ], + '^.*/backend/admin/account/settings.*$' => [ + [ + 'dest' => '\Modules\Admin\Controller:viewAccountSettings', + 'verb' => RouteVerb::GET, + ], + ], + '^.*/backend/admin/account/create.*$' => [ + [ + 'dest' => '\Modules\Admin\Controller:viewAccountCreate', + 'verb' => RouteVerb::GET, + ], + ], + '^.*/backend/admin/group/list.*$' => [ + [ + 'dest' => '\Modules\Admin\Controller:viewGroupList', + 'verb' => RouteVerb::GET, + ], + ], + '^.*/backend/admin/group/settings.*$' => [ + [ + 'dest' => '\Modules\Admin\Controller:viewGroupSettings', + 'verb' => RouteVerb::GET, + ], + ], + '^.*/backend/admin/group/create.*$' => [ + [ + 'dest' => '\Modules\Admin\Controller:viewGroupCreate', + 'verb' => RouteVerb::GET, + ], + ], + '^.*/backend/admin/module/list.*$' => [ + [ + 'dest' => '\Modules\Admin\Controller:viewModuleList', + 'verb' => RouteVerb::GET, + ], + ], + '^.*/backend/admin/module/settings.*$' => [ + [ + 'dest' => '\Modules\Admin\Controller:viewModuleProfile', + 'verb' => RouteVerb::GET, + ], + ], +]; diff --git a/Admin/Routes/console.php b/Admin/Routes/console.php new file mode 100644 index 0000000..1ecbfac --- /dev/null +++ b/Admin/Routes/console.php @@ -0,0 +1,3 @@ + + * @author Dennis Eichhorn + * @copyright Dennis Eichhorn + * @license OMS License 1.0 + * @version 1.0.0 + * @link http://orange-management.com + */ +namespace Modules\Admin\Admin; + + +use phpOMS\DataStorage\Database\DatabasePool; +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..4cfdf2a --- /dev/null +++ b/Admin/Update.php @@ -0,0 +1,46 @@ + + * @author Dennis Eichhorn + * @copyright Dennis Eichhorn + * @license OMS License 1.0 + * @version 1.0.0 + * @link http://orange-management.com + */ +namespace Modules\Admin\Admin; + + +use phpOMS\DataStorage\Database\DatabasePool; +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, array $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..28b963c --- /dev/null +++ b/Controller.php @@ -0,0 +1,446 @@ + + * @author Dennis Eichhorn + * @copyright Dennis Eichhorn + * @license OMS License 1.0 + * @version 1.0.0 + * @link http://orange-management.com + */ +namespace Modules\Admin; + +use Model\Message\FormValidation; +use Modules\Admin\Models\Account; +use phpOMS\Account\AccountStatus; +use phpOMS\Account\AccountType; +use Modules\Admin\Models\AccountMapper; +use Modules\Admin\Models\Group; +use Modules\Admin\Models\GroupMapper; +use phpOMS\Account\GroupStatus; +use phpOMS\Message\RequestAbstract; +use phpOMS\Message\ResponseAbstract; +use phpOMS\Module\ModuleAbstract; +use phpOMS\Module\WebInterface; +use phpOMS\System\MimeType; +use phpOMS\Views\View; + +/** + * Admin controller 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 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 = 'Admin'; + + /** + * 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 viewSettingsGeneral(RequestAbstract $request, ResponseAbstract $response, $data = null) : \Serializable + { + $settings = $this->app->appSettings->get([ + 1000000009, + 1000000019, + 1000000020, + 1000000021, + 1000000022, + 1000000023, + 1000000027, + 1000000028, + ]); + + $view = new View($this->app, $request, $response); + $view->setTemplate('/Modules/Admin/Theme/Backend/settings-general'); + $view->addData('nav', $this->app->moduleManager->get('Navigation')->createNavigationMid(1000104001, $request, $response)); + + $view->setData('oname', $settings[1000000009]); + $view->setData('country', $settings[1000000019]); + $view->setData('timezone', $settings[1000000021]); + $view->setData('timeformat', $settings[1000000022]); + $view->setData('language', $settings[1000000020]); + $view->setData('currency', $settings[1000000023]); + $view->setData('decimal_point', $settings[1000000027]); + $view->setData('thousands_sep', $settings[1000000028]); + $view->setData('countries', $settings[1000000028]); + + 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 viewAccountList(RequestAbstract $request, ResponseAbstract $response, $data = null) : \Serializable + { + $view = new View($this->app, $request, $response); + $view->setTemplate('/Modules/Admin/Theme/Backend/accounts-list'); + $view->addData('nav', $this->app->moduleManager->get('Navigation')->createNavigationMid(1000104001, $request, $response)); + + $view->setData('list:elements', AccountMapper::getAll()); + $view->setData('list:count', 1); + + 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 viewAccountSettings(RequestAbstract $request, ResponseAbstract $response, $data = null) : \Serializable + { + $view = new View($this->app, $request, $response); + $view->setTemplate('/Modules/Admin/Theme/Backend/accounts-single'); + $view->addData('nav', $this->app->moduleManager->get('Navigation')->createNavigationMid(1000104001, $request, $response)); + + $view->addData('account', AccountMapper::get((int) $request->getData('id'))); + + 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 viewAccountCreate(RequestAbstract $request, ResponseAbstract $response, $data = null) : \Serializable + { + $view = new View($this->app, $request, $response); + $view->setTemplate('/Modules/Admin/Theme/Backend/accounts-create'); + $view->addData('nav', $this->app->moduleManager->get('Navigation')->createNavigationMid(1000104001, $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 viewGroupList(RequestAbstract $request, ResponseAbstract $response, $data = null) : \Serializable + { + $view = new View($this->app, $request, $response); + $view->setTemplate('/Modules/Admin/Theme/Backend/groups-list'); + $view->addData('nav', $this->app->moduleManager->get('Navigation')->createNavigationMid(1000103001, $request, $response)); + + $view->setData('list:elements', GroupMapper::getAll()); + + 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 viewGroupSettings(RequestAbstract $request, ResponseAbstract $response, $data = null) : \Serializable + { + $view = new View($this->app, $request, $response); + $view->setTemplate('/Modules/Admin/Theme/Backend/groups-single'); + $view->addData('nav', $this->app->moduleManager->get('Navigation')->createNavigationMid(1000103001, $request, $response)); + + $view->addData('group', GroupMapper::get((int) $request->getData('id'))); + + 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 viewGroupCreate(RequestAbstract $request, ResponseAbstract $response, $data = null) : \Serializable + { + $view = new View($this->app, $request, $response); + $view->setTemplate('/Modules/Admin/Theme/Backend/groups-create'); + $view->addData('nav', $this->app->moduleManager->get('Navigation')->createNavigationMid(1000103001, $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 viewModuleList(RequestAbstract $request, ResponseAbstract $response, $data = null) : \Serializable + { + $view = new View($this->app, $request, $response); + $view->setTemplate('/Modules/Admin/Theme/Backend/modules-list'); + + 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 viewModuleProfile(RequestAbstract $request, ResponseAbstract $response, $data = null) : \Serializable + { + $view = new View($this->app, $request, $response); + $view->setTemplate('/Modules/Admin/Theme/Backend/modules-single'); + + return $view; + } + + public function apiSettingsGet(RequestAbstract $request, ResponseAbstract $response, $data = null) + { + $response->set('settings', $this->app->appSettings->get($request->getData('id'))); + } + + public function apiSettingsSet(RequestAbstract $request, ResponseAbstract $response, $data = null) + { + $success = $this->app->appSettings->set((array) $request->getData('settings'), true); + + $response->set('settings', $success); + } + + public function apiGroupGet(RequestAbstract $request, ResponseAbstract $response, $data = null) + { + $response->set('group', GroupMapper::getByRequest($request)); + } + + private function validateGroupCreate(RequestAbstract $request) : array + { + $val = []; + if ( + ($val['name'] = empty($request->getData('name'))) + || ($val['status'] = ( + $request->getData('status') === null + || !GroupStatus::isValidValue((int) $request->getData('status')) + )) + ) { + return $val; + } + + return []; + } + + public function apiGroupCreate(RequestAbstract $request, ResponseAbstract $response, $data = null) + { + if (!empty($val = $this->validateGroupCreate($request))) { + $response->set('group_create', new FormValidation($val)); + + return; + } + + $group = new Group(); + $group->setName($request->getData('name') ?? ''); + $group->setStatus((int) $request->getData('status')); + $group->setDescription($request->getData('description') ?? ''); + + GroupMapper::create($group); + + $response->set('group', $group->__toString()); + } + + public function apiGroupDelete(RequestAbstract $request, ResponseAbstract $response, $data = null) + { + $status = GroupMapper::delete($request->getData('id')); + + $response->set('group', $status); + } + + public function apiGroupUpdate(RequestAbstract $request, ResponseAbstract $response, $data = null) + { + $group = GroupMapper::get($request->getData('id')); + $group->setName($request->getData('name')); + $group->setDescription($request->getData('desc')); + + $status = GroupMapper::update($group); + + $response->set('group', ['status' => $status, 'group' => $group->__toString()]); + } + + public function apiAccountGet(RequestAbstract $request, ResponseAbstract $response, $data = null) + { + $response->getHeader()->set('Content-Type', MimeType::M_JSON . '; charset=utf-8', true); + $response->set('account', AccountMapper::getByRequest($request)); + } + + private function validateAccountCreate(RequestAbstract $request) : array + { + $val = []; + if ( + ($val['name'] = empty($request->getData('name'))) + || ($val['name1'] = empty($request->getData('name1'))) + || ($val['type'] = !AccountType::isValidValue((int) $request->getData('type'))) + || ($val['status'] = !AccountStatus::isValidValue((int) $request->getData('status'))) + ) { + return $val; + } + + return []; + } + + public function apiAccountCreate(RequestAbstract $request, ResponseAbstract $response, $data = null) + { + if (!empty($val = $this->validateAccountCreate($request))) { + $response->set('account_create', new FormValidation($val)); + + return; + } + + $account = new Account(); + $account->setStatus($request->getData('status')); + $account->setType($request->getData('type')); + $account->setName($request->getData('name')); + $account->setName1($request->getData('name1')); + $account->setName2($request->getData('name2')); + $account->setName3($request->getData('name3')); + $account->setEmail($request->getData('email')); + $account->generatePassword($request->getData('password')); + + AccountMapper::create($account); + + $response->set('account', $account->jsonSerialize()); + } + + public function apiAccountDelete(RequestAbstract $request, ResponseAbstract $response, $data = null) + { + $status = AccountMapper::delete($request->getData('id')); + + $response->set('account', $status); + } + + public function apiAccountUpdate(RequestAbstract $request, ResponseAbstract $response, $data = null) + { + $account = AccountMapper::get($request->getData('id')); + $account->setName($request->getData('name')); + $account->setDescription($request->getData('desc')); + + $status = AccountMapper::update($account); + + $response->set('account', ['status' => $status, 'account' => $account->jsonSerialize()]); + } + + public function apiModuleStatusUpdate(RequestAbstract $request, ResponseAbstract $response, $data = null) + { + $module = $request->getData('module'); + $status = $request->getData('status'); + + if (!$module || !$status) { + // todo: create failure response + } + + switch ($status) { + case 'activate': + $done = $this->app->moduleManager->activate($module); + break; + case 'deactivate': + $done = $this->app->moduleManager->deactivate($module); + break; + case 'install': + $done = $this->app->moduleManager->install($module); + break; + case 'uninstall': + //$done = $this->app->moduleManager->uninstall($module); + $done = true; + break; + default: + $done = false; + } + + $response->set('module', [$status => $done, 'module' => $module]); + } +} diff --git a/Models/Account.php b/Models/Account.php new file mode 100644 index 0000000..f627b25 --- /dev/null +++ b/Models/Account.php @@ -0,0 +1,31 @@ + + * @author Dennis Eichhorn + * @copyright Dennis Eichhorn + * @license OMS License 1.0 + * @version 1.0.0 + * @link http://orange-management.com + */ +namespace Modules\Admin\Models; + +/** + * Account 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 Account extends \phpOMS\Account\Account +{ +} diff --git a/Models/AccountMapper.php b/Models/AccountMapper.php new file mode 100644 index 0000000..c1fc563 --- /dev/null +++ b/Models/AccountMapper.php @@ -0,0 +1,131 @@ + + * @author Dennis Eichhorn + * @copyright Dennis Eichhorn + * @license OMS License 1.0 + * @version 1.0.0 + * @link http://orange-management.com + */ +namespace Modules\Admin\Models; + +use Modules\Media\Models\MediaMapper; +use phpOMS\DataStorage\Database\DataMapperAbstract; +use phpOMS\DataStorage\Database\Query\Builder; +use phpOMS\DataStorage\Database\Query\Column; +use phpOMS\DataStorage\Database\RelationType; + +class AccountMapper extends DataMapperAbstract +{ + /** + * Columns. + * + * @var array + * @since 1.0.0 + */ + protected static $columns = [ + 'account_id' => ['name' => 'account_id', 'type' => 'int', 'internal' => 'id'], + 'account_status' => ['name' => 'account_status', 'type' => 'int', 'internal' => 'status'], + 'account_type' => ['name' => 'account_type', 'type' => 'int', 'internal' => 'type'], + 'account_login' => ['name' => 'account_login', 'type' => 'string', 'internal' => 'login'], + 'account_name1' => ['name' => 'account_name1', 'type' => 'string', 'internal' => 'name1'], + 'account_name2' => ['name' => 'account_name2', 'type' => 'string', 'internal' => 'name2'], + 'account_name3' => ['name' => 'account_name3', 'type' => 'string', 'internal' => 'name3'], + 'account_password' => ['name' => 'account_password', 'type' => 'string', 'internal' => 'password'], + 'account_email' => ['name' => 'account_email', 'type' => 'string', 'internal' => 'email'], + //'account_tries' => ['name' => 'account_tries', 'type' => 'int', 'internal' => 'tries'], + 'account_lactive' => ['name' => 'account_lactive', 'type' => 'DateTime', + 'internal' => 'lastActive'], + 'account_created_at' => ['name' => 'account_created_at', 'type' => 'DateTime', 'internal' => 'createdAt'], + ]; + + /** + * Primary table. + * + * @var string + * @since 1.0.0 + */ + protected static $table = 'account'; + + /** + * Primary field name. + * + * @var string + * @since 1.0.0 + */ + protected static $primaryField = 'account_id'; + + /** + * Created at column + * + * @var string + * @since 1.0.0 + */ + protected static $createdAt = 'account_created_at'; + + /** + * 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); + $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(1, 'account', 'account', 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; + } + + /** + * Get object. + * + * @param mixed $primaryKey Key + * @param int $relations Load relations + * @param mixed $fill Object to fill + * + * @return Account + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ + public static function get($primaryKey, int $relations = RelationType::ALL, $fill = null) + { + return parent::get((int) $primaryKey, $relations, $fill); + } +} diff --git a/Models/Group.php b/Models/Group.php new file mode 100644 index 0000000..1f81cc6 --- /dev/null +++ b/Models/Group.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 + */ +namespace Modules\Admin\Models; + +/** + * Account group class. + * + * @category Framework + * @package phpOMS\Account + * @author OMS Development Team + * @author Dennis Eichhorn + * @license OMS License 1.0 + * @link http://orange-management.com + * @since 1.0.0 + */ +class Group extends \phpOMS\Account\Group +{ + /** + * Created at. + * + * @var \DateTime + * @since 1.0.0 + */ + protected $createdAt = null; + + /** + * Created by. + * + * @var int + * @since 1.0.0 + */ + protected $createdBy = 0; + + /** + * Get created at. + * + * @return \DateTime + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ + public function getCreatedAt() : \DateTime + { + return $this->createdAt ?? new \DateTime('NOW'); + } + + /** + * Get created by. + * + * @return int + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ + public function getCreatedBy() : int + { + return $this->createdBy; + } +} diff --git a/Models/GroupMapper.php b/Models/GroupMapper.php new file mode 100644 index 0000000..244cd29 --- /dev/null +++ b/Models/GroupMapper.php @@ -0,0 +1,78 @@ + + * @author Dennis Eichhorn + * @copyright Dennis Eichhorn + * @license OMS License 1.0 + * @version 1.0.0 + * @link http://orange-management.com + */ +namespace Modules\Admin\Models; + +use phpOMS\DataStorage\Database\DataMapperAbstract; +use phpOMS\DataStorage\Database\RelationType; + +class GroupMapper extends DataMapperAbstract +{ + + /** + * Columns. + * + * @var array + * @since 1.0.0 + */ + protected static $columns = [ + 'group_id' => ['name' => 'group_id', 'type' => 'int', 'internal' => 'id'], + 'group_name' => ['name' => 'group_name', 'type' => 'string', 'internal' => 'name'], + 'group_status' => ['name' => 'group_status', 'type' => 'int', 'internal' => 'status'], + 'group_desc' => ['name' => 'group_desc', 'type' => 'string', 'internal' => 'description'], + 'group_created' => ['name' => 'group_created', 'type' => 'DateTime', 'internal' => 'createdAt'], + ]; + + /** + * Primary table. + * + * @var string + * @since 1.0.0 + */ + protected static $table = 'group'; + + /** + * Primary field name. + * + * @var string + * @since 1.0.0 + */ + protected static $primaryField = 'group_id'; + + /** + * Created at column + * + * @var string + * @since 1.0.0 + */ + protected static $createdAt = 'group_created'; + + /** + * Get object. + * + * @param mixed $primaryKey Key + * @param int $relations Load relations + * @param mixed $fill Object to fill + * + * @return Group + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ + public static function get($primaryKey, int $relations = RelationType::ALL, $fill = null) + { + return parent::get((int) $primaryKey, $relations, $fill); + } +} diff --git a/Models/NullAccount.php b/Models/NullAccount.php new file mode 100644 index 0000000..ba68cca --- /dev/null +++ b/Models/NullAccount.php @@ -0,0 +1,20 @@ + + * @author Dennis Eichhorn + * @copyright Dennis Eichhorn + * @license OMS License 1.0 + * @version 1.0.0 + * @link http://orange-management.com + */ +namespace Modules\Admin\Models; + +class NullAccount extends Account +{ +} diff --git a/Models/NullGroup.php b/Models/NullGroup.php new file mode 100644 index 0000000..22aa441 --- /dev/null +++ b/Models/NullGroup.php @@ -0,0 +1,20 @@ + + * @author Dennis Eichhorn + * @copyright Dennis Eichhorn + * @license OMS License 1.0 + * @version 1.0.0 + * @link http://orange-management.com + */ +namespace Modules\Admin\Models; + +class NullGroup extends Group +{ +} diff --git a/README.md b/README.md new file mode 100644 index 0000000..cfba9ee --- /dev/null +++ b/README.md @@ -0,0 +1,13 @@ +# Admin # + +The Admin module is part of the core modules for OMS. This module is managing for modules, accounts, groups, permissions and monitoring. + +## Modules ## + +## Accounts ## + +## Groups ## + +## Permissions ## + +## Monitoring ## diff --git a/Theme/Backend/Lang/Navigation.en.lang.php b/Theme/Backend/Lang/Navigation.en.lang.php new file mode 100644 index 0000000..ddb3c2b --- /dev/null +++ b/Theme/Backend/Lang/Navigation.en.lang.php @@ -0,0 +1,27 @@ + + * @author Dennis Eichhorn + * @copyright Dennis Eichhorn + * @license OMS License 1.0 + * @version 1.0.0 + * @link http://orange-management.com + */ +return ['Navigation' => [ + 'Admin' => 'Admin', + 'Create' => 'Create', + 'Front' => 'Front', + 'General' => 'General', + 'Groups' => 'Groups', + 'List' => 'List', + 'Members' => 'Members', + 'Modules' => 'Modules', + 'Account' => 'Account', + 'Accounts' => 'Accounts', +]]; diff --git a/Theme/Backend/Lang/api.en.lang.php b/Theme/Backend/Lang/api.en.lang.php new file mode 100644 index 0000000..a82e530 --- /dev/null +++ b/Theme/Backend/Lang/api.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 + */ +$MODLANG[1] = [ + 'i:ModuleInstalled' => 'Installation of the module {$1} was successful.', +]; diff --git a/Theme/Backend/Lang/en.lang.php b/Theme/Backend/Lang/en.lang.php new file mode 100644 index 0000000..9418907 --- /dev/null +++ b/Theme/Backend/Lang/en.lang.php @@ -0,0 +1,132 @@ + + * @author Dennis Eichhorn + * @copyright Dennis Eichhorn + * @license OMS License 1.0 + * @version 1.0.0 + * @link http://orange-management.com + */ +return ['Admin' => [ + 'Account' => 'Account', + 'Accounts' => 'Accounts', + 'Active' => 'Active', + 'Activate' => 'Activate', + 'Activity' => 'Activity', + 'Available' => 'Available', + 'All' => 'All', + 'Area' => 'Area', + 'Banned' => 'Banned', + 'Cache' => 'Cache', + 'Children' => 'Children', + 'Country' => 'Country', + 'Created' => 'Created', + 'CreatedBy' => 'Created By', + 'Currency' => 'Currency', + 'DecimalPoint' => 'Decimal Point', + 'Description' => 'Description', + 'Delete' => 'Delete', + 'Deactivate' => 'Deactivate', + 'Email' => 'Email', + 'EmailAdmin' => 'Email Admin', + 'Fast' => 'Fast', + 'Features' => 'Features', + 'File' => 'File', + 'General' => 'General', + 'Glass' => 'Glass', + 'Group' => 'Group', + 'Groups' => 'Groups', + 'Heavy' => 'Heavy', + 'Inactive' => 'Inactive', + 'Install' => 'Install', + 'Installed' => 'Installed', + 'LAddress' => 'Local Address', + 'Language' => 'Language', + 'Large' => 'Large', + 'Length' => 'Length', + 'Light' => 'Light', + 'Localization' => 'Localization', + 'Long' => 'Long', + 'Loginname' => 'Login Name', + 'Lowercase' => 'Lowercase', + 'Maintenance' => 'Maintenance', + 'Medium' => 'Medium', + 'Member' => 'Member', + 'Members' => 'Members', + 'Memcache' => 'Memcache', + 'MemoryLimit' => 'Memory Limit', + 'Message' => 'Message', + 'Module' => 'Module', + 'Modules' => 'Modules', + 'Name' => 'Name', + 'Name1' => 'Name 1', + 'Name2' => 'Name 2', + 'Name3' => 'Name 3', + 'None' => 'None', + 'Numberformat' => 'Numberformat', + 'Numeric' => 'Numeric', + 'Organization' => 'Organization', + 'OrganizationName' => 'Organization Name', + 'Page' => 'Page', + 'Parent' => 'Parent', + 'Parents' => 'Parents', + 'Password' => 'Password', + 'PasswordRegex' => 'Password Regex', + 'Permissions' => 'Permissions', + 'Person' => 'Person', + 'Profile' => 'Profile', + 'RAddress' => 'Remote Address', + 'ReCache' => 'Re-Cache', + 'Running' => 'Running', + 'Short' => 'Short', + 'Sea' => 'Sea', + 'Settings' => 'Settings', + 'SettingsGeneral' => 'Settings - General', + 'Single' => 'Single', + 'Slow' => 'Slow', + 'Small' => 'Small', + 'Speed' => 'Speed', + 'Specialchar' => 'Special character', + 'Status' => 'Status', + 'Total' => 'Total', + 'Release' => 'Release', + 'Tablespoon' => 'Tablespoon', + 'Teaspoon' => 'Teaspoon', + 'Temperature' => 'Temperature', + 'Theme' => 'Theme', + 'ThousandsSeparator' => 'Thousands Separator', + 'Time' => 'Time', + 'Timestamp' => 'Timestamp', + 'Timeformat' => 'Timeformat', + 'Timeout' => 'Timeout', + 'Timezone' => 'Timezone', + 'Type' => 'Type', + 'Uninstall' => 'Uninstall', + 'Uppercase' => 'Uppercase', + 'Username' => 'Username', + 'Version' => 'Version', + 'VeryFast' => 'Very Fast', + 'VeryHeavy' => 'Very Heavy', + 'VeryLarge' => 'Very Large', + 'VeryLight' => 'Very Light', + 'VeryLong' => 'Very Long', + 'VerySlow' => 'Very Slow', + 'VeryShort' => 'Very Short', + 'VerySmall' => 'Very Small', + 'Volume' => 'Volume', + 'Warnings' => 'Warnings', + 'Website' => 'Website', + 'Weight' => 'Weight', + 'i:loc' => 'IP address or URL for remote access.', + 'i:mail' => 'Email address.', + 'i:oname' => 'Organization name.', + 'i:rem' => 'IP address or URL for remote access.', + 'i:rc' => 'Forcing re-cache for every user.', + 'i:timef' => 'Time format.', +]]; diff --git a/Theme/Backend/accounts-create.tpl.php b/Theme/Backend/accounts-create.tpl.php new file mode 100644 index 0000000..4af016f --- /dev/null +++ b/Theme/Backend/accounts-create.tpl.php @@ -0,0 +1,88 @@ + + * @author Dennis Eichhorn + * @copyright Dennis Eichhorn + * @license OMS License 1.0 + * @version 1.0.0 + * @link http://orange-management.com + */ +echo $this->getData('nav')->render(); ?> + +
+
+
+

getText('Account') ?>

+
+
+ + +
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ +
+
+

getText('Groups') ?>

+
+
+ + +
+
+
+
+
+
+
+
+ +
+
+

getText('Permissions') ?>

+
+
+ + +
+
+
+
+
+
+
+
+
diff --git a/Theme/Backend/accounts-list.tpl.php b/Theme/Backend/accounts-list.tpl.php new file mode 100644 index 0000000..97818bf --- /dev/null +++ b/Theme/Backend/accounts-list.tpl.php @@ -0,0 +1,61 @@ + + * @author Dennis Eichhorn + * @copyright Dennis Eichhorn + * @license OMS License 1.0 + * @version 1.0.0 + * @link http://orange-management.com + */ +/** + * @var \phpOMS\Views\View $this + */ + + +$footerView = new \Web\Views\Lists\PaginationView($this->app, $this->request, $this->response); +$footerView->setTemplate('/Web/Templates/Lists/Footer/PaginationBig'); + +$footerView->setPages($this->getData('list:count') / 25); +$footerView->setPage(1); +$footerView->setResults($this->getData('list:count')); + +echo $this->getData('nav')->render(); +?> + +
+
+
+ + + + + + + getData('list:elements') as $key => $value) : $c++; + $url = \phpOMS\Uri\UriFactory::build('/{/lang}/backend/admin/account/settings?{?}&id=' . $value->getId()); ?> + +
getText('Groups'); ?>
getText('ID', 0, 0); ?> + getText('Status'); ?> + getText('Name'); ?> + getText('Activity'); ?> + getText('Created'); ?> +
render(); ?> +
getId(); ?> + getStatus(); ?> + getName1(); ?> + getLastActive()->format('Y-m-d H:i:s'); ?> + getCreatedAt()->format('Y-m-d H:i:s'); ?> + + +
getText('Empty', 0, 0); ?> + +
+
+
+
diff --git a/Theme/Backend/accounts-single.tpl.php b/Theme/Backend/accounts-single.tpl.php new file mode 100644 index 0000000..8f98db9 --- /dev/null +++ b/Theme/Backend/accounts-single.tpl.php @@ -0,0 +1,95 @@ + + * @author Dennis Eichhorn + * @copyright Dennis Eichhorn + * @license OMS License 1.0 + * @version 1.0.0 + * @link http://orange-management.com + */ +/* + * UI Logic + */ + +$account = $this->getData('account'); +echo $this->getData('nav')->render(); ?> + +
+
+
+

getText('Account') ?>

+
+
+ + +
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ +
+
+

getText('Groups') ?>

+
+
+ + +
+
+
+
+
+
+
+
+ +
+
+

getText('Permissions') ?>

+
+
+ + +
+
+
+
+
+
+
+
+
\ No newline at end of file diff --git a/Theme/Backend/groups-create.tpl.php b/Theme/Backend/groups-create.tpl.php new file mode 100644 index 0000000..76523c9 --- /dev/null +++ b/Theme/Backend/groups-create.tpl.php @@ -0,0 +1,76 @@ + + * @author Dennis Eichhorn + * @copyright Dennis Eichhorn + * @license OMS License 1.0 + * @version 1.0.0 + * @link http://orange-management.com + */ +/* + * UI Logic + */ + +echo $this->getData('nav')->render(); ?> + +
+
+
+

getText('Group') ?>

+
+
+ + +
+
+
+
+
+
+
+
+
+
+
+ +
+
+

getText('Parent') ?>

+
+
+ + +
+
+
+
+
+
+
+
+ +
+
+

getText('Permissions') ?>

+
+
+ + +
+
+
+
+
+
+
+
+
\ No newline at end of file diff --git a/Theme/Backend/groups-list.tpl.php b/Theme/Backend/groups-list.tpl.php new file mode 100644 index 0000000..c089857 --- /dev/null +++ b/Theme/Backend/groups-list.tpl.php @@ -0,0 +1,57 @@ + + * @author Dennis Eichhorn + * @copyright Dennis Eichhorn + * @license OMS License 1.0 + * @version 1.0.0 + * @link http://orange-management.com + */ +/** + * @var \phpOMS\Views\View $this + */ + +$footerView = new \Web\Views\Lists\PaginationView($this->app, $this->request, $this->response); +$footerView->setTemplate('/Web/Templates/Lists/Footer/PaginationBig'); + +$footerView->setPages($this->getData('list:count') ?? 0 / 25); +$footerView->setPage(1); +$footerView->setResults($this->getData('list:count') ?? 1); + +echo $this->getData('nav')->render(); ?> + +
+
+ + + + + + + getData('list:elements') as $key => $value) : $c++; + $url = \phpOMS\Uri\UriFactory::build('/{/lang}/backend/admin/group/settings?{?}&id=' . $value->getId()); ?> + +
getText('Groups'); ?>
getText('ID', 0, 0); ?> + getText('Name'); ?> + getText('Parents'); ?> + getText('Children'); ?> + getText('Members'); ?> +
render(); ?> +
getId(); ?> + getName(); ?> + + + + + +
getText('Empty', 0, 0); ?> + +
+
+
\ No newline at end of file diff --git a/Theme/Backend/groups-single.tpl.php b/Theme/Backend/groups-single.tpl.php new file mode 100644 index 0000000..2b81542 --- /dev/null +++ b/Theme/Backend/groups-single.tpl.php @@ -0,0 +1,92 @@ + + * @author Dennis Eichhorn + * @copyright Dennis Eichhorn + * @license OMS License 1.0 + * @version 1.0.0 + * @link http://orange-management.com + */ +/* + * UI Logic + */ + +$group = $this->getData('group'); + +echo $this->getData('nav')->render(); ?> + +
+
+
+

getText('Group') ?>

+
+
+ + +
+
+
+
+
+
+
+
+
+
+
+
+ +
+
+

getText('Parent') ?>

+
+
+ + +
+
+
+
+
+
+
+
+ +
+
+

getText('Permissions') ?>

+
+
+ + +
+
+
+
+
+
+
+
+ +
+
+

getText('Accounts') ?>

+
+
+ + +
+
+
+
+
+
+
+
+
\ No newline at end of file diff --git a/Theme/Backend/modules-list.tpl.php b/Theme/Backend/modules-list.tpl.php new file mode 100644 index 0000000..966caae --- /dev/null +++ b/Theme/Backend/modules-list.tpl.php @@ -0,0 +1,66 @@ + + * @author Dennis Eichhorn + * @copyright Dennis Eichhorn + * @license OMS License 1.0 + * @version 1.0.0 + * @link http://orange-management.com + */ +/** + * @var \phpOMS\Views\View $this + */ + +$footerView = new \Web\Views\Lists\PaginationView($this->app, $this->request, $this->response); +$footerView->setTemplate('/Web/Templates/Lists/Footer/PaginationBig'); + +$modules = $this->app->moduleManager->getAllModules(); +$active = $this->app->moduleManager->getActiveModules(); +$installed = $this->app->moduleManager->getInstalledModules(); + +$footerView->setPages(count($modules) / 25); +$footerView->setPage(1); +$footerView->setResults(count($modules)); +?> + +
+
+
+ + + + + + + + $module) : $count++; + $url = \phpOMS\Uri\UriFactory::build('/{/lang}/backend/admin/module/settings?{?}&id=' . $module['name']['internal']); ?> + +
getText('Modules'); ?>
getText('ID', 0, 0); ?> + getText('Name'); ?> + getText('Version'); ?> + getText('Status'); ?> +
render(); ?> +
+ + + getText('Active')); + elseif (in_array($module['name']['internal'], $installed)) + echo strtolower($this->getText('Inactive')); + else + echo strtolower($this->getText('Available')); ?> + + +
getText('Empty', 0, 0); ?> + +
+
+
+
diff --git a/Theme/Backend/modules-settings.tpl.php b/Theme/Backend/modules-settings.tpl.php new file mode 100644 index 0000000..e69de29 diff --git a/Theme/Backend/modules-single.tpl.php b/Theme/Backend/modules-single.tpl.php new file mode 100644 index 0000000..18a42b1 --- /dev/null +++ b/Theme/Backend/modules-single.tpl.php @@ -0,0 +1,96 @@ + + * @author Dennis Eichhorn + * @copyright Dennis Eichhorn + * @license OMS License 1.0 + * @version 1.0.0 + * @link http://orange-management.com + */ +/** + * @var \phpOMS\Views\View $this + */ + +$modules = $this->app->moduleManager->getAllModules(); +$active = $this->app->moduleManager->getActiveModules(); +$installed = $this->app->moduleManager->getInstalledModules(); + +$id = $this->request->getData('id') ?? 1; +?> + +
+
+
+

+ +
+ + + + + + + + +
getText('Name') ?> + +
getText('Version') ?> + +
getText('CreatedBy') ?> + +
getText('Website') ?> + +
getText('Description') ?> + +
+ + + + + + + + + +
+
+
+
+ +
+
+

getText('Settings') ?>

+ +
+ +
+
+
+ +
+
+

getText('Groups') ?>

+ +
+ +
+
+
+ +
+
+

getText('Permissions') ?>

+ +
+ +
+
+
+
diff --git a/Theme/Backend/settings-general.tpl.php b/Theme/Backend/settings-general.tpl.php new file mode 100644 index 0000000..61df682 --- /dev/null +++ b/Theme/Backend/settings-general.tpl.php @@ -0,0 +1,295 @@ + + * @author Dennis Eichhorn + * @copyright Dennis Eichhorn + * @license OMS License 1.0 + * @version 1.0.0 + * @link http://orange-management.com + */ +/* + * UI Logic + */ + +$_oname = $this->getData('oname') ?? ''; +$_timezone = $this->getData('timezone') ?? ''; +$_timeformat = $this->getData('timeformat') ?? ''; +$_language = $this->getData('language') ?? ''; +$_currency = $this->getData('currency') ?? ''; +$_decimal_point = $this->getData('decimal_point') ?? ''; +$_thousands_sep = $this->getData('thousands_sep') ?? ''; +$_password = $this->getData('password') ?? ''; +$_country = $this->getData('country') ?? ''; + +$countries = \phpOMS\Localization\ISO3166NameEnum::getConstants(); +$timezones = \phpOMS\Localization\TimeZoneEnumArray::getConstants(); +$timeformats = \phpOMS\Localization\ISO8601EnumArray::getConstants(); +$languages = \phpOMS\Localization\ISO639Enum::getConstants(); +$currencies = \phpOMS\Localization\ISO4217Enum::getConstants(); +?> + +
+
+ +
+
+ +
+
+
+
+

getText('Settings') ?>

+
+
+ + +
+
+
+
+
+
+
+
+
+
+
+
+ +
+
+
+
+

getText('Localization') ?>

+
+
+ + +
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ +
+
+

getText('Numeric') ?>

+
+
+ +
+
+

getText('Numberformat') ?>

+
+ +
+ +
+
+
+
+
+ +
+
+

getText('Weight') ?>

+
+
+ + + + + + + + + + + + +
+
+
+
+
+
+ +
+
+
+

getText('Speed') ?>

+
+
+ + + + + + + + + + + + + + +
+
+
+
+
+ +
+
+

getText('Length') ?>

+
+
+ + + + + + + + + + + + + + +
+
+
+
+
+ +
+
+

getText('Area') ?>

+
+
+ + + + + + + + + + + + +
+
+
+
+
+
+ +
+
+
+

getText('Volume') ?>

+
+
+ + + + + + + + + + + + + + + + + + +
+
+
+
+
+
+
+
+
diff --git a/img/module_teaser_small.png b/img/module_teaser_small.png new file mode 100644 index 0000000..f56e6ff Binary files /dev/null and b/img/module_teaser_small.png differ diff --git a/info.json b/info.json new file mode 100644 index 0000000..645991a --- /dev/null +++ b/info.json @@ -0,0 +1,51 @@ +{ + "name": { + "id": 1000100000, + "internal": "Admin", + "external": "OMS Admin" + }, + "version": "1.0.0", + "requirements": { + "phpOMS": "1.0.0", + "phpOMS-db": "1.0.0" + }, + "creator": { + "name": "Orange Management", + "website": "www.spl1nes.com" + }, + "description": "The administration module.", + "directory": "Admin", + "dependencies": {}, + "providing": { + "Navigation": "*" + }, + "load": [ + { + "pid": [ + "1854402adfd24425fd13776a2d3787151609b360" + ], + "type": 4, + "for": "Content", + "file": "Admin", + "from": "Admin" + }, + { + "pid": [ + "754a08ddf8bcb1cf22f310f09206dd783d42f7dd" + ], + "type": 5, + "from": "Admin", + "for": "Navigation", + "file": "Navigation" + }, + { + "pid": [ + "1854402adfd24425fd13776a2d3787151609b360" + ], + "type": 5, + "for": "Content", + "file": "", + "from": "Admin" + } + ] +}