From a6bacd0dc351717be8231a18265466a1b7b7a180 Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Mon, 20 Apr 2020 11:16:38 +0200 Subject: [PATCH] ModulePage: Select icingadb by default if installed --- .../setup/application/forms/ModulePage.php | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/modules/setup/application/forms/ModulePage.php b/modules/setup/application/forms/ModulePage.php index 123085489..d62b5a93e 100644 --- a/modules/setup/application/forms/ModulePage.php +++ b/modules/setup/application/forms/ModulePage.php @@ -4,6 +4,7 @@ namespace Icinga\Module\Setup\Forms; use Icinga\Application\Icinga; +use Icinga\Application\Modules\Module; use Icinga\Web\Form; class ModulePage extends Form @@ -12,6 +13,8 @@ class ModulePage extends Form protected $modulePaths; + protected $foundIcingaDB = false; + /** * Initialize this page */ @@ -29,19 +32,29 @@ class ModulePage extends Form public function createElements(array $formData) { foreach ($this->getModules() as $module) { + $checked = false; + if ($module->getName() === 'monitoring') { + $checked = ! $this->foundIcingaDB; + } elseif ($this->foundIcingaDB && $module->getName() === 'icingadb') { + $checked = true; + } + $this->addElement( 'checkbox', $module->getName(), array( 'description' => $module->getDescription(), 'label' => ucfirst($module->getName()), - 'value' => $module->getName() === 'monitoring' ? 1 : 0, + 'value' => (int) $checked, 'decorators' => array('ViewHelper') ) ); } } + /** + * @return Module[] + */ protected function getModules() { if ($this->modules !== null) { @@ -56,6 +69,10 @@ class ModulePage extends Form if ($moduleName !== 'setup') { $this->modules[$moduleName] = $moduleManager->loadModule($moduleName)->getModule($moduleName); } + + if ($moduleName === 'icingadb') { + $this->foundIcingaDB = true; + } } return $this->modules;