diff --git a/src/modules/Extension/Service.php b/src/modules/Extension/Service.php index 781c6f1d7..243ee9d88 100644 --- a/src/modules/Extension/Service.php +++ b/src/modules/Extension/Service.php @@ -272,7 +272,7 @@ class Service implements InjectionAwareInterface $modules = $this->di['mod']('extension')->getCoreModules(); $installed = $this->getInstalledMods(); - $list = array_merge($modules, $installed); + $list = array_unique(array_merge($modules, $installed)); foreach ($list as $mod) { if (!$staff_service->hasPermission($admin, $mod)) { continue; @@ -698,19 +698,14 @@ class Service implements InjectionAwareInterface continue; } - // If getSpecificModulePermissions returns false, we need to skip that module and not include it in the permissions list - $permissions = $this->getSpecificModulePermissions($module, true); - if ($permissions === false) { - continue; - } else { - $modules[$module]['permissions'] = $permissions; - } + $permissions = $this->getSpecificModulePermissions($module); + $modules[$module]['permissions'] = $permissions; } return $modules; } - public function getSpecificModulePermissions(string $module, bool $buildingCompleteList = false): array|false + public function getSpecificModulePermissions(string $module): array|false { $class = 'Box\Mod\\' . ucfirst($module) . '\Service'; if (class_exists($class) && method_exists($class, 'getModulePermissions')) { @@ -720,22 +715,20 @@ class Service implements InjectionAwareInterface } $permissions = $moduleService->getModulePermissions(); - if (isset($permissions['hide_permissions']) && $permissions['hide_permissions']) { - return $buildingCompleteList ? false : []; - } else { + if (isset($permissions['hide_permissions']) && !$permissions['hide_permissions']) { unset($permissions['hide_permissions']); - - // Fill in the manage_settings permission as it will always be the same - if (isset($permissions['manage_settings'])) { - $permissions['manage_settings'] = [ - 'type' => 'bool', - 'display_name' => __trans('Manage settings'), - 'description' => __trans('Allows the staff member to edit settings for this module.'), - ]; - } - - return $permissions; } + + // Fill in the manage_settings permission as it will always be the same + if (isset($permissions['manage_settings'])) { + $permissions['manage_settings'] = [ + 'type' => 'bool', + 'display_name' => __trans('Manage settings'), + 'description' => __trans('Allows the staff member to edit settings for this module.'), + ]; + } + + return $permissions; } return []; diff --git a/src/modules/Security/Service.php b/src/modules/Security/Service.php index 8523267d9..2152dd842 100644 --- a/src/modules/Security/Service.php +++ b/src/modules/Security/Service.php @@ -34,7 +34,6 @@ class Service { return [ 'can_always_access' => true, - 'hide_permissions' => true, 'run_checks' => [ 'type' => 'bool', 'display_name' => __trans('Run security checks'), diff --git a/src/modules/Staff/Service.php b/src/modules/Staff/Service.php index edb7d5530..7630e4996 100644 --- a/src/modules/Staff/Service.php +++ b/src/modules/Staff/Service.php @@ -162,7 +162,12 @@ class Service implements InjectionAwareInterface $modulePermissions = $extensionService->getSpecificModulePermissions($module); $permissions = $this->getPermissions($member->id); - $canAlwaysAccess = $modulePermissions['can_always_access'] ?? false; + if ($modulePermissions['hide_permissions'] ?? false) { + $canAlwaysAccess = true; + } else { + $canAlwaysAccess = $modulePermissions['can_always_access'] ?? false; + } + if (!$canAlwaysAccess) { // They have no permissions or don't have any access to that module if (empty($permissions) || !array_key_exists($module, $permissions) || !is_array($permissions[$module]) || !($permissions[$module]['access'] ?? false)) { @@ -170,15 +175,17 @@ class Service implements InjectionAwareInterface } } - // If this passes, the permission key isn't assigned to them and they therefore don't have permission - if ((!is_null($key) && !is_array($permissions[$module])) || (!is_null($key) && !array_key_exists($key, $permissions[$module]))) { - return false; - } + if (!is_null($key)) { + // If this passes, the permission key isn't assigned to them and they therefore don't have permission + if (!is_array($permissions[$module]) || !array_key_exists($key, $permissions[$module])) { + return false; + } - if (!is_null($key) && !is_null($constraint)) { - return $permissions[$module][$key] === $constraint; - } elseif (!is_null($key)) { - return (bool) $permissions[$module][$key]; + if (!is_null($constraint)) { + return $permissions[$module][$key] === $constraint; + } else { + return (bool) $permissions[$module][$key]; + } } return true; diff --git a/src/modules/Staff/html_admin/mod_staff_manage.html.twig b/src/modules/Staff/html_admin/mod_staff_manage.html.twig index 186a2c6a7..0371f4cd0 100644 --- a/src/modules/Staff/html_admin/mod_staff_manage.html.twig +++ b/src/modules/Staff/html_admin/mod_staff_manage.html.twig @@ -148,7 +148,7 @@ - {% for modName, mod in mods %} + {% for modName, mod in mods|filter(mod => mod.permissions.hide_permissions is not true) %}