diff --git a/Admin/Install/Navigation.install.json b/Admin/Install/Navigation.install.json index 0003a01..65734bb 100755 --- a/Admin/Install/Navigation.install.json +++ b/Admin/Install/Navigation.install.json @@ -150,7 +150,7 @@ "children": [] }, { - "id": 1000105301, + "id": 1000105401, "pid": "/admin/module", "type": 3, "subtype": 1, @@ -158,14 +158,14 @@ "uri": "{/prefix}admin/module/route/list?{?}", "target": "self", "icon": null, - "order": 10, + "order": 15, "from": "Admin", "permission": { "permission": 2, "type": null, "element": null }, "parent": 1000105001, "children": [] }, { - "id": 1000105401, + "id": 1000105501, "pid": "/admin/module", "type": 3, "subtype": 1, @@ -173,7 +173,7 @@ "uri": "{/prefix}admin/module/log?{?}", "target": "self", "icon": null, - "order": 15, + "order": 20, "from": "Admin", "permission": { "permission": 2, "type": null, "element": null }, "parent": 1000105001, diff --git a/Controller/BackendController.php b/Controller/BackendController.php index dc8e1c1..6dc9e13 100755 --- a/Controller/BackendController.php +++ b/Controller/BackendController.php @@ -418,6 +418,23 @@ final class BackendController extends Controller $view->setTemplate('/Modules/Admin/Theme/Backend/modules-route-list'); $view->addData('nav', $this->app->moduleManager->get('Navigation')->createNavigationMid(1000105001, $request, $response)); + $module = $request->getData('id') ?? ''; + $view->setData('module', $module); + + $appPath = __DIR__ . '/../../../Web'; + $activeRoutes = []; + $apps = \scandir($appPath); + + foreach ($apps as $app) { + if (!\is_file(__DIR__ . '/../../../Web/' . $app . '/Routes.php')) { + continue; + } + + $activeRoutes[$app] = include __DIR__ . '/../../../Web/' . $app . '/Routes.php'; + } + + $view->setData('routes', $activeRoutes); + return $view; } diff --git a/Models/AccountMapper.php b/Models/AccountMapper.php index 1ebe50c..e0dfa68 100755 --- a/Models/AccountMapper.php +++ b/Models/AccountMapper.php @@ -135,12 +135,20 @@ final class AccountMapper extends DataMapperFactory $groupPermissions = empty($groups) ? [] - : GroupPermissionMapper::getAll()->where('group', \array_keys($account->getGroups()), 'in')->execute(); + : GroupPermissionMapper::getAll() + ->where('group', \array_keys($account->getGroups()), 'in') + ->where('element', null) + ->execute(); + foreach ($groupPermissions as $permission) { $account->addPermissions(\is_array($permission) ? $permission : [$permission]); } - $accountPermissions = AccountPermissionMapper::getAll()->where('account', $id)->execute(); + $accountPermissions = AccountPermissionMapper::getAll() + ->where('account', $id) + ->where('element', null) + ->execute(); + foreach ($accountPermissions as $permission) { $account->addPermissions(\is_array($permission) ? $permission : [$permission]); } diff --git a/Models/AppMapper.php b/Models/AppMapper.php index 1a1c261..a84b1f9 100644 --- a/Models/AppMapper.php +++ b/Models/AppMapper.php @@ -33,10 +33,10 @@ final class AppMapper extends DataMapperFactory * @since 1.0.0 */ public const COLUMNS = [ - 'app_id' => ['name' => 'app_id', 'type' => 'int', 'internal' => 'id'], - 'app_name' => ['name' => 'app_name', 'type' => 'string', 'internal' => 'name'], - 'app_theme' => ['name' => 'app_theme', 'type' => 'string', 'internal' => 'theme'], - 'app_status' => ['name' => 'app_status', 'type' => 'int', 'internal' => 'status'], + 'app_id' => ['name' => 'app_id', 'type' => 'int', 'internal' => 'id'], + 'app_name' => ['name' => 'app_name', 'type' => 'string', 'internal' => 'name'], + 'app_theme' => ['name' => 'app_theme', 'type' => 'string', 'internal' => 'theme'], + 'app_status' => ['name' => 'app_status', 'type' => 'int', 'internal' => 'status'], ]; /** diff --git a/Models/PermissionAbstractMapper.php b/Models/PermissionAbstractMapper.php new file mode 100644 index 0000000..fbb9651 --- /dev/null +++ b/Models/PermissionAbstractMapper.php @@ -0,0 +1,35 @@ +connection = $connection; + } + + public function groups(array $groups) : self + { + + $this->groups = $groups; + + return $this; + } + + public function account(int $account) : self + { + $this->account = $account; + + return $this; + } + + public function units(array $units) : self + { + $this->units = $units; + + return $this; + } + + public function apps(array $apps) : self + { + $this->apps = $apps; + + return $this; + } + + public function types(array $types) : self + { + $this->types = $types; + + return $this; + } + + public function modules(array $modules) : self + { + $this->modules = $modules; + + return $this; + } + + public function permission(int $permission) : self + { + $this->permission = $permission; + + return $this; + } + + public function query(string $idField) : Builder + { + $where = new Where($this->connection); + + // Handle account permissions + if (!empty($this->account)) { + $accountPermission = new Builder($this->connection); + $accountPermission->select('account_permission_element') + ->from('account_permission') + ->where('account_permission_account', '=', $this->account); + + $subWhere = new Where($this->connection); + foreach ($this->units as $unit) { + $subWhere->orWhere('account_permission_unit', '=', $unit); + } + + $accountPermission->where($subWhere); + + $subWhere = new Where($this->connection); + foreach ($this->apps as $app) { + $subWhere->orWhere('account_permission_app', '=', $app); + } + + $accountPermission->where($subWhere); + + $subWhere = new Where($this->connection); + foreach ($this->modules as $module) { + $subWhere->orWhere('account_permission_module', '=', $module); + } + + $accountPermission->where($subWhere); + + $subWhere = new Where($this->connection); + foreach ($this->types as $type) { + $subWhere->orWhere('account_permission_type', '=', $type); + } + + $accountPermission->where($subWhere); + + $accountPermission->where('account_permission_permission', '>', $this->permission); + $where->where($idField, 'in', $accountPermission); + } + + // Handle group permissions + if (!empty($this->groups)) { + $groupPermission = new Builder($this->connection); + $groupPermission->select('group_permission_element') + ->from('group_permission') + ->where('group_permission_group', 'IN', $this->groups); + + $subWhere = new Where($this->connection); + foreach ($this->units as $unit) { + $subWhere->orWhere('group_permission_unit', '=', $unit); + } + + $groupPermission->where($subWhere); + + $subWhere = new Where($this->connection); + foreach ($this->apps as $app) { + $subWhere->orWhere('group_permission_app', '=', $app); + } + + $groupPermission->where($subWhere); + + $subWhere = new Where($this->connection); + foreach ($this->modules as $module) { + $subWhere->orWhere('group_permission_module', '=', $module); + } + + $groupPermission->where($subWhere); + + $subWhere = new Where($this->connection); + foreach ($this->types as $type) { + $subWhere->orWhere('group_permission_type', '=', $type); + } + + $groupPermission->where($subWhere); + + $groupPermission->where('group_permission_permission', '>', $this->permission); + $where->orWhere($idField, 'in', $groupPermission); + } + + return $where; + } +} diff --git a/Theme/Backend/groups-single.tpl.php b/Theme/Backend/groups-single.tpl.php index c75650a..129a089 100755 --- a/Theme/Backend/groups-single.tpl.php +++ b/Theme/Backend/groups-single.tpl.php @@ -169,7 +169,7 @@ echo $this->getData('nav')->render(); ?> @@ -177,7 +177,7 @@ echo $this->getData('nav')->render(); ?> @@ -185,7 +185,7 @@ echo $this->getData('nav')->render(); ?> @@ -193,7 +193,7 @@ echo $this->getData('nav')->render(); ?> @@ -201,7 +201,7 @@ echo $this->getData('nav')->render(); ?> @@ -211,7 +211,9 @@ echo $this->getData('nav')->render(); ?>
- + + +
@@ -220,8 +222,13 @@ echo $this->getData('nav')->render(); ?>
getHtml('Permissions'); ?>
-
- +
+
- $value) : ++$c; $permission = $value->getPermission(); ?> + $value) : ++$c; + $permission = $value->getPermission(); ?>
@@ -255,23 +262,35 @@ echo $this->getData('nav')->render(); ?>
- + getId(); ?> - getUnit(); ?> - getApp(); ?> - getModule(); ?> - getType(); ?> - getElement(); ?> - getComponent(); ?> + getUnit(); ?> + getApp(); ?> + getModule(); ?> + getType(); ?> + getElement(); ?> + getComponent(); ?> - - - - - + + C + + + R + + + U + + + D + + + P +
getHtml('Empty', '0', '0'); ?> diff --git a/Theme/Backend/module-route-list.tpl.php b/Theme/Backend/module-route-list.tpl.php deleted file mode 100644 index 0496fb7..0000000 --- a/Theme/Backend/module-route-list.tpl.php +++ /dev/null @@ -1,25 +0,0 @@ -getData('auditlogs') ?? []; - -$previous = empty($audits) ? HttpHeader::getAllHeaders()['Referer'] ?? '{/prefix}admin/module/settings?id={?id}#{\#}' : '{/prefix}admin/module/settings?{?}&audit=' . \reset($audits)->getId() . '&ptype=p#{\#}'; -$next = empty($audits) ? HttpHeader::getAllHeaders()['Referer'] ?? '{/prefix}admin/module/settings?id={?id}#{\#}' : '{/prefix}admin/module/settings?{?}&audit=' . \end($audits)->getId() . '&ptype=n#{\#}'; - -echo $this->getData('nav')->render(); diff --git a/Theme/Backend/modules-route-list.tpl.php b/Theme/Backend/modules-route-list.tpl.php new file mode 100644 index 0000000..a9a2bbd --- /dev/null +++ b/Theme/Backend/modules-route-list.tpl.php @@ -0,0 +1,95 @@ +getData('routes') ?? []; +$module = $this->getData('module') ?? ''; + +echo $this->getData('nav')->render(); +?> + +
+
+
+
getHtml('Routes'); ?>
+
+ + + + + + $appRoutes) : + foreach ($appRoutes as $uri => $destinations) : + foreach ($destinations as $route) : + if (\stripos($route['dest'], '\Modules\\' . $module . '\Controller') === false) { + continue; + } + + ++$c; + ?> + + +
+
+