diff --git a/application/controllers/ConfigController.php b/application/controllers/ConfigController.php index 543a84217..cb2c31855 100644 --- a/application/controllers/ConfigController.php +++ b/application/controllers/ConfigController.php @@ -95,6 +95,7 @@ class ConfigController extends Controller */ public function modulesAction() { + $this->assertPermission('config/modules'); // Overwrite tabs created in init // @TODO(el): This seems not natural to me. Module configuration should have its own controller. $this->view->tabs = Widget::create('tabs') @@ -120,6 +121,7 @@ class ConfigController extends Controller public function moduleAction() { + $this->assertPermission('config/modules'); $app = Icinga::app(); $manager = $app->getModuleManager(); $name = $this->getParam('name'); diff --git a/application/controllers/SearchController.php b/application/controllers/SearchController.php index 3816eb3e8..aa5cfaf9d 100644 --- a/application/controllers/SearchController.php +++ b/application/controllers/SearchController.php @@ -12,7 +12,9 @@ class SearchController extends ActionController { public function indexAction() { - $this->view->dashboard = SearchDashboard::search($this->params->get('q')); + $searchDashboard = new SearchDashboard(); + $searchDashboard->setUser($this->Auth()->getUser()); + $this->view->dashboard = $searchDashboard->search($this->params->get('q')); // NOTE: This renders the dashboard twice. Remove this once we can catch exceptions thrown in view scripts. $this->view->dashboard->render(); diff --git a/application/forms/Security/RoleForm.php b/application/forms/Security/RoleForm.php index 114ddfc1f..dba7ebe9f 100644 --- a/application/forms/Security/RoleForm.php +++ b/application/forms/Security/RoleForm.php @@ -63,24 +63,34 @@ 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 + ); + + $module = $mm->getModule($moduleName, false); foreach ($module->getProvidedPermissions() as $permission) { /** @var object $permission */ - $this->providedPermissions[$permission->name] = $permission->description . ' (' . $permission->name . ')'; + $this->providedPermissions[$permission->name] = $permission->description + . ' (' . $permission->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) + // 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 + 'description' => $restriction->description, + 'name' => $restriction->name ); } } diff --git a/application/views/scripts/layout/menu.phtml b/application/views/scripts/layout/menu.phtml index fe931c9d4..ee2ab0081 100644 --- a/application/views/scripts/layout/menu.phtml +++ b/application/views/scripts/layout/menu.phtml @@ -1,8 +1,11 @@ - if (SearchDashboard::search('dummy')->getPane('search')->hasDashlets()): ?> +use Icinga\Web\Widget\SearchDashboard; + +$searchDashboard = new SearchDashboard(); +$searchDashboard->setUser($this->Auth()->getUser()); + +if ($searchDashboard->search('dummy')->getPane('search')->hasDashlets()): ?>