Provide module permissions automatically

refs #9644
This commit is contained in:
Eric Lippmann 2015-07-22 15:01:54 +02:00
parent 5dcc307e87
commit bf590ed380
1 changed files with 28 additions and 18 deletions

View File

@ -63,7 +63,16 @@ class RoleForm extends ConfigForm
public function init()
{
$helper = new Zend_Form_Element('bogus');
foreach (Icinga::app()->getModuleManager()->getLoadedModules() as $module) {
$mm = Icinga::app()->getModuleManager();
foreach ($mm->listInstalledModules() as $moduleName) {
$modulePermission = $mm::MODULE_PERMISSION_NS . $moduleName;
$this->providedPermissions[$modulePermission] = sprintf(
$this->translate('Allow access to module %s') . ' (%s)',
$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 . ')';
@ -85,6 +94,7 @@ class RoleForm extends ConfigForm
}
}
}
}
/**
* {@inheritdoc}