From d1f4e9831ab5e6f10ca6982ae5f1ec5530bcab06 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jannis=20Mo=C3=9Fhammer?= Date: Wed, 26 Jun 2013 16:05:01 +0200 Subject: [PATCH] Fix empty module folder causing errors, fix var naming Fix a wrongly named class causing ClassNotFound issues, also added additional checks for empty module folder and added en moduleFolder directive to configure module location refs #4092 --- config/icinga.ini | 1 + library/Icinga/Application/ApplicationBootstrap.php | 2 +- library/Icinga/Application/Modules/Manager.php | 12 ++++++++++-- public/js/icinga/container.js | 1 - public/js/icinga/icinga.js | 2 -- public/js/main.js | 1 - 6 files changed, 12 insertions(+), 7 deletions(-) diff --git a/config/icinga.ini b/config/icinga.ini index c685d24d6..871e759f8 100755 --- a/config/icinga.ini +++ b/config/icinga.ini @@ -3,6 +3,7 @@ environment = development timezone = "Europe/Berlin" indexModule = monitoring indexController = dashboard +moduleFolder = "/usr/etc/icinga-modules" [logging] ; General log diff --git a/library/Icinga/Application/ApplicationBootstrap.php b/library/Icinga/Application/ApplicationBootstrap.php index 715850ee5..4675a1e4c 100755 --- a/library/Icinga/Application/ApplicationBootstrap.php +++ b/library/Icinga/Application/ApplicationBootstrap.php @@ -100,7 +100,7 @@ abstract class ApplicationBootstrap public function moduleManager() { if ($this->moduleManager === null) { - $this->moduleManager = new ModuleManager($this, "/etc/icinga2/modules_enabled"); + $this->moduleManager = new ModuleManager($this, $this->config->global->moduleFolder); } return $this->moduleManager; } diff --git a/library/Icinga/Application/Modules/Manager.php b/library/Icinga/Application/Modules/Manager.php index f4612de7f..96a6234c8 100644 --- a/library/Icinga/Application/Modules/Manager.php +++ b/library/Icinga/Application/Modules/Manager.php @@ -54,7 +54,7 @@ class Manager public function select() { - $source = new \Icinga\Data\ArrayDataSource($this->getModuleInfo()); + $source = new \Icinga\Data\ArrayDatasource($this->getModuleInfo()); return $source->select(); } @@ -238,7 +238,12 @@ class Manager public function getModuleInfo() { $installed = $this->listInstalledModules(); + $info = array(); + if ($installed === null) { + return $info; + } + foreach ($installed as $name) { $info[] = (object) array( 'name' => $name, @@ -265,7 +270,10 @@ class Manager if ($this->installedBaseDirs === null) { $this->detectInstalledModules(); } - return array_keys($this->installedBaseDirs); + + if ($this->installedBaseDirs !== null) { + return array_keys($this->installedBaseDirs); + } } public function detectInstalledModules() diff --git a/public/js/icinga/container.js b/public/js/icinga/container.js index 8e0891802..4f99ff53e 100755 --- a/public/js/icinga/container.js +++ b/public/js/icinga/container.js @@ -108,6 +108,5 @@ containerMgrInstance = new ContainerMgr($,log,widgets,subTable); } return containerMgrInstance; - }); })(); diff --git a/public/js/icinga/icinga.js b/public/js/icinga/icinga.js index d538ab552..1c28a35f4 100755 --- a/public/js/icinga/icinga.js +++ b/public/js/icinga/icinga.js @@ -80,5 +80,3 @@ define([ }; return new Icinga(); }); - - diff --git a/public/js/main.js b/public/js/main.js index f0fa6ceb9..0836be32c 100755 --- a/public/js/main.js +++ b/public/js/main.js @@ -24,4 +24,3 @@ define(['jquery','Holder'], function ($) { window.Icinga = Icinga; }); }); -