parent
5dcc307e87
commit
bf590ed380
|
@ -63,25 +63,35 @@ class RoleForm extends ConfigForm
|
||||||
public function init()
|
public function init()
|
||||||
{
|
{
|
||||||
$helper = new Zend_Form_Element('bogus');
|
$helper = new Zend_Form_Element('bogus');
|
||||||
foreach (Icinga::app()->getModuleManager()->getLoadedModules() as $module) {
|
$mm = Icinga::app()->getModuleManager();
|
||||||
foreach ($module->getProvidedPermissions() as $permission) {
|
foreach ($mm->listInstalledModules() as $moduleName) {
|
||||||
/** @var object $permission */
|
$modulePermission = $mm::MODULE_PERMISSION_NS . $moduleName;
|
||||||
$this->providedPermissions[$permission->name] = $permission->description . ' (' . $permission->name . ')';
|
$this->providedPermissions[$modulePermission] = sprintf(
|
||||||
}
|
$this->translate('Allow access to module %s') . ' (%s)',
|
||||||
foreach ($module->getProvidedRestrictions() as $restriction) {
|
$moduleName,
|
||||||
/** @var object $restriction */
|
$modulePermission
|
||||||
$name = $helper->filterName($restriction->name); // Zend only permits alphanumerics, the underscore,
|
);
|
||||||
// the circumflex and any ASCII character in range
|
if ($mm->hasEnabled($moduleName)) {
|
||||||
// \x7f to \xff (127 to 255)
|
$module = $mm->getModule($moduleName);
|
||||||
while (isset($this->providedRestrictions[$name])) {
|
foreach ($module->getProvidedPermissions() as $permission) {
|
||||||
// Because Zend_Form_Element::filterName() replaces any not permitted character with the empty
|
/** @var object $permission */
|
||||||
// string we may have duplicate names, e.g. 're/striction' and 'restriction'
|
$this->providedPermissions[$permission->name] = $permission->description . ' (' . $permission->name . ')';
|
||||||
$name .= '_';
|
}
|
||||||
|
foreach ($module->getProvidedRestrictions() as $restriction) {
|
||||||
|
/** @var object $restriction */
|
||||||
|
$name = $helper->filterName($restriction->name); // Zend only permits alphanumerics, the underscore,
|
||||||
|
// the circumflex and any ASCII character in range
|
||||||
|
// \x7f to \xff (127 to 255)
|
||||||
|
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
|
||||||
|
);
|
||||||
}
|
}
|
||||||
$this->providedRestrictions[$name] = array(
|
|
||||||
'description' => $restriction->description,
|
|
||||||
'name' => $restriction->name
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue