From a51f0ad65e71d8ec5c1115947b897dd06f3df877 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Fri, 24 Jul 2015 16:13:08 +0200 Subject: [PATCH] Roles: Include permissions and restrictions of unloaded modules too Because we now have module permissions it makes sense to allow an admin to configure permissions and restrictions from a module before allowing access to it. refs #9644 --- application/forms/Security/RoleForm.php | 41 ++++++++++++------------- 1 file changed, 20 insertions(+), 21 deletions(-) diff --git a/application/forms/Security/RoleForm.php b/application/forms/Security/RoleForm.php index 19307262d..dba7ebe9f 100644 --- a/application/forms/Security/RoleForm.php +++ b/application/forms/Security/RoleForm.php @@ -71,28 +71,27 @@ class RoleForm extends ConfigForm $moduleName, $modulePermission ); - if ($mm->hasEnabled($moduleName)) { - $module = $mm->getModule($moduleName); - foreach ($module->getProvidedPermissions() as $permission) { - /** @var object $permission */ - $this->providedPermissions[$permission->name] = $permission->description - . ' (' . $permission->name . ')'; - } - foreach ($module->getProvidedRestrictions() as $restriction) { - /** @var object $restriction */ - // Zend only permits alphanumerics, the underscore, the circumflex and any ASCII character in range - // \x7f to \xff (127 to 255) - $name = $helper->filterName($restriction->name); - while (isset($this->providedRestrictions[$name])) { - // Because Zend_Form_Element::filterName() replaces any not permitted character with the empty - // string we may have duplicate names, e.g. 're/striction' and 'restriction' - $name .= '_'; - } - $this->providedRestrictions[$name] = array( - 'description' => $restriction->description, - 'name' => $restriction->name - ); + + $module = $mm->getModule($moduleName, false); + foreach ($module->getProvidedPermissions() as $permission) { + /** @var object $permission */ + $this->providedPermissions[$permission->name] = $permission->description + . ' (' . $permission->name . ')'; + } + foreach ($module->getProvidedRestrictions() as $restriction) { + /** @var object $restriction */ + // Zend only permits alphanumerics, the underscore, the circumflex and any ASCII character in range + // \x7f to \xff (127 to 255) + $name = $helper->filterName($restriction->name); + while (isset($this->providedRestrictions[$name])) { + // Because Zend_Form_Element::filterName() replaces any not permitted character with the empty + // string we may have duplicate names, e.g. 're/striction' and 'restriction' + $name .= '_'; } + $this->providedRestrictions[$name] = array( + 'description' => $restriction->description, + 'name' => $restriction->name + ); } } }