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
This commit is contained in:
Eric Lippmann 2015-07-24 16:13:08 +02:00
parent 8358e9165c
commit a51f0ad65e

View File

@ -71,28 +71,27 @@ class RoleForm extends ConfigForm
$moduleName, $moduleName,
$modulePermission $modulePermission
); );
if ($mm->hasEnabled($moduleName)) {
$module = $mm->getModule($moduleName); $module = $mm->getModule($moduleName, false);
foreach ($module->getProvidedPermissions() as $permission) { foreach ($module->getProvidedPermissions() as $permission) {
/** @var object $permission */ /** @var object $permission */
$this->providedPermissions[$permission->name] = $permission->description $this->providedPermissions[$permission->name] = $permission->description
. ' (' . $permission->name . ')'; . ' (' . $permission->name . ')';
} }
foreach ($module->getProvidedRestrictions() as $restriction) { foreach ($module->getProvidedRestrictions() as $restriction) {
/** @var object $restriction */ /** @var object $restriction */
// Zend only permits alphanumerics, the underscore, the circumflex and any ASCII character in range // Zend only permits alphanumerics, the underscore, the circumflex and any ASCII character in range
// \x7f to \xff (127 to 255) // \x7f to \xff (127 to 255)
$name = $helper->filterName($restriction->name); $name = $helper->filterName($restriction->name);
while (isset($this->providedRestrictions[$name])) { while (isset($this->providedRestrictions[$name])) {
// Because Zend_Form_Element::filterName() replaces any not permitted character with the empty // 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' // string we may have duplicate names, e.g. 're/striction' and 'restriction'
$name .= '_'; $name .= '_';
}
$this->providedRestrictions[$name] = array(
'description' => $restriction->description,
'name' => $restriction->name
);
} }
$this->providedRestrictions[$name] = array(
'description' => $restriction->description,
'name' => $restriction->name
);
} }
} }
} }