From 1e8523aae655539f6c4c0d1ff4ca5c5c01ce3e4c Mon Sep 17 00:00:00 2001 From: Alexander Fuhr Date: Wed, 26 Nov 2014 14:24:19 +0100 Subject: [PATCH 0001/2920] Add Cookie helper class for cookie support detection refs #7383 --- library/Icinga/Web/Cookie.php | 79 +++++++++++++++++++++++++++++++++++ 1 file changed, 79 insertions(+) create mode 100644 library/Icinga/Web/Cookie.php diff --git a/library/Icinga/Web/Cookie.php b/library/Icinga/Web/Cookie.php new file mode 100644 index 000000000..888425151 --- /dev/null +++ b/library/Icinga/Web/Cookie.php @@ -0,0 +1,79 @@ + Date: Wed, 26 Nov 2014 14:25:05 +0100 Subject: [PATCH 0002/2920] Add cookie support detection refs #7383 --- library/Icinga/Application/Web.php | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/library/Icinga/Application/Web.php b/library/Icinga/Application/Web.php index 37ec5138a..8c103e01c 100644 --- a/library/Icinga/Application/Web.php +++ b/library/Icinga/Application/Web.php @@ -12,6 +12,7 @@ use Icinga\Exception\ConfigurationError; use Icinga\Exception\NotReadableError; use Icinga\Application\Logger; use Icinga\Util\TimezoneDetect; +use Icinga\Web\Cookie; use Icinga\Web\Request; use Icinga\Web\Response; use Icinga\Web\View; @@ -91,6 +92,7 @@ class Web extends ApplicationBootstrap { return $this ->setupZendAutoloader() + ->detectCookieSupport() ->setupLogging() ->setupErrorHandling() ->loadConfig() @@ -337,5 +339,20 @@ class Web extends ApplicationBootstrap ); return $this; } + + /** + * Check cookie support + * + * @return $this + */ + protected function detectCookieSupport() + { + if (! Cookie::isSupported()) { + echo 'Cookies must be enabled to run this application.'; + exit(1); + } + + return $this; + } } // @codeCoverageIgnoreEnd From 00a09284efa406c1f704a5a22048eeffe3f28505 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Tue, 9 Dec 2014 12:28:23 +0100 Subject: [PATCH 0003/2920] lib: Add NonEmptyFileIterator Add iterator for iterating over non-empty files. --- library/Icinga/File/NonEmptyFileIterator.php | 49 ++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 library/Icinga/File/NonEmptyFileIterator.php diff --git a/library/Icinga/File/NonEmptyFileIterator.php b/library/Icinga/File/NonEmptyFileIterator.php new file mode 100644 index 000000000..c5c7fda45 --- /dev/null +++ b/library/Icinga/File/NonEmptyFileIterator.php @@ -0,0 +1,49 @@ + + * + */ +class NonEmptyFileIterator extends FilterIterator +{ + /** + * Accept non-empty files + * + * @return bool Whether the current element of the iterator is acceptable + * through this filter + */ + public function accept() + { + $current = $this->current(); + /** @type $current \SplFileInfo */ + if (! $current->isFile() + || $current->getSize() === 0 + ) { + return false; + } + return true; + } +} From 1afc2a0b1dd86469c124d90b9913fd72a3c5ff94 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Tue, 9 Dec 2014 12:28:49 +0100 Subject: [PATCH 0004/2920] lib: Add FileExtensionFilterIterator Add iterator for iterating over files having a specific file extension. --- .../File/FileExtensionFilterIterator.php | 71 +++++++++++++++++++ 1 file changed, 71 insertions(+) create mode 100644 library/Icinga/File/FileExtensionFilterIterator.php diff --git a/library/Icinga/File/FileExtensionFilterIterator.php b/library/Icinga/File/FileExtensionFilterIterator.php new file mode 100644 index 000000000..909156749 --- /dev/null +++ b/library/Icinga/File/FileExtensionFilterIterator.php @@ -0,0 +1,71 @@ + + * + */ +class FileExtensionFilterIterator extends FilterIterator +{ + /** + * The extension to filter for + * + * @type string + */ + protected $extension; + + /** + * Create a new FileExtensionFilterIterator + * + * @param Iterator $iterator Apply filter to this iterator + * @param string $extension The file extension to filter for. The file extension may not contain the leading dot + */ + public function __construct(Iterator $iterator, $extension) + { + $this->extension = '.' . ltrim(strtolower((string) $extension), '.'); + parent::__construct($iterator); + } + + /** + * Accept files which match the file extension to filter for + * + * @return bool Whether the current element of the iterator is acceptable + * through this filter + */ + public function accept() + { + $current = $this->current(); + /* @var $current \SplFileInfo */ + if (! $current->isFile()) { + return false; + } + // SplFileInfo::getExtension() is only available since PHP 5 >= 5.3.6 + $filename = $current->getFilename(); + $sfx = substr($filename, -strlen($this->extension)); + return $sfx === false ? false : strtolower($sfx) === $this->extension; + } +} From 5f772c36202422162ab4e40884f0b9a79759c040 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Tue, 9 Dec 2014 12:29:48 +0100 Subject: [PATCH 0005/2920] doc: Use Icinga Web 2's iterators --- modules/doc/library/Doc/DocIterator.php | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/modules/doc/library/Doc/DocIterator.php b/modules/doc/library/Doc/DocIterator.php index 43a9c7727..3045b6309 100644 --- a/modules/doc/library/Doc/DocIterator.php +++ b/modules/doc/library/Doc/DocIterator.php @@ -9,6 +9,8 @@ use Countable; use IteratorAggregate; use RecursiveIteratorIterator; use RecursiveDirectoryIterator; +use Icinga\File\NonEmptyFileIterator; +use Icinga\File\FileExtensionFilterIterator; /** * Iterator over non-empty Markdown files ordered by the case insensitive "natural order" of file names @@ -29,12 +31,14 @@ class DocIterator implements Countable, IteratorAggregate */ public function __construct($path) { - $it = new RecursiveIteratorIterator( + $it = new FileExtensionFilterIterator( new NonEmptyFileIterator( - new MarkdownFileIterator( - new RecursiveDirectoryIterator($path) + new RecursiveIteratorIterator( + new RecursiveDirectoryIterator($path), + RecursiveIteratorIterator::SELF_FIRST ) - ) + ), + 'md' ); // Unfortunately we have no chance to sort the iterator $fileInfo = iterator_to_array($it); From 001eba73e73e83b53ac5ff344f3ab64622834109 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Tue, 9 Dec 2014 12:30:08 +0100 Subject: [PATCH 0006/2920] doc: Remove iterators because they are superseded by iterators from Icinga Web 2's library --- .../doc/library/Doc/MarkdownFileIterator.php | 31 ------------------- .../doc/library/Doc/NonEmptyFileIterator.php | 31 ------------------- 2 files changed, 62 deletions(-) delete mode 100644 modules/doc/library/Doc/MarkdownFileIterator.php delete mode 100644 modules/doc/library/Doc/NonEmptyFileIterator.php diff --git a/modules/doc/library/Doc/MarkdownFileIterator.php b/modules/doc/library/Doc/MarkdownFileIterator.php deleted file mode 100644 index 6f317ce6a..000000000 --- a/modules/doc/library/Doc/MarkdownFileIterator.php +++ /dev/null @@ -1,31 +0,0 @@ -getInnerIterator()->current(); - /* @var $current \SplFileInfo */ - if (! $current->isFile()) { - return false; - } - $filename = $current->getFilename(); - $sfx = substr($filename, -3); - return $sfx === false ? false : strtolower($sfx) === '.md'; - } -} diff --git a/modules/doc/library/Doc/NonEmptyFileIterator.php b/modules/doc/library/Doc/NonEmptyFileIterator.php deleted file mode 100644 index 71bf5acfa..000000000 --- a/modules/doc/library/Doc/NonEmptyFileIterator.php +++ /dev/null @@ -1,31 +0,0 @@ -getInnerIterator()->current(); - /* @var $current \SplFileInfo */ - if (! $current->isFile() - || $current->getSize() === 0 - ) { - return false; - } - return true; - } -} From ca8dbdb9386e8a23ae246eac3f532039c31dd31c Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Tue, 9 Dec 2014 12:50:29 +0100 Subject: [PATCH 0007/2920] doc: Make path to Icinga Web 2's doc configureable refs #7196 --- .../controllers/IcingawebController.php | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/modules/doc/application/controllers/IcingawebController.php b/modules/doc/application/controllers/IcingawebController.php index 5740f50a9..d052d8268 100644 --- a/modules/doc/application/controllers/IcingawebController.php +++ b/modules/doc/application/controllers/IcingawebController.php @@ -8,12 +8,20 @@ use Icinga\Module\Doc\DocController; class Doc_IcingawebController extends DocController { + /** + * Get the path to Icinga Web 2's documentation + */ + protected function getDocPath() + { + return $this->Config()->get('documentation', 'path', Icinga::app()->getBaseDir('doc')); + } + /** * View the toc of Icinga Web 2's documentation */ public function tocAction() { - return $this->renderToc(Icinga::app()->getApplicationDir('/../doc'), 'Icinga Web 2', 'doc/icingaweb/chapter'); + return $this->renderToc($this->getDocPath(), 'Icinga Web 2', 'doc/icingaweb/chapter'); } /** @@ -31,7 +39,7 @@ class Doc_IcingawebController extends DocController ); } return $this->renderChapter( - Icinga::app()->getApplicationDir('/../doc'), + $this->getDocPath(), $chapterId, 'doc/icingaweb/toc', 'doc/icingaweb/chapter' @@ -43,6 +51,6 @@ class Doc_IcingawebController extends DocController */ public function pdfAction() { - return $this->renderPdf(Icinga::app()->getApplicationDir('/../doc'), 'Icinga Web 2', 'doc/icingaweb/chapter'); + return $this->renderPdf($this->getDocPath(), 'Icinga Web 2', 'doc/icingaweb/chapter'); } } From cc619e0a7b8c1d27d14ababa3f5cc6d921b8f59e Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Tue, 9 Dec 2014 12:53:44 +0100 Subject: [PATCH 0008/2920] doc/configuration.php: Prefer @type over @var --- modules/doc/configuration.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/doc/configuration.php b/modules/doc/configuration.php index 87e5da77a..6e924e964 100644 --- a/modules/doc/configuration.php +++ b/modules/doc/configuration.php @@ -2,7 +2,7 @@ // {{{ICINGA_LICENSE_HEADER}}} // {{{ICINGA_LICENSE_HEADER}}} -/* @var $this \Icinga\Application\Modules\Module */ +/** @type $this \Icinga\Application\Modules\Module */ $section = $this->menuSection($this->translate('Documentation'), array( 'title' => 'Documentation', From da575910e6c844067adb37c6bccb143266ea029f Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Tue, 9 Dec 2014 12:54:41 +0100 Subject: [PATCH 0009/2920] doc/run.php: Remove superfluous newline --- modules/doc/run.php | 1 - 1 file changed, 1 deletion(-) diff --git a/modules/doc/run.php b/modules/doc/run.php index 7392e4c22..31aff8ff0 100644 --- a/modules/doc/run.php +++ b/modules/doc/run.php @@ -47,4 +47,3 @@ $this->addRoute('doc/module/chapter', $docModuleChapter); $this->addRoute('doc/icingaweb/chapter', $docIcingaWebChapter); $this->addRoute('doc/module/toc', $docModuleToc); $this->addRoute('doc/module/pdf', $docModulePdf); - From 19d89f0a67de95ce5314dd6a15d39b0917d05597 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Tue, 9 Dec 2014 12:55:12 +0100 Subject: [PATCH 0010/2920] monitoring/configuration.php: Prefer @type over @var --- modules/monitoring/configuration.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/monitoring/configuration.php b/modules/monitoring/configuration.php index d61e32858..b1cdee2de 100644 --- a/modules/monitoring/configuration.php +++ b/modules/monitoring/configuration.php @@ -2,7 +2,7 @@ // {{{ICINGA_LICENSE_HEADER}}} // {{{ICINGA_LICENSE_HEADER}}} -/** @var $this \Icinga\Application\Modules\Module */ +/** @type $this \Icinga\Application\Modules\Module */ $this->providePermission( 'monitoring/command/*', From 51b47df4c5bb67337e333a505e330e59ac878fe3 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Tue, 9 Dec 2014 12:55:29 +0100 Subject: [PATCH 0011/2920] doc: Set version to 2.0.0 --- modules/doc/module.info | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/doc/module.info b/modules/doc/module.info index 2826d72de..1689fd940 100644 --- a/modules/doc/module.info +++ b/modules/doc/module.info @@ -1,4 +1,4 @@ Module: doc -Version: 2.0.0~alpha4 +Version: 2.0.0 Description: Documentation module Extracts, shows and exports documentation for Icinga Web 2 and it's modules. From 7edb1217c6ac936e1a351eb2a76caaa44404aa0d Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Tue, 9 Dec 2014 12:57:16 +0100 Subject: [PATCH 0012/2920] doc: Use sprintf for "Missing parameter x" exceptions --- modules/doc/application/controllers/ModuleController.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/doc/application/controllers/ModuleController.php b/modules/doc/application/controllers/ModuleController.php index 1e9cf43b1..adc46a991 100644 --- a/modules/doc/application/controllers/ModuleController.php +++ b/modules/doc/application/controllers/ModuleController.php @@ -37,7 +37,7 @@ class Doc_ModuleController extends DocController { if (empty($moduleName)) { throw new Zend_Controller_Action_Exception( - $this->translate('Missing parameter \'moduleName\''), + sprintf($this->translate('Missing parameter \'%s\''), 'moduleName'), 404 ); } From 40b709848005098f6a0e20db27392f2326101f9d Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Tue, 9 Dec 2014 14:24:11 +0100 Subject: [PATCH 0013/2920] doc/parser: Fix PHPDoc indentation --- modules/doc/library/Doc/DocParser.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/doc/library/Doc/DocParser.php b/modules/doc/library/Doc/DocParser.php index c63532dc1..6cfeca418 100644 --- a/modules/doc/library/Doc/DocParser.php +++ b/modules/doc/library/Doc/DocParser.php @@ -31,7 +31,7 @@ class DocParser /** * Create a new documentation parser for the given path * - * @param string $path Path to the documentation + * @param string $path Path to the documentation * * @throws DocException If the documentation directory does not exist * @throws NotReadableError If the documentation directory is not readable From 823d338f73cd1470315bffb5c4d83f8728e2de93 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Tue, 9 Dec 2014 14:24:45 +0100 Subject: [PATCH 0014/2920] doc/Controller: Do not use 'void' results --- modules/doc/library/Doc/DocController.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/modules/doc/library/Doc/DocController.php b/modules/doc/library/Doc/DocController.php index bc782953f..0d12f58df 100644 --- a/modules/doc/library/Doc/DocController.php +++ b/modules/doc/library/Doc/DocController.php @@ -28,7 +28,7 @@ class DocController extends ModuleActionController $urlParams ); $this->view->title = $chapterId; - return $this->render('chapter', null, true); + $this->render('chapter', null, true); } /** @@ -46,7 +46,7 @@ class DocController extends ModuleActionController $name = ucfirst($name); $this->view->docName = $name; $this->view->title = sprintf($this->translate('%s Documentation'), $name); - return $this->render('toc', null, true); + $this->render('toc', null, true); } /** @@ -71,6 +71,6 @@ class DocController extends ModuleActionController ); $this->view->docName = $name; $this->_request->setParam('format', 'pdf'); - return $this->render('pdf', null, true); + $this->render('pdf', null, true); } } From 08bbe596790285aa7eee78a75f0b8df05a774e3d Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Tue, 9 Dec 2014 14:27:02 +0100 Subject: [PATCH 0015/2920] doc: Throw an exception if Icinga Web 2's documentation is not avaiable refs #7196 --- .../controllers/IcingawebController.php | 26 +++++++++++++++---- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/modules/doc/application/controllers/IcingawebController.php b/modules/doc/application/controllers/IcingawebController.php index d052d8268..b989bc883 100644 --- a/modules/doc/application/controllers/IcingawebController.php +++ b/modules/doc/application/controllers/IcingawebController.php @@ -10,10 +10,26 @@ class Doc_IcingawebController extends DocController { /** * Get the path to Icinga Web 2's documentation + * + * @return string + * + * @throws Zend_Controller_Action_Exception If Icinga Web 2's documentation is not available */ - protected function getDocPath() + protected function getPath() { - return $this->Config()->get('documentation', 'path', Icinga::app()->getBaseDir('doc')); + if (($path = $this->Config()->get('documentation', 'icingaweb2')) !== null) { + if (is_dir($path)) { + return $path; + } + } + $path = Icinga::app()->getBaseDir('doc'); + if (is_dir($path)) { + return $path; + } + throw new Zend_Controller_Action_Exception( + $this->translate('Documentation for Icinga Web 2 is not available'), + 404 + ); } /** @@ -21,7 +37,7 @@ class Doc_IcingawebController extends DocController */ public function tocAction() { - return $this->renderToc($this->getDocPath(), 'Icinga Web 2', 'doc/icingaweb/chapter'); + return $this->renderToc($this->getPath(), 'Icinga Web 2', 'doc/icingaweb/chapter'); } /** @@ -39,7 +55,7 @@ class Doc_IcingawebController extends DocController ); } return $this->renderChapter( - $this->getDocPath(), + $this->getPath(), $chapterId, 'doc/icingaweb/toc', 'doc/icingaweb/chapter' @@ -51,6 +67,6 @@ class Doc_IcingawebController extends DocController */ public function pdfAction() { - return $this->renderPdf($this->getDocPath(), 'Icinga Web 2', 'doc/icingaweb/chapter'); + return $this->renderPdf($this->getPath(), 'Icinga Web 2', 'doc/icingaweb/chapter'); } } From 7605076dc525832eea119eb2520abe22f8cf7a64 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Tue, 9 Dec 2014 14:28:10 +0100 Subject: [PATCH 0016/2920] doc/IcingawebController: Use sprintf for "Missing parameter x" exceptions --- modules/doc/application/controllers/IcingawebController.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/doc/application/controllers/IcingawebController.php b/modules/doc/application/controllers/IcingawebController.php index b989bc883..b51c126ae 100644 --- a/modules/doc/application/controllers/IcingawebController.php +++ b/modules/doc/application/controllers/IcingawebController.php @@ -50,7 +50,7 @@ class Doc_IcingawebController extends DocController $chapterId = $this->getParam('chapterId'); if ($chapterId === null) { throw new Zend_Controller_Action_Exception( - $this->translate('Missing parameter \'chapterId\''), + sprintf($this->translate('Missing parameter \'%s\''), 'chapterId'), 404 ); } From e901e545c3b78e376bb653dcf446b0415ed56100 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Tue, 9 Dec 2014 14:28:58 +0100 Subject: [PATCH 0017/2920] doc/IcingawebController: Do not use 'void' results --- modules/doc/application/controllers/IcingawebController.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/modules/doc/application/controllers/IcingawebController.php b/modules/doc/application/controllers/IcingawebController.php index b51c126ae..c07b65798 100644 --- a/modules/doc/application/controllers/IcingawebController.php +++ b/modules/doc/application/controllers/IcingawebController.php @@ -37,7 +37,7 @@ class Doc_IcingawebController extends DocController */ public function tocAction() { - return $this->renderToc($this->getPath(), 'Icinga Web 2', 'doc/icingaweb/chapter'); + $this->renderToc($this->getPath(), 'Icinga Web 2', 'doc/icingaweb/chapter'); } /** @@ -54,7 +54,7 @@ class Doc_IcingawebController extends DocController 404 ); } - return $this->renderChapter( + $this->renderChapter( $this->getPath(), $chapterId, 'doc/icingaweb/toc', @@ -67,6 +67,6 @@ class Doc_IcingawebController extends DocController */ public function pdfAction() { - return $this->renderPdf($this->getPath(), 'Icinga Web 2', 'doc/icingaweb/chapter'); + $this->renderPdf($this->getPath(), 'Icinga Web 2', 'doc/icingaweb/chapter'); } } From c7e6252acab649bb0a2f21a296cb13255b36dfa5 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Tue, 9 Dec 2014 14:30:10 +0100 Subject: [PATCH 0018/2920] doc: Make path to module documentations configureable refs #7196 --- .../controllers/ModuleController.php | 81 +++++++++++++------ 1 file changed, 56 insertions(+), 25 deletions(-) diff --git a/modules/doc/application/controllers/ModuleController.php b/modules/doc/application/controllers/ModuleController.php index adc46a991..12c4a9246 100644 --- a/modules/doc/application/controllers/ModuleController.php +++ b/modules/doc/application/controllers/ModuleController.php @@ -9,6 +9,40 @@ use Icinga\Module\Doc\Exception\DocException; class Doc_ModuleController extends DocController { + /** + * Get the path to a module documentation + * + * @param string $module The name of the module + * @param string $default The default path + * @param bool $suppressErrors Whether to not throw an exception if the module documentation is not + * available + * + * @return string|null Path to the documentation or null if the module documentation is not + * available and errors are suppressed + * + * @throws Zend_Controller_Action_Exception If the module documentation is not available and errors are not + * suppressed + */ + protected function getPath($module, $default, $suppressErrors = false) + { + if (($path = $this->Config()->get('documentation', 'modules')) !== null) { + $path = str_replace('{module}', $module, $path); + if (is_dir($path)) { + return $path; + } + } + if (is_dir($default)) { + return $default; + } + if ($suppressErrors) { + return null; + } + throw new Zend_Controller_Action_Exception( + sprintf($this->translate('Documentation for module \'%s\' is not available'), $module), + 404 + ); + } + /** * List modules which are enabled and having the 'doc' directory */ @@ -16,10 +50,10 @@ class Doc_ModuleController extends DocController { $moduleManager = Icinga::app()->getModuleManager(); $modules = array(); - foreach (Icinga::app()->getModuleManager()->listEnabledModules() as $enabledModule) { - $docDir = $moduleManager->getModuleDir($enabledModule, '/doc'); - if (is_dir($docDir)) { - $modules[] = $enabledModule; + foreach (Icinga::app()->getModuleManager()->listEnabledModules() as $module) { + $path = $this->getPath($module, $moduleManager->getModuleDir($module, '/doc'), true); + if ($path !== null) { + $modules[] = $module; } } $this->view->modules = $modules; @@ -63,16 +97,15 @@ class Doc_ModuleController extends DocController */ public function tocAction() { - $moduleName = $this->getParam('moduleName'); - $this->assertModuleEnabled($moduleName); - $this->view->moduleName = $moduleName; - $moduleManager = Icinga::app()->getModuleManager(); + $module = $this->getParam('moduleName'); + $this->assertModuleEnabled($module); + $this->view->moduleName = $module; try { return $this->renderToc( - $moduleManager->getModuleDir($moduleName, '/doc'), - $moduleName, + $this->getPath($module, Icinga::app()->getModuleManager()->getModuleDir($module, '/doc')), + $module, 'doc/module/chapter', - array('moduleName' => $moduleName) + array('moduleName' => $module) ); } catch (DocException $e) { throw new Zend_Controller_Action_Exception($e->getMessage(), 404); @@ -88,24 +121,23 @@ class Doc_ModuleController extends DocController */ public function chapterAction() { - $moduleName = $this->getParam('moduleName'); - $this->assertModuleEnabled($moduleName); + $module = $this->getParam('moduleName'); + $this->assertModuleEnabled($module); $chapterId = $this->getParam('chapterId'); if ($chapterId === null) { throw new Zend_Controller_Action_Exception( - $this->translate('Missing parameter \'chapterId\''), + sprintf($this->translate('Missing parameter \'%s\''), 'chapterId'), 404 ); } - $this->view->moduleName = $moduleName; - $moduleManager = Icinga::app()->getModuleManager(); + $this->view->moduleName = $module; try { return $this->renderChapter( - $moduleManager->getModuleDir($moduleName, '/doc'), + $this->getPath($module, Icinga::app()->getModuleManager()->getModuleDir($module, '/doc')), $chapterId, - $this->_helper->url->url(array('moduleName' => $moduleName), 'doc/module/toc'), + $this->_helper->url->url(array('moduleName' => $module), 'doc/module/toc'), 'doc/module/chapter', - array('moduleName' => $moduleName) + array('moduleName' => $module) ); } catch (DocException $e) { throw new Zend_Controller_Action_Exception($e->getMessage(), 404); @@ -119,14 +151,13 @@ class Doc_ModuleController extends DocController */ public function pdfAction() { - $moduleName = $this->getParam('moduleName'); - $this->assertModuleEnabled($moduleName); - $moduleManager = Icinga::app()->getModuleManager(); + $module = $this->getParam('moduleName'); + $this->assertModuleEnabled($module); return $this->renderPdf( - $moduleManager->getModuleDir($moduleName, '/doc'), - $moduleName, + $this->getPath($module, Icinga::app()->getModuleManager()->getModuleDir($module, '/doc')), + $module, 'doc/module/chapter', - array('moduleName' => $moduleName) + array('moduleName' => $module) ); } } From 3120a0c090b7d54775cef12d93c772e2835fc122 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Tue, 9 Dec 2014 14:30:57 +0100 Subject: [PATCH 0019/2920] doc/ModuleController: Do not use 'void' results --- modules/doc/application/controllers/ModuleController.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/modules/doc/application/controllers/ModuleController.php b/modules/doc/application/controllers/ModuleController.php index 12c4a9246..cf9ddea16 100644 --- a/modules/doc/application/controllers/ModuleController.php +++ b/modules/doc/application/controllers/ModuleController.php @@ -101,7 +101,7 @@ class Doc_ModuleController extends DocController $this->assertModuleEnabled($module); $this->view->moduleName = $module; try { - return $this->renderToc( + $this->renderToc( $this->getPath($module, Icinga::app()->getModuleManager()->getModuleDir($module, '/doc')), $module, 'doc/module/chapter', @@ -132,7 +132,7 @@ class Doc_ModuleController extends DocController } $this->view->moduleName = $module; try { - return $this->renderChapter( + $this->renderChapter( $this->getPath($module, Icinga::app()->getModuleManager()->getModuleDir($module, '/doc')), $chapterId, $this->_helper->url->url(array('moduleName' => $module), 'doc/module/toc'), @@ -153,7 +153,7 @@ class Doc_ModuleController extends DocController { $module = $this->getParam('moduleName'); $this->assertModuleEnabled($module); - return $this->renderPdf( + $this->renderPdf( $this->getPath($module, Icinga::app()->getModuleManager()->getModuleDir($module, '/doc')), $module, 'doc/module/chapter', From d2a7254a37ebdeefd3b176d69f66fc54582591a6 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Tue, 9 Dec 2014 14:55:24 +0100 Subject: [PATCH 0020/2920] doc: Prefer "root" doc path over configured path If the "root" doc path, i.e. application/doc exists, it is preferred over the configured one. refs #4075 --- .../doc/application/controllers/IcingawebController.php | 8 ++++---- modules/doc/application/controllers/ModuleController.php | 6 +++--- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/modules/doc/application/controllers/IcingawebController.php b/modules/doc/application/controllers/IcingawebController.php index c07b65798..60c5da5ee 100644 --- a/modules/doc/application/controllers/IcingawebController.php +++ b/modules/doc/application/controllers/IcingawebController.php @@ -17,15 +17,15 @@ class Doc_IcingawebController extends DocController */ protected function getPath() { + $path = Icinga::app()->getBaseDir('doc'); + if (is_dir($path)) { + return $path; + } if (($path = $this->Config()->get('documentation', 'icingaweb2')) !== null) { if (is_dir($path)) { return $path; } } - $path = Icinga::app()->getBaseDir('doc'); - if (is_dir($path)) { - return $path; - } throw new Zend_Controller_Action_Exception( $this->translate('Documentation for Icinga Web 2 is not available'), 404 diff --git a/modules/doc/application/controllers/ModuleController.php b/modules/doc/application/controllers/ModuleController.php index cf9ddea16..a4d14cf61 100644 --- a/modules/doc/application/controllers/ModuleController.php +++ b/modules/doc/application/controllers/ModuleController.php @@ -25,15 +25,15 @@ class Doc_ModuleController extends DocController */ protected function getPath($module, $default, $suppressErrors = false) { + if (is_dir($default)) { + return $default; + } if (($path = $this->Config()->get('documentation', 'modules')) !== null) { $path = str_replace('{module}', $module, $path); if (is_dir($path)) { return $path; } } - if (is_dir($default)) { - return $default; - } if ($suppressErrors) { return null; } From bca2335aa341836f1c102a8ba7e3bcf90755590c Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Tue, 9 Dec 2014 14:58:18 +0100 Subject: [PATCH 0021/2920] doc: Add module documentation --- modules/doc/doc/1-module-documentation.md | 59 ++++++++++++++++++++++ modules/doc/public/img/doc/markdown.png | Bin 0 -> 2180 bytes 2 files changed, 59 insertions(+) create mode 100644 modules/doc/doc/1-module-documentation.md create mode 100644 modules/doc/public/img/doc/markdown.png diff --git a/modules/doc/doc/1-module-documentation.md b/modules/doc/doc/1-module-documentation.md new file mode 100644 index 000000000..968dd32d7 --- /dev/null +++ b/modules/doc/doc/1-module-documentation.md @@ -0,0 +1,59 @@ +# Writing Module Documentation + +![Markdown](/img/doc/doc/markdown.png) + +Icinga Web 2 is capable of viewing your module's documentation, if the documentation is written in +[Markdown](http://en.wikipedia.org/wiki/Markdown). Please refer to +[Markdown Syntax Documentation](http://daringfireball.net/projects/markdown/syntax) for Markdown's formatting syntax. + +## Where to Put Module Documentation? + +By default, your module's Markdown documentation files must be placed in the `doc` directory beneath your module's root +directory, e.g.: + + example-module/doc + +## Chapters + +Each Markdown documentation file represents a chapter of your module's documentation. The first found heading inside +each file is the chapter's title. The order of chapters is based on the case insensitive "Natural Order" of your files' +names. Natural Order means that the file names are ordered in the way which seems natural to humans. +It is best practice to prefix Markdown documentation file names with numbers to ensure that they appear in the correct +order, e.g.: + + 1-about.md + 2-installation.md + 3-configuration.md + +## Table Of Contents + +The table of contents for your module's documentation is auto-generated based on all found headings inside each +Markdown documentation file. + +## Linking Between Headings + +For linking between headings, place an anchor where you want to link to, e.g.: + + # Heading + +Now you can reference the anchor either in the same or **in another** Markdown documentation file, e.g.: + + This is a link to [Heading](#heading). + +## Including Images + +Images must placed in the `img` directory beneath your module's `public` directory, e.g.: + + example-module/public/img/doc + +Module images can be accessed using the following URL: + + {baseURL}/img/{moduleName}/{file} e.g. icingaweb/img/example-module/doc/example.png + +Markdown's image syntax is very similar to Markdown's link syntax, but prefixed with an exclamation mark, e.g.: + + ![Alt text](http://path/to/img.png "Optional Title") + +URLs to images inside your Markdown documentation files must be specified without the base URL, e.g.: + + ![Example](/img/example-module/doc/example.png) diff --git a/modules/doc/public/img/doc/markdown.png b/modules/doc/public/img/doc/markdown.png new file mode 100644 index 0000000000000000000000000000000000000000..93e729bc77ca37a36b97509e4cd552e1033973f9 GIT binary patch literal 2180 zcmaJ@3pCSxAD^wcY}Rs*WtD5G;fWbxQ?n;Z>?w^%R6I%eyW|avwnDTzlpgZBtwM^W z$&fc$p0XlZVkGpJ%9=})+uYyj>FGV^J@0wX@BDth^Z8yr-|z2ozQ11@)qNKVp@)D# zAShQC=Y8^7DDMnqMfn(SHgsM-DIVRk%Neq~(%AL4Ga(RVJ6Go&p0RnOeIBWSURr{2 zV9NH=6SaIdWsU6zYpF*>w^r?SPJ8+5^CpE~4C*p6D4tIbHc`%DUNAB?veYywr;e#^ zaz?4Cq&-PC+*Haouxvm2{sx1AYzT)DwFiqExY&4%=43HC+dds?#|>&h%xi^ zx;6p^oiWdh=I8VE`M9QZo$(Po7!aOhnQsZFP=G)5(%X|~By~=Fx_lO@0(H6fcjZ<{(!+q{M7 zL%a|jm|;W^eX>Z+2pb&>WxVuf6&!N%q75st9Gx}3Q_&xzMt`HSqJro z=%-qo`Uky~8XXLd8(}89bD>p%pY+T+uzIl$FBBc8OCTI?yA%ZPf+E(Vaz}doW~Y<1 zX6lV+Kiz{{drp-KLw>pkdUMIiS$`+v#&ciXRrd?z5=^O#DOo^RZ*8I8 zn39t$x64;()pZw=%nK<6kNl+3e3*sOdh~bFR-Jm$nF9xz(E1$M5aT54{a2{h_-um5 z*pMM*Y^a?KloXT@o!8nscnXD1qV_Gq*X9~?3AHgBx5Uc)<1OEMZGZ>U<7{6jW}-44 zCu#gV*-1_ISDtx5^4Dr}r{*u8E_V#_k#Hg)i9hn2Z#rPJI({T93Mgt*{`&UNvsduX z6>9z0^WO{=g$R!UnR$(^OeBApgWT8=!K7xMD$lkUSUqunHu{krPhb%(-@D)M@dS_^ z@79xSB?80v@7rlJ3*qURsglq4EH>5lf{`b91>MqLwvo{Ig8SE?`z7|U5gl1g7AGMK zAaY(;bgIhSlLfb?=4^7&MlWBHFPm;H=6B4EDTZsxW}1eZKD-a_G zBF7ze){N?3Hl+mm>0)){4D%{1oTXPnaSEa(MUgXqnTs6JD&A;X7-0p&3b zTyyPGyO}!gaytCE(LYMpSXr-~5CY`_WJmr<$HVsl1IhJM3_j5_RbTH?+!sPh7ml>q z_f)wiTRH2-PKn=R$0^L8@3IOzaNB7JYS965^17O&NfDrG;hPv0`kK3sVSvM!g>IL# zihy#FTo|?@w6VmR6{(_{9Hud4omqvB691u{3OzzgPnVT2qXgP0j`Xlb?7i7Z<*~~W zvV}fIpmA^{_iLNcbN<{eUE^ z&}U^G8;+L%=m6x--fhz~VUtnK@2uGsJ9%{8-hkkt7G3QtF>2{~K{ucQ2 zoI6vwN`gZ# zKMW;V<~MuSy6m~FJT&>>Y0$tit47L`8RomPY+Pl%{Qa=!pJkY0bPOxQ%wd4)#8@WZ zpK0IIX;_J$X3oI6E)e$l!yk9t!(QQh3j((zbGSW7u-de3;TBTxpAw02RWW#WF@b|}A1v5Hkbm`Ii v0@|%qBtaQNUf$8&Gpzv{H;#JK<}AKdSfrDxI5YBZ1;mx&?tE`&z`1_|&HV@> literal 0 HcmV?d00001 From 28f08078f05e6f422d72a55d14b5a7373aa35ed8 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Tue, 9 Dec 2014 14:58:39 +0100 Subject: [PATCH 0022/2920] doc: Add module config.ini for packaging resolves #7196 --- packages/files/modules/doc/config.ini | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 packages/files/modules/doc/config.ini diff --git a/packages/files/modules/doc/config.ini b/packages/files/modules/doc/config.ini new file mode 100644 index 000000000..80df20784 --- /dev/null +++ b/packages/files/modules/doc/config.ini @@ -0,0 +1,3 @@ +[documentation] +icingaweb2 = /usr/share/doc/icingaweb2/markdown +modules = /usr/share/doc/icingaweb2/modules/{module}/markdown From 7d00f68660af4f54652e1f7bfd7941c9ca9a20d2 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Tue, 9 Dec 2014 16:27:04 +0100 Subject: [PATCH 0023/2920] Revert "Load core modules also when bootstrapping the CLI" This reverts commit f12473d34bf55b2acea2a196d5455ad851dbf86b. The CLI must not load core modules, i.e. setup. --- library/Icinga/Application/Cli.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/library/Icinga/Application/Cli.php b/library/Icinga/Application/Cli.php index abf46262f..7d1a98eec 100644 --- a/library/Icinga/Application/Cli.php +++ b/library/Icinga/Application/Cli.php @@ -43,8 +43,7 @@ class Cli extends ApplicationBootstrap ->parseBasicParams() ->setupLogger() ->setupResourceFactory() - ->setupModuleManager() - ->loadCoreModules(); + ->setupModuleManager(); } protected function setupLogging() From 916868a051755bdacc899c9d61557b1d11e54014 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Tue, 9 Dec 2014 16:28:05 +0100 Subject: [PATCH 0024/2920] Revert "Add support for "core" modules and make the setup module such a module" This reverts commit 8af13f564b3f8e69c2c1abcda5d7e2e5266c3c7d. The setup module must only be loaded when necessary not always. --- .../Application/ApplicationBootstrap.php | 15 --------- .../Icinga/Application/Modules/Manager.php | 32 ++----------------- library/Icinga/Application/Web.php | 1 - .../Util/GettextTranslationHelper.php | 2 +- 4 files changed, 3 insertions(+), 47 deletions(-) diff --git a/library/Icinga/Application/ApplicationBootstrap.php b/library/Icinga/Application/ApplicationBootstrap.php index 7f1667e5b..733cdbf83 100644 --- a/library/Icinga/Application/ApplicationBootstrap.php +++ b/library/Icinga/Application/ApplicationBootstrap.php @@ -378,21 +378,6 @@ abstract class ApplicationBootstrap return $this; } - /** - * Load all core modules - * - * @return self - */ - protected function loadCoreModules() - { - try { - $this->moduleManager->loadCoreModules(); - } catch (NotReadableError $e) { - Logger::error(new IcingaException('Cannot load core modules. An exception was thrown:', $e)); - } - return $this; - } - /** * Load all enabled modules * diff --git a/library/Icinga/Application/Modules/Manager.php b/library/Icinga/Application/Modules/Manager.php index 6469d3929..7ee2461f9 100644 --- a/library/Icinga/Application/Modules/Manager.php +++ b/library/Icinga/Application/Modules/Manager.php @@ -68,18 +68,6 @@ class Manager */ private $modulePaths = array(); - /** - * The core modules - * - * Core modules do not need to be enabled to load and cannot be disabled - * by the user. This must not be writable programmatically! - * - * @var array - */ - private $coreModules = array( - 'setup' - ); - /** * Create a new instance of the module manager * @@ -170,21 +158,7 @@ class Manager } /** - * Try to set all core modules in loaded state - * - * @return self - * @see Manager::loadModule() - */ - public function loadCoreModules() - { - foreach ($this->coreModules as $name) { - $this->loadModule($name); - } - return $this; - } - - /** - * Try to set all enabled modules in loaded state + * Try to set all enabled modules in loaded sate * * @return self * @see Manager::loadModule() @@ -239,8 +213,6 @@ class Manager 'Cannot enable module "%s". Module is not installed.', $name ); - } elseif (in_array($name, $this->coreModules)) { - return $this; } clearstatcache(true); @@ -458,7 +430,7 @@ class Manager } $installed = $this->listInstalledModules(); - foreach (array_diff($installed, $this->coreModules) as $name) { + foreach ($installed as $name) { $info[$name] = (object) array( 'name' => $name, 'path' => $this->installedBaseDirs[$name], diff --git a/library/Icinga/Application/Web.php b/library/Icinga/Application/Web.php index 37ec5138a..a21f21025 100644 --- a/library/Icinga/Application/Web.php +++ b/library/Icinga/Application/Web.php @@ -104,7 +104,6 @@ class Web extends ApplicationBootstrap ->setupZendMvc() ->setupFormNamespace() ->setupModuleManager() - ->loadCoreModules() ->loadEnabledModules() ->setupRoute() ->setupPagination(); diff --git a/modules/translation/library/Translation/Util/GettextTranslationHelper.php b/modules/translation/library/Translation/Util/GettextTranslationHelper.php index 0d5a950e1..5702def85 100644 --- a/modules/translation/library/Translation/Util/GettextTranslationHelper.php +++ b/modules/translation/library/Translation/Util/GettextTranslationHelper.php @@ -101,7 +101,7 @@ class GettextTranslationHelper */ public function __construct(ApplicationBootstrap $bootstrap, $locale) { - $this->moduleMgr = $bootstrap->getModuleManager()->loadCoreModules()->loadEnabledModules(); + $this->moduleMgr = $bootstrap->getModuleManager()->loadEnabledModules(); $this->appDir = $bootstrap->getApplicationDir(); $this->locale = $locale; } From d0e8718d619f7a6671e23aa23a6cc9c7e2d348e4 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Tue, 9 Dec 2014 16:56:06 +0100 Subject: [PATCH 0025/2920] packages: Rename icingaweb.conf to icingaweb2.conf --- packages/files/apache/{icingaweb.conf => icingaweb2.conf} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename packages/files/apache/{icingaweb.conf => icingaweb2.conf} (100%) diff --git a/packages/files/apache/icingaweb.conf b/packages/files/apache/icingaweb2.conf similarity index 100% rename from packages/files/apache/icingaweb.conf rename to packages/files/apache/icingaweb2.conf From ef00765ff0828c9225c97f353fbcb57b20245c8e Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Wed, 10 Dec 2014 09:29:38 +0100 Subject: [PATCH 0026/2920] packages: Use 'icingaweb2' as the web path refs #4075 --- packages/files/apache/icingaweb2.conf | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/files/apache/icingaweb2.conf b/packages/files/apache/icingaweb2.conf index 2c52b73e3..6bf0b7a66 100644 --- a/packages/files/apache/icingaweb2.conf +++ b/packages/files/apache/icingaweb2.conf @@ -1,4 +1,4 @@ -Alias /icingaweb "/usr/share/icingaweb2/public" +Alias /icingaweb2 "/usr/share/icingaweb2/public" Options SymLinksIfOwnerMatch @@ -23,7 +23,7 @@ Alias /icingaweb "/usr/share/icingaweb2/public" RewriteEngine on - RewriteBase /icingaweb/ + RewriteBase /icingaweb2/ RewriteCond %{REQUEST_FILENAME} -s [OR] RewriteCond %{REQUEST_FILENAME} -l [OR] RewriteCond %{REQUEST_FILENAME} -d From 2b5fe7baf4a8e0cd50eefe834e061c8dd5696d87 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Wed, 10 Dec 2014 09:30:12 +0100 Subject: [PATCH 0027/2920] Set default config dir to '/etc/icingaweb2' --- library/Icinga/Application/ApplicationBootstrap.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library/Icinga/Application/ApplicationBootstrap.php b/library/Icinga/Application/ApplicationBootstrap.php index 733cdbf83..5e2a787c7 100644 --- a/library/Icinga/Application/ApplicationBootstrap.php +++ b/library/Icinga/Application/ApplicationBootstrap.php @@ -133,7 +133,7 @@ abstract class ApplicationBootstrap if (array_key_exists('ICINGAWEB_CONFIGDIR', $_SERVER)) { $configDir = $_SERVER['ICINGAWEB_CONFIGDIR']; } else { - $configDir = '/etc/icingaweb'; + $configDir = '/etc/icingaweb2'; } } $canonical = realpath($configDir); From 613cbae5bfc7d278da24923ab3970c43a289cf95 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Wed, 10 Dec 2014 09:30:35 +0100 Subject: [PATCH 0028/2920] packages: Fix base dir path in the icingacli refs #4075 --- packages/files/bin/icingacli | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/files/bin/icingacli b/packages/files/bin/icingacli index 10b4857aa..5b41e4e8c 100755 --- a/packages/files/bin/icingacli +++ b/packages/files/bin/icingacli @@ -3,4 +3,4 @@ require_once '/usr/share/php/Icinga/Application/Cli.php'; -Icinga\Application\Cli::start('/usr/share/icingaweb')->dispatch(); +Icinga\Application\Cli::start('/usr/share/icingaweb2')->dispatch(); From 888fa90fe209edcd19b278ced262e70c5a638f6a Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Wed, 10 Dec 2014 09:31:37 +0100 Subject: [PATCH 0029/2920] Fix typo in PHPDoc in EmbeddedWeb --- library/Icinga/Application/EmbeddedWeb.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library/Icinga/Application/EmbeddedWeb.php b/library/Icinga/Application/EmbeddedWeb.php index 23cb365f0..72a4ec919 100644 --- a/library/Icinga/Application/EmbeddedWeb.php +++ b/library/Icinga/Application/EmbeddedWeb.php @@ -9,7 +9,7 @@ require_once dirname(__FILE__) . '/ApplicationBootstrap.php'; use Icinga\Exception\ProgrammingError; /** - * Use this if you want to make use of Icinga funtionality in other web projects + * Use this if you want to make use of Icinga functionality in other web projects * * Usage example: * From 68e460b5d12e468e95ad058f649153fa96a59cdd Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Wed, 10 Dec 2014 09:32:02 +0100 Subject: [PATCH 0030/2920] Remove unused use in EmbeddedWeb --- library/Icinga/Application/EmbeddedWeb.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/library/Icinga/Application/EmbeddedWeb.php b/library/Icinga/Application/EmbeddedWeb.php index 72a4ec919..b9ed067a2 100644 --- a/library/Icinga/Application/EmbeddedWeb.php +++ b/library/Icinga/Application/EmbeddedWeb.php @@ -6,8 +6,6 @@ namespace Icinga\Application; require_once dirname(__FILE__) . '/ApplicationBootstrap.php'; -use Icinga\Exception\ProgrammingError; - /** * Use this if you want to make use of Icinga functionality in other web projects * From 311ebfbcbac2a961c41ce12c1d988fc37c754a01 Mon Sep 17 00:00:00 2001 From: Carlos Cesario Date: Wed, 10 Dec 2014 10:44:45 -0200 Subject: [PATCH 0031/2920] Add support to untranslated strings Add support to untranslated strings refs #7988 --- .../application/controllers/AlertsummaryController.php | 6 +++--- .../monitoring/application/controllers/ListController.php | 2 +- .../monitoring/application/views/scripts/list/hosts.phtml | 2 +- .../application/views/scripts/list/notifications.phtml | 6 +++--- .../monitoring/application/views/scripts/process/info.phtml | 4 ++-- 5 files changed, 10 insertions(+), 10 deletions(-) diff --git a/modules/monitoring/application/controllers/AlertsummaryController.php b/modules/monitoring/application/controllers/AlertsummaryController.php index 75f0fc1fe..fdb1ec99f 100644 --- a/modules/monitoring/application/controllers/AlertsummaryController.php +++ b/modules/monitoring/application/controllers/AlertsummaryController.php @@ -193,11 +193,11 @@ class Monitoring_AlertsummaryController extends Controller $out = new stdClass(); if ($yesterday === $today) { - $out->trend = 'unchanged'; + $out->trend = $this->translate('unchanged'); } elseif ($yesterday > $today) { - $out->trend = 'down'; + $out->trend = $this->translate('down'); } else { - $out->trend = 'up'; + $out->trend = $this->translate('up'); } if ($yesterday <= 0) { diff --git a/modules/monitoring/application/controllers/ListController.php b/modules/monitoring/application/controllers/ListController.php index 4f92a25b1..35dcd811f 100644 --- a/modules/monitoring/application/controllers/ListController.php +++ b/modules/monitoring/application/controllers/ListController.php @@ -605,7 +605,7 @@ class Monitoring_ListController extends Controller $this->filterQuery($query); $this->setupSortControl(array( - 'timestamp' => 'Occurence' + 'timestamp' => $this->translate('Occurence') )); $this->view->history = $query->paginate(); } diff --git a/modules/monitoring/application/views/scripts/list/hosts.phtml b/modules/monitoring/application/views/scripts/list/hosts.phtml index 588d39712..d7d700185 100644 --- a/modules/monitoring/application/views/scripts/list/hosts.phtml +++ b/modules/monitoring/application/views/scripts/list/hosts.phtml @@ -42,7 +42,7 @@ if ($hosts->count() === 0) { util()->getHostStateName($host->host_state)); - $hostLink = $this->href('monitoring/host/show', array('host' => $host->host_name)); + $hostLink = $this->href('monitoring/host/show', array('host' => $host->host_display_name)); $icons = array(); if (! $host->host_handled && $host->host_state > 0){ diff --git a/modules/monitoring/application/views/scripts/list/notifications.phtml b/modules/monitoring/application/views/scripts/list/notifications.phtml index 365d32f56..28c71c0b8 100644 --- a/modules/monitoring/application/views/scripts/list/notifications.phtml +++ b/modules/monitoring/application/views/scripts/list/notifications.phtml @@ -56,7 +56,7 @@ foreach ($notifications as $notification): - service ?> on host ?> + translate('%s on %s'), "$notification->service", $notification->host); ?> host ?> @@ -65,10 +65,10 @@ foreach ($notifications as $notification):
contact): ?> - Sent to href( 'monitoring/show/contact', array('contact' => $notification->notification_contact) - ) ?>">escape($notification->notification_contact) ?> + )\">$this->escape($notification->notification_contact)"); ?> diff --git a/modules/monitoring/application/views/scripts/process/info.phtml b/modules/monitoring/application/views/scripts/process/info.phtml index 02b8eeb80..92bb6cb63 100644 --- a/modules/monitoring/application/views/scripts/process/info.phtml +++ b/modules/monitoring/application/views/scripts/process/info.phtml @@ -26,11 +26,11 @@ $cp = $this->checkPerformance()->create($this->checkperformance); translate('Last Status Update'); ?> - timeSince($this->programStatus->status_update_time) ?> ago + translate('%s ago'), $this->timeSince($this->programStatus->status_update_time)); ?> translate('Last External Command Check'); ?> - timeSince($this->programStatus->last_command_check) ?> ago + translate('%s ago'), $this->timeSince($this->programStatus->last_command_check)); ?> translate('Last Log File Rotation'); ?> From eca176f19135d5d52c9622c2f5a31813eb975d6c Mon Sep 17 00:00:00 2001 From: Carlos Cesario Date: Wed, 10 Dec 2014 11:30:59 -0200 Subject: [PATCH 0032/2920] Fix wrong change Fix wrong change host->host_display_name to host->host_name. refs #7988 --- modules/monitoring/application/views/scripts/list/hosts.phtml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/monitoring/application/views/scripts/list/hosts.phtml b/modules/monitoring/application/views/scripts/list/hosts.phtml index d7d700185..588d39712 100644 --- a/modules/monitoring/application/views/scripts/list/hosts.phtml +++ b/modules/monitoring/application/views/scripts/list/hosts.phtml @@ -42,7 +42,7 @@ if ($hosts->count() === 0) { util()->getHostStateName($host->host_state)); - $hostLink = $this->href('monitoring/host/show', array('host' => $host->host_display_name)); + $hostLink = $this->href('monitoring/host/show', array('host' => $host->host_name)); $icons = array(); if (! $host->host_handled && $host->host_state > 0){ From d4bbd3a323f8db52009a1405c9a416979aa3f010 Mon Sep 17 00:00:00 2001 From: Carlos Cesario Date: Tue, 16 Dec 2014 09:31:20 -0200 Subject: [PATCH 0033/2920] Add more support to plural strings translation Add more support to plural strings translation refs #8092 --- .../application/views/scripts/hosts/show.phtml | 17 +++++++++++------ .../scripts/multi/components/comments.phtml | 4 ++-- .../views/scripts/services/show.phtml | 8 ++++---- 3 files changed, 17 insertions(+), 12 deletions(-) diff --git a/modules/monitoring/application/views/scripts/hosts/show.phtml b/modules/monitoring/application/views/scripts/hosts/show.phtml index 6ab717635..8ae19aa0b 100644 --- a/modules/monitoring/application/views/scripts/hosts/show.phtml +++ b/modules/monitoring/application/views/scripts/hosts/show.phtml @@ -6,7 +6,7 @@ translate('No hosts matching the filter') ?>
- translate('Hosts (%u)'), array_sum(array_values($hostStates))) ?> + translatePlural('Host (%u)', 'Hosts (%u)', array_sum(array_values($hostStates))), array_sum(array_values($hostStates))) ?>
hostStatesPieChart ?> @@ -18,9 +18,14 @@

- translate('%u Hosts'), - count($objects)) - ?> + translatePlural( + '%u Host', + '%u Hosts', + count($objects) + ), + count($objects) + ) ?>

@@ -102,7 +107,7 @@ icon('plug') ?> - translate(sprintf('%u hosts are in downtime', count($objectsInDowntime))) ?> + translatePlural('%u host is in downtime', '%u hosts are in downtime', count($objectsInDowntime)),count($objectsInDowntime)) ?> @@ -112,7 +117,7 @@ icon('comment') ?> - translate(sprintf('%u comments', count($objects->getComments()))) ?> + translatePlural('%u comment', '%u comments', count($objects->getComments())), count($objects->getComments())) ?> diff --git a/modules/monitoring/application/views/scripts/multi/components/comments.phtml b/modules/monitoring/application/views/scripts/multi/components/comments.phtml index f0b262c9d..f477cd953 100644 --- a/modules/monitoring/application/views/scripts/multi/components/comments.phtml +++ b/modules/monitoring/application/views/scripts/multi/components/comments.phtml @@ -3,7 +3,7 @@ $objectName = $this->is_service ? 'Services' : 'Hosts'; ?> - translate('Comments') ?> + translatePlural('%u Comment', '%u Comments', count($comments)), count($comments)) ?> icon('cancel') @@ -20,6 +20,6 @@ $objectName = $this->is_service ? 'Services' : 'Hosts'; 'monitoring/list/comments', array('comment_internal_id' => '(' . implode('|', $this->comments) . ')') ); - ?>"> comments . + ?>"> translatePlural('%u comment', '%u comments', count($comments)), count($comments)) ?>. diff --git a/modules/monitoring/application/views/scripts/services/show.phtml b/modules/monitoring/application/views/scripts/services/show.phtml index 18071c152..e8a4c70a1 100644 --- a/modules/monitoring/application/views/scripts/services/show.phtml +++ b/modules/monitoring/application/views/scripts/services/show.phtml @@ -8,7 +8,7 @@
- translate('Services (%u)'), array_sum(array_values($serviceStates))) ?> + translatePlural('Service (%u)', 'Services (%u)', array_sum(array_values($serviceStates))), array_sum(array_values($serviceStates))) ?>
serviceStatesPieChart ?> @@ -22,7 +22,7 @@
- translate('Hosts (%u)'), array_sum(array_values($hostStates))) ?> + translatePlural('Host (%u)', 'Hosts (%u)', array_sum(array_values($hostStates))), array_sum(array_values($hostStates))) ?>
hostStatesPieChart ?> @@ -114,7 +114,7 @@ icon('plug') ?> - translate(sprintf('%u services are in downtime', count($objectsInDowntime))) ?> + translatePlural('%u service is in downtime', '%u services are in downtime', count($objectsInDowntime)), count($objectsInDowntime)) ?> @@ -124,7 +124,7 @@ icon('comment') ?> - translate(sprintf('%u comments', count($objects->getComments()))) ?> + translatePlural('%u comment', '%u comments', count($objects->getComments())), count($objects->getComments())) ?> From 2f3667aa3dba85224483ed48e324b4a27f09844a Mon Sep 17 00:00:00 2001 From: Carlos Cesario Date: Wed, 17 Dec 2014 10:00:15 -0200 Subject: [PATCH 0034/2920] Use hosts link instead services link Use hosts link instead services link to show hosts group. refs #7259 --- .../monitoring/application/views/scripts/list/hostgroups.phtml | 2 +- .../application/views/scripts/show/components/hostgroups.phtml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/monitoring/application/views/scripts/list/hostgroups.phtml b/modules/monitoring/application/views/scripts/list/hostgroups.phtml index a15b5be7e..0e21dc3ee 100644 --- a/modules/monitoring/application/views/scripts/list/hostgroups.phtml +++ b/modules/monitoring/application/views/scripts/list/hostgroups.phtml @@ -79,7 +79,7 @@ - + hostgroup; ?> diff --git a/modules/monitoring/application/views/scripts/show/components/hostgroups.phtml b/modules/monitoring/application/views/scripts/show/components/hostgroups.phtml index 40db3e5c4..165df627a 100644 --- a/modules/monitoring/application/views/scripts/show/components/hostgroups.phtml +++ b/modules/monitoring/application/views/scripts/show/components/hostgroups.phtml @@ -4,7 +4,7 @@ if (empty($object->hostgroups)) return; $list = array(); foreach ($object->hostgroups as $name => $alias) { - $list[] = $this->qlink($alias, 'monitoring/list/services', array( + $list[] = $this->qlink($alias, 'monitoring/list/hosts', array( 'hostgroup' => $name )); } From 8728b3f12596f7ee4315d26c7cd670a91ce336bf Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Thu, 18 Dec 2014 17:17:59 +0100 Subject: [PATCH 0035/2920] puppet: Add user 'vagrant' to group 'icingaweb' --- .puppet/manifests/site.pp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.puppet/manifests/site.pp b/.puppet/manifests/site.pp index 77ebfa0a7..08120d911 100644 --- a/.puppet/manifests/site.pp +++ b/.puppet/manifests/site.pp @@ -12,4 +12,6 @@ node default { file { '/etc/profile.d/env.sh': source => 'puppet:////vagrant/.puppet/files/etc/profile.d/env.sh' } + @user { vagrant: ensure => present } + User <| title == vagrant |> { groups +> icingaweb } } From 4dfac2839303178a101d43488dd57d846988471d Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Thu, 18 Dec 2014 17:21:06 +0100 Subject: [PATCH 0036/2920] lib: Fix PHPDoc of Form::setOnSuccess() --- library/Icinga/Web/Form.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library/Icinga/Web/Form.php b/library/Icinga/Web/Form.php index 37d8789fe..647be721d 100644 --- a/library/Icinga/Web/Form.php +++ b/library/Icinga/Web/Form.php @@ -147,7 +147,7 @@ class Form extends Zend_Form /** * Set a callback that is called instead of this form's onSuccess method * - * It is called using the following signature: (Request $request, Form $form). + * It is called using the following signature: (Form $this). * * @param callable $onSuccess Callback * From 1468ed0a1979574ff20d859cd7f4f6128b93d2b2 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Thu, 18 Dec 2014 17:23:54 +0100 Subject: [PATCH 0037/2920] lib: Add separator parameter to String::cname() --- library/Icinga/Util/String.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/library/Icinga/Util/String.php b/library/Icinga/Util/String.php index 0bebb06e7..248ab0d34 100644 --- a/library/Icinga/Util/String.php +++ b/library/Icinga/Util/String.php @@ -23,16 +23,17 @@ class String } /** - * Uppercase the first character of each word in a string assuming and removing the underscore as word separator + * Uppercase the first character of each word in a string * * Converts 'first_name' to 'firstName' for example. * * @param string $name + * @param string $separator Word separator * * @return string */ - public static function cname($name) + public static function cname($name, $separator = '_') { - return str_replace(' ', '', ucwords(str_replace('_', ' ', strtolower($name)))); + return str_replace(' ', '', ucwords(str_replace($separator, ' ', strtolower($name)))); } } From b0ab6c3a768f4a20a01676eff8520bc9aaf593ce Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Fri, 19 Dec 2014 10:43:14 +0100 Subject: [PATCH 0038/2920] monitoring: Remove css class 'control-group' from the expire time element This CSS class does no longer exist. --- .../forms/Command/Object/AcknowledgeProblemCommandForm.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/monitoring/application/forms/Command/Object/AcknowledgeProblemCommandForm.php b/modules/monitoring/application/forms/Command/Object/AcknowledgeProblemCommandForm.php index 3456e1bfb..25ac76c25 100644 --- a/modules/monitoring/application/forms/Command/Object/AcknowledgeProblemCommandForm.php +++ b/modules/monitoring/application/forms/Command/Object/AcknowledgeProblemCommandForm.php @@ -104,7 +104,7 @@ class AcknowledgeProblemCommandForm extends ObjectsCommandForm array( 'decorators' => array( 'FormElements', - array('HtmlTag', array('tag' => 'div', 'class' => 'control-group')) + array('HtmlTag', array('tag' => 'div')) ) ) ); From fa226f261e1d1f3094fd7299d136afab45eb2e3b Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Fri, 19 Dec 2014 10:45:23 +0100 Subject: [PATCH 0039/2920] monitoring: Remove css class 'control-group' from date and time elements in the schedule downtime command form This CSS class does no longer exist. --- .../Command/Object/ScheduleServiceDowntimeCommandForm.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/monitoring/application/forms/Command/Object/ScheduleServiceDowntimeCommandForm.php b/modules/monitoring/application/forms/Command/Object/ScheduleServiceDowntimeCommandForm.php index 9fd86a82b..9961d4b65 100644 --- a/modules/monitoring/application/forms/Command/Object/ScheduleServiceDowntimeCommandForm.php +++ b/modules/monitoring/application/forms/Command/Object/ScheduleServiceDowntimeCommandForm.php @@ -130,7 +130,7 @@ class ScheduleServiceDowntimeCommandForm extends ObjectsCommandForm array( 'decorators' => array( 'FormElements', - array('HtmlTag', array('tag' => 'div', 'class' => 'control-group')) + array('HtmlTag', array('tag' => 'div')) ) ) ); @@ -169,7 +169,7 @@ class ScheduleServiceDowntimeCommandForm extends ObjectsCommandForm ), 'decorators' => array( 'FormElements', - array('HtmlTag', array('tag' => 'div', 'class' => 'control-group')), + array('HtmlTag', array('tag' => 'div')), array( 'Description', array('tag' => 'span', 'class' => 'description', 'placement' => 'prepend') From e5d2d4cec2f5941a3092ef5884cfae0cc9ac2c42 Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Fri, 19 Dec 2014 11:29:24 +0100 Subject: [PATCH 0040/2920] Add module-aware Form::translate and Form::translatePlural refs #7551 --- library/Icinga/Util/Translator.php | 7 +++--- library/Icinga/Web/Form.php | 35 ++++++++++++++++++++++++++++++ 2 files changed, 38 insertions(+), 4 deletions(-) diff --git a/library/Icinga/Util/Translator.php b/library/Icinga/Util/Translator.php index 52a84bd62..87d9e4c88 100644 --- a/library/Icinga/Util/Translator.php +++ b/library/Icinga/Util/Translator.php @@ -4,7 +4,6 @@ namespace Icinga\Util; -use Exception; use Icinga\Exception\IcingaException; /** @@ -34,8 +33,8 @@ class Translator * * Falls back to the default domain in case the string cannot be translated using the given domain * - * @param string $text The string to translate - * @param string $domain The primary domain to use + * @param string $text The string to translate + * @param string $domain The primary domain to use * @param string|null $context Optional parameter for context based translation * * @return string The translated string @@ -64,7 +63,7 @@ class Translator * * @param string $textSingular The string in singular form to translate * @param string $textPlural The string in plural form to translate - * @param integer $number The number to get the plural or singular string + * @param integer $number The amount to determine from whether to return singular or plural * @param string $domain The primary domain to use * @param string|null $context Optional parameter for context based translation * diff --git a/library/Icinga/Web/Form.php b/library/Icinga/Web/Form.php index 647be721d..205c4e238 100644 --- a/library/Icinga/Web/Form.php +++ b/library/Icinga/Web/Form.php @@ -9,6 +9,7 @@ use Zend_Config; use Zend_Form; use Zend_View_Interface; use Icinga\Application\Icinga; +use Icinga\Util\Translator; use Icinga\Web\Form\Decorator\NoScriptApply; use Icinga\Web\Form\Element\CsrfCounterMeasure; @@ -804,6 +805,40 @@ class Form extends Zend_Form return array(); } + /** + * Translate a string + * + * @param string $text The string to translate + * @param string|null $context Optional parameter for context based translation + * + * @return string The translated string + */ + protected function translate($text, $context = null) + { + return Translator::translate($text, $this->request->getModuleName(), $context); + } + + /** + * Translate a plural string + * + * @param string $textSingular The string in singular form to translate + * @param string $textPlural The string in plural form to translate + * @param integer $number The amount to determine from whether to return singular or plural + * @param string|null $context Optional parameter for context based translation + * + * @return string The translated string + */ + protected function translatePlural($textSingular, $textPlural, $number, $context = null) + { + return Translator::translatePlural( + $textSingular, + $textPlural, + $number, + $this->request->getModuleName(), + $context + ); + } + /** * Render this form * From cf43b814009c2109c3990e4743ef0738bce5b459 Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Fri, 19 Dec 2014 12:08:54 +0100 Subject: [PATCH 0041/2920] Use the class namespace instead of the request in Form::translate(Plural) refs #7551 --- library/Icinga/Web/Form.php | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/library/Icinga/Web/Form.php b/library/Icinga/Web/Form.php index 205c4e238..f3810903c 100644 --- a/library/Icinga/Web/Form.php +++ b/library/Icinga/Web/Form.php @@ -805,6 +805,20 @@ class Form extends Zend_Form return array(); } + /** + * Return the translation domain for this form + * + * @return string + */ + protected function getTranslationDomain() + { + if (preg_match('@^Icinga\\\\Module\\\\([A-z]+)\\\\.*$@', get_called_class(), $matches) === 1) { + return strtolower($matches[0]); + } + + return $this->getRequest()->getModuleName(); + } + /** * Translate a string * @@ -815,7 +829,7 @@ class Form extends Zend_Form */ protected function translate($text, $context = null) { - return Translator::translate($text, $this->request->getModuleName(), $context); + return Translator::translate($text, $this->getTranslationDomain(), $context); } /** @@ -834,7 +848,7 @@ class Form extends Zend_Form $textSingular, $textPlural, $number, - $this->request->getModuleName(), + $this->getTranslationDomain(), $context ); } From 6d263ae316f24d3e27abf42bde15f4f43bff27df Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Fri, 19 Dec 2014 13:07:51 +0100 Subject: [PATCH 0042/2920] Do NOT fetch the translation domain from the request in Form::translate(..) It might be the case that a module is using a library form... refs #7551 --- library/Icinga/Web/Form.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/library/Icinga/Web/Form.php b/library/Icinga/Web/Form.php index f3810903c..850285baa 100644 --- a/library/Icinga/Web/Form.php +++ b/library/Icinga/Web/Form.php @@ -808,6 +808,9 @@ class Form extends Zend_Form /** * Return the translation domain for this form * + * The returned translation domain is either determined based on + * this form's class path or it is the default `icinga' domain + * * @return string */ protected function getTranslationDomain() @@ -816,7 +819,7 @@ class Form extends Zend_Form return strtolower($matches[0]); } - return $this->getRequest()->getModuleName(); + return 'icinga'; } /** From 8e6c8c3e0e5260b85cf370ba8f7a2b980e9a1303 Mon Sep 17 00:00:00 2001 From: Alexander Klimov Date: Fri, 19 Dec 2014 15:18:59 +0100 Subject: [PATCH 0043/2920] Hostgroups list: improve tooltips refs #8110 --- .../views/scripts/list/hostgroups.phtml | 80 +++++++++++++++++-- 1 file changed, 72 insertions(+), 8 deletions(-) diff --git a/modules/monitoring/application/views/scripts/list/hostgroups.phtml b/modules/monitoring/application/views/scripts/list/hostgroups.phtml index a15b5be7e..6238c1963 100644 --- a/modules/monitoring/application/views/scripts/list/hostgroups.phtml +++ b/modules/monitoring/application/views/scripts/list/hostgroups.phtml @@ -96,7 +96,15 @@ 'hostgroup' => $h->hostgroup, 'sort' => 'service_severity' ) - ); ?>" title="translate('Services OK'); ?>"> + ); ?>" title="translatePlural( + '%s Service OK in hostgroup `%s\'', + '%s Services OK in hostgroup `%s\'', + $h->services_ok + ), + $h->services_ok, + $h->hostgroup + ); ?>"> services_ok; ?> @@ -113,7 +121,15 @@ 'hostgroup' => $h->hostgroup, 'sort' => 'service_severity' ) - ); ?>" title="translate('Services CRITICAL Unhandled'); ?>"> + ); ?>" title="translatePlural( + '%s Service CRITICAL Unhandled in hostgroup `%s\'', + '%s Services CRITICAL Unhandled in hostgroup `%s\'', + $h->services_critical_unhandled + ), + $h->services_critical_unhandled, + $h->hostgroup + ); ?>"> services_critical_unhandled; ?> @@ -127,7 +143,15 @@ 'hostgroup' => $h->hostgroup, 'sort' => 'service_severity' ) - ); ?>" title="translate('Services CRITICAL Handled'); ?>"> + ); ?>" title="translatePlural( + '%s Service CRITICAL Handled in hostgroup `%s\'', + '%s Services CRITICAL Handled in hostgroup `%s\'', + $h->services_critical_handled + ), + $h->services_critical_handled, + $h->hostgroup + ); ?>"> services_critical_handled; ?> @@ -147,7 +171,15 @@ 'hostgroup' => $h->hostgroup, 'sort' => 'service_severity' ) - ); ?>" title="translate('Services UNKNOWN Unhandled'); ?>"> + ); ?>" title="translatePlural( + '%s Service UNKNOWN Unhandled in hostgroup `%s\'', + '%s Services UNKNOWN Unhandled in hostgroup `%s\'', + $h->services_unknown_unhandled + ), + $h->services_unknown_unhandled, + $h->hostgroup + ); ?>"> services_unknown_unhandled; ?> @@ -161,7 +193,15 @@ 'hostgroup' => $h->hostgroup, 'sort' => 'service_severity' ) - ); ?>" title="translate('Services UNKNOWN Handled'); ?>"> + ); ?>" title="translatePlural( + '%s Service UNKNOWN Handled in hostgroup `%s\'', + '%s Services UNKNOWN Handled in hostgroup `%s\'', + $h->services_unknown_handled + ), + $h->services_unknown_handled, + $h->hostgroup + ); ?>"> services_unknown_handled; ?> @@ -181,7 +221,15 @@ 'hostgroup' => $h->hostgroup, 'sort' => 'service_severity' ) - ); ?>" title="translate('Services WARNING Unhandled'); ?>"> + ); ?>" title="translatePlural( + '%s Service WARNING Unhandled in hostgroup `%s\'', + '%s Services WARNING Unhandled in hostgroup `%s\'', + $h->services_warning_unhandled + ), + $h->services_warning_unhandled, + $h->hostgroup + ); ?>"> services_warning_unhandled; ?> @@ -195,7 +243,15 @@ 'hostgroup' => $h->hostgroup, 'sort' => 'service_severity' ) - ); ?>" title="translate('Services WARNING Handled'); ?>"> + ); ?>" title="translatePlural( + '%s Service WARNING Handled in hostgroup `%s\'', + '%s Services WARNING Handled in hostgroup `%s\'', + $h->services_warning_handled + ), + $h->services_warning_handled, + $h->hostgroup + ); ?>"> services_warning_handled; ?> @@ -212,7 +268,15 @@ 'hostgroup' => $h->hostgroup, 'sort' => 'service_severity' ) - ); ?>" title="translate('Services PENDING'); ?>"> + ); ?>" title="translatePlural( + '%s Service PENDING in hostgroup `%s\'', + '%s Services PENDING in hostgroup `%s\'', + $h->services_pending + ), + $h->services_pending, + $h->hostgroup + ); ?>"> services_pending; ?> From bdbca6a774aa0973365b52af118d6fa04d60dbad Mon Sep 17 00:00:00 2001 From: Alexander Klimov Date: Fri, 19 Dec 2014 15:18:59 +0100 Subject: [PATCH 0044/2920] Servicegroups list: improve tooltips refs #8110 --- .../views/scripts/list/servicegroups.phtml | 80 +++++++++++++++++-- 1 file changed, 72 insertions(+), 8 deletions(-) diff --git a/modules/monitoring/application/views/scripts/list/servicegroups.phtml b/modules/monitoring/application/views/scripts/list/servicegroups.phtml index ceb3929c0..09abae6a1 100644 --- a/modules/monitoring/application/views/scripts/list/servicegroups.phtml +++ b/modules/monitoring/application/views/scripts/list/servicegroups.phtml @@ -96,7 +96,15 @@ 'servicegroup' => $s->servicegroup, 'sort' => 'service_severity' ) - ); ?>" title="translate('Services OK'); ?>"> + ); ?>" title="translatePlural( + '%s Service OK in servicegroup `%s\'', + '%s Services OK in servicegroup `%s\'', + $s->services_ok + ), + $s->services_ok, + $s->servicegroup + ); ?>"> services_ok; ?> @@ -113,7 +121,15 @@ 'servicegroup' => $s->servicegroup, 'sort' => 'service_severity' ) - ); ?>" title="translate('Services CRITICAL Unhandled'); ?>"> + ); ?>" title="translatePlural( + '%s Service CRITICAL Unhandled in servicegroup `%s\'', + '%s Services CRITICAL Unhandled in servicegroup `%s\'', + $s->services_critical_unhandled + ), + $s->services_critical_unhandled, + $s->servicegroup + ); ?>"> services_critical_unhandled; ?> @@ -127,7 +143,15 @@ 'servicegroup' => $s->servicegroup, 'sort' => 'service_severity' ) - ); ?>" title="translate('Services CRITICAL Handled'); ?>"> + ); ?>" title="translatePlural( + '%s Service CRITICAL Handled in servicegroup `%s\'', + '%s Services CRITICAL Handled in servicegroup `%s\'', + $s->services_critical_handled + ), + $s->services_critical_handled, + $s->servicegroup + ); ?>"> services_critical_handled; ?> @@ -147,7 +171,15 @@ 'servicegroup' => $s->servicegroup, 'sort' => 'service_severity' ) - ); ?>" title="translate('Services UNKNOWN Unhandled'); ?>"> + ); ?>" title="translatePlural( + '%s Service UNKNOWN Unhandled in servicegroup `%s\'', + '%s Services UNKNOWN Unhandled in servicegroup `%s\'', + $s->services_unknown_unhandled + ), + $s->services_unknown_unhandled, + $s->servicegroup + ); ?>"> services_unknown_unhandled; ?> @@ -161,7 +193,15 @@ 'servicegroup' => $s->servicegroup, 'sort' => 'service_severity' ) - ); ?>" title="translate('Services UNKNOWN Handled'); ?>"> + ); ?>" title="translatePlural( + '%s Service UNKNOWN Handled in servicegroup `%s\'', + '%s Services UNKNOWN Handled in servicegroup `%s\'', + $s->services_unknown_handled + ), + $s->services_unknown_handled, + $s->servicegroup + ); ?>"> services_unknown_handled; ?> @@ -181,7 +221,15 @@ 'servicegroup' => $s->servicegroup, 'sort' => 'service_severity' ) - ); ?>" title="translate('Services WARNING Unhandled'); ?>"> + ); ?>" title="translatePlural( + '%s Service WARNING Unhandled in servicegroup `%s\'', + '%s Services WARNING Unhandled in servicegroup `%s\'', + $s->services_warning_unhandled + ), + $s->services_warning_unhandled, + $s->servicegroup + ); ?>"> services_warning_unhandled; ?> @@ -195,7 +243,15 @@ 'servicegroup' => $s->servicegroup, 'sort' => 'service_severity' ) - ); ?>" title="translate('Services WARNING Handled'); ?>"> + ); ?>" title="translatePlural( + '%s Service WARNING Handled in servicegroup `%s\'', + '%s Services WARNING Handled in servicegroup `%s\'', + $s->services_warning_handled + ), + $s->services_warning_handled, + $s->servicegroup + ); ?>"> services_warning_handled; ?> @@ -212,7 +268,15 @@ 'servicegroup' => $s->servicegroup, 'sort' => 'service_severity' ) - ); ?>" title="translate('Services PENDING'); ?>"> + ); ?>" title="translatePlural( + '%s Service PENDING in servicegroup `%s\'', + '%s Services PENDING in servicegroup `%s\'', + $s->services_pending + ), + $s->services_pending, + $s->servicegroup + ); ?>"> services_pending; ?> From a02d9cecfe4fd60fac5d685228af494f2fbcfe01 Mon Sep 17 00:00:00 2001 From: Alexander Klimov Date: Fri, 19 Dec 2014 17:15:14 +0100 Subject: [PATCH 0045/2920] Improve and translate the logout button's title refs #8110 --- application/layouts/scripts/parts/topbar.phtml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/application/layouts/scripts/parts/topbar.phtml b/application/layouts/scripts/parts/topbar.phtml index 39d559f57..68f919951 100644 --- a/application/layouts/scripts/parts/topbar.phtml +++ b/application/layouts/scripts/parts/topbar.phtml @@ -32,7 +32,7 @@ translate('Preferences'); ?>
  • - translate('Logout'); ?> + translate('Logout'); ?>
  • From ebc539bc3770d5a27e0a96cae6de84542f8025f4 Mon Sep 17 00:00:00 2001 From: Alexander Klimov Date: Fri, 19 Dec 2014 17:15:14 +0100 Subject: [PATCH 0046/2920] JoystickPagination view script: show axis type (x/y) in titles refs #8110 --- application/views/scripts/joystickPagination.phtml | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/application/views/scripts/joystickPagination.phtml b/application/views/scripts/joystickPagination.phtml index 27cafa309..a89d2601d 100644 --- a/application/views/scripts/joystickPagination.phtml +++ b/application/views/scripts/joystickPagination.phtml @@ -6,7 +6,7 @@ if ($xAxisPaginator->count() <= 1 && $yAxisPaginator->count() <= 1) { return; // Display this pagination only if there are multiple pages } -$fromTo = t('%s: %d to %d of %d'); +$fromTo = t('%s: %d to %d of %d (on the %s-axis)'); $xAxisPages = $xAxisPaginator->getPages('all'); $yAxisPages = $yAxisPaginator->getPages('all'); @@ -35,7 +35,8 @@ $nextXAxisPage = $currentXAxisPage < $totalXAxisPages ? $currentXAxisPage + 1 : t('Hosts'), ($prevYAxisPage - 1) * $yAxisPages->itemCountPerPage + 1, $prevYAxisPage * $yAxisPages->itemCountPerPage, - $yAxisPages->totalItemCount + $yAxisPages->totalItemCount, + 'y' ); ?>">icon('up-open'); ?> icon('up-open'); ?> @@ -53,7 +54,8 @@ $nextXAxisPage = $currentXAxisPage < $totalXAxisPages ? $currentXAxisPage + 1 : t('Services'), ($prevXAxisPage - 1) * $xAxisPages->itemCountPerPage + 1, $prevXAxisPage * $xAxisPages->itemCountPerPage, - $xAxisPages->totalItemCount + $xAxisPages->totalItemCount, + 'x' ); ?>">icon('left-open'); ?> icon('left-open'); ?> @@ -69,7 +71,8 @@ $nextXAxisPage = $currentXAxisPage < $totalXAxisPages ? $currentXAxisPage + 1 : t('Services'), $currentXAxisPage * $xAxisPages->itemCountPerPage + 1, $nextXAxisPage === $xAxisPages->last ? $xAxisPages->totalItemCount : $nextXAxisPage * $xAxisPages->itemCountPerPage, - $xAxisPages->totalItemCount + $xAxisPages->totalItemCount, + 'x' ); ?>">icon('right-open'); ?> icon('right-open'); ?> @@ -87,7 +90,8 @@ $nextXAxisPage = $currentXAxisPage < $totalXAxisPages ? $currentXAxisPage + 1 : t('Hosts'), $currentYAxisPage * $yAxisPages->itemCountPerPage + 1, $nextYAxisPage === $yAxisPages->last ? $yAxisPages->totalItemCount : $nextYAxisPage * $yAxisPages->itemCountPerPage, - $yAxisPages->totalItemCount + $yAxisPages->totalItemCount, + 'y' ); ?>">icon('down-open'); ?> icon('down-open'); ?> From ff1cda94ef111442bb6aa13034b555ee365308b9 Mon Sep 17 00:00:00 2001 From: Alexander Klimov Date: Fri, 19 Dec 2014 17:15:14 +0100 Subject: [PATCH 0047/2920] PivottablePagination view script: show axis type (x/y) in titles refs #8110 --- application/views/scripts/pivottablePagination.phtml | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/application/views/scripts/pivottablePagination.phtml b/application/views/scripts/pivottablePagination.phtml index 52bcb0351..ce180146e 100644 --- a/application/views/scripts/pivottablePagination.phtml +++ b/application/views/scripts/pivottablePagination.phtml @@ -6,7 +6,7 @@ if ($xAxisPaginator->count() <= 1 && $yAxisPaginator->count() <= 1) { return; // Display this pagination only if there are multiple pages } -$fromTo = t('%s: %d to %d of %d'); +$fromTo = t('%s: %d to %d of %d (on the %s-axis)'); $xAxisPages = $xAxisPaginator->getPages('all'); $yAxisPages = $yAxisPaginator->getPages('all'); @@ -28,13 +28,15 @@ $yAxisPages = $yAxisPaginator->getPages('all'); t('Hosts'), ($yAxisPage - 1) * $yAxisPages->itemCountPerPage + 1, $yAxisPage === $yAxisPages->last ? $yAxisPages->totalItemCount : $yAxisPage * $yAxisPages->itemCountPerPage, - $yAxisPages->totalItemCount + $yAxisPages->totalItemCount, + 'y' ) . '; ' . sprintf( $fromTo, t('Services'), ($xAxisPage - 1) * $xAxisPages->itemCountPerPage + 1, $xAxisPage === $xAxisPages->last ? $xAxisPages->totalItemCount : $xAxisPage * $xAxisPages->itemCountPerPage, - $xAxisPages->totalItemCount + $xAxisPages->totalItemCount, + 'x' ); ?>"> From 4c4c0c97a5de5ed09d3a6cef9364712e140bad5b Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Mon, 22 Dec 2014 08:30:08 +0100 Subject: [PATCH 0048/2920] Fix incorrect token generation example on the wizard's welcome page fixes #8135 --- .../setup/application/views/scripts/form/setup-welcome.phtml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/modules/setup/application/views/scripts/form/setup-welcome.phtml b/modules/setup/application/views/scripts/form/setup-welcome.phtml index 6c8228541..9aad09dbc 100644 --- a/modules/setup/application/views/scripts/form/setup-welcome.phtml +++ b/modules/setup/application/views/scripts/form/setup-welcome.phtml @@ -51,9 +51,7 @@ $cliPath = realpath(Icinga::app()->getApplicationDir() . '/../bin/icingacli');

    - su && mkdir -m 2770 ; - head -c 12 /dev/urandom | base64 | tee ; - chmod 0660 ; + su -c "mkdir -m 2770 ; head -c 12 /dev/urandom | base64 | tee ; chmod 0660 ;";

    Date: Mon, 22 Dec 2014 09:14:19 +0100 Subject: [PATCH 0049/2920] Fix the config warning's grammar on the login screen --- application/views/scripts/authentication/login.phtml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/application/views/scripts/authentication/login.phtml b/application/views/scripts/authentication/login.phtml index 584d8ad16..416e651d1 100644 --- a/application/views/scripts/authentication/login.phtml +++ b/application/views/scripts/authentication/login.phtml @@ -18,7 +18,7 @@

    Date: Mon, 22 Dec 2014 09:37:01 +0100 Subject: [PATCH 0050/2920] There is no copy-on-write for objects in PHP fixes #8088 --- application/views/scripts/roles/index.phtml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/application/views/scripts/roles/index.phtml b/application/views/scripts/roles/index.phtml index 0f40f8279..79eda5dac 100644 --- a/application/views/scripts/roles/index.phtml +++ b/application/views/scripts/roles/index.phtml @@ -30,7 +30,7 @@ without(...) or $role->shift(...) would be nice! - $restrictions = $role; + $restrictions = clone $role; unset($restrictions['users']); unset($restrictions['groups']); unset($restrictions['permissions']); From 706e5504e651e63b7fee1e5a116f924452bf33d3 Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Mon, 22 Dec 2014 10:46:29 +0100 Subject: [PATCH 0051/2920] Escape restriction names manually in Forms\Security\RoleForm fixes #8086 --- application/forms/Security/RoleForm.php | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/application/forms/Security/RoleForm.php b/application/forms/Security/RoleForm.php index 0fb53e858..4edb33d07 100644 --- a/application/forms/Security/RoleForm.php +++ b/application/forms/Security/RoleForm.php @@ -93,7 +93,7 @@ class RoleForm extends ConfigForm foreach ($this->providedRestrictions as $name => $description) { $this->addElement( 'text', - $name, + str_replace('/', '_', $name), array( 'label' => $name, 'description' => $description @@ -129,6 +129,12 @@ class RoleForm extends ConfigForm ? String::trimSplit($role['permissions']) : null; $role['name'] = $name; + foreach (array_keys($role) as $key) { + // Slashes are not allowed in a form's element name + $value = $role[$key]; + unset($role[$key]); + $role[str_replace('/', '_', $key)] = $value; + } $this->populate($role); return $this; } @@ -230,6 +236,12 @@ class RoleForm extends ConfigForm if (isset($values['permissions'])) { $values['permissions'] = implode(', ', $values['permissions']); } + foreach (array_keys($values) as $key) { + // Slashes are not allowed in a form's element name + $value = $values[$key]; + unset($values[$key]); + $values[str_replace('/', '_', $key)] = $value; + } return $values; } } From f7d11ce11f82b8e2716ed065ecdb0f4109ddd25a Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Mon, 22 Dec 2014 11:02:48 +0100 Subject: [PATCH 0052/2920] Relax session storage check to the `files' save handler fixes #8053 --- library/Icinga/Web/Session/PhpSession.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library/Icinga/Web/Session/PhpSession.php b/library/Icinga/Web/Session/PhpSession.php index bef978c0b..094685fe4 100644 --- a/library/Icinga/Web/Session/PhpSession.php +++ b/library/Icinga/Web/Session/PhpSession.php @@ -78,7 +78,7 @@ class PhpSession extends Session } } - if (!is_writable(session_save_path())) { + if (ini_get('session.save_handler') === 'files' && !is_writable(session_save_path())) { throw new ConfigurationError('Can\'t save session'); } From 086334c8618ce218f5df872b1bca5de33604dbc6 Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Mon, 22 Dec 2014 13:59:03 +0100 Subject: [PATCH 0053/2920] Properly build the unhandled action links when showing multiple objects The links designated to acknowledge unhandled problems or to schedule a downtime for them were generated based on the full list of objects and limited by non-supported filter parameters. As we are already aware of the exact "unhandled" objects this list is now used to generate proper links. (Btw applying filters to URLs is a mess...) fixes #8017 --- .../controllers/HostsController.php | 12 ++++++------ .../controllers/ServicesController.php | 18 ++++++++++++------ 2 files changed, 18 insertions(+), 12 deletions(-) diff --git a/modules/monitoring/application/controllers/HostsController.php b/modules/monitoring/application/controllers/HostsController.php index 4944cc237..37611a001 100644 --- a/modules/monitoring/application/controllers/HostsController.php +++ b/modules/monitoring/application/controllers/HostsController.php @@ -108,12 +108,12 @@ class Monitoring_HostsController extends Controller $this->view->hostStates = $hostStates; $this->view->objects = $this->hostList; $this->view->unhandledObjects = $unhandledObjects; - $this->view->acknowledgeUnhandledLink = Url::fromRequest() - ->setPath('monitoring/hosts/acknowledge-problem') - ->addParams(array('host_problem' => 1, 'host_handled' => 0)); - $this->view->downtimeUnhandledLink = Url::fromRequest() - ->setPath('monitoring/hosts/schedule-downtime') - ->addParams(array('host_problem' => 1, 'host_handled' => 0)); + $this->view->acknowledgeUnhandledLink = Url::fromPath('monitoring/hosts/acknowledge-problem')->setQueryString( + Filter::where('host', array_map(function ($h) { return $h->host; }, $unhandledObjects))->toQueryString() + ); + $this->view->downtimeUnhandledLink = Url::fromPath('monitoring/hosts/schedule-downtime')->setQueryString( + Filter::where('host', array_map(function ($h) { return $h->host; }, $unhandledObjects))->toQueryString() + ); $this->view->acknowledgedObjects = $acknowledgedObjects; $this->view->objectsInDowntime = $objectsInDowntime; $this->view->inDowntimeLink = Url::fromRequest() diff --git a/modules/monitoring/application/controllers/ServicesController.php b/modules/monitoring/application/controllers/ServicesController.php index cdf86f460..f859f6790 100644 --- a/modules/monitoring/application/controllers/ServicesController.php +++ b/modules/monitoring/application/controllers/ServicesController.php @@ -125,12 +125,18 @@ class Monitoring_ServicesController extends Controller $this->view->serviceStates = $serviceStates; $this->view->objects = $this->serviceList; $this->view->unhandledObjects = $unhandledObjects; - $this->view->acknowledgeUnhandledLink = Url::fromRequest() - ->setPath('monitoring/services/acknowledge-problem') - ->addParams(array('service_problem' => 1, 'service_handled' => 0)); - $this->view->downtimeUnhandledLink = Url::fromRequest() - ->setPath('monitoring/services/schedule-downtime') - ->addParams(array('service_problem' => 1, 'service_handled' => 0)); + $unhandledFilterExpressions = array(); + foreach ($unhandledObjects as $service) { + $unhandledFilterExpressions[] = Filter::matchAll( + Filter::expression('host', '=', $service->getHost()->getName()), + Filter::expression('service', '=', $service->getName()) + ); + } + $queryString = Filter::matchAny($unhandledFilterExpressions)->toQueryString(); + $this->view->acknowledgeUnhandledLink = Url::fromPath('monitoring/services/acknowledge-problem'); + $this->view->acknowledgeUnhandledLink->setQueryString($queryString); + $this->view->downtimeUnhandledLink = Url::fromPath('monitoring/services/schedule-downtime'); + $this->view->downtimeUnhandledLink->setQueryString($queryString); $this->view->acknowledgedObjects = $acknowledgedObjects; $this->view->objectsInDowntime = $objectsInDowntime; $this->view->inDowntimeLink = Url::fromRequest() From c5915f24cc4f1ae3846cac0ac129b3e61d8e644e Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Mon, 22 Dec 2014 14:44:09 +0100 Subject: [PATCH 0054/2920] Make it easier to distinguish host and service downtimes Added an icon to the left of a host's or service's label and an additional textual indicator. refs #8008 --- .../views/scripts/list/downtimes.phtml | 20 +++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/modules/monitoring/application/views/scripts/list/downtimes.phtml b/modules/monitoring/application/views/scripts/list/downtimes.phtml index 37b34fe5e..8a8e5576c 100644 --- a/modules/monitoring/application/views/scripts/list/downtimes.phtml +++ b/modules/monitoring/application/views/scripts/list/downtimes.phtml @@ -53,7 +53,7 @@ use Icinga\Module\Monitoring\Object\Service; service)): ?> - href('monitoring/service/show', array( 'host' => $downtime->host, 'service' => $downtime->service )); ?>"> @@ -63,7 +63,7 @@ use Icinga\Module\Monitoring\Object\Service; translate('on'); ?> host; ?> - href('monitoring/host/show', array( 'host' => $downtime->host )); ?>"> host; ?> @@ -76,7 +76,9 @@ use Icinga\Module\Monitoring\Object\Service; is_flexible): ?> is_in_effect): ?> translate('This flexible downtime was started on %s at %s and lasts for %s until %s at %s.'), + isset($downtime->service) + ? $this->translate('This flexible service downtime was started on %s at %s and lasts for %s until %s at %s.') + : $this->translate('This flexible host downtime was started on %s at %s and lasts for %s until %s at %s.'), date('d.m.y', $downtime->start), date('H:i', $downtime->start), $this->format()->duration($downtime->duration), @@ -85,7 +87,9 @@ use Icinga\Module\Monitoring\Object\Service; ); ?> translate('This flexible downtime has been scheduled to start between %s - %s and to last for %s.'), + isset($downtime->service) + ? $this->translate('This flexible service downtime has been scheduled to start between %s - %s and to last for %s.') + : $this->translate('This flexible host downtime has been scheduled to start between %s - %s and to last for %s.'), date('d.m.y H:i', $downtime->scheduled_start), date('d.m.y H:i', $downtime->scheduled_end), $this->format()->duration($downtime->duration) @@ -94,7 +98,9 @@ use Icinga\Module\Monitoring\Object\Service; is_in_effect): ?> translate('This fixed downtime was started on %s at %s and expires on %s at %s.'), + isset($downtime->service) + ? $this->translate('This fixed service downtime was started on %s at %s and expires on %s at %s.') + : $this->translate('This fixed host downtime was started on %s at %s and expires on %s at %s.'), date('d.m.y', $downtime->start), date('H:i', $downtime->start), date('d.m.y', $downtime->end), @@ -102,7 +108,9 @@ use Icinga\Module\Monitoring\Object\Service; ); ?> translate('This fixed downtime has been scheduled to start on %s at %s and to end on %s at %s.'), + isset($downtime->service) + ? $this->translate('This fixed service downtime has been scheduled to start on %s at %s and to end on %s at %s.') + : $this->translate('This fixed host downtime has been scheduled to start on %s at %s and to end on %s at %s.'), date('d.m.y', $downtime->scheduled_start), date('H:i', $downtime->scheduled_start), date('d.m.y', $downtime->scheduled_end), From 5b0c8763620a474fe8bfb173490f27283f426375 Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Mon, 22 Dec 2014 16:18:39 +0100 Subject: [PATCH 0055/2920] Use the service_handled column instead of acknowledged and in_downtime Only service_handled takes the host's state into consideration. refs #8013 --- .../monitoring/application/views/scripts/list/hosts.phtml | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/modules/monitoring/application/views/scripts/list/hosts.phtml b/modules/monitoring/application/views/scripts/list/hosts.phtml index debef375c..2f339b1bf 100644 --- a/modules/monitoring/application/views/scripts/list/hosts.phtml +++ b/modules/monitoring/application/views/scripts/list/hosts.phtml @@ -108,10 +108,9 @@ if ($hosts->count() === 0) { $host->host_unhandled_services), 'monitoring/show/services', array( - 'host' => $host->host_name, - 'service_problem' => 1, - 'service_acknowledged' => 0, - 'service_in_downtime' => 0 + 'host' => $host->host_name, + 'service_problem' => 1, + 'service_handled' => 0 ), array('style' => 'font-weight: normal') ) ?>) From f513e7959e1c2c515fe0304571ea1d154a108fd5 Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Mon, 22 Dec 2014 16:20:12 +0100 Subject: [PATCH 0056/2920] Consider also the host's state when counting its service problems refs #8013 --- .../library/Monitoring/Backend/Ido/Query/StatusQuery.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/modules/monitoring/library/Monitoring/Backend/Ido/Query/StatusQuery.php b/modules/monitoring/library/Monitoring/Backend/Ido/Query/StatusQuery.php index e390aa114..28b06dc80 100644 --- a/modules/monitoring/library/Monitoring/Backend/Ido/Query/StatusQuery.php +++ b/modules/monitoring/library/Monitoring/Backend/Ido/Query/StatusQuery.php @@ -518,12 +518,14 @@ class StatusQuery extends IdoQuery protected function joinServiceproblemsummary() { $sub = new Zend_Db_Expr('(SELECT' - . ' SUM(CASE WHEN (ss.problem_has_been_acknowledged + ss.scheduled_downtime_depth) > 0 THEN 0 ELSE 1 END) AS unhandled_services_count,' - . ' SUM(CASE WHEN (ss.problem_has_been_acknowledged + ss.scheduled_downtime_depth) > 0 THEN 1 ELSE 0 END) AS handled_services_count,' + . ' SUM(CASE WHEN (ss.problem_has_been_acknowledged + ss.scheduled_downtime_depth + COALESCE(hs.current_state, 0)) > 0 THEN 0 ELSE 1 END) AS unhandled_services_count,' + . ' SUM(CASE WHEN (ss.problem_has_been_acknowledged + ss.scheduled_downtime_depth + COALESCE(hs.current_state, 0)) > 0 THEN 1 ELSE 0 END) AS handled_services_count,' . ' s.host_object_id FROM icinga_servicestatus ss' . ' JOIN icinga_services s' . ' ON s.service_object_id = ss.service_object_id' . ' AND ss.current_state > 0' + . ' JOIN icinga_hoststatus hs' + . ' ON hs.host_object_id = s.host_object_id' . ' GROUP BY s.host_object_id)'); $this->select->joinLeft( array('sps' => $sub), From 64a2acd12eb84f6d62d577b7a49b637efa11a418 Mon Sep 17 00:00:00 2001 From: Matthias Jentsch Date: Thu, 18 Dec 2014 16:44:55 +0100 Subject: [PATCH 0057/2920] Do not display labels for single data sets in perfdata piecharts Display generic chart titles for the whole piechart that only contain title and percentage and don't style perfdata piecharts using HTML properties. refs #7077 refs #6200 refs #7304 --- library/Icinga/Web/Widget/Chart/InlinePie.php | 210 +++++------------- .../controllers/MultiController.php | 2 +- .../controllers/ServicesController.php | 3 +- .../application/views/helpers/Perfdata.php | 14 +- public/css/icinga/widgets.less | 12 + public/js/icinga/behavior/sparkline.js | 51 ++--- 6 files changed, 107 insertions(+), 185 deletions(-) diff --git a/library/Icinga/Web/Widget/Chart/InlinePie.php b/library/Icinga/Web/Widget/Chart/InlinePie.php index 618d2903b..3acb83f5c 100644 --- a/library/Icinga/Web/Widget/Chart/InlinePie.php +++ b/library/Icinga/Web/Widget/Chart/InlinePie.php @@ -34,30 +34,20 @@ class InlinePie extends AbstractWidget * @var string */ private $template =<<<'EOD' - - + + +{noscript} EOD; + private $noscript =<<<'EOD' + +EOD; + + /** * @var Url */ @@ -70,34 +60,6 @@ EOD; */ private $colors = array('#44bb77', '#ffaa44', '#ff5566', '#ddccdd'); - /** - * The width of the rendered chart - * - * @var int The value in px - */ - private $width = 16; - - /** - * The height of the rendered chart - * - * @var int The value in px - */ - private $height = 16; - - /** - * PieChart border width - * - * @var float - */ - private $borderWidth = 1; - - /** - * The color of the border - * - * @var string - */ - private $borderColor = '#fff'; - /** * The title of the chart * @@ -106,11 +68,9 @@ EOD; private $title; /** - * The style for the HtmlElement - * - * @var string + * @var */ - private $style = ''; + private $size; /** * The data displayed by the pie-chart @@ -126,19 +86,17 @@ EOD; */ private $labels = array(); - /** - * If the tooltip for the "empty" area should be hidden - * - * @var bool - */ - private $hideEmptyLabel = false; - /** * The format string used to display tooltips * * @var string */ - private $tooltipFormat = '{{title}}
    {{label}}: {{formatted}} ({{percent}}%)'; + private $tooltipFormat = '{{title}}
    {{label}} {{formatted}} ({{percent}}%)'; + + /** + * @var string + */ + private $disableTooltips = ''; /** * The number format used to render numeric values in tooltips @@ -147,19 +105,6 @@ EOD; */ private $format = self::NUMBER_FORMAT_NONE; - /** - * Set if the tooltip for the empty area should be hidden - * - * @param bool $hide Whether to hide the empty area - * - * @return $this - */ - public function setHideEmptyLabel($hide = true) - { - $this->hideEmptyLabel = $hide; - return $this; - } - /** * Set the data to be displayed. * @@ -174,6 +119,27 @@ EOD; return $this; } + /** + * Set the size of the inline pie + * + * @param int $size Sets both, the height and width + * + * @return $this + */ + public function setSize($size = null) + { + $this->size = $size; + return $this; + } + + /** + * Do not display the NoScript fallback html + */ + public function disableNoScript() + { + $this->noscript = ''; + } + /** * The labels to be displayed in the pie-chart * @@ -186,7 +152,7 @@ EOD; if (is_array($label)) { $this->url->setParam('labels', implode(',', array_keys($label))); } elseif ($label != null) { - $labelArr = array($label, $label, $label, ''); + $labelArr = array($label, $label, $label, $label); $this->url->setParam('labels', implode(',', $labelArr)); $label = $labelArr; } else { @@ -250,69 +216,6 @@ EOD; return $this; } - /** - * Set the height - * - * @param $height - * - * @return $this - */ - public function setHeight($height) - { - $this->height = $height; - return $this; - } - - /** - * Set the border width of the pie chart - * - * @param float $width Width in px - * - * @return $this - */ - public function setBorderWidth($width) - { - $this->borderWidth = $width; - return $this; - } - - /** - * Set the color of the pie chart border - * - * @param string $col The color string - * - * @return $this - */ - public function setBorderColor($col) - { - $this->borderColor = $col; - } - - /** - * Set the width - * - * @param $width - * - * @return $this - */ - public function setWidth($width) - { - $this->width = $width; - return $this; - } - - /** - * Set the styling of the created HtmlElement - * - * @param string $style - * - * @return $this - */ - public function setStyle($style) - { - $this->style = $style; - } - /** * Set the title of the displayed Data * @@ -322,10 +225,20 @@ EOD; */ public function setTitle($title) { - $this->title = $title; + $this->title = 'title="' . htmlspecialchars($title) . '"'; return $this; } + /** + * Whether to display tooltips for the InlinePie + * + * @param bool $val + */ + public function setDisableTooltip($val = true) + { + $this->disableTooltips = $val !== true ? '' : 'sparkDisableTooltips="true"'; + } + /** * Create a new InlinePie * @@ -335,7 +248,7 @@ EOD; */ public function __construct(array $data, $title, $colors = null) { - $this->title = $title; + $this->setTitle($title); $this->url = Url::fromPath('svg/chart.php'); if (array_key_exists('data', $data)) { $this->data = $data['data']; @@ -386,7 +299,7 @@ EOD; )); try { - $png = $pie->toPng($this->width, $this->height); + $png = $pie->toPng($this->size, $this->size); return ''; } catch (IcingaException $_) { return ''; @@ -394,17 +307,15 @@ EOD; } $template = $this->template; + // TODO: Check whether we are XHR and don't send + $template = str_replace('{noscript}', $this->noscript, $template); $template = str_replace('{url}', $this->url, $template); // style - $template = str_replace('{width}', $this->width, $template); - $template = str_replace('{height}', $this->height, $template); - $template = str_replace('{title}', htmlspecialchars($this->title), $template); - $template = str_replace('{style}', $this->style, $template); + $template = str_replace('{size}', + isset($this->size) ? 'sparkWidth="' . $this->size . '" sparkHeight="' . $this->size . '" ' : '', $template); + $template = str_replace('{title}', $this->title, $template); $template = str_replace('{colors}', implode(',', $this->colors), $template); - $template = str_replace('{borderWidth}', $this->borderWidth, $template); - $template = str_replace('{borderColor}', $this->borderColor, $template); - $template = str_replace('{hideEmptyLabel}', $this->hideEmptyLabel ? 'true' : 'false', $template); // Locale-ignorant string cast. Please. Do. NOT. Remove. This. Again. // Problem is that implode respects locales when casting floats. This means @@ -423,6 +334,7 @@ EOD; $template = str_replace('{formatted}', htmlspecialchars(implode('|', $formatted)), $template); $template = str_replace('{labels}', htmlspecialchars($this->createLabelString()), $template); $template = str_replace('{tooltipFormat}', $this->tooltipFormat, $template); + $template = str_replace('{disableTooltips}', $this->disableTooltips, $template); return $template; } diff --git a/modules/monitoring/application/controllers/MultiController.php b/modules/monitoring/application/controllers/MultiController.php index 52d927ffb..6deff2fc3 100644 --- a/modules/monitoring/application/controllers/MultiController.php +++ b/modules/monitoring/application/controllers/MultiController.php @@ -221,7 +221,7 @@ class Monitoring_MultiController extends Controller private function createPie($states, $colors, $title) { $chart = new InlinePie(array_values($states), $title, $colors); - $chart->setLabel(array_keys($states))->setHeight(100)->setWidth(100); + $chart->setLabel(array_keys($states))->setSize(100); $chart->setTitle($title); return $chart; } diff --git a/modules/monitoring/application/controllers/ServicesController.php b/modules/monitoring/application/controllers/ServicesController.php index f859f6790..a7b2d0294 100644 --- a/modules/monitoring/application/controllers/ServicesController.php +++ b/modules/monitoring/application/controllers/ServicesController.php @@ -160,8 +160,7 @@ class Monitoring_ServicesController extends Controller $chart = new InlinePie(array_values($states), $title, $colors); return $chart ->setLabel(array_map('strtoupper', array_keys($states))) - ->setHeight(100) - ->setWidth(100) + ->setSize(100) ->setTitle($title); } diff --git a/modules/monitoring/application/views/helpers/Perfdata.php b/modules/monitoring/application/views/helpers/Perfdata.php index eb649e77d..6e168c90f 100644 --- a/modules/monitoring/application/views/helpers/Perfdata.php +++ b/modules/monitoring/application/views/helpers/Perfdata.php @@ -84,21 +84,19 @@ class Zend_View_Helper_Perfdata extends Zend_View_Helper_Abstract protected function createInlinePie(Perfdata $perfdata) { - $pieChart = new InlinePie($this->calculatePieChartData($perfdata), $perfdata->getLabel()); - $pieChart->setLabel(htmlspecialchars($perfdata->getLabel())); - $pieChart->setHideEmptyLabel(); + $pieChart = new InlinePie($this->calculatePieChartData($perfdata), + $perfdata->getLabel() . ' ' . (int)$perfdata->getPercentage() . '%'); + $pieChart->setDisableTooltip(); + if (Zend_Controller_Front::getInstance()->getRequest()->isXmlHttpRequest()) { + $pieChart->disableNoScript(); + } - //$pieChart->setHeight(32)->setWidth(32); if ($perfdata->isBytes()) { - $pieChart->setTooltipFormat('{{label}}: {{formatted}} ({{percent}}%)'); $pieChart->setNumberFormat(InlinePie::NUMBER_FORMAT_BYTES); } else if ($perfdata->isSeconds()) { - $pieChart->setTooltipFormat('{{label}}: {{formatted}} ({{percent}}%)'); $pieChart->setNumberFormat(InlinePie::NUMBER_FORMAT_TIME); } else { - $pieChart->setTooltipFormat('{{label}}: {{formatted}}%'); $pieChart->setNumberFormat(InlinePie::NUMBER_FORMAT_RATIO); - $pieChart->setHideEmptyLabel(); } return $pieChart; } diff --git a/public/css/icinga/widgets.less b/public/css/icinga/widgets.less index 93625b0dc..87941157c 100644 --- a/public/css/icinga/widgets.less +++ b/public/css/icinga/widgets.less @@ -285,3 +285,15 @@ li li .badge { .widgetFilter li.active { background-color: #eee; } + +.sparkline { + width: 12px; + height: 12px; +} + +.inlinepie { + width: 12px; + height: 12px; + position: relative; + top: 10px; +} \ No newline at end of file diff --git a/public/js/icinga/behavior/sparkline.js b/public/js/icinga/behavior/sparkline.js index 33cc0d34b..1992bae0a 100644 --- a/public/js/icinga/behavior/sparkline.js +++ b/public/js/icinga/behavior/sparkline.js @@ -21,31 +21,32 @@ var $spark = $(element); var labels = $spark.attr('labels').split('|'); var formatted = $spark.attr('formatted').split('|'); - var tooltipChartTitle = $spark.attr('sparkTooltipChartTitle') || ''; - var format = $spark.attr('tooltipformat'); - var hideEmpty = $spark.attr('hideEmptyLabel') === 'true'; - $spark.sparkline( - 'html', - { - enableTagOptions: true, - tooltipFormatter: function (sparkline, options, fields) { - var out = format; - if (hideEmpty && fields.offset === 3) { - return ''; - } - var replace = { - title: tooltipChartTitle, - label: labels[fields.offset] ? labels[fields.offset] : fields.offset, - formatted: formatted[fields.offset] ? formatted[fields.offset] : '', - value: fields.value, - percent: Math.round(fields.percent * 100) / 100 - }; - $.each(replace, function(key, value) { - out = out.replace('{{' + key + '}}', value); - }); - return out; - } - }); + var title = $spark.attr('title'); + var format = $spark.attr('tooltipFormat'); + + if ($spark.attr('labels')) { + $spark.removeAttr('original-title'); + } + var options = { + enableTagOptions: true, + width: $spark.attr('sparkWidth') || 12, + height: $spark.attr('sparkHeight') || 12, + tooltipFormatter: function (sparkline, options, fields) { + var out = format; + var replace = { + title: title, + label: labels[fields.offset] ? labels[fields.offset] : fields.offset, + formatted: formatted[fields.offset] ? formatted[fields.offset] : '', + value: fields.value, + percent: Math.round(fields.percent * 100) / 100 + }; + $.each(replace, function(key, value) { + out = out.replace('{{' + key + '}}', value); + }); + return out; + } + }; + $spark.sparkline('html', options); }); }; From cda5a6a9034cd961cc6b6faeed732e55ab4cce5a Mon Sep 17 00:00:00 2001 From: Matthias Jentsch Date: Tue, 23 Dec 2014 15:26:45 +0100 Subject: [PATCH 0058/2920] Streamline chart implementation Define sparkline layout through CSS class and remove label/tooltip formatting. fixes #7077 --- library/Icinga/Web/Widget/Chart/InlinePie.php | 150 ++---------------- .../controllers/HostsController.php | 3 - .../controllers/ServicesController.php | 7 +- public/js/icinga/behavior/sparkline.js | 48 +++--- 4 files changed, 39 insertions(+), 169 deletions(-) diff --git a/library/Icinga/Web/Widget/Chart/InlinePie.php b/library/Icinga/Web/Widget/Chart/InlinePie.php index 3acb83f5c..69de8ebd5 100644 --- a/library/Icinga/Web/Widget/Chart/InlinePie.php +++ b/library/Icinga/Web/Widget/Chart/InlinePie.php @@ -5,6 +5,7 @@ namespace Icinga\Web\Widget\Chart; use Icinga\Chart\PieChart; +use Icinga\Module\Monitoring\Plugin\PerfdataSet; use Icinga\Web\Widget\AbstractWidget; use Icinga\Web\Url; use Icinga\Util\Format; @@ -28,15 +29,12 @@ class InlinePie extends AbstractWidget const NUMBER_FORMAT_RATIO = 'ratio'; /** - * The template string used for rendering this widget * The template string used for rendering this widget * * @var string */ private $template =<<<'EOD' - + {noscript} EOD; @@ -80,30 +78,9 @@ EOD; private $data; /** - * The labels to display for each data set - * - * @var array + * @var */ - private $labels = array(); - - /** - * The format string used to display tooltips - * - * @var string - */ - private $tooltipFormat = '{{title}}
    {{label}} {{formatted}} ({{percent}}%)'; - - /** - * @var string - */ - private $disableTooltips = ''; - - /** - * The number format used to render numeric values in tooltips - * - * @var array - */ - private $format = self::NUMBER_FORMAT_NONE; + private $class = ''; /** * Set the data to be displayed. @@ -141,24 +118,15 @@ EOD; } /** - * The labels to be displayed in the pie-chart + * Set the class to define the * - * @param mixed $label The label of the displayed value, or null for no labels + * @param $class * - * @return $this + * @return $this */ - public function setLabel($label) + public function setSparklineClass($class) { - if (is_array($label)) { - $this->url->setParam('labels', implode(',', array_keys($label))); - } elseif ($label != null) { - $labelArr = array($label, $label, $label, $label); - $this->url->setParam('labels', implode(',', $labelArr)); - $label = $labelArr; - } else { - $this->url->removeKey('labels'); - } - $this->labels = $label; + $this->class = $class; return $this; } @@ -180,42 +148,6 @@ EOD; return $this; } - /** - * Set the used number format - * - * @param $format string 'bytes' or 'time' - * - * @return $this - */ - public function setNumberFormat($format) - { - $this->format = $format; - return $this; - } - - /** - * A format string used to render the content of the piechart tooltips - * - * Placeholders using curly braces '{FOO}' are replace with their specific values. The format - * String may contain HTML-Markup. The available replaceable values are: - *
      - *
    • label: The description for the current value
    • - *
    • formatted: A string representing the formatted value
    • - *
    • value: The raw (non-formatted) value used to render the piechart
    • - *
    • percent: The percentage of the current value
    • - *
    - * Note: Changes will only affect JavaScript sparklines and not the SVG charts used for fallback - * - * @param $format - * - * @return $this - */ - public function setTooltipFormat($format) - { - $this->tooltipFormat = $format; - return $this; - } - /** * Set the title of the displayed Data * @@ -229,16 +161,6 @@ EOD; return $this; } - /** - * Whether to display tooltips for the InlinePie - * - * @param bool $val - */ - public function setDisableTooltip($val = true) - { - $this->disableTooltips = $val !== true ? '' : 'sparkDisableTooltips="true"'; - } - /** * Create a new InlinePie * @@ -252,9 +174,6 @@ EOD; $this->url = Url::fromPath('svg/chart.php'); if (array_key_exists('data', $data)) { $this->data = $data['data']; - if (array_key_exists('labels', $data)) { - $this->labels = $data['labels']; - } if (array_key_exists('colors', $data)) { $this->colors = $data['colors']; } @@ -267,21 +186,6 @@ EOD; $this->setColors($this->colors); } } - - /** - * Create a serialization containing the current label array - * - * @return string A serialized array of labels - */ - private function createLabelString () - { - $labels = $this->labels; - foreach ($labels as $key => $label) { - $labels[$key] = str_replace('|', '', $label); - } - return isset($this->labels) && is_array($this->labels) ? implode('|', $this->labels) : ''; - } - /** * Renders this widget via the given view and returns the * HTML as a string @@ -295,7 +199,7 @@ EOD; $pie->alignTopLeft(); $pie->disableLegend(); $pie->drawPie(array( - 'data' => $this->data, 'colors' => $this->colors, 'labels' => $this->labels + 'data' => $this->data, 'colors' => $this->colors )); try { @@ -310,11 +214,13 @@ EOD; // TODO: Check whether we are XHR and don't send $template = str_replace('{noscript}', $this->noscript, $template); $template = str_replace('{url}', $this->url, $template); + $template = str_replace('{class}', $this->class, $template); // style $template = str_replace('{size}', isset($this->size) ? 'sparkWidth="' . $this->size . '" sparkHeight="' . $this->size . '" ' : '', $template); $template = str_replace('{title}', $this->title, $template); + $template = str_replace('{colors}', implode(',', $this->colors), $template); // Locale-ignorant string cast. Please. Do. NOT. Remove. This. Again. @@ -325,39 +231,7 @@ EOD; $data[] = sprintf('%F', $dat); } - // values - $formatted = array(); - foreach ($this->data as $key => $value) { - $formatted[$key] = $this->formatValue($value); - } $template = str_replace('{data}', htmlspecialchars(implode(',', $data)), $template); - $template = str_replace('{formatted}', htmlspecialchars(implode('|', $formatted)), $template); - $template = str_replace('{labels}', htmlspecialchars($this->createLabelString()), $template); - $template = str_replace('{tooltipFormat}', $this->tooltipFormat, $template); - $template = str_replace('{disableTooltips}', $this->disableTooltips, $template); return $template; } - - /** - * Format the given value depending on the current value of numberFormat - * - * @param float $value The value to format - * - * @return string The formatted value - */ - private function formatValue($value) - { - if ($this->format === self::NUMBER_FORMAT_NONE) { - return (string)$value; - } elseif ($this->format === self::NUMBER_FORMAT_BYTES) { - return Format::bytes($value); - } elseif ($this->format === self::NUMBER_FORMAT_TIME) { - return Format::duration($value); - } elseif ($this->format === self::NUMBER_FORMAT_RATIO) { - return $value; - } else { - Logger::warning('Unknown format string "' . $this->format . '" for InlinePie, value not formatted.'); - return $value; - } - } } diff --git a/modules/monitoring/application/controllers/HostsController.php b/modules/monitoring/application/controllers/HostsController.php index 37611a001..451f6e44d 100644 --- a/modules/monitoring/application/controllers/HostsController.php +++ b/modules/monitoring/application/controllers/HostsController.php @@ -131,9 +131,6 @@ class Monitoring_HostsController extends Controller { $chart = new InlinePie(array_values($states), $title, $colors); return $chart - ->setLabel(array_map('strtoupper', array_keys($states))) - ->setHeight(100) - ->setWidth(100) ->setTitle($title); } diff --git a/modules/monitoring/application/controllers/ServicesController.php b/modules/monitoring/application/controllers/ServicesController.php index a7b2d0294..315737b31 100644 --- a/modules/monitoring/application/controllers/ServicesController.php +++ b/modules/monitoring/application/controllers/ServicesController.php @@ -159,9 +159,10 @@ class Monitoring_ServicesController extends Controller { $chart = new InlinePie(array_values($states), $title, $colors); return $chart - ->setLabel(array_map('strtoupper', array_keys($states))) - ->setSize(100) - ->setTitle($title); + // ->setLabel(array_map('strtoupper', array_keys($states))) + ->setSize(50) + ->setTitle($title) + ->setSparklineClass('sparkline-multi'); } /** diff --git a/public/js/icinga/behavior/sparkline.js b/public/js/icinga/behavior/sparkline.js index 1992bae0a..e0d0fb0c7 100644 --- a/public/js/icinga/behavior/sparkline.js +++ b/public/js/icinga/behavior/sparkline.js @@ -18,35 +18,33 @@ $('span.sparkline', el).each(function(i, element) { // read custom options - var $spark = $(element); - var labels = $spark.attr('labels').split('|'); - var formatted = $spark.attr('formatted').split('|'); - var title = $spark.attr('title'); - var format = $spark.attr('tooltipFormat'); + var $spark = $(element); + var title = $spark.attr('title'); if ($spark.attr('labels')) { $spark.removeAttr('original-title'); } - var options = { - enableTagOptions: true, - width: $spark.attr('sparkWidth') || 12, - height: $spark.attr('sparkHeight') || 12, - tooltipFormatter: function (sparkline, options, fields) { - var out = format; - var replace = { - title: title, - label: labels[fields.offset] ? labels[fields.offset] : fields.offset, - formatted: formatted[fields.offset] ? formatted[fields.offset] : '', - value: fields.value, - percent: Math.round(fields.percent * 100) / 100 - }; - $.each(replace, function(key, value) { - out = out.replace('{{' + key + '}}', value); - }); - return out; - } - }; - $spark.sparkline('html', options); + + var options; + if ($spark.hasClass('sparkline-perfdata')) { + options = { + enableTagOptions: true, + width: 12, + height: 12, + title: title, + disableTooltips: true + }; + $spark.sparkline('html', options); + } else if ($spark.hasClass('sparkline-multi')) { + options = { + width: 100, + height: 100, + title: title, + enableTagOptions: true + }; + $spark.sparkline('html', options); + } + }); }; From c93b13b1387c1017d4ef4e58d7b9e078a2d4e0bb Mon Sep 17 00:00:00 2001 From: Matthias Jentsch Date: Tue, 23 Dec 2014 15:45:45 +0100 Subject: [PATCH 0059/2920] Rework behavior of perfdata visualization Determine perfdata pie color from host or service state, display zero percent piecharts, only render displayabl PieCharts with min and max values, move perfdata to piechart conversion functions into the Perfdata object. fixes #6423 fixes #6200 fixes #7170 fixes #7304 --- .../application/views/helpers/Perfdata.php | 89 ++++++------------- .../library/Monitoring/Plugin/Perfdata.php | 63 +++++++++++++ public/css/icinga/widgets.less | 7 +- 3 files changed, 90 insertions(+), 69 deletions(-) diff --git a/modules/monitoring/application/views/helpers/Perfdata.php b/modules/monitoring/application/views/helpers/Perfdata.php index 6e168c90f..ada99da9f 100644 --- a/modules/monitoring/application/views/helpers/Perfdata.php +++ b/modules/monitoring/application/views/helpers/Perfdata.php @@ -9,33 +9,36 @@ use Icinga\Module\Monitoring\Plugin\PerfdataSet; class Zend_View_Helper_Perfdata extends Zend_View_Helper_Abstract { - public function perfdata($perfdataStr, $compact = false) + + /** + * Display the given perfdata string to the user + * + * @param $perfdataStr The perfdata string + * @param bool $compact Whether to display the perfdata in compact mode + * @param $color The color indicating the perfdata state + * + * @return string + */ + public function perfdata($perfdataStr, $compact = false, $color = Perfdata::PERFDATA_GREEN) { - $pset = PerfdataSet::fromString($perfdataStr)->asArray(); - $onlyPieChartData = array_filter($pset, function ($e) { return $e->getPercentage() > 0; }); - if ($compact) { - $onlyPieChartData = array_slice($onlyPieChartData, 0, 5); - } else { - $nonPieChartData = array_filter($pset, function ($e) { return $e->getPercentage() == 0; }); - } + $pieChartData = PerfdataSet::fromString($perfdataStr)->asArray(); $result = ''; $table = array(); - foreach ($onlyPieChartData as $perfdata) { - $pieChart = $this->createInlinePie($perfdata); - if ($compact) { - $result .= $pieChart->render(); - } else { - if (! $perfdata->isPercentage()) { - // TODO: Should we trust sprintf-style placeholders in perfdata titles? - $pieChart->setTooltipFormat('{{label}}: {{formatted}} ({{percent}}%)'); + foreach ($pieChartData as $perfdata) { + if ($perfdata->isVisualizable()) { + $pieChart = $perfdata->asInlinePie($color); + if ($compact) { + $result .= $pieChart->render(); + } else { + $table[] = '' . $pieChart->render() + . htmlspecialchars($perfdata->getLabel()) + . ' ' + . htmlspecialchars($this->formatPerfdataValue($perfdata)) . + ' '; } - // $pieChart->setStyle('margin: 0.2em 0.5em 0.2em 0.5em;'); - $table[] = '' . $pieChart->render() - . htmlspecialchars($perfdata->getLabel()) - . ' ' - . htmlspecialchars($this->formatPerfdataValue($perfdata)) . - ' '; + } else { + $table[] = (string)$perfdata; } } @@ -43,32 +46,10 @@ class Zend_View_Helper_Perfdata extends Zend_View_Helper_Abstract return $result; } else { $pieCharts = empty($table) ? '' : '' . implode("\n", $table) . '
    '; - return $pieCharts . "\n" . implode("
    \n", $nonPieChartData); + return $pieCharts; } } - protected function calculatePieChartData(Perfdata $perfdata) - { - $rawValue = $perfdata->getValue(); - $minValue = $perfdata->getMinimumValue() !== null ? $perfdata->getMinimumValue() : 0; - $maxValue = $perfdata->getMaximumValue(); - $usedValue = ($rawValue - $minValue); - $unusedValue = ($maxValue - $minValue) - $usedValue; - - $gray = $unusedValue; - $green = $orange = $red = 0; - // TODO(#6122): Add proper treshold parsing. - if ($perfdata->getCriticalThreshold() && $perfdata->getValue() > $perfdata->getCriticalThreshold()) { - $red = $usedValue; - } elseif ($perfdata->getWarningThreshold() && $perfdata->getValue() > $perfdata->getWarningThreshold()) { - $orange = $usedValue; - } else { - $green = $usedValue; - } - - return array($green, $orange, $red, $gray); - } - protected function formatPerfdataValue(Perfdata $perfdata) { if ($perfdata->isBytes()) { @@ -82,22 +63,4 @@ class Zend_View_Helper_Perfdata extends Zend_View_Helper_Abstract return $perfdata->getValue(); } - protected function createInlinePie(Perfdata $perfdata) - { - $pieChart = new InlinePie($this->calculatePieChartData($perfdata), - $perfdata->getLabel() . ' ' . (int)$perfdata->getPercentage() . '%'); - $pieChart->setDisableTooltip(); - if (Zend_Controller_Front::getInstance()->getRequest()->isXmlHttpRequest()) { - $pieChart->disableNoScript(); - } - - if ($perfdata->isBytes()) { - $pieChart->setNumberFormat(InlinePie::NUMBER_FORMAT_BYTES); - } else if ($perfdata->isSeconds()) { - $pieChart->setNumberFormat(InlinePie::NUMBER_FORMAT_TIME); - } else { - $pieChart->setNumberFormat(InlinePie::NUMBER_FORMAT_RATIO); - } - return $pieChart; - } } diff --git a/modules/monitoring/library/Monitoring/Plugin/Perfdata.php b/modules/monitoring/library/Monitoring/Plugin/Perfdata.php index 6af3cde17..1b687d243 100644 --- a/modules/monitoring/library/Monitoring/Plugin/Perfdata.php +++ b/modules/monitoring/library/Monitoring/Plugin/Perfdata.php @@ -5,9 +5,16 @@ namespace Icinga\Module\Monitoring\Plugin; use InvalidArgumentException; +use Icinga\Exception\ProgrammingError; +use Icinga\Web\Widget\Chart\InlinePie; +use Zend_Controller_Front; class Perfdata { + const PERFDATA_GREEN = 'green'; + const PERFDATA_ORANGE = 'orange'; + const PERFDATA_RED = 'red'; + /** * The performance data value being parsed * @@ -159,6 +166,16 @@ class Perfdata return $this->unit === 'c'; } + /** + * Returns whether it is possible to display a visual representation + * + * @return bool True when the perfdata is visualizable + */ + public function isVisualizable() + { + return isset($this->minValue) && isset($this->maxValue) && isset($this->value); + } + /** * Return this perfomance data's label */ @@ -316,4 +333,50 @@ class Perfdata } } } + + protected function calculatePieChartData( $color) + { + $rawValue = $this->getValue(); + $minValue = $this->getMinimumValue() !== null ? $this->getMinimumValue() : 0; + $maxValue = $this->getMaximumValue(); + $usedValue = ($rawValue - $minValue); + $unusedValue = ($maxValue - $minValue) - $usedValue; + + $gray = $unusedValue; + $green = $orange = $red = 0; + + switch ($color) { + case self::PERFDATA_GREEN: + $green = $usedValue; + break; + + case self::PERFDATA_RED: + $red = $usedValue; + break; + + case self::PERFDATA_ORANGE: + $orange = $usedValue; + break; + } + // TODO(#6122): Add proper treshold parsing. + + return array($green, $orange, $red, $gray); + } + + + public function asInlinePie($color) + { + if (! $this->isVisualizable()) { + throw new ProgrammingError('Cannot calculate piechart data for unvisualizable perfdata entry.'); + } + + $data = $this->calculatePieChartData($color); + $pieChart = new InlinePie($data, $this->getLabel() . ' ' . number_format($this->getPercentage(), 2) . '%'); + $pieChart->setSparklineClass('sparkline-perfdata'); + + if (Zend_Controller_Front::getInstance()->getRequest()->isXmlHttpRequest()) { + $pieChart->disableNoScript(); + } + return $pieChart; + } } diff --git a/public/css/icinga/widgets.less b/public/css/icinga/widgets.less index 87941157c..e2e37d7ab 100644 --- a/public/css/icinga/widgets.less +++ b/public/css/icinga/widgets.less @@ -289,11 +289,6 @@ li li .badge { .sparkline { width: 12px; height: 12px; -} - -.inlinepie { - width: 12px; - height: 12px; position: relative; - top: 10px; + top: 4px; } \ No newline at end of file From 41c101d99fa8ec161b211b851bbf234907333feb Mon Sep 17 00:00:00 2001 From: Matthias Jentsch Date: Tue, 23 Dec 2014 16:12:25 +0100 Subject: [PATCH 0060/2920] Use neutral default color in perfdata piecharts If nothing is known about the state of the monitoring object, the piecharts should neither indicate OK nor Critical. --- library/Icinga/Web/Widget/Chart/InlinePie.php | 2 +- modules/monitoring/application/views/helpers/Perfdata.php | 2 +- .../monitoring/application/views/scripts/list/services.phtml | 1 + modules/monitoring/library/Monitoring/Plugin/Perfdata.php | 5 ++--- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/library/Icinga/Web/Widget/Chart/InlinePie.php b/library/Icinga/Web/Widget/Chart/InlinePie.php index 69de8ebd5..04e3e7318 100644 --- a/library/Icinga/Web/Widget/Chart/InlinePie.php +++ b/library/Icinga/Web/Widget/Chart/InlinePie.php @@ -56,7 +56,7 @@ EOD; * * @var array */ - private $colors = array('#44bb77', '#ffaa44', '#ff5566', '#ddccdd'); + private $colors = array('#049BAF', '#ffaa44', '#ff5566', '#ddccdd'); /** * The title of the chart diff --git a/modules/monitoring/application/views/helpers/Perfdata.php b/modules/monitoring/application/views/helpers/Perfdata.php index ada99da9f..47c34d156 100644 --- a/modules/monitoring/application/views/helpers/Perfdata.php +++ b/modules/monitoring/application/views/helpers/Perfdata.php @@ -19,7 +19,7 @@ class Zend_View_Helper_Perfdata extends Zend_View_Helper_Abstract * * @return string */ - public function perfdata($perfdataStr, $compact = false, $color = Perfdata::PERFDATA_GREEN) + public function perfdata($perfdataStr, $compact = false, $color = Perfdata::PERFDATA_DEFAULT) { $pieChartData = PerfdataSet::fromString($perfdataStr)->asArray(); diff --git a/modules/monitoring/application/views/scripts/list/services.phtml b/modules/monitoring/application/views/scripts/list/services.phtml index 994304f08..8ef6f7fe8 100644 --- a/modules/monitoring/application/views/scripts/list/services.phtml +++ b/modules/monitoring/application/views/scripts/list/services.phtml @@ -1,6 +1,7 @@ getHelper('MonitoringState'); diff --git a/modules/monitoring/library/Monitoring/Plugin/Perfdata.php b/modules/monitoring/library/Monitoring/Plugin/Perfdata.php index 1b687d243..7da4559fd 100644 --- a/modules/monitoring/library/Monitoring/Plugin/Perfdata.php +++ b/modules/monitoring/library/Monitoring/Plugin/Perfdata.php @@ -11,8 +11,7 @@ use Zend_Controller_Front; class Perfdata { - const PERFDATA_GREEN = 'green'; - const PERFDATA_ORANGE = 'orange'; + const PERFDATA_DEFAULT = 'green'; const PERFDATA_RED = 'red'; /** @@ -346,7 +345,7 @@ class Perfdata $green = $orange = $red = 0; switch ($color) { - case self::PERFDATA_GREEN: + case self::PERFDATA_DEFAULT: $green = $usedValue; break; From 7f5ba135eee69a1ec3378e02131fff624e9138e3 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Mon, 29 Dec 2014 09:25:30 +0100 Subject: [PATCH 0061/2920] Revert "Relax session storage check to the `files' save handler" This reverts commit f7d11ce11f82b8e2716ed065ecdb0f4109ddd25a. Sorry mate but a guy on GitHub was faster ;) refs #8053 --- library/Icinga/Web/Session/PhpSession.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library/Icinga/Web/Session/PhpSession.php b/library/Icinga/Web/Session/PhpSession.php index 094685fe4..bef978c0b 100644 --- a/library/Icinga/Web/Session/PhpSession.php +++ b/library/Icinga/Web/Session/PhpSession.php @@ -78,7 +78,7 @@ class PhpSession extends Session } } - if (ini_get('session.save_handler') === 'files' && !is_writable(session_save_path())) { + if (!is_writable(session_save_path())) { throw new ConfigurationError('Can\'t save session'); } From 5e40ce2088ed1a0ae8da5ab4a6148d9e8528387c Mon Sep 17 00:00:00 2001 From: Boden Garman Date: Mon, 15 Dec 2014 13:24:18 +1100 Subject: [PATCH 0062/2920] Only check the session save path is writable if the session handler is 'files' fixes #8053 Signed-off-by: Eric Lippmann --- library/Icinga/Web/Session/PhpSession.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) mode change 100644 => 100755 library/Icinga/Web/Session/PhpSession.php diff --git a/library/Icinga/Web/Session/PhpSession.php b/library/Icinga/Web/Session/PhpSession.php old mode 100644 new mode 100755 index bef978c0b..fa545fd8d --- a/library/Icinga/Web/Session/PhpSession.php +++ b/library/Icinga/Web/Session/PhpSession.php @@ -78,8 +78,9 @@ class PhpSession extends Session } } - if (!is_writable(session_save_path())) { - throw new ConfigurationError('Can\'t save session'); + $sessionSavePath = session_save_path(); + if (session_module_name() === 'files' && !is_writable($sessionSavePath)) { + throw new ConfigurationError("Can't save session, path '$sessionSavePath' is not writable."); } if ($this->exists()) { From 6960a08de04bedc1594dbfdef57d58505bcc13cc Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Mon, 29 Dec 2014 09:39:23 +0100 Subject: [PATCH 0063/2920] Revert "Escape restriction names manually in Forms\Security\RoleForm" This reverts commit 706e5504e651e63b7fee1e5a116f924452bf33d3. HTML5 does allow any non-empty value for the name attribute but Zend only permits alphanumerics, the underscore, the circumflex and any ASCII character in range \x7f to \xff (127 to 255). Thus only escaping the slash (/) is wrong. refs #8086 --- application/forms/Security/RoleForm.php | 14 +------------- 1 file changed, 1 insertion(+), 13 deletions(-) diff --git a/application/forms/Security/RoleForm.php b/application/forms/Security/RoleForm.php index 4edb33d07..0fb53e858 100644 --- a/application/forms/Security/RoleForm.php +++ b/application/forms/Security/RoleForm.php @@ -93,7 +93,7 @@ class RoleForm extends ConfigForm foreach ($this->providedRestrictions as $name => $description) { $this->addElement( 'text', - str_replace('/', '_', $name), + $name, array( 'label' => $name, 'description' => $description @@ -129,12 +129,6 @@ class RoleForm extends ConfigForm ? String::trimSplit($role['permissions']) : null; $role['name'] = $name; - foreach (array_keys($role) as $key) { - // Slashes are not allowed in a form's element name - $value = $role[$key]; - unset($role[$key]); - $role[str_replace('/', '_', $key)] = $value; - } $this->populate($role); return $this; } @@ -236,12 +230,6 @@ class RoleForm extends ConfigForm if (isset($values['permissions'])) { $values['permissions'] = implode(', ', $values['permissions']); } - foreach (array_keys($values) as $key) { - // Slashes are not allowed in a form's element name - $value = $values[$key]; - unset($values[$key]); - $values[str_replace('/', '_', $key)] = $value; - } return $values; } } From 2c1a37afa3a5be52af78fd1a395a5671df5fc54b Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Mon, 29 Dec 2014 10:51:12 +0100 Subject: [PATCH 0064/2920] Use Zend_Form_Element::filterName() for translating restriction names to element names fixes #8086 --- application/forms/Security/RoleForm.php | 39 ++++++++++++++++++++++--- 1 file changed, 35 insertions(+), 4 deletions(-) diff --git a/application/forms/Security/RoleForm.php b/application/forms/Security/RoleForm.php index 0fb53e858..a45ca16ac 100644 --- a/application/forms/Security/RoleForm.php +++ b/application/forms/Security/RoleForm.php @@ -6,6 +6,7 @@ namespace Icinga\Forms\Security; use InvalidArgumentException; use LogicException; +use Zend_Form_Element; use Icinga\Application\Icinga; use Icinga\Forms\ConfigForm; use Icinga\Util\String; @@ -35,6 +36,7 @@ class RoleForm extends ConfigForm */ public function init() { + $helper = new Zend_Form_Element('bogus'); foreach (Icinga::app()->getModuleManager()->getLoadedModules() as $module) { foreach ($module->getProvidedPermissions() as $permission) { /** @var object $permission */ @@ -42,7 +44,18 @@ class RoleForm extends ConfigForm } foreach ($module->getProvidedRestrictions() as $restriction) { /** @var object $restriction */ - $this->providedRestrictions[$restriction->name] = $restriction->description; + $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 + ); } } } @@ -90,13 +103,13 @@ class RoleForm extends ConfigForm ) ) )); - foreach ($this->providedRestrictions as $name => $description) { + foreach ($this->providedRestrictions as $name => $spec) { $this->addElement( 'text', $name, array( - 'label' => $name, - 'description' => $description + 'label' => $spec['name'], + 'description' => $spec['description'] ) ); } @@ -129,6 +142,15 @@ class RoleForm extends ConfigForm ? String::trimSplit($role['permissions']) : null; $role['name'] = $name; + $restrictions = array(); + foreach ($this->providedRestrictions as $name => $spec) { + if (isset($role[$spec['name']])) { + // Translate restriction names to filtered element names + $restrictions[$name] = $role[$spec['name']]; + unset($role[$spec['name']]); + } + } + $role = array_merge($role, $restrictions); $this->populate($role); return $this; } @@ -230,6 +252,15 @@ class RoleForm extends ConfigForm if (isset($values['permissions'])) { $values['permissions'] = implode(', ', $values['permissions']); } + $restrictions = array(); + foreach ($this->providedRestrictions as $name => $spec) { + if (isset($values[$name])) { + // Translate filtered element names to restriction names + $restrictions[$spec['name']] = $values[$name]; + unset($values[$name]); + } + } + $values = array_merge($values, $restrictions); return $values; } } From 49dad43a0affbab49285b80ba5e0de668cedad24 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Mon, 29 Dec 2014 11:53:06 +0100 Subject: [PATCH 0065/2920] Use @type instead of @var in Security/RoleForm.php --- application/forms/Security/RoleForm.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/application/forms/Security/RoleForm.php b/application/forms/Security/RoleForm.php index a45ca16ac..eed9ea441 100644 --- a/application/forms/Security/RoleForm.php +++ b/application/forms/Security/RoleForm.php @@ -19,14 +19,14 @@ class RoleForm extends ConfigForm /** * Provided permissions by currently loaded modules * - * @var array + * @type array */ protected $providedPermissions = array(); /** * Provided restrictions by currently loaded modules * - * @var array + * @type array */ protected $providedRestrictions = array(); @@ -39,11 +39,11 @@ class RoleForm extends ConfigForm $helper = new Zend_Form_Element('bogus'); foreach (Icinga::app()->getModuleManager()->getLoadedModules() as $module) { foreach ($module->getProvidedPermissions() as $permission) { - /** @var object $permission */ + /** @type object $permission */ $this->providedPermissions[$permission->name] = $permission->name . ': ' . $permission->description; } foreach ($module->getProvidedRestrictions() as $restriction) { - /** @var object $restriction */ + /** @type 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) From 4441c1d4de54295ade7fc57ff290534a33da2189 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Mon, 29 Dec 2014 11:53:55 +0100 Subject: [PATCH 0066/2920] Allow to grant every permission --- application/forms/Security/RoleForm.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/application/forms/Security/RoleForm.php b/application/forms/Security/RoleForm.php index eed9ea441..b27a4ec8b 100644 --- a/application/forms/Security/RoleForm.php +++ b/application/forms/Security/RoleForm.php @@ -21,7 +21,7 @@ class RoleForm extends ConfigForm * * @type array */ - protected $providedPermissions = array(); + protected $providedPermissions = array('*' => '*'); /** * Provided restrictions by currently loaded modules From 2db286543385f569f18c0901ee59608ed560a2b5 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Mon, 29 Dec 2014 12:11:49 +0100 Subject: [PATCH 0067/2920] Do not use an extra loop for generating the unhandled objects filter in ServicesController.php --- .../controllers/ServicesController.php | 22 +++++++++---------- 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/modules/monitoring/application/controllers/ServicesController.php b/modules/monitoring/application/controllers/ServicesController.php index 315737b31..fdc040d29 100644 --- a/modules/monitoring/application/controllers/ServicesController.php +++ b/modules/monitoring/application/controllers/ServicesController.php @@ -74,6 +74,7 @@ class Monitoring_ServicesController extends Controller 'service_obsessing'*/ )); $unhandledObjects = array(); + $unhandledFilterExpressions = array(); $acknowledgedObjects = array(); $objectsInDowntime = array(); $serviceStates = array( @@ -94,6 +95,10 @@ class Monitoring_ServicesController extends Controller /** @var Service $service */ if ((bool) $service->problem === true && (bool) $service->handled === false) { $unhandledObjects[] = $service; + $unhandledFilterExpressions[] = Filter::matchAll( + Filter::where('host', $service->getHost()->getName()), + Filter::where('service', $service->getName()) + ); } if ((bool) $service->acknowledged === true) { $acknowledgedObjects[] = $service; @@ -125,18 +130,11 @@ class Monitoring_ServicesController extends Controller $this->view->serviceStates = $serviceStates; $this->view->objects = $this->serviceList; $this->view->unhandledObjects = $unhandledObjects; - $unhandledFilterExpressions = array(); - foreach ($unhandledObjects as $service) { - $unhandledFilterExpressions[] = Filter::matchAll( - Filter::expression('host', '=', $service->getHost()->getName()), - Filter::expression('service', '=', $service->getName()) - ); - } - $queryString = Filter::matchAny($unhandledFilterExpressions)->toQueryString(); - $this->view->acknowledgeUnhandledLink = Url::fromPath('monitoring/services/acknowledge-problem'); - $this->view->acknowledgeUnhandledLink->setQueryString($queryString); - $this->view->downtimeUnhandledLink = Url::fromPath('monitoring/services/schedule-downtime'); - $this->view->downtimeUnhandledLink->setQueryString($queryString); + $unhandledFilterQueryString = Filter::matchAny($unhandledFilterExpressions)->toQueryString(); + $this->view->acknowledgeUnhandledLink = Url::fromPath('monitoring/services/acknowledge-problem') + ->setQueryString($unhandledFilterQueryString); + $this->view->downtimeUnhandledLink = Url::fromPath('monitoring/services/schedule-downtime') + ->setQueryString($unhandledFilterQueryString); $this->view->acknowledgedObjects = $acknowledgedObjects; $this->view->objectsInDowntime = $objectsInDowntime; $this->view->inDowntimeLink = Url::fromRequest() From f1f808b7a3d820eaf8a004954dfc41a7e799d798 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Mon, 29 Dec 2014 12:17:17 +0100 Subject: [PATCH 0068/2920] Do not use array_map for generating the unhandled objects filter in HostsController.php --- .../application/controllers/HostsController.php | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/modules/monitoring/application/controllers/HostsController.php b/modules/monitoring/application/controllers/HostsController.php index 451f6e44d..8fe431ca2 100644 --- a/modules/monitoring/application/controllers/HostsController.php +++ b/modules/monitoring/application/controllers/HostsController.php @@ -72,6 +72,7 @@ class Monitoring_HostsController extends Controller 'host_obsessing'*/ )); $unhandledObjects = array(); + $unhandledFilterExpressions = array(); $acknowledgedObjects = array(); $objectsInDowntime = array(); $hostStates = array( @@ -81,9 +82,10 @@ class Monitoring_HostsController extends Controller Host::getStateText(Host::STATE_PENDING) => 0, ); foreach ($this->hostList as $host) { - /** @var Service $host */ + /** @var Host $host */ if ((bool) $host->problem === true && (bool) $host->handled === false) { $unhandledObjects[] = $host; + $unhandledFilterExpressions[] = Filter::where('host', $host->getName()); } if ((bool) $host->acknowledged === true) { $acknowledgedObjects[] = $host; @@ -108,12 +110,11 @@ class Monitoring_HostsController extends Controller $this->view->hostStates = $hostStates; $this->view->objects = $this->hostList; $this->view->unhandledObjects = $unhandledObjects; - $this->view->acknowledgeUnhandledLink = Url::fromPath('monitoring/hosts/acknowledge-problem')->setQueryString( - Filter::where('host', array_map(function ($h) { return $h->host; }, $unhandledObjects))->toQueryString() - ); - $this->view->downtimeUnhandledLink = Url::fromPath('monitoring/hosts/schedule-downtime')->setQueryString( - Filter::where('host', array_map(function ($h) { return $h->host; }, $unhandledObjects))->toQueryString() - ); + $unhandledFilterQueryString = Filter::matchAny($unhandledFilterExpressions)->toQueryString(); + $this->view->acknowledgeUnhandledLink = Url::fromPath('monitoring/hosts/acknowledge-problem') + ->setQueryString($unhandledFilterQueryString); + $this->view->downtimeUnhandledLink = Url::fromPath('monitoring/hosts/schedule-downtime') + ->setQueryString($unhandledFilterQueryString); $this->view->acknowledgedObjects = $acknowledgedObjects; $this->view->objectsInDowntime = $objectsInDowntime; $this->view->inDowntimeLink = Url::fromRequest() From 26bc56e9df306cea1e1937720d07c1dc5b6f519b Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Mon, 29 Dec 2014 12:19:37 +0100 Subject: [PATCH 0069/2920] monitoring: Fix the link to hosts in downtime when multiple hosts are selected --- .../monitoring/application/controllers/HostsController.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/modules/monitoring/application/controllers/HostsController.php b/modules/monitoring/application/controllers/HostsController.php index 8fe431ca2..09957a4a0 100644 --- a/modules/monitoring/application/controllers/HostsController.php +++ b/modules/monitoring/application/controllers/HostsController.php @@ -75,6 +75,7 @@ class Monitoring_HostsController extends Controller $unhandledFilterExpressions = array(); $acknowledgedObjects = array(); $objectsInDowntime = array(); + $downtimeFilterExpressions = array(); $hostStates = array( Host::getStateText(Host::STATE_UP) => 0, Host::getStateText(Host::STATE_DOWN) => 0, @@ -92,6 +93,7 @@ class Monitoring_HostsController extends Controller } if ((bool) $host->in_downtime === true) { $objectsInDowntime[] = $host; + $downtimeFilterExpressions[] = Filter::where('downtime_host', $host->getName()); } ++$hostStates[$host::getStateText($host->state)]; } @@ -117,8 +119,8 @@ class Monitoring_HostsController extends Controller ->setQueryString($unhandledFilterQueryString); $this->view->acknowledgedObjects = $acknowledgedObjects; $this->view->objectsInDowntime = $objectsInDowntime; - $this->view->inDowntimeLink = Url::fromRequest() - ->setPath('monitoring/list/downtimes'); + $this->view->inDowntimeLink = Url::fromPath('monitoring/list/downtimes') + ->setQueryString(Filter::matchAny($downtimeFilterExpressions)->toQueryString()); $this->view->havingCommentsLink = Url::fromRequest() ->setPath('monitoring/list/comments'); $this->view->hostStatesPieChart = $this->createPieChart( From bf92f9fa85476450e898333293da3c49575f2e0b Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Mon, 29 Dec 2014 12:25:41 +0100 Subject: [PATCH 0070/2920] monitoring: Fix the link to services in downtime when multiple services are selected --- .../application/controllers/ServicesController.php | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/modules/monitoring/application/controllers/ServicesController.php b/modules/monitoring/application/controllers/ServicesController.php index fdc040d29..4d08622c2 100644 --- a/modules/monitoring/application/controllers/ServicesController.php +++ b/modules/monitoring/application/controllers/ServicesController.php @@ -77,6 +77,7 @@ class Monitoring_ServicesController extends Controller $unhandledFilterExpressions = array(); $acknowledgedObjects = array(); $objectsInDowntime = array(); + $downtimeFilterExpressions = array(); $serviceStates = array( Service::getStateText(Service::STATE_OK) => 0, Service::getStateText(Service::STATE_WARNING) => 0, @@ -105,6 +106,10 @@ class Monitoring_ServicesController extends Controller } if ((bool) $service->in_downtime === true) { $objectsInDowntime[] = $service; + $downtimeFilterExpressions[] = Filter::matchAll( + Filter::where('downtime_host', $service->getHost()->getName()), + Filter::where('downtime_service', $service->getName()) + ); } ++$serviceStates[$service::getStateText($service->state)]; if (! isset($knownHostStates[$service->getHost()->getName()])) { @@ -137,8 +142,8 @@ class Monitoring_ServicesController extends Controller ->setQueryString($unhandledFilterQueryString); $this->view->acknowledgedObjects = $acknowledgedObjects; $this->view->objectsInDowntime = $objectsInDowntime; - $this->view->inDowntimeLink = Url::fromRequest() - ->setPath('monitoring/list/downtimes'); + $this->view->inDowntimeLink = Url::fromPath('monitoring/list/downtimes') + ->setQueryString(Filter::matchAny($downtimeFilterExpressions)->toQueryString()); $this->view->havingCommentsLink = Url::fromRequest() ->setPath('monitoring/list/comments'); $this->view->serviceStatesPieChart = $this->createPieChart( From a48adb5e4bea9fd72ddc2f39be60ec1b671cda7f Mon Sep 17 00:00:00 2001 From: root Date: Wed, 24 Dec 2014 16:30:30 +0000 Subject: [PATCH 0071/2920] doc: Fix typo in installation.md Signed-off-by: Eric Lippmann --- doc/installation.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/installation.md b/doc/installation.md index 88c9c3650..6eb6737ec 100644 --- a/doc/installation.md +++ b/doc/installation.md @@ -26,7 +26,7 @@ repository either via git or http protocol using the following URLs: * http://git.icinga.org/icingaweb2.git There is also a browsable version available at -[gi.icinga.org](https://git.icinga.org/?p=icingaweb2.git;a=summary "Icinga Web 2 Git Repository"). +[git.icinga.org](https://git.icinga.org/?p=icingaweb2.git;a=summary "Icinga Web 2 Git Repository"). This version also offers snapshots for easy download which you can use if you do not have git present on your system. ```` From 7d36a59c67dba7b177f53361f479929c5e19ccd5 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Mon, 29 Dec 2014 14:01:19 +0100 Subject: [PATCH 0072/2920] Use '@return $this' instead of '@return self' for document fluent interfaces in ApplicationBootstrap.php --- .../Icinga/Application/ApplicationBootstrap.php | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/library/Icinga/Application/ApplicationBootstrap.php b/library/Icinga/Application/ApplicationBootstrap.php index 81230a7fb..86dcef8c4 100644 --- a/library/Icinga/Application/ApplicationBootstrap.php +++ b/library/Icinga/Application/ApplicationBootstrap.php @@ -333,7 +333,7 @@ abstract class ApplicationBootstrap /** * Setup Icinga auto loader * - * @return self + * @return $this */ public function setupAutoloader() { @@ -366,7 +366,7 @@ abstract class ApplicationBootstrap /** * Setup module manager * - * @return self + * @return $this */ protected function setupModuleManager() { @@ -381,7 +381,7 @@ abstract class ApplicationBootstrap /** * Load all enabled modules * - * @return self + * @return $this */ protected function loadEnabledModules() { @@ -396,7 +396,7 @@ abstract class ApplicationBootstrap /** * Setup default logging * - * @return self + * @return $this */ protected function setupLogging() { @@ -413,7 +413,7 @@ abstract class ApplicationBootstrap /** * Load Configuration * - * @return self + * @return $this */ protected function loadConfig() { @@ -432,7 +432,7 @@ abstract class ApplicationBootstrap /** * Error handling configuration * - * @return self + * @return $this */ protected function setupErrorHandling() { @@ -458,7 +458,7 @@ abstract class ApplicationBootstrap /** * Set up logger * - * @return self + * @return $this */ protected function setupLogger() { @@ -475,7 +475,7 @@ abstract class ApplicationBootstrap /** * Set up the resource factory * - * @return self + * @return $this */ protected function setupResourceFactory() { From 611d01788f787bd4c2451bb75c05f224174ff984 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Mon, 29 Dec 2014 14:29:31 +0100 Subject: [PATCH 0073/2920] Add setup related utility functions to ApplicationBootstrap.php --- .../Application/ApplicationBootstrap.php | 41 +++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/library/Icinga/Application/ApplicationBootstrap.php b/library/Icinga/Application/ApplicationBootstrap.php index 86dcef8c4..92e97ba39 100644 --- a/library/Icinga/Application/ApplicationBootstrap.php +++ b/library/Icinga/Application/ApplicationBootstrap.php @@ -113,6 +113,13 @@ abstract class ApplicationBootstrap */ protected $isWeb = false; + /** + * Whether Icinga Web 2 requires setup + * + * @type bool + */ + protected $requiresSetup = false; + /** * Constructor * @@ -393,6 +400,40 @@ abstract class ApplicationBootstrap return $this; } + /** + * Load the setup module if Icinga Web 2 requires setup + * + * @return $this + */ + protected function loadSetupModuleIfNecessary() + { + if (! @file_exists($this->config->resolvePath('config.ini'))) { + $this->requiresSetup = true; + $this->moduleManager->loadModule('setup'); + } + return $this; + } + + /** + * Get whether Icinga Web 2 requires setup + * + * @return bool + */ + public function requiresSetup() + { + return $this->requiresSetup; + } + + /** + * Get whether the setup token exists + * + * @return bool + */ + public function setupTokenExists() + { + return @file_exists($this->config->resolvePath('setup.token')); + } + /** * Setup default logging * From 9d8fab51b1c4f147d70cef111c5cdd360b66fe6f Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Mon, 29 Dec 2014 14:30:06 +0100 Subject: [PATCH 0074/2920] Use the setup related utility functions in AuthenticationController.php --- application/controllers/AuthenticationController.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/application/controllers/AuthenticationController.php b/application/controllers/AuthenticationController.php index 00dae1c6d..d2c9d4873 100644 --- a/application/controllers/AuthenticationController.php +++ b/application/controllers/AuthenticationController.php @@ -15,6 +15,7 @@ use Icinga\Exception\NotReadableError; use Icinga\Exception\ConfigurationError; use Icinga\User; use Icinga\Web\Url; +use Icinga\Application\Icinga; /** * Application wide controller for authentication @@ -33,7 +34,8 @@ class AuthenticationController extends ActionController */ public function loginAction() { - if (@file_exists(Config::resolvePath('setup.token')) && !@file_exists(Config::resolvePath('config.ini'))) { + $icinga = Icinga::app(); + if ($icinga->setupTokenExists() && $icinga->requiresSetup()) { $this->redirectNow(Url::fromPath('setup')); } @@ -139,7 +141,7 @@ class AuthenticationController extends ActionController $this->view->errorInfo = $e->getMessage(); } - $this->view->configMissing = is_dir(Config::$configDir) === false; + $this->view->requiresSetup = Icinga::app()->requiresSetup(); } /** From 250e05f2e81d448f9f03e6e20fbbfd42331038dd Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Mon, 29 Dec 2014 14:30:47 +0100 Subject: [PATCH 0075/2920] Optimize imports in AuthenticationController.php --- .../controllers/AuthenticationController.php | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/application/controllers/AuthenticationController.php b/application/controllers/AuthenticationController.php index d2c9d4873..2d7926819 100644 --- a/application/controllers/AuthenticationController.php +++ b/application/controllers/AuthenticationController.php @@ -4,18 +4,18 @@ # namespace Icinga\Application\Controllers; -use Icinga\Authentication\Backend\AutoLoginBackend; -use Icinga\Web\Controller\ActionController; -use Icinga\Forms\Authentication\LoginForm; -use Icinga\Authentication\AuthChain; use Icinga\Application\Config; -use Icinga\Application\Logger; -use Icinga\Exception\AuthenticationException; -use Icinga\Exception\NotReadableError; -use Icinga\Exception\ConfigurationError; -use Icinga\User; -use Icinga\Web\Url; use Icinga\Application\Icinga; +use Icinga\Application\Logger; +use Icinga\Authentication\AuthChain; +use Icinga\Authentication\Backend\AutoLoginBackend; +use Icinga\Exception\AuthenticationException; +use Icinga\Exception\ConfigurationError; +use Icinga\Exception\NotReadableError; +use Icinga\Forms\Authentication\LoginForm; +use Icinga\User; +use Icinga\Web\Controller\ActionController; +use Icinga\Web\Url; /** * Application wide controller for authentication From 74ce666cd85a4ca3b1abf38874cf78b686986a19 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Mon, 29 Dec 2014 14:31:07 +0100 Subject: [PATCH 0076/2920] Use the requiresSetup variable instead of configMissing in login.phtml --- application/views/scripts/authentication/login.phtml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/application/views/scripts/authentication/login.phtml b/application/views/scripts/authentication/login.phtml index 416e651d1..a3d8fcfa9 100644 --- a/application/views/scripts/authentication/login.phtml +++ b/application/views/scripts/authentication/login.phtml @@ -15,7 +15,7 @@ form ?>
    - +
    Date: Mon, 29 Dec 2014 14:31:34 +0100 Subject: [PATCH 0077/2920] Web: Load setup module if necessary --- library/Icinga/Application/Web.php | 1 + 1 file changed, 1 insertion(+) diff --git a/library/Icinga/Application/Web.php b/library/Icinga/Application/Web.php index a21f21025..5b18f1be8 100644 --- a/library/Icinga/Application/Web.php +++ b/library/Icinga/Application/Web.php @@ -104,6 +104,7 @@ class Web extends ApplicationBootstrap ->setupZendMvc() ->setupFormNamespace() ->setupModuleManager() + ->loadSetupModuleIfNecessary() ->loadEnabledModules() ->setupRoute() ->setupPagination(); From 19387b24ab726529d3a7fb7cd25b7bfc83c44f55 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Mon, 29 Dec 2014 14:32:20 +0100 Subject: [PATCH 0078/2920] Do not use a new function for getting the configuration directory in our web wizard --- modules/setup/library/Setup/WebWizard.php | 22 +++------------------- 1 file changed, 3 insertions(+), 19 deletions(-) diff --git a/modules/setup/library/Setup/WebWizard.php b/modules/setup/library/Setup/WebWizard.php index faa123fe8..8dff112f5 100644 --- a/modules/setup/library/Setup/WebWizard.php +++ b/modules/setup/library/Setup/WebWizard.php @@ -9,6 +9,7 @@ use Icinga\Web\Form; use Icinga\Web\Wizard; use Icinga\Web\Request; use Icinga\Application\Config; +use Icinga\Application\Icinga; use Icinga\Application\Platform; use Icinga\Module\Setup\Forms\ModulePage; use Icinga\Module\Setup\Forms\WelcomePage; @@ -343,7 +344,7 @@ class WebWizard extends Wizard implements SetupWizard ); } - $configDir = $this->getConfigDir(); + $configDir = Icinga::app()->getConfigDir(); $setup->addStep( new MakeDirStep( array( @@ -528,7 +529,7 @@ class WebWizard extends Wizard implements SetupWizard ) ); - $configDir = $this->getConfigDir(); + $configDir = Icinga::app()->getConfigDir(); $requirements->addMandatory( mt('setup', 'Writable Config Directory'), mt( @@ -551,21 +552,4 @@ class WebWizard extends Wizard implements SetupWizard return $requirements; } - - /** - * Return the configuration directory of Icinga Web 2 - * - * @return string - */ - protected function getConfigDir() - { - if (array_key_exists('ICINGAWEB_CONFIGDIR', $_SERVER)) { - $configDir = $_SERVER['ICINGAWEB_CONFIGDIR']; - } else { - $configDir = '/etc/icingaweb'; - } - - $canonical = realpath($configDir); - return $canonical ? $canonical : $configDir; - } } From daaf242145fb2d75209d0917e528fedc526421dc Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Mon, 29 Dec 2014 14:33:07 +0100 Subject: [PATCH 0079/2920] Fix the default configuration path in our web wizard --- modules/setup/library/Setup/WebWizard.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/setup/library/Setup/WebWizard.php b/modules/setup/library/Setup/WebWizard.php index 8dff112f5..e4d61dfd7 100644 --- a/modules/setup/library/Setup/WebWizard.php +++ b/modules/setup/library/Setup/WebWizard.php @@ -534,7 +534,7 @@ class WebWizard extends Wizard implements SetupWizard mt('setup', 'Writable Config Directory'), mt( 'setup', - 'The Icinga Web 2 configuration directory defaults to "/etc/icingaweb", if' . + 'The Icinga Web 2 configuration directory defaults to "/etc/icingaweb2", if' . ' not explicitly set in the environment variable "ICINGAWEB_CONFIGDIR".' ), is_writable($configDir), From 2bd9d27e054fcf86970e07f59127b19bf676688a Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Mon, 29 Dec 2014 14:33:37 +0100 Subject: [PATCH 0080/2920] Do not validate the mode of the setup.token Relying on the mode of the configuration directory must be sufficient. --- .../Setup/Web/Form/Validator/TokenValidator.php | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/modules/setup/library/Setup/Web/Form/Validator/TokenValidator.php b/modules/setup/library/Setup/Web/Form/Validator/TokenValidator.php index 7dc2ea2f9..fa858f531 100644 --- a/modules/setup/library/Setup/Web/Form/Validator/TokenValidator.php +++ b/modules/setup/library/Setup/Web/Form/Validator/TokenValidator.php @@ -38,10 +38,6 @@ class TokenValidator extends Zend_Validate_Abstract mt('setup', 'Cannot validate token, file "%s" is empty. Please define a token.'), $tokenPath ), - 'TOKEN_FILE_PUBLIC' => sprintf( - mt('setup', 'Cannot validate token, file "%s" must only be accessible by the webserver\'s user.'), - $tokenPath - ), 'TOKEN_INVALID' => mt('setup', 'Invalid token supplied.') ); } @@ -56,12 +52,6 @@ class TokenValidator extends Zend_Validate_Abstract */ public function isValid($value, $context = null) { - $tokenStats = @stat($this->tokenPath); - if (($tokenStats['mode'] & 4) === 4) { - $this->_error('TOKEN_FILE_PUBLIC'); - return false; - } - try { $file = new File($this->tokenPath); $expectedToken = trim($file->fgets()); From 94a4b4425f82412dead4a26c57af9763b53d12cd Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Mon, 29 Dec 2014 15:42:24 +0100 Subject: [PATCH 0081/2920] puppet: Use icingaweb2 instead of icingaweb in paths and database setup --- .puppet/hiera/common.yaml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/.puppet/hiera/common.yaml b/.puppet/hiera/common.yaml index 0a85ba63a..c76b904bf 100644 --- a/.puppet/hiera/common.yaml +++ b/.puppet/hiera/common.yaml @@ -1,7 +1,7 @@ --- -icingaweb2::config: /etc/icingaweb -icingaweb2::log: /var/log/icingaweb/icingaweb.log -icingaweb2::web_path: icingaweb -icingaweb2::db_user: icingaweb -icingaweb2::db_pass: icingaweb -icingaweb2::db_name: icingaweb +icingaweb2::config: /etc/icingaweb2 +icingaweb2::log: /var/log/icingaweb2/icingaweb2.log +icingaweb2::web_path: icingaweb2 +icingaweb2::db_user: icingaweb2 +icingaweb2::db_pass: icingaweb2 +icingaweb2::db_name: icingaweb2 From e1bedc9afedfa163268f8cb536e18f4f26ad54ca Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Mon, 29 Dec 2014 15:55:57 +0100 Subject: [PATCH 0082/2920] Use Icinga 2's default Livestatus socket path as default when configuring a livestatus resource --- application/forms/Config/Resource/LivestatusResourceForm.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/application/forms/Config/Resource/LivestatusResourceForm.php b/application/forms/Config/Resource/LivestatusResourceForm.php index d90600370..2262cf583 100644 --- a/application/forms/Config/Resource/LivestatusResourceForm.php +++ b/application/forms/Config/Resource/LivestatusResourceForm.php @@ -44,7 +44,7 @@ class LivestatusResourceForm extends Form 'required' => true, 'label' => t('Socket'), 'description' => t('The path to your livestatus socket used for querying monitoring data'), - 'value' => realpath(Icinga::app()->getApplicationDir() . '/../var/rw/livestatus') + 'value' => '/var/run/icinga2/cmd/livestatus' ) ); From cfb52eeadb1c0a0404d47bf5b74a9a48cff68ad0 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Mon, 29 Dec 2014 15:56:32 +0100 Subject: [PATCH 0083/2920] Do not use a default regular expression for stripping off parts of a username when configuring an auto-login backend There's no safe default for this. --- .../forms/Config/Authentication/AutologinBackendForm.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/application/forms/Config/Authentication/AutologinBackendForm.php b/application/forms/Config/Authentication/AutologinBackendForm.php index a21d2c006..97b5dfed7 100644 --- a/application/forms/Config/Authentication/AutologinBackendForm.php +++ b/application/forms/Config/Authentication/AutologinBackendForm.php @@ -53,8 +53,10 @@ class AutologinBackendForm extends Form 'strip_username_regexp', array( 'label' => t('Filter Pattern'), - 'description' => t('The regular expression to use to strip specific parts off from usernames. Leave empty if you do not want to strip off anything'), - 'value' => '/\@[^$]+$/', + 'description' => t( + 'The regular expression to use to strip specific parts off from usernames.' + . ' Leave empty if you do not want to strip off anything' + ), 'validators' => array( new Zend_Validate_Callback(function ($value) { return @preg_match($value, '') !== false; From 5bc2144b18670fdc98756b87ecfc979be97c5808 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Mon, 29 Dec 2014 16:01:07 +0100 Subject: [PATCH 0084/2920] Use 'icingaweb2' as default application prefix for logging to syslog --- application/forms/Config/General/LoggingConfigForm.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/application/forms/Config/General/LoggingConfigForm.php b/application/forms/Config/General/LoggingConfigForm.php index deed06011..bb9bea33a 100644 --- a/application/forms/Config/General/LoggingConfigForm.php +++ b/application/forms/Config/General/LoggingConfigForm.php @@ -67,7 +67,7 @@ class LoggingConfigForm extends Form 'required' => true, 'label' => t('Application Prefix'), 'description' => t('The name of the application by which to prefix syslog messages.'), - 'value' => 'icingaweb', + 'value' => 'icingaweb2', 'validators' => array( array( 'Regex', From f0fe6246acf8e3b1c0d1b9c8b7524ac450b7d99c Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Mon, 29 Dec 2014 16:02:40 +0100 Subject: [PATCH 0085/2920] Use '/var/log/icingaweb2/icingaweb2.log' as default path when logging to file --- .../forms/Config/General/LoggingConfigForm.php | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/application/forms/Config/General/LoggingConfigForm.php b/application/forms/Config/General/LoggingConfigForm.php index bb9bea33a..759c2a6e3 100644 --- a/application/forms/Config/General/LoggingConfigForm.php +++ b/application/forms/Config/General/LoggingConfigForm.php @@ -106,7 +106,7 @@ class LoggingConfigForm extends Form 'required' => true, 'label' => t('File path'), 'description' => t('The full path to the log file to write messages to.'), - 'value' => $this->getDefaultLogDir(), + 'value' => '/var/log/icingaweb2/icingaweb2.log', 'validators' => array(new WritablePathValidator()) ) ); @@ -114,14 +114,4 @@ class LoggingConfigForm extends Form return $this; } - - /** - * Return the default logging directory for type 'file' - * - * @return string - */ - protected function getDefaultLogDir() - { - return realpath(Icinga::app()->getApplicationDir('../var/log/icingaweb.log')); - } } From ff17c3729cfa1b073277f8f5c4278c554a5c26a5 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Mon, 29 Dec 2014 16:06:34 +0100 Subject: [PATCH 0086/2920] setup: Use 'icingaweb2' as default authentication backend name --- modules/setup/application/forms/AuthBackendPage.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/setup/application/forms/AuthBackendPage.php b/modules/setup/application/forms/AuthBackendPage.php index fac2a7bbd..bd820d352 100644 --- a/modules/setup/application/forms/AuthBackendPage.php +++ b/modules/setup/application/forms/AuthBackendPage.php @@ -112,7 +112,7 @@ class AuthBackendPage extends Form } $this->addElements($backendForm->getElements()); - $this->getElement('name')->setValue('icingaweb'); + $this->getElement('name')->setValue('icingaweb2'); } /** From 4cf8da4bb9bd0bf09cb80ac82b79852126e7ba0c Mon Sep 17 00:00:00 2001 From: Matthias Jentsch Date: Mon, 29 Dec 2014 13:30:54 +0100 Subject: [PATCH 0087/2920] Do not focus logout menu item after a recurring login Implement new MenuItemRenderer made for pages that are not part of the regular site navigation and should trigger a complete site reload instead of handling it via XHR. --- library/Icinga/Web/Menu.php | 3 ++- .../Web/Menu/ForeignMenuItemRenderer.php | 24 +++++++++++++++++++ 2 files changed, 26 insertions(+), 1 deletion(-) create mode 100644 library/Icinga/Web/Menu/ForeignMenuItemRenderer.php diff --git a/library/Icinga/Web/Menu.php b/library/Icinga/Web/Menu.php index 18a17ea67..a74112dc4 100644 --- a/library/Icinga/Web/Menu.php +++ b/library/Icinga/Web/Menu.php @@ -248,7 +248,8 @@ class Menu implements RecursiveIterator $section->add(t('Logout'), array( 'url' => 'authentication/logout', - 'priority' => 700 + 'priority' => 700, + 'renderer' => 'ForeignMenuItemRenderer' )); } } diff --git a/library/Icinga/Web/Menu/ForeignMenuItemRenderer.php b/library/Icinga/Web/Menu/ForeignMenuItemRenderer.php new file mode 100644 index 000000000..659709868 --- /dev/null +++ b/library/Icinga/Web/Menu/ForeignMenuItemRenderer.php @@ -0,0 +1,24 @@ +%s%s', + $menu->getUrl() ?: '#', + $menu->getIcon() ? ' ' : '', + htmlspecialchars($menu->getTitle()) + ); + } +} From 3d07049fbfc863f28969afd0b16c6bfe9a2ab15f Mon Sep 17 00:00:00 2001 From: Matthias Jentsch Date: Mon, 29 Dec 2014 16:14:12 +0100 Subject: [PATCH 0088/2920] Re-render menu item after setting class to active Force the browser to re-render the menu item, to update the link layout immediately by recreting the content html. fixes #7897 --- public/js/icinga/behavior/navigation.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/public/js/icinga/behavior/navigation.js b/public/js/icinga/behavior/navigation.js index fde043c01..53fc5c8af 100644 --- a/public/js/icinga/behavior/navigation.js +++ b/public/js/icinga/behavior/navigation.js @@ -32,6 +32,15 @@ if ($outerMenu.size()) { $outerMenu.addClass('active'); } + + /* + Recreate the html content of the menu item to force the browser to update the layout, or else + the link would only be visible as active after another click or page reload in Gecko and WebKit. + + fixes #7897 + */ + $selectedMenu.html($selectedMenu.html()); + } else { // store menu state var $menus = $('#menu li.active', el); From a1950aabbac1699136d1567583bc58a42e52b290 Mon Sep 17 00:00:00 2001 From: Matthias Jentsch Date: Mon, 29 Dec 2014 16:27:28 +0100 Subject: [PATCH 0089/2920] Fix some obsolete or wrong docstrings --- library/Icinga/Web/Controller/ActionController.php | 2 +- library/Icinga/Web/Menu.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/library/Icinga/Web/Controller/ActionController.php b/library/Icinga/Web/Controller/ActionController.php index 400803dce..013f31099 100644 --- a/library/Icinga/Web/Controller/ActionController.php +++ b/library/Icinga/Web/Controller/ActionController.php @@ -270,7 +270,7 @@ class ActionController extends Zend_Controller_Action /** * Redirect to the login path * - * @param string $afterLogin The action to call when the login was successful. Defaults to '/index/welcome' + * @param Url $afterLogin The action to call when the login was successful. Defaults to '/index/welcome' * * @throws \Exception */ diff --git a/library/Icinga/Web/Menu.php b/library/Icinga/Web/Menu.php index a74112dc4..f0279ea9c 100644 --- a/library/Icinga/Web/Menu.php +++ b/library/Icinga/Web/Menu.php @@ -367,7 +367,7 @@ class Menu implements RecursiveIterator /** * Return the url of this menu * - * @return string + * @return Url */ public function getUrl() { From 0b8ab18243da17af6c128da18ad691491013a144 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Mon, 29 Dec 2014 16:30:44 +0100 Subject: [PATCH 0090/2920] Parsedown: Rename LICENSE.txt to LICENSE --- library/vendor/Parsedown/{LICENSE.txt => LICENSE} | 0 library/vendor/Parsedown/SOURCE | 1 + 2 files changed, 1 insertion(+) rename library/vendor/Parsedown/{LICENSE.txt => LICENSE} (100%) diff --git a/library/vendor/Parsedown/LICENSE.txt b/library/vendor/Parsedown/LICENSE similarity index 100% rename from library/vendor/Parsedown/LICENSE.txt rename to library/vendor/Parsedown/LICENSE diff --git a/library/vendor/Parsedown/SOURCE b/library/vendor/Parsedown/SOURCE index c5a2c7c28..43ee6c61c 100644 --- a/library/vendor/Parsedown/SOURCE +++ b/library/vendor/Parsedown/SOURCE @@ -4,3 +4,4 @@ DESTINATION=. wget -O ${FILENAME}.tar.gz https://github.com/erusev/parsedown/archive/${RELEASE}.tar.gz tar xfz ${FILENAME}.tar.gz -C $DESTINATION/ --strip-components 1 $FILENAME/Parsedown.php $FILENAME/LICENSE.txt chmod 644 $DESTINATION/Parsedown.php +mv LICENSE.txt LICENSE From 57121bf0ea1ddfb099e80286a2d8a65d7316f3a5 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Mon, 29 Dec 2014 16:31:21 +0100 Subject: [PATCH 0091/2920] dompdf: Rename LICENSE.LGPL to LICENSE --- library/vendor/dompdf/{LICENSE.LGPL => LICENSE} | 0 library/vendor/dompdf/SOURCE | 1 + 2 files changed, 1 insertion(+) rename library/vendor/dompdf/{LICENSE.LGPL => LICENSE} (100%) diff --git a/library/vendor/dompdf/LICENSE.LGPL b/library/vendor/dompdf/LICENSE similarity index 100% rename from library/vendor/dompdf/LICENSE.LGPL rename to library/vendor/dompdf/LICENSE diff --git a/library/vendor/dompdf/SOURCE b/library/vendor/dompdf/SOURCE index 9343b58cf..c26253e30 100644 --- a/library/vendor/dompdf/SOURCE +++ b/library/vendor/dompdf/SOURCE @@ -1,6 +1,7 @@ curl https://codeload.github.com/dompdf/dompdf/tar.gz/v0.6.1 -o dompdf-0.6.1.tar.gz tar xzf dompdf-0.6.1.tar.gz --strip-components 1 dompdf-0.6.1/{include/*.php,lib,dompdf*.php,LICENSE.LGPL} rm dompdf-0.6.1.tar.gz +mv LICENSE.LGPL LICENSE curl https://codeload.github.com/PhenX/php-font-lib/tar.gz/0.3.1 -o php-font-lib-0.3.1.tar.gz mkdir lib/php-font-lib/classes From 2d0153464d20ebf3bbb43b1c486757ad33616201 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Mon, 29 Dec 2014 16:48:18 +0100 Subject: [PATCH 0092/2920] Add spec file for RHEL (CentOS and Fedora) packages refs #6401 fixes #6894 --- icingaweb2.spec | 398 ++++++++++++++++++++++++------------------------ 1 file changed, 198 insertions(+), 200 deletions(-) diff --git a/icingaweb2.spec b/icingaweb2.spec index fb628f995..0b4813bc4 100644 --- a/icingaweb2.spec +++ b/icingaweb2.spec @@ -1,237 +1,235 @@ -#/** -# * This file is part of Icinga Web 2. -# * -# * Icinga Web 2 - Head for multiple monitoring backends. -# * Copyright (C) 2014 Icinga Development Team -# * -# * This program is free software; you can redistribute it and/or -# * modify it under the terms of the GNU General Public License -# * as published by the Free Software Foundation; either version 2 -# * of the License, or (at your option) any later version. -# * -# * This program is distributed in the hope that it will be useful, -# * but WITHOUT ANY WARRANTY; without even the implied warranty of -# * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# * GNU General Public License for more details. -# * -# * You should have received a copy of the GNU General Public License -# * along with this program; if not, write to the Free Software -# * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -# * -# * @copyright 2014 Icinga Development Team -# * @license http://www.gnu.org/licenses/gpl-2.0.txt GPL, version 2 -# * @author Icinga Development Team -# * -# */ - -%define revision 1 - -%define configdir %{_sysconfdir}/%{name} -%define sharedir %{_datadir}/%{name} -%define prefixdir %{_datadir}/%{name} -%define usermodparam -a -G -%define logdir %{_localstatedir}/log/%{name} -%define docdir %{sharedir}/doc - -%if "%{_vendor}" == "suse" -%define phpname php5 -%define phpzendname php5-ZendFramework -%define apache2modphpname apache2-mod_php5 -%endif -# SLE 11 = 1110 -%if 0%{?suse_version} == 1110 -%define phpname php53 -%define apache2modphpname apache2-mod_php53 -%define usermodparam -A -%endif - -%if "%{_vendor}" == "redhat" -%define phpname php -%define phpzendname php-ZendFramework -%endif - -# el5 requires newer php53 rather than php (5.1) -%if 0%{?el5} || 0%{?rhel} == 5 || "%{?dist}" == ".el5" -%define phpname php53 -%endif - -%if "%{_vendor}" == "suse" -%define apacheconfdir %{_sysconfdir}/apache2/conf.d -%define apacheuser wwwrun -%define apachegroup www -%define extcmdfile %{_localstatedir}/run/icinga2/cmd/icinga.cmd -%define livestatussocket %{_localstatedir}/run/icinga2/cmd/livestatus -%endif -%if "%{_vendor}" == "redhat" -%define apacheconfdir %{_sysconfdir}/httpd/conf.d -%define apacheuser apache -%define apachegroup apache -%define extcmdfile %{_localstatedir}/run/icinga2/cmd/icinga.cmd -%define livestatussocket %{_localstatedir}/run/icinga2/cmd/livestatus -%endif - -Summary: Open Source host, service and network monitoring Web UI Name: icingaweb2 -Version: 0.0.1 -Release: %{revision}%{?dist} -License: GPLv2 +Version: 2.0.0 +Release: 1.beta2%{?dist} +Summary: Icinga Web 2 Group: Applications/System -URL: http://www.icinga.org +License: GPL +URL: https://icinga.org +Source0: https://github.com/Icinga/%{name}/archive/v%{version}.tar.gz BuildArch: noarch +BuildRoot: %{_tmppath}/%{name}-%{version}-%{release} +Packager: Icinga Team -%if "%{_vendor}" == "suse" -AutoReqProv: Off +%if 0%{?fedora} || 0%{?rhel} +%define wwwconfigdir %{_sysconfdir}/httpd/conf.d +%define wwwuser apache +%if 0%{?rhel} == 5 +%define php php53 +%define php_cli php53-cli +%else +%define php php +%define php_cli php-cli +%endif +%if 0%{rhel} == 6 +%define zend php-ZendFramework +%else +%define zend %{name}-vendor-Zend +%endif %endif -Source: icingaweb2-%{version}.tar.gz - -BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root - -BuildRequires: %{phpname} >= 5.3.0 -BuildRequires: %{phpname}-devel >= 5.3.0 -BuildRequires: %{phpname}-ldap -BuildRequires: %{phpname}-pdo -BuildRequires: %{phpzendname} -%if "%{_vendor}" != "suse" -BuildRequires: %{phpzendname}-Db-Adapter-Pdo -BuildRequires: %{phpzendname}-Db-Adapter-Pdo-Mysql -BuildRequires: %{phpzendname}-Db-Adapter-Pdo-Pgsql -%endif - -%if "%{_vendor}" == "redhat" -%endif -%if "%{_vendor}" == "suse" -Requires: %{phpname}-devel >= 5.3.0 -BuildRequires: %{phpname}-json -BuildRequires: %{phpname}-sockets -BuildRequires: %{phpname}-dom -%endif - -Requires: %{phpname} >= 5.3.0 -Requires: %{phpzendname} -Requires: %{phpname}-ldap -Requires: %{phpname}-pdo -%if "%{_vendor}" == "redhat" -Requires: %{phpname}-common -Requires: %{phpzendname}-Db-Adapter-Pdo -Requires: %{phpzendname}-Db-Adapter-Pdo-Mysql -Requires: php-pear -%endif -%if "%{_vendor}" == "suse" -Requires: %{phpname}-pear -Requires: %{phpname}-dom -Requires: %{phpname}-tokenizer -Requires: %{phpname}-gettext -Requires: %{phpname}-ctype -Requires: %{phpname}-json -Requires: %{apache2modphpname} -%endif - -Requires: php-Icinga +Requires(pre): shadow-utils +Requires: %{name}-common = %{version}-%{release} +Requires: php-Icinga = %{version}-%{release} +Requires: %{name}-vendor-dompdf +Requires: %{name}-vendor-HTMLPurifier +Requires: %{name}-vendor-JShrink +Requires: %{name}-vendor-lessphp +Requires: %{name}-vendor-Parsedown +Requires: %{zend} %description -Icinga Web 2 for Icinga 2 or Icinga 1.x using multiple backends -for example DB IDO. +Icinga Web 2 + + +%define basedir %{_datadir}/%{name} +%define bindir %{_bindir} +%define configdir %{_sysconfdir}/%{name} +%define logdir %{_localstatedir}/log/%{name} +%define phpdir %{_datadir}/php +%define icingawebgroup icingaweb2 + + +%package common +Summary: Common files for Icinga Web 2 and the Icinga CLI +Group: Applications/System + +%description common +Common files for Icinga Web 2 and the Icinga CLI + + +%package -n php-Icinga +Summary: Icinga Web 2 PHP library +Group: Development/Libraries +Requires: %{php} >= 5.3.0 + +%description -n php-Icinga +Icinga Web 2 PHP library + %package -n icingacli Summary: Icinga CLI Group: Applications/System -Requires: %{name} = %{version}-%{release} -Requires: php-Icinga +Requires: %{name}-common = %{version}-%{release} +Requires: php-Icinga = %{version}-%{release} +Requires: %{php_cli} >= 5.3.0 %description -n icingacli -Icinga CLI using php-Icinga Icinga Web 2 backend. - -%package -n php-Icinga -Summary: Icinga Web 2 PHP Libraries -Group: Applications/System -Requires: %{name} = %{version}-%{release} -Requires: %{phpname} >= 5.3.0 -Requires: %{phpzendname} +Icinga CLI -%description -n php-Icinga -Icinga Web 2 PHP Libraries required by the web frontend and cli tool. +%package vendor-dompdf +Version: 0.6.1 +Release: 1%{?dist} +Summary: Icinga Web 2 vendor library dompdf +Group: Development/Libraries +Requires: %{php} >= 5.3.0 + +%description vendor-dompdf +Icinga Web 2 vendor library dompdf + + +%package vendor-HTMLPurifier +Version: 4.6.0 +Release: 1%{?dist} +Summary: Icinga Web 2 vendor library HTMLPurifier +Group: Development/Libraries +Requires: %{php} >= 5.3.0 + +%description vendor-HTMLPurifier +Icinga Web 2 vendor library HTMLPurifier + + +%package vendor-JShrink +Version: 1.0.1 +Release: 1%{?dist} +Summary: Icinga Web 2 vendor library JShrink +Group: Development/Libraries +Requires: %{php} >= 5.3.0 + +%description vendor-JShrink +Icinga Web 2 vendor library JShrink + + +%package vendor-lessphp +Version: 0.4.0 +Release: 1%{?dist} +Summary: Icinga Web 2 vendor library lessphp +Group: Development/Libraries +Requires: %{php} >= 5.3.0 + +%description vendor-lessphp +Icinga Web 2 vendor library lessphp + + +%package vendor-Parsedown +Version: 1.0.0 +Release: 1%{?dist} +Summary: Icinga Web 2 vendor library Parsedown +Group: Development/Libraries +Requires: %{php} >= 5.3.0 + +%description vendor-Parsedown +Icinga Web 2 vendor library Parsedown + + +%package vendor-Zend +Version: 1.12.9 +Release: 1%{?dist} +Summary: Icinga Web 2 vendor library Zend Framework +Group: Development/Libraries +Requires: %{php} >= 5.3.0 + +%description vendor-Zend +Icinga Web 2 vendor library Zend %prep -#VERSION=0.0.1; git archive --format=tar --prefix=icingaweb2-$VERSION/ HEAD | gzip >icingaweb2-$VERSION.tar.gz -%setup -q -n %{name}-%{version} +%setup -q %build %install -[ "%{buildroot}" != "/" ] && [ -d "%{buildroot}" ] && rm -rf %{buildroot} - -# prepare configuration for sub packages - -# install rhel apache config -install -D -m0644 packages/files/apache/icingaweb.conf %{buildroot}/%{apacheconfdir}/icingaweb.conf - -# install public, library, modules -%{__mkdir} -p %{buildroot}/%{sharedir} -%{__mkdir} -p %{buildroot}/%{logdir} -%{__mkdir} -p %{buildroot}/%{docdir} -%{__mkdir} -p %{buildroot}/%{_sysconfdir}/%{name} -%{__mkdir} -p %{buildroot}/%{_sysconfdir}/dashboard -%{__mkdir} -p %{buildroot}/%{_sysconfdir}/%{name}/modules -%{__mkdir} -p %{buildroot}/%{_sysconfdir}/%{name}/modules/monitoring -%{__mkdir} -p %{buildroot}/%{_sysconfdir}/%{name}/enabledModules - -# make sure to install local icingacli for setup wizard token generation & webserver config -%{__cp} -r application doc library modules public bin %{buildroot}/%{sharedir}/ - -# enable the monitoring module by default -ln -s %{sharedir}/modules/monitoring %{buildroot}/%{_sysconfdir}/%{name}/enabledModules/monitoring -## config - -# symlink icingacli -mkdir -p %{buildroot}/usr/bin -ln -sf %{sharedir}/bin/icingacli %{buildroot}/usr/bin/icingacli +rm -rf %{buildroot} +mkdir -p %{buildroot}/{%{basedir}/{modules,library,public},%{bindir},%{configdir},%{logdir},%{phpdir},%{wwwconfigdir}} +cp -prv application doc var %{buildroot}/%{basedir} +cp -prv modules/{monitoring,setup} %{buildroot}/%{basedir}/modules +cp -prv library/Icinga %{buildroot}/%{phpdir} +cp -prv library/vendor %{buildroot}/%{basedir}/library +cp -prv public/{css,img,js,error_norewrite.html} %{buildroot}/%{basedir}/public +cp -pv packages/files/apache/icingaweb2.conf %{buildroot}/%{wwwconfigdir}/icingaweb2.conf +cp -pv packages/files/bin/icingacli %{buildroot}/%{bindir} +cp -pv packages/files/public/index.php %{buildroot}/%{basedir}/public %pre -# Add apacheuser in the icingacmd group -# If the group exists, add the apacheuser in the icingacmd group. -# It is not neccessary that icinga2-web is installed on the same system as -# icinga and only on systems with icinga installed the icingacmd -# group exists. In all other cases the user used for ssh access has -# to be added to the icingacmd group on the remote icinga server. -getent group icingacmd > /dev/null - -if [ $? -eq 0 ]; then -%{_sbindir}/usermod %{usermodparam} icingacmd %{apacheuser} -fi - -%preun - -%post +getent group icingacmd >/dev/null || groupadd -r icingacmd +usermod -a -G icingacmd,%{icingawebgroup} %{wwwuser} +exit 0 %clean -[ "%{buildroot}" != "/" ] && [ -d "%{buildroot}" ] && rm -rf %{buildroot} +rm -rf %{buildroot} %files -# main dirs %defattr(-,root,root) -%doc etc/schema doc packages/RPM.md -%attr(755,%{apacheuser},%{apachegroup}) %{sharedir}/public -%attr(755,%{apacheuser},%{apachegroup}) %{sharedir}/modules -# configs +%{basedir}/application/controllers +%{basedir}/application/fonts +%{basedir}/application/forms +%{basedir}/application/layouts +%{basedir}/application/views +%{basedir}/doc +%{basedir}/modules +%{basedir}/public +%{wwwconfigdir}/icingaweb2.conf +%attr(2775,root,%{icingawebgroup}) %dir %{logdir} + + +%pre common +getent group %{icingawebgroup} >/dev/null || groupadd -r %{icingawebgroup} +exit 0 + +%files common %defattr(-,root,root) -%config(noreplace) %attr(-,root,root) %{apacheconfdir}/icingaweb.conf -%config(noreplace) %attr(-,%{apacheuser},%{apachegroup}) %{configdir} -# logs -%attr(2775,%{apacheuser},%{apachegroup}) %dir %{logdir} -# shipped docs -%attr(755,%{apacheuser},%{apachegroup}) %{sharedir}/doc +%{basedir}/application/locale +%dir %{basedir}/modules +%attr(2770,root,%{icingawebgroup}) %config(noreplace) %{configdir} + %files -n php-Icinga -%attr(755,%{apacheuser},%{apachegroup}) %{sharedir}/application -%attr(755,%{apacheuser},%{apachegroup}) %{sharedir}/library +%defattr(-,root,root) +%{phpdir}/Icinga + %files -n icingacli -%attr(0755,root,root) /usr/bin/icingacli -%attr(0755,root,root) %{sharedir}/bin/icingacli -%attr(0755,root,root) %{sharedir}/bin/license_writer.py +%defattr(-,root,root) +%{basedir}/application/clicommands +%attr(0755,root,root) %{bindir}/icingacli -%changelog + +%files vendor-dompdf +%defattr(-,root,root) +%{basedir}/library/vendor/dompdf + + +%files vendor-HTMLPurifier +%defattr(-,root,root) +%{basedir}/library/vendor/HTMLPurifier + + +%files vendor-JShrink +%defattr(-,root,root) +%{basedir}/library/vendor/JShrink + + +%files vendor-lessphp +%defattr(-,root,root) +%{basedir}/library/vendor/lessphp + + +%files vendor-Parsedown +%defattr(-,root,root) +%{basedir}/library/vendor/Parsedown + + +%files vendor-Zend +%defattr(-,root,root) +%{basedir}/library/vendor/Zend From fd044017fb385e93145243fbe6f51bd98d7c0595 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Mon, 29 Dec 2014 17:31:00 +0100 Subject: [PATCH 0093/2920] Revert "Highlight hovered state rows even if there is no href" This reverts commit 73f9328f12a4f3c41c138e77ad2e92a588f1ca59. Highlighting table rows which do not contain a link does not make sense. refs #8024 --- public/css/icinga/monitoring-colors.less | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/public/css/icinga/monitoring-colors.less b/public/css/icinga/monitoring-colors.less index 86268d2ce..1e657101f 100644 --- a/public/css/icinga/monitoring-colors.less +++ b/public/css/icinga/monitoring-colors.less @@ -195,7 +195,7 @@ tr.state.handled td.state { } /* HOVER colors */ -tr.state:hover, tr[href]:hover { +tr[href]:hover { color: black; background-color: #eee; } From e376bd628578f816644eac5f2ae417f1f4cc76ef Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Mon, 29 Dec 2014 17:54:09 +0100 Subject: [PATCH 0094/2920] monitoring: Fix that exporting a object's history throws an exception fixes #6586 --- modules/monitoring/application/controllers/ShowController.php | 3 +-- .../monitoring/library/Monitoring/Object/MonitoredObject.php | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/modules/monitoring/application/controllers/ShowController.php b/modules/monitoring/application/controllers/ShowController.php index efec6665a..ba865deaa 100644 --- a/modules/monitoring/application/controllers/ShowController.php +++ b/modules/monitoring/application/controllers/ShowController.php @@ -73,9 +73,8 @@ class Monitoring_ShowController extends Controller public function historyAction() { $this->getTabs()->activate('history'); - //$this->view->object->populate(); $this->view->object->fetchEventHistory(); - $this->view->history = $this->view->object->eventhistory->paginate($this->params->get('limit', 50)); + $this->view->history = $this->view->object->eventhistory->getQuery()->paginate($this->params->get('limit', 50)); $this->handleFormatRequest($this->view->object->eventhistory); $this->fetchHostStats(); } diff --git a/modules/monitoring/library/Monitoring/Object/MonitoredObject.php b/modules/monitoring/library/Monitoring/Object/MonitoredObject.php index 4be004d99..2d9f1f30c 100644 --- a/modules/monitoring/library/Monitoring/Object/MonitoredObject.php +++ b/modules/monitoring/library/Monitoring/Object/MonitoredObject.php @@ -421,7 +421,7 @@ abstract class MonitoredObject if ($this->type === self::TYPE_SERVICE) { $eventHistory->where('service_description', $this->service_description); } - $this->eventhistory = $eventHistory->getQuery(); + $this->eventhistory = $eventHistory; return $this; } From 3bd24c48ff453f2e47b0be154e9f7214b0ccc079 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Mon, 29 Dec 2014 17:54:39 +0100 Subject: [PATCH 0095/2920] monitoring: Do not provide export when viewing a monitored object This is simply not possible at the moment. --- .../Monitoring/Web/Controller/MonitoredObjectController.php | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/modules/monitoring/library/Monitoring/Web/Controller/MonitoredObjectController.php b/modules/monitoring/library/Monitoring/Web/Controller/MonitoredObjectController.php index 7ee73d575..94dbe3f10 100644 --- a/modules/monitoring/library/Monitoring/Web/Controller/MonitoredObjectController.php +++ b/modules/monitoring/library/Monitoring/Web/Controller/MonitoredObjectController.php @@ -223,8 +223,6 @@ abstract class MonitoredObjectController extends Controller ) ); } - $tabs - ->extend(new OutputFormat()) - ->extend(new DashboardAction()); + $tabs->extend(new DashboardAction()); } } From fc05f4d53e50e7f02e0fcfc9ff0c2bd7f650dc74 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Mon, 29 Dec 2014 17:55:34 +0100 Subject: [PATCH 0096/2920] setup: Fix the mode of created directories --- modules/setup/library/Setup/WebWizard.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/setup/library/Setup/WebWizard.php b/modules/setup/library/Setup/WebWizard.php index e4d61dfd7..102c2c6a0 100644 --- a/modules/setup/library/Setup/WebWizard.php +++ b/modules/setup/library/Setup/WebWizard.php @@ -352,7 +352,7 @@ class WebWizard extends Wizard implements SetupWizard $configDir . '/preferences', $configDir . '/enabledModules' ), - 0775 + 2770 ) ); From 58cfb679830cdbcf32ecda8e7e30df5ff65b5988 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Tue, 30 Dec 2014 09:27:18 +0100 Subject: [PATCH 0097/2920] Load setup module when necessary when bootstrapping the CLI fixes #8146 --- library/Icinga/Application/Cli.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/library/Icinga/Application/Cli.php b/library/Icinga/Application/Cli.php index 7d1a98eec..6341d561e 100644 --- a/library/Icinga/Application/Cli.php +++ b/library/Icinga/Application/Cli.php @@ -43,7 +43,8 @@ class Cli extends ApplicationBootstrap ->parseBasicParams() ->setupLogger() ->setupResourceFactory() - ->setupModuleManager(); + ->setupModuleManager() + ->loadSetupModuleIfNecessary(); } protected function setupLogging() From c1aff80f7b31b319e93665fcaf7bf4ba6d0683af Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Tue, 30 Dec 2014 09:39:11 +0100 Subject: [PATCH 0098/2920] monitoring: Fix "Show resource configuration" link --- .../monitoring/application/forms/Config/BackendConfigForm.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/monitoring/application/forms/Config/BackendConfigForm.php b/modules/monitoring/application/forms/Config/BackendConfigForm.php index 4b1aa65b6..c60848858 100644 --- a/modules/monitoring/application/forms/Config/BackendConfigForm.php +++ b/modules/monitoring/application/forms/Config/BackendConfigForm.php @@ -253,7 +253,7 @@ class BackendConfigForm extends ConfigForm array( 'value' => sprintf( '%s', - $this->getView()->href('/icingaweb/config/editresource', array('resource' => $resourceName)), + $this->getView()->url('config/editresource', array('resource' => $resourceName)), mt('monitoring', 'Show resource configuration') ), 'escape' => false From d595541d42425e3f793381fc27998bb05155b907 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Tue, 30 Dec 2014 09:40:09 +0100 Subject: [PATCH 0099/2920] monitoring: optimize imports in the backend configuration form --- .../monitoring/application/forms/Config/BackendConfigForm.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/monitoring/application/forms/Config/BackendConfigForm.php b/modules/monitoring/application/forms/Config/BackendConfigForm.php index c60848858..3953830fd 100644 --- a/modules/monitoring/application/forms/Config/BackendConfigForm.php +++ b/modules/monitoring/application/forms/Config/BackendConfigForm.php @@ -5,10 +5,10 @@ namespace Icinga\Module\Monitoring\Forms\Config; use InvalidArgumentException; -use Icinga\Web\Notification; -use Icinga\Forms\ConfigForm; use Icinga\Application\Config; use Icinga\Exception\ConfigurationError; +use Icinga\Forms\ConfigForm; +use Icinga\Web\Notification; /** * Form class for creating/modifying monitoring backends From 2a1f12354e19f723d7b309d7f298679b1bbe52d4 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Tue, 30 Dec 2014 09:41:22 +0100 Subject: [PATCH 0100/2920] monitoring: Use '@return $this' when documenting fluent interfaces in the backend configuration form --- .../monitoring/application/forms/Config/BackendConfigForm.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/monitoring/application/forms/Config/BackendConfigForm.php b/modules/monitoring/application/forms/Config/BackendConfigForm.php index 3953830fd..c25c73544 100644 --- a/modules/monitoring/application/forms/Config/BackendConfigForm.php +++ b/modules/monitoring/application/forms/Config/BackendConfigForm.php @@ -36,7 +36,7 @@ class BackendConfigForm extends ConfigForm * * @param Config $resources The resource configuration * - * @return self + * @return $this * * @throws ConfigurationError In case there are no valid monitoring backend resources */ @@ -64,7 +64,7 @@ class BackendConfigForm extends ConfigForm * * @param array $values The values to extend the configuration with * - * @return self + * @return $this * * @throws InvalidArgumentException In case the backend does already exist */ From 6a67b7fee39928dc81d87db1ff756b58ba7c2a68 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Tue, 30 Dec 2014 09:43:35 +0100 Subject: [PATCH 0101/2920] monitoring: add description to @see tags in the backend configuration form --- .../application/forms/Config/BackendConfigForm.php | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/modules/monitoring/application/forms/Config/BackendConfigForm.php b/modules/monitoring/application/forms/Config/BackendConfigForm.php index c25c73544..54bd8371c 100644 --- a/modules/monitoring/application/forms/Config/BackendConfigForm.php +++ b/modules/monitoring/application/forms/Config/BackendConfigForm.php @@ -160,9 +160,7 @@ class BackendConfigForm extends ConfigForm /** * Populate the form in case a monitoring backend is being edited * - * @see Form::onRequest() - * - * @throws ConfigurationError In case the backend name is missing in the request or is invalid + * @throws ConfigurationError In case the backend name is missing in the request or is invalid */ public function onRequest() { @@ -181,7 +179,8 @@ class BackendConfigForm extends ConfigForm } /** - * @see Form::createElements() + * (non-PHPDoc) + * @see Form::createElements() For the method documentation. */ public function createElements(array $formData) { From 27110ce5943e357d11bcdb9de73c8e9e861bdbfb Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Tue, 30 Dec 2014 09:44:33 +0100 Subject: [PATCH 0102/2920] monitoring: use @type instead of @var in the backend configuration form --- .../monitoring/application/forms/Config/BackendConfigForm.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/monitoring/application/forms/Config/BackendConfigForm.php b/modules/monitoring/application/forms/Config/BackendConfigForm.php index 54bd8371c..80afbc653 100644 --- a/modules/monitoring/application/forms/Config/BackendConfigForm.php +++ b/modules/monitoring/application/forms/Config/BackendConfigForm.php @@ -18,7 +18,7 @@ class BackendConfigForm extends ConfigForm /** * The available monitoring backend resources split by type * - * @var array + * @type array */ protected $resources; From 24b2369adba047d49568f15c678946404e878e45 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Tue, 30 Dec 2014 09:45:24 +0100 Subject: [PATCH 0103/2920] monitoring: Fix PHPDoc of BackendConfigForm::setResourceConfig() --- .../monitoring/application/forms/Config/BackendConfigForm.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/monitoring/application/forms/Config/BackendConfigForm.php b/modules/monitoring/application/forms/Config/BackendConfigForm.php index 80afbc653..67672dd20 100644 --- a/modules/monitoring/application/forms/Config/BackendConfigForm.php +++ b/modules/monitoring/application/forms/Config/BackendConfigForm.php @@ -34,7 +34,7 @@ class BackendConfigForm extends ConfigForm /** * Set the resource configuration to use * - * @param Config $resources The resource configuration + * @param Config $resourceConfig The resource configuration * * @return $this * From e72361c2cba622da5f441a04b20528dbbe6c52ca Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Tue, 30 Dec 2014 09:47:19 +0100 Subject: [PATCH 0104/2920] monitoring: Fix missing return argument in the backend configuration form --- .../monitoring/application/forms/Config/BackendConfigForm.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/monitoring/application/forms/Config/BackendConfigForm.php b/modules/monitoring/application/forms/Config/BackendConfigForm.php index 67672dd20..51d5b5542 100644 --- a/modules/monitoring/application/forms/Config/BackendConfigForm.php +++ b/modules/monitoring/application/forms/Config/BackendConfigForm.php @@ -147,7 +147,7 @@ class BackendConfigForm extends ConfigForm } } catch (InvalidArgumentException $e) { Notification::error($e->getMessage()); - return; + return null; } if ($this->save()) { From e05e04bb744a803c0f6802bf1e70699920fce564 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Tue, 30 Dec 2014 09:47:45 +0100 Subject: [PATCH 0105/2920] monitoring: Uppercasse the first word of comments in the backend configuration form --- .../monitoring/application/forms/Config/BackendConfigForm.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/monitoring/application/forms/Config/BackendConfigForm.php b/modules/monitoring/application/forms/Config/BackendConfigForm.php index 51d5b5542..3ad18c830 100644 --- a/modules/monitoring/application/forms/Config/BackendConfigForm.php +++ b/modules/monitoring/application/forms/Config/BackendConfigForm.php @@ -138,10 +138,10 @@ class BackendConfigForm extends ConfigForm { $monitoringBackend = $this->request->getQuery('backend'); try { - if ($monitoringBackend === null) { // create new backend + if ($monitoringBackend === null) { // Create new backend $this->add($this->getValues()); $message = mt('monitoring', 'Monitoring backend "%s" has been successfully created'); - } else { // edit existing backend + } else { // Edit existing backend $this->edit($monitoringBackend, $this->getValues()); $message = mt('monitoring', 'Monitoring backend "%s" has been successfully changed'); } From d6e331018bb36e7562b870c4fd27f950dfd53d97 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Tue, 30 Dec 2014 10:02:31 +0100 Subject: [PATCH 0106/2920] monitoring: Use Form::translate() in the backend configuration form refs #7551 --- .../forms/Config/BackendConfigForm.php | 44 +++++++++---------- 1 file changed, 21 insertions(+), 23 deletions(-) diff --git a/modules/monitoring/application/forms/Config/BackendConfigForm.php b/modules/monitoring/application/forms/Config/BackendConfigForm.php index 3ad18c830..ca45c068b 100644 --- a/modules/monitoring/application/forms/Config/BackendConfigForm.php +++ b/modules/monitoring/application/forms/Config/BackendConfigForm.php @@ -28,7 +28,7 @@ class BackendConfigForm extends ConfigForm public function init() { $this->setName('form_config_monitoring_backends'); - $this->setSubmitLabel(mt('monitoring', 'Save Changes')); + $this->setSubmitLabel($this->translate('Save Changes')); } /** @@ -50,7 +50,7 @@ class BackendConfigForm extends ConfigForm } if (empty($resources)) { - throw new ConfigurationError(mt('monitoring', 'Could not find any valid monitoring backend resources')); + throw new ConfigurationError($this->translate('Could not find any valid monitoring backend resources')); } $this->resources = $resources; @@ -72,9 +72,9 @@ class BackendConfigForm extends ConfigForm { $name = isset($values['name']) ? $values['name'] : ''; if (! $name) { - throw new InvalidArgumentException(mt('monitoring', 'Monitoring backend name missing')); + throw new InvalidArgumentException($this->translate('Monitoring backend name missing')); } elseif ($this->config->hasSection($name)) { - throw new InvalidArgumentException(mt('monitoring', 'Monitoring backend already exists')); + throw new InvalidArgumentException($this->translate('Monitoring backend already exists')); } unset($values['name']); @@ -95,11 +95,11 @@ class BackendConfigForm extends ConfigForm public function edit($name, array $values) { if (! $name) { - throw new InvalidArgumentException(mt('monitoring', 'Old monitoring backend name missing')); + throw new InvalidArgumentException($this->translate('Old monitoring backend name missing')); } elseif (! ($newName = isset($values['name']) ? $values['name'] : '')) { - throw new InvalidArgumentException(mt('monitoring', 'New monitoring backend name missing')); + throw new InvalidArgumentException($this->translate('New monitoring backend name missing')); } elseif (! $this->config->hasSection($name)) { - throw new InvalidArgumentException(mt('monitoring', 'Unknown monitoring backend provided')); + throw new InvalidArgumentException($this->translate('Unknown monitoring backend provided')); } unset($values['name']); @@ -119,9 +119,9 @@ class BackendConfigForm extends ConfigForm public function remove($name) { if (! $name) { - throw new InvalidArgumentException(mt('monitoring', 'Monitoring backend name missing')); + throw new InvalidArgumentException($this->translate('Monitoring backend name missing')); } elseif (! $this->config->hasSection($name)) { - throw new InvalidArgumentException(mt('monitoring', 'Unknown monitoring backend provided')); + throw new InvalidArgumentException($this->translate('Unknown monitoring backend provided')); } $backendConfig = $this->config->getSection($name); @@ -131,8 +131,6 @@ class BackendConfigForm extends ConfigForm /** * Add or edit a monitoring backend and save the configuration - * - * @see Form::onSuccess() */ public function onSuccess() { @@ -140,10 +138,10 @@ class BackendConfigForm extends ConfigForm try { if ($monitoringBackend === null) { // Create new backend $this->add($this->getValues()); - $message = mt('monitoring', 'Monitoring backend "%s" has been successfully created'); + $message = $this->translate('Monitoring backend "%s" has been successfully created'); } else { // Edit existing backend $this->edit($monitoringBackend, $this->getValues()); - $message = mt('monitoring', 'Monitoring backend "%s" has been successfully changed'); + $message = $this->translate('Monitoring backend "%s" has been successfully changed'); } } catch (InvalidArgumentException $e) { Notification::error($e->getMessage()); @@ -167,9 +165,9 @@ class BackendConfigForm extends ConfigForm $monitoringBackend = $this->request->getQuery('backend'); if ($monitoringBackend !== null) { if ($monitoringBackend === '') { - throw new ConfigurationError(mt('monitoring', 'Monitoring backend name missing')); + throw new ConfigurationError($this->translate('Monitoring backend name missing')); } elseif (! $this->config->hasSection($monitoringBackend)) { - throw new ConfigurationError(mt('monitoring', 'Unknown monitoring backend provided')); + throw new ConfigurationError($this->translate('Unknown monitoring backend provided')); } $backendConfig = $this->config->getSection($monitoringBackend)->toArray(); @@ -199,7 +197,7 @@ class BackendConfigForm extends ConfigForm 'disabled', array( 'required' => true, - 'label' => mt('monitoring', 'Disable This Backend') + 'label' => $this->translate('Disable This Backend') ) ); $this->addElement( @@ -207,8 +205,8 @@ class BackendConfigForm extends ConfigForm 'name', array( 'required' => true, - 'label' => mt('monitoring', 'Backend Name'), - 'description' => mt('monitoring', 'The identifier of this backend') + 'label' => $this->translate('Backend Name'), + 'description' => $this->translate('The identifier of this backend') ) ); $this->addElement( @@ -217,8 +215,8 @@ class BackendConfigForm extends ConfigForm array( 'required' => true, 'autosubmit' => true, - 'label' => mt('monitoring', 'Backend Type'), - 'description' => mt('monitoring', 'The data source used for retrieving monitoring information'), + 'label' => $this->translate('Backend Type'), + 'description' => $this->translate('The data source used for retrieving monitoring information'), 'multiOptions' => $resourceTypes, 'value' => $resourceType ) @@ -229,8 +227,8 @@ class BackendConfigForm extends ConfigForm 'resource', array( 'required' => true, - 'label' => mt('monitoring', 'Resource'), - 'description' => mt('monitoring', 'The resource to use'), + 'label' => $this->translate('Resource'), + 'description' => $this->translate('The resource to use'), 'multiOptions' => $this->resources[$resourceType], 'autosubmit' => true ) @@ -253,7 +251,7 @@ class BackendConfigForm extends ConfigForm 'value' => sprintf( '%s', $this->getView()->url('config/editresource', array('resource' => $resourceName)), - mt('monitoring', 'Show resource configuration') + $this->translate('Show resource configuration') ), 'escape' => false ) From 50bbf77d0c499afa015b4a6317be3ce69bf01400 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Tue, 30 Dec 2014 10:08:33 +0100 Subject: [PATCH 0107/2920] Fix module domain detection in Form::getTranslationDomain() The usage of preg_replace had two errors: 1) The regular expression was wrong 2) $matches[0] always contains the full matched string, not the first parenthesized subpattern The correct version of preg_replace would've been: if (preg_match('/^Icinga\\\\Module\\\\([A-Za-z]+)\\\\/', get_called_class(), $matches) === 1) { return strtolower($matches[1]); } But since there's no benefit of using a regular expression here except less speed, I replaced it with using explode. refs #7551 --- library/Icinga/Web/Form.php | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/library/Icinga/Web/Form.php b/library/Icinga/Web/Form.php index 850285baa..64712961f 100644 --- a/library/Icinga/Web/Form.php +++ b/library/Icinga/Web/Form.php @@ -806,19 +806,20 @@ class Form extends Zend_Form } /** - * Return the translation domain for this form + * Get the translation domain for this form * - * The returned translation domain is either determined based on - * this form's class path or it is the default `icinga' domain + * The returned translation domain is either determined based on this form's qualified name or it is the default + * 'icinga' domain * - * @return string + * @return string */ protected function getTranslationDomain() { - if (preg_match('@^Icinga\\\\Module\\\\([A-z]+)\\\\.*$@', get_called_class(), $matches) === 1) { - return strtolower($matches[0]); + $parts = explode('\\', get_called_class()); + if ($parts[1] === 'Module') { + // Assume format Icinga\Module\ModuleName\Forms\... + return strtolower($parts[2]); } - return 'icinga'; } From c87733debc65ceba04c499cc31ad5fbd680a6091 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Tue, 30 Dec 2014 10:26:19 +0100 Subject: [PATCH 0108/2920] monitoring: Count hosts once in hosts/show.phtml --- .../application/views/scripts/hosts/show.phtml | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/modules/monitoring/application/views/scripts/hosts/show.phtml b/modules/monitoring/application/views/scripts/hosts/show.phtml index 8ae19aa0b..a4629e652 100644 --- a/modules/monitoring/application/views/scripts/hosts/show.phtml +++ b/modules/monitoring/application/views/scripts/hosts/show.phtml @@ -2,11 +2,12 @@ tabs ?>
    - + + translate('No hosts matching the filter') ?>
    - translatePlural('Host (%u)', 'Hosts (%u)', array_sum(array_values($hostStates))), array_sum(array_values($hostStates))) ?> + translatePlural('Host (%u)', 'Hosts (%u)', $hostCount), $hostCount) ?>
    hostStatesPieChart ?> @@ -22,9 +23,9 @@ $this->translatePlural( '%u Host', '%u Hosts', - count($objects) - ), - count($objects) + $hostCount + ), + $hostCount ) ?> From 507aefa9dd64cf3e934f4ebd1b9cea74a238e68d Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Tue, 30 Dec 2014 10:30:31 +0100 Subject: [PATCH 0109/2920] monitoring: Count unhandled hosts once in hosts/show.phtml --- .../monitoring/application/views/scripts/hosts/show.phtml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/modules/monitoring/application/views/scripts/hosts/show.phtml b/modules/monitoring/application/views/scripts/hosts/show.phtml index a4629e652..f1db2d9b0 100644 --- a/modules/monitoring/application/views/scripts/hosts/show.phtml +++ b/modules/monitoring/application/views/scripts/hosts/show.phtml @@ -62,13 +62,14 @@

    + translatePlural( '%u Unhandled Host Problem', '%u Unhandled Host Problems', - count($unhandledObjects) + $unhandledCount ), - count($unhandledObjects) + $unhandledCount ) ?>

    From 3745d3ebefce5b370d98c896d02521c8a22b0098 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Tue, 30 Dec 2014 10:31:23 +0100 Subject: [PATCH 0110/2920] monitoring: Count acknowledged hosts once in hosts/show.phtml --- .../monitoring/application/views/scripts/hosts/show.phtml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/modules/monitoring/application/views/scripts/hosts/show.phtml b/modules/monitoring/application/views/scripts/hosts/show.phtml index f1db2d9b0..e6fc7f8be 100644 --- a/modules/monitoring/application/views/scripts/hosts/show.phtml +++ b/modules/monitoring/application/views/scripts/hosts/show.phtml @@ -90,13 +90,14 @@

    + translatePlural( '%u Acknowledged Host Problem', '%u Acknowledged Host Problems', - count($acknowledgedObjects) + $acknowledgedCount ), - count($acknowledgedObjects) + $acknowledgedCount ) ?>

    From b82f4e53565b0ceb0ba8930cbbc1555f1093f4d5 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Tue, 30 Dec 2014 10:33:32 +0100 Subject: [PATCH 0111/2920] monitoring: Count hosts in downtime once in hosts/show.phtml --- .../application/views/scripts/hosts/show.phtml | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/modules/monitoring/application/views/scripts/hosts/show.phtml b/modules/monitoring/application/views/scripts/hosts/show.phtml index e6fc7f8be..dc0165497 100644 --- a/modules/monitoring/application/views/scripts/hosts/show.phtml +++ b/modules/monitoring/application/views/scripts/hosts/show.phtml @@ -107,10 +107,18 @@

    + icon('plug') ?> - translatePlural('%u host is in downtime', '%u hosts are in downtime', count($objectsInDowntime)),count($objectsInDowntime)) ?> + translatePlural( + '%u host is in downtime', + '%u hosts are in downtime', + $inDowntimeCount + ), + $inDowntimeCount + ) ?>

    From 56102a1e39092c9229f9730a48974ddce740a14e Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Tue, 30 Dec 2014 10:35:18 +0100 Subject: [PATCH 0112/2920] monitoring: Count hosts having comments once in hosts/show.phtml --- .../application/views/scripts/hosts/show.phtml | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/modules/monitoring/application/views/scripts/hosts/show.phtml b/modules/monitoring/application/views/scripts/hosts/show.phtml index dc0165497..739069416 100644 --- a/modules/monitoring/application/views/scripts/hosts/show.phtml +++ b/modules/monitoring/application/views/scripts/hosts/show.phtml @@ -123,12 +123,20 @@ - getComments())): ?> + getComments()) ?> +

    icon('comment') ?> - translatePlural('%u comment', '%u comments', count($objects->getComments())), count($objects->getComments())) ?> + translatePlural( + '%u comment', + '%u comments', + $havingCommentsCount + ), + $havingCommentsCount + ) ?>

    From 8594ff6843b4767609cb5f48ca2ee370597ee227 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Tue, 30 Dec 2014 10:38:02 +0100 Subject: [PATCH 0113/2920] monitoring: Remove multi/* view scripts They are no longer used. --- .../scripts/multi/components/comments.phtml | 25 ------- .../scripts/multi/components/downtimes.phtml | 19 ------ .../scripts/multi/components/flags.phtml | 25 ------- .../scripts/multi/components/objectlist.phtml | 65 ------------------- .../scripts/multi/components/summary.phtml | 59 ----------------- .../views/scripts/multi/host.phtml | 62 ------------------ .../views/scripts/multi/service.phtml | 61 ----------------- 7 files changed, 316 deletions(-) delete mode 100644 modules/monitoring/application/views/scripts/multi/components/comments.phtml delete mode 100644 modules/monitoring/application/views/scripts/multi/components/downtimes.phtml delete mode 100644 modules/monitoring/application/views/scripts/multi/components/flags.phtml delete mode 100644 modules/monitoring/application/views/scripts/multi/components/objectlist.phtml delete mode 100644 modules/monitoring/application/views/scripts/multi/components/summary.phtml delete mode 100644 modules/monitoring/application/views/scripts/multi/host.phtml delete mode 100644 modules/monitoring/application/views/scripts/multi/service.phtml diff --git a/modules/monitoring/application/views/scripts/multi/components/comments.phtml b/modules/monitoring/application/views/scripts/multi/components/comments.phtml deleted file mode 100644 index f477cd953..000000000 --- a/modules/monitoring/application/views/scripts/multi/components/comments.phtml +++ /dev/null @@ -1,25 +0,0 @@ -is_service ? 'Services' : 'Hosts'; - -?> - translatePlural('%u Comment', '%u Comments', count($comments)), count($comments)) ?> - - icon('cancel') - ?> translate('Remove Comments') ?>
    - icon('bell-off-empty') - ?> translate('Delay Notifications') ?>
    - - icon('ok') ?> Acknowledge - - - translatePlural('%u comment', '%u comments', count($comments)), count($comments)) ?>. - - diff --git a/modules/monitoring/application/views/scripts/multi/components/downtimes.phtml b/modules/monitoring/application/views/scripts/multi/components/downtimes.phtml deleted file mode 100644 index af8d841b4..000000000 --- a/modules/monitoring/application/views/scripts/multi/components/downtimes.phtml +++ /dev/null @@ -1,19 +0,0 @@ -is_service ? 'Services' : 'Hosts'; - -?> - - Downtimes - - icon('cancel') ?>Remove Downtimes
    - icon('plug') - ?> Schedule Downtimes - - - Change downtimes. - - diff --git a/modules/monitoring/application/views/scripts/multi/components/flags.phtml b/modules/monitoring/application/views/scripts/multi/components/flags.phtml deleted file mode 100644 index 1269e2f49..000000000 --- a/modules/monitoring/application/views/scripts/multi/components/flags.phtml +++ /dev/null @@ -1,25 +0,0 @@ -
    - - form->getElements() as $name => $element): - if ($element instanceof \Icinga\Web\Form\Element\TriStateCheckbox): - $element->setDecorators(array('ViewHelper')); - ?> - - - - - - - - - - - -
    render() ?>
    render() ?>
    -
    \ No newline at end of file diff --git a/modules/monitoring/application/views/scripts/multi/components/objectlist.phtml b/modules/monitoring/application/views/scripts/multi/components/objectlist.phtml deleted file mode 100644 index 879a13a1d..000000000 --- a/modules/monitoring/application/views/scripts/multi/components/objectlist.phtml +++ /dev/null @@ -1,65 +0,0 @@ -is_service) { - $links[] = $this->qlink( - $object->host_name . ' ' . $object->service_description, - 'monitoring/show/service', - array( - 'host' => $object->host_name, - 'service' => $object->service_description - ) - ); - } else { - $links[] = $this->qlink( - $object->host_name, - 'monitoring/show/host', - array( - 'host' => $object->host_name - ) - ); - } -} - -if ($this->is_service) { - $objectName = $this->translate('Services'); - $link = 'monitoring/list/services'; - $target = array( - 'host' => $this->hostquery, - 'service' => $this->servicequery - ); -} else { - $objectName = $this->translate('Hosts'); - $link = 'monitoring/list/hosts'; - $target = array( - 'host' => $this->hostquery - ); -} - -$more = clone $this->url; - - -?> -qlink( - $this->translate('List all'), - $more->setPath($link), - null, - array('title' => $this->translate('List all selected objects')) -) ?> - - 5) { - echo ' ' . sprintf($this->translate('and %d more'), count($objects) - 5); -} - -?> - - diff --git a/modules/monitoring/application/views/scripts/multi/components/summary.phtml b/modules/monitoring/application/views/scripts/multi/components/summary.phtml deleted file mode 100644 index d832624c7..000000000 --- a/modules/monitoring/application/views/scripts/multi/components/summary.phtml +++ /dev/null @@ -1,59 +0,0 @@ -getHelper('CommandForm'); -$servicequery = isset($this->servicequery) ? $this->servicequery : ''; -$objectName = $this->is_service ? $this->translate('Services') : $this->translate('Hosts'); - -$params = array( - 'host' => $this->target['host'], - 'service' => null, - 'checktime' => time(), - 'forcecheck' => '1' -); -if (array_key_exists('service', $this->target)) { - $params['service'] = $this->target['service']; -} else { - unset($params['service']); -} -?> - - - - icon('rescheduel') - ?> Recheck
    - icon('reschedule') - ?> Reschedule
    - - Perform actions on . - - - - problems ?> Problems - - icon('plug') - ?> Schedule Downtimes - - problems, - count($this->objects), - $objectName - ) ?> - - - unhandled) ?> Unhandled - - icon('ok') - ?> Acknowledge
    - icon('remove_petrol.png') ?> Remove Acknowledgements - - diff --git a/modules/monitoring/application/views/scripts/multi/host.phtml b/modules/monitoring/application/views/scripts/multi/host.phtml deleted file mode 100644 index 6179f6339..000000000 --- a/modules/monitoring/application/views/scripts/multi/host.phtml +++ /dev/null @@ -1,62 +0,0 @@ -is_service = false; -$this->hostquery = implode($this->hostnames, ','); -$this->target = array('host' => $this->hostquery); -?> - -
    - tabs; ?> -
    - -
    - - - -

    Summary for hosts

    - render('multi/components/objectlist.phtml'); ?> - - - - - - - - - - -
    -

    Hosts

    -
    - pie->render(); ?> - - $count) { - if ($count > 0) { - echo ucfirst($state) . ': ' . $count . '
    '; - } - } - ?> -
    - -

    icon('host')?> Host Actions

    - - - - render('multi/components/summary.phtml'); ?> - render('multi/components/comments.phtml'); ?> - render('multi/components/downtimes.phtml'); ?> - -
    - - render('multi/components/flags.phtml') ?> - -
    - - - - diff --git a/modules/monitoring/application/views/scripts/multi/service.phtml b/modules/monitoring/application/views/scripts/multi/service.phtml deleted file mode 100644 index dc2e9f19e..000000000 --- a/modules/monitoring/application/views/scripts/multi/service.phtml +++ /dev/null @@ -1,61 +0,0 @@ -is_service = true; -$this->hostquery = implode($this->hostnames, ','); -$this->servicequery = implode($this->servicenames, ','); -$this->target = array( - 'host' => $this->hostquery, - 'service' => $this->servicequery -); -?> - -
    -tabs ?> -
    - -
    - - - -

    Summary for services

    - - - - - - - - - - - - -
    Services Hosts
    service_pie->render() ?> $count) { - if ($count > 0) { - echo ucfirst($state) . ': ' . $count . '
    '; - } - } - - ?>
    host_pie->render() ?> $count) { - if ($count > 0) { - echo ucfirst($state) . ': ' . $count . '
    '; - } - } - ?>
    - -

    icon('conf')?> Service Actions

    - - - - render('multi/components/objectlist.phtml') ?> - render('multi/components/summary.phtml') ?> - render('multi/components/comments.phtml') ?> - render('multi/components/downtimes.phtml') ?> - -
    - - render('multi/components/flags.phtml') ?> - -
    From b7d6ee75f245250c9dd971b474e8a944c9c3ee84 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Tue, 30 Dec 2014 10:38:43 +0100 Subject: [PATCH 0114/2920] monitoring: Remove the MultiController The controller is no longer used. --- .../controllers/MultiController.php | 282 ------------------ 1 file changed, 282 deletions(-) delete mode 100644 modules/monitoring/application/controllers/MultiController.php diff --git a/modules/monitoring/application/controllers/MultiController.php b/modules/monitoring/application/controllers/MultiController.php deleted file mode 100644 index 6deff2fc3..000000000 --- a/modules/monitoring/application/controllers/MultiController.php +++ /dev/null @@ -1,282 +0,0 @@ -backend->select()->from( - 'hostStatus', - array( - 'host_name', - 'host_in_downtime', - 'host_passive_checks_enabled', - 'host_obsessing', - 'host_state', - 'host_notifications_enabled', - 'host_event_handler_enabled', - 'host_flap_detection_enabled', - 'host_active_checks_enabled', - // columns intended for filter-request - 'host_problem', - 'host_handled' - ) - )->getQuery(); - $this->applyQueryFilter($query); - $hosts = $query->fetchAll(); - - $comments = $this->backend->select()->from('comment', array( - 'comment_internal_id', - 'comment_host', - )); - $this->applyQueryFilter($comments); - $uniqueComments = array_keys($this->getUniqueValues($comments->getQuery()->fetchAll(), 'comment_internal_id')); - - // Populate view - $this->view->objects = $this->view->hosts = $hosts; - $this->view->problems = $this->getProblems($hosts); - $this->view->comments = $uniqueComments; - $this->view->hostnames = $this->getProperties($hosts, 'host_name'); - $this->view->downtimes = $this->getDowntimes($hosts); - $this->view->errors = $errors; - $this->view->states = $this->countStates($hosts, 'host', 'host_name'); - $this->view->pie = $this->createPie( - $this->view->states, - $this->view->getHelper('MonitoringState')->getHostStateColors(), - mt('monitoring', 'Host State') - ); - - // Handle configuration changes - $this->handleConfigurationForm(array( - 'host_passive_checks_enabled' => $this->translate('Passive Checks'), - 'host_active_checks_enabled' => $this->translate('Active Checks'), - 'host_notifications_enabled' => $this->translate('Notifications'), - 'host_event_handler_enabled' => $this->translate('Event Handler'), - 'host_flap_detection_enabled' => $this->translate('Flap Detection'), - 'host_obsessing' => $this->translate('Obsessing') - )); - } - - public function serviceAction() - { - $errors = array(); - $query = $this->backend->select()->from('serviceStatus', array( - 'host_name', - 'host_state', - 'service_description', - 'service_handled', - 'service_state', - 'service_in_downtime', - 'service_passive_checks_enabled', - 'service_notifications_enabled', - 'service_event_handler_enabled', - 'service_flap_detection_enabled', - 'service_active_checks_enabled', - 'service_obsessing', - // also accept all filter-requests from ListView - 'service_problem', - 'service_severity', - 'service_last_check', - 'service_state_type', - 'host_severity', - 'host_address', - 'host_last_check' - )); - - $this->applyQueryFilter($query); - $services = $query->getQuery()->fetchAll(); - - $comments = $this->backend->select()->from('comment', array( - 'comment_internal_id', - 'comment_host', - 'comment_service' - )); - $this->applyQueryFilter($comments); - $uniqueComments = array_keys($this->getUniqueValues($comments->getQuery()->fetchAll(), 'comment_internal_id')); - - // populate the view - $this->view->objects = $this->view->services = $services; - $this->view->problems = $this->getProblems($services); - $this->view->comments = $uniqueComments; - $this->view->hostnames = $this->getProperties($services, 'host_name'); - $this->view->servicenames = $this->getProperties($services, 'service_description'); - $this->view->downtimes = $this->getDowntimes($services); - $this->view->service_states = $this->countStates($services, 'service'); - $this->view->host_states = $this->countStates($services, 'host', 'host_name'); - $this->view->service_pie = $this->createPie( - $this->view->service_states, - $this->view->getHelper('MonitoringState')->getServiceStateColors(), - mt('monitoring', 'Service State') - ); - $this->view->host_pie = $this->createPie( - $this->view->host_states, - $this->view->getHelper('MonitoringState')->getHostStateColors(), - mt('monitoring', 'Host State') - ); - $this->view->errors = $errors; - - $this->handleConfigurationForm(array( - 'service_passive_checks_enabled' => $this->translate('Passive Checks'), - 'service_active_checks_enabled' => $this->translate('Active Checks'), - 'service_notifications_enabled' => $this->translate('Notifications'), - 'service_event_handler_enabled' => $this->translate('Event Handler'), - 'service_flap_detection_enabled' => $this->translate('Flap Detection'), - 'service_obsessing' => $this->translate('Obsessing'), - )); - } - - protected function applyQueryFilter($query) - { - $params = clone $this->params; - $modifyFilter = $params->shift('modifyFilter'); - - $filter = Filter::fromQueryString((string) $params); - if ($modifyFilter) { - $this->view->filterWidget = Widget::create('filterEditor', array( - 'filter' => $filter, - 'query' => $query - )); - } - $this->view->filter = $filter; - $query->applyFilter($filter); - return $query; - } - - /** - * Create an array with all unique values as keys. - * - * @param array $values The array containing the objects - * @param $key The key to access - * - * @return array - */ - private function getUniqueValues($values, $key) - { - $unique = array(); - foreach ($values as $value) { - if (is_array($value)) { - $unique[$value[$key]] = $value[$key]; - } else { - $unique[$value->$key] = $value->$key; - } - } - return $unique; - } - - /** - * Get the numbers of problems of the given objects - * - * @param $objects The objects containing the problems - * - * @return int The problem count - */ - private function getProblems($objects) - { - $problems = 0; - foreach ($objects as $object) { - if (property_exists($object, 'host_unhandled_service_count')) { - $problems += $object->host_unhandled_service_count; - } else if ( - property_exists($object, 'service_handled') && - !$object->service_handled && - $object->service_state > 0 - ) { - $problems++; - } - } - return $problems; - } - - private function countStates($objects, $type = 'host', $unique = null) - { - $known = array(); - if ($type === 'host') { - $states = array_fill_keys($this->view->getHelper('MonitoringState')->getHostStateNames(), 0); - } else { - $states = array_fill_keys($this->view->getHelper('MonitoringState')->getServiceStateNames(), 0); - } - foreach ($objects as $object) { - if (isset($unique)) { - if (array_key_exists($object->$unique, $known)) { - continue; - } - $known[$object->$unique] = true; - } - $states[$this->view->monitoringState($object, $type)]++; - } - return $states; - } - - private function createPie($states, $colors, $title) - { - $chart = new InlinePie(array_values($states), $title, $colors); - $chart->setLabel(array_keys($states))->setSize(100); - $chart->setTitle($title); - return $chart; - } - - - private function getComments($objects) - { - $unique = array(); - foreach ($objects as $object) { - $unique = array_merge($unique, $this->getUniqueValues($object->comments, 'comment_internal_id')); - } - return array_keys($unique); - } - - private function getProperties($objects, $property) - { - $objectnames = array(); - foreach ($objects as $object) { - $objectnames[] = $object->$property; - } - return $objectnames; - } - - private function getDowntimes($objects) - { - $downtimes = array(); - foreach ($objects as $object) - { - if ( - (property_exists($object, 'host_in_downtime') && $object->host_in_downtime) || - (property_exists($object, 'service_in_downtime') && $object->service_in_downtime) - ) { - $downtimes[] = true; - } - } - return $downtimes; - } - - - /** - * Handle the form to edit configuration flags. - * - * @param $flags array The used flags. - */ - private function handleConfigurationForm(array $flags) - { - $this->view->form = $form = new MultiCommandFlagForm($flags); - $this->view->formElements = $form->buildCheckboxes(); - $form->setRequest($this->_request); - if ($form->isSubmittedAndValid()) { - // TODO: Handle commands - $changed = $form->getChangedValues(); - } - if ($this->_request->isPost() === false) { - $this->view->form->initFromItems($this->view->objects); - } - } -} From 41ef926fd6511aecba184a803c2ed81b3a044a5d Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Tue, 30 Dec 2014 10:39:33 +0100 Subject: [PATCH 0115/2920] monitoring: Remove the CommandController The controller is no longer used. --- .../controllers/CommandController.php | 1098 ----------------- 1 file changed, 1098 deletions(-) delete mode 100644 modules/monitoring/application/controllers/CommandController.php diff --git a/modules/monitoring/application/controllers/CommandController.php b/modules/monitoring/application/controllers/CommandController.php deleted file mode 100644 index d2615104a..000000000 --- a/modules/monitoring/application/controllers/CommandController.php +++ /dev/null @@ -1,1098 +0,0 @@ -form = $form; - } - - /** - * Test if we have a valid form object - * - * @return bool - */ - public function issetForm() - { - return $this->form !== null && ($this->form instanceof Form); - } - - protected function addTitleTab($action) - { - $this->getTabs()->add($action, array( - 'title' => ucfirst($action), - 'url' => Url::fromRequest() - ))->activate($action); - } - - /** - * Post dispatch method - * - * When we have a form put it into the view - */ - public function postDispatch() - { - - if ($this->issetForm()) { - if ($this->form->isSubmittedAndValid()) { - $this->_helper->viewRenderer->setNoRender(true); - $this->_helper->layout()->disableLayout(); - $this->ignoreXhrBody(); - if ($this->_request->getHeader('referer') && ! $this->getRequest()->isXmlHttpRequest()) { - $this->redirect($this->_request->getHeader('referer')); - } - } else { - $this->view->form = $this->form; - } - } - parent::postDispatch(); - } - - /** - * Controller configuration - * - * @throws Icinga\Exception\ConfigurationError - */ - public function init() - { - if ($this->_request->isPost()) { - $instance = $this->_request->getPost('instance'); - $targetConfig = Config::module('monitoring', 'instances'); - if ($instance) { - if ($targetConfig->get($instance)) { - $this->target = new CommandPipe($targetConfig->get($instance)); - } else { - throw new ConfigurationError( - $this->translate('Instance is not configured: %s'), - $instance - ); - } - } else { - if ($targetConfig && $targetInfo = $targetConfig->current()) { - // Take the very first section - $this->target = new CommandPipe($targetInfo); - } else { - throw new ConfigurationError($this->translate('No instances are configured yet')); - } - } - } - - if ($this->getRequest()->getActionName() !== 'list') { - $this->_helper->viewRenderer->setRender(self::DEFAULT_VIEW_SCRIPT); - } - - $this->view->objects = array(); - } - - /** - * Retrieve all existing targets for host- and service combination - * - * @param $hostOnly Ignore the service parameters - * (for example when using commands that only make sense for hosts) - * @return array Array of monitoring objects - * @throws Icinga\Exception\MissingParameterException - */ - private function selectCommandTargets($hostOnly = false) - { - $query = null; - - $fields = array( - 'host_name', - 'host_state' - ); - - try { - $hostname = $this->getParam('host', null); - $servicename = $this->getParam('service', null); - - if (!$hostname && !$servicename) { - throw new MissingParameterException('No target given for this command'); - } - - if ($servicename && !$hostOnly) { - $fields[] = 'service_description'; - $query = $this->backend->select() - ->from('serviceStatus', $fields) - ->where('host', $hostname) - ->where('service', $servicename); - } elseif ($hostname) { - $query = $this->backend->select()->from('hostStatus', $fields)->where('host', $hostname); - } else { - throw new MissingParameterException('hostOnly command got no hostname'); - } - return $query->getQuery()->fetchAll(); - - } catch (\Exception $e) { - Logger::error( - "CommandController: SQL Query '%s' failed (message %s) ", - $query ? (string) $query->dump() : '--', $e->getMessage() - ); - return array(); - } - } - - /** - * Convert other params into valid command structure - * - * @param array $supported Array of supported parameter names - * @param array $params Parameters from request - * - * @return array Return - */ - private function selectOtherTargets(array $supported, array $params) - { - $others = array_diff_key($supported, array('host' => true, 'service' => true)); - $otherParams = array_intersect_key($params, $others); - $out = array(); - - foreach ($otherParams as $name => $value) { - $data = new stdClass(); - $data->{$name} = $value; - $out[] = $data; - } - - return $out; - } - - /** - * Displays a list of all commands - * - * This method uses reflection on the sourcecode to determine all *Action classes and return - * a list of them (ignoring the listAction) - */ - public function listAction() - { - $reflection = new ReflectionObject($this); - $commands = array(); - $methods = $reflection->getMethods(ReflectionMethod::IS_PUBLIC); - foreach ($methods as $method) { - $name = $method->getName(); - if ($name !== 'listAction' && preg_match('/Action$/', $name)) { - $commands[] = preg_replace('/Action$/', '', $name); - } - } - $this->view->commands = $commands; - } - - /** - * Tell the controller that at least one of the parameters in $supported is required to be availabe - * - * @param array $supported An array of properties to check for existence in the POST or GET parameter list - * @throws Exception When non of the supported parameters is given - */ - private function setSupportedParameters(array $supported) - { - $objects = array(); - - $supported = array_flip($supported); - - $given = array_intersect_key($supported, $this->getRequest()->getParams()); - - if (empty($given)) { - throw new IcingaException( - 'Missing parameter, supported: %s', - implode(', ', array_flip($supported)) - ); - } - - if (isset($given['host'])) { - $objects = $this->selectCommandTargets(!in_array("service", $supported)); - if (empty($objects)) { - throw new IcingaException('No objects found for your command'); - } - } - - $this->view->objects = $objects; - } - - // ------------------------------------------------------------------------ - // Commands for hosts / services - // ------------------------------------------------------------------------ - - /** - * Handle command disableactivechecks - */ - public function disableactivechecksAction() - { - $this->setSupportedParameters(array('host', 'service', 'global')); - - $form = new SingleArgumentCommandForm(); - - $form->setCommand( - 'DISABLE_HOST_CHECK', - 'DISABLE_SVC_CHECK' - ); - - $form->setGlobalCommands( - 'STOP_EXECUTING_HOST_CHECKS', - 'STOP_EXECUTING_SVC_CHECKS' - ); - - $form->setRequest($this->getRequest()); - $form->setSubmitLabel($this->translate('Disable Active Checks')); - - if ($form->provideGlobalCommand()) { - $form->addNote($this->translate('Disable active checks on a program-wide basis.')); - } else { - $form->addNote($this->translate('Disable active checks for this object.')); - } - - $this->setForm($form); - - if ($form->IsSubmittedAndValid() === true) { - $this->target->sendCommand($form->createCommand(), $this->view->objects); - Notification::success($this->translate('Command has been sent, active checks will be disabled')); - } - } - - /** - * Handle command enableactivechecks - */ - public function enableactivechecksAction() - { - $this->setSupportedParameters(array('host', 'service', 'global')); - $form = new SingleArgumentCommandForm(); - $form->setCommand('ENABLE_HOST_CHECK', 'ENABLE_SVC_CHECK'); - $form->setGlobalCommands('START_EXECUTING_HOST_CHECKS', 'START_EXECUTING_SVC_CHECKS'); - - $form->setRequest($this->getRequest()); - $form->setSubmitLabel($this->translate('Enable Active Checks')); - if ($form->provideGlobalCommand()) { - $form->addNote($this->translate('Enable active checks on a program-wide basis.')); - } else { - $form->addNote($this->translate('Enable active checks for this object.')); - } - $this->setForm($form); - - if ($form->IsSubmittedAndValid() === true) { - $this->target->sendCommand($form->createCommand(), $this->view->objects); - Notification::success($this->translate('Command has been sent, active checks will be enabled')); - } - } - - /** - * Handle command reschedulenextcheck - */ - public function reschedulenextcheckAction() - { - $this->addTitleTab('Reschedule Next Check'); - $this->setSupportedParameters(array('host', 'service')); - $form = new RescheduleNextCheckForm(); - $form->setRequest($this->getRequest()); - $form->setConfiguration(Config::app()); - - $this->setForm($form); - - if ($form->IsSubmittedAndValid() === true) { - $this->target->sendCommand($form->createCommand(), $this->view->objects); - Notification::success($this->translate('Command has been sent, check will be rescheduled')); - } - } - - /** - * Handle command submitpassivecheckresult - */ - public function submitpassivecheckresultAction() - { - $this->setSupportedParameters(array('host', 'service')); - $type = SubmitPassiveCheckResultForm::TYPE_SERVICE; - if ($this->getParam('service', null) === null) { - $type = SubmitPassiveCheckResultForm::TYPE_HOST; - } - - $form = new SubmitPassiveCheckResultForm(); - $form->setRequest($this->getRequest()); - $form->setType($type); - - $this->setForm($form); - - if ($form->IsSubmittedAndValid() === true) { - $this->target->sendCommand($form->createCommand(), $this->view->objects); - Notification::success($this->translate('Passive check result has been submitted')); - } - } - - /** - * Handle command stopobsessing - */ - public function stopobsessingAction() - { - $this->setSupportedParameters(array('host', 'service', 'global')); - $form = new SingleArgumentCommandForm(); - $form->setRequest($this->getRequest()); - $form->setSubmitLabel($this->translate('Stop obsessing')); - - if ($form->provideGlobalCommand() === true) { - $form->addNote($this->translate('Disable obsessing on a program-wide basis.')); - } else { - $form->addNote($this->translate('Stop obsessing over this object.')); - } - - $form->setCommand( - 'STOP_OBSESSING_OVER_HOST', - 'STOP_OBSESSING_OVER_SVC' - ); - - $form->setGlobalCommands( - 'STOP_OBSESSING_OVER_HOST_CHECKS', - 'STOP_OBSESSING_OVER_SVC_CHECKS' - ); - - $this->setForm($form); - - if ($form->IsSubmittedAndValid() === true) { - $this->target->sendCommand($form->createCommand(), $this->view->objects); - Notification::success($this->translate('Command has been sent, obsessing will be disabled')); - } - } - - /** - * Handle command startobsessing - */ - public function startobsessingAction() - { - $this->setSupportedParameters(array('host', 'service', 'global')); - $form = new SingleArgumentCommandForm(); - $form->setRequest($this->getRequest()); - $form->setSubmitLabel($this->translate('Start obsessing')); - - if ($form->provideGlobalCommand() === true) { - $form->addNote($this->translate('Enable obsessing on a program-wide basis.')); - } else { - $form->addNote($this->translate('Start obsessing over this object.')); - } - - $form->setCommand( - 'START_OBSESSING_OVER_HOST', - 'START_OBSESSING_OVER_SVC' - ); - - $form->setGlobalCommands( - 'START_OBSESSING_OVER_HOST_CHECKS', - 'START_OBSESSING_OVER_SVC_CHECKS' - ); - - $this->setForm($form); - - if ($form->IsSubmittedAndValid() === true) { - $this->target->sendCommand($form->createCommand(), $this->view->objects); - Notification::success($this->translate('Command has been sent, obsessing will be enabled')); - } - } - - /** - * Handle command stopacceptingpassivechecks - */ - public function stopacceptingpassivechecksAction() - { - $this->setSupportedParameters(array('host', 'service', 'global')); - $form = new SingleArgumentCommandForm(); - $form->setRequest($this->getRequest()); - $form->setSubmitLabel($this->translate('Stop Accepting Passive Checks')); - - if ($form->provideGlobalCommand() === true) { - $form->addNote($this->translate('Disable passive checks on a program-wide basis.')); - } else { - $form->addNote($this->translate('Passive checks for this object will be omitted.')); - } - - $form->setCommand( - 'DISABLE_PASSIVE_HOST_CHECKS', - 'DISABLE_PASSIVE_SVC_CHECKS' - ); - - $form->setGlobalCommands( - 'STOP_ACCEPTING_PASSIVE_HOST_CHECKS', - 'STOP_ACCEPTING_PASSIVE_SVC_CHECKS' - ); - - $this->setForm($form); - - if ($form->IsSubmittedAndValid() === true) { - $this->target->sendCommand($form->createCommand(), $this->view->objects); - Notification::success($this->translate('Command has been sent, passive check results will be refused')); - } - } - - /** - * Handle command startacceptingpassivechecks - */ - public function startacceptingpassivechecksAction() - { - $this->setSupportedParameters(array('host', 'service', 'global')); - $form = new SingleArgumentCommandForm(); - $form->setRequest($this->getRequest()); - $form->setSubmitLabel($this->translate('Start Accepting Passive Checks')); - - if ($form->provideGlobalCommand() === true) { - $form->addNote($this->translate('Enable passive checks on a program-wide basis.')); - } else { - $form->addNote($this->translate('Passive checks for this object will be accepted.')); - } - - $form->setCommand( - 'ENABLE_PASSIVE_HOST_CHECKS', - 'ENABLE_PASSIVE_SVC_CHECKS' - ); - - $form->setGlobalCommands( - 'START_ACCEPTING_PASSIVE_HOST_CHECKS', - 'START_ACCEPTING_PASSIVE_SVC_CHECKS' - ); - $this->setForm($form); - - if ($form->IsSubmittedAndValid() === true) { - $this->target->sendCommand($form->createCommand(), $this->view->objects); - Notification::success($this->translate('Command has been sent, passive check results will be accepted')); - } - } - - /** - * Disable notifications with expiration - * - * This is a global command only - */ - public function disablenotificationswithexpireAction() - { - $this->setParam('global', 1); - $form = new DisableNotificationWithExpireForm(); - $form->setRequest($this->_request); - $this->setForm($form); - - if ($form->IsSubmittedAndValid() === true) { - $this->target->sendCommand($form->createCommand(), $this->view->objects); - Notification::success($this->translate('Command has been sent, notifications will be disabled')); - } - } - - /** - * Handle command disablenotifications - */ - public function disablenotificationsAction() - { - $this->setSupportedParameters(array('host', 'service', 'global')); - $form = new SingleArgumentCommandForm(); - $form->setRequest($this->getRequest()); - - $form->setSubmitLabel($this->translate('Disable Notifications')); - - if ($form->provideGlobalCommand() === true) { - $form->addNote($this->translate('Disable notifications on a program-wide basis.')); - } else { - $form->addNote($this->translate('Notifications for this object will be disabled.')); - } - - $form->setCommand('DISABLE_HOST_NOTIFICATIONS', 'DISABLE_SVC_NOTIFICATIONS'); - $form->setGlobalCommands('DISABLE_NOTIFICATIONS'); - - $this->setForm($form); - - if ($form->IsSubmittedAndValid() === true) { - $this->target->sendCommand($form->createCommand(), $this->view->objects); - Notification::success($this->translate('Command has been sent, notifications will be disabled')); - } - - } - - /** - * Handle command enablenotifications - */ - public function enablenotificationsAction() - { - $this->addTitleTab('Enable Notifications'); - $this->setSupportedParameters(array('host', 'service', 'global')); - $form = new SingleArgumentCommandForm(); - $form->setRequest($this->getRequest()); - - $form->setSubmitLabel($this->translate('Enable Notifications')); - - if ($form->provideGlobalCommand() === true) { - $form->addNote($this->translate('Enable notifications on a program-wide basis.')); - } else { - $form->addNote($this->translate('Notifications for this object will be enabled.')); - } - - $form->setCommand('ENABLE_HOST_NOTIFICATIONS', 'ENABLE_SVC_NOTIFICATIONS'); - $form->setGlobalCommands('ENABLE_NOTIFICATIONS'); - - $this->setForm($form); - - if ($form->IsSubmittedAndValid() === true) { - $this->target->sendCommand($form->createCommand(), $this->view->objects); - Notification::success($this->translate('Command has been sent, notifications will be enabled')); - } - } - - /** - * Handle command sendcustomnotification - */ - public function sendcustomnotificationAction() - { - $this->setSupportedParameters(array('host', 'service')); - $form = new CustomNotificationForm(); - $form->setRequest($this->getRequest()); - $this->setForm($form); - - if ($form->IsSubmittedAndValid() === true) { - $this->target->sendCommand($form->createCommand(), $this->view->objects); - Notification::success($this->translate('Custom notification has been sent')); - } - } - - /** - * Handle command scheduledowntime - */ - public function scheduledowntimeAction() - { - $this->addTitleTab('Schedule Downtime'); - $this->setSupportedParameters(array('host', 'service')); - $form = new ScheduleDowntimeForm(); - $form->setRequest($this->getRequest()); - $form->setConfiguration(Config::app()); - $form->setWithChildren(false); - $this->setForm($form); - - if ($form->IsSubmittedAndValid() === true) { - $this->target->sendCommand($form->createCommand(), $this->view->objects); - Notification::success($this->translate('Downtime scheduling requested')); - } - } - - /** - * Handle command scheduledowntimeswithchildren - */ - public function scheduledowntimeswithchildrenAction() - { - $this->setSupportedParameters(array('host')); - $form = new ScheduleDowntimeForm(); - $form->setRequest($this->getRequest()); - $form->setConfiguration(Config::app()); - $form->setWithChildren(true); - $this->setForm($form); - - if ($form->IsSubmittedAndValid() === true) { - $this->target->sendCommand($form->createCommand(), $this->view->objects); - Notification::success($this->translate('Downtime scheduling requested')); - } - } - - /** - * Handle command removedowntimeswithchildren - */ - public function removedowntimeswithchildrenAction() - { - $this->setSupportedParameters(array('host')); - $form = new SingleArgumentCommandForm(); - $form->setRequest($this->getRequest()); - $form->setSubmitLabel($this->translate('Remove Downtime(s)')); - $form->addNote($this->translate('Remove downtime(s) from this host and its services.')); - $form->setCommand('DEL_DOWNTIME_BY_HOST_NAME', 'DEL_DOWNTIME_BY_HOST_NAME'); - $this->setForm($form); - - if ($form->IsSubmittedAndValid() === true) { - $this->target->sendCommand($form->createCommand(), $this->view->objects); - Notification::success($this->translate('Downtime removal requested')); - } - } - - /** - * Handle command disablenotificationswithchildren - */ - public function disablenotificationswithchildrenAction() - { - $this->setSupportedParameters(array('host')); - $form = new SingleArgumentCommandForm(); - $form->setRequest($this->getRequest()); - $form->setSubmitLabel($this->translate('Disable Notifications')); - $form->addNote($this->translate('Notifications for this host and its services will be disabled.')); - $form->setCommand('DISABLE_ALL_NOTIFICATIONS_BEYOND_HOST'); - $this->setForm($form); - - if ($form->IsSubmittedAndValid() === true) { - $this->target->sendCommand($form->createCommand(), $this->view->objects); - $form->setCommand('DISABLE_HOST_NOTIFICATIONS', 'DISABLE_SVC_NOTIFICATIONS'); - $this->target->sendCommand($form->createCommand(), $this->view->objects); - Notification::success($this->translate('Command has been sent, notifications will be disabled')); - } - } - - /** - * Handle command enablenotificationswithchildren - */ - public function enablenotificationswithchildrenAction() - { - $this->setSupportedParameters(array('host')); - $form = new SingleArgumentCommandForm(); - $form->setRequest($this->getRequest()); - $form->setSubmitLabel($this->translate('Enable Notifications')); - $form->addNote($this->translate('Notifications for this host and its services will be enabled.')); - $form->setCommand('ENABLE_ALL_NOTIFICATIONS_BEYOND_HOST'); - $this->setForm($form); - - if ($form->IsSubmittedAndValid() === true) { - $this->target->sendCommand($form->createCommand(), $this->view->objects); - $form->setCommand('ENABLE_HOST_NOTIFICATIONS', 'ENABLE_SVC_NOTIFICATIONS'); - $this->target->sendCommand($form->createCommand(), $this->view->objects); - Notification::success($this->translate('Command has been sent, notifications will be enabled')); - } - } - - /** - * Handle command reschedulenextcheckwithchildren - */ - public function reschedulenextcheckwithchildrenAction() - { - $this->setSupportedParameters(array('host')); - $form = new RescheduleNextCheckForm(); - $form->setRequest($this->getRequest()); - $form->setConfiguration(Config::app()); - $form->setWithChildren(true); - - $this->setForm($form); - - if ($form->IsSubmittedAndValid() === true) { - $this->target->sendCommand($form->createCommand(), $this->view->objects); - Notification::success($this->translate('Command has been sent, checks will be rescheduled')); - } - } - - /** - * Handle command disableactivecheckswithchildren - */ - public function disableactivecheckswithchildrenAction() - { - $this->setSupportedParameters(array('host')); - $form = new SingleArgumentCommandForm(); - $form->setRequest($this->getRequest()); - $form->setSubmitLabel($this->translate('Disable Active Checks')); - $form->addNote($this->translate('Disable active checks for this host and its services.')); - $form->setCommand('DISABLE_HOST_CHECK'); - $this->setForm($form); - - if ($form->IsSubmittedAndValid() === true) { - // @TODO(mh): Missing child command - $this->target->sendCommand($form->createCommand(), $this->view->objects); - Notification::success($this->translate('Command has been sent, active checks will be disabled')); - } - } - - /** - * Handle command enableactivecheckswithchildren - */ - public function enableactivecheckswithchildrenAction() - { - $this->setSupportedParameters(array('host')); - $form = new SingleArgumentCommandForm(); - $form->setRequest($this->getRequest()); - $form->setSubmitLabel($this->translate('Enable Active Checks')); - $form->addNote($this->translate('Enable active checks for this host and its services.')); - $form->setCommand('ENABLE_HOST_CHECK'); - $this->setForm($form); - - if ($form->IsSubmittedAndValid() === true) { - // @TODO(mh): Missing child command - $this->target->sendCommand($form->createCommand(), $this->view->objects); - Notification::success($this->translate('Command has been sent, active checks will be enabled')); - } - } - - /** - * Handle command disableeventhandler - */ - public function disableeventhandlerAction() - { - $this->setSupportedParameters(array('host', 'service', 'global')); - $form = new SingleArgumentCommandForm(); - $form->setRequest($this->getRequest()); - $form->setSubmitLabel($this->translate('Disable Event Handler')); - - if ($form->provideGlobalCommand() === true) { - $form->addNote($this->translate('Disable event handler for the whole system.')); - } else { - $form->addNote($this->translate('Disable event handler for this object.')); - } - - $form->setCommand( - 'DISABLE_HOST_EVENT_HANDLER', - 'DISABLE_SVC_EVENT_HANDLER' - ); - - $form->setGlobalCommands('DISABLE_EVENT_HANDLERS'); - - $this->setForm($form); - - if ($form->IsSubmittedAndValid() === true) { - $this->target->sendCommand($form->createCommand(), $this->view->objects); - Notification::success($this->translate('Command has been sent, event handlers will be disabled')); - } - } - - /** - * Handle command enableeventhandler - */ - public function enableeventhandlerAction() - { - $this->setSupportedParameters(array('host', 'service', 'global')); - - $form = new SingleArgumentCommandForm(); - $form->setRequest($this->getRequest()); - $form->setSubmitLabel($this->translate('Enable Event Handler')); - - if ($form->provideGlobalCommand() === true) { - $form->addNote($this->translate('Enable event handlers on the whole system.')); - } else { - $form->addNote($this->translate('Enable event handler for this object.')); - } - - $form->setCommand( - 'ENABLE_HOST_EVENT_HANDLER', - 'ENABLE_SVC_EVENT_HANDLER' - ); - - $form->setGlobalCommands('ENABLE_EVENT_HANDLERS'); - - $this->setForm($form); - - if ($form->IsSubmittedAndValid() === true) { - $this->target->sendCommand($form->createCommand(), $this->view->objects); - Notification::success($this->translate('Command has been sent, event handlers will be enabled')); - } - } - - /** - * Handle command disableflapdetection - */ - public function disableflapdetectionAction() - { - $this->setSupportedParameters(array('host', 'service', 'global')); - $form = new SingleArgumentCommandForm(); - $form->setRequest($this->getRequest()); - $form->setSubmitLabel($this->translate('Disable Flapping Detection')); - - if ($form->provideGlobalCommand() === true) { - $form->addNote($this->translate('Disable flapping detection on a program-wide basis.')); - } else { - $form->addNote($this->translate('Disable flapping detection for this object.')); - } - - $form->setCommand( - 'DISABLE_HOST_FLAP_DETECTION', - 'DISABLE_SVC_FLAP_DETECTION' - ); - - $form->setGlobalCommands( - 'DISABLE_FLAP_DETECTION' - ); - - $this->setForm($form); - - if ($form->IsSubmittedAndValid() === true) { - $this->target->sendCommand($form->createCommand(), $this->view->objects); - Notification::success($this->translate('Command has been sent, flap detection will be disabled')); - } - } - - /** - * Handle command enableflapdetection - */ - public function enableflapdetectionAction() - { - $this->setSupportedParameters(array('host', 'service', 'global')); - $form = new SingleArgumentCommandForm(); - $form->setRequest($this->getRequest()); - $form->setSubmitLabel($this->translate('Enable Flapping Detection')); - - if ($form->provideGlobalCommand() === true) { - $form->addNote($this->translate('Enable flapping detection on a program-wide basis.')); - } else { - $form->addNote($this->translate('Enable flapping detection for this object.')); - } - - $form->setCommand( - 'ENABLE_HOST_FLAP_DETECTION', - 'ENABLE_SVC_FLAP_DETECTION' - ); - - $form->setGlobalCommands( - 'ENABLE_FLAP_DETECTION' - ); - - $this->setForm($form); - - if ($form->IsSubmittedAndValid() === true) { - $this->target->sendCommand($form->createCommand(), $this->view->objects); - Notification::success($this->translate('Command has been sent, flap detection will be enabled')); - } - } - - /** - * Handle command addcomment - */ - public function addcommentAction() - { - $this->addTitleTab('Add comment'); - $this->setSupportedParameters(array('host', 'service')); - $form = new CommentForm(); - $form->setRequest($this->_request); - - $this->setForm($form); - - if ($form->IsSubmittedAndValid() === true) { - $this->target->sendCommand($form->createCommand(), $this->view->objects); - Notification::success($this->translate('Your new comment has been submitted')); - } - } - - /** - * Remove a single comment - */ - public function removecommentAction() - { - $this->addTitleTab('Remove Comment'); - $this->setSupportedParameters(array('commentid', 'host', 'service')); - $form = new SingleArgumentCommandForm(); - $form->setRequest($this->_request); - $form->setCommand('DEL_HOST_COMMENT', 'DEL_SVC_COMMENT'); - $form->setParameterName('commentid'); - $form->setSubmitLabel($this->translate('Remove comment')); - $form->setObjectIgnoreFlag(true); - $this->setForm($form); - - if ($form->IsSubmittedAndValid() === true) { - $this->target->sendCommand($form->createCommand(), $this->view->objects); - Notification::success($this->translate('Comment removal has been requested')); - } - } - - /** - * Handle command resetattributes - */ - public function resetattributesAction() - { - $this->setSupportedParameters(array('host', 'service')); - $form = new SingleArgumentCommandForm(); - $form->setRequest($this->getRequest()); - $form->setSubmitLabel($this->translate('Reset Attributes')); - $form->addNote($this->translate('Reset modified attributes to its default.')); - $form->setCommand('CHANGE_HOST_MODATTR', 'CHANGE_SVC_MODATTR'); - $form->setParameterValue(0); - $this->setForm($form); - - if ($form->IsSubmittedAndValid() === true) { - $this->target->sendCommand($form->createCommand(), $this->view->objects); - } - } - - /** - * Handle command acknowledgeproblem - */ - public function acknowledgeproblemAction() - { - $this->addTitleTab('Acknowledge Problem'); - $this->setSupportedParameters(array('host', 'service')); - $form = new AcknowledgeForm(); - $form->setRequest($this->getRequest()); - $form->setConfiguration(Config::app()); - - if ($form->IsSubmittedAndValid() === true) { - $this->target->sendCommand($form->createCommand(), $this->view->objects); - Notification::success($this->translate('Acknowledgement has been sent')); - } - - $this->setForm($form); - } - - /** - * Handle command removeacknowledgement - */ - public function removeacknowledgementAction() - { - $this->addTitleTab('Remove Acknowledgement'); - $this->setSupportedParameters(array('host', 'service')); - $form = new SingleArgumentCommandForm(); - $form->setRequest($this->getRequest()); - $form->setSubmitLabel($this->translate('Remove Problem Acknowledgement')); - $form->addNote($this->translate('Remove problem acknowledgement for this object.')); - $form->setCommand('REMOVE_HOST_ACKNOWLEDGEMENT', 'REMOVE_SVC_ACKNOWLEDGEMENT'); - $this->setForm($form); - - if ($form->IsSubmittedAndValid() === true) { - $this->target->sendCommand($form->createCommand(), $this->view->objects); - Notification::success($this->translate('Acknowledgement removal has been requested')); - } - } - - /** - * Handle command delaynotification - */ - public function delaynotificationAction() - { - $this->setSupportedParameters(array('host', 'service')); - $form = new DelayNotificationForm(); - $form->setRequest($this->getRequest()); - - $this->setForm($form); - - if ($form->IsSubmittedAndValid() === true) { - $this->target->sendCommand($form->createCommand(), $this->view->objects); - Notification::success($this->translate('Notification delay has been requested')); - } - } - - /** - * Handle command removedowntime - */ - public function removedowntimeAction() - { - $this->setSupportedParameters(array('host', 'service', 'downtimeid')); - $form = new SingleArgumentCommandForm(); - $form->setRequest($this->getRequest()); - - $form->setSubmitLabel($this->translate('Delete Downtime')); - $form->setParameterName('downtimeid'); - $form->addNote($this->translate('Delete a single downtime with the id shown above')); - $form->setCommand('DEL_HOST_DOWNTIME', 'DEL_SVC_DOWNTIME'); - $form->setObjectIgnoreFlag(true); - $this->setForm($form); - - if ($form->IsSubmittedAndValid() === true) { - $this->target->sendCommand($form->createCommand(), $this->view->objects); - Notification::success($this->translate('Downtime removal has been requested')); - } - } - - /** - * Shutdown the icinga process - */ - public function shutdownprocessAction() - { - $this->setParam('global', '1'); - $form = new SingleArgumentCommandForm(); - $form->setRequest($this->_request); - - $form->setSubmitLabel($this->translate('Shutdown monitoring process')); - $form->addNote($this->translate('Stop monitoring instance. You have to start it again from command line.')); - $form->setGlobalCommands('SHUTDOWN_PROCESS'); - $this->setForm($form); - - if ($form->IsSubmittedAndValid() === true) { - $this->target->sendCommand($form->createCommand(), $this->view->objects); - Notification::success($this->translate('Command has been sent, process will shut down')); - } - } - - /** - * Restart the icinga process - */ - public function restartprocessAction() - { - $this->setParam('global', '1'); - $form = new SingleArgumentCommandForm(); - $form->setRequest($this->_request); - - $form->setSubmitLabel($this->translate('Restart monitoring process')); - $form->addNote($this->translate('Restart the monitoring process.')); - $form->setGlobalCommands('RESTART_PROCESS'); - - $this->setForm($form); - - if ($form->IsSubmittedAndValid() === true) { - $this->target->sendCommand($form->createCommand(), $this->view->objects); - Notification::success($this->translate('Command has been sent, monitoring process will restart now')); - } - } - - /** - * Disable processing of performance data - */ - public function disableperformancedataAction() - { - $this->setParam('global', 1); - $form = new SingleArgumentCommandForm(); - $form->setRequest($this->_request); - - $form->setSubmitLabel($this->translate('Disable Performance Data')); - $form->addNote($this->translate('Disable processing of performance data on a program-wide basis.')); - - $form->setGlobalCommands('DISABLE_PERFORMANCE_DATA'); - - $this->setForm($form); - - if ($form->IsSubmittedAndValid() === true) { - $this->target->sendCommand($form->createCommand(), $this->view->objects); - Notification::success($this->translate('Command has been sent, performance data processing will be disabled')); - } - } - - /** - * Enable processing of performance data - */ - public function enableperformancedataAction() - { - $this->setParam('global', 1); - $form = new SingleArgumentCommandForm(); - $form->setRequest($this->_request); - - $form->setSubmitLabel($this->translate('Enable Performance Data')); - $form->addNote($this->translate('Enable processing of performance data on a program-wide basis.')); - - $form->setGlobalCommands('ENABLE_PERFORMANCE_DATA'); - - $this->setForm($form); - - if ($form->IsSubmittedAndValid() === true) { - $this->target->sendCommand($form->createCommand(), $this->view->objects); - Notification::success($this->translate('Command has been sent, performance data processing will be enabled')); - } - } -} From c28f4284e4536378e81856e5c3d4934c70999381 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Tue, 30 Dec 2014 10:40:56 +0100 Subject: [PATCH 0116/2920] monitoring: Remove the command/* view scripts They are no longer used. --- .../views/scripts/command/list.phtml | 10 -------- .../views/scripts/command/renderform.phtml | 25 ------------------- 2 files changed, 35 deletions(-) delete mode 100644 modules/monitoring/application/views/scripts/command/list.phtml delete mode 100644 modules/monitoring/application/views/scripts/command/renderform.phtml diff --git a/modules/monitoring/application/views/scripts/command/list.phtml b/modules/monitoring/application/views/scripts/command/list.phtml deleted file mode 100644 index 747dd4b5e..000000000 --- a/modules/monitoring/application/views/scripts/command/list.phtml +++ /dev/null @@ -1,10 +0,0 @@ -

    - \ No newline at end of file diff --git a/modules/monitoring/application/views/scripts/command/renderform.phtml b/modules/monitoring/application/views/scripts/command/renderform.phtml deleted file mode 100644 index 9c8e79428..000000000 --- a/modules/monitoring/application/views/scripts/command/renderform.phtml +++ /dev/null @@ -1,25 +0,0 @@ -
    -tabs ?> -
    -
    -objects) && !empty($this->objects) && isset($this->objects[0]->host_name)): ?> - - - - - - - - -objects as $object): ?> - - - - - - -
    icon('host') ?> Hosticon('conf') ?> Service
    host_name; ?>service_description) ? $object->service_description : '') ?>
    - - -form ?> -
    From 3d95e37b7f99ad42d9990b50c28a4635b88a017b Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Tue, 30 Dec 2014 10:43:39 +0100 Subject: [PATCH 0117/2920] monitoring: Count services once in services/show.phtml --- .../monitoring/application/views/scripts/services/show.phtml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/modules/monitoring/application/views/scripts/services/show.phtml b/modules/monitoring/application/views/scripts/services/show.phtml index e8a4c70a1..5b39489e2 100644 --- a/modules/monitoring/application/views/scripts/services/show.phtml +++ b/modules/monitoring/application/views/scripts/services/show.phtml @@ -2,13 +2,14 @@ tabs ?>
    - + + translate('No services matching the filter') ?>
    - translatePlural('Service (%u)', 'Services (%u)', array_sum(array_values($serviceStates))), array_sum(array_values($serviceStates))) ?> + translatePlural('Service (%u)', 'Services (%u)', $serviceCount), $serviceCount) ?>
    serviceStatesPieChart ?> From a7a99b5856423ddbb29807886a11a2f5d2b1ca6f Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Tue, 30 Dec 2014 10:44:22 +0100 Subject: [PATCH 0118/2920] monitoring: Count hosts once in services/show.phtml --- .../monitoring/application/views/scripts/services/show.phtml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/modules/monitoring/application/views/scripts/services/show.phtml b/modules/monitoring/application/views/scripts/services/show.phtml index 5b39489e2..2e73c8c5d 100644 --- a/modules/monitoring/application/views/scripts/services/show.phtml +++ b/modules/monitoring/application/views/scripts/services/show.phtml @@ -23,7 +23,8 @@
    - translatePlural('Host (%u)', 'Hosts (%u)', array_sum(array_values($hostStates))), array_sum(array_values($hostStates))) ?> + + translatePlural('Host (%u)', 'Hosts (%u)', $hostCount), $hostCount) ?>
    hostStatesPieChart ?> From df3d7d2034772d12c7cac6e49d6663babeaf4970 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Tue, 30 Dec 2014 10:45:24 +0100 Subject: [PATCH 0119/2920] monitoring: Count unhandled services once in services/show.phtml --- .../monitoring/application/views/scripts/services/show.phtml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/modules/monitoring/application/views/scripts/services/show.phtml b/modules/monitoring/application/views/scripts/services/show.phtml index 2e73c8c5d..794849141 100644 --- a/modules/monitoring/application/views/scripts/services/show.phtml +++ b/modules/monitoring/application/views/scripts/services/show.phtml @@ -70,13 +70,14 @@

    + translatePlural( '%u Unhandled Service Problem', '%u Unhandled Service Problems', - count($unhandledObjects) + $unhandledCount ), - count($unhandledObjects) + $unhandledCount ) ?>

    From 128f6822f1baf4fb562de8aaff0df8364cd0c8c3 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Tue, 30 Dec 2014 10:46:08 +0100 Subject: [PATCH 0120/2920] monitoring: Count acknowledged services once in services/show.phtml --- .../monitoring/application/views/scripts/services/show.phtml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/modules/monitoring/application/views/scripts/services/show.phtml b/modules/monitoring/application/views/scripts/services/show.phtml index 794849141..46e3babf1 100644 --- a/modules/monitoring/application/views/scripts/services/show.phtml +++ b/modules/monitoring/application/views/scripts/services/show.phtml @@ -98,13 +98,14 @@

    + translatePlural( '%u Acknowledged Service Problem', '%u Acknowledged Service Problems', - count($acknowledgedObjects) + $acknowledgedCount ), - count($acknowledgedObjects) + $acknowledgedCount ) ?>

    From 2e4e04551d8e062426ac0df959e768b97b59c801 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Tue, 30 Dec 2014 10:47:10 +0100 Subject: [PATCH 0121/2920] monitoring: Count services in downtime once in services/show.phtml --- .../application/views/scripts/services/show.phtml | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/modules/monitoring/application/views/scripts/services/show.phtml b/modules/monitoring/application/views/scripts/services/show.phtml index 46e3babf1..cb19c2f5f 100644 --- a/modules/monitoring/application/views/scripts/services/show.phtml +++ b/modules/monitoring/application/views/scripts/services/show.phtml @@ -115,10 +115,18 @@

    + icon('plug') ?> - translatePlural('%u service is in downtime', '%u services are in downtime', count($objectsInDowntime)), count($objectsInDowntime)) ?> + translatePlural( + '%u service is in downtime', + '%u services are in downtime', + $inDowntimeCount + ), + $inDowntimeCount + ) ?>

    From 9c989306d9ba8ca4fddf27793876e8abd55fe768 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Tue, 30 Dec 2014 10:48:30 +0100 Subject: [PATCH 0122/2920] monitoring: Count services having comments once in services/show.phtml --- .../application/views/scripts/services/show.phtml | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/modules/monitoring/application/views/scripts/services/show.phtml b/modules/monitoring/application/views/scripts/services/show.phtml index cb19c2f5f..65049b792 100644 --- a/modules/monitoring/application/views/scripts/services/show.phtml +++ b/modules/monitoring/application/views/scripts/services/show.phtml @@ -131,12 +131,20 @@ - getComments())): ?> + getComments()) ?> +

    icon('comment') ?> - translatePlural('%u comment', '%u comments', count($objects->getComments())), count($objects->getComments())) ?> + translatePlural( + '%u comment', + '%u comments', + $havingCommentsCount + ), + $havingCommentsCount + ) ?>

    From a37d68b235ffefb4f47d2a3c07eef95287062cc7 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Tue, 30 Dec 2014 10:51:33 +0100 Subject: [PATCH 0123/2920] monitoring: Remove run.php The monitoring module still registered the obsolete top bar hook. --- modules/monitoring/run.php | 8 -------- 1 file changed, 8 deletions(-) delete mode 100644 modules/monitoring/run.php diff --git a/modules/monitoring/run.php b/modules/monitoring/run.php deleted file mode 100644 index 8f4ee1b67..000000000 --- a/modules/monitoring/run.php +++ /dev/null @@ -1,8 +0,0 @@ -registerHook( - 'TopBar', - 'Icinga\\Module\\Monitoring\\Web\\Hook\\TopBar' -); From c59c0e6cdb180efcca6d5afa00125c2e27c0e6d1 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Tue, 30 Dec 2014 10:52:12 +0100 Subject: [PATCH 0124/2920] monitoring: Remove top bar hook layout No longer in use. --- .../views/scripts/layout/topbar.phtml | 65 ------------------- 1 file changed, 65 deletions(-) delete mode 100644 modules/monitoring/application/views/scripts/layout/topbar.phtml diff --git a/modules/monitoring/application/views/scripts/layout/topbar.phtml b/modules/monitoring/application/views/scripts/layout/topbar.phtml deleted file mode 100644 index f7c58db85..000000000 --- a/modules/monitoring/application/views/scripts/layout/topbar.phtml +++ /dev/null @@ -1,65 +0,0 @@ - - - From a781b8c60705d7072e796234025f17a18e22116b Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Tue, 30 Dec 2014 10:52:57 +0100 Subject: [PATCH 0125/2920] monitoring: Remove the top bar hook No longer in use. --- .../library/Monitoring/Web/Hook/TopBar.php | 61 ------------------- 1 file changed, 61 deletions(-) delete mode 100644 modules/monitoring/library/Monitoring/Web/Hook/TopBar.php diff --git a/modules/monitoring/library/Monitoring/Web/Hook/TopBar.php b/modules/monitoring/library/Monitoring/Web/Hook/TopBar.php deleted file mode 100644 index 082a03c5b..000000000 --- a/modules/monitoring/library/Monitoring/Web/Hook/TopBar.php +++ /dev/null @@ -1,61 +0,0 @@ -getQuery()->fetchRow(); - - $serviceSummary = StatusSummaryView::fromRequest( - $request, - array( - 'services_ok', - 'services_critical_handled', - 'services_critical_unhandled', - 'services_warning_handled', - 'services_warning_unhandled', - 'services_unknown_handled', - 'services_unknown_unhandled', - 'services_pending' - ) - )->getQuery()->fetchRow(); - - return $this->getView()->partial( - 'layout/topbar.phtml', - 'monitoring', - array( - 'hostSummary' => $hostSummary, - 'serviceSummary' => $serviceSummary - ) - ); - } -} From a5122f540d7506ecc51cdfecc26f1628f5f0f873 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Tue, 30 Dec 2014 11:14:13 +0100 Subject: [PATCH 0126/2920] monitoring: Add 'Notifications' to the 'Overview' menu section --- modules/monitoring/configuration.php | 29 ++++++++++++++++------------ 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/modules/monitoring/configuration.php b/modules/monitoring/configuration.php index b1cdee2de..f56c23d5c 100644 --- a/modules/monitoring/configuration.php +++ b/modules/monitoring/configuration.php @@ -127,22 +127,27 @@ $section->add($this->translate('Hostgroups'), array( 'url' => 'monitoring/list/hostgroups', 'priority' => 60 )); -$section->add($this->translate('Contactgroups'), array( - 'url' => 'monitoring/list/contactgroups', - 'priority' => 61 -)); -$section->add($this->translate('Downtimes'), array( - 'url' => 'monitoring/list/downtimes', - 'priority' => 71 -)); -$section->add($this->translate('Comments'), array( - 'url' => 'monitoring/list/comments?comment_type=(comment|ack)', - 'priority' => 70 -)); $section->add($this->translate('Contacts'), array( 'url' => 'monitoring/list/contacts', 'priority' => 70 )); +$section->add($this->translate('Contactgroups'), array( + 'url' => 'monitoring/list/contactgroups', + 'priority' => 70 +)); +$section->add($this->translate('Comments'), array( + 'url' => 'monitoring/list/comments?comment_type=(comment|ack)', + 'priority' => 80 +)); +$section->add($this->translate('Downtimes'), array( + 'url' => 'monitoring/list/downtimes', + 'priority' => 80 +)); +$section->add($this->translate('Notifications'), array( + 'url' => 'monitoring/list/notifications', + 'priority' => 80 +)); + /* * History Section From ac56cc02acd034fe0be68f440febc94ffe847839 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Tue, 30 Dec 2014 11:14:30 +0100 Subject: [PATCH 0127/2920] monitoring: Fix the notifications view script --- .../views/scripts/list/notifications.phtml | 140 ++++++++---------- 1 file changed, 65 insertions(+), 75 deletions(-) diff --git a/modules/monitoring/application/views/scripts/list/notifications.phtml b/modules/monitoring/application/views/scripts/list/notifications.phtml index 13736b9f3..939d46eba 100644 --- a/modules/monitoring/application/views/scripts/list/notifications.phtml +++ b/modules/monitoring/application/views/scripts/list/notifications.phtml @@ -5,85 +5,75 @@ use Icinga\Module\Monitoring\Object\Service; ?> -compact): ?> +compact): ?>
    - tabs ?> -
    - translate('Sort by') ?> sortControl->render($this) ?> -
    - widget('limiter') ?> - paginationControl($notifications, null, null, array('preserve' => $this->preserve)) ?> -
    + tabs ?> +
    + translate('Sort by') ?> sortControl->render($this) ?> +
    + widget('limiter') ?> + paginationControl($notifications, null, null, array('preserve' => $this->preserve)) ?> +
    -inline): ?>
    - + + translate('No notifications matching the filter') ?> + -notifications)) { - echo 'No notifications yet
    '; - return; -} -?> - - - -service)) { - $isService = true; - $href = $this->href('monitoring/show/service', array( - 'host' => $notification->host, - 'service' => $notification->service - )); - $stateName = Service::getStateText($notification->notification_state); - } else { - $isService = false; - $href = $this->href('monitoring/show/host', array( - 'host' => $notification->host - )); - $stateName = Host::getStateText($notification->notification_state); - } -?> - - + + + + + +
    - dateTimeRenderer($notification->notification_start_time)->render( - $this->translate('on %s', 'datetime'), - $this->translate('at %s', 'time'), - $this->translate('%s ago', 'timespan') - ); + + + service)) { + $isService = true; + $href = $this->href('monitoring/show/service', array( + 'host' => $notification->host, + 'service' => $notification->service + )); + $stateName = Service::getStateText($notification->notification_state); + } else { + $isService = false; + $href = $this->href('monitoring/show/host', array( + 'host' => $notification->host + )); + $stateName = Host::getStateText($notification->notification_state); + } ?> - - - - - -
    - - translate('%s on %s'), "$notification->service", $notification->host); ?> - - host ?> - -
    - escape(substr(strip_tags($notification->notification_output), 0, 10000)); ?> -
    - contact): ?> - - translate('Sent to %s'), "href( - 'monitoring/show/contact', - array('contact' => $notification->notification_contact) - )\">$this->escape($notification->notification_contact)"); ?> - - -
    - -inline): ?> +
    + dateTimeRenderer($notification->notification_start_time)->render( + $this->translate('on %s', 'datetime'), + $this->translate('at %s', 'time'), + $this->translate('%s ago', 'timespan') + ) ?> + + + translate('%s on %s'), + $this->qlink($notification->service, $href), $notification->host + ) ?> + + qlink($notification->host, $href) ?> + +
    + escape(substr(strip_tags($notification->notification_output), 0, 10000)); ?> +
    + contact): ?> + + translate('Sent to %s'), + $this->qlink( + $notification->notification_contact, + 'monitoring/show/contact', + array('contact' => $notification->notification_contact) + ) + ) ?> + + +
    - From 9af46838b0611edcad7c5c52301bcd6f8d5a635b Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Tue, 30 Dec 2014 12:26:40 +0100 Subject: [PATCH 0128/2920] Remove the var/log directory --- var/log/.gitkeep | 0 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 var/log/.gitkeep diff --git a/var/log/.gitkeep b/var/log/.gitkeep deleted file mode 100644 index e69de29bb..000000000 From 8eb37d9d766769f49e634e22a8eaf305afdecd74 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Tue, 30 Dec 2014 14:33:36 +0100 Subject: [PATCH 0129/2920] Cli/Command: Add @type PHPDoc to params --- library/Icinga/Cli/Command.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/library/Icinga/Cli/Command.php b/library/Icinga/Cli/Command.php index 7546f871f..59d33ae4b 100644 --- a/library/Icinga/Cli/Command.php +++ b/library/Icinga/Cli/Command.php @@ -16,6 +16,10 @@ abstract class Command { protected $app; protected $docs; + + /** + * @type Params + */ protected $params; protected $screen; protected $isVerbose; From 5e812c72f1197c55555aad86042f104b293574f7 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Tue, 30 Dec 2014 14:37:34 +0100 Subject: [PATCH 0130/2920] cli/webserver config: Fix --config sanity check --- modules/setup/application/clicommands/ConfigCommand.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/setup/application/clicommands/ConfigCommand.php b/modules/setup/application/clicommands/ConfigCommand.php index 676572542..aa1cb98cf 100644 --- a/modules/setup/application/clicommands/ConfigCommand.php +++ b/modules/setup/application/clicommands/ConfigCommand.php @@ -113,7 +113,7 @@ class ConfigCommand extends Command )); } $configDir = $this->params->get('config', $webserver->getConfigDir()); - if (! is_string($documentRoot) || strlen(trim($documentRoot)) === 0) { + if (! is_string($configDir) || strlen(trim($configDir)) === 0) { $this->fail($this->translate( 'The argument --config expects a path to Icinga Web 2\'s configuration files' )); From 70c564bb0e56bca5ba23ba9a2c9b01f7115d5b35 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Tue, 30 Dec 2014 14:41:00 +0100 Subject: [PATCH 0131/2920] Cli: Remove useless sprintf format in Command::fail() --- library/Icinga/Cli/Command.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library/Icinga/Cli/Command.php b/library/Icinga/Cli/Command.php index 59d33ae4b..c410cfc0e 100644 --- a/library/Icinga/Cli/Command.php +++ b/library/Icinga/Cli/Command.php @@ -128,7 +128,7 @@ abstract class Command public function fail($msg) { - throw new IcingaException('%s', $msg); + throw new IcingaException($msg); } public function getDefaultActionName() From 60b74ddcec094eb342ab0ec49202bd514576126c Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Tue, 30 Dec 2014 14:41:35 +0100 Subject: [PATCH 0132/2920] Cli: Fix parameter documentation for ConfigCommand::webserverAction() We speak of icingaweb2 not icingaweb now. --- .../setup/application/clicommands/ConfigCommand.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/modules/setup/application/clicommands/ConfigCommand.php b/modules/setup/application/clicommands/ConfigCommand.php index aa1cb98cf..d26dfdd80 100644 --- a/modules/setup/application/clicommands/ConfigCommand.php +++ b/modules/setup/application/clicommands/ConfigCommand.php @@ -73,11 +73,11 @@ class ConfigCommand extends Command * * OPTIONS: * - * --path= The URL path to Icinga Web 2 [/icingaweb] + * --path= The URL path to Icinga Web 2 [/icingaweb2] * - * --root/--document-root= The directory from which the webserver will serve files [./public] + * --root/--document-root= The directory from which the webserver will serve files [/path/to/icingaweb2/public] * - * --config= Path to Icinga Web 2's configuration files [/etc/icingaweb] + * --config= Path to Icinga Web 2's configuration files [/etc/icingaweb2] * * --file= Write configuration to file [stdout] * @@ -86,9 +86,9 @@ class ConfigCommand extends Command * * icingacli setup config webserver apache * - * icingacli setup config webserver apache --path /icingaweb --document-root /usr/share/icingaweb/public --config=/etc/icingaweb + * icingacli setup config webserver apache --path /icingaweb2 --document-root /usr/share/icingaweb2/public --config=/etc/icingaweb2 * - * icingacli setup config webserver apache --file /etc/apache2/conf.d/icingaweb.conf + * icingacli setup config webserver apache --file /etc/apache2/conf.d/icingaweb2.conf * * icingacli setup config webserver nginx */ From 2d69e4484684019352ce3a56e0da6acc229e1d03 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Tue, 30 Dec 2014 14:42:42 +0100 Subject: [PATCH 0133/2920] setup: Set default URL path to /icingaweb2 --- modules/setup/library/Setup/Webserver.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/setup/library/Setup/Webserver.php b/modules/setup/library/Setup/Webserver.php index 2449f9b9e..dbc55b6a2 100644 --- a/modules/setup/library/Setup/Webserver.php +++ b/modules/setup/library/Setup/Webserver.php @@ -24,7 +24,7 @@ abstract class Webserver * * @var string */ - protected $urlPath = '/icingaweb'; + protected $urlPath = '/icingaweb2'; /** * Path to Icinga Web 2's configuration files From aea7b068daf8db77ac059c201a511dc8cd77ad2b Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Tue, 30 Dec 2014 14:43:19 +0100 Subject: [PATCH 0134/2920] setup: Add --config switch to TokenCommand::showAction() refs #7906 --- .../application/clicommands/TokenCommand.php | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/modules/setup/application/clicommands/TokenCommand.php b/modules/setup/application/clicommands/TokenCommand.php index ff0229cfe..0d665cec6 100644 --- a/modules/setup/application/clicommands/TokenCommand.php +++ b/modules/setup/application/clicommands/TokenCommand.php @@ -22,11 +22,22 @@ class TokenCommand extends Command * * USAGE: * - * icingacli setup token show + * icingacli setup token show [options] + * + * OPTIONS: + * + * --config= Path to Icinga Web 2's configuration files [/etc/icingaweb2] */ public function showAction() { - $token = file_get_contents($this->app->getConfigDir() . '/setup.token'); + $configDir = $this->params->get('config', $this->app->getConfigDir()); + if (! is_string($configDir) || strlen(trim($configDir)) === 0) { + $this->fail($this->translate( + 'The argument --config expects a path to Icinga Web 2\'s configuration files' + )); + } + + $token = file_get_contents($configDir . '/setup.token'); if (! $token) { $this->fail( $this->translate('Nothing to show. Please create a new setup token using the generateToken action.') From bee3fe7027aefe0f66ff1101a24b2012cfb3c3a5 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Tue, 30 Dec 2014 14:44:17 +0100 Subject: [PATCH 0135/2920] rpm: Install bash completion for icingacli --- icingaweb2.spec | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/icingaweb2.spec b/icingaweb2.spec index 0b4813bc4..f469d3c92 100644 --- a/icingaweb2.spec +++ b/icingaweb2.spec @@ -68,11 +68,12 @@ Icinga Web 2 PHP library %package -n icingacli -Summary: Icinga CLI -Group: Applications/System -Requires: %{name}-common = %{version}-%{release} -Requires: php-Icinga = %{version}-%{release} -Requires: %{php_cli} >= 5.3.0 +Summary: Icinga CLI +Group: Applications/System +Requires: %{name}-common = %{version}-%{release} +Requires: php-Icinga = %{version}-%{release} +Requires: %{php_cli} >= 5.3.0 +%{?rhel:Requires: bash-completion} %description -n icingacli Icinga CLI @@ -151,8 +152,9 @@ Icinga Web 2 vendor library Zend %install rm -rf %{buildroot} -mkdir -p %{buildroot}/{%{basedir}/{modules,library,public},%{bindir},%{configdir},%{logdir},%{phpdir},%{wwwconfigdir}} +mkdir -p %{buildroot}/{%{basedir}/{modules,library,public},%{bindir},%{configdir},%{logdir},%{phpdir},%{wwwconfigdir},{_sysconfdir}/bash_completion.d} cp -prv application doc var %{buildroot}/%{basedir} +cp -pv etc/bash_completion.d/icingacli %{buildroot}/{_sysconfdir}/bash_completion.d cp -prv modules/{monitoring,setup} %{buildroot}/%{basedir}/modules cp -prv library/Icinga %{buildroot}/%{phpdir} cp -prv library/vendor %{buildroot}/%{basedir}/library @@ -202,6 +204,7 @@ exit 0 %files -n icingacli %defattr(-,root,root) %{basedir}/application/clicommands +{_sysconfdir}/bash_completion.d/icingacli %attr(0755,root,root) %{bindir}/icingacli From deec606a226971810e069eb9c5c197c0c7eabd2a Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Tue, 30 Dec 2014 14:48:02 +0100 Subject: [PATCH 0136/2920] rpm: Do not copy var/ to build root This directory does no longer exist. --- icingaweb2.spec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/icingaweb2.spec b/icingaweb2.spec index f469d3c92..1b5e17797 100644 --- a/icingaweb2.spec +++ b/icingaweb2.spec @@ -153,7 +153,7 @@ Icinga Web 2 vendor library Zend %install rm -rf %{buildroot} mkdir -p %{buildroot}/{%{basedir}/{modules,library,public},%{bindir},%{configdir},%{logdir},%{phpdir},%{wwwconfigdir},{_sysconfdir}/bash_completion.d} -cp -prv application doc var %{buildroot}/%{basedir} +cp -prv application doc %{buildroot}/%{basedir} cp -pv etc/bash_completion.d/icingacli %{buildroot}/{_sysconfdir}/bash_completion.d cp -prv modules/{monitoring,setup} %{buildroot}/%{basedir}/modules cp -prv library/Icinga %{buildroot}/%{phpdir} From cc68c58fe31698909fc107773a504eb1dd6b7a78 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Tue, 30 Dec 2014 14:48:47 +0100 Subject: [PATCH 0137/2920] rpm: Fix typo --- icingaweb2.spec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/icingaweb2.spec b/icingaweb2.spec index 1b5e17797..fc6f7f6e0 100644 --- a/icingaweb2.spec +++ b/icingaweb2.spec @@ -204,7 +204,7 @@ exit 0 %files -n icingacli %defattr(-,root,root) %{basedir}/application/clicommands -{_sysconfdir}/bash_completion.d/icingacli +%{_sysconfdir}/bash_completion.d/icingacli %attr(0755,root,root) %{bindir}/icingacli From 59dc5c5bc315fd385f81505ac44825072da1e3c8 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Tue, 30 Dec 2014 14:51:18 +0100 Subject: [PATCH 0138/2920] rpm: Fix {_sysconfig} usages missing the leading % --- icingaweb2.spec | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/icingaweb2.spec b/icingaweb2.spec index fc6f7f6e0..0a854047c 100644 --- a/icingaweb2.spec +++ b/icingaweb2.spec @@ -152,9 +152,9 @@ Icinga Web 2 vendor library Zend %install rm -rf %{buildroot} -mkdir -p %{buildroot}/{%{basedir}/{modules,library,public},%{bindir},%{configdir},%{logdir},%{phpdir},%{wwwconfigdir},{_sysconfdir}/bash_completion.d} +mkdir -p %{buildroot}/{%{basedir}/{modules,library,public},%{bindir},%{configdir},%{logdir},%{phpdir},%{wwwconfigdir},%{_sysconfdir}/bash_completion.d} cp -prv application doc %{buildroot}/%{basedir} -cp -pv etc/bash_completion.d/icingacli %{buildroot}/{_sysconfdir}/bash_completion.d +cp -pv etc/bash_completion.d/icingacli %{buildroot}/%{_sysconfdir}/bash_completion.d/icingacli cp -prv modules/{monitoring,setup} %{buildroot}/%{basedir}/modules cp -prv library/Icinga %{buildroot}/%{phpdir} cp -prv library/vendor %{buildroot}/%{basedir}/library From 4b6ea55cbb0993cad0ee355ebd6b60b06fe48f0d Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Tue, 30 Dec 2014 14:55:44 +0100 Subject: [PATCH 0139/2920] setup: Add --config switch to TokenCommand::createAction() refs #7906 --- .../application/clicommands/TokenCommand.php | 25 +++++++++++++------ 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/modules/setup/application/clicommands/TokenCommand.php b/modules/setup/application/clicommands/TokenCommand.php index 0d665cec6..6f6e2b08e 100644 --- a/modules/setup/application/clicommands/TokenCommand.php +++ b/modules/setup/application/clicommands/TokenCommand.php @@ -54,24 +54,35 @@ class TokenCommand extends Command * * USAGE: * - * icingacli setup token create + * icingacli setup token create [options] + * + * OPTIONS: + * + * --config= Path to Icinga Web 2's configuration files [/etc/icingaweb2] */ public function createAction() { + $configDir = $this->params->get('config', $this->app->getConfigDir()); + if (! is_string($configDir) || strlen(trim($configDir)) === 0) { + $this->fail($this->translate( + 'The argument --config expects a path to Icinga Web 2\'s configuration files' + )); + } + + $file = $configDir . '/setup.token'; + if (function_exists('openssl_random_pseudo_bytes')) { $token = bin2hex(openssl_random_pseudo_bytes(8)); } else { $token = substr(md5(mt_rand()), 16); } - $filepath = $this->app->getConfigDir() . '/setup.token'; - - if (false === file_put_contents($filepath, $token)) { - $this->fail(sprintf($this->translate('Cannot write setup token "%s" to disk.'), $filepath)); + if (false === file_put_contents($file, $token)) { + $this->fail(sprintf($this->translate('Cannot write setup token "%s" to disk.'), $file)); } - if (false === chmod($filepath, 0660)) { - $this->fail(sprintf($this->translate('Cannot change access mode of "%s" to %o.'), $filepath, 0660)); + if (! chmod($file, 0660)) { + $this->fail(sprintf($this->translate('Cannot change access mode of "%s" to %o.'), $file, 0660)); } printf($this->translate("The newly generated setup token is: %s\n"), $token); From 861252b1e7ec65ac9b96ba2ac3d4e8f550102ec3 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Tue, 30 Dec 2014 14:59:23 +0100 Subject: [PATCH 0140/2920] setup: Rename createDirectory to diretory 'icingacli setup config directory' does not suffer from camel case notation and explains pretty much what it does. --- .../setup/application/clicommands/ConfigCommand.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/modules/setup/application/clicommands/ConfigCommand.php b/modules/setup/application/clicommands/ConfigCommand.php index d26dfdd80..a2d98b0fe 100644 --- a/modules/setup/application/clicommands/ConfigCommand.php +++ b/modules/setup/application/clicommands/ConfigCommand.php @@ -12,14 +12,14 @@ use Icinga\Module\Setup\Webserver; class ConfigCommand extends Command { /** - * Create the configuration directory + * Create Icinga Web 2's configuration directory * * This command creates the configuration directory for Icinga Web 2. The `group' argument * is mandatory and should be the groupname of the user your web server is running as. * * USAGE: * - * icingacli setup config createDirectory [options] + * icingacli setup config directory [options] * * OPTIONS: * @@ -28,11 +28,11 @@ class ConfigCommand extends Command * * EXAMPLES: * - * icingacli setup config createDirectory apache - * icingacli setup config createDirectory apache --mode 2775 - * icingacli setup config createDirectory apache --path /some/path + * icingacli setup config directory apache + * icingacli setup config directory apache --mode 2775 + * icingacli setup config directory apache --path /some/path */ - public function createDirectoryAction() + public function directoryAction() { $group = $this->params->getStandalone(); if ($group === null) { From bad7aad05e962ca9e8a8bd7da3f7a375f7a2f323 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Tue, 30 Dec 2014 15:22:53 +0100 Subject: [PATCH 0141/2920] cli/setup: Do not use the webserver user's group but 'icingaweb2' --- .../application/clicommands/ConfigCommand.php | 36 +++++++++---------- 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/modules/setup/application/clicommands/ConfigCommand.php b/modules/setup/application/clicommands/ConfigCommand.php index a2d98b0fe..562c1b30d 100644 --- a/modules/setup/application/clicommands/ConfigCommand.php +++ b/modules/setup/application/clicommands/ConfigCommand.php @@ -14,30 +14,31 @@ class ConfigCommand extends Command /** * Create Icinga Web 2's configuration directory * - * This command creates the configuration directory for Icinga Web 2. The `group' argument - * is mandatory and should be the groupname of the user your web server is running as. - * * USAGE: * - * icingacli setup config directory [options] + * icingacli setup config directory [options] * * OPTIONS: * - * --mode The access mode to use. Default is: 2770 - * --path The path to the configuration directory. If omitted the default is used. + * --mode= The access mode to use [2770] + * + * --path= Path to Icinga Web 2's configuration files [/etc/icingaweb2] + * + * --group= Owner group for the configuration directory [icingaweb2] * * EXAMPLES: * - * icingacli setup config directory apache - * icingacli setup config directory apache --mode 2775 - * icingacli setup config directory apache --path /some/path + * icingacli setup config directory + * + * icingacli setup config directory --mode 2775 --config /opt/icingaweb2/etc */ public function directoryAction() { - $group = $this->params->getStandalone(); - if ($group === null) { - $this->fail($this->translate('The `group\' argument is mandatory.')); - return false; + $group = trim($this->params->get('group', 'icingaweb2')); + if (strlen($group) === 0) { + $this->fail($this->translate( + 'The argument --group expects a owner group for the configuration directory' + )); } $path = $this->params->get('path', $this->app->getConfigDir()); @@ -81,16 +82,15 @@ class ConfigCommand extends Command * * --file= Write configuration to file [stdout] * - * * EXAMPLES: * - * icingacli setup config webserver apache + * icingacli setup config webserver apache * - * icingacli setup config webserver apache --path /icingaweb2 --document-root /usr/share/icingaweb2/public --config=/etc/icingaweb2 + * icingacli setup config webserver apache --path /icingaweb2 --document-root /usr/share/icingaweb2/public --config=/etc/icingaweb2 * - * icingacli setup config webserver apache --file /etc/apache2/conf.d/icingaweb2.conf + * icingacli setup config webserver apache --file /etc/apache2/conf.d/icingaweb2.conf * - * icingacli setup config webserver nginx + * icingacli setup config webserver nginx */ public function webserverAction() { From 082cdd6dd25ccbf1a00378c428528b9e62b72c65 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Tue, 30 Dec 2014 15:24:31 +0100 Subject: [PATCH 0142/2920] cli/setup: Rename --path switch to --config for the directory action All other actions use --config too. --- .../application/clicommands/ConfigCommand.php | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/modules/setup/application/clicommands/ConfigCommand.php b/modules/setup/application/clicommands/ConfigCommand.php index 562c1b30d..a1cf3c19a 100644 --- a/modules/setup/application/clicommands/ConfigCommand.php +++ b/modules/setup/application/clicommands/ConfigCommand.php @@ -22,7 +22,7 @@ class ConfigCommand extends Command * * --mode= The access mode to use [2770] * - * --path= Path to Icinga Web 2's configuration files [/etc/icingaweb2] + * --config= Path to Icinga Web 2's configuration files [/etc/icingaweb2] * * --group= Owner group for the configuration directory [icingaweb2] * @@ -41,28 +41,28 @@ class ConfigCommand extends Command )); } - $path = $this->params->get('path', $this->app->getConfigDir()); - if (file_exists($path)) { - printf($this->translate("Configuration directory already exists at: %s\n"), $path); + $config = $this->params->get('config', $this->app->getConfigDir()); + if (file_exists($config)) { + printf($this->translate("Configuration directory already exists at: %s\n"), $config); return true; } $mode = octdec($this->params->get('mode', '2770')); - if (false === mkdir($path)) { - $this->fail(sprintf($this->translate('Unable to create path: %s'), $path)); + if (false === mkdir($config)) { + $this->fail(sprintf($this->translate('Unable to create path: %s'), $config)); return false; } $old = umask(0); // Prevent $mode from being mangled by the system's umask ($old) - chmod($path, $mode); + chmod($config, $mode); umask($old); - if (chgrp($path, $group) === false) { - $this->fail(sprintf($this->translate('Unable to change the group of "%s" to "%s".'), $path, $group)); + if (chgrp($config, $group) === false) { + $this->fail(sprintf($this->translate('Unable to change the group of "%s" to "%s".'), $config, $group)); return false; } - printf($this->translate("Successfully created configuration directory at: %s\n"), $path); + printf($this->translate("Successfully created configuration directory at: %s\n"), $config); } /** From f84a9a6529467de33cef675d1c7336d207460113 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Tue, 30 Dec 2014 15:33:01 +0100 Subject: [PATCH 0143/2920] cli/setup: Do not use umask(0) chmod is not affected in any way by the umask. --- modules/setup/application/clicommands/ConfigCommand.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/modules/setup/application/clicommands/ConfigCommand.php b/modules/setup/application/clicommands/ConfigCommand.php index a1cf3c19a..d3b2900bc 100644 --- a/modules/setup/application/clicommands/ConfigCommand.php +++ b/modules/setup/application/clicommands/ConfigCommand.php @@ -53,9 +53,7 @@ class ConfigCommand extends Command return false; } - $old = umask(0); // Prevent $mode from being mangled by the system's umask ($old) chmod($config, $mode); - umask($old); if (chgrp($config, $group) === false) { $this->fail(sprintf($this->translate('Unable to change the group of "%s" to "%s".'), $config, $group)); From fbe252063bfa5b60bcdde2e05e496d5ff4743110 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Tue, 30 Dec 2014 15:39:03 +0100 Subject: [PATCH 0144/2920] IniWriter: Do not use umask(0) chmod is not affected in any way by the umask. --- library/Icinga/File/Ini/IniWriter.php | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/library/Icinga/File/Ini/IniWriter.php b/library/Icinga/File/Ini/IniWriter.php index 94a20faa5..28ca53ff0 100644 --- a/library/Icinga/File/Ini/IniWriter.php +++ b/library/Icinga/File/Ini/IniWriter.php @@ -90,11 +90,9 @@ class IniWriter extends Zend_Config_Writer_FileAbstract if ($setMode) { $mode = isset($this->options['filemode']) ? $this->options['filemode'] : static::$fileMode; - $old = umask(0); // Make sure that the mode we're going to set doesn't get mangled if (is_int($mode) && false === @chmod($filePath, $mode)) { throw new Zend_Config_Exception(sprintf('Failed to set file mode "%o" on file "%s"', $mode, $filePath)); } - umask($old); } } @@ -234,7 +232,7 @@ class IniWriter extends Zend_Config_Writer_FileAbstract /** * Getter for filename - * + * * @return string */ public function getFilename() From d3dcf152fb6e06837b9ce0f77d4749d9bf5dfb30 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Tue, 30 Dec 2014 15:40:06 +0100 Subject: [PATCH 0145/2920] setup: Do not use umask(0) chmod is not affected in any way by the umask. --- modules/setup/library/Setup/Utils/MakeDirStep.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/modules/setup/library/Setup/Utils/MakeDirStep.php b/modules/setup/library/Setup/Utils/MakeDirStep.php index d15c7db6a..b758ccd79 100644 --- a/modules/setup/library/Setup/Utils/MakeDirStep.php +++ b/modules/setup/library/Setup/Utils/MakeDirStep.php @@ -35,9 +35,7 @@ class MakeDirStep extends Step $success = false; } else { $this->errors[$path] = null; - $old = umask(0); chmod($path, $this->dirmode); - umask($old); } } } From 672500029cd304aeb4ccb40d1432f71c7a86b7f6 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Tue, 30 Dec 2014 15:46:22 +0100 Subject: [PATCH 0146/2920] cli/setup: Add sanity check for the --mode switch when creating the config directory --- .../application/clicommands/ConfigCommand.php | 37 +++++++++++++------ 1 file changed, 25 insertions(+), 12 deletions(-) diff --git a/modules/setup/application/clicommands/ConfigCommand.php b/modules/setup/application/clicommands/ConfigCommand.php index d3b2900bc..4421c7600 100644 --- a/modules/setup/application/clicommands/ConfigCommand.php +++ b/modules/setup/application/clicommands/ConfigCommand.php @@ -20,10 +20,10 @@ class ConfigCommand extends Command * * OPTIONS: * - * --mode= The access mode to use [2770] - * * --config= Path to Icinga Web 2's configuration files [/etc/icingaweb2] * + * --mode= The access mode to use [2770] + * * --group= Owner group for the configuration directory [icingaweb2] * * EXAMPLES: @@ -34,6 +34,13 @@ class ConfigCommand extends Command */ public function directoryAction() { + $configDir = trim($this->params->get('config', $this->app->getConfigDir())); + if (strlen($configDir) === 0) { + $this->fail($this->translate( + 'The argument --config expects a path to Icinga Web 2\'s configuration files' + )); + } + $group = trim($this->params->get('group', 'icingaweb2')); if (strlen($group) === 0) { $this->fail($this->translate( @@ -41,26 +48,32 @@ class ConfigCommand extends Command )); } - $config = $this->params->get('config', $this->app->getConfigDir()); - if (file_exists($config)) { - printf($this->translate("Configuration directory already exists at: %s\n"), $config); + $mode = trim($this->params->get('mode', '2770')); + if (strlen($mode) === 0) { + $this->fail($this->translate( + 'The argument --mode expects an access mode for the configuration directory' + )); + } + + if (file_exists($configDir)) { + printf($this->translate("Configuration directory already exists at: %s\n"), $configDir); return true; } - $mode = octdec($this->params->get('mode', '2770')); - if (false === mkdir($config)) { - $this->fail(sprintf($this->translate('Unable to create path: %s'), $config)); + $mode = octdec($mode); + if (false === mkdir($configDir)) { + $this->fail(sprintf($this->translate('Unable to create path: %s'), $configDir)); return false; } - chmod($config, $mode); + chmod($configDir, $mode); - if (chgrp($config, $group) === false) { - $this->fail(sprintf($this->translate('Unable to change the group of "%s" to "%s".'), $config, $group)); + if (chgrp($configDir, $group) === false) { + $this->fail(sprintf($this->translate('Unable to change the group of "%s" to "%s".'), $configDir, $group)); return false; } - printf($this->translate("Successfully created configuration directory at: %s\n"), $config); + printf($this->translate("Successfully created configuration directory at: %s\n"), $configDir); } /** From 9c40372b619987ae11d4b3a2f7bf260e185443fd Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Tue, 30 Dec 2014 15:49:11 +0100 Subject: [PATCH 0147/2920] cli/setup: Do not translate \n --- .../setup/application/clicommands/ConfigCommand.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/modules/setup/application/clicommands/ConfigCommand.php b/modules/setup/application/clicommands/ConfigCommand.php index 4421c7600..27daa8b89 100644 --- a/modules/setup/application/clicommands/ConfigCommand.php +++ b/modules/setup/application/clicommands/ConfigCommand.php @@ -41,6 +41,11 @@ class ConfigCommand extends Command )); } + if (file_exists($configDir)) { + printf($this->translate('Configuration directory already exists at: %s') . PHP_EOL, $configDir); + return true; + } + $group = trim($this->params->get('group', 'icingaweb2')); if (strlen($group) === 0) { $this->fail($this->translate( @@ -55,11 +60,6 @@ class ConfigCommand extends Command )); } - if (file_exists($configDir)) { - printf($this->translate("Configuration directory already exists at: %s\n"), $configDir); - return true; - } - $mode = octdec($mode); if (false === mkdir($configDir)) { $this->fail(sprintf($this->translate('Unable to create path: %s'), $configDir)); From 9de1b20d3cced9308f3376c26122ab7ca7b349f7 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Tue, 30 Dec 2014 15:51:00 +0100 Subject: [PATCH 0148/2920] cli/setup: Issue an error if chmod fails when setting up the configuration directory --- modules/setup/application/clicommands/ConfigCommand.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/modules/setup/application/clicommands/ConfigCommand.php b/modules/setup/application/clicommands/ConfigCommand.php index 27daa8b89..5c7ad6c23 100644 --- a/modules/setup/application/clicommands/ConfigCommand.php +++ b/modules/setup/application/clicommands/ConfigCommand.php @@ -60,13 +60,16 @@ class ConfigCommand extends Command )); } - $mode = octdec($mode); if (false === mkdir($configDir)) { $this->fail(sprintf($this->translate('Unable to create path: %s'), $configDir)); return false; } - chmod($configDir, $mode); + if (! chmod($configDir, octdec($mode))) { + $this->fail($this->translate( + 'Unable to change the mode of the configuration directory' + )); + } if (chgrp($configDir, $group) === false) { $this->fail(sprintf($this->translate('Unable to change the group of "%s" to "%s".'), $configDir, $group)); From f9ca0296a4d9d6932b867dcd7eaca2ac9e4eb237 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Tue, 30 Dec 2014 15:54:07 +0100 Subject: [PATCH 0149/2920] cli/setup: Do not return false; after $this->fail() $this-fail() throws an exception. --- .../application/clicommands/ConfigCommand.php | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/modules/setup/application/clicommands/ConfigCommand.php b/modules/setup/application/clicommands/ConfigCommand.php index 5c7ad6c23..1999764c9 100644 --- a/modules/setup/application/clicommands/ConfigCommand.php +++ b/modules/setup/application/clicommands/ConfigCommand.php @@ -60,20 +60,23 @@ class ConfigCommand extends Command )); } - if (false === mkdir($configDir)) { - $this->fail(sprintf($this->translate('Unable to create path: %s'), $configDir)); - return false; + if (! mkdir($configDir)) { + $this->fail(sprintf($this->translate('Can\'t create configuration directory %s'), $configDir)); } if (! chmod($configDir, octdec($mode))) { - $this->fail($this->translate( - 'Unable to change the mode of the configuration directory' + $this->fail(sprintf( + $this->translate('Can\'t change the mode of the configuration directory to %s'), + $mode )); } - if (chgrp($configDir, $group) === false) { - $this->fail(sprintf($this->translate('Unable to change the group of "%s" to "%s".'), $configDir, $group)); - return false; + if (! chgrp($configDir, $group)) { + $this->fail(sprintf( + $this->translate('Can\'t change the to change the group of %s to %s'), + $configDir, + $group + )); } printf($this->translate("Successfully created configuration directory at: %s\n"), $configDir); From 90fb44122bff415d02aa4e99505a41b666056c69 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Tue, 30 Dec 2014 15:55:14 +0100 Subject: [PATCH 0150/2920] cli/setup: Do not translate \n again --- modules/setup/application/clicommands/ConfigCommand.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/setup/application/clicommands/ConfigCommand.php b/modules/setup/application/clicommands/ConfigCommand.php index 1999764c9..282590872 100644 --- a/modules/setup/application/clicommands/ConfigCommand.php +++ b/modules/setup/application/clicommands/ConfigCommand.php @@ -79,7 +79,7 @@ class ConfigCommand extends Command )); } - printf($this->translate("Successfully created configuration directory at: %s\n"), $configDir); + printf($this->translate('Successfully created configuration directory %s') . PHP_EOL, $configDir); } /** From 865b5c126ad03e0f117e3517d828178af7cbb32c Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Tue, 30 Dec 2014 15:56:42 +0100 Subject: [PATCH 0151/2920] cli/setup: Do not exit setup config directory when the directory already exists mkdir may succeed but chmod or chgrp may fail. The next time the command is called it will ll exit before trying to chmod or chgrp again because the directory already exists. --- modules/setup/application/clicommands/ConfigCommand.php | 5 ----- 1 file changed, 5 deletions(-) diff --git a/modules/setup/application/clicommands/ConfigCommand.php b/modules/setup/application/clicommands/ConfigCommand.php index 282590872..6598d3f28 100644 --- a/modules/setup/application/clicommands/ConfigCommand.php +++ b/modules/setup/application/clicommands/ConfigCommand.php @@ -41,11 +41,6 @@ class ConfigCommand extends Command )); } - if (file_exists($configDir)) { - printf($this->translate('Configuration directory already exists at: %s') . PHP_EOL, $configDir); - return true; - } - $group = trim($this->params->get('group', 'icingaweb2')); if (strlen($group) === 0) { $this->fail($this->translate( From 9f545535a0ad9d46214cb90326d3f52db5f44ab4 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Tue, 30 Dec 2014 16:03:05 +0100 Subject: [PATCH 0152/2920] cli/setup: Issue nice error messages when creating the config directory fails --- .../application/clicommands/ConfigCommand.php | 29 ++++++++++++------- 1 file changed, 19 insertions(+), 10 deletions(-) diff --git a/modules/setup/application/clicommands/ConfigCommand.php b/modules/setup/application/clicommands/ConfigCommand.php index 6598d3f28..d4d60e8e2 100644 --- a/modules/setup/application/clicommands/ConfigCommand.php +++ b/modules/setup/application/clicommands/ConfigCommand.php @@ -55,22 +55,31 @@ class ConfigCommand extends Command )); } - if (! mkdir($configDir)) { - $this->fail(sprintf($this->translate('Can\'t create configuration directory %s'), $configDir)); - } - - if (! chmod($configDir, octdec($mode))) { + if (! file_exists($configDir) && ! @mkdir($configDir)) { + $e = error_get_last(); $this->fail(sprintf( - $this->translate('Can\'t change the mode of the configuration directory to %s'), - $mode + $this->translate('Can\'t create configuration directory %s: %s'), + $configDir, + $e['message'] )); } - if (! chgrp($configDir, $group)) { + if (! @chmod($configDir, octdec($mode))) { + $e = error_get_last(); $this->fail(sprintf( - $this->translate('Can\'t change the to change the group of %s to %s'), + $this->translate('Can\'t change the mode of the configuration directory to %s: %s'), + $mode, + $e['message'] + )); + } + + if (! @chgrp($configDir, $group)) { + $e = error_get_last(); + $this->fail(sprintf( + $this->translate('Can\'t change the group of %s to %s: %s'), $configDir, - $group + $group, + $e['message'] )); } From e47eb73499880959564e05f45cb94c45bd4181b9 Mon Sep 17 00:00:00 2001 From: Matthias Jentsch Date: Tue, 30 Dec 2014 13:53:46 +0100 Subject: [PATCH 0153/2920] Improve visibility of focus Display navigation focus in a visible color and display focus outline in regular site body more prominently. fixes #6164 --- public/css/icinga/menu.less | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/public/css/icinga/menu.less b/public/css/icinga/menu.less index c8ab698a5..0f3f2691e 100644 --- a/public/css/icinga/menu.less +++ b/public/css/icinga/menu.less @@ -62,15 +62,6 @@ color: @colorPetrol; } -#menu > ul > li.active li a:focus { - color: @colorTextDefault; -} - -#menu > ul > li > a:focus { - color: @colorTextDefault; - text-shadow: none; -} - #menu > ul > li.active li a:hover { text-decoration: underline; } @@ -264,3 +255,16 @@ html.ie8 #menu input.search { input:focus { outline: none; } +/* Make focus outline properly visible */ +a:focus { + outline: dotted black 1px; +} + +/* Displaying the outline in the navigation is not possible because of the messed up link borders, + color those links instead. */ +#menu a:focus, +#menu > ul > li > a:focus, +#menu .active ul li a:focus { + color: #21b5ad; + outline: none; +} From b5747797b785de7a6349f7fbe338469703bd549d Mon Sep 17 00:00:00 2001 From: Matthias Jentsch Date: Tue, 30 Dec 2014 16:31:37 +0100 Subject: [PATCH 0154/2920] Fix perfdata output Display all perfdata key-value pairs in a formatted table, add padding to table css improve piechart label. --- .../application/views/helpers/Perfdata.php | 55 +++++++++--------- .../library/Monitoring/Plugin/Perfdata.php | 58 +++++++++++++++++-- public/css/icinga/main-content.less | 1 + 3 files changed, 81 insertions(+), 33 deletions(-) diff --git a/modules/monitoring/application/views/helpers/Perfdata.php b/modules/monitoring/application/views/helpers/Perfdata.php index 47c34d156..dd451bc1a 100644 --- a/modules/monitoring/application/views/helpers/Perfdata.php +++ b/modules/monitoring/application/views/helpers/Perfdata.php @@ -24,21 +24,36 @@ class Zend_View_Helper_Perfdata extends Zend_View_Helper_Abstract $pieChartData = PerfdataSet::fromString($perfdataStr)->asArray(); $result = ''; - $table = array(); + $table = array( + '' . implode( + '', + array('', t('Label'), t('Value'), t('Min'), t('Max'), t('Warning'), t('Critical')) + ) . '' + ); foreach ($pieChartData as $perfdata) { - if ($perfdata->isVisualizable()) { - $pieChart = $perfdata->asInlinePie($color); - if ($compact) { - $result .= $pieChart->render(); - } else { - $table[] = '' . $pieChart->render() - . htmlspecialchars($perfdata->getLabel()) - . ' ' - . htmlspecialchars($this->formatPerfdataValue($perfdata)) . - ' '; - } + + if ($compact && $perfdata->isVisualizable()) { + $result .= $perfdata->asInlinePie($color)->render(); } else { - $table[] = (string)$perfdata; + $row = ''; + + $row .= ''; + if ($perfdata->isVisualizable()) { + $row .= $perfdata->asInlinePie($color)->render() . ' '; + } + $row .= ''; + + if (!$compact) { + foreach ($perfdata->toArray() as $value) { + if ($value === '') { + $value = '-'; + } + $row .= '' . (string)$value . ''; + } + } + + $row .= ''; + $table[] = $row; } } @@ -49,18 +64,4 @@ class Zend_View_Helper_Perfdata extends Zend_View_Helper_Abstract return $pieCharts; } } - - protected function formatPerfdataValue(Perfdata $perfdata) - { - if ($perfdata->isBytes()) { - return Format::bytes($perfdata->getValue()); - } elseif ($perfdata->isSeconds()) { - return Format::seconds($perfdata->getValue()); - } elseif ($perfdata->isPercentage()) { - return $perfdata->getValue() . '%'; - } - - return $perfdata->getValue(); - } - } diff --git a/modules/monitoring/library/Monitoring/Plugin/Perfdata.php b/modules/monitoring/library/Monitoring/Plugin/Perfdata.php index 7da4559fd..3e0237184 100644 --- a/modules/monitoring/library/Monitoring/Plugin/Perfdata.php +++ b/modules/monitoring/library/Monitoring/Plugin/Perfdata.php @@ -4,6 +4,7 @@ namespace Icinga\Module\Monitoring\Plugin; +use Icinga\Util\Format; use InvalidArgumentException; use Icinga\Exception\ProgrammingError; use Icinga\Web\Widget\Chart\InlinePie; @@ -263,7 +264,7 @@ class Perfdata */ public function __toString() { - return sprintf(strpos($this->label, ' ') === false ? '%s=%s' : "'%s'=%s", $this->label, $this->perfdataValue); + return $this->formatLabel(); } /** @@ -294,11 +295,9 @@ class Perfdata $this->minValue = self::convert($parts[3], $this->unit); } case 3: - // TODO(#6123): Tresholds have the same UOM and need to be converted as well! - $this->criticalThreshold = trim($parts[2]) ? trim($parts[2]) : null; + $this->criticalThreshold = trim($parts[2]) ? self::convert(trim($parts[2]), $this->unit) : null; case 2: - // TODO(#6123): Tresholds have the same UOM and need to be converted as well! - $this->warningThreshold = trim($parts[1]) ? trim($parts[1]) : null; + $this->warningThreshold = trim($parts[1]) ? self::convert(trim($parts[1]), $this->unit) : null; } } @@ -370,7 +369,7 @@ class Perfdata } $data = $this->calculatePieChartData($color); - $pieChart = new InlinePie($data, $this->getLabel() . ' ' . number_format($this->getPercentage(), 2) . '%'); + $pieChart = new InlinePie($data, $this); $pieChart->setSparklineClass('sparkline-perfdata'); if (Zend_Controller_Front::getInstance()->getRequest()->isXmlHttpRequest()) { @@ -378,4 +377,51 @@ class Perfdata } return $pieChart; } + + /** + * Format the given value depending on the currently used unit + */ + protected function format($value) + { + if ($this->isPercentage()) { + return (string)$value . '%'; + } + if ($this->isBytes()) { + return Format::bytes($value); + } + if ($this->isSeconds()) { + return Format::seconds($value); + } + return number_format($value, 2); + } + + /** + * Format the title string that represents this perfdata set + * + * @param bool $html + * + * @return stringS + */ + public function formatLabel($html = false) + { + return sprintf( + $html ? t('%s %s (%s%%)') : t('%s %s (%s%%)'), + htmlspecialchars($this->getLabel()), + $this->format($this->value), + number_format($this->getPercentage(), 2) + ); + } + + public function toArray() + { + $parts = array( + $this->getLabel(), + 'value' => $this->format($this->getvalue()), + 'min' => isset($this->minValue) && !$this->isPercentage() ? $this->format($this->minValue) : '', + 'max' => isset($this->maxValue) && !$this->isPercentage() ? $this->format($this->maxValue) : '', + 'warn' => isset($this->warningThreshold) ? $this->format($this->warningThreshold) : '', + 'crit' => isset($this->criticalThreshold) ? $this->format($this->criticalThreshold) : '' + ); + return $parts; + } } diff --git a/public/css/icinga/main-content.less b/public/css/icinga/main-content.less index 6972e95dc..5b142184d 100644 --- a/public/css/icinga/main-content.less +++ b/public/css/icinga/main-content.less @@ -154,6 +154,7 @@ table.perfdata th { table.perfdata td { white-space: nowrap; + padding-right: 0.5em; } table.objectlist { From 80730e0bb2ed6c0b804734d0bc8b7dd67c4cfc98 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Tue, 30 Dec 2014 18:49:47 +0100 Subject: [PATCH 0155/2920] cli/setup: Remove is_string checks for switches of the webserver generation --- .../application/clicommands/ConfigCommand.php | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/modules/setup/application/clicommands/ConfigCommand.php b/modules/setup/application/clicommands/ConfigCommand.php index d4d60e8e2..e63e770b8 100644 --- a/modules/setup/application/clicommands/ConfigCommand.php +++ b/modules/setup/application/clicommands/ConfigCommand.php @@ -123,18 +123,20 @@ class ConfigCommand extends Command } catch (ProgrammingError $e) { $this->fail($this->translate('Unknown type') . ': ' . $type); } - $urlPath = $this->params->get('path', $webserver->getUrlPath()); - if (! is_string($urlPath) || strlen(trim($urlPath)) === 0) { + $urlPath = trim($this->params->get('path', $webserver->getUrlPath())); + if (strlen($urlPath) === 0) { $this->fail($this->translate('The argument --path expects a URL path')); } - $documentRoot = $this->params->get('root', $this->params->get('document-root', $webserver->getDocumentRoot())); - if (! is_string($documentRoot) || strlen(trim($documentRoot)) === 0) { + $documentRoot = trim( + $this->params->get('root', $this->params->get('document-root', $webserver->getDocumentRoot())) + ); + if (strlen($documentRoot) === 0) { $this->fail($this->translate( 'The argument --root/--document-root expects a directory from which the webserver will serve files' )); } - $configDir = $this->params->get('config', $webserver->getConfigDir()); - if (! is_string($configDir) || strlen(trim($configDir)) === 0) { + $configDir = trim($this->params->get('config', $webserver->getConfigDir())); + if (strlen($configDir) === 0) { $this->fail($this->translate( 'The argument --config expects a path to Icinga Web 2\'s configuration files' )); From ec38c0c817e8dae2389c34765f745390e74a3e32 Mon Sep 17 00:00:00 2001 From: Matthias Jentsch Date: Mon, 5 Jan 2015 11:30:51 +0100 Subject: [PATCH 0156/2920] Fix pies in multi views --- .../monitoring/application/controllers/HostsController.php | 4 +++- .../application/controllers/ServicesController.php | 5 ++--- .../monitoring/application/views/scripts/hosts/show.phtml | 2 +- .../monitoring/application/views/scripts/services/show.phtml | 4 ++-- 4 files changed, 8 insertions(+), 7 deletions(-) diff --git a/modules/monitoring/application/controllers/HostsController.php b/modules/monitoring/application/controllers/HostsController.php index 09957a4a0..869be92d8 100644 --- a/modules/monitoring/application/controllers/HostsController.php +++ b/modules/monitoring/application/controllers/HostsController.php @@ -134,7 +134,9 @@ class Monitoring_HostsController extends Controller { $chart = new InlinePie(array_values($states), $title, $colors); return $chart - ->setTitle($title); + ->setSize(75) + ->setTitle('') + ->setSparklineClass('sparkline-multi'); } /** diff --git a/modules/monitoring/application/controllers/ServicesController.php b/modules/monitoring/application/controllers/ServicesController.php index 4d08622c2..dc7feb2da 100644 --- a/modules/monitoring/application/controllers/ServicesController.php +++ b/modules/monitoring/application/controllers/ServicesController.php @@ -162,9 +162,8 @@ class Monitoring_ServicesController extends Controller { $chart = new InlinePie(array_values($states), $title, $colors); return $chart - // ->setLabel(array_map('strtoupper', array_keys($states))) - ->setSize(50) - ->setTitle($title) + ->setSize(75) + ->setTitle('') ->setSparklineClass('sparkline-multi'); } diff --git a/modules/monitoring/application/views/scripts/hosts/show.phtml b/modules/monitoring/application/views/scripts/hosts/show.phtml index 739069416..3c7dafbc5 100644 --- a/modules/monitoring/application/views/scripts/hosts/show.phtml +++ b/modules/monitoring/application/views/scripts/hosts/show.phtml @@ -10,7 +10,7 @@ translatePlural('Host (%u)', 'Hosts (%u)', $hostCount), $hostCount) ?>
    - hostStatesPieChart ?> +  hostStatesPieChart ?>
    $count) { diff --git a/modules/monitoring/application/views/scripts/services/show.phtml b/modules/monitoring/application/views/scripts/services/show.phtml index 65049b792..93e4ae84a 100644 --- a/modules/monitoring/application/views/scripts/services/show.phtml +++ b/modules/monitoring/application/views/scripts/services/show.phtml @@ -12,7 +12,7 @@ translatePlural('Service (%u)', 'Services (%u)', $serviceCount), $serviceCount) ?>
    - serviceStatesPieChart ?> +  serviceStatesPieChart ?>
    $count) { @@ -27,7 +27,7 @@ translatePlural('Host (%u)', 'Hosts (%u)', $hostCount), $hostCount) ?>
    - hostStatesPieChart ?> +  hostStatesPieChart ?>
    $count) { From be91fce75f4234d38b1db02cd8a973708a20a4cf Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Mon, 12 Jan 2015 16:19:14 +0100 Subject: [PATCH 0157/2920] rpm: Install schema files to /usr/share/doc/icingaweb2 refs #4075 --- icingaweb2.spec | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/icingaweb2.spec b/icingaweb2.spec index 0a854047c..f5dbfbd53 100644 --- a/icingaweb2.spec +++ b/icingaweb2.spec @@ -152,7 +152,7 @@ Icinga Web 2 vendor library Zend %install rm -rf %{buildroot} -mkdir -p %{buildroot}/{%{basedir}/{modules,library,public},%{bindir},%{configdir},%{logdir},%{phpdir},%{wwwconfigdir},%{_sysconfdir}/bash_completion.d} +mkdir -p %{buildroot}/{%{basedir}/{modules,library,public},%{bindir},%{configdir},%{logdir},%{phpdir},%{wwwconfigdir},%{_sysconfdir}/bash_completion.d,%{_datadir}/doc/%{name}} cp -prv application doc %{buildroot}/%{basedir} cp -pv etc/bash_completion.d/icingacli %{buildroot}/%{_sysconfdir}/bash_completion.d/icingacli cp -prv modules/{monitoring,setup} %{buildroot}/%{basedir}/modules @@ -162,6 +162,7 @@ cp -prv public/{css,img,js,error_norewrite.html} %{buildroot}/%{basedir}/public cp -pv packages/files/apache/icingaweb2.conf %{buildroot}/%{wwwconfigdir}/icingaweb2.conf cp -pv packages/files/bin/icingacli %{buildroot}/%{bindir} cp -pv packages/files/public/index.php %{buildroot}/%{basedir}/public +cp -prv etc/schema %{buildroot}/%{_datadir}/doc/%{name} %pre getent group icingacmd >/dev/null || groupadd -r icingacmd @@ -183,6 +184,8 @@ rm -rf %{buildroot} %{basedir}/public %{wwwconfigdir}/icingaweb2.conf %attr(2775,root,%{icingawebgroup}) %dir %{logdir} +%{_datadir}/doc/%{name} +%docdir %{_datadir}/doc/%{name} %pre common From e842abf80fc78c7f229ac1b3d6314a92d9d27cd4 Mon Sep 17 00:00:00 2001 From: Michael Friedrich Date: Tue, 13 Jan 2015 08:59:36 +0100 Subject: [PATCH 0158/2920] spec: Add %revision macro for snapshot builds fixes #8193 --- icingaweb2.spec | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/icingaweb2.spec b/icingaweb2.spec index f5dbfbd53..b4d120923 100644 --- a/icingaweb2.spec +++ b/icingaweb2.spec @@ -1,6 +1,8 @@ +%define revision 1.beta2 + Name: icingaweb2 Version: 2.0.0 -Release: 1.beta2%{?dist} +Release: %{revision}%{?dist} Summary: Icinga Web 2 Group: Applications/System License: GPL From 5e2594d250c5c43403b08e8a8b1c1572b70cf1d9 Mon Sep 17 00:00:00 2001 From: Matthias Jentsch Date: Tue, 13 Jan 2015 10:59:33 +0100 Subject: [PATCH 0159/2920] Parse perfdata thresholds provisionary Use a heuristic to determine whether thresholds should be inverted, to support plugins with non-standard perfdata output while still being able to parse standard-compliant perfdata input. --- .../application/views/helpers/Perfdata.php | 4 +- .../library/Monitoring/Plugin/Perfdata.php | 60 ++++++++++++++----- 2 files changed, 47 insertions(+), 17 deletions(-) diff --git a/modules/monitoring/application/views/helpers/Perfdata.php b/modules/monitoring/application/views/helpers/Perfdata.php index dd451bc1a..4c2bee89a 100644 --- a/modules/monitoring/application/views/helpers/Perfdata.php +++ b/modules/monitoring/application/views/helpers/Perfdata.php @@ -8,7 +8,7 @@ use Icinga\Module\Monitoring\Plugin\Perfdata; use Icinga\Module\Monitoring\Plugin\PerfdataSet; class Zend_View_Helper_Perfdata extends Zend_View_Helper_Abstract -{ +{# /** * Display the given perfdata string to the user @@ -19,7 +19,7 @@ class Zend_View_Helper_Perfdata extends Zend_View_Helper_Abstract * * @return string */ - public function perfdata($perfdataStr, $compact = false, $color = Perfdata::PERFDATA_DEFAULT) + public function perfdata($perfdataStr, $compact = false, $color = Perfdata::PERFDATA_OK) { $pieChartData = PerfdataSet::fromString($perfdataStr)->asArray(); diff --git a/modules/monitoring/library/Monitoring/Plugin/Perfdata.php b/modules/monitoring/library/Monitoring/Plugin/Perfdata.php index 3e0237184..f51801192 100644 --- a/modules/monitoring/library/Monitoring/Plugin/Perfdata.php +++ b/modules/monitoring/library/Monitoring/Plugin/Perfdata.php @@ -12,8 +12,9 @@ use Zend_Controller_Front; class Perfdata { - const PERFDATA_DEFAULT = 'green'; - const PERFDATA_RED = 'red'; + const PERFDATA_OK = 'ok'; + const PERFDATA_WARNING = 'warning'; + const PERFDATA_CRITICAL = 'critical'; /** * The performance data value being parsed @@ -60,6 +61,8 @@ class Perfdata /** * The WARNING threshold * + * TODO: Should be parsed Range-Object instead of string + * * @var string */ protected $warningThreshold; @@ -67,6 +70,8 @@ class Perfdata /** * The CRITICAL threshold * + * TODO: Should be parsed Range-Object instead of string + * * @var string */ protected $criticalThreshold; @@ -240,7 +245,7 @@ class Perfdata /** * Return the minimum value or null if it is not available * - * @return null|float + * @return null|string */ public function getMinimumValue() { @@ -295,9 +300,9 @@ class Perfdata $this->minValue = self::convert($parts[3], $this->unit); } case 3: - $this->criticalThreshold = trim($parts[2]) ? self::convert(trim($parts[2]), $this->unit) : null; + $this->criticalThreshold = trim($parts[2]) ? trim($parts[2]) : null; case 2: - $this->warningThreshold = trim($parts[1]) ? self::convert(trim($parts[1]), $this->unit) : null; + $this->warningThreshold = trim($parts[1]) ? trim($parts[1]) : null; } } @@ -332,7 +337,7 @@ class Perfdata } } - protected function calculatePieChartData( $color) + protected function calculatePieChartData() { $rawValue = $this->getValue(); $minValue = $this->getMinimumValue() !== null ? $this->getMinimumValue() : 0; @@ -340,36 +345,61 @@ class Perfdata $usedValue = ($rawValue - $minValue); $unusedValue = ($maxValue - $minValue) - $usedValue; + $warningThreshold = $this->convert($this->warningThreshold, $this->unit); + $criticalThreshold = $this->convert($this->criticalThreshold, $this->unit); + $gray = $unusedValue; $green = $orange = $red = 0; - switch ($color) { - case self::PERFDATA_DEFAULT: + $pieState = self::PERFDATA_OK; + if ($warningThreshold > $criticalThreshold) { + // inverted threshold parsing OK > warning > critical + if (isset($warningThreshold) && $this->value <= $warningThreshold) { + $pieState = self::PERFDATA_WARNING; + } + if (isset($criticalThreshold) && $this->value <= $criticalThreshold) { + $pieState = self::PERFDATA_CRITICAL; + } + + } else { + // TODO: Use standard perfdata range format to decide the state #8194 + + // regular threshold parsing OK < warning < critical + if (isset($warningThreshold) && $rawValue > $warningThreshold) { + $pieState = self::PERFDATA_WARNING; + } + if (isset($criticalThreshold) && $rawValue > $criticalThreshold) { + $pieState = self::PERFDATA_CRITICAL; + } + } + + switch ($pieState) { + case self::PERFDATA_OK: $green = $usedValue; break; - case self::PERFDATA_RED: + case self::PERFDATA_CRITICAL: $red = $usedValue; break; - case self::PERFDATA_ORANGE: + case self::PERFDATA_WARNING: $orange = $usedValue; break; } - // TODO(#6122): Add proper treshold parsing. return array($green, $orange, $red, $gray); } - public function asInlinePie($color) + public function asInlinePie() { if (! $this->isVisualizable()) { throw new ProgrammingError('Cannot calculate piechart data for unvisualizable perfdata entry.'); } - $data = $this->calculatePieChartData($color); + $data = $this->calculatePieChartData(); $pieChart = new InlinePie($data, $this); + $pieChart->setColors(array('#44bb77', '#ffaa44', '#ff5566', '#ddccdd')); $pieChart->setSparklineClass('sparkline-perfdata'); if (Zend_Controller_Front::getInstance()->getRequest()->isXmlHttpRequest()) { @@ -419,8 +449,8 @@ class Perfdata 'value' => $this->format($this->getvalue()), 'min' => isset($this->minValue) && !$this->isPercentage() ? $this->format($this->minValue) : '', 'max' => isset($this->maxValue) && !$this->isPercentage() ? $this->format($this->maxValue) : '', - 'warn' => isset($this->warningThreshold) ? $this->format($this->warningThreshold) : '', - 'crit' => isset($this->criticalThreshold) ? $this->format($this->criticalThreshold) : '' + 'warn' => isset($this->warningThreshold) ? $this->format(self::convert($this->warningThreshold, $this->unit)) : '', + 'crit' => isset($this->criticalThreshold) ? $this->format(self::convert($this->criticalThreshold, $this->unit)) : '' ); return $parts; } From 3961a447693b8300e490042dc2abb020041735f7 Mon Sep 17 00:00:00 2001 From: Rene Moser Date: Mon, 12 Jan 2015 10:38:37 +0100 Subject: [PATCH 0160/2920] setup-welcome: fix cli doc * `createDirectory` does not exist, this should be `direcotory`. * For changing the group option `--group` must be used. * Default config directory is `/etc/icingaweb2` not `/etc/icingaweb`. Signed-off-by: Eric Lippmann --- .../setup/application/views/scripts/form/setup-welcome.phtml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/setup/application/views/scripts/form/setup-welcome.phtml b/modules/setup/application/views/scripts/form/setup-welcome.phtml index 9aad09dbc..8d3ba67c5 100644 --- a/modules/setup/application/views/scripts/form/setup-welcome.phtml +++ b/modules/setup/application/views/scripts/form/setup-welcome.phtml @@ -46,7 +46,7 @@ $cliPath = realpath(Icinga::app()->getApplicationDir() . '/../bin/icingacli'); ); ?>

    - setup config createDirectory ; + setup config directory --group ; setup token create;

    From e2667dfb63a40d360ebb1185a8aa7d2f97808f3b Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Tue, 13 Jan 2015 13:08:09 +0100 Subject: [PATCH 0161/2920] doc: Use icingaweb2 as directory instead of icingaweb --- doc/installation.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/doc/installation.md b/doc/installation.md index 6eb6737ec..6928cb2e3 100644 --- a/doc/installation.md +++ b/doc/installation.md @@ -38,7 +38,7 @@ git clone git://git.icinga.org/icingaweb2.git Choose a target directory and move Icinga Web 2 there. ```` -mv icingaweb2 /usr/share/icingaweb +mv icingaweb2 /usr/share/icingaweb2 ```` **Step 3: Configuring the Web Server** @@ -48,13 +48,13 @@ Use `icingacli` to generate web server configuration for either Apache or nginx. *Apache* ```` -./bin/icingacli setup config webserver apache --document-root /usr/share/icingaweb/public +./bin/icingacli setup config webserver apache --document-root /usr/share/icingaweb2/public ```` *nginx* ```` -./bin/icingacli setup config webserver nginx --document-root /usr/share/icingaweb/public +./bin/icingacli setup config webserver nginx --document-root /usr/share/icingaweb2/public ```` **Step 4: Web Setup** From debc30578985970ff952c7d53cf13cc5b80fd2aa Mon Sep 17 00:00:00 2001 From: Matthias Jentsch Date: Tue, 2 Dec 2014 17:24:34 +0100 Subject: [PATCH 0162/2920] Add logarithmic AxisUnit resolves #7845 --- library/Icinga/Chart/Unit/LogarithmicUnit.php | 264 ++++++++++++++++++ .../controllers/ChartController.php | 99 ++++++- .../views/scripts/chart/test.phtml | 11 +- 3 files changed, 366 insertions(+), 8 deletions(-) create mode 100644 library/Icinga/Chart/Unit/LogarithmicUnit.php diff --git a/library/Icinga/Chart/Unit/LogarithmicUnit.php b/library/Icinga/Chart/Unit/LogarithmicUnit.php new file mode 100644 index 000000000..44580b15e --- /dev/null +++ b/library/Icinga/Chart/Unit/LogarithmicUnit.php @@ -0,0 +1,264 @@ + + * this article for a more detailed description. + */ +class LogarithmicUnit implements AxisUnit +{ + /** + * @var int + */ + protected $base; + + /** + * @var + */ + protected $currentTick; + + /** + * @var + */ + protected $minExp; + + /** + * @var + */ + protected $maxExp; + + /** + * True when the minimum value is static and isn't affected by the data set + * + * @var bool + */ + protected $staticMin = false; + + /** + * True when the maximum value is static and isn't affected by the data set + * + * @var bool + */ + protected $staticMax = false; + + /** + * Create and initialize this AxisUnit + * + * @param int $nrOfTicks The number of ticks to use + */ + public function __construct($base = 10) + {; + $this->base = $base; + $this->minExp = PHP_INT_MAX; + $this->maxExp = ~PHP_INT_MAX; + } + + /** + * Add a dataset and calculate the minimum and maximum value for this AxisUnit + * + * @param array $dataset The dataset to add + * @param int $idx The idx (0 for x, 1 for y) + * + * @return self Fluent interface + */ + public function addValues(array $dataset, $idx = 0) + { + $datapoints = array(); + + foreach ($dataset['data'] as $points) { + $datapoints[] = $points[$idx]; + } + if (empty($datapoints)) { + return $this; + } + sort($datapoints); + if (!$this->staticMax) { + $this->maxExp = max($this->maxExp, $this->logCeil($datapoints[count($datapoints) - 1])); + } + if (!$this->staticMin) { + $this->minExp = min($this->minExp, $this->logFloor($datapoints[0])); + } + $this->currentTick = 0; + + return $this; + } + + /** + * Transform the absolute value to an axis relative value + * + * @param int $value The absolute coordinate from the data set + * @return float|int The axis relative coordinate (between 0 and 100) + */ + public function transform($value) + { + if ($value < $this->pow($this->minExp)) { + return 0; + } elseif ($value > $this->pow($this->maxExp)) { + return 100; + } else { + return 100 * ($this->log($value) - $this->minExp) / $this->getTicks(); + } + } + + /** + * Return the position of the current tick + * + * @return int + */ + public function current() + { + return $this->currentTick * (100 / $this->getTicks()); + } + + /** + * Calculate the next tick and tick value + */ + public function next() + { + ++ $this->currentTick; + } + + /** + * Return the label for the current tick + * + * @return string The label for the current tick + */ + public function key() + { + $currentBase = $this->currentTick + $this->minExp; + if (abs($currentBase) > 4) { + return '10E' . $currentBase; + } + return (string) intval($this->pow($currentBase)); + } + + /** + * True when we're at a valid tick (iterator interface) + * + * @return bool + */ + public function valid() + { + return $this->currentTick >= 0 && $this->currentTick < $this->getTicks(); + } + + /** + * Reset the current tick and label value + */ + public function rewind() + { + $this->currentTick = 0; + } + + /** + * Perform a log-modulo transformation + * + * @param $value The value to transform + * + * @return double The transformed value + */ + protected function log($value) + { + $sign = $value > 0 ? 1 : -1; + return $sign * log1p($sign * $value) / log($this->base); + } + + /** + * Calculate the biggest exponent necessary to display the given data point + * + * @param $value + * + * @return float + */ + protected function logCeil($value) + { + return ceil($this->log($value)) + 1; + } + + /** + * Calculate the smallest exponent necessary to display the given data point + * + * @param $value + * + * @return float + */ + protected function logFloor($value) + { + return floor($this->log($value)); + } + + /** + * Inverse function to the log-modulo transformation + * + * @param $value + * + * @return double + */ + protected function pow($value) + { + if ($value == 0) { + return 0; + } + $sign = $value > 0 ? 1 : -1; + return $sign * (pow($this->base, $sign * $value)); + } + + /** + * Set the axis minimum value to a fixed value + * + * @param int $min The new minimum value + */ + public function setMin($min) + { + $this->minExp = $this->logFloor($min); + $this->staticMin = true; + } + + /** + * Set the axis maximum value to a fixed value + * + * @param int $max The new maximum value + */ + public function setMax($max) + { + $this->maxExp = $this->logCeil($max); + $this->staticMax = true; + } + + /** + * Return the current minimum value of the axis + * + * @return int The minimum set for this axis + */ + public function getMin() + { + return $this->pow($this->minExp); + } + + /** + * Return the current maximum value of the axis + * + * @return int The maximum set for this axis + */ + public function getMax() + { + return $this->pow($this->maxExp); + } + + /** + * Get the amount of ticks necessary to display this AxisUnit + * + * @return int + */ + protected function getTicks() + { + return $this->maxExp - $this->minExp; + } +} diff --git a/modules/monitoring/application/controllers/ChartController.php b/modules/monitoring/application/controllers/ChartController.php index 2024f83f4..640ee2520 100644 --- a/modules/monitoring/application/controllers/ChartController.php +++ b/modules/monitoring/application/controllers/ChartController.php @@ -6,6 +6,8 @@ use Icinga\Module\Monitoring\Controller; use Icinga\Chart\GridChart; use Icinga\Chart\PieChart; use Icinga\Chart\Unit\StaticAxis; +use Icinga\Chart\Unit\LogarithmicUnit; +use Icinga\Chart\Unit\LinearUnit; /** * Class Monitoring_CommandController @@ -20,6 +22,95 @@ class Monitoring_ChartController extends Controller $this->view->compact = $this->_request->getParam('view') === 'compact'; } + private function drawLogChart1() + { + $chart = new GridChart(); + $chart->alignTopLeft(); + $chart->setAxisLabel('X axis label', 'Y axis label') + ->setYAxis(new LogarithmicUnit()); + + for ($i = -15; $i < 15; $i++) { + $data1[] = array($i, -$i * rand(1, 10) * pow(2, rand(1, 2))); + } + for ($i = -15; $i < 15; $i++) { + $data2[] = array($i, 1000 + $i * rand(1, 35) * pow(2, rand(1, 2))); + } + for ($i = -15; $i < 15; $i++) { + $data3[] = array($i, $i * rand(1, 100) * pow(2, rand(1, 10)) - 1000); + } + + $chart->drawLines( + array( + 'label' => 'Random 1', + 'color' => 'red', + 'data' => $data1, + 'showPoints' => true + ) + ); + $chart->drawLines( + array( + 'label' => 'Random 2', + 'color' => 'blue', + 'data' => $data2, + 'showPoints' => true + ) + ); + $chart->drawLines( + array( + 'label' => 'Random 3', + 'color' => 'green', + 'data' => $data3, + 'showPoints' => true + ) + ); + return $chart; + } + + private function drawLogChart2() + { + $chart = new GridChart(); + $chart->alignTopLeft(); + $chart->setAxisLabel('X axis label', 'Y axis label') + ->setYAxis(new LogarithmicUnit()); + + for ($i = -10; $i < 10; $i++) { + $sign = $i > 0 ? 1 : + ($i < 0 ? -1 : 0); + $data[] = array($i, $sign * pow(10, abs($i))); + } + $chart->drawLines( + array( + 'label' => 'f(x): sign(x) * 10^|x|', + 'color' => 'red', + 'data' => $data, + 'showPoints' => true + ) + ); + return $chart; + } + private function drawLogChart3() + { + $chart = new GridChart(); + $chart->alignTopLeft(); + $chart->setAxisLabel('X axis label', 'Y axis label') + ->setYAxis(new LogarithmicUnit()); + + for ($i = -2; $i < 3; $i++) { + $sign = $i > 0 ? 1 : + ($i < 0 ? -1 : 0); + $data[] = array($i, $sign * pow(10, abs($i))); + } + $chart->drawLines( + array( + 'label' => 'f(x): sign(x) * 10^|x|', + 'color' => 'red', + 'data' => $data, + 'showPoints' => true + ) + ); + return $chart; + } + public function testAction() { $this->chart = new GridChart(); @@ -52,7 +143,7 @@ class Monitoring_ChartController extends Controller */ $this->chart->drawBars( array( - 'label' => 'Some other line', + 'label' => 'A big amount of data', 'color' => 'green', 'data' => $data3, 'showPoints' => true @@ -68,7 +159,11 @@ class Monitoring_ChartController extends Controller ) ); */ - $this->view->svg = $this->chart; + $this->view->svgs = array(); + $this->view->svgs[] = $this->drawLogChart1(); + $this->view->svgs[] = $this->drawLogChart2(); + $this->view->svgs[] = $this->drawLogChart3(); + $this->view->svgs[] = $this->chart; } public function hostgroupAction() diff --git a/modules/monitoring/application/views/scripts/chart/test.phtml b/modules/monitoring/application/views/scripts/chart/test.phtml index 1c2046bdf..214f44d33 100644 --- a/modules/monitoring/application/views/scripts/chart/test.phtml +++ b/modules/monitoring/application/views/scripts/chart/test.phtml @@ -1,6 +1,5 @@ -mah -
    -render(); -?> -
    \ No newline at end of file + +
    + render() ?> +
    + \ No newline at end of file From 807666bf8860579d248f03e48992c5ed86db992c Mon Sep 17 00:00:00 2001 From: Matthias Jentsch Date: Mon, 5 Jan 2015 17:49:11 +0100 Subject: [PATCH 0163/2920] Improve chart axis readability Introduce different line weights to separate between the smallest visible separator (steps) and single chart values (ticks). Calculate the amount of ticks per step using the available chart space. fixes #7846 --- library/Icinga/Chart/Axis.php | 143 ++++++++++++------ library/Icinga/Chart/Graph/BarGraph.php | 2 +- library/Icinga/Chart/Unit/AxisUnit.php | 10 +- library/Icinga/Chart/Unit/LinearUnit.php | 57 ++----- library/Icinga/Chart/Unit/LogarithmicUnit.php | 4 +- library/Icinga/Chart/Unit/StaticAxis.php | 10 ++ 6 files changed, 137 insertions(+), 89 deletions(-) diff --git a/library/Icinga/Chart/Axis.php b/library/Icinga/Chart/Axis.php index 00a5f5679..74c40b495 100644 --- a/library/Icinga/Chart/Axis.php +++ b/library/Icinga/Chart/Axis.php @@ -77,6 +77,20 @@ class Axis implements Drawable */ private $yUnit = null; + /** + * The minimum amount of units each step must take up + * + * @var int + */ + public $minUnitsPerStep = 80; + + /** + * The minimum amount of units each tick must take up + * + * @var int + */ + public $minUnitsPerTick = 15; + /** * If the displayed labels should be aligned horizontally or diagonally */ @@ -160,6 +174,14 @@ class Axis implements Drawable */ private function renderHorizontalAxis(RenderContext $ctx, DOMElement $group) { + $steps = $this->ticksPerX($this->xUnit->getTicks(), $ctx->getNrOfUnitsX(), $this->minUnitsPerStep); + $ticks = $this->ticksPerX($this->xUnit->getTicks(), $ctx->getNrOfUnitsX(), $this->minUnitsPerTick); + + // Steps should always be ticks + if ($ticks !== $steps) { + $steps = $ticks * 5; + } + $line = new Line(0, 100, 100, 100); $line->setStrokeWidth(2); $group->appendChild($line->toSvg($ctx)); @@ -168,41 +190,48 @@ class Axis implements Drawable $lastLabelEnd = -1; $shift = 0; + $i = 0; foreach ($this->xUnit as $label => $pos) { - if ($this->labelRotationStyle === self::LABEL_ROTATE_HORIZONTAL) { - // If the last label would overlap this label we shift the y axis a bit - if ($lastLabelEnd > $pos) { - $shift = ($shift + 5) % 10; - } else { - $shift = 0; + + if ($i % $ticks === 0) { + $tick = new Line($pos, 100, $pos, 101); + $group->appendChild($tick->toSvg($ctx)); + } + + if ($i % $steps === 0) { + if ($this->labelRotationStyle === self::LABEL_ROTATE_HORIZONTAL) { + // If the last label would overlap this label we shift the y axis a bit + if ($lastLabelEnd > $pos) { + $shift = ($shift + 5) % 10; + } else { + $shift = 0; + } } + + $labelField = new Text($pos + 0.5, ($this->xLabel ? 107 : 105) + $shift, $label); + if ($this->labelRotationStyle === self::LABEL_ROTATE_HORIZONTAL) { + $labelField->setAlignment(Text::ALIGN_MIDDLE) + ->setFontSize('1.8em'); + } else { + $labelField->setFontSize('2.5em'); + } + + if ($this->labelRotationStyle === self::LABEL_ROTATE_DIAGONAL) { + $labelField = new Rotator($labelField, 45); + } + $labelField = $labelField->toSvg($ctx); + + $group->appendChild($labelField); + + if ($this->drawYGrid) { + $bgLine = new Line($pos, 0, $pos, 100); + $bgLine->setStrokeWidth(0.5) + ->setStrokeColor('#232'); + $group->appendChild($bgLine->toSvg($ctx)); + } + $lastLabelEnd = $pos + strlen($label) * 1.2; } - - $tick = new Line($pos, 100, $pos, 102); - $group->appendChild($tick->toSvg($ctx)); - - $labelField = new Text($pos + 0.5, ($this->xLabel ? 107 : 105) + $shift, $label); - if ($this->labelRotationStyle === self::LABEL_ROTATE_HORIZONTAL) { - $labelField->setAlignment(Text::ALIGN_MIDDLE) - ->setFontSize('1.8em'); - } else { - $labelField->setFontSize('2.5em'); - } - - if ($this->labelRotationStyle === self::LABEL_ROTATE_DIAGONAL) { - $labelField = new Rotator($labelField, 45); - } - $labelField = $labelField->toSvg($ctx); - - $group->appendChild($labelField); - - if ($this->drawYGrid) { - $bgLine = new Line($pos, 0, $pos, 100); - $bgLine->setStrokeWidth(0.5) - ->setStrokeColor('#232'); - $group->appendChild($bgLine->toSvg($ctx)); - } - $lastLabelEnd = $pos + strlen($label) * 1.2; + $i++; } // render the label for this axis @@ -223,26 +252,42 @@ class Axis implements Drawable */ private function renderVerticalAxis(RenderContext $ctx, DOMElement $group) { + $steps = $this->ticksPerX($this->yUnit->getTicks(), $ctx->getNrOfUnitsY(), $this->minUnitsPerStep); + $ticks = $this->ticksPerX($this->yUnit->getTicks(), $ctx->getNrOfUnitsY(), $this->minUnitsPerTick); + + // Steps should always be ticks + if ($ticks !== $steps) { + $steps = $ticks * 5; + } $line = new Line(0, 0, 0, 100); $line->setStrokeWidth(2); $group->appendChild($line->toSvg($ctx)); + $i = 0; foreach ($this->yUnit as $label => $pos) { $pos = 100 - $pos; - $tick = new Line(0, $pos, -1, $pos); - $group->appendChild($tick->toSvg($ctx)); - $labelField = new Text(-0.5, $pos+0.5, $label); - $labelField->setFontSize('1.8em') - ->setAlignment(Text::ALIGN_END); - - $group->appendChild($labelField->toSvg($ctx)); - if ($this->drawXGrid) { - $bgLine = new Line(0, $pos, 100, $pos); - $bgLine->setStrokeWidth(0.5) - ->setStrokeColor('#343'); - $group->appendChild($bgLine->toSvg($ctx)); + if ($i % $ticks === 0) { + // draw a tick + $tick = new Line(0, $pos, -1, $pos); + $group->appendChild($tick->toSvg($ctx)); } + + if ($i % $steps === 0) { + // draw a step + $labelField = new Text(-0.5, $pos+0.5, $label); + $labelField->setFontSize('1.8em') + ->setAlignment(Text::ALIGN_END); + + $group->appendChild($labelField->toSvg($ctx)); + if ($this->drawXGrid) { + $bgLine = new Line(0, $pos, 100, $pos); + $bgLine->setStrokeWidth(0.5) + ->setStrokeColor('#343'); + $group->appendChild($bgLine->toSvg($ctx)); + } + } + $i++; } if ($this->yLabel) { @@ -416,4 +461,14 @@ class Axis implements Drawable $this->renderVerticalAxis($ctx, $group); return $group; } + + protected function ticksPerX($ticks, $units, $min) + { + $per = 1; + while ($per * $units / $ticks < $min) { + $per++; + } + return $per; + } + } diff --git a/library/Icinga/Chart/Graph/BarGraph.php b/library/Icinga/Chart/Graph/BarGraph.php index 1225307ad..0ec5e77a9 100644 --- a/library/Icinga/Chart/Graph/BarGraph.php +++ b/library/Icinga/Chart/Graph/BarGraph.php @@ -28,7 +28,7 @@ class BarGraph extends Styleable implements Drawable * * @var int */ - private $barWidth = 4; + private $barWidth = 1; /** * The dataset to use for this bar graph diff --git a/library/Icinga/Chart/Unit/AxisUnit.php b/library/Icinga/Chart/Unit/AxisUnit.php index dc57f99e0..fba521778 100644 --- a/library/Icinga/Chart/Unit/AxisUnit.php +++ b/library/Icinga/Chart/Unit/AxisUnit.php @@ -9,13 +9,14 @@ use Iterator; /** * Base class for Axis Units * + * An AxisUnit takes a set of values and places them on a given range + * * Concrete subclasses must implement the iterator interface, with * getCurrent returning the axis relative position and getValue the label * that will be displayed */ interface AxisUnit extends Iterator { - /** * Add a dataset to this AxisUnit, required for dynamic min and max vlaues * @@ -46,4 +47,11 @@ interface AxisUnit extends Iterator * @param int $max The new maximum value */ public function setMax($max); + + /** + * Get the amount of ticks of this axis + * + * @return int + */ + public function getTicks(); } diff --git a/library/Icinga/Chart/Unit/LinearUnit.php b/library/Icinga/Chart/Unit/LinearUnit.php index d776fe304..fe80971d4 100644 --- a/library/Icinga/Chart/Unit/LinearUnit.php +++ b/library/Icinga/Chart/Unit/LinearUnit.php @@ -9,7 +9,6 @@ namespace Icinga\Chart\Unit; */ class LinearUnit implements AxisUnit { - /** * The minimum value to display * @@ -43,7 +42,7 @@ class LinearUnit implements AxisUnit * * @var int */ - private $nrOfTicks = 10; + protected $nrOfTicks = 10; /** * The currently displayed tick @@ -95,45 +94,13 @@ class LinearUnit implements AxisUnit if (!$this->staticMin) { $this->min = min($this->min, $datapoints[0]); } - if (!$this->staticMin || !$this->staticMax) { - $this->updateMaxValue(); - } $this->currentTick = 0; $this->currentValue = $this->min; - return $this; - } - - /** - * Refresh the range depending on the current values of min, max and nrOfTicks - */ - private function updateMaxValue() - { - $this->max = $this->calculateTickRange($this->max - $this->min, $this->nrOfTicks) * - $this->nrOfTicks + $this->min; - } - - /** - * Determine the minimum tick range that is necessary to display the given value range - * correctly - * - * @param int range The range to display - * @param int ticks The amount of ticks to use - * - * @return int The value for each tick - */ - private function calculateTickRange($range, $ticks) - { - $factor = 1; - $steps = array(1, 2, 5); - $step = 0; - while ($range / ($factor * $steps[$step]) > $ticks) { - $step++; - if ($step === count($steps)) { - $step = 0; - $factor *= 10; - } + if ($this->max === $this->min) { + $this->max = $this->min + 10; } - return $steps[$step] * $factor; + $this->nrOfTicks = $this->max - $this->min; + return $this; } /** @@ -149,7 +116,7 @@ class LinearUnit implements AxisUnit } elseif ($value > $this->max) { return 100; } else { - return 100 * ($value - $this->min) / $this->max - $this->min; + return 100 * ($value - $this->min) / $this->nrOfTicks; } } @@ -211,7 +178,6 @@ class LinearUnit implements AxisUnit if ($max !== null) { $this->max = $max; $this->staticMax = true; - $this->updateMaxValue(); } } @@ -225,7 +191,6 @@ class LinearUnit implements AxisUnit if ($min !== null) { $this->min = $min; $this->staticMin = true; - $this->updateMaxValue(); } } @@ -248,4 +213,14 @@ class LinearUnit implements AxisUnit { return $this->max; } + + /** + * Get the amount of ticks necessary to display this AxisUnit + * + * @return int + */ + public function getTicks() + { + return $this->nrOfTicks; + } } diff --git a/library/Icinga/Chart/Unit/LogarithmicUnit.php b/library/Icinga/Chart/Unit/LogarithmicUnit.php index 44580b15e..6d07f3d45 100644 --- a/library/Icinga/Chart/Unit/LogarithmicUnit.php +++ b/library/Icinga/Chart/Unit/LogarithmicUnit.php @@ -134,7 +134,7 @@ class LogarithmicUnit implements AxisUnit { $currentBase = $this->currentTick + $this->minExp; if (abs($currentBase) > 4) { - return '10E' . $currentBase; + return $this->base . 'E' . $currentBase; } return (string) intval($this->pow($currentBase)); } @@ -257,7 +257,7 @@ class LogarithmicUnit implements AxisUnit * * @return int */ - protected function getTicks() + public function getTicks() { return $this->maxExp - $this->minExp; } diff --git a/library/Icinga/Chart/Unit/StaticAxis.php b/library/Icinga/Chart/Unit/StaticAxis.php index 6458ae599..c7e9c2be5 100644 --- a/library/Icinga/Chart/Unit/StaticAxis.php +++ b/library/Icinga/Chart/Unit/StaticAxis.php @@ -118,4 +118,14 @@ class StaticAxis implements AxisUnit { return reset($this->items); } + + /** + * Get the amount of ticks of this axis + * + * @return int + */ + public function getTicks() + { + return count($this->items); + } } From d1c7d9d2f9cd8481b7d2a15830da8635189c6eaa Mon Sep 17 00:00:00 2001 From: Matthias Jentsch Date: Tue, 13 Jan 2015 18:21:11 +0100 Subject: [PATCH 0164/2920] Improve SVG layout --- library/Icinga/Chart/Axis.php | 20 +++++++++++++------- library/Icinga/Chart/Graph/LineGraph.php | 11 +++++++++-- library/Icinga/Chart/Primitive/Circle.php | 2 +- 3 files changed, 23 insertions(+), 10 deletions(-) diff --git a/library/Icinga/Chart/Axis.php b/library/Icinga/Chart/Axis.php index 74c40b495..e6046705a 100644 --- a/library/Icinga/Chart/Axis.php +++ b/library/Icinga/Chart/Axis.php @@ -182,9 +182,11 @@ class Axis implements Drawable $steps = $ticks * 5; } + /* $line = new Line(0, 100, 100, 100); $line->setStrokeWidth(2); $group->appendChild($line->toSvg($ctx)); + */ // contains the approximate end position of the last label $lastLabelEnd = -1; @@ -194,8 +196,10 @@ class Axis implements Drawable foreach ($this->xUnit as $label => $pos) { if ($i % $ticks === 0) { + /* $tick = new Line($pos, 100, $pos, 101); $group->appendChild($tick->toSvg($ctx)); + */ } if ($i % $steps === 0) { @@ -211,7 +215,7 @@ class Axis implements Drawable $labelField = new Text($pos + 0.5, ($this->xLabel ? 107 : 105) + $shift, $label); if ($this->labelRotationStyle === self::LABEL_ROTATE_HORIZONTAL) { $labelField->setAlignment(Text::ALIGN_MIDDLE) - ->setFontSize('1.8em'); + ->setFontSize('2.5em'); } else { $labelField->setFontSize('2.5em'); } @@ -226,7 +230,7 @@ class Axis implements Drawable if ($this->drawYGrid) { $bgLine = new Line($pos, 0, $pos, 100); $bgLine->setStrokeWidth(0.5) - ->setStrokeColor('#232'); + ->setStrokeColor('#BFBFBF'); $group->appendChild($bgLine->toSvg($ctx)); } $lastLabelEnd = $pos + strlen($label) * 1.2; @@ -259,9 +263,11 @@ class Axis implements Drawable if ($ticks !== $steps) { $steps = $ticks * 5; } + /* $line = new Line(0, 0, 0, 100); $line->setStrokeWidth(2); $group->appendChild($line->toSvg($ctx)); + */ $i = 0; foreach ($this->yUnit as $label => $pos) { @@ -269,21 +275,21 @@ class Axis implements Drawable if ($i % $ticks === 0) { // draw a tick - $tick = new Line(0, $pos, -1, $pos); - $group->appendChild($tick->toSvg($ctx)); + //$tick = new Line(0, $pos, -1, $pos); + //$group->appendChild($tick->toSvg($ctx)); } if ($i % $steps === 0) { // draw a step - $labelField = new Text(-0.5, $pos+0.5, $label); - $labelField->setFontSize('1.8em') + $labelField = new Text(-0.5, $pos + 0.5, $label); + $labelField->setFontSize('2.5em') ->setAlignment(Text::ALIGN_END); $group->appendChild($labelField->toSvg($ctx)); if ($this->drawXGrid) { $bgLine = new Line(0, $pos, 100, $pos); $bgLine->setStrokeWidth(0.5) - ->setStrokeColor('#343'); + ->setStrokeColor('#BFBFBF'); $group->appendChild($bgLine->toSvg($ctx)); } } diff --git a/library/Icinga/Chart/Graph/LineGraph.php b/library/Icinga/Chart/Graph/LineGraph.php index d12d4eed9..3644f1492 100644 --- a/library/Icinga/Chart/Graph/LineGraph.php +++ b/library/Icinga/Chart/Graph/LineGraph.php @@ -45,6 +45,13 @@ class LineGraph extends Styleable implements Drawable */ public $strokeWidth = 5; + /** + * The size of the displayed dots + * + * @var int + */ + public $dotWith = 0; + /** * Create a new LineGraph displaying the given dataset * @@ -138,8 +145,8 @@ class LineGraph extends Styleable implements Drawable $group = $path->toSvg($ctx); if ($this->showDataPoints === true) { foreach ($this->dataset as $point) { - $dot = new Circle($point[0], $point[1], $this->strokeWidth*5); - $dot->setFill('black'); + $dot = new Circle($point[0], $point[1], $this->dotWith); + $dot->setFill($this->strokeColor); $group->appendChild($dot->toSvg($ctx)); } diff --git a/library/Icinga/Chart/Primitive/Circle.php b/library/Icinga/Chart/Primitive/Circle.php index 058211bf7..da5f1785e 100644 --- a/library/Icinga/Chart/Primitive/Circle.php +++ b/library/Icinga/Chart/Primitive/Circle.php @@ -61,7 +61,7 @@ class Circle extends Styleable implements Drawable $circle = $ctx->getDocument()->createElement('circle'); $circle->setAttribute('cx', Format::formatSVGNumber($coords[0])); $circle->setAttribute('cy', Format::formatSVGNumber($coords[1])); - $circle->setAttribute('r', 5); + $circle->setAttribute('r', $this->radius); $circle->setAttribute('style', $this->getStyle()); $this->applyAttributes($circle); return $circle; From 1732fa90e83aa4adcf50b41a583466fc42a1de76 Mon Sep 17 00:00:00 2001 From: Matthias Jentsch Date: Tue, 13 Jan 2015 18:24:04 +0100 Subject: [PATCH 0165/2920] Fix axisMin in alert summary --- .../application/controllers/AlertsummaryController.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/monitoring/application/controllers/AlertsummaryController.php b/modules/monitoring/application/controllers/AlertsummaryController.php index fdb1ec99f..1344d03f4 100644 --- a/modules/monitoring/application/controllers/AlertsummaryController.php +++ b/modules/monitoring/application/controllers/AlertsummaryController.php @@ -344,8 +344,8 @@ class Monitoring_AlertsummaryController extends Controller $gridChart->alignTopLeft(); $gridChart->setAxisLabel('', mt('monitoring', 'Notifications')) ->setXAxis(new StaticAxis()) - ->setAxisMin(null, 0) - ->setYAxis(new LinearUnit(10)); + ->setYAxis(new LinearUnit(10)) + ->setAxisMin(null, 0); $interval = $this->getInterval(); From 76d3e5435fada8d4ff5c496bed818722ec20cd22 Mon Sep 17 00:00:00 2001 From: Matthias Jentsch Date: Tue, 13 Jan 2015 18:25:19 +0100 Subject: [PATCH 0166/2920] Display bigger legend labels correctly without overlapping --- library/Icinga/Chart/Legend.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/library/Icinga/Chart/Legend.php b/library/Icinga/Chart/Legend.php index 46ba8081c..df334089f 100644 --- a/library/Icinga/Chart/Legend.php +++ b/library/Icinga/Chart/Legend.php @@ -66,13 +66,14 @@ class Legend implements Drawable $outer->getLayout()->setPadding(2, 2, 2, 2); $nrOfColumns = 4; - $leftstep = 100 / $nrOfColumns; $topstep = 10 / $nrOfColumns + 2; $top = 0; $left = 0; $lastLabelEndPos = -1; foreach ($this->dataset as $color => $text) { + $leftstep = 100 / $nrOfColumns + strlen($text); + // Make sure labels don't overlap each other while ($lastLabelEndPos >= $left) { $left += $leftstep; From be7e3f98e91fe3b4b083cccdb10d7d5fe936f6cc Mon Sep 17 00:00:00 2001 From: Matthias Jentsch Date: Tue, 13 Jan 2015 18:26:39 +0100 Subject: [PATCH 0167/2920] Improve testAction Add charts to test logarithmic scale, use less annoying colors --- .../controllers/ChartController.php | 38 ++++++++++--------- 1 file changed, 21 insertions(+), 17 deletions(-) diff --git a/modules/monitoring/application/controllers/ChartController.php b/modules/monitoring/application/controllers/ChartController.php index 640ee2520..757329bfe 100644 --- a/modules/monitoring/application/controllers/ChartController.php +++ b/modules/monitoring/application/controllers/ChartController.php @@ -42,7 +42,7 @@ class Monitoring_ChartController extends Controller $chart->drawLines( array( 'label' => 'Random 1', - 'color' => 'red', + 'color' => '#F56', 'data' => $data1, 'showPoints' => true ) @@ -50,7 +50,7 @@ class Monitoring_ChartController extends Controller $chart->drawLines( array( 'label' => 'Random 2', - 'color' => 'blue', + 'color' => '#fa4', 'data' => $data2, 'showPoints' => true ) @@ -58,7 +58,7 @@ class Monitoring_ChartController extends Controller $chart->drawLines( array( 'label' => 'Random 3', - 'color' => 'green', + 'color' => '#4b7', 'data' => $data3, 'showPoints' => true ) @@ -81,7 +81,7 @@ class Monitoring_ChartController extends Controller $chart->drawLines( array( 'label' => 'f(x): sign(x) * 10^|x|', - 'color' => 'red', + 'color' => '#F56', 'data' => $data, 'showPoints' => true ) @@ -103,7 +103,7 @@ class Monitoring_ChartController extends Controller $chart->drawLines( array( 'label' => 'f(x): sign(x) * 10^|x|', - 'color' => 'red', + 'color' => '#F56', 'data' => $data, 'showPoints' => true ) @@ -119,7 +119,7 @@ class Monitoring_ChartController extends Controller $data1 = array(); $data2 = array(); $data3 = array(); - for ($i = 0; $i < 25; $i++) { + for ($i = 0; $i < 50; $i++) { $data3[] = array('Label ' . $i, rand(0, 30)); } @@ -127,13 +127,13 @@ class Monitoring_ChartController extends Controller $this->chart->drawLines( array( 'label' => 'Nr of outtakes', - 'color' => 'red', + 'color' => '#F56', 'width' => '5', 'data' => $data ), array( 'label' => 'Some line', - 'color' => 'blue', + 'color' => '#fa4', 'width' => '4', 'data' => $data3, @@ -144,7 +144,7 @@ class Monitoring_ChartController extends Controller $this->chart->drawBars( array( 'label' => 'A big amount of data', - 'color' => 'green', + 'color' => '#4b7', 'data' => $data3, 'showPoints' => true ) @@ -280,18 +280,15 @@ class Monitoring_ChartController extends Controller $upBars = array(); $downBars = array(); $unreachableBars = array(); - foreach ($query as $hostgroup) { + for ($i = 0; $i < 50; $i++) { $upBars[] = array( - $hostgroup->hostgroup, - $hostgroup->hosts_up + (string)$i, rand(1, 200), rand(1, 200) ); $downBars[] = array( - $hostgroup->hostgroup, - $hostgroup->hosts_down_unhandled + (string)$i, rand(1, 200), rand(1, 200) ); $unreachableBars[] = array( - $hostgroup->hostgroup, - $hostgroup->hosts_unreachable_unhandled + (string)$i, rand(1, 200), rand(1, 200) ); } $tooltip = mt('monitoring', '{title}:
    {value} of {sum} hosts are {label}'); @@ -367,7 +364,14 @@ class Monitoring_ChartController extends Controller (int) $query->hosts_unreachable_unhandled, (int) $query->hosts_pending ), - 'colors' => array('#44bb77', '#ff4444', '#ff0000', '#E066FF', '#f099FF', '#fefefe'), + 'colors' => array( + '#44bb77', // 'Ok' + '#ff4444', // 'Warning' + '#ff0000', // 'WarningHandled' + '#E066FF', + '#f099FF', + '#fefefe' + ), 'labels'=> array( (int) $query->hosts_up . mt('monitoring', ' Up Hosts'), (int) $query->hosts_down_handled . mt('monitoring', ' Down Hosts (Handled)'), From 0dbd4eb496459b0d21b01c2e41b95ee27319c983 Mon Sep 17 00:00:00 2001 From: Thomas Gelf Date: Wed, 14 Jan 2015 10:58:36 +0100 Subject: [PATCH 0168/2920] Web\Hook: support hook base classes in modules refs #8207 --- library/Icinga/Web/Hook.php | 32 +++++++++++++++++++++++++++++--- 1 file changed, 29 insertions(+), 3 deletions(-) diff --git a/library/Icinga/Web/Hook.php b/library/Icinga/Web/Hook.php index 01d1e0e2c..7ace738d7 100644 --- a/library/Icinga/Web/Hook.php +++ b/library/Icinga/Web/Hook.php @@ -113,6 +113,18 @@ class Hook return $instance; } + protected static function splitHookName($name) + { + $sep = '\\'; + if (false === $module = strpos($name, $sep)) { + return array(null, $name); + } + return array( + substr($name, 0, $module), + substr($name, $module + 1) + ); + } + /** * Test for a valid class name * @@ -123,10 +135,24 @@ class Hook */ private static function assertValidHook($instance, $name) { - $base_class = self::$BASE_NS . ucfirst($name) . 'Hook'; + $suffix = self::$classSuffix; // 'Hook' + $base = self::$BASE_NS; // 'Icinga\\Web\\Hook\\' - if (strpos($base_class, self::$classSuffix) === false) { - $base_class .= self::$classSuffix; + list($module, $name) = self::splitHookName($name); + + if ($module === null) { + $base_class = $base . ucfirst($name) . 'Hook'; + + // I'm unsure whether this makes sense. Unused and Wrong. + if (strpos($base_class, $suffix) === false) { + $base_class .= $suffix; + } + } else { + $base_class = 'Icinga\\Module\\' + . ucfirst($module) + . '\\Web\\Hook\\' + . ucfirst($name) + . $suffix; } if (!$instance instanceof $base_class) { From 5e4b611860da8365b47d2ab750851a426b2f2fd1 Mon Sep 17 00:00:00 2001 From: Thomas Gelf Date: Wed, 14 Jan 2015 11:00:26 +0100 Subject: [PATCH 0169/2920] HostActionsHook: initial very simple implementation refs #8208 --- .../library/Monitoring/Web/Hook/HostActionsHook.php | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 modules/monitoring/library/Monitoring/Web/Hook/HostActionsHook.php diff --git a/modules/monitoring/library/Monitoring/Web/Hook/HostActionsHook.php b/modules/monitoring/library/Monitoring/Web/Hook/HostActionsHook.php new file mode 100644 index 000000000..c1ccdfbca --- /dev/null +++ b/modules/monitoring/library/Monitoring/Web/Hook/HostActionsHook.php @@ -0,0 +1,10 @@ + Date: Wed, 14 Jan 2015 11:01:39 +0100 Subject: [PATCH 0170/2920] HostController: use host actions hook refs #8208 --- .../application/controllers/HostController.php | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/modules/monitoring/application/controllers/HostController.php b/modules/monitoring/application/controllers/HostController.php index ab62c3756..2f3eedf30 100644 --- a/modules/monitoring/application/controllers/HostController.php +++ b/modules/monitoring/application/controllers/HostController.php @@ -9,6 +9,7 @@ use Icinga\Module\Monitoring\Forms\Command\Object\ScheduleHostCheckCommandForm; use Icinga\Module\Monitoring\Forms\Command\Object\ScheduleHostDowntimeCommandForm; use Icinga\Module\Monitoring\Object\Host; use Icinga\Module\Monitoring\Web\Controller\MonitoredObjectController; +use Icinga\Web\Hook; class Monitoring_HostController extends MonitoredObjectController { @@ -33,12 +34,26 @@ class Monitoring_HostController extends MonitoredObjectController $this->createTabs(); } + protected function getHostActions() + { + $urls = array(); + + foreach (Hook::all('Monitoring\\HostActions') as $hook) { + foreach ($hook->getActionsForHost($this->object) as $id => $url) { + $urls[$id] = $url; + } + } + + return $urls; + } + /** * Show a host */ public function showAction() { $this->getTabs()->activate('host'); + $this->view->hostActions = $this->getHostActions(); parent::showAction(); } From 0d3131fbd0335f6b8aa627b85057349347946530 Mon Sep 17 00:00:00 2001 From: Thomas Gelf Date: Wed, 14 Jan 2015 11:02:06 +0100 Subject: [PATCH 0171/2920] host/show: show action urls above perfdata --- modules/monitoring/application/views/scripts/host/show.phtml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/monitoring/application/views/scripts/host/show.phtml b/modules/monitoring/application/views/scripts/host/show.phtml index 8023c1821..02f49b561 100644 --- a/modules/monitoring/application/views/scripts/host/show.phtml +++ b/modules/monitoring/application/views/scripts/host/show.phtml @@ -13,9 +13,9 @@ render('show/components/notifications.phtml') ?> render('show/components/downtime.phtml') ?> render('show/components/flapping.phtml') ?> + render('show/components/actions.phtml') ?> render('show/components/perfdata.phtml') ?> render('show/components/checksource.phtml') ?> - render('show/components/actions.phtml') ?> render('show/components/command.phtml') ?> render('show/components/hostgroups.phtml') ?> render('show/components/contacts.phtml') ?> From 0fa31acf5fb89ea25addbc578768058f30c4dbda Mon Sep 17 00:00:00 2001 From: Thomas Gelf Date: Wed, 14 Jan 2015 11:02:43 +0100 Subject: [PATCH 0172/2920] components/actions: show host action urls if given --- .../views/scripts/show/components/actions.phtml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/modules/monitoring/application/views/scripts/show/components/actions.phtml b/modules/monitoring/application/views/scripts/show/components/actions.phtml index 9f3211bd3..c34141084 100644 --- a/modules/monitoring/application/views/scripts/show/components/actions.phtml +++ b/modules/monitoring/application/views/scripts/show/components/actions.phtml @@ -6,6 +6,7 @@ if (! $object->action_url && ! $object->notes_url) { $links = array(); $linkText = '%s'; +$localLinkText = '%s'; if ($object->notes_url) { if (strpos($object->notes_url, "' ") === false) { @@ -32,6 +33,12 @@ if ($object->action_url) { } } +if (isset($this->hostActions)) { + foreach ($this->hostActions as $id => $action) { + $links[] = sprintf($localLinkText, $action, $id); + } +} + ?> Foreign URLs From b5cddc0a4f246c0887c544bcb5ecfd69419de227 Mon Sep 17 00:00:00 2001 From: Thomas Gelf Date: Wed, 14 Jan 2015 11:50:03 +0100 Subject: [PATCH 0173/2920] components/actions: show links if available Now we show links regardless of whether we have host actions, there might be hook-provided links only. Renamed "Foreign URLs" to "Actions" and made it translatable. --- .../views/scripts/show/components/actions.phtml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/modules/monitoring/application/views/scripts/show/components/actions.phtml b/modules/monitoring/application/views/scripts/show/components/actions.phtml index c34141084..1d926b33a 100644 --- a/modules/monitoring/application/views/scripts/show/components/actions.phtml +++ b/modules/monitoring/application/views/scripts/show/components/actions.phtml @@ -1,9 +1,5 @@ action_url && ! $object->notes_url) { - return; -} - $links = array(); $linkText = '%s'; $localLinkText = '%s'; @@ -39,8 +35,12 @@ if (isset($this->hostActions)) { } } +if (empty($links)) { + return; +} + ?> - Foreign URLs + translate('Actions') ?> From 4971037b379c173b4934d4531f1bdd70aac6358c Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Wed, 14 Jan 2015 13:24:04 +0100 Subject: [PATCH 0174/2920] doc/installation: Add section Preparing Web Setup --- doc/installation.md | 58 +++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 53 insertions(+), 5 deletions(-) diff --git a/doc/installation.md b/doc/installation.md index 6928cb2e3..c4496cbf4 100644 --- a/doc/installation.md +++ b/doc/installation.md @@ -45,18 +45,66 @@ mv icingaweb2 /usr/share/icingaweb2 Use `icingacli` to generate web server configuration for either Apache or nginx. -*Apache* - +Apache: ```` ./bin/icingacli setup config webserver apache --document-root /usr/share/icingaweb2/public ```` -*nginx* - +nginx: ```` ./bin/icingacli setup config webserver nginx --document-root /usr/share/icingaweb2/public ```` -**Step 4: Web Setup** +**Step 4: Preparing Web Setup** + +Because both web and CLI must have access to configuration and logs, permissions will be managed using a special +system group. The web server user and CLI user have to be added to this system group. + +Add the system group `icingaweb2` in the first place. + +Fedora, RHEL, CentOS, SLES and OpenSUSE: +```` +groupadd -r icingaweb2 +```` + +Debian and Ubuntu: +```` +addgroup --system icingaweb2 +```` + +Add your web server's user to the system group `icingaweb2`: + +Fedora, RHEL and CentOS: +```` +usermod -a -G icingaweb2 apache +```` + +SLES and OpenSUSE: +```` +usermod -G icingaweb2 wwwrun +```` + +Debian and Ubuntu: +```` +usermod -a -G icingaweb2 wwwrun +```` + +Use `icingacli` to create the configuration directory which defaults to **/etc/icingaweb2**: +```` +./bin/icingacli setup config directory +```` + +When using the web setup you are required to authenticate using a token. In order to generate a token use the +`icingacli`: +```` +./bin/icingacli setup token create +```` + +In case you do not remember the token you can show it using the `icingacli`: +```` +./bin/icingacli setup token show +```` + +**Step 5: Web Setup** Visit Icinga Web 2 in your browser and complete installation using the web setup. From b983f1901ba093ccd8433073db4a113e8e672651 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Wed, 14 Jan 2015 13:24:31 +0100 Subject: [PATCH 0175/2920] modules: Fix that the forms namespace is not registered when the module does not have any library file --- library/Icinga/Application/Modules/Module.php | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/library/Icinga/Application/Modules/Module.php b/library/Icinga/Application/Modules/Module.php index 99722f2b6..96bbae7be 100644 --- a/library/Icinga/Application/Modules/Module.php +++ b/library/Icinga/Application/Modules/Module.php @@ -759,15 +759,15 @@ class Module protected function registerAutoloader() { $moduleName = ucfirst($this->getName()); + $moduleLibraryDir = $this->getLibDir(). '/'. $moduleName; - if (is_dir($this->getBaseDir()) && is_dir($this->getLibDir()) && is_dir($moduleLibraryDir)) { + if (is_dir($moduleLibraryDir)) { $this->app->getLoader()->registerNamespace('Icinga\\Module\\' . $moduleName, $moduleLibraryDir); - if (is_dir($this->getFormDir())) { - $this->app->getLoader()->registerNamespace( - 'Icinga\\Module\\' . $moduleName. '\\Forms', - $this->getFormDir() - ); - } + } + + $moduleFormDir = $this->getFormDir(); + if (is_dir($moduleFormDir)) { + $this->app->getLoader()->registerNamespace('Icinga\\Module\\' . $moduleName. '\\Forms', $moduleFormDir); } return $this; From b8288b28a7717e752250f29041521ddeb5ffa80c Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Wed, 14 Jan 2015 14:14:44 +0100 Subject: [PATCH 0176/2920] doc/installation: Add PHP gettext and PHP OpenSSL support as requirement --- doc/installation.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/installation.md b/doc/installation.md index c4496cbf4..def23ffaf 100644 --- a/doc/installation.md +++ b/doc/installation.md @@ -6,7 +6,7 @@ system and distribution you are running. But it is also possible to install Icin ## Installing Requirements * A web server, e.g. Apache or nginx -* PHP >= 5.3.0 +* PHP >= 5.3.0 w/ gettext and OpenSSL support * MySQL or PostgreSQL PHP libraries when using a database for authentication or storing user preferences into a database * LDAP PHP library when using Active Directory or LDAP for authentication * Icinga 1.x w/ Livestatus or IDO, Icinga 2 w/ Livestatus or IDO feature enabled From 37880c6c89dec056ae1d61377afb05c746a03d67 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Wed, 14 Jan 2015 14:15:24 +0100 Subject: [PATCH 0177/2920] rpm: Support SUSE packages resolves #6403 --- icingaweb2.spec | 38 +++++++++++++++++++++++++++++--------- 1 file changed, 29 insertions(+), 9 deletions(-) diff --git a/icingaweb2.spec b/icingaweb2.spec index b4d120923..b77f42d86 100644 --- a/icingaweb2.spec +++ b/icingaweb2.spec @@ -29,6 +29,20 @@ Packager: Icinga Team %endif %endif + +%if 0%{?suse_version} +%define wwwconfigdir %{_sysconfdir}/apache2/conf.d +%define wwwuser wwwrun +%define zend php5-ZendFramework +%if 0%{?suse_version} == 1110 +%define php php53 +Requires: apache2-mod_php53 +%else +%define php php5 +Requires: apache2-mod_php5 +%endif +%endif + Requires(pre): shadow-utils Requires: %{name}-common = %{version}-%{release} Requires: php-Icinga = %{version}-%{release} @@ -61,21 +75,23 @@ Common files for Icinga Web 2 and the Icinga CLI %package -n php-Icinga -Summary: Icinga Web 2 PHP library -Group: Development/Libraries -Requires: %{php} >= 5.3.0 +Summary: Icinga Web 2 PHP library +Group: Development/Libraries +Requires: %{php} >= 5.3.0 +%{?suse_version:Requires: %{php}-gettext %{php}-openssl} %description -n php-Icinga Icinga Web 2 PHP library %package -n icingacli -Summary: Icinga CLI -Group: Applications/System -Requires: %{name}-common = %{version}-%{release} -Requires: php-Icinga = %{version}-%{release} -Requires: %{php_cli} >= 5.3.0 -%{?rhel:Requires: bash-completion} +Summary: Icinga CLI +Group: Applications/System +Requires: %{name}-common = %{version}-%{release} +Requires: php-Icinga = %{version}-%{release} +%{?suse_version:Requires: %{php} >= 5.3.0} +%{?rhel:Requires: %{php_cli} >= 5.3.0} +%{?rhel:Requires: bash-completion} %description -n icingacli Icinga CLI @@ -168,7 +184,11 @@ cp -prv etc/schema %{buildroot}/%{_datadir}/doc/%{name} %pre getent group icingacmd >/dev/null || groupadd -r icingacmd +%if 0%{?suse_version} +usermod -G icingacmd,%{icingawebgroup} %{wwwuser} +%else usermod -a -G icingacmd,%{icingawebgroup} %{wwwuser} +%endif exit 0 %clean From 35e090c17eef7e2525c97e7061b207e063f16ff4 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Fri, 16 Jan 2015 13:12:10 +0100 Subject: [PATCH 0178/2920] monitoring: Support format query parameters for process/info --- .../monitoring/application/controllers/ProcessController.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/modules/monitoring/application/controllers/ProcessController.php b/modules/monitoring/application/controllers/ProcessController.php index 62334d7e8..bb5a4e5c2 100644 --- a/modules/monitoring/application/controllers/ProcessController.php +++ b/modules/monitoring/application/controllers/ProcessController.php @@ -64,8 +64,9 @@ class Monitoring_ProcessController extends Controller 'process_performance_data' ) ) - ->getQuery() - ->fetchRow(); + ->getQuery(); + $this->handleFormatRequest($programStatus); + $programStatus = $programStatus->fetchRow(); if ($programStatus === false) { return $this->render('not-running', true, null); } From e93e8f633045d7fd0f844e797848d4d6fe32ca9e Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Fri, 16 Jan 2015 13:13:13 +0100 Subject: [PATCH 0179/2920] setup: Convert octal directory mode to decimal notation PHP's chmod sets wrong permissions when using 2770 as directory mode for example. fixes #8233 --- modules/setup/library/Setup/Utils/MakeDirStep.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/setup/library/Setup/Utils/MakeDirStep.php b/modules/setup/library/Setup/Utils/MakeDirStep.php index b758ccd79..27919820b 100644 --- a/modules/setup/library/Setup/Utils/MakeDirStep.php +++ b/modules/setup/library/Setup/Utils/MakeDirStep.php @@ -16,12 +16,12 @@ class MakeDirStep extends Step /** * @param array $paths - * @param int $dirmode + * @param int $dirmode Directory mode in octal notation */ public function __construct($paths, $dirmode) { $this->paths = $paths; - $this->dirmode = $dirmode; + $this->dirmode = octdec($dirmode); $this->errors = array(); } From a6861789bb668877fb4a1101ab3dcb97fe4a80bf Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Fri, 16 Jan 2015 17:00:44 +0100 Subject: [PATCH 0180/2920] lib: Remove superfluous return false from IdoQuery --- .../monitoring/library/Monitoring/Backend/Ido/Query/IdoQuery.php | 1 - 1 file changed, 1 deletion(-) diff --git a/modules/monitoring/library/Monitoring/Backend/Ido/Query/IdoQuery.php b/modules/monitoring/library/Monitoring/Backend/Ido/Query/IdoQuery.php index 4682487d2..0b505cd73 100644 --- a/modules/monitoring/library/Monitoring/Backend/Ido/Query/IdoQuery.php +++ b/modules/monitoring/library/Monitoring/Backend/Ido/Query/IdoQuery.php @@ -292,7 +292,6 @@ abstract class IdoQuery extends DbQuery $mapped = $this->getMappedField($field); if ($mapped === null) { return stripos($field, 'UNIX_TIMESTAMP') !== false; - return false; } return stripos($mapped, 'UNIX_TIMESTAMP') !== false; } From dae3ccd90cf040fc4add11b12e51049491affbce Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Fri, 16 Jan 2015 17:02:35 +0100 Subject: [PATCH 0181/2920] monitoring: Take status_update_time into account when is_currently_running is 1 fixes #8210 --- .../Backend/Ido/Query/ProgramstatusQuery.php | 26 +++++++++++++------ 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/modules/monitoring/library/Monitoring/Backend/Ido/Query/ProgramstatusQuery.php b/modules/monitoring/library/Monitoring/Backend/Ido/Query/ProgramstatusQuery.php index e6abd4f77..989c2b698 100644 --- a/modules/monitoring/library/Monitoring/Backend/Ido/Query/ProgramstatusQuery.php +++ b/modules/monitoring/library/Monitoring/Backend/Ido/Query/ProgramstatusQuery.php @@ -11,17 +11,27 @@ class ProgramstatusQuery extends IdoQuery { protected $columnMap = array( 'programstatus' => array( - 'id' => 'programstatus_id', - 'status_update_time' => 'UNIX_TIMESTAMP(status_update_time)', - 'program_start_time' => 'UNIX_TIMESTAMP(program_start_time)', - 'program_end_time' => 'UNIX_TIMESTAMP(program_end_time)', - 'is_currently_running' => 'is_currently_running', + 'id' => 'programstatus_id', + 'status_update_time' => 'UNIX_TIMESTAMP(programstatus.status_update_time)', + 'program_start_time' => 'UNIX_TIMESTAMP(programstatus.program_start_time)', + 'program_end_time' => 'UNIX_TIMESTAMP(programstatus.program_end_time)', + 'is_currently_running' => 'CASE WHEN (programstatus.is_currently_running = 0) + THEN + 0 + ELSE + CASE WHEN (UNIX_TIMESTAMP(programstatus.status_update_time) + 60 > UNIX_TIMESTAMP(NOW())) + THEN + 1 + ELSE + 0 + END + END', 'process_id' => 'process_id', 'daemon_mode' => 'daemon_mode', - 'last_command_check' => 'UNIX_TIMESTAMP(last_command_check)', - 'last_log_rotation' => 'UNIX_TIMESTAMP(last_log_rotation)', + 'last_command_check' => 'UNIX_TIMESTAMP(programstatus.last_command_check)', + 'last_log_rotation' => 'UNIX_TIMESTAMP(programstatus.last_log_rotation)', 'notifications_enabled' => 'notifications_enabled', - 'disable_notif_expire_time' => 'UNIX_TIMESTAMP(disable_notif_expire_time)', + 'disable_notif_expire_time' => 'UNIX_TIMESTAMP(programstatus.disable_notif_expire_time)', 'active_service_checks_enabled' => 'active_service_checks_enabled', 'passive_service_checks_enabled' => 'passive_service_checks_enabled', 'active_host_checks_enabled' => 'active_host_checks_enabled', From 09d5ec6b7a097fcc65a32e8c9272440c64b52882 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Fri, 16 Jan 2015 17:05:50 +0100 Subject: [PATCH 0182/2920] postgres: Return 0 if a timestamp looks like the default timestamp The PostgreSQL IDO schema sets the default value for timestamps with time zone to the epoch time w/o giving the time zone +00. Thus default timestamps are always wrong when using a time zone other than 'UTC'. refs #7919 --- .../library/Monitoring/Backend/Ido/Query/IdoQuery.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/modules/monitoring/library/Monitoring/Backend/Ido/Query/IdoQuery.php b/modules/monitoring/library/Monitoring/Backend/Ido/Query/IdoQuery.php index 0b505cd73..f2e5bd15f 100644 --- a/modules/monitoring/library/Monitoring/Backend/Ido/Query/IdoQuery.php +++ b/modules/monitoring/library/Monitoring/Backend/Ido/Query/IdoQuery.php @@ -323,6 +323,11 @@ abstract class IdoQuery extends DbQuery foreach ($columns as $key => & $value) { $value = preg_replace('/ COLLATE .+$/', '', $value); $value = preg_replace('/inet_aton\(([[:word:].]+)\)/i', '$1::inet - \'0.0.0.0\'', $value); + $value = preg_replace( + '/(UNIX_TIMESTAMP(\((?>[^()]|(?-1))*\)))/i', + 'CASE WHEN ($1 = EXTRACT(TIMEZONE FROM NOW()) * -1) THEN 0 ELSE $1 END', + $value + ); } } } From bab92b1b16bfec9fd7bae6b3783b163cbf4196b4 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Fri, 16 Jan 2015 17:38:22 +0100 Subject: [PATCH 0183/2920] rpm: Use a macro for the docs directory refs #4075 --- icingaweb2.spec | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/icingaweb2.spec b/icingaweb2.spec index b77f42d86..4fa670333 100644 --- a/icingaweb2.spec +++ b/icingaweb2.spec @@ -64,6 +64,7 @@ Icinga Web 2 %define logdir %{_localstatedir}/log/%{name} %define phpdir %{_datadir}/php %define icingawebgroup icingaweb2 +%define docsdir %{_datadir}/doc/%{name} %package common @@ -170,7 +171,7 @@ Icinga Web 2 vendor library Zend %install rm -rf %{buildroot} -mkdir -p %{buildroot}/{%{basedir}/{modules,library,public},%{bindir},%{configdir},%{logdir},%{phpdir},%{wwwconfigdir},%{_sysconfdir}/bash_completion.d,%{_datadir}/doc/%{name}} +mkdir -p %{buildroot}/{%{basedir}/{modules,library,public},%{bindir},%{configdir},%{logdir},%{phpdir},%{wwwconfigdir},%{_sysconfdir}/bash_completion.d,%{docsdir}} cp -prv application doc %{buildroot}/%{basedir} cp -pv etc/bash_completion.d/icingacli %{buildroot}/%{_sysconfdir}/bash_completion.d/icingacli cp -prv modules/{monitoring,setup} %{buildroot}/%{basedir}/modules @@ -180,7 +181,7 @@ cp -prv public/{css,img,js,error_norewrite.html} %{buildroot}/%{basedir}/public cp -pv packages/files/apache/icingaweb2.conf %{buildroot}/%{wwwconfigdir}/icingaweb2.conf cp -pv packages/files/bin/icingacli %{buildroot}/%{bindir} cp -pv packages/files/public/index.php %{buildroot}/%{basedir}/public -cp -prv etc/schema %{buildroot}/%{_datadir}/doc/%{name} +cp -prv etc/schema %{buildroot}/%{docsdir} %pre getent group icingacmd >/dev/null || groupadd -r icingacmd @@ -206,8 +207,8 @@ rm -rf %{buildroot} %{basedir}/public %{wwwconfigdir}/icingaweb2.conf %attr(2775,root,%{icingawebgroup}) %dir %{logdir} -%{_datadir}/doc/%{name} -%docdir %{_datadir}/doc/%{name} +%{docsdir} +%docdir %{docsdir} %pre common From 970006838cb2791091dfb2632b1c7eea9d4a243f Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Mon, 19 Jan 2015 10:49:02 +0100 Subject: [PATCH 0184/2920] Replace t() and mt() with translate() in the monitoring module's forms refs #7551 --- .../DisableNotificationsExpireCommandForm.php | 11 ++-- .../ToggleInstanceFeaturesCommandForm.php | 28 +++++----- .../Object/AcknowledgeProblemCommandForm.php | 34 ++++++------ .../Command/Object/AddCommentCommandForm.php | 13 ++--- .../Command/Object/CheckNowCommandForm.php | 4 +- .../Object/DeleteCommentCommandForm.php | 4 +- .../Object/DeleteDowntimeCommandForm.php | 4 +- .../Object/ProcessCheckResultCommandForm.php | 30 +++++------ .../Object/ScheduleHostCheckCommandForm.php | 5 +- .../ScheduleHostDowntimeCommandForm.php | 16 +++--- .../ScheduleServiceCheckCommandForm.php | 17 +++--- .../ScheduleServiceDowntimeCommandForm.php | 34 ++++++------ .../ToggleObjectFeaturesCommandForm.php | 16 +++--- .../Config/Instance/LocalInstanceForm.php | 4 +- .../Config/Instance/RemoteInstanceForm.php | 16 +++--- .../RemoteInstanceKeyResourcePage.php | 54 +++++++++++++++++++ .../forms/Config/InstanceConfigForm.php | 34 ++++++------ .../forms/Config/SecurityConfigForm.php | 8 +-- .../application/forms/EventOverviewForm.php | 10 ++-- .../application/forms/Setup/BackendPage.php | 15 +++--- .../forms/Setup/IdoResourcePage.php | 11 ++-- .../application/forms/Setup/InstancePage.php | 5 +- .../forms/Setup/LivestatusResourcePage.php | 11 ++-- .../application/forms/Setup/SecurityPage.php | 5 +- .../application/forms/Setup/WelcomePage.php | 10 ++-- .../application/forms/StatehistoryForm.php | 42 +++++++-------- 26 files changed, 237 insertions(+), 204 deletions(-) create mode 100644 modules/monitoring/application/forms/Config/Instance/RemoteInstanceKeyResourcePage.php diff --git a/modules/monitoring/application/forms/Command/Instance/DisableNotificationsExpireCommandForm.php b/modules/monitoring/application/forms/Command/Instance/DisableNotificationsExpireCommandForm.php index 0e64a4b03..21d926b58 100644 --- a/modules/monitoring/application/forms/Command/Instance/DisableNotificationsExpireCommandForm.php +++ b/modules/monitoring/application/forms/Command/Instance/DisableNotificationsExpireCommandForm.php @@ -21,7 +21,7 @@ class DisableNotificationsExpireCommandForm extends CommandForm */ public function init() { - $this->setSubmitLabel(mt('monitoring', 'Disable Notifications')); + $this->setSubmitLabel($this->translate('Disable Notifications')); } /** @@ -30,8 +30,7 @@ class DisableNotificationsExpireCommandForm extends CommandForm */ public function getHelp() { - return mt( - 'monitoring', + return $this->translate( 'This command is used to disable host and service notifications for a specific time.' ); } @@ -49,8 +48,8 @@ class DisableNotificationsExpireCommandForm extends CommandForm 'expire_time', array( 'required' => true, - 'label' => mt('monitoring', 'Expire Time'), - 'description' => mt('monitoring', 'Set the expire time.'), + 'label' => $this->translate('Expire Time'), + 'description' => $this->translate('Set the expire time.'), 'value' => $expireTime ) ); @@ -67,7 +66,7 @@ class DisableNotificationsExpireCommandForm extends CommandForm $disableNotifications ->setExpireTime($this->getElement('expire_time')->getValue()->getTimestamp()); $this->getTransport($this->request)->send($disableNotifications); - Notification::success(mt('monitoring', 'Disabling host and service notifications..')); + Notification::success($this->translate('Disabling host and service notifications..')); return true; } } diff --git a/modules/monitoring/application/forms/Command/Instance/ToggleInstanceFeaturesCommandForm.php b/modules/monitoring/application/forms/Command/Instance/ToggleInstanceFeaturesCommandForm.php index 291619b2f..469c1b6eb 100644 --- a/modules/monitoring/application/forms/Command/Instance/ToggleInstanceFeaturesCommandForm.php +++ b/modules/monitoring/application/forms/Command/Instance/ToggleInstanceFeaturesCommandForm.php @@ -61,13 +61,13 @@ class ToggleInstanceFeaturesCommandForm extends CommandForm if ((bool) $this->status->notifications_enabled) { $notificationDescription = sprintf( '%s', - mt('monitoring', 'Disable notifications for a specific time on a program-wide basis'), + $this->translate('Disable notifications for a specific time on a program-wide basis'), $this->getView()->href('monitoring/process/disable-notifications'), - mt('monitoring', 'Disable temporarily') + $this->translate('Disable temporarily') ); } elseif ($this->status->disable_notif_expire_time) { $notificationDescription = sprintf( - mt('monitoring', 'Notifications will be re-enabled in %s'), + $this->translate('Notifications will be re-enabled in %s'), $this->getView()->timeUntil($this->status->disable_notif_expire_time) ); } else { @@ -78,7 +78,7 @@ class ToggleInstanceFeaturesCommandForm extends CommandForm 'checkbox', ToggleInstanceFeatureCommand::FEATURE_ACTIVE_HOST_CHECKS, array( - 'label' => mt('monitoring', 'Active Host Checks Being Executed'), + 'label' => $this->translate('Active Host Checks Being Executed'), 'autosubmit' => true ) ), @@ -86,7 +86,7 @@ class ToggleInstanceFeaturesCommandForm extends CommandForm 'checkbox', ToggleInstanceFeatureCommand::FEATURE_ACTIVE_SERVICE_CHECKS, array( - 'label' => mt('monitoring', 'Active Service Checks Being Executed'), + 'label' => $this->translate('Active Service Checks Being Executed'), 'autosubmit' => true ) ), @@ -94,7 +94,7 @@ class ToggleInstanceFeaturesCommandForm extends CommandForm 'checkbox', ToggleInstanceFeatureCommand::FEATURE_EVENT_HANDLERS, array( - 'label' => mt('monitoring', 'Event Handlers Enabled'), + 'label' => $this->translate('Event Handlers Enabled'), 'autosubmit' => true ) ), @@ -102,7 +102,7 @@ class ToggleInstanceFeaturesCommandForm extends CommandForm 'checkbox', ToggleInstanceFeatureCommand::FEATURE_FLAP_DETECTION, array( - 'label' => mt('monitoring', 'Flap Detection Enabled'), + 'label' => $this->translate('Flap Detection Enabled'), 'autosubmit' => true ) ), @@ -110,7 +110,7 @@ class ToggleInstanceFeaturesCommandForm extends CommandForm 'checkbox', ToggleInstanceFeatureCommand::FEATURE_NOTIFICATIONS, array( - 'label' => mt('monitoring', 'Notifications Enabled'), + 'label' => $this->translate('Notifications Enabled'), 'autosubmit' => true, 'description' => $notificationDescription, 'decorators' => array( @@ -129,7 +129,7 @@ class ToggleInstanceFeaturesCommandForm extends CommandForm 'checkbox', ToggleInstanceFeatureCommand::FEATURE_HOST_OBSESSING, array( - 'label' => mt('monitoring', 'Obsessing Over Hosts'), + 'label' => $this->translate('Obsessing Over Hosts'), 'autosubmit' => true ) ), @@ -137,7 +137,7 @@ class ToggleInstanceFeaturesCommandForm extends CommandForm 'checkbox', ToggleInstanceFeatureCommand::FEATURE_SERVICE_OBSESSING, array( - 'label' => mt('monitoring', 'Obsessing Over Services'), + 'label' => $this->translate('Obsessing Over Services'), 'autosubmit' => true ) ), @@ -145,7 +145,7 @@ class ToggleInstanceFeaturesCommandForm extends CommandForm 'checkbox', ToggleInstanceFeatureCommand::FEATURE_PASSIVE_HOST_CHECKS, array( - 'label' => mt('monitoring', 'Passive Host Checks Being Accepted'), + 'label' => $this->translate('Passive Host Checks Being Accepted'), 'autosubmit' => true ) ), @@ -153,7 +153,7 @@ class ToggleInstanceFeaturesCommandForm extends CommandForm 'checkbox', ToggleInstanceFeatureCommand::FEATURE_PASSIVE_SERVICE_CHECKS, array( - 'label' => mt('monitoring', 'Passive Service Checks Being Accepted'), + 'label' => $this->translate('Passive Service Checks Being Accepted'), 'autosubmit' => true ) ), @@ -161,7 +161,7 @@ class ToggleInstanceFeaturesCommandForm extends CommandForm 'checkbox', ToggleInstanceFeatureCommand::FEATURE_PERFORMANCE_DATA, array( - 'label' => mt('monitoring', 'Performance Data Being Processed'), + 'label' => $this->translate('Performance Data Being Processed'), 'autosubmit' => true ) ) @@ -198,7 +198,7 @@ class ToggleInstanceFeaturesCommandForm extends CommandForm ->setEnabled($enabled); $this->getTransport($this->request)->send($toggleFeature); } - Notification::success(mt('monitoring', 'Toggling feature..')); + Notification::success($this->translate('Toggling feature..')); return true; } } diff --git a/modules/monitoring/application/forms/Command/Object/AcknowledgeProblemCommandForm.php b/modules/monitoring/application/forms/Command/Object/AcknowledgeProblemCommandForm.php index 25ac76c25..df3731837 100644 --- a/modules/monitoring/application/forms/Command/Object/AcknowledgeProblemCommandForm.php +++ b/modules/monitoring/application/forms/Command/Object/AcknowledgeProblemCommandForm.php @@ -31,8 +31,7 @@ class AcknowledgeProblemCommandForm extends ObjectsCommandForm */ public function getHelp() { - return mt( - 'monitoring', + return $this->translate( 'This command is used to acknowledge host or service problems. When a problem is acknowledged,' . ' future notifications about problems are temporarily disabled until the host or service' . ' recovers.' @@ -51,9 +50,8 @@ class AcknowledgeProblemCommandForm extends ObjectsCommandForm 'comment', array( 'required' => true, - 'label' => mt('monitoring', 'Comment'), - 'description' => mt( - 'monitoring', + 'label' => $this->translate('Comment'), + 'description' => $this->translate( 'If you work with other administrators, you may find it useful to share information about the' . ' the host or service that is having problems. Make sure you enter a brief description of' . ' what you are doing.' @@ -64,9 +62,8 @@ class AcknowledgeProblemCommandForm extends ObjectsCommandForm 'checkbox', 'persistent', array( - 'label' => mt('monitoring', 'Persistent Comment'), - 'description' => mt( - 'monitoring', + 'label' => $this->translate('Persistent Comment'), + 'description' => $this->translate( 'If you would like the comment to remain even when the acknowledgement is removed, check this' . ' option.' ) @@ -76,8 +73,10 @@ class AcknowledgeProblemCommandForm extends ObjectsCommandForm 'checkbox', 'expire', array( - 'label' => mt('monitoring', 'Use Expire Time'), - 'description' => mt('monitoring', 'If the acknowledgement should expire, check this option.'), + 'label' => $this->translate('Use Expire Time'), + 'description' => $this->translate( + 'If the acknowledgement should expire, check this option.' + ), 'autosubmit' => true ) ) @@ -89,10 +88,9 @@ class AcknowledgeProblemCommandForm extends ObjectsCommandForm 'dateTimePicker', 'expire_time', array( - 'label' => mt('monitoring', 'Expire Time'), + 'label' => $this->translate('Expire Time'), 'value' => $expireTime, - 'description' => mt( - 'monitoring', + 'description' => $this->translate( 'Enter the expire date and time for this acknowledgement here. Icinga will delete the' . ' acknowledgement after this time expired.' ) @@ -114,10 +112,9 @@ class AcknowledgeProblemCommandForm extends ObjectsCommandForm 'checkbox', 'sticky', array( - 'label' => mt('monitoring', 'Sticky Acknowledgement'), + 'label' => $this->translate('Sticky Acknowledgement'), 'value' => true, - 'description' => mt( - 'monitoring', + 'description' => $this->translate( 'If you want the acknowledgement to disable notifications until the host or service recovers,' . ' check this option.' ) @@ -127,10 +124,9 @@ class AcknowledgeProblemCommandForm extends ObjectsCommandForm 'checkbox', 'notify', array( - 'label' => mt('monitoring', 'Send Notification'), + 'label' => $this->translate('Send Notification'), 'value' => true, - 'description' => mt( - 'monitoring', + 'description' => $this->translate( 'If you do not want an acknowledgement notification to be sent out to the appropriate contacts,' . ' uncheck this option.' ) diff --git a/modules/monitoring/application/forms/Command/Object/AddCommentCommandForm.php b/modules/monitoring/application/forms/Command/Object/AddCommentCommandForm.php index f5adf6c71..e7f7e91f9 100644 --- a/modules/monitoring/application/forms/Command/Object/AddCommentCommandForm.php +++ b/modules/monitoring/application/forms/Command/Object/AddCommentCommandForm.php @@ -29,8 +29,7 @@ class AddCommentCommandForm extends ObjectsCommandForm */ public function getHelp() { - return mt( - 'monitoring', + return $this->translate( 'This command is used to add host or service comments.' ); } @@ -47,9 +46,8 @@ class AddCommentCommandForm extends ObjectsCommandForm 'comment', array( 'required' => true, - 'label' => mt('monitoring', 'Comment'), - 'description' => mt( - 'monitoring', + 'label' => $this->translate('Comment'), + 'description' => $this->translate( 'If you work with other administrators, you may find it useful to share information about the' . ' the host or service that is having problems. Make sure you enter a brief description of' . ' what you are doing.' @@ -60,10 +58,9 @@ class AddCommentCommandForm extends ObjectsCommandForm 'checkbox', 'persistent', array( - 'label' => mt('monitoring', 'Persistent'), + 'label' => $this->translate('Persistent'), 'value' => true, - 'description' => mt( - 'monitoring', + 'description' => $this->translate( 'If you uncheck this option, the comment will automatically be deleted the next time Icinga is' . ' restarted.' ) diff --git a/modules/monitoring/application/forms/Command/Object/CheckNowCommandForm.php b/modules/monitoring/application/forms/Command/Object/CheckNowCommandForm.php index 01006683f..1054aae05 100644 --- a/modules/monitoring/application/forms/Command/Object/CheckNowCommandForm.php +++ b/modules/monitoring/application/forms/Command/Object/CheckNowCommandForm.php @@ -35,8 +35,8 @@ class CheckNowCommandForm extends ObjectsCommandForm array( 'ignore' => true, 'type' => 'submit', - 'value' => mt('monitoring', 'Check now'), - 'label' => ' ' . mt('monitoring', 'Check now'), + 'value' => $this->translate('Check now'), + 'label' => ' ' . $this->translate('Check now'), 'decorators' => array('ViewHelper'), 'escape' => false, 'class' => 'link-like' diff --git a/modules/monitoring/application/forms/Command/Object/DeleteCommentCommandForm.php b/modules/monitoring/application/forms/Command/Object/DeleteCommentCommandForm.php index 3d85afcec..0f7858ad9 100644 --- a/modules/monitoring/application/forms/Command/Object/DeleteCommentCommandForm.php +++ b/modules/monitoring/application/forms/Command/Object/DeleteCommentCommandForm.php @@ -55,7 +55,7 @@ class DeleteCommentCommandForm extends ObjectsCommandForm array( 'ignore' => true, 'label' => 'X', - 'title' => mt('monitoring', 'Delete comment'), + 'title' => $this->translate('Delete comment'), 'decorators' => array('ViewHelper') ) ); @@ -80,7 +80,7 @@ class DeleteCommentCommandForm extends ObjectsCommandForm if (! empty($redirect)) { $this->setRedirectUrl($redirect); } - Notification::success(mt('monitoring', 'Deleting comment..')); + Notification::success($this->translate('Deleting comment..')); return true; } } diff --git a/modules/monitoring/application/forms/Command/Object/DeleteDowntimeCommandForm.php b/modules/monitoring/application/forms/Command/Object/DeleteDowntimeCommandForm.php index 1c7095b82..43ca52b05 100644 --- a/modules/monitoring/application/forms/Command/Object/DeleteDowntimeCommandForm.php +++ b/modules/monitoring/application/forms/Command/Object/DeleteDowntimeCommandForm.php @@ -55,7 +55,7 @@ class DeleteDowntimeCommandForm extends ObjectsCommandForm array( 'ignore' => true, 'label' => 'X', - 'title' => mt('monitoring', 'Delete downtime'), + 'title' => $this->translate('Delete downtime'), 'decorators' => array('ViewHelper') ) ); @@ -80,7 +80,7 @@ class DeleteDowntimeCommandForm extends ObjectsCommandForm if (! empty($redirect)) { $this->setRedirectUrl($redirect); } - Notification::success(mt('monitoring', 'Deleting downtime..')); + Notification::success($this->translate('Deleting downtime..')); return true; } } diff --git a/modules/monitoring/application/forms/Command/Object/ProcessCheckResultCommandForm.php b/modules/monitoring/application/forms/Command/Object/ProcessCheckResultCommandForm.php index 48ee00ab3..44e248956 100644 --- a/modules/monitoring/application/forms/Command/Object/ProcessCheckResultCommandForm.php +++ b/modules/monitoring/application/forms/Command/Object/ProcessCheckResultCommandForm.php @@ -29,8 +29,7 @@ class ProcessCheckResultCommandForm extends ObjectsCommandForm */ public function getHelp() { - return mt( - 'monitoring', + return $this->translate( 'This command is used to submit passive host or service check results.' ); } @@ -53,17 +52,17 @@ class ProcessCheckResultCommandForm extends ObjectsCommandForm 'status', array( 'required' => true, - 'label' => mt('monitoring', 'Status'), - 'description' => mt('monitoring', 'The state this check result should report'), + 'label' => $this->translate('Status'), + 'description' => $this->translate('The state this check result should report'), 'multiOptions' => $object->getType() === $object::TYPE_HOST ? array( - ProcessCheckResultCommand::HOST_UP => mt('monitoring', 'UP', 'icinga.state'), - ProcessCheckResultCommand::HOST_DOWN => mt('monitoring', 'DOWN', 'icinga.state'), - ProcessCheckResultCommand::HOST_UNREACHABLE => mt('monitoring', 'UNREACHABLE', 'icinga.state') + ProcessCheckResultCommand::HOST_UP => $this->translate('UP', 'icinga.state'), + ProcessCheckResultCommand::HOST_DOWN => $this->translate('DOWN', 'icinga.state'), + ProcessCheckResultCommand::HOST_UNREACHABLE => $this->translate('UNREACHABLE', 'icinga.state') ) : array( - ProcessCheckResultCommand::SERVICE_OK => mt('monitoring', 'OK', 'icinga.state'), - ProcessCheckResultCommand::SERVICE_WARNING => mt('monitoring', 'WARNING', 'icinga.state'), - ProcessCheckResultCommand::SERVICE_CRITICAL => mt('monitoring', 'CRITICAL', 'icinga.state'), - ProcessCheckResultCommand::SERVICE_UNKNOWN => mt('monitoring', 'UNKNOWN', 'icinga.state') + ProcessCheckResultCommand::SERVICE_OK => $this->translate('OK', 'icinga.state'), + ProcessCheckResultCommand::SERVICE_WARNING => $this->translate('WARNING', 'icinga.state'), + ProcessCheckResultCommand::SERVICE_CRITICAL => $this->translate('CRITICAL', 'icinga.state'), + ProcessCheckResultCommand::SERVICE_UNKNOWN => $this->translate('UNKNOWN', 'icinga.state') ) ) ); @@ -72,8 +71,8 @@ class ProcessCheckResultCommandForm extends ObjectsCommandForm 'output', array( 'required' => true, - 'label' => mt('monitoring', 'Output'), - 'description' => mt('monitoring', 'The plugin output of this check result') + 'label' => $this->translate('Output'), + 'description' => $this->translate('The plugin output of this check result') ) ); $this->addElement( @@ -81,9 +80,8 @@ class ProcessCheckResultCommandForm extends ObjectsCommandForm 'perfdata', array( 'allowEmpty' => true, - 'label' => mt('monitoring', 'Performance Data'), - 'description' => mt( - 'monitoring', + 'label' => $this->translate('Performance Data'), + 'description' => $this->translate( 'The performance data of this check result. Leave empty' . ' if this check result has no performance data' ) diff --git a/modules/monitoring/application/forms/Command/Object/ScheduleHostCheckCommandForm.php b/modules/monitoring/application/forms/Command/Object/ScheduleHostCheckCommandForm.php index 82a9b2e52..949ec33e1 100644 --- a/modules/monitoring/application/forms/Command/Object/ScheduleHostCheckCommandForm.php +++ b/modules/monitoring/application/forms/Command/Object/ScheduleHostCheckCommandForm.php @@ -24,9 +24,8 @@ class ScheduleHostCheckCommandForm extends ScheduleServiceCheckCommandForm 'checkbox', 'all_services', array( - 'label' => mt('monitoring', 'All Services'), - 'description' => mt( - 'monitoring', + 'label' => $this->translate('All Services'), + 'description' => $this->translate( 'Schedule check for all services on the hosts and the hosts themselves.' ) ) diff --git a/modules/monitoring/application/forms/Command/Object/ScheduleHostDowntimeCommandForm.php b/modules/monitoring/application/forms/Command/Object/ScheduleHostDowntimeCommandForm.php index beb0793ef..f84069a9a 100644 --- a/modules/monitoring/application/forms/Command/Object/ScheduleHostDowntimeCommandForm.php +++ b/modules/monitoring/application/forms/Command/Object/ScheduleHostDowntimeCommandForm.php @@ -27,9 +27,8 @@ class ScheduleHostDowntimeCommandForm extends ScheduleServiceDowntimeCommandForm 'checkbox', 'all_services', array( - 'label' => mt('monitoring', 'All Services'), - 'description' => mt( - 'monitoring', + 'label' => $this->translate('All Services'), + 'description' => $this->translate( 'Schedule downtime for all services on the hosts and the hosts themselves.' ) ) @@ -38,15 +37,14 @@ class ScheduleHostDowntimeCommandForm extends ScheduleServiceDowntimeCommandForm 'select', 'child_hosts', array( - 'label' => mt('monitoring', 'Child Hosts'), + 'label' => $this->translate('Child Hosts'), 'required' => true, 'multiOptions' => array( - 0 => mt('monitoring', 'Do nothing with child hosts'), - 1 => mt('monitoring', 'Schedule triggered downtime for all child hosts'), - 2 => mt('monitoring', 'Schedule non-triggered downtime for all child hosts') + 0 => $this->translate('Do nothing with child hosts'), + 1 => $this->translate('Schedule triggered downtime for all child hosts'), + 2 => $this->translate('Schedule non-triggered downtime for all child hosts') ), - 'description' => mt( - 'monitoring', + 'description' => $this->translate( 'Define what should be done with the child hosts of the hosts.' ) ) diff --git a/modules/monitoring/application/forms/Command/Object/ScheduleServiceCheckCommandForm.php b/modules/monitoring/application/forms/Command/Object/ScheduleServiceCheckCommandForm.php index 9e04a2254..b34472d49 100644 --- a/modules/monitoring/application/forms/Command/Object/ScheduleServiceCheckCommandForm.php +++ b/modules/monitoring/application/forms/Command/Object/ScheduleServiceCheckCommandForm.php @@ -32,8 +32,7 @@ class ScheduleServiceCheckCommandForm extends ObjectsCommandForm */ public function getHelp() { - return mt( - 'monitoring', + return $this->translate( 'This command is used to schedule the next check of hosts or services. Icinga will re-queue the' . ' hosts or services to be checked at the time you specify.' ); @@ -52,8 +51,7 @@ class ScheduleServiceCheckCommandForm extends ObjectsCommandForm 'note', 'command-info', array( - 'value' => mt( - 'monitoring', + 'value' => $this->translate( 'This command is used to schedule the next check of hosts or services. Icinga will re-queue the' . ' hosts or services to be checked at the time you specify.' ) @@ -64,8 +62,10 @@ class ScheduleServiceCheckCommandForm extends ObjectsCommandForm 'check_time', array( 'required' => true, - 'label' => mt('monitoring', 'Check Time'), - 'description' => mt('monitoring', 'Set the date and time when the check should be scheduled.'), + 'label' => $this->translate('Check Time'), + 'description' => $this->translate( + 'Set the date and time when the check should be scheduled.' + ), 'value' => $checkTime ) ), @@ -73,9 +73,8 @@ class ScheduleServiceCheckCommandForm extends ObjectsCommandForm 'checkbox', 'force_check', array( - 'label' => mt('monitoring', 'Force Check'), - 'description' => mt( - 'monitoring', + 'label' => $this->translate('Force Check'), + 'description' => $this->translate( 'If you select this option, Icinga will force a check regardless of both what time the' . ' scheduled check occurs and whether or not checks are enabled.' ) diff --git a/modules/monitoring/application/forms/Command/Object/ScheduleServiceDowntimeCommandForm.php b/modules/monitoring/application/forms/Command/Object/ScheduleServiceDowntimeCommandForm.php index 9961d4b65..4f66898f6 100644 --- a/modules/monitoring/application/forms/Command/Object/ScheduleServiceDowntimeCommandForm.php +++ b/modules/monitoring/application/forms/Command/Object/ScheduleServiceDowntimeCommandForm.php @@ -42,8 +42,7 @@ class ScheduleServiceDowntimeCommandForm extends ObjectsCommandForm */ public function getHelp() { - return mt( - 'monitoring', + return $this->translate( 'This command is used to schedule host and service downtimes. During the specified downtime,' . ' Icinga will not send notifications out about the hosts and services. When the scheduled' . ' downtime expires, Icinga will send out notifications for the hosts and services as it' @@ -67,9 +66,8 @@ class ScheduleServiceDowntimeCommandForm extends ObjectsCommandForm 'comment', array( 'required' => true, - 'label' => mt('monitoring', 'Comment'), - 'description' => mt( - 'monitoring', + 'label' => $this->translate('Comment'), + 'description' => $this->translate( 'If you work with other administrators, you may find it useful to share information about the' . ' the host or service that is having problems. Make sure you enter a brief description of' . ' what you are doing.' @@ -81,8 +79,8 @@ class ScheduleServiceDowntimeCommandForm extends ObjectsCommandForm 'start', array( 'required' => true, - 'label' => mt('monitoring', 'Start Time'), - 'description' => mt('monitoring', 'Set the start date and time for the downtime.'), + 'label' => $this->translate('Start Time'), + 'description' => $this->translate('Set the start date and time for the downtime.'), 'value' => $start ) ), @@ -91,8 +89,8 @@ class ScheduleServiceDowntimeCommandForm extends ObjectsCommandForm 'end', array( 'required' => true, - 'label' => mt('monitoring', 'End Time'), - 'description' => mt('monitoring', 'Set the end date and time for the downtime.'), + 'label' => $this->translate('End Time'), + 'description' => $this->translate('Set the end date and time for the downtime.'), 'value' => $end ) ), @@ -102,17 +100,16 @@ class ScheduleServiceDowntimeCommandForm extends ObjectsCommandForm array( 'required' => true, 'autosubmit' => true, - 'label' => mt('monitoring', 'Type'), - 'description' => mt( - 'monitoring', + 'label' => $this->translate('Type'), + 'description' => $this->translate( 'If you select the fixed option, the downtime will be in effect between the start and end' . ' times you specify whereas a flexible downtime starts when the host or service enters a' . ' problem state sometime between the start and end times you specified and lasts as long' . ' as the duration time you enter. The duration fields do not apply for fixed downtimes.' ), 'multiOptions' => array( - self::FIXED => mt('monitoring', 'Fixed'), - self::FLEXIBLE => mt('monitoring', 'Flexible') + self::FIXED => $this->translate('Fixed'), + self::FLEXIBLE => $this->translate('Flexible') ), 'validators' => array( array( @@ -141,7 +138,7 @@ class ScheduleServiceDowntimeCommandForm extends ObjectsCommandForm 'hours', array( 'required' => true, - 'label' => mt('monitoring', 'Hours'), + 'label' => $this->translate('Hours'), 'value' => 2, 'min' => -1 ) @@ -151,7 +148,7 @@ class ScheduleServiceDowntimeCommandForm extends ObjectsCommandForm 'minutes', array( 'required' => true, - 'label' => mt('monitoring', 'Minutes'), + 'label' => $this->translate('Minutes'), 'value' => 0, 'min' => -1 ) @@ -161,9 +158,8 @@ class ScheduleServiceDowntimeCommandForm extends ObjectsCommandForm array('hours', 'minutes'), 'duration', array( - 'legend' => mt('monitoring', 'Flexible Duration'), - 'description' => mt( - 'monitoring', + 'legend' => $this->translate('Flexible Duration'), + 'description' => $this->translate( 'Enter here the duration of the downtime. The downtime will be automatically deleted after this' . ' time expired.' ), diff --git a/modules/monitoring/application/forms/Command/Object/ToggleObjectFeaturesCommandForm.php b/modules/monitoring/application/forms/Command/Object/ToggleObjectFeaturesCommandForm.php index c33527895..bf0a1d8b1 100644 --- a/modules/monitoring/application/forms/Command/Object/ToggleObjectFeaturesCommandForm.php +++ b/modules/monitoring/application/forms/Command/Object/ToggleObjectFeaturesCommandForm.php @@ -33,7 +33,7 @@ class ToggleObjectFeaturesCommandForm extends ObjectsCommandForm 'checkbox', ToggleObjectFeatureCommand::FEATURE_ACTIVE_CHECKS, array( - 'label' => mt('monitoring', 'Active Checks'), + 'label' => $this->translate('Active Checks'), 'autosubmit' => true ) ), @@ -41,7 +41,7 @@ class ToggleObjectFeaturesCommandForm extends ObjectsCommandForm 'checkbox', ToggleObjectFeatureCommand::FEATURE_PASSIVE_CHECKS, array( - 'label' => mt('monitoring', 'Passive Checks'), + 'label' => $this->translate('Passive Checks'), 'autosubmit' => true ) ), @@ -49,7 +49,7 @@ class ToggleObjectFeaturesCommandForm extends ObjectsCommandForm 'checkbox', ToggleObjectFeatureCommand::FEATURE_OBSESSING, array( - 'label' => mt('monitoring', 'Obsessing'), + 'label' => $this->translate('Obsessing'), 'autosubmit' => true ) ), @@ -57,7 +57,7 @@ class ToggleObjectFeaturesCommandForm extends ObjectsCommandForm 'checkbox', ToggleObjectFeatureCommand::FEATURE_NOTIFICATIONS, array( - 'label' => mt('monitoring', 'Notifications'), + 'label' => $this->translate('Notifications'), 'autosubmit' => true ) ), @@ -65,7 +65,7 @@ class ToggleObjectFeaturesCommandForm extends ObjectsCommandForm 'checkbox', ToggleObjectFeatureCommand::FEATURE_EVENT_HANDLER, array( - 'label' => mt('monitoring', 'Event Handler'), + 'label' => $this->translate('Event Handler'), 'autosubmit' => true ) ), @@ -73,7 +73,7 @@ class ToggleObjectFeaturesCommandForm extends ObjectsCommandForm 'checkbox', ToggleObjectFeatureCommand::FEATURE_FLAP_DETECTION, array( - 'label' => mt('monitoring', 'Flap Detection'), + 'label' => $this->translate('Flap Detection'), 'autosubmit' => true ) ) @@ -95,7 +95,7 @@ class ToggleObjectFeaturesCommandForm extends ObjectsCommandForm $element = $this->getElement($feature); $element->setChecked($object->{$feature}); if ((bool) $object->{$feature . '_changed'} === true) { - $element->setDescription(mt('monitoring', 'changed')); + $element->setDescription($this->translate('changed')); } } return $this; @@ -120,7 +120,7 @@ class ToggleObjectFeaturesCommandForm extends ObjectsCommandForm } } } - Notification::success(mt('monitoring', 'Toggling feature..')); + Notification::success($this->translate('Toggling feature..')); return true; } } diff --git a/modules/monitoring/application/forms/Config/Instance/LocalInstanceForm.php b/modules/monitoring/application/forms/Config/Instance/LocalInstanceForm.php index daabe7e02..405bac144 100644 --- a/modules/monitoring/application/forms/Config/Instance/LocalInstanceForm.php +++ b/modules/monitoring/application/forms/Config/Instance/LocalInstanceForm.php @@ -28,9 +28,9 @@ class LocalInstanceForm extends Form 'path', array( 'required' => true, - 'label' => mt('monitoring', 'Command File'), + 'label' => $this->translate('Command File'), 'value' => '/var/run/icinga2/cmd/icinga2.cmd', - 'description' => mt('monitoring', 'Path to the local Icinga command file') + 'description' => $this->translate('Path to the local Icinga command file') ) ); return $this; diff --git a/modules/monitoring/application/forms/Config/Instance/RemoteInstanceForm.php b/modules/monitoring/application/forms/Config/Instance/RemoteInstanceForm.php index 7c55f655a..47b2a0316 100644 --- a/modules/monitoring/application/forms/Config/Instance/RemoteInstanceForm.php +++ b/modules/monitoring/application/forms/Config/Instance/RemoteInstanceForm.php @@ -29,8 +29,8 @@ class RemoteInstanceForm extends Form 'host', array( 'required' => true, - 'label' => mt('monitoring', 'Host'), - 'description' => mt('monitoring', + 'label' => $this->translate('Host'), + 'description' => $this->translate( 'Hostname or address of the remote Icinga instance' ) ) @@ -40,8 +40,8 @@ class RemoteInstanceForm extends Form 'port', array( 'required' => true, - 'label' => mt('monitoring', 'Port'), - 'description' => mt('monitoring', 'SSH port to connect to on the remote Icinga instance'), + 'label' => $this->translate('Port'), + 'description' => $this->translate('SSH port to connect to on the remote Icinga instance'), 'value' => 22 ) ), @@ -50,8 +50,8 @@ class RemoteInstanceForm extends Form 'user', array( 'required' => true, - 'label' => mt('monitoring', 'User'), - 'description' => mt('monitoring', + 'label' => $this->translate('User'), + 'description' => $this->translate( 'User to log in as on the remote Icinga instance. Please note that key-based SSH login must be' . ' possible for this user' ) @@ -62,9 +62,9 @@ class RemoteInstanceForm extends Form 'path', array( 'required' => true, - 'label' => mt('monitoring', 'Command File'), + 'label' => $this->translate('Command File'), 'value' => '/var/run/icinga2/cmd/icinga2.cmd', - 'description' => mt('monitoring', 'Path to the Icinga command file on the remote Icinga instance') + 'description' => $this->translate('Path to the Icinga command file on the remote Icinga instance') ) ) )); diff --git a/modules/monitoring/application/forms/Config/Instance/RemoteInstanceKeyResourcePage.php b/modules/monitoring/application/forms/Config/Instance/RemoteInstanceKeyResourcePage.php new file mode 100644 index 000000000..454c67d47 --- /dev/null +++ b/modules/monitoring/application/forms/Config/Instance/RemoteInstanceKeyResourcePage.php @@ -0,0 +1,54 @@ +addElement( + 'button', + Wizard::BTN_NEXT, + array( + 'type' => 'submit', + 'value' => $pageName, + 'label' => $this->translate('Save Changes'), + 'decorators' => array('ViewHelper') + ) + ); + } + + public function addPreviousButton($pageName) + { + + } +} diff --git a/modules/monitoring/application/forms/Config/InstanceConfigForm.php b/modules/monitoring/application/forms/Config/InstanceConfigForm.php index b89e48c0a..5618f27ee 100644 --- a/modules/monitoring/application/forms/Config/InstanceConfigForm.php +++ b/modules/monitoring/application/forms/Config/InstanceConfigForm.php @@ -25,7 +25,7 @@ class InstanceConfigForm extends ConfigForm public function init() { $this->setName('form_config_monitoring_instance'); - $this->setSubmitLabel(mt('monitoring', 'Save Changes')); + $this->setSubmitLabel($this->translate('Save Changes')); } /** @@ -48,7 +48,7 @@ class InstanceConfigForm extends ConfigForm break; default: throw new InvalidArgumentException( - sprintf(mt('monitoring', 'Invalid instance type "%s" given'), $type) + sprintf($this->translate('Invalid instance type "%s" given'), $type) ); } return $form; @@ -69,10 +69,10 @@ class InstanceConfigForm extends ConfigForm { $name = isset($values['name']) ? $values['name'] : ''; if (! $name) { - throw new InvalidArgumentException(mt('monitoring', 'Instance name missing')); + throw new InvalidArgumentException($this->translate('Instance name missing')); } if ($this->config->hasSection($name)) { - throw new InvalidArgumentException(mt('monitoring', 'Instance already exists')); + throw new InvalidArgumentException($this->translate('Instance already exists')); } unset($values['name']); @@ -93,11 +93,11 @@ class InstanceConfigForm extends ConfigForm public function edit($name, array $values) { if (! $name) { - throw new InvalidArgumentException(mt('monitoring', 'Old instance name missing')); + throw new InvalidArgumentException($this->translate('Old instance name missing')); } elseif (! ($newName = isset($values['name']) ? $values['name'] : '')) { - throw new InvalidArgumentException(mt('monitoring', 'New instance name missing')); + throw new InvalidArgumentException($this->translate('New instance name missing')); } elseif (! $this->config->hasSection($name)) { - throw new InvalidArgumentException(mt('monitoring', 'Unknown instance name provided')); + throw new InvalidArgumentException($this->translate('Unknown instance name provided')); } unset($values['name']); @@ -117,9 +117,9 @@ class InstanceConfigForm extends ConfigForm public function remove($name) { if (! $name) { - throw new InvalidArgumentException(mt('monitoring', 'Instance name missing')); + throw new InvalidArgumentException($this->translate('Instance name missing')); } elseif (! $this->config->hasSection($name)) { - throw new InvalidArgumentException(mt('monitoring', 'Unknown instance name provided')); + throw new InvalidArgumentException($this->translate('Unknown instance name provided')); } $instanceConfig = $this->config->getSection($name); @@ -136,10 +136,10 @@ class InstanceConfigForm extends ConfigForm $instanceName = $this->request->getQuery('instance'); if ($instanceName !== null) { if (! $instanceName) { - throw new ConfigurationError(mt('monitoring', 'Instance name missing')); + throw new ConfigurationError($this->translate('Instance name missing')); } if (! $this->config->hasSection($instanceName)) { - throw new ConfigurationError(mt('monitoring', 'Unknown instance name given')); + throw new ConfigurationError($this->translate('Unknown instance name given')); } $instanceConfig = $this->config->getSection($instanceName)->toArray(); @@ -158,10 +158,10 @@ class InstanceConfigForm extends ConfigForm try { if ($instanceName === null) { // create new instance $this->add($this->getValues()); - $message = mt('monitoring', 'Instance "%s" created successfully.'); + $message = $this->translate('Instance "%s" created successfully.'); } else { // edit existing instance $this->edit($instanceName, $this->getValues()); - $message = mt('monitoring', 'Instance "%s" edited successfully.'); + $message = $this->translate('Instance "%s" edited successfully.'); } } catch (InvalidArgumentException $e) { Notification::error($e->getMessage()); @@ -189,7 +189,7 @@ class InstanceConfigForm extends ConfigForm 'name', array( 'required' => true, - 'label' => mt('monitoring', 'Instance Name') + 'label' => $this->translate('Instance Name') ) ), array( @@ -198,10 +198,10 @@ class InstanceConfigForm extends ConfigForm array( 'required' => true, 'autosubmit' => true, - 'label' => mt('monitoring', 'Instance Type'), + 'label' => $this->translate('Instance Type'), 'multiOptions' => array( - LocalCommandFile::TRANSPORT => mt('monitoring', 'Local Command File'), - RemoteCommandFile::TRANSPORT => mt('monitoring', 'Remote Command File') + LocalCommandFile::TRANSPORT => $this->translate('Local Command File'), + RemoteCommandFile::TRANSPORT => $this->translate('Remote Command File') ), 'value' => $instanceType ) diff --git a/modules/monitoring/application/forms/Config/SecurityConfigForm.php b/modules/monitoring/application/forms/Config/SecurityConfigForm.php index 40c0b7b8c..b202f5938 100644 --- a/modules/monitoring/application/forms/Config/SecurityConfigForm.php +++ b/modules/monitoring/application/forms/Config/SecurityConfigForm.php @@ -18,7 +18,7 @@ class SecurityConfigForm extends ConfigForm public function init() { $this->setName('form_config_monitoring_security'); - $this->setSubmitLabel(mt('monitoring', 'Save Changes')); + $this->setSubmitLabel($this->translate('Save Changes')); } /** @@ -29,7 +29,7 @@ class SecurityConfigForm extends ConfigForm $this->config->setSection('security', $this->getValues()); if ($this->save()) { - Notification::success(mt('monitoring', 'New security configuration has successfully been stored')); + Notification::success($this->translate('New security configuration has successfully been stored')); } else { return false; } @@ -54,8 +54,8 @@ class SecurityConfigForm extends ConfigForm array( 'allowEmpty' => true, 'value' => '*pw*,*pass*,community', - 'label' => mt('monitoring', 'Protected Custom Variables'), - 'description' => mt('monitoring', + 'label' => $this->translate('Protected Custom Variables'), + 'description' => $this->translate( 'Comma separated case insensitive list of protected custom variables.' . ' Use * as a placeholder for zero or more wildcard characters.' . ' Existance of those custom variables will be shown, but their values will be masked.' diff --git a/modules/monitoring/application/forms/EventOverviewForm.php b/modules/monitoring/application/forms/EventOverviewForm.php index 25d268f76..dc697b940 100644 --- a/modules/monitoring/application/forms/EventOverviewForm.php +++ b/modules/monitoring/application/forms/EventOverviewForm.php @@ -44,7 +44,7 @@ class EventOverviewForm extends Form 'checkbox', 'statechange', array( - 'label' => t('State Changes'), + 'label' => $this->translate('State Changes'), 'class' => 'autosubmit', 'decorators' => $decorators, 'value' => strpos($url, $this->stateChangeFilter()->toQueryString()) === false ? 0 : 1 @@ -54,7 +54,7 @@ class EventOverviewForm extends Form 'checkbox', 'downtime', array( - 'label' => t('Downtimes'), + 'label' => $this->translate('Downtimes'), 'class' => 'autosubmit', 'decorators' => $decorators, 'value' => strpos($url, $this->downtimeFilter()->toQueryString()) === false ? 0 : 1 @@ -64,7 +64,7 @@ class EventOverviewForm extends Form 'checkbox', 'comment', array( - 'label' => t('Comments'), + 'label' => $this->translate('Comments'), 'class' => 'autosubmit', 'decorators' => $decorators, 'value' => strpos($url, $this->commentFilter()->toQueryString()) === false ? 0 : 1 @@ -74,7 +74,7 @@ class EventOverviewForm extends Form 'checkbox', 'notification', array( - 'label' => t('Notifications'), + 'label' => $this->translate('Notifications'), 'class' => 'autosubmit', 'decorators' => $decorators, 'value' => strpos($url, $this->notificationFilter()->toQueryString()) === false ? 0 : 1 @@ -84,7 +84,7 @@ class EventOverviewForm extends Form 'checkbox', 'flapping', array( - 'label' => t('Flapping'), + 'label' => $this->translate('Flapping'), 'class' => 'autosubmit', 'decorators' => $decorators, 'value' => strpos($url, $this->flappingFilter()->toQueryString()) === false ? 0 : 1 diff --git a/modules/monitoring/application/forms/Setup/BackendPage.php b/modules/monitoring/application/forms/Setup/BackendPage.php index 1f6ef6894..b5ab2ffd6 100644 --- a/modules/monitoring/application/forms/Setup/BackendPage.php +++ b/modules/monitoring/application/forms/Setup/BackendPage.php @@ -20,7 +20,7 @@ class BackendPage extends Form 'note', 'title', array( - 'value' => mt('monitoring', 'Monitoring Backend', 'setup.page.title'), + 'value' => $this->translate('Monitoring Backend', 'setup.page.title'), 'decorators' => array( 'ViewHelper', array('HtmlTag', array('tag' => 'h2')) @@ -31,8 +31,7 @@ class BackendPage extends Form 'note', 'description', array( - 'value' => mt( - 'monitoring', + 'value' => $this->translate( 'Please configure below how Icinga Web 2 should retrieve monitoring information.' ) ) @@ -44,8 +43,8 @@ class BackendPage extends Form array( 'required' => true, 'value' => 'icinga', - 'label' => mt('monitoring', 'Backend Name'), - 'description' => mt('monitoring', 'The identifier of this backend') + 'label' => $this->translate('Backend Name'), + 'description' => $this->translate('The identifier of this backend') ) ); @@ -60,8 +59,10 @@ class BackendPage extends Form 'type', array( 'required' => true, - 'label' => mt('monitoring', 'Backend Type'), - 'description' => mt('monitoring', 'The data source used for retrieving monitoring information'), + 'label' => $this->translate('Backend Type'), + 'description' => $this->translate( + 'The data source used for retrieving monitoring information' + ), 'multiOptions' => $resourceTypes ) ); diff --git a/modules/monitoring/application/forms/Setup/IdoResourcePage.php b/modules/monitoring/application/forms/Setup/IdoResourcePage.php index 189d65fea..c28b52e6b 100644 --- a/modules/monitoring/application/forms/Setup/IdoResourcePage.php +++ b/modules/monitoring/application/forms/Setup/IdoResourcePage.php @@ -28,7 +28,7 @@ class IdoResourcePage extends Form 'note', 'title', array( - 'value' => mt('monitoring', 'Monitoring IDO Resource', 'setup.page.title'), + 'value' => $this->translate('Monitoring IDO Resource', 'setup.page.title'), 'decorators' => array( 'ViewHelper', array('HtmlTag', array('tag' => 'h2')) @@ -39,8 +39,7 @@ class IdoResourcePage extends Form 'note', 'description', array( - 'value' => mt( - 'monitoring', + 'value' => $this->translate( 'Please fill out the connection details below to access' . ' the IDO database of your monitoring environment.' ) @@ -91,8 +90,10 @@ class IdoResourcePage extends Form 'skip_validation', array( 'required' => true, - 'label' => t('Skip Validation'), - 'description' => t('Check this to not to validate connectivity with the given database server') + 'label' => $this->translate('Skip Validation'), + 'description' => $this->translate( + 'Check this to not to validate connectivity with the given database server' + ) ) ); } diff --git a/modules/monitoring/application/forms/Setup/InstancePage.php b/modules/monitoring/application/forms/Setup/InstancePage.php index dccfd1d91..8f151554d 100644 --- a/modules/monitoring/application/forms/Setup/InstancePage.php +++ b/modules/monitoring/application/forms/Setup/InstancePage.php @@ -20,7 +20,7 @@ class InstancePage extends Form 'note', 'title', array( - 'value' => mt('monitoring', 'Monitoring Instance', 'setup.page.title'), + 'value' => $this->translate('Monitoring Instance', 'setup.page.title'), 'decorators' => array( 'ViewHelper', array('HtmlTag', array('tag' => 'h2')) @@ -31,8 +31,7 @@ class InstancePage extends Form 'note', 'description', array( - 'value' => mt( - 'monitoring', + 'value' => $this->translate( 'Please define the settings specific to your monitoring instance below.' ) ) diff --git a/modules/monitoring/application/forms/Setup/LivestatusResourcePage.php b/modules/monitoring/application/forms/Setup/LivestatusResourcePage.php index 4faa17416..245d2abcc 100644 --- a/modules/monitoring/application/forms/Setup/LivestatusResourcePage.php +++ b/modules/monitoring/application/forms/Setup/LivestatusResourcePage.php @@ -28,7 +28,7 @@ class LivestatusResourcePage extends Form 'note', 'title', array( - 'value' => mt('monitoring', 'Monitoring Livestatus Resource', 'setup.page.title'), + 'value' => $this->translate('Monitoring Livestatus Resource', 'setup.page.title'), 'decorators' => array( 'ViewHelper', array('HtmlTag', array('tag' => 'h2')) @@ -39,8 +39,7 @@ class LivestatusResourcePage extends Form 'note', 'description', array( - 'value' => mt( - 'monitoring', + 'value' => $this->translate( 'Please fill out the connection details below to access the Livestatus' . ' socket interface for your monitoring environment.' ) @@ -91,8 +90,10 @@ class LivestatusResourcePage extends Form 'skip_validation', array( 'required' => true, - 'label' => t('Skip Validation'), - 'description' => t('Check this to not to validate connectivity with the given Livestatus socket') + 'label' => $this->translate('Skip Validation'), + 'description' => $this->translate( + 'Check this to not to validate connectivity with the given Livestatus socket' + ) ) ); } diff --git a/modules/monitoring/application/forms/Setup/SecurityPage.php b/modules/monitoring/application/forms/Setup/SecurityPage.php index 0c7d3d1de..ba8083e50 100644 --- a/modules/monitoring/application/forms/Setup/SecurityPage.php +++ b/modules/monitoring/application/forms/Setup/SecurityPage.php @@ -20,7 +20,7 @@ class SecurityPage extends Form 'note', 'title', array( - 'value' => mt('monitoring', 'Monitoring Security', 'setup.page.title'), + 'value' => $this->translate('Monitoring Security', 'setup.page.title'), 'decorators' => array( 'ViewHelper', array('HtmlTag', array('tag' => 'h2')) @@ -31,8 +31,7 @@ class SecurityPage extends Form 'note', 'description', array( - 'value' => mt( - 'monitoring', + 'value' => $this->translate( 'To protect your monitoring environment against prying eyes please fill out the settings below.' ) ) diff --git a/modules/monitoring/application/forms/Setup/WelcomePage.php b/modules/monitoring/application/forms/Setup/WelcomePage.php index d910e2e01..f79eb6c62 100644 --- a/modules/monitoring/application/forms/Setup/WelcomePage.php +++ b/modules/monitoring/application/forms/Setup/WelcomePage.php @@ -19,10 +19,7 @@ class WelcomePage extends Form 'note', 'welcome', array( - 'value' => mt( - 'monitoring', - 'Welcome to the configuration of the monitoring module for Icinga Web 2!' - ), + 'value' => $this->translate('Welcome to the configuration of the monitoring module for Icinga Web 2!'), 'decorators' => array( 'ViewHelper', array('HtmlTag', array('tag' => 'h2')) @@ -34,7 +31,7 @@ class WelcomePage extends Form 'note', 'core_hint', array( - 'value' => mt('monitoring', 'This is the core module for Icinga Web 2.') + 'value' => $this->translate('This is the core module for Icinga Web 2.') ) ); @@ -42,8 +39,7 @@ class WelcomePage extends Form 'note', 'description', array( - 'value' => mt( - 'monitoring', + 'value' => $this->translate( 'It offers various status and reporting views with powerful filter capabilities that allow' . ' you to keep track of the most important events in your monitoring environment.' ) diff --git a/modules/monitoring/application/forms/StatehistoryForm.php b/modules/monitoring/application/forms/StatehistoryForm.php index 9fa1bdc26..d859f5815 100644 --- a/modules/monitoring/application/forms/StatehistoryForm.php +++ b/modules/monitoring/application/forms/StatehistoryForm.php @@ -19,7 +19,7 @@ class StatehistoryForm extends Form public function init() { $this->setName('form_event_overview'); - $this->setSubmitLabel(mt('monitoring', 'Apply')); + $this->setSubmitLabel($this->translate('Apply')); } /** @@ -65,14 +65,14 @@ class StatehistoryForm extends Form 'select', 'from', array( - 'label' => mt('monitoring', 'From'), + 'label' => $this->translate('From'), 'value' => $this->getRequest()->getParam('from', strtotime('3 months ago')), 'multiOptions' => array( - strtotime('midnight 3 months ago') => mt('monitoring', '3 Months'), - strtotime('midnight 4 months ago') => mt('monitoring', '4 Months'), - strtotime('midnight 8 months ago') => mt('monitoring', '8 Months'), - strtotime('midnight 12 months ago') => mt('monitoring', '1 Year'), - strtotime('midnight 24 months ago') => mt('monitoring', '2 Years') + strtotime('midnight 3 months ago') => $this->translate('3 Months'), + strtotime('midnight 4 months ago') => $this->translate('4 Months'), + strtotime('midnight 8 months ago') => $this->translate('8 Months'), + strtotime('midnight 12 months ago') => $this->translate('1 Year'), + strtotime('midnight 24 months ago') => $this->translate('2 Years') ), 'class' => 'autosubmit' ) @@ -81,10 +81,10 @@ class StatehistoryForm extends Form 'select', 'to', array( - 'label' => mt('monitoring', 'To'), + 'label' => $this->translate('To'), 'value' => $this->getRequest()->getParam('to', time()), 'multiOptions' => array( - time() => mt('monitoring', 'Today') + time() => $this->translate('Today') ), 'class' => 'autosubmit' ) @@ -95,11 +95,11 @@ class StatehistoryForm extends Form 'select', 'objecttype', array( - 'label' => mt('monitoring', 'Object type'), + 'label' => $this->translate('Object type'), 'value' => $objectType, 'multiOptions' => array( - 'services' => mt('monitoring', 'Services'), - 'hosts' => mt('monitoring', 'Hosts') + 'services' => $this->translate('Services'), + 'hosts' => $this->translate('Hosts') ), 'class' => 'autosubmit' ) @@ -113,13 +113,13 @@ class StatehistoryForm extends Form 'select', 'state', array( - 'label' => mt('monitoring', 'State'), + 'label' => $this->translate('State'), 'value' => $serviceState, 'multiOptions' => array( - 'cnt_critical_hard' => mt('monitoring', 'Critical'), - 'cnt_warning_hard' => mt('monitoring', 'Warning'), - 'cnt_unknown_hard' => mt('monitoring', 'Unknown'), - 'cnt_ok' => mt('monitoring', 'Ok') + 'cnt_critical_hard' => $this->translate('Critical'), + 'cnt_warning_hard' => $this->translate('Warning'), + 'cnt_unknown_hard' => $this->translate('Unknown'), + 'cnt_ok' => $this->translate('Ok') ), 'class' => 'autosubmit' ) @@ -133,12 +133,12 @@ class StatehistoryForm extends Form 'select', 'state', array( - 'label' => mt('monitoring', 'State'), + 'label' => $this->translate('State'), 'value' => $hostState, 'multiOptions' => array( - 'cnt_up' => mt('monitoring', 'Up'), - 'cnt_down_hard' => mt('monitoring', 'Down'), - 'cnt_unreachable_hard' => mt('monitoring', 'Unreachable') + 'cnt_up' => $this->translate('Up'), + 'cnt_down_hard' => $this->translate('Down'), + 'cnt_unreachable_hard' => $this->translate('Unreachable') ), 'class' => 'autosubmit' ) From 8c87a9df13d1452bfc5906218d25bab1b7809435 Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Mon, 19 Jan 2015 11:07:39 +0100 Subject: [PATCH 0185/2920] Replace t() and mt() with translate() in setup module's forms refs #7551 --- .../application/forms/AdminAccountPage.php | 35 +++++++++---------- .../application/forms/AuthBackendPage.php | 15 ++++---- .../application/forms/AuthenticationPage.php | 13 ++++--- .../forms/DatabaseCreationPage.php | 23 ++++++------ .../application/forms/DbResourcePage.php | 11 +++--- .../application/forms/GeneralConfigPage.php | 5 ++- .../forms/LdapDiscoveryConfirmPage.php | 6 ++-- .../application/forms/LdapDiscoveryPage.php | 13 +++---- .../application/forms/LdapResourcePage.php | 10 +++--- .../application/forms/PreferencesPage.php | 15 ++++---- .../setup/application/forms/WelcomePage.php | 5 ++- 11 files changed, 69 insertions(+), 82 deletions(-) diff --git a/modules/setup/application/forms/AdminAccountPage.php b/modules/setup/application/forms/AdminAccountPage.php index 6ef791d4e..3b2e6ec9f 100644 --- a/modules/setup/application/forms/AdminAccountPage.php +++ b/modules/setup/application/forms/AdminAccountPage.php @@ -74,16 +74,15 @@ class AdminAccountPage extends Form $choices = array(); if ($this->backendConfig['backend'] !== 'db') { - $choices['by_name'] = mt('setup', 'By Name', 'setup.admin'); + $choices['by_name'] = $this->translate('By Name', 'setup.admin'); $this->addElement( 'text', 'by_name', array( 'required' => isset($formData['user_type']) && $formData['user_type'] === 'by_name', 'value' => $this->getUsername(), - 'label' => mt('setup', 'Username'), - 'description' => mt( - 'setup', + 'label' => $this->translate('Username'), + 'description' => $this->translate( 'Define the initial administrative account by providing a username that reflects' . ' a user created later or one that is authenticated using external mechanisms' ) @@ -94,21 +93,20 @@ class AdminAccountPage extends Form if ($this->backendConfig['backend'] === 'db' || $this->backendConfig['backend'] === 'ldap') { $users = $this->fetchUsers(); if (false === empty($users)) { - $choices['existing_user'] = mt('setup', 'Existing User'); + $choices['existing_user'] = $this->translate('Existing User'); $this->addElement( 'select', 'existing_user', array( 'required' => isset($formData['user_type']) && $formData['user_type'] === 'existing_user', - 'label' => mt('setup', 'Username'), + 'label' => $this->translate('Username'), 'description' => sprintf( - mt( - 'setup', + $this->translate( 'Choose a user reported by the %s backend as the initial administrative account', 'setup.admin' ), $this->backendConfig['backend'] === 'db' - ? mt('setup', 'database', 'setup.admin.authbackend') + ? $this->translate('database', 'setup.admin.authbackend') : 'LDAP' ), 'multiOptions' => array_combine($users, $users) @@ -118,16 +116,15 @@ class AdminAccountPage extends Form } if ($this->backendConfig['backend'] === 'db') { - $choices['new_user'] = mt('setup', 'New User'); + $choices['new_user'] = $this->translate('New User'); $required = isset($formData['user_type']) && $formData['user_type'] === 'new_user'; $this->addElement( 'text', 'new_user', array( 'required' => $required, - 'label' => mt('setup', 'Username'), - 'description' => mt( - 'setup', + 'label' => $this->translate('Username'), + 'description' => $this->translate( 'Enter the username to be used when creating an initial administrative account' ) ) @@ -137,8 +134,8 @@ class AdminAccountPage extends Form 'new_user_password', array( 'required' => $required, - 'label' => mt('setup', 'Password'), - 'description' => mt('setup', 'Enter the password to assign to the newly created account') + 'label' => $this->translate('Password'), + 'description' => $this->translate('Enter the password to assign to the newly created account') ) ); $this->addElement( @@ -146,8 +143,8 @@ class AdminAccountPage extends Form 'new_user_2ndpass', array( 'required' => $required, - 'label' => mt('setup', 'Repeat password'), - 'description' => mt('setup', 'Please repeat the password given above to avoid typing errors'), + 'label' => $this->translate('Repeat password'), + 'description' => $this->translate('Please repeat the password given above to avoid typing errors'), 'validators' => array( array('identical', false, array('new_user_password')) ) @@ -179,7 +176,7 @@ class AdminAccountPage extends Form 'note', 'title', array( - 'value' => mt('setup', 'Administration', 'setup.page.title'), + 'value' => $this->translate('Administration', 'setup.page.title'), 'decorators' => array( 'ViewHelper', array('HtmlTag', array('tag' => 'h2')) @@ -215,7 +212,7 @@ class AdminAccountPage extends Form } if ($data['user_type'] === 'new_user' && array_search($data['new_user'], $this->fetchUsers()) !== false) { - $this->getElement('new_user')->addError(mt('setup', 'Username already exists.')); + $this->getElement('new_user')->addError($this->translate('Username already exists.')); return false; } diff --git a/modules/setup/application/forms/AuthBackendPage.php b/modules/setup/application/forms/AuthBackendPage.php index bd820d352..ced0d9c59 100644 --- a/modules/setup/application/forms/AuthBackendPage.php +++ b/modules/setup/application/forms/AuthBackendPage.php @@ -62,7 +62,7 @@ class AuthBackendPage extends Form 'note', 'title', array( - 'value' => mt('setup', 'Authentication Backend', 'setup.page.title'), + 'value' => $this->translate('Authentication Backend', 'setup.page.title'), 'decorators' => array( 'ViewHelper', array('HtmlTag', array('tag' => 'h2')) @@ -71,20 +71,17 @@ class AuthBackendPage extends Form ); if ($this->config['type'] === 'db') { - $note = mt( - 'setup', + $note = $this->translate( 'As you\'ve chosen to use a database for authentication all you need ' . 'to do now is defining a name for your first authentication backend.' ); } elseif ($this->config['type'] === 'ldap') { - $note = mt( - 'setup', + $note = $this->translate( 'Before you are able to authenticate using the LDAP connection defined earlier you need to' . ' provide some more information so that Icinga Web 2 is able to locate account details.' ); } else { // if ($this->config['type'] === 'autologin' - $note = mt( - 'setup', + $note = $this->translate( 'You\'ve chosen to authenticate using a web server\'s mechanism so it may be necessary' . ' to adjust usernames before any permissions, restrictions, etc. are being applied.' ); @@ -150,8 +147,8 @@ class AuthBackendPage extends Form 'order' => 2, 'ignore' => true, 'required' => true, - 'label' => mt('setup', 'Skip Validation'), - 'description' => mt('setup', 'Check this to not to validate authentication using this backend') + 'label' => $this->translate('Skip Validation'), + 'description' => $this->translate('Check this to not to validate authentication using this backend') ) ); } diff --git a/modules/setup/application/forms/AuthenticationPage.php b/modules/setup/application/forms/AuthenticationPage.php index 2a579e670..88db9c6d8 100644 --- a/modules/setup/application/forms/AuthenticationPage.php +++ b/modules/setup/application/forms/AuthenticationPage.php @@ -29,7 +29,7 @@ class AuthenticationPage extends Form 'note', 'title', array( - 'value' => mt('setup', 'Authentication', 'setup.page.title'), + 'value' => $this->translate('Authentication', 'setup.page.title'), 'decorators' => array( 'ViewHelper', array('HtmlTag', array('tag' => 'h2')) @@ -40,8 +40,7 @@ class AuthenticationPage extends Form 'note', 'description', array( - 'value' => mt( - 'setup', + 'value' => $this->translate( 'Please choose how you want to authenticate when accessing Icinga Web 2.' . ' Configuring backend specific details follows in a later step.' ) @@ -50,20 +49,20 @@ class AuthenticationPage extends Form $backendTypes = array(); if (Platform::hasMysqlSupport() || Platform::hasPostgresqlSupport()) { - $backendTypes['db'] = t('Database'); + $backendTypes['db'] = $this->translate('Database'); } if (Platform::extensionLoaded('ldap')) { $backendTypes['ldap'] = 'LDAP'; } - $backendTypes['autologin'] = t('Autologin'); + $backendTypes['autologin'] = $this->translate('Autologin'); $this->addElement( 'select', 'type', array( 'required' => true, - 'label' => mt('setup', 'Authentication Type'), - 'description' => mt('setup', 'The type of authentication to use when accessing Icinga Web 2'), + 'label' => $this->translate('Authentication Type'), + 'description' => $this->translate('The type of authentication to use when accessing Icinga Web 2'), 'multiOptions' => $backendTypes ) ); diff --git a/modules/setup/application/forms/DatabaseCreationPage.php b/modules/setup/application/forms/DatabaseCreationPage.php index ec4a77ee1..be2974a52 100644 --- a/modules/setup/application/forms/DatabaseCreationPage.php +++ b/modules/setup/application/forms/DatabaseCreationPage.php @@ -90,7 +90,7 @@ class DatabaseCreationPage extends Form 'note', 'title', array( - 'value' => mt('setup', 'Database Setup', 'setup.page.title'), + 'value' => $this->translate('Database Setup', 'setup.page.title'), 'decorators' => array( 'ViewHelper', array('HtmlTag', array('tag' => 'h2')) @@ -101,8 +101,7 @@ class DatabaseCreationPage extends Form 'note', 'description', array( - 'value' => mt( - 'setup', + 'value' => $this->translate( 'It seems that either the database you defined earlier does not yet exist and cannot be created' . ' using the provided access credentials or the database does not have the required schema to ' . 'be operated by Icinga Web 2. Please provide appropriate access credentials to solve this.' @@ -116,16 +115,16 @@ class DatabaseCreationPage extends Form 'username', array( 'required' => false === $skipValidation, - 'label' => mt('setup', 'Username'), - 'description' => mt('setup', 'A user which is able to create databases and/or touch the database schema') + 'label' => $this->translate('Username'), + 'description' => $this->translate('A user which is able to create databases and/or touch the database schema') ) ); $this->addElement( 'password', 'password', array( - 'label' => mt('setup', 'Password'), - 'description' => mt('setup', 'The password for the database user defined above') + 'label' => $this->translate('Password'), + 'description' => $this->translate('The password for the database user defined above') ) ); @@ -182,7 +181,7 @@ class DatabaseCreationPage extends Form // form need to be granted to create databases, users... if (false === $db->checkPrivileges($this->databaseSetupPrivileges)) { $this->addError( - mt('setup', 'The provided credentials cannot be used to create the database and/or the user.') + $this->translate('The provided credentials cannot be used to create the database and/or the user.') ); $this->addSkipValidationCheckbox(); return false; @@ -191,8 +190,7 @@ class DatabaseCreationPage extends Form // ...and to grant all required usage privileges to others if (false === $db->isGrantable($this->databaseUsagePrivileges)) { $this->addError(sprintf( - mt( - 'setup', + $this->translate( 'The provided credentials cannot be used to grant all required privileges to the login "%s".' ), $this->config['username'] @@ -215,9 +213,8 @@ class DatabaseCreationPage extends Form array( 'order' => 2, 'required' => true, - 'label' => mt('setup', 'Skip Validation'), - 'description' => mt( - 'setup', + 'label' => $this->translate('Skip Validation'), + 'description' => $this->translate( 'Check this to not to validate the ability to login and required privileges' ) ) diff --git a/modules/setup/application/forms/DbResourcePage.php b/modules/setup/application/forms/DbResourcePage.php index 4a6535324..1901d8ca9 100644 --- a/modules/setup/application/forms/DbResourcePage.php +++ b/modules/setup/application/forms/DbResourcePage.php @@ -39,7 +39,7 @@ class DbResourcePage extends Form 'note', 'title', array( - 'value' => mt('setup', 'Database Resource', 'setup.page.title'), + 'value' => $this->translate('Database Resource', 'setup.page.title'), 'decorators' => array( 'ViewHelper', array('HtmlTag', array('tag' => 'h2')) @@ -50,8 +50,7 @@ class DbResourcePage extends Form 'note', 'description', array( - 'value' => mt( - 'setup', + 'value' => $this->translate( 'Now please configure your database resource. Note that the database itself does not need to' . ' exist at this time as it is going to be created once the wizard is about to be finished.' ) @@ -121,8 +120,10 @@ class DbResourcePage extends Form 'skip_validation', array( 'required' => true, - 'label' => mt('setup', 'Skip Validation'), - 'description' => mt('setup', 'Check this to not to validate connectivity with the given database server') + 'label' => $this->translate('Skip Validation'), + 'description' => $this->translate( + 'Check this to not to validate connectivity with the given database server' + ) ) ); } diff --git a/modules/setup/application/forms/GeneralConfigPage.php b/modules/setup/application/forms/GeneralConfigPage.php index 309c1784d..e0a9d0fab 100644 --- a/modules/setup/application/forms/GeneralConfigPage.php +++ b/modules/setup/application/forms/GeneralConfigPage.php @@ -29,7 +29,7 @@ class GeneralConfigPage extends Form 'note', 'title', array( - 'value' => mt('setup', 'Application Configuration', 'setup.page.title'), + 'value' => $this->translate('Application Configuration', 'setup.page.title'), 'decorators' => array( 'ViewHelper', array('HtmlTag', array('tag' => 'h2')) @@ -40,8 +40,7 @@ class GeneralConfigPage extends Form 'note', 'description', array( - 'value' => mt( - 'setup', + 'value' => $this->translate( 'Now please adjust all application and logging related configuration options to fit your needs.' ) ) diff --git a/modules/setup/application/forms/LdapDiscoveryConfirmPage.php b/modules/setup/application/forms/LdapDiscoveryConfirmPage.php index f76cbee07..66fd39001 100644 --- a/modules/setup/application/forms/LdapDiscoveryConfirmPage.php +++ b/modules/setup/application/forms/LdapDiscoveryConfirmPage.php @@ -82,7 +82,7 @@ EOT; 'note', 'title', array( - 'value' => mt('setup', 'LDAP Discovery Results', 'setup.page.title'), + 'value' => $this->translate('LDAP Discovery Results', 'setup.page.title'), 'decorators' => array( 'ViewHelper', array('HtmlTag', array('tag' => 'h2')) @@ -94,7 +94,7 @@ EOT; 'description', array( 'value' => sprintf( - mt('setup', 'The following directory service has been found on domain "%s":'), + $this->translate('The following directory service has been found on domain "%s":'), $this->config['domain'] ) ) @@ -119,7 +119,7 @@ EOT; 'confirm', array( 'value' => '1', - 'label' => mt('setup', 'Use this configuration?') + 'label' => $this->translate('Use this configuration?') ) ); } diff --git a/modules/setup/application/forms/LdapDiscoveryPage.php b/modules/setup/application/forms/LdapDiscoveryPage.php index 8c61eb379..26b43803b 100644 --- a/modules/setup/application/forms/LdapDiscoveryPage.php +++ b/modules/setup/application/forms/LdapDiscoveryPage.php @@ -36,7 +36,7 @@ class LdapDiscoveryPage extends Form 'note', 'title', array( - 'value' => mt('setup', 'LDAP Discovery', 'setup.page.title'), + 'value' => $this->translate('LDAP Discovery', 'setup.page.title'), 'decorators' => array( 'ViewHelper', array('HtmlTag', array('tag' => 'h2')) @@ -47,8 +47,7 @@ class LdapDiscoveryPage extends Form 'note', 'description', array( - 'value' => mt( - 'setup', + 'value' => $this->translate( 'You can use this page to discover LDAP or ActiveDirectory servers ' . ' for authentication. If you don\' want to execute a discovery, just skip this step.' ) @@ -66,8 +65,8 @@ class LdapDiscoveryPage extends Form 'skip_validation', array( 'required' => true, - 'label' => mt('setup', 'Skip'), - 'description' => mt('setup', 'Do not discover LDAP servers and enter all settings manually.') + 'label' => $this->translate('Skip'), + 'description' => $this->translate('Do not discover LDAP servers and enter all settings manually.') ) ); } @@ -94,7 +93,9 @@ class LdapDiscoveryPage extends Form return true; } } - $this->addError(sprintf(t('Could not find any LDAP servers on the domain "%s".'), $data['domain'])); + $this->addError( + sprintf($this->translate('Could not find any LDAP servers on the domain "%s".'), $data['domain']) + ); return false; } diff --git a/modules/setup/application/forms/LdapResourcePage.php b/modules/setup/application/forms/LdapResourcePage.php index 49bed69c3..f003a7370 100644 --- a/modules/setup/application/forms/LdapResourcePage.php +++ b/modules/setup/application/forms/LdapResourcePage.php @@ -37,7 +37,7 @@ class LdapResourcePage extends Form 'note', 'title', array( - 'value' => mt('setup', 'LDAP Resource', 'setup.page.title'), + 'value' => $this->translate('LDAP Resource', 'setup.page.title'), 'decorators' => array( 'ViewHelper', array('HtmlTag', array('tag' => 'h2')) @@ -48,8 +48,7 @@ class LdapResourcePage extends Form 'note', 'description', array( - 'value' => mt( - 'setup', + 'value' => $this->translate( 'Now please configure your AD/LDAP resource. This will later ' . 'be used to authenticate users logging in to Icinga Web 2.' ) @@ -107,9 +106,8 @@ class LdapResourcePage extends Form 'skip_validation', array( 'required' => true, - 'label' => mt('setup', 'Skip Validation'), - 'description' => mt( - 'setup', + 'label' => $this->translate('Skip Validation'), + 'description' => $this->translate( 'Check this to not to validate connectivity with the given directory service' ) ) diff --git a/modules/setup/application/forms/PreferencesPage.php b/modules/setup/application/forms/PreferencesPage.php index 26fd048e1..07e011ee1 100644 --- a/modules/setup/application/forms/PreferencesPage.php +++ b/modules/setup/application/forms/PreferencesPage.php @@ -30,8 +30,7 @@ class PreferencesPage extends Form $this->getElement('type') ->setValue('db') ->setDescription( - mt( - 'setup', + $this->translate( 'Note that choosing "Database" causes Icinga Web 2 to use the same database as for authentication.' ) ); @@ -47,7 +46,7 @@ class PreferencesPage extends Form 'note', 'title', array( - 'value' => mt('setup', 'Preferences', 'setup.page.title'), + 'value' => $this->translate('Preferences', 'setup.page.title'), 'decorators' => array( 'ViewHelper', array('HtmlTag', array('tag' => 'h2')) @@ -58,23 +57,23 @@ class PreferencesPage extends Form 'note', 'description', array( - 'value' => mt('setup', 'Please choose how Icinga Web 2 should store user preferences.') + 'value' => $this->translate('Please choose how Icinga Web 2 should store user preferences.') ) ); $storageTypes = array(); - $storageTypes['ini'] = t('File System (INI Files)'); + $storageTypes['ini'] = $this->translate('File System (INI Files)'); if (Platform::hasMysqlSupport() || Platform::hasPostgresqlSupport()) { - $storageTypes['db'] = t('Database'); + $storageTypes['db'] = $this->translate('Database'); } - $storageTypes['null'] = t('Don\'t Store Preferences'); + $storageTypes['null'] = $this->translate('Don\'t Store Preferences'); $this->addElement( 'select', 'type', array( 'required' => true, - 'label' => t('User Preference Storage Type'), + 'label' => $this->translate('User Preference Storage Type'), 'multiOptions' => $storageTypes ) ); diff --git a/modules/setup/application/forms/WelcomePage.php b/modules/setup/application/forms/WelcomePage.php index 5da607683..66340ff25 100644 --- a/modules/setup/application/forms/WelcomePage.php +++ b/modules/setup/application/forms/WelcomePage.php @@ -32,9 +32,8 @@ class WelcomePage extends Form 'token', array( 'required' => true, - 'label' => mt('setup', 'Setup Token'), - 'description' => mt( - 'setup', + 'label' => $this->translate('Setup Token'), + 'description' => $this->translate( 'For security reasons we need to ensure that you are permitted to run this wizard.' . ' Please provide a token by following the instructions below.' ), From dbd69ba6935fb59de471123f3f55b01ad58ca167 Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Mon, 19 Jan 2015 11:26:23 +0100 Subject: [PATCH 0186/2920] Replace t() and mt() with translate() in the application's forms refs #7551 --- .../forms/Authentication/LoginForm.php | 10 ++-- .../Authentication/AutologinBackendForm.php | 8 +-- .../Config/Authentication/DbBackendForm.php | 14 +++--- .../Config/Authentication/LdapBackendForm.php | 28 ++++++----- .../AuthenticationBackendConfigForm.php | 50 ++++++++++--------- .../AuthenticationBackendReorderForm.php | 2 +- .../Config/General/ApplicationConfigForm.php | 14 +++--- .../Config/General/LoggingConfigForm.php | 35 ++++++------- .../forms/Config/GeneralConfigForm.php | 4 +- .../forms/Config/Resource/DbResourceForm.php | 32 ++++++------ .../Config/Resource/FileResourceForm.php | 12 ++--- .../Config/Resource/LdapResourceForm.php | 32 +++++++----- .../Resource/LivestatusResourceForm.php | 14 +++--- .../forms/Config/ResourceConfigForm.php | 38 +++++++------- application/forms/ConfirmRemovalForm.php | 2 +- application/forms/Dashboard/DashletForm.php | 27 +++++----- application/forms/LdapDiscoveryForm.php | 14 +++--- application/forms/PreferenceForm.php | 22 ++++---- application/forms/Security/RoleForm.php | 26 +++++----- 19 files changed, 203 insertions(+), 181 deletions(-) diff --git a/application/forms/Authentication/LoginForm.php b/application/forms/Authentication/LoginForm.php index a6d69d15a..8be455dcc 100644 --- a/application/forms/Authentication/LoginForm.php +++ b/application/forms/Authentication/LoginForm.php @@ -18,7 +18,7 @@ class LoginForm extends Form public function init() { $this->setName('form_login'); - $this->setSubmitLabel(t('Login')); + $this->setSubmitLabel($this->translate('Login')); } /** @@ -31,8 +31,8 @@ class LoginForm extends Form 'username', array( 'required' => true, - 'label' => t('Username'), - 'placeholder' => t('Please enter your username...'), + 'label' => $this->translate('Username'), + 'placeholder' => $this->translate('Please enter your username...'), 'class' => false === isset($formData['username']) ? 'autofocus' : '' ) ); @@ -41,8 +41,8 @@ class LoginForm extends Form 'password', array( 'required' => true, - 'label' => t('Password'), - 'placeholder' => t('...and your password'), + 'label' => $this->translate('Password'), + 'placeholder' => $this->translate('...and your password'), 'class' => isset($formData['username']) ? 'autofocus' : '' ) ); diff --git a/application/forms/Config/Authentication/AutologinBackendForm.php b/application/forms/Config/Authentication/AutologinBackendForm.php index 97b5dfed7..cd09d38ac 100644 --- a/application/forms/Config/Authentication/AutologinBackendForm.php +++ b/application/forms/Config/Authentication/AutologinBackendForm.php @@ -30,8 +30,8 @@ class AutologinBackendForm extends Form 'name', array( 'required' => true, - 'label' => t('Backend Name'), - 'description' => t( + 'label' => $this->translate('Backend Name'), + 'description' => $this->translate( 'The name of this authentication provider that is used to differentiate it from others' ), 'validators' => array( @@ -52,8 +52,8 @@ class AutologinBackendForm extends Form 'text', 'strip_username_regexp', array( - 'label' => t('Filter Pattern'), - 'description' => t( + 'label' => $this->translate('Filter Pattern'), + 'description' => $this->translate( 'The regular expression to use to strip specific parts off from usernames.' . ' Leave empty if you do not want to strip off anything' ), diff --git a/application/forms/Config/Authentication/DbBackendForm.php b/application/forms/Config/Authentication/DbBackendForm.php index 572a09c2e..f8a4fb832 100644 --- a/application/forms/Config/Authentication/DbBackendForm.php +++ b/application/forms/Config/Authentication/DbBackendForm.php @@ -53,8 +53,8 @@ class DbBackendForm extends Form 'name', array( 'required' => true, - 'label' => t('Backend Name'), - 'description' => t( + 'label' => $this->translate('Backend Name'), + 'description' => $this->translate( 'The name of this authentication provider that is used to differentiate it from others' ), ) @@ -64,8 +64,10 @@ class DbBackendForm extends Form 'resource', array( 'required' => true, - 'label' => t('Database Connection'), - 'description' => t('The database connection to use for authenticating with this provider'), + 'label' => $this->translate('Database Connection'), + 'description' => $this->translate( + 'The database connection to use for authenticating with this provider' + ), 'multiOptions' => false === empty($this->resources) ? array_combine($this->resources, $this->resources) : array() @@ -107,11 +109,11 @@ class DbBackendForm extends Form try { $dbUserBackend = new DbUserBackend(ResourceFactory::createResource($form->getResourceConfig())); if ($dbUserBackend->count() < 1) { - $form->addError(t('No users found under the specified database backend')); + $form->addError($this->translate('No users found under the specified database backend')); return false; } } catch (Exception $e) { - $form->addError(sprintf(t('Using the specified backend failed: %s'), $e->getMessage())); + $form->addError(sprintf($this->translate('Using the specified backend failed: %s'), $e->getMessage())); return false; } diff --git a/application/forms/Config/Authentication/LdapBackendForm.php b/application/forms/Config/Authentication/LdapBackendForm.php index 9b48c3dbc..5915a0a10 100644 --- a/application/forms/Config/Authentication/LdapBackendForm.php +++ b/application/forms/Config/Authentication/LdapBackendForm.php @@ -54,8 +54,8 @@ class LdapBackendForm extends Form 'name', array( 'required' => true, - 'label' => t('Backend Name'), - 'description' => t( + 'label' => $this->translate('Backend Name'), + 'description' => $this->translate( 'The name of this authentication provider that is used to differentiate it from others' ) ) @@ -65,8 +65,8 @@ class LdapBackendForm extends Form 'resource', array( 'required' => true, - 'label' => t('LDAP Resource'), - 'description' => t('The resource to use for authenticating with this provider'), + 'label' => $this->translate('LDAP Resource'), + 'description' => $this->translate('The resource to use for authenticating with this provider'), 'multiOptions' => false === empty($this->resources) ? array_combine($this->resources, $this->resources) : array() @@ -77,8 +77,8 @@ class LdapBackendForm extends Form 'user_class', array( 'required' => true, - 'label' => t('LDAP User Object Class'), - 'description' => t('The object class used for storing users on the ldap server'), + 'label' => $this->translate('LDAP User Object Class'), + 'description' => $this->translate('The object class used for storing users on the ldap server'), 'value' => 'inetOrgPerson' ) ); @@ -87,8 +87,10 @@ class LdapBackendForm extends Form 'user_name_attribute', array( 'required' => true, - 'label' => t('LDAP User Name Attribute'), - 'description' => t('The attribute name used for storing the user name on the ldap server'), + 'label' => $this->translate('LDAP User Name Attribute'), + 'description' => $this->translate( + 'The attribute name used for storing the user name on the ldap server' + ), 'value' => 'uid' ) ); @@ -105,9 +107,11 @@ class LdapBackendForm extends Form 'base_dn', array( 'required' => false, - 'label' => t('Base DN'), - 'description' => t('The path where users can be found on the ldap server. ' . - ' Leave empty to select all users available on the specified resource.') + 'label' => $this->translate('Base DN'), + 'description' => $this->translate( + 'The path where users can be found on the ldap server. Leave ' . + 'empty to select all users available on the specified resource.' + ) ) ); return $this; @@ -146,7 +150,7 @@ class LdapBackendForm extends Form $form->addError($e->getMessage()); return false; } catch (Exception $e) { - $form->addError(sprintf(t('Unable to validate authentication: %s'), $e->getMessage())); + $form->addError(sprintf($this->translate('Unable to validate authentication: %s'), $e->getMessage())); return false; } diff --git a/application/forms/Config/AuthenticationBackendConfigForm.php b/application/forms/Config/AuthenticationBackendConfigForm.php index 12f407c69..076f8cb17 100644 --- a/application/forms/Config/AuthenticationBackendConfigForm.php +++ b/application/forms/Config/AuthenticationBackendConfigForm.php @@ -31,7 +31,7 @@ class AuthenticationBackendConfigForm extends ConfigForm public function init() { $this->setName('form_config_authbackend'); - $this->setSubmitLabel(t('Save Changes')); + $this->setSubmitLabel($this->translate('Save Changes')); } /** @@ -70,7 +70,7 @@ class AuthenticationBackendConfigForm extends ConfigForm } elseif ($type === 'autologin') { $form = new AutologinBackendForm(); } else { - throw new InvalidArgumentException(sprintf(t('Invalid backend type "%s" provided'), $type)); + throw new InvalidArgumentException(sprintf($this->translate('Invalid backend type "%s" provided'), $type)); } return $form; @@ -91,9 +91,9 @@ class AuthenticationBackendConfigForm extends ConfigForm { $name = isset($values['name']) ? $values['name'] : ''; if (! $name) { - throw new InvalidArgumentException(t('Authentication backend name missing')); + throw new InvalidArgumentException($this->translate('Authentication backend name missing')); } elseif ($this->config->hasSection($name)) { - throw new InvalidArgumentException(t('Authentication backend already exists')); + throw new InvalidArgumentException($this->translate('Authentication backend already exists')); } unset($values['name']); @@ -114,11 +114,11 @@ class AuthenticationBackendConfigForm extends ConfigForm public function edit($name, array $values) { if (! $name) { - throw new InvalidArgumentException(t('Old authentication backend name missing')); + throw new InvalidArgumentException($this->translate('Old authentication backend name missing')); } elseif (! ($newName = isset($values['name']) ? $values['name'] : '')) { - throw new InvalidArgumentException(t('New authentication backend name missing')); + throw new InvalidArgumentException($this->translate('New authentication backend name missing')); } elseif (! $this->config->hasSection($name)) { - throw new InvalidArgumentException(t('Unknown authentication backend provided')); + throw new InvalidArgumentException($this->translate('Unknown authentication backend provided')); } $backendConfig = $this->config->getSection($name); @@ -144,9 +144,9 @@ class AuthenticationBackendConfigForm extends ConfigForm public function remove($name) { if (! $name) { - throw new InvalidArgumentException(t('Authentication backend name missing')); + throw new InvalidArgumentException($this->translate('Authentication backend name missing')); } elseif (! $this->config->hasSection($name)) { - throw new InvalidArgumentException(t('Unknown authentication backend provided')); + throw new InvalidArgumentException($this->translate('Unknown authentication backend provided')); } $backendConfig = $this->config->getSection($name); @@ -167,9 +167,9 @@ class AuthenticationBackendConfigForm extends ConfigForm public function move($name, $position) { if (! $name) { - throw new InvalidArgumentException(t('Authentication backend name missing')); + throw new InvalidArgumentException($this->translate('Authentication backend name missing')); } elseif (! $this->config->hasSection($name)) { - throw new InvalidArgumentException(t('Unknown authentication backend provided')); + throw new InvalidArgumentException($this->translate('Unknown authentication backend provided')); } $backendOrder = $this->config->keys(); @@ -208,10 +208,10 @@ class AuthenticationBackendConfigForm extends ConfigForm try { if ($authBackend === null) { // create new backend $this->add($this->getValues()); - $message = t('Authentication backend "%s" has been successfully created'); + $message = $this->translate('Authentication backend "%s" has been successfully created'); } else { // edit existing backend $this->edit($authBackend, $this->getValues()); - $message = t('Authentication backend "%s" has been successfully changed'); + $message = $this->translate('Authentication backend "%s" has been successfully changed'); } } catch (InvalidArgumentException $e) { Notification::error($e->getMessage()); @@ -237,11 +237,13 @@ class AuthenticationBackendConfigForm extends ConfigForm $authBackend = $this->request->getQuery('auth_backend'); if ($authBackend !== null) { if ($authBackend === '') { - throw new ConfigurationError(t('Authentication backend name missing')); + throw new ConfigurationError($this->translate('Authentication backend name missing')); } elseif (! $this->config->hasSection($authBackend)) { - throw new ConfigurationError(t('Unknown authentication backend provided')); + throw new ConfigurationError($this->translate('Unknown authentication backend provided')); } elseif ($this->config->getSection($authBackend)->backend === null) { - throw new ConfigurationError(sprintf(t('Backend "%s" has no `backend\' setting'), $authBackend)); + throw new ConfigurationError( + sprintf($this->translate('Backend "%s" has no `backend\' setting'), $authBackend) + ); } $configValues = $this->config->getSection($authBackend)->toArray(); @@ -257,7 +259,7 @@ class AuthenticationBackendConfigForm extends ConfigForm ); if (false === empty($autologinBackends)) { - throw new ConfigurationError(t('Could not find any resources for authentication')); + throw new ConfigurationError($this->translate('Could not find any resources for authentication')); } } } @@ -276,8 +278,8 @@ class AuthenticationBackendConfigForm extends ConfigForm array( 'order' => 0, 'ignore' => true, - 'label' => t('Force Changes'), - 'description' => t('Check this box to enforce changes without connectivity validation') + 'label' => $this->translate('Force Changes'), + 'description' => $this->translate('Check this box to enforce changes without connectivity validation') ) ); } @@ -291,7 +293,7 @@ class AuthenticationBackendConfigForm extends ConfigForm $backendType = isset($formData['type']) ? $formData['type'] : null; if (isset($this->resources['db'])) { - $backendTypes['db'] = t('Database'); + $backendTypes['db'] = $this->translate('Database'); } if (isset($this->resources['ldap']) && ($backendType === 'ldap' || Platform::extensionLoaded('ldap'))) { $backendTypes['ldap'] = 'LDAP'; @@ -304,7 +306,7 @@ class AuthenticationBackendConfigForm extends ConfigForm } ); if ($backendType === 'autologin' || empty($autologinBackends)) { - $backendTypes['autologin'] = t('Autologin'); + $backendTypes['autologin'] = $this->translate('Autologin'); } if ($backendType === null) { @@ -318,8 +320,10 @@ class AuthenticationBackendConfigForm extends ConfigForm 'ignore' => true, 'required' => true, 'autosubmit' => true, - 'label' => t('Backend Type'), - 'description' => t('The type of the resource to use for this authenticaton provider'), + 'label' => $this->translate('Backend Type'), + 'description' => $this->translate( + 'The type of the resource to use for this authenticaton provider' + ), 'multiOptions' => $backendTypes ) ); diff --git a/application/forms/Config/AuthenticationBackendReorderForm.php b/application/forms/Config/AuthenticationBackendReorderForm.php index 07200827a..a41224248 100644 --- a/application/forms/Config/AuthenticationBackendReorderForm.php +++ b/application/forms/Config/AuthenticationBackendReorderForm.php @@ -52,7 +52,7 @@ class AuthenticationBackendReorderForm extends ConfigForm try { if ($configForm->move($backendName, $position)->save()) { - Notification::success(t('Authentication order updated!')); + Notification::success($this->translate('Authentication order updated!')); } else { return false; } diff --git a/application/forms/Config/General/ApplicationConfigForm.php b/application/forms/Config/General/ApplicationConfigForm.php index 95ad22071..8f718ccdf 100644 --- a/application/forms/Config/General/ApplicationConfigForm.php +++ b/application/forms/Config/General/ApplicationConfigForm.php @@ -33,10 +33,10 @@ class ApplicationConfigForm extends Form 'text', 'global_module_path', array( - 'label' => t('Module Path'), + 'label' => $this->translate('Module Path'), 'required' => true, 'value' => implode(':', Icinga::app()->getModuleManager()->getModuleDirs()), - 'description' => t( + 'description' => $this->translate( 'Contains the directories that will be searched for available modules, separated by ' . 'colons. Modules that don\'t exist in these directories can still be symlinked in ' . 'the module folder, but won\'t show up in the list of disabled modules.' @@ -50,11 +50,11 @@ class ApplicationConfigForm extends Form array( 'required' => true, 'autosubmit' => true, - 'label' => t('User Preference Storage Type'), + 'label' => $this->translate('User Preference Storage Type'), 'multiOptions' => array( - 'ini' => t('File System (INI Files)'), - 'db' => t('Database'), - 'null' => t('Don\'t Store Preferences') + 'ini' => $this->translate('File System (INI Files)'), + 'db' => $this->translate('Database'), + 'null' => $this->translate('Don\'t Store Preferences') ) ) ); @@ -72,7 +72,7 @@ class ApplicationConfigForm extends Form array( 'required' => true, 'multiOptions' => $backends, - 'label' => t('Database Connection') + 'label' => $this->translate('Database Connection') ) ); } diff --git a/application/forms/Config/General/LoggingConfigForm.php b/application/forms/Config/General/LoggingConfigForm.php index 759c2a6e3..997bd558a 100644 --- a/application/forms/Config/General/LoggingConfigForm.php +++ b/application/forms/Config/General/LoggingConfigForm.php @@ -4,7 +4,6 @@ namespace Icinga\Forms\Config\General; -use Icinga\Application\Icinga; use Icinga\Application\Logger; use Icinga\Web\Form; use Icinga\Web\Form\Validator\WritablePathValidator; @@ -31,12 +30,12 @@ class LoggingConfigForm extends Form array( 'required' => true, 'autosubmit' => true, - 'label' => t('Logging Type'), - 'description' => t('The type of logging to utilize.'), + 'label' => $this->translate('Logging Type'), + 'description' => $this->translate('The type of logging to utilize.'), 'multiOptions' => array( 'syslog' => 'Syslog', - 'file' => t('File', 'app.config.logging.type'), - 'none' => t('None', 'app.config.logging.type') + 'file' => $this->translate('File', 'app.config.logging.type'), + 'none' => $this->translate('None', 'app.config.logging.type') ) ) ); @@ -47,13 +46,13 @@ class LoggingConfigForm extends Form 'logging_level', array( 'required' => true, - 'label' => t('Logging Level'), - 'description' => t('The maximum logging level to emit.'), + 'label' => $this->translate('Logging Level'), + 'description' => $this->translate('The maximum logging level to emit.'), 'multiOptions' => array( - Logger::$levels[Logger::ERROR] => t('Error', 'app.config.logging.level'), - Logger::$levels[Logger::WARNING] => t('Warning', 'app.config.logging.level'), - Logger::$levels[Logger::INFO] => t('Information', 'app.config.logging.level'), - Logger::$levels[Logger::DEBUG] => t('Debug', 'app.config.logging.level') + Logger::$levels[Logger::ERROR] => $this->translate('Error', 'app.config.logging.level'), + Logger::$levels[Logger::WARNING] => $this->translate('Warning', 'app.config.logging.level'), + Logger::$levels[Logger::INFO] => $this->translate('Information', 'app.config.logging.level'), + Logger::$levels[Logger::DEBUG] => $this->translate('Debug', 'app.config.logging.level') ) ) ); @@ -65,8 +64,10 @@ class LoggingConfigForm extends Form 'logging_application', array( 'required' => true, - 'label' => t('Application Prefix'), - 'description' => t('The name of the application by which to prefix syslog messages.'), + 'label' => $this->translate('Application Prefix'), + 'description' => $this->translate( + 'The name of the application by which to prefix syslog messages.' + ), 'value' => 'icingaweb2', 'validators' => array( array( @@ -91,8 +92,8 @@ class LoggingConfigForm extends Form // 'logging_facility', // array( // 'required' => true, -// 'label' => t('Facility'), -// 'description' => t('The syslog facility to utilize.'), +// 'label' => $this->translate('Facility'), +// 'description' => $this->translate('The syslog facility to utilize.'), // 'multiOptions' => array( // 'user' => 'LOG_USER' // ) @@ -104,8 +105,8 @@ class LoggingConfigForm extends Form 'logging_file', array( 'required' => true, - 'label' => t('File path'), - 'description' => t('The full path to the log file to write messages to.'), + 'label' => $this->translate('File path'), + 'description' => $this->translate('The full path to the log file to write messages to.'), 'value' => '/var/log/icingaweb2/icingaweb2.log', 'validators' => array(new WritablePathValidator()) ) diff --git a/application/forms/Config/GeneralConfigForm.php b/application/forms/Config/GeneralConfigForm.php index 0d81bb96b..7e3357d7b 100644 --- a/application/forms/Config/GeneralConfigForm.php +++ b/application/forms/Config/GeneralConfigForm.php @@ -20,7 +20,7 @@ class GeneralConfigForm extends ConfigForm public function init() { $this->setName('form_config_general'); - $this->setSubmitLabel(t('Save Changes')); + $this->setSubmitLabel($this->translate('Save Changes')); } /** @@ -52,7 +52,7 @@ class GeneralConfigForm extends ConfigForm } if ($this->save()) { - Notification::success(t('New configuration has successfully been stored')); + Notification::success($this->translate('New configuration has successfully been stored')); } else { return false; } diff --git a/application/forms/Config/Resource/DbResourceForm.php b/application/forms/Config/Resource/DbResourceForm.php index 36e69e9e1..9e4027299 100644 --- a/application/forms/Config/Resource/DbResourceForm.php +++ b/application/forms/Config/Resource/DbResourceForm.php @@ -41,8 +41,8 @@ class DbResourceForm extends Form 'name', array( 'required' => true, - 'label' => t('Resource Name'), - 'description' => t('The unique name of this resource') + 'label' => $this->translate('Resource Name'), + 'description' => $this->translate('The unique name of this resource') ) ); $this->addElement( @@ -50,8 +50,8 @@ class DbResourceForm extends Form 'db', array( 'required' => true, - 'label' => t('Database Type'), - 'description' => t('The type of SQL database'), + 'label' => $this->translate('Database Type'), + 'description' => $this->translate('The type of SQL database'), 'multiOptions' => $dbChoices ) ); @@ -60,8 +60,8 @@ class DbResourceForm extends Form 'host', array ( 'required' => true, - 'label' => t('Host'), - 'description' => t('The hostname of the database'), + 'label' => $this->translate('Host'), + 'description' => $this->translate('The hostname of the database'), 'value' => 'localhost' ) ); @@ -70,8 +70,8 @@ class DbResourceForm extends Form 'port', array( 'required' => true, - 'label' => t('Port'), - 'description' => t('The port to use'), + 'label' => $this->translate('Port'), + 'description' => $this->translate('The port to use'), 'value' => 3306 ) ); @@ -80,8 +80,8 @@ class DbResourceForm extends Form 'dbname', array( 'required' => true, - 'label' => t('Database Name'), - 'description' => t('The name of the database to use') + 'label' => $this->translate('Database Name'), + 'description' => $this->translate('The name of the database to use') ) ); $this->addElement( @@ -89,8 +89,8 @@ class DbResourceForm extends Form 'username', array ( 'required' => true, - 'label' => t('Username'), - 'description' => t('The user name to use for authentication') + 'label' => $this->translate('Username'), + 'description' => $this->translate('The user name to use for authentication') ) ); $this->addElement( @@ -99,8 +99,8 @@ class DbResourceForm extends Form array( 'required' => true, 'renderPassword' => true, - 'label' => t('Password'), - 'description' => t('The password to use for authentication') + 'label' => $this->translate('Password'), + 'description' => $this->translate('The password to use for authentication') ) ); @@ -132,7 +132,9 @@ class DbResourceForm extends Form $resource = ResourceFactory::createResource(new ConfigObject($form->getValues())); $resource->getConnection()->getConnection(); } catch (Exception $e) { - $form->addError(t('Connectivity validation failed, connection to the given resource not possible.')); + $form->addError( + $this->translate('Connectivity validation failed, connection to the given resource not possible.') + ); return false; } diff --git a/application/forms/Config/Resource/FileResourceForm.php b/application/forms/Config/Resource/FileResourceForm.php index 8e2920313..960926114 100644 --- a/application/forms/Config/Resource/FileResourceForm.php +++ b/application/forms/Config/Resource/FileResourceForm.php @@ -30,8 +30,8 @@ class FileResourceForm extends Form 'name', array( 'required' => true, - 'label' => t('Resource Name'), - 'description' => t('The unique name of this resource') + 'label' => $this->translate('Resource Name'), + 'description' => $this->translate('The unique name of this resource') ) ); $this->addElement( @@ -39,8 +39,8 @@ class FileResourceForm extends Form 'filename', array( 'required' => true, - 'label' => t('Filepath'), - 'description' => t('The filename to fetch information from'), + 'label' => $this->translate('Filepath'), + 'description' => $this->translate('The filename to fetch information from'), 'validators' => array(new ReadablePathValidator()) ) ); @@ -49,8 +49,8 @@ class FileResourceForm extends Form 'fields', array( 'required' => true, - 'label' => t('Pattern'), - 'description' => t('The regular expression by which to identify columns') + 'label' => $this->translate('Pattern'), + 'description' => $this->translate('The regular expression by which to identify columns') ) ); diff --git a/application/forms/Config/Resource/LdapResourceForm.php b/application/forms/Config/Resource/LdapResourceForm.php index 6641b96bb..c113e2471 100644 --- a/application/forms/Config/Resource/LdapResourceForm.php +++ b/application/forms/Config/Resource/LdapResourceForm.php @@ -32,8 +32,8 @@ class LdapResourceForm extends Form 'name', array( 'required' => true, - 'label' => t('Resource Name'), - 'description' => t('The unique name of this resource') + 'label' => $this->translate('Resource Name'), + 'description' => $this->translate('The unique name of this resource') ) ); $this->addElement( @@ -41,8 +41,10 @@ class LdapResourceForm extends Form 'hostname', array( 'required' => true, - 'label' => t('Host'), - 'description' => t('The hostname or address of the LDAP server to use for authentication'), + 'label' => $this->translate('Host'), + 'description' => $this->translate( + 'The hostname or address of the LDAP server to use for authentication' + ), 'value' => 'localhost' ) ); @@ -51,8 +53,8 @@ class LdapResourceForm extends Form 'port', array( 'required' => true, - 'label' => t('Port'), - 'description' => t('The port of the LDAP server to use for authentication'), + 'label' => $this->translate('Port'), + 'description' => $this->translate('The port of the LDAP server to use for authentication'), 'value' => 389 ) ); @@ -61,8 +63,10 @@ class LdapResourceForm extends Form 'root_dn', array( 'required' => true, - 'label' => t('Root DN'), - 'description' => t('Only the root and its child nodes will be accessible on this resource.') + 'label' => $this->translate('Root DN'), + 'description' => $this->translate( + 'Only the root and its child nodes will be accessible on this resource.' + ) ) ); $this->addElement( @@ -70,8 +74,8 @@ class LdapResourceForm extends Form 'bind_dn', array( 'required' => true, - 'label' => t('Bind DN'), - 'description' => t('The user dn to use for querying the ldap server') + 'label' => $this->translate('Bind DN'), + 'description' => $this->translate('The user dn to use for querying the ldap server') ) ); $this->addElement( @@ -80,8 +84,8 @@ class LdapResourceForm extends Form array( 'required' => true, 'renderPassword' => true, - 'label' => t('Bind Password'), - 'description' => t('The password to use for querying the ldap server') + 'label' => $this->translate('Bind Password'), + 'description' => $this->translate('The password to use for querying the ldap server') ) ); @@ -119,7 +123,9 @@ class LdapResourceForm extends Form throw new Exception(); } } catch (Exception $e) { - $form->addError(t('Connectivity validation failed, connection to the given resource not possible.')); + $form->addError( + $this->translate('Connectivity validation failed, connection to the given resource not possible.') + ); return false; } diff --git a/application/forms/Config/Resource/LivestatusResourceForm.php b/application/forms/Config/Resource/LivestatusResourceForm.php index 2262cf583..996827228 100644 --- a/application/forms/Config/Resource/LivestatusResourceForm.php +++ b/application/forms/Config/Resource/LivestatusResourceForm.php @@ -33,8 +33,8 @@ class LivestatusResourceForm extends Form 'name', array( 'required' => true, - 'label' => t('Resource Name'), - 'description' => t('The unique name of this resource') + 'label' => $this->translate('Resource Name'), + 'description' => $this->translate('The unique name of this resource') ) ); $this->addElement( @@ -42,8 +42,8 @@ class LivestatusResourceForm extends Form 'socket', array( 'required' => true, - 'label' => t('Socket'), - 'description' => t('The path to your livestatus socket used for querying monitoring data'), + 'label' => $this->translate('Socket'), + 'description' => $this->translate('The path to your livestatus socket used for querying monitoring data'), 'value' => '/var/run/icinga2/cmd/livestatus' ) ); @@ -75,8 +75,10 @@ class LivestatusResourceForm extends Form try { $resource = ResourceFactory::createResource(new ConfigObject($form->getValues())); $resource->connect()->disconnect(); - } catch (Exception $e) { - $form->addError(t('Connectivity validation failed, connection to the given resource not possible.')); + } catch (Exception $_) { + $form->addError( + $this->translate('Connectivity validation failed, connection to the given resource not possible.') + ); return false; } diff --git a/application/forms/Config/ResourceConfigForm.php b/application/forms/Config/ResourceConfigForm.php index e7933c18f..67912142a 100644 --- a/application/forms/Config/ResourceConfigForm.php +++ b/application/forms/Config/ResourceConfigForm.php @@ -22,7 +22,7 @@ class ResourceConfigForm extends ConfigForm public function init() { $this->setName('form_config_resource'); - $this->setSubmitLabel(t('Save Changes')); + $this->setSubmitLabel($this->translate('Save Changes')); } /** @@ -43,7 +43,7 @@ class ResourceConfigForm extends ConfigForm } elseif ($type === 'file') { return new FileResourceForm(); } else { - throw new InvalidArgumentException(sprintf(t('Invalid resource type "%s" provided'), $type)); + throw new InvalidArgumentException(sprintf($this->translate('Invalid resource type "%s" provided'), $type)); } } @@ -62,9 +62,9 @@ class ResourceConfigForm extends ConfigForm { $name = isset($values['name']) ? $values['name'] : ''; if (! $name) { - throw new InvalidArgumentException(t('Resource name missing')); + throw new InvalidArgumentException($this->translate('Resource name missing')); } elseif ($this->config->hasSection($name)) { - throw new InvalidArgumentException(t('Resource already exists')); + throw new InvalidArgumentException($this->translate('Resource already exists')); } unset($values['name']); @@ -85,11 +85,11 @@ class ResourceConfigForm extends ConfigForm public function edit($name, array $values) { if (! $name) { - throw new InvalidArgumentException(t('Old resource name missing')); + throw new InvalidArgumentException($this->translate('Old resource name missing')); } elseif (! ($newName = isset($values['name']) ? $values['name'] : '')) { - throw new InvalidArgumentException(t('New resource name missing')); + throw new InvalidArgumentException($this->translate('New resource name missing')); } elseif (! $this->config->hasSection($name)) { - throw new InvalidArgumentException(t('Unknown resource provided')); + throw new InvalidArgumentException($this->translate('Unknown resource provided')); } $resourceConfig = $this->config->getSection($name); @@ -111,9 +111,9 @@ class ResourceConfigForm extends ConfigForm public function remove($name) { if (! $name) { - throw new InvalidArgumentException(t('Resource name missing')); + throw new InvalidArgumentException($this->translate('Resource name missing')); } elseif (! $this->config->hasSection($name)) { - throw new InvalidArgumentException(t('Unknown resource provided')); + throw new InvalidArgumentException($this->translate('Unknown resource provided')); } $resourceConfig = $this->config->getSection($name); @@ -143,10 +143,10 @@ class ResourceConfigForm extends ConfigForm try { if ($resource === null) { // create new resource $this->add($this->getValues()); - $message = t('Resource "%s" has been successfully created'); + $message = $this->translate('Resource "%s" has been successfully created'); } else { // edit existing resource $this->edit($resource, $this->getValues()); - $message = t('Resource "%s" has been successfully changed'); + $message = $this->translate('Resource "%s" has been successfully changed'); } } catch (InvalidArgumentException $e) { Notification::error($e->getMessage()); @@ -172,9 +172,9 @@ class ResourceConfigForm extends ConfigForm $resource = $this->request->getQuery('resource'); if ($resource !== null) { if ($resource === '') { - throw new ConfigurationError(t('Resource name missing')); + throw new ConfigurationError($this->translate('Resource name missing')); } elseif (! $this->config->hasSection($resource)) { - throw new ConfigurationError(t('Unknown resource provided')); + throw new ConfigurationError($this->translate('Unknown resource provided')); } $configValues = $this->config->getSection($resource)->toArray(); @@ -197,8 +197,8 @@ class ResourceConfigForm extends ConfigForm array( 'order' => 0, 'ignore' => true, - 'label' => t('Force Changes'), - 'description' => t('Check this box to enforce changes without connectivity validation') + 'label' => $this->translate('Force Changes'), + 'description' => $this->translate('Check this box to enforce changes without connectivity validation') ) ); } @@ -211,14 +211,14 @@ class ResourceConfigForm extends ConfigForm $resourceType = isset($formData['type']) ? $formData['type'] : 'db'; $resourceTypes = array( - 'file' => t('File'), + 'file' => $this->translate('File'), 'livestatus' => 'Livestatus', ); if ($resourceType === 'ldap' || Platform::extensionLoaded('ldap')) { $resourceTypes['ldap'] = 'LDAP'; } if ($resourceType === 'db' || Platform::hasMysqlSupport() || Platform::hasPostgresqlSupport()) { - $resourceTypes['db'] = t('SQL Database'); + $resourceTypes['db'] = $this->translate('SQL Database'); } $this->addElement( @@ -227,8 +227,8 @@ class ResourceConfigForm extends ConfigForm array( 'required' => true, 'autosubmit' => true, - 'label' => t('Resource Type'), - 'description' => t('The type of resource'), + 'label' => $this->translate('Resource Type'), + 'description' => $this->translate('The type of resource'), 'multiOptions' => $resourceTypes, 'value' => $resourceType ) diff --git a/application/forms/ConfirmRemovalForm.php b/application/forms/ConfirmRemovalForm.php index 02d7263df..6840db37d 100644 --- a/application/forms/ConfirmRemovalForm.php +++ b/application/forms/ConfirmRemovalForm.php @@ -17,6 +17,6 @@ class ConfirmRemovalForm extends Form public function init() { $this->setName('form_confirm_removal'); - $this->setSubmitLabel(t('Confirm Removal')); + $this->setSubmitLabel($this->translate('Confirm Removal')); } } diff --git a/application/forms/Dashboard/DashletForm.php b/application/forms/Dashboard/DashletForm.php index 6c38ff97e..e58ca8aba 100644 --- a/application/forms/Dashboard/DashletForm.php +++ b/application/forms/Dashboard/DashletForm.php @@ -26,7 +26,7 @@ class DashletForm extends Form { $this->setName('form_dashboard_addurl'); if (! $this->getSubmitLabel()) { - $this->setSubmitLabel(t('Add To Dashboard')); + $this->setSubmitLabel($this->translate('Add To Dashboard')); } $this->setAction(URL::fromRequest()); } @@ -66,9 +66,10 @@ class DashletForm extends Form 'url', array( 'required' => true, - 'label' => t('Url'), - 'description' => - t('Enter url being loaded in the dashlet. You can paste the full URL, including filters.') + 'label' => $this->translate('Url'), + 'description' => $this->translate( + 'Enter url being loaded in the dashlet. You can paste the full URL, including filters.' + ) ) ); $this->addElement( @@ -76,8 +77,8 @@ class DashletForm extends Form 'dashlet', array( 'required' => true, - 'label' => t('Dashlet Title'), - 'description' => t('Enter a title for the dashlet.') + 'label' => $this->translate('Dashlet Title'), + 'description' => $this->translate('Enter a title for the dashlet.') ) ); $this->addElement( @@ -95,9 +96,8 @@ class DashletForm extends Form 'pane', array( 'required' => true, - 'label' => t("New Dashboard Title"), - 'description' => - t('Enter a title for the new pane.') + 'label' => $this->translate("New Dashboard Title"), + 'description' => $this->translate('Enter a title for the new pane.') ) ); } else { @@ -106,10 +106,9 @@ class DashletForm extends Form 'pane', array( 'required' => true, - 'label' => t('Dashboard'), + 'label' => $this->translate('Dashboard'), 'multiOptions' => $panes, - 'description' => - t('Select a pane you want to add the dashlet.') + 'description' => $this->translate('Select a pane you want to add the dashlet.') ) ); } @@ -119,9 +118,9 @@ class DashletForm extends Form 'create_new_pane', array( 'required' => false, - 'label' => t('New dashboard'), + 'label' => $this->translate('New dashboard'), 'class' => 'autosubmit', - 'description' => t('Check this box if you want to add the dashlet to a new dashboard') + 'description' => $this->translate('Check this box if you want to add the dashlet to a new dashboard') ) ); } diff --git a/application/forms/LdapDiscoveryForm.php b/application/forms/LdapDiscoveryForm.php index 0fd0ea0d3..ea5f3a99e 100644 --- a/application/forms/LdapDiscoveryForm.php +++ b/application/forms/LdapDiscoveryForm.php @@ -26,8 +26,8 @@ class LdapDiscoveryForm extends Form 'domain', array( 'required' => true, - 'label' => t('Search Domain'), - 'description' => t('Search this domain for records of available servers.'), + 'label' => $this->translate('Search Domain'), + 'description' => $this->translate('Search this domain for records of available servers.'), ) ); @@ -36,7 +36,7 @@ class LdapDiscoveryForm extends Form 'note', 'additional_description', array( - 'value' => t('No Ldap servers found on this domain.' + 'value' => $this->translate('No Ldap servers found on this domain.' . ' You can try to specify host and port and try again, or just skip this step and ' . 'configure the server manually.' ) @@ -47,8 +47,8 @@ class LdapDiscoveryForm extends Form 'hostname', array( 'required' => false, - 'label' => t('Host'), - 'description' => t('IP or host name to search.'), + 'label' => $this->translate('Host'), + 'description' => $this->translate('IP or host name to search.'), ) ); @@ -57,8 +57,8 @@ class LdapDiscoveryForm extends Form 'port', array( 'required' => false, - 'label' => t('Port'), - 'description' => t('Port', 389), + 'label' => $this->translate('Port'), + 'description' => $this->translate('Port', 389), ) ); } diff --git a/application/forms/PreferenceForm.php b/application/forms/PreferenceForm.php index e3cfdf319..9b5a3ecf8 100644 --- a/application/forms/PreferenceForm.php +++ b/application/forms/PreferenceForm.php @@ -105,9 +105,9 @@ class PreferenceForm extends Form try { if ($this->getElement('btn_submit_preferences')->isChecked()) { $this->save(); - Notification::success(t('Preferences successfully saved')); + Notification::success($this->translate('Preferences successfully saved')); } else { - Notification::success(t('Preferences successfully saved for the current session')); + Notification::success($this->translate('Preferences successfully saved for the current session')); } } catch (Exception $e) { Logger::error($e); @@ -142,13 +142,13 @@ class PreferenceForm extends Form public function createElements(array $formData) { $languages = array(); - $languages['autodetect'] = sprintf(t('Browser (%s)', 'preferences.form'), $this->getLocale()); + $languages['autodetect'] = sprintf($this->translate('Browser (%s)', 'preferences.form'), $this->getLocale()); foreach (Translator::getAvailableLocaleCodes() as $language) { $languages[$language] = $language; } $tzList = array(); - $tzList['autodetect'] = sprintf(t('Browser (%s)', 'preferences.form'), $this->getDefaultTimezone()); + $tzList['autodetect'] = sprintf($this->translate('Browser (%s)', 'preferences.form'), $this->getDefaultTimezone()); foreach (DateTimeZone::listIdentifiers() as $tz) { $tzList[$tz] = $tz; } @@ -158,8 +158,8 @@ class PreferenceForm extends Form 'language', array( 'required' => true, - 'label' => t('Your Current Language'), - 'description' => t('Use the following language to display texts and messages'), + 'label' => $this->translate('Your Current Language'), + 'description' => $this->translate('Use the following language to display texts and messages'), 'multiOptions' => $languages, 'value' => substr(setlocale(LC_ALL, 0), 0, 5) ) @@ -170,8 +170,8 @@ class PreferenceForm extends Form 'timezone', array( 'required' => true, - 'label' => t('Your Current Timezone'), - 'description' => t('Use the following timezone for dates and times'), + 'label' => $this->translate('Your Current Timezone'), + 'description' => $this->translate('Use the following timezone for dates and times'), 'multiOptions' => $tzList, 'value' => $this->getDefaultTimezone() ) @@ -182,7 +182,7 @@ class PreferenceForm extends Form 'show_benchmark', array( 'required' => true, - 'label' => t('Use benchmark') + 'label' => $this->translate('Use benchmark') ) ); @@ -191,7 +191,7 @@ class PreferenceForm extends Form 'btn_submit_preferences', array( 'ignore' => true, - 'label' => t('Save to the Preferences'), + 'label' => $this->translate('Save to the Preferences'), 'decorators' => array( 'ViewHelper', array('HtmlTag', array('tag' => 'div')) @@ -204,7 +204,7 @@ class PreferenceForm extends Form 'btn_submit_session', array( 'ignore' => true, - 'label' => t('Save for the current Session'), + 'label' => $this->translate('Save for the current Session'), 'decorators' => array( 'ViewHelper', array('HtmlTag', array('tag' => 'div')) diff --git a/application/forms/Security/RoleForm.php b/application/forms/Security/RoleForm.php index b27a4ec8b..f32c0cab4 100644 --- a/application/forms/Security/RoleForm.php +++ b/application/forms/Security/RoleForm.php @@ -72,8 +72,8 @@ class RoleForm extends ConfigForm 'name', array( 'required' => true, - 'label' => t('Role Name'), - 'description' => t('The name of the role'), + 'label' => $this->translate('Role Name'), + 'description' => $this->translate('The name of the role'), 'ignore' => true ), ), @@ -81,24 +81,26 @@ class RoleForm extends ConfigForm 'textarea', 'users', array( - 'label' => t('Users'), - 'description' => t('Comma-separated list of users that are assigned to the role') + 'label' => $this->translate('Users'), + 'description' => $this->translate('Comma-separated list of users that are assigned to the role') ), ), array( 'textarea', 'groups', array( - 'label' => t('Groups'), - 'description' => t('Comma-separated list of groups that are assigned to the role') + 'label' => $this->translate('Groups'), + 'description' => $this->translate('Comma-separated list of groups that are assigned to the role') ), ), array( 'multiselect', 'permissions', array( - 'label' => t('Permissions Set'), - 'description' => t('The permissions to grant. You may select more than one permission'), + 'label' => $this->translate('Permissions Set'), + 'description' => $this->translate( + 'The permissions to grant. You may select more than one permission' + ), 'multiOptions' => $this->providedPermissions ) ) @@ -133,7 +135,7 @@ class RoleForm extends ConfigForm } if (! $this->config->hasSection($name)) { throw new InvalidArgumentException(sprintf( - t('Can\'t load role \'%s\'. Role does not exist'), + $this->translate('Can\'t load role \'%s\'. Role does not exist'), $name )); } @@ -174,7 +176,7 @@ class RoleForm extends ConfigForm } if ($this->config->hasSection($name)) { throw new InvalidArgumentException(sprintf( - t('Can\'t add role \'%s\'. Role already exists'), + $this->translate('Can\'t add role \'%s\'. Role already exists'), $name )); } @@ -200,7 +202,7 @@ class RoleForm extends ConfigForm } if (! $this->config->hasSection($name)) { throw new InvalidArgumentException(sprintf( - t('Can\'t remove role \'%s\'. Role does not exist'), + $this->translate('Can\'t remove role \'%s\'. Role does not exist'), $name )); } @@ -233,7 +235,7 @@ class RoleForm extends ConfigForm } else { if (! $this->config->hasSection($name)) { throw new InvalidArgumentException(sprintf( - t('Can\'t update role \'%s\'. Role does not exist'), + $this->translate('Can\'t update role \'%s\'. Role does not exist'), $name )); } From f6eb9a764f8d704cea792334a9b2a0555c1ca1ee Mon Sep 17 00:00:00 2001 From: Matthias Jentsch Date: Mon, 19 Jan 2015 11:33:21 +0100 Subject: [PATCH 0187/2920] Determine axis orientation based on max label length --- library/Icinga/Chart/Axis.php | 47 +++++++++++++++++++++-------------- 1 file changed, 28 insertions(+), 19 deletions(-) diff --git a/library/Icinga/Chart/Axis.php b/library/Icinga/Chart/Axis.php index e6046705a..88718f976 100644 --- a/library/Icinga/Chart/Axis.php +++ b/library/Icinga/Chart/Axis.php @@ -94,22 +94,7 @@ class Axis implements Drawable /** * If the displayed labels should be aligned horizontally or diagonally */ - private $labelRotationStyle = self::LABEL_ROTATE_DIAGONAL; - - /** - * Set the label rotation style for the horizontal axis - * - *
      - *
    • LABEL_ROTATE_HORIZONTAL: Labels will be displayed horizontally
    • - *
    • LABEL_ROTATE_DIAGONAL: Labels will be rotated by 45°
    • - *
    - * - * @param $style The rotation mode - */ - public function setHorizontalLabelRotationStyle($style) - { - $this->labelRotationStyle = $style; - } + protected $labelRotationStyle = self::LABEL_ROTATE_HORIZONTAL; /** * Inform the axis about an added dataset @@ -182,6 +167,12 @@ class Axis implements Drawable $steps = $ticks * 5; } + // Check whether there is enough room for regular labels + $labelRotationStyle = $this->labelRotationStyle; + if ($this->labelsOversized($this->xUnit, 6)) { + $labelRotationStyle = self::LABEL_ROTATE_DIAGONAL; + } + /* $line = new Line(0, 100, 100, 100); $line->setStrokeWidth(2); @@ -203,7 +194,7 @@ class Axis implements Drawable } if ($i % $steps === 0) { - if ($this->labelRotationStyle === self::LABEL_ROTATE_HORIZONTAL) { + if ($labelRotationStyle === self::LABEL_ROTATE_HORIZONTAL) { // If the last label would overlap this label we shift the y axis a bit if ($lastLabelEnd > $pos) { $shift = ($shift + 5) % 10; @@ -213,14 +204,14 @@ class Axis implements Drawable } $labelField = new Text($pos + 0.5, ($this->xLabel ? 107 : 105) + $shift, $label); - if ($this->labelRotationStyle === self::LABEL_ROTATE_HORIZONTAL) { + if ($labelRotationStyle === self::LABEL_ROTATE_HORIZONTAL) { $labelField->setAlignment(Text::ALIGN_MIDDLE) ->setFontSize('2.5em'); } else { $labelField->setFontSize('2.5em'); } - if ($this->labelRotationStyle === self::LABEL_ROTATE_DIAGONAL) { + if ($labelRotationStyle === self::LABEL_ROTATE_DIAGONAL) { $labelField = new Rotator($labelField, 45); } $labelField = $labelField->toSvg($ctx); @@ -477,4 +468,22 @@ class Axis implements Drawable return $per; } + /** + * Returns whether at least one label of the given Axis + * is bigger than the given maxLength + * + * @param AxisUnit $axis The axis that contains the labels that will be checked + * + * @return boolean Whether at least one label is bigger than maxLength + */ + private function labelsOversized(AxisUnit $axis, $maxLength = 5) + { + $oversized = false; + foreach ($axis as $label => $pos) { + if (strlen($label) > $maxLength) { + $oversized = true; + } + } + return $oversized; + } } From a57f1b00a97abba9b21c6a4e61590e5196911d97 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Fri, 16 Jan 2015 17:41:49 +0100 Subject: [PATCH 0188/2920] rpm: Introduce config directory for packaged configuration files refs #4075 --- packages/files/{ => config}/modules/doc/config.ini | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename packages/files/{ => config}/modules/doc/config.ini (100%) diff --git a/packages/files/modules/doc/config.ini b/packages/files/config/modules/doc/config.ini similarity index 100% rename from packages/files/modules/doc/config.ini rename to packages/files/config/modules/doc/config.ini From 601436208917af59b9e08fba8100bef4f6723c4d Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Fri, 16 Jan 2015 17:44:16 +0100 Subject: [PATCH 0189/2920] packages: Install custom setup module config w/ correct path to the schema files refs #4075 --- packages/files/config/modules/setup/config.ini | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 packages/files/config/modules/setup/config.ini diff --git a/packages/files/config/modules/setup/config.ini b/packages/files/config/modules/setup/config.ini new file mode 100644 index 000000000..5158aae99 --- /dev/null +++ b/packages/files/config/modules/setup/config.ini @@ -0,0 +1,2 @@ +[schema] +path = /usr/share/doc/icingaweb2/schema From 556610adc18c2ebe3c62936bd9d915a596b6c63b Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Fri, 16 Jan 2015 17:52:08 +0100 Subject: [PATCH 0190/2920] rpm: icingaweb2-common must not install any config file except the config directory refs #4075 --- icingaweb2.spec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/icingaweb2.spec b/icingaweb2.spec index 4fa670333..7520d336c 100644 --- a/icingaweb2.spec +++ b/icingaweb2.spec @@ -219,7 +219,7 @@ exit 0 %defattr(-,root,root) %{basedir}/application/locale %dir %{basedir}/modules -%attr(2770,root,%{icingawebgroup}) %config(noreplace) %{configdir} +%attr(2770,root,%{icingawebgroup}) %config(noreplace) %dir %{configdir} %files -n php-Icinga From ef412688e9f853643091748fdb4c57299541e1ef Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Fri, 16 Jan 2015 18:10:19 +0100 Subject: [PATCH 0191/2920] setup: Require to set a path to the schema files refs #8232 --- modules/setup/library/Setup/Steps/DatabaseStep.php | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/modules/setup/library/Setup/Steps/DatabaseStep.php b/modules/setup/library/Setup/Steps/DatabaseStep.php index c6ec2ef2b..006b6c9ed 100644 --- a/modules/setup/library/Setup/Steps/DatabaseStep.php +++ b/modules/setup/library/Setup/Steps/DatabaseStep.php @@ -6,7 +6,6 @@ namespace Icinga\Module\Setup\Steps; use Exception; use PDOException; -use Icinga\Application\Icinga; use Icinga\Module\Setup\Step; use Icinga\Module\Setup\Utils\DbTool; use Icinga\Module\Setup\Exception\SetupException; @@ -71,7 +70,7 @@ class DatabaseStep extends Step $this->log(mt('setup', 'Database schema already exists...')); } else { $this->log(mt('setup', 'Creating database schema...')); - $db->import(Icinga::app()->getApplicationDir() . '/../etc/schema/mysql.schema.sql'); + $db->import($this->data['schemaPath'] . '/mysql.schema.sql'); } if ($db->hasLogin($this->data['resourceConfig']['username'])) { @@ -122,7 +121,7 @@ class DatabaseStep extends Step $this->log(mt('setup', 'Database schema already exists...')); } else { $this->log(mt('setup', 'Creating database schema...')); - $db->import(Icinga::app()->getApplicationDir() . '/../etc/schema/pgsql.schema.sql'); + $db->import($this->data['schemaPath'] . '/pgsql.schema.sql'); } if ($db->hasLogin($this->data['resourceConfig']['username'])) { From 70f080313dc44bb85ba324c32f9d63171f3124d5 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Fri, 16 Jan 2015 18:10:54 +0100 Subject: [PATCH 0192/2920] setup: Use schema path from setup's config or default refs #8232 --- modules/setup/library/Setup/WebWizard.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/modules/setup/library/Setup/WebWizard.php b/modules/setup/library/Setup/WebWizard.php index 102c2c6a0..68632e305 100644 --- a/modules/setup/library/Setup/WebWizard.php +++ b/modules/setup/library/Setup/WebWizard.php @@ -295,7 +295,9 @@ class WebWizard extends Wizard implements SetupWizard : null, 'adminPassword' => isset($pageData['setup_database_creation']['password']) ? $pageData['setup_database_creation']['password'] - : null + : null, + 'schemaPath' => Config::module('setup') + ->get('schema', 'path', Icinga::app()->getBaseDir('etc/schema')) )) ); } From 4819ebb6b22166d16c8bcfee8b9701220fdd0f23 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Fri, 16 Jan 2015 18:11:20 +0100 Subject: [PATCH 0193/2920] rpm: Install configuration for the setup module refs #4075 refs #8232 --- icingaweb2.spec | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/icingaweb2.spec b/icingaweb2.spec index 7520d336c..83ba9b4a7 100644 --- a/icingaweb2.spec +++ b/icingaweb2.spec @@ -171,7 +171,7 @@ Icinga Web 2 vendor library Zend %install rm -rf %{buildroot} -mkdir -p %{buildroot}/{%{basedir}/{modules,library,public},%{bindir},%{configdir},%{logdir},%{phpdir},%{wwwconfigdir},%{_sysconfdir}/bash_completion.d,%{docsdir}} +mkdir -p %{buildroot}/{%{basedir}/{modules,library,public},%{bindir},%{configdir}/modules/setup,%{logdir},%{phpdir},%{wwwconfigdir},%{_sysconfdir}/bash_completion.d,%{docsdir}} cp -prv application doc %{buildroot}/%{basedir} cp -pv etc/bash_completion.d/icingacli %{buildroot}/%{_sysconfdir}/bash_completion.d/icingacli cp -prv modules/{monitoring,setup} %{buildroot}/%{basedir}/modules @@ -182,6 +182,7 @@ cp -pv packages/files/apache/icingaweb2.conf %{buildroot}/%{wwwconfigdir}/icinga cp -pv packages/files/bin/icingacli %{buildroot}/%{bindir} cp -pv packages/files/public/index.php %{buildroot}/%{basedir}/public cp -prv etc/schema %{buildroot}/%{docsdir} +cp -prv packages/files/config/modules/setup %{buildroot}/%{configdir}/modules/ %pre getent group icingacmd >/dev/null || groupadd -r icingacmd @@ -209,6 +210,7 @@ rm -rf %{buildroot} %attr(2775,root,%{icingawebgroup}) %dir %{logdir} %{docsdir} %docdir %{docsdir} +%attr(2770,root,%{icingawebgroup}) %config(noreplace) %{configdir}/modules/setup %pre common From f4ea24bfa07cdb1ec2a25b9ce2bcb369ca64041e Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Mon, 19 Jan 2015 10:50:27 +0100 Subject: [PATCH 0194/2920] rpm: Fix configuration files permissions refs #4075 --- icingaweb2.spec | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/icingaweb2.spec b/icingaweb2.spec index 83ba9b4a7..c98a8c65f 100644 --- a/icingaweb2.spec +++ b/icingaweb2.spec @@ -210,7 +210,8 @@ rm -rf %{buildroot} %attr(2775,root,%{icingawebgroup}) %dir %{logdir} %{docsdir} %docdir %{docsdir} -%attr(2770,root,%{icingawebgroup}) %config(noreplace) %{configdir}/modules/setup +%attr(2770,root,%{icingawebgroup}) %config(noreplace) %dir %{configdir}/modules/setup +%attr(0660,root,%{icingawebgroup}) %config(noreplace) %{configdir}/modules/setup/config.ini %pre common @@ -222,6 +223,7 @@ exit 0 %{basedir}/application/locale %dir %{basedir}/modules %attr(2770,root,%{icingawebgroup}) %config(noreplace) %dir %{configdir} +%attr(2770,root,%{icingawebgroup}) %config(noreplace) %dir %{configdir}/modules %files -n php-Icinga From abc74c7fb505b9b089b51a3695f6f8597c0b597a Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Mon, 19 Jan 2015 11:11:59 +0100 Subject: [PATCH 0195/2920] monitoring/setup: Fix directory mode of the monitoring configuration directory We should introduce a CreateConfigDirectoryStep because module developers must not provide a directory mode but use our default. --- modules/monitoring/library/Monitoring/MonitoringWizard.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/monitoring/library/Monitoring/MonitoringWizard.php b/modules/monitoring/library/Monitoring/MonitoringWizard.php index 0ac4c7f63..f524a3d10 100644 --- a/modules/monitoring/library/Monitoring/MonitoringWizard.php +++ b/modules/monitoring/library/Monitoring/MonitoringWizard.php @@ -124,7 +124,7 @@ class MonitoringWizard extends Wizard implements SetupWizard $pageData = $this->getPageData(); $setup = new Setup(); - $setup->addStep(new MakeDirStep(array($this->getConfigDir() . '/modules/monitoring'), 0775)); + $setup->addStep(new MakeDirStep(array($this->getConfigDir() . '/modules/monitoring'), 2770)); $setup->addStep( new BackendStep(array( From c0444a81b24aea332b07eb1409af168c1c53f0c9 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Mon, 19 Jan 2015 11:14:24 +0100 Subject: [PATCH 0196/2920] setup: Fix octdec for directory modes Modes prefixed w/ zero, e.g. 0775 require a string conversion before calling octdec. --- modules/setup/library/Setup/Utils/MakeDirStep.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/setup/library/Setup/Utils/MakeDirStep.php b/modules/setup/library/Setup/Utils/MakeDirStep.php index 27919820b..d7813541b 100644 --- a/modules/setup/library/Setup/Utils/MakeDirStep.php +++ b/modules/setup/library/Setup/Utils/MakeDirStep.php @@ -21,7 +21,7 @@ class MakeDirStep extends Step public function __construct($paths, $dirmode) { $this->paths = $paths; - $this->dirmode = octdec($dirmode); + $this->dirmode = octdec((string) $dirmode); $this->errors = array(); } From 7fc70c5a0238963da56aa2fa0414219d8d0ab10e Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Mon, 19 Jan 2015 11:16:17 +0100 Subject: [PATCH 0197/2920] IniWriter: Don't allow read for others on new files --- library/Icinga/File/Ini/IniWriter.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library/Icinga/File/Ini/IniWriter.php b/library/Icinga/File/Ini/IniWriter.php index 28ca53ff0..21402ab74 100644 --- a/library/Icinga/File/Ini/IniWriter.php +++ b/library/Icinga/File/Ini/IniWriter.php @@ -27,7 +27,7 @@ class IniWriter extends Zend_Config_Writer_FileAbstract * * @var int */ - public static $fileMode = 0664; + public static $fileMode = 0660; /** * Create a new INI writer From 599cb620d86a643b19dbc73a3015972f3ced256c Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Mon, 19 Jan 2015 11:23:43 +0100 Subject: [PATCH 0198/2920] Config: Don't throw NotReadableError if the file does not exist --- library/Icinga/Application/Config.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library/Icinga/Application/Config.php b/library/Icinga/Application/Config.php index dcb837fde..ac37e8c69 100644 --- a/library/Icinga/Application/Config.php +++ b/library/Icinga/Application/Config.php @@ -292,7 +292,7 @@ class Config implements Countable, Iterator $config = new static(new ConfigObject(parse_ini_file($filepath, true))); $config->setConfigFile($filepath); return $config; - } else { + } elseif (@file_exists($filepath)) { throw new NotReadableError(t('Cannot read config file "%s". Permission denied'), $filepath); } From 87adbacb3beda6c7236dfdb2d535b41cc3910141 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Mon, 19 Jan 2015 11:24:41 +0100 Subject: [PATCH 0199/2920] Config: Fix coding style --- library/Icinga/Application/Config.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/library/Icinga/Application/Config.php b/library/Icinga/Application/Config.php index ac37e8c69..676e237a4 100644 --- a/library/Icinga/Application/Config.php +++ b/library/Icinga/Application/Config.php @@ -322,7 +322,7 @@ class Config implements Countable, Iterator */ public static function app($configname = 'config', $fromDisk = false) { - if (!isset(self::$app[$configname]) || $fromDisk) { + if (! isset(self::$app[$configname]) || $fromDisk) { self::$app[$configname] = static::fromIni(static::resolvePath($configname . '.ini')); } @@ -341,12 +341,12 @@ class Config implements Countable, Iterator */ public static function module($modulename, $configname = 'config', $fromDisk = false) { - if (!isset(self::$modules[$modulename])) { + if (! isset(self::$modules[$modulename])) { self::$modules[$modulename] = array(); } $moduleConfigs = self::$modules[$modulename]; - if (!isset($moduleConfigs[$configname]) || $fromDisk) { + if (! isset($moduleConfigs[$configname]) || $fromDisk) { $moduleConfigs[$configname] = static::fromIni( static::resolvePath('modules/' . $modulename . '/' . $configname . '.ini') ); From ac503031a700506e1c1b3f958ae42aecf66d7932 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Mon, 19 Jan 2015 11:25:06 +0100 Subject: [PATCH 0200/2920] Config: Fix PHPDoc for fromIni --- library/Icinga/Application/Config.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library/Icinga/Application/Config.php b/library/Icinga/Application/Config.php index 676e237a4..361f5f11d 100644 --- a/library/Icinga/Application/Config.php +++ b/library/Icinga/Application/Config.php @@ -279,7 +279,7 @@ class Config implements Countable, Iterator * * @param string $file The file to parse * - * @throws NotReadableError When the file does not exist or cannot be read + * @throws NotReadableError When the file cannot be read */ public static function fromIni($file) { From 64d4bb089c4041b60e4feb4c106b369c29d48f94 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Mon, 19 Jan 2015 11:31:35 +0100 Subject: [PATCH 0201/2920] monitoring/setup: Remove function for getting the configuration directory Getting the config directory is not a task for module wizards. --- .../library/Monitoring/MonitoringWizard.php | 20 ++----------------- 1 file changed, 2 insertions(+), 18 deletions(-) diff --git a/modules/monitoring/library/Monitoring/MonitoringWizard.php b/modules/monitoring/library/Monitoring/MonitoringWizard.php index f524a3d10..9c588e5b3 100644 --- a/modules/monitoring/library/Monitoring/MonitoringWizard.php +++ b/modules/monitoring/library/Monitoring/MonitoringWizard.php @@ -4,6 +4,7 @@ namespace Icinga\Module\Monitoring; +use Icinga\Application\Icinga; use Icinga\Web\Form; use Icinga\Web\Wizard; use Icinga\Web\Request; @@ -124,7 +125,7 @@ class MonitoringWizard extends Wizard implements SetupWizard $pageData = $this->getPageData(); $setup = new Setup(); - $setup->addStep(new MakeDirStep(array($this->getConfigDir() . '/modules/monitoring'), 2770)); + $setup->addStep(new MakeDirStep(array(Icinga::app()->getConfigDir() . '/modules/monitoring'), 2770)); $setup->addStep( new BackendStep(array( @@ -159,21 +160,4 @@ class MonitoringWizard extends Wizard implements SetupWizard { return new Requirements(); } - - /** - * Return the configuration directory of Icinga Web 2 - * - * @return string - */ - protected function getConfigDir() - { - if (array_key_exists('ICINGAWEB_CONFIGDIR', $_SERVER)) { - $configDir = $_SERVER['ICINGAWEB_CONFIGDIR']; - } else { - $configDir = '/etc/icingaweb'; - } - - $canonical = realpath($configDir); - return $canonical ? $canonical : $configDir; - } } From ae4a9fe50ccca9a520c269a24c8f1949596988f4 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Mon, 19 Jan 2015 11:43:13 +0100 Subject: [PATCH 0202/2920] puppet: Use hiera for defining the icinga web group --- .puppet/hiera/common.yaml | 1 + .puppet/modules/icingaweb2/manifests/config.pp | 7 ++++--- .../icingaweb2/manifests/config/general.pp | 7 ++++--- .../icingaweb2/manifests/config/module.pp | 9 +++++---- .../profiles/icingaweb2_dev/manifests/init.pp | 17 +++++++++-------- 5 files changed, 23 insertions(+), 18 deletions(-) diff --git a/.puppet/hiera/common.yaml b/.puppet/hiera/common.yaml index c76b904bf..d7802181f 100644 --- a/.puppet/hiera/common.yaml +++ b/.puppet/hiera/common.yaml @@ -5,3 +5,4 @@ icingaweb2::web_path: icingaweb2 icingaweb2::db_user: icingaweb2 icingaweb2::db_pass: icingaweb2 icingaweb2::db_name: icingaweb2 +icingaweb2::group: icingaweb2 diff --git a/.puppet/modules/icingaweb2/manifests/config.pp b/.puppet/modules/icingaweb2/manifests/config.pp index 473d89d06..625c47b7a 100644 --- a/.puppet/modules/icingaweb2/manifests/config.pp +++ b/.puppet/modules/icingaweb2/manifests/config.pp @@ -1,14 +1,15 @@ class icingaweb2::config ( - $config = hiera('icingaweb2::config') + $config = hiera('icingaweb2::config'), + $web_group = hiera('icingaweb2::group') ) { - group { 'icingaweb': + group { $web_group: ensure => present, } file { [ "${config}", "${config}/enabledModules", "${config}/modules", "${config}/preferences" ]: ensure => directory, owner => 'root', - group => 'icingaweb', + group => $web_group, mode => '2770', } } diff --git a/.puppet/modules/icingaweb2/manifests/config/general.pp b/.puppet/modules/icingaweb2/manifests/config/general.pp index c2daec83f..8ccea172f 100644 --- a/.puppet/modules/icingaweb2/manifests/config/general.pp +++ b/.puppet/modules/icingaweb2/manifests/config/general.pp @@ -1,14 +1,15 @@ define icingaweb2::config::general ( $source, - $config = hiera('icingaweb2::config'), - $replace = true + $config = hiera('icingaweb2::config'), + $web_group = hiera('icingaweb2::group'), + $replace = true ) { include icingaweb2::config file { "${config}/${name}.ini": content => template("${source}/${name}.ini.erb"), owner => 'root', - group => 'icingaweb', + group => $web_group, mode => 0660, replace => $replace, } diff --git a/.puppet/modules/icingaweb2/manifests/config/module.pp b/.puppet/modules/icingaweb2/manifests/config/module.pp index 69e5abd6b..19db02250 100644 --- a/.puppet/modules/icingaweb2/manifests/config/module.pp +++ b/.puppet/modules/icingaweb2/manifests/config/module.pp @@ -1,8 +1,9 @@ define icingaweb2::config::module ( $module, $source, - $config = hiera('icingaweb2::config'), - $replace = true + $config = hiera('icingaweb2::config'), + $web_group = hiera('icingaweb2::group'), + $replace = true ) { include icingaweb2::config @@ -10,7 +11,7 @@ define icingaweb2::config::module ( file { "${config}/modules/${module}": ensure => directory, owner => 'root', - group => 'icingaweb', + group => $web_group, mode => '2770', } } @@ -18,7 +19,7 @@ define icingaweb2::config::module ( file { "${config}/modules/${module}/${name}.ini": source => "${source}/modules/${module}/${name}.ini", owner => 'root', - group => 'icingaweb', + group => $web_group, mode => 0660, replace => $replace, } diff --git a/.puppet/profiles/icingaweb2_dev/manifests/init.pp b/.puppet/profiles/icingaweb2_dev/manifests/init.pp index 379f75247..157a9d80a 100644 --- a/.puppet/profiles/icingaweb2_dev/manifests/init.pp +++ b/.puppet/profiles/icingaweb2_dev/manifests/init.pp @@ -1,10 +1,11 @@ class icingaweb2_dev ( - $config = hiera('icingaweb2::config'), - $log = hiera('icingaweb2::log'), - $web_path = hiera('icingaweb2::web_path'), - $db_user = hiera('icingaweb2::db_user'), - $db_pass = hiera('icingaweb2::db_pass'), - $db_name = hiera('icingaweb2::db_name'), + $config = hiera('icingaweb2::config'), + $log = hiera('icingaweb2::log'), + $web_path = hiera('icingaweb2::web_path'), + $db_user = hiera('icingaweb2::db_user'), + $db_pass = hiera('icingaweb2::db_pass'), + $db_name = hiera('icingaweb2::db_name'), + $web_group = hiera('icingaweb2::group'), ) { include apache include php @@ -28,7 +29,7 @@ class icingaweb2_dev ( Exec { path => '/usr/local/bin:/usr/bin:/bin' } # TODO(el): Enabling/disabling modules should be a resource - User <| alias == apache |> { groups +> 'icingaweb' } + User <| alias == apache |> { groups +> $web_group } -> exec { 'enable-monitoring-module': command => 'icingacli module enable monitoring', user => 'apache', @@ -50,7 +51,7 @@ class icingaweb2_dev ( file { $log_dir: ensure => directory, owner => 'root', - group => 'icingaweb', + group => $web_group, mode => '2775' } From fecd4151d1c4284b0861ddf06818f65819517bed Mon Sep 17 00:00:00 2001 From: Matthias Jentsch Date: Mon, 19 Jan 2015 13:35:41 +0100 Subject: [PATCH 0203/2920] Move axis labels to the top of the chart --- library/Icinga/Chart/Axis.php | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/library/Icinga/Chart/Axis.php b/library/Icinga/Chart/Axis.php index 88718f976..c12d9a904 100644 --- a/library/Icinga/Chart/Axis.php +++ b/library/Icinga/Chart/Axis.php @@ -228,15 +228,6 @@ class Axis implements Drawable } $i++; } - - // render the label for this axis - if ($this->xLabel) { - $axisLabel = new Text(50, 104, $this->xLabel); - $axisLabel->setFontSize('2em') - ->setFontWeight('bold') - ->setAlignment(Text::ALIGN_MIDDLE); - $group->appendChild($axisLabel->toSvg($ctx)); - } } /** @@ -287,12 +278,19 @@ class Axis implements Drawable $i++; } - if ($this->yLabel) { - $axisLabel = new Text(-8, 50, $this->yLabel); + if ($this->yLabel || $this->xLabel) { + if ($this->yLabel && $this->xLabel) { + $txt = $this->yLabel . ' / ' . $this->xLabel; + } else if ($this->xLabel) { + $txt = $this->xLabel; + } else { + $txt = $this->yLabel; + } + + $axisLabel = new Text(50, -3, $txt); $axisLabel->setFontSize('2em') ->setFontWeight('bold') ->setAlignment(Text::ALIGN_MIDDLE); - $axisLabel = new Rotator($axisLabel, 90); $group->appendChild($axisLabel->toSvg($ctx)); } From 23bbf63b73a70933944175dcde709d47437330df Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Mon, 19 Jan 2015 13:44:16 +0100 Subject: [PATCH 0204/2920] Revert "Replace t() and mt() with translate() in the monitoring module's forms" This reverts commit 970006838cb2791091dfb2632b1c7eea9d4a243f. --- .../DisableNotificationsExpireCommandForm.php | 11 ++-- .../ToggleInstanceFeaturesCommandForm.php | 28 +++++----- .../Object/AcknowledgeProblemCommandForm.php | 34 ++++++------ .../Command/Object/AddCommentCommandForm.php | 13 +++-- .../Command/Object/CheckNowCommandForm.php | 4 +- .../Object/DeleteCommentCommandForm.php | 4 +- .../Object/DeleteDowntimeCommandForm.php | 4 +- .../Object/ProcessCheckResultCommandForm.php | 30 ++++++----- .../Object/ScheduleHostCheckCommandForm.php | 5 +- .../ScheduleHostDowntimeCommandForm.php | 16 +++--- .../ScheduleServiceCheckCommandForm.php | 17 +++--- .../ScheduleServiceDowntimeCommandForm.php | 34 ++++++------ .../ToggleObjectFeaturesCommandForm.php | 16 +++--- .../Config/Instance/LocalInstanceForm.php | 4 +- .../Config/Instance/RemoteInstanceForm.php | 16 +++--- .../RemoteInstanceKeyResourcePage.php | 54 ------------------- .../forms/Config/InstanceConfigForm.php | 34 ++++++------ .../forms/Config/SecurityConfigForm.php | 8 +-- .../application/forms/EventOverviewForm.php | 10 ++-- .../application/forms/Setup/BackendPage.php | 15 +++--- .../forms/Setup/IdoResourcePage.php | 11 ++-- .../application/forms/Setup/InstancePage.php | 5 +- .../forms/Setup/LivestatusResourcePage.php | 11 ++-- .../application/forms/Setup/SecurityPage.php | 5 +- .../application/forms/Setup/WelcomePage.php | 10 ++-- .../application/forms/StatehistoryForm.php | 42 +++++++-------- 26 files changed, 204 insertions(+), 237 deletions(-) delete mode 100644 modules/monitoring/application/forms/Config/Instance/RemoteInstanceKeyResourcePage.php diff --git a/modules/monitoring/application/forms/Command/Instance/DisableNotificationsExpireCommandForm.php b/modules/monitoring/application/forms/Command/Instance/DisableNotificationsExpireCommandForm.php index 21d926b58..0e64a4b03 100644 --- a/modules/monitoring/application/forms/Command/Instance/DisableNotificationsExpireCommandForm.php +++ b/modules/monitoring/application/forms/Command/Instance/DisableNotificationsExpireCommandForm.php @@ -21,7 +21,7 @@ class DisableNotificationsExpireCommandForm extends CommandForm */ public function init() { - $this->setSubmitLabel($this->translate('Disable Notifications')); + $this->setSubmitLabel(mt('monitoring', 'Disable Notifications')); } /** @@ -30,7 +30,8 @@ class DisableNotificationsExpireCommandForm extends CommandForm */ public function getHelp() { - return $this->translate( + return mt( + 'monitoring', 'This command is used to disable host and service notifications for a specific time.' ); } @@ -48,8 +49,8 @@ class DisableNotificationsExpireCommandForm extends CommandForm 'expire_time', array( 'required' => true, - 'label' => $this->translate('Expire Time'), - 'description' => $this->translate('Set the expire time.'), + 'label' => mt('monitoring', 'Expire Time'), + 'description' => mt('monitoring', 'Set the expire time.'), 'value' => $expireTime ) ); @@ -66,7 +67,7 @@ class DisableNotificationsExpireCommandForm extends CommandForm $disableNotifications ->setExpireTime($this->getElement('expire_time')->getValue()->getTimestamp()); $this->getTransport($this->request)->send($disableNotifications); - Notification::success($this->translate('Disabling host and service notifications..')); + Notification::success(mt('monitoring', 'Disabling host and service notifications..')); return true; } } diff --git a/modules/monitoring/application/forms/Command/Instance/ToggleInstanceFeaturesCommandForm.php b/modules/monitoring/application/forms/Command/Instance/ToggleInstanceFeaturesCommandForm.php index 469c1b6eb..291619b2f 100644 --- a/modules/monitoring/application/forms/Command/Instance/ToggleInstanceFeaturesCommandForm.php +++ b/modules/monitoring/application/forms/Command/Instance/ToggleInstanceFeaturesCommandForm.php @@ -61,13 +61,13 @@ class ToggleInstanceFeaturesCommandForm extends CommandForm if ((bool) $this->status->notifications_enabled) { $notificationDescription = sprintf( '%s', - $this->translate('Disable notifications for a specific time on a program-wide basis'), + mt('monitoring', 'Disable notifications for a specific time on a program-wide basis'), $this->getView()->href('monitoring/process/disable-notifications'), - $this->translate('Disable temporarily') + mt('monitoring', 'Disable temporarily') ); } elseif ($this->status->disable_notif_expire_time) { $notificationDescription = sprintf( - $this->translate('Notifications will be re-enabled in %s'), + mt('monitoring', 'Notifications will be re-enabled in %s'), $this->getView()->timeUntil($this->status->disable_notif_expire_time) ); } else { @@ -78,7 +78,7 @@ class ToggleInstanceFeaturesCommandForm extends CommandForm 'checkbox', ToggleInstanceFeatureCommand::FEATURE_ACTIVE_HOST_CHECKS, array( - 'label' => $this->translate('Active Host Checks Being Executed'), + 'label' => mt('monitoring', 'Active Host Checks Being Executed'), 'autosubmit' => true ) ), @@ -86,7 +86,7 @@ class ToggleInstanceFeaturesCommandForm extends CommandForm 'checkbox', ToggleInstanceFeatureCommand::FEATURE_ACTIVE_SERVICE_CHECKS, array( - 'label' => $this->translate('Active Service Checks Being Executed'), + 'label' => mt('monitoring', 'Active Service Checks Being Executed'), 'autosubmit' => true ) ), @@ -94,7 +94,7 @@ class ToggleInstanceFeaturesCommandForm extends CommandForm 'checkbox', ToggleInstanceFeatureCommand::FEATURE_EVENT_HANDLERS, array( - 'label' => $this->translate('Event Handlers Enabled'), + 'label' => mt('monitoring', 'Event Handlers Enabled'), 'autosubmit' => true ) ), @@ -102,7 +102,7 @@ class ToggleInstanceFeaturesCommandForm extends CommandForm 'checkbox', ToggleInstanceFeatureCommand::FEATURE_FLAP_DETECTION, array( - 'label' => $this->translate('Flap Detection Enabled'), + 'label' => mt('monitoring', 'Flap Detection Enabled'), 'autosubmit' => true ) ), @@ -110,7 +110,7 @@ class ToggleInstanceFeaturesCommandForm extends CommandForm 'checkbox', ToggleInstanceFeatureCommand::FEATURE_NOTIFICATIONS, array( - 'label' => $this->translate('Notifications Enabled'), + 'label' => mt('monitoring', 'Notifications Enabled'), 'autosubmit' => true, 'description' => $notificationDescription, 'decorators' => array( @@ -129,7 +129,7 @@ class ToggleInstanceFeaturesCommandForm extends CommandForm 'checkbox', ToggleInstanceFeatureCommand::FEATURE_HOST_OBSESSING, array( - 'label' => $this->translate('Obsessing Over Hosts'), + 'label' => mt('monitoring', 'Obsessing Over Hosts'), 'autosubmit' => true ) ), @@ -137,7 +137,7 @@ class ToggleInstanceFeaturesCommandForm extends CommandForm 'checkbox', ToggleInstanceFeatureCommand::FEATURE_SERVICE_OBSESSING, array( - 'label' => $this->translate('Obsessing Over Services'), + 'label' => mt('monitoring', 'Obsessing Over Services'), 'autosubmit' => true ) ), @@ -145,7 +145,7 @@ class ToggleInstanceFeaturesCommandForm extends CommandForm 'checkbox', ToggleInstanceFeatureCommand::FEATURE_PASSIVE_HOST_CHECKS, array( - 'label' => $this->translate('Passive Host Checks Being Accepted'), + 'label' => mt('monitoring', 'Passive Host Checks Being Accepted'), 'autosubmit' => true ) ), @@ -153,7 +153,7 @@ class ToggleInstanceFeaturesCommandForm extends CommandForm 'checkbox', ToggleInstanceFeatureCommand::FEATURE_PASSIVE_SERVICE_CHECKS, array( - 'label' => $this->translate('Passive Service Checks Being Accepted'), + 'label' => mt('monitoring', 'Passive Service Checks Being Accepted'), 'autosubmit' => true ) ), @@ -161,7 +161,7 @@ class ToggleInstanceFeaturesCommandForm extends CommandForm 'checkbox', ToggleInstanceFeatureCommand::FEATURE_PERFORMANCE_DATA, array( - 'label' => $this->translate('Performance Data Being Processed'), + 'label' => mt('monitoring', 'Performance Data Being Processed'), 'autosubmit' => true ) ) @@ -198,7 +198,7 @@ class ToggleInstanceFeaturesCommandForm extends CommandForm ->setEnabled($enabled); $this->getTransport($this->request)->send($toggleFeature); } - Notification::success($this->translate('Toggling feature..')); + Notification::success(mt('monitoring', 'Toggling feature..')); return true; } } diff --git a/modules/monitoring/application/forms/Command/Object/AcknowledgeProblemCommandForm.php b/modules/monitoring/application/forms/Command/Object/AcknowledgeProblemCommandForm.php index df3731837..25ac76c25 100644 --- a/modules/monitoring/application/forms/Command/Object/AcknowledgeProblemCommandForm.php +++ b/modules/monitoring/application/forms/Command/Object/AcknowledgeProblemCommandForm.php @@ -31,7 +31,8 @@ class AcknowledgeProblemCommandForm extends ObjectsCommandForm */ public function getHelp() { - return $this->translate( + return mt( + 'monitoring', 'This command is used to acknowledge host or service problems. When a problem is acknowledged,' . ' future notifications about problems are temporarily disabled until the host or service' . ' recovers.' @@ -50,8 +51,9 @@ class AcknowledgeProblemCommandForm extends ObjectsCommandForm 'comment', array( 'required' => true, - 'label' => $this->translate('Comment'), - 'description' => $this->translate( + 'label' => mt('monitoring', 'Comment'), + 'description' => mt( + 'monitoring', 'If you work with other administrators, you may find it useful to share information about the' . ' the host or service that is having problems. Make sure you enter a brief description of' . ' what you are doing.' @@ -62,8 +64,9 @@ class AcknowledgeProblemCommandForm extends ObjectsCommandForm 'checkbox', 'persistent', array( - 'label' => $this->translate('Persistent Comment'), - 'description' => $this->translate( + 'label' => mt('monitoring', 'Persistent Comment'), + 'description' => mt( + 'monitoring', 'If you would like the comment to remain even when the acknowledgement is removed, check this' . ' option.' ) @@ -73,10 +76,8 @@ class AcknowledgeProblemCommandForm extends ObjectsCommandForm 'checkbox', 'expire', array( - 'label' => $this->translate('Use Expire Time'), - 'description' => $this->translate( - 'If the acknowledgement should expire, check this option.' - ), + 'label' => mt('monitoring', 'Use Expire Time'), + 'description' => mt('monitoring', 'If the acknowledgement should expire, check this option.'), 'autosubmit' => true ) ) @@ -88,9 +89,10 @@ class AcknowledgeProblemCommandForm extends ObjectsCommandForm 'dateTimePicker', 'expire_time', array( - 'label' => $this->translate('Expire Time'), + 'label' => mt('monitoring', 'Expire Time'), 'value' => $expireTime, - 'description' => $this->translate( + 'description' => mt( + 'monitoring', 'Enter the expire date and time for this acknowledgement here. Icinga will delete the' . ' acknowledgement after this time expired.' ) @@ -112,9 +114,10 @@ class AcknowledgeProblemCommandForm extends ObjectsCommandForm 'checkbox', 'sticky', array( - 'label' => $this->translate('Sticky Acknowledgement'), + 'label' => mt('monitoring', 'Sticky Acknowledgement'), 'value' => true, - 'description' => $this->translate( + 'description' => mt( + 'monitoring', 'If you want the acknowledgement to disable notifications until the host or service recovers,' . ' check this option.' ) @@ -124,9 +127,10 @@ class AcknowledgeProblemCommandForm extends ObjectsCommandForm 'checkbox', 'notify', array( - 'label' => $this->translate('Send Notification'), + 'label' => mt('monitoring', 'Send Notification'), 'value' => true, - 'description' => $this->translate( + 'description' => mt( + 'monitoring', 'If you do not want an acknowledgement notification to be sent out to the appropriate contacts,' . ' uncheck this option.' ) diff --git a/modules/monitoring/application/forms/Command/Object/AddCommentCommandForm.php b/modules/monitoring/application/forms/Command/Object/AddCommentCommandForm.php index e7f7e91f9..f5adf6c71 100644 --- a/modules/monitoring/application/forms/Command/Object/AddCommentCommandForm.php +++ b/modules/monitoring/application/forms/Command/Object/AddCommentCommandForm.php @@ -29,7 +29,8 @@ class AddCommentCommandForm extends ObjectsCommandForm */ public function getHelp() { - return $this->translate( + return mt( + 'monitoring', 'This command is used to add host or service comments.' ); } @@ -46,8 +47,9 @@ class AddCommentCommandForm extends ObjectsCommandForm 'comment', array( 'required' => true, - 'label' => $this->translate('Comment'), - 'description' => $this->translate( + 'label' => mt('monitoring', 'Comment'), + 'description' => mt( + 'monitoring', 'If you work with other administrators, you may find it useful to share information about the' . ' the host or service that is having problems. Make sure you enter a brief description of' . ' what you are doing.' @@ -58,9 +60,10 @@ class AddCommentCommandForm extends ObjectsCommandForm 'checkbox', 'persistent', array( - 'label' => $this->translate('Persistent'), + 'label' => mt('monitoring', 'Persistent'), 'value' => true, - 'description' => $this->translate( + 'description' => mt( + 'monitoring', 'If you uncheck this option, the comment will automatically be deleted the next time Icinga is' . ' restarted.' ) diff --git a/modules/monitoring/application/forms/Command/Object/CheckNowCommandForm.php b/modules/monitoring/application/forms/Command/Object/CheckNowCommandForm.php index 1054aae05..01006683f 100644 --- a/modules/monitoring/application/forms/Command/Object/CheckNowCommandForm.php +++ b/modules/monitoring/application/forms/Command/Object/CheckNowCommandForm.php @@ -35,8 +35,8 @@ class CheckNowCommandForm extends ObjectsCommandForm array( 'ignore' => true, 'type' => 'submit', - 'value' => $this->translate('Check now'), - 'label' => ' ' . $this->translate('Check now'), + 'value' => mt('monitoring', 'Check now'), + 'label' => ' ' . mt('monitoring', 'Check now'), 'decorators' => array('ViewHelper'), 'escape' => false, 'class' => 'link-like' diff --git a/modules/monitoring/application/forms/Command/Object/DeleteCommentCommandForm.php b/modules/monitoring/application/forms/Command/Object/DeleteCommentCommandForm.php index 0f7858ad9..3d85afcec 100644 --- a/modules/monitoring/application/forms/Command/Object/DeleteCommentCommandForm.php +++ b/modules/monitoring/application/forms/Command/Object/DeleteCommentCommandForm.php @@ -55,7 +55,7 @@ class DeleteCommentCommandForm extends ObjectsCommandForm array( 'ignore' => true, 'label' => 'X', - 'title' => $this->translate('Delete comment'), + 'title' => mt('monitoring', 'Delete comment'), 'decorators' => array('ViewHelper') ) ); @@ -80,7 +80,7 @@ class DeleteCommentCommandForm extends ObjectsCommandForm if (! empty($redirect)) { $this->setRedirectUrl($redirect); } - Notification::success($this->translate('Deleting comment..')); + Notification::success(mt('monitoring', 'Deleting comment..')); return true; } } diff --git a/modules/monitoring/application/forms/Command/Object/DeleteDowntimeCommandForm.php b/modules/monitoring/application/forms/Command/Object/DeleteDowntimeCommandForm.php index 43ca52b05..1c7095b82 100644 --- a/modules/monitoring/application/forms/Command/Object/DeleteDowntimeCommandForm.php +++ b/modules/monitoring/application/forms/Command/Object/DeleteDowntimeCommandForm.php @@ -55,7 +55,7 @@ class DeleteDowntimeCommandForm extends ObjectsCommandForm array( 'ignore' => true, 'label' => 'X', - 'title' => $this->translate('Delete downtime'), + 'title' => mt('monitoring', 'Delete downtime'), 'decorators' => array('ViewHelper') ) ); @@ -80,7 +80,7 @@ class DeleteDowntimeCommandForm extends ObjectsCommandForm if (! empty($redirect)) { $this->setRedirectUrl($redirect); } - Notification::success($this->translate('Deleting downtime..')); + Notification::success(mt('monitoring', 'Deleting downtime..')); return true; } } diff --git a/modules/monitoring/application/forms/Command/Object/ProcessCheckResultCommandForm.php b/modules/monitoring/application/forms/Command/Object/ProcessCheckResultCommandForm.php index 44e248956..48ee00ab3 100644 --- a/modules/monitoring/application/forms/Command/Object/ProcessCheckResultCommandForm.php +++ b/modules/monitoring/application/forms/Command/Object/ProcessCheckResultCommandForm.php @@ -29,7 +29,8 @@ class ProcessCheckResultCommandForm extends ObjectsCommandForm */ public function getHelp() { - return $this->translate( + return mt( + 'monitoring', 'This command is used to submit passive host or service check results.' ); } @@ -52,17 +53,17 @@ class ProcessCheckResultCommandForm extends ObjectsCommandForm 'status', array( 'required' => true, - 'label' => $this->translate('Status'), - 'description' => $this->translate('The state this check result should report'), + 'label' => mt('monitoring', 'Status'), + 'description' => mt('monitoring', 'The state this check result should report'), 'multiOptions' => $object->getType() === $object::TYPE_HOST ? array( - ProcessCheckResultCommand::HOST_UP => $this->translate('UP', 'icinga.state'), - ProcessCheckResultCommand::HOST_DOWN => $this->translate('DOWN', 'icinga.state'), - ProcessCheckResultCommand::HOST_UNREACHABLE => $this->translate('UNREACHABLE', 'icinga.state') + ProcessCheckResultCommand::HOST_UP => mt('monitoring', 'UP', 'icinga.state'), + ProcessCheckResultCommand::HOST_DOWN => mt('monitoring', 'DOWN', 'icinga.state'), + ProcessCheckResultCommand::HOST_UNREACHABLE => mt('monitoring', 'UNREACHABLE', 'icinga.state') ) : array( - ProcessCheckResultCommand::SERVICE_OK => $this->translate('OK', 'icinga.state'), - ProcessCheckResultCommand::SERVICE_WARNING => $this->translate('WARNING', 'icinga.state'), - ProcessCheckResultCommand::SERVICE_CRITICAL => $this->translate('CRITICAL', 'icinga.state'), - ProcessCheckResultCommand::SERVICE_UNKNOWN => $this->translate('UNKNOWN', 'icinga.state') + ProcessCheckResultCommand::SERVICE_OK => mt('monitoring', 'OK', 'icinga.state'), + ProcessCheckResultCommand::SERVICE_WARNING => mt('monitoring', 'WARNING', 'icinga.state'), + ProcessCheckResultCommand::SERVICE_CRITICAL => mt('monitoring', 'CRITICAL', 'icinga.state'), + ProcessCheckResultCommand::SERVICE_UNKNOWN => mt('monitoring', 'UNKNOWN', 'icinga.state') ) ) ); @@ -71,8 +72,8 @@ class ProcessCheckResultCommandForm extends ObjectsCommandForm 'output', array( 'required' => true, - 'label' => $this->translate('Output'), - 'description' => $this->translate('The plugin output of this check result') + 'label' => mt('monitoring', 'Output'), + 'description' => mt('monitoring', 'The plugin output of this check result') ) ); $this->addElement( @@ -80,8 +81,9 @@ class ProcessCheckResultCommandForm extends ObjectsCommandForm 'perfdata', array( 'allowEmpty' => true, - 'label' => $this->translate('Performance Data'), - 'description' => $this->translate( + 'label' => mt('monitoring', 'Performance Data'), + 'description' => mt( + 'monitoring', 'The performance data of this check result. Leave empty' . ' if this check result has no performance data' ) diff --git a/modules/monitoring/application/forms/Command/Object/ScheduleHostCheckCommandForm.php b/modules/monitoring/application/forms/Command/Object/ScheduleHostCheckCommandForm.php index 949ec33e1..82a9b2e52 100644 --- a/modules/monitoring/application/forms/Command/Object/ScheduleHostCheckCommandForm.php +++ b/modules/monitoring/application/forms/Command/Object/ScheduleHostCheckCommandForm.php @@ -24,8 +24,9 @@ class ScheduleHostCheckCommandForm extends ScheduleServiceCheckCommandForm 'checkbox', 'all_services', array( - 'label' => $this->translate('All Services'), - 'description' => $this->translate( + 'label' => mt('monitoring', 'All Services'), + 'description' => mt( + 'monitoring', 'Schedule check for all services on the hosts and the hosts themselves.' ) ) diff --git a/modules/monitoring/application/forms/Command/Object/ScheduleHostDowntimeCommandForm.php b/modules/monitoring/application/forms/Command/Object/ScheduleHostDowntimeCommandForm.php index f84069a9a..beb0793ef 100644 --- a/modules/monitoring/application/forms/Command/Object/ScheduleHostDowntimeCommandForm.php +++ b/modules/monitoring/application/forms/Command/Object/ScheduleHostDowntimeCommandForm.php @@ -27,8 +27,9 @@ class ScheduleHostDowntimeCommandForm extends ScheduleServiceDowntimeCommandForm 'checkbox', 'all_services', array( - 'label' => $this->translate('All Services'), - 'description' => $this->translate( + 'label' => mt('monitoring', 'All Services'), + 'description' => mt( + 'monitoring', 'Schedule downtime for all services on the hosts and the hosts themselves.' ) ) @@ -37,14 +38,15 @@ class ScheduleHostDowntimeCommandForm extends ScheduleServiceDowntimeCommandForm 'select', 'child_hosts', array( - 'label' => $this->translate('Child Hosts'), + 'label' => mt('monitoring', 'Child Hosts'), 'required' => true, 'multiOptions' => array( - 0 => $this->translate('Do nothing with child hosts'), - 1 => $this->translate('Schedule triggered downtime for all child hosts'), - 2 => $this->translate('Schedule non-triggered downtime for all child hosts') + 0 => mt('monitoring', 'Do nothing with child hosts'), + 1 => mt('monitoring', 'Schedule triggered downtime for all child hosts'), + 2 => mt('monitoring', 'Schedule non-triggered downtime for all child hosts') ), - 'description' => $this->translate( + 'description' => mt( + 'monitoring', 'Define what should be done with the child hosts of the hosts.' ) ) diff --git a/modules/monitoring/application/forms/Command/Object/ScheduleServiceCheckCommandForm.php b/modules/monitoring/application/forms/Command/Object/ScheduleServiceCheckCommandForm.php index b34472d49..9e04a2254 100644 --- a/modules/monitoring/application/forms/Command/Object/ScheduleServiceCheckCommandForm.php +++ b/modules/monitoring/application/forms/Command/Object/ScheduleServiceCheckCommandForm.php @@ -32,7 +32,8 @@ class ScheduleServiceCheckCommandForm extends ObjectsCommandForm */ public function getHelp() { - return $this->translate( + return mt( + 'monitoring', 'This command is used to schedule the next check of hosts or services. Icinga will re-queue the' . ' hosts or services to be checked at the time you specify.' ); @@ -51,7 +52,8 @@ class ScheduleServiceCheckCommandForm extends ObjectsCommandForm 'note', 'command-info', array( - 'value' => $this->translate( + 'value' => mt( + 'monitoring', 'This command is used to schedule the next check of hosts or services. Icinga will re-queue the' . ' hosts or services to be checked at the time you specify.' ) @@ -62,10 +64,8 @@ class ScheduleServiceCheckCommandForm extends ObjectsCommandForm 'check_time', array( 'required' => true, - 'label' => $this->translate('Check Time'), - 'description' => $this->translate( - 'Set the date and time when the check should be scheduled.' - ), + 'label' => mt('monitoring', 'Check Time'), + 'description' => mt('monitoring', 'Set the date and time when the check should be scheduled.'), 'value' => $checkTime ) ), @@ -73,8 +73,9 @@ class ScheduleServiceCheckCommandForm extends ObjectsCommandForm 'checkbox', 'force_check', array( - 'label' => $this->translate('Force Check'), - 'description' => $this->translate( + 'label' => mt('monitoring', 'Force Check'), + 'description' => mt( + 'monitoring', 'If you select this option, Icinga will force a check regardless of both what time the' . ' scheduled check occurs and whether or not checks are enabled.' ) diff --git a/modules/monitoring/application/forms/Command/Object/ScheduleServiceDowntimeCommandForm.php b/modules/monitoring/application/forms/Command/Object/ScheduleServiceDowntimeCommandForm.php index 4f66898f6..9961d4b65 100644 --- a/modules/monitoring/application/forms/Command/Object/ScheduleServiceDowntimeCommandForm.php +++ b/modules/monitoring/application/forms/Command/Object/ScheduleServiceDowntimeCommandForm.php @@ -42,7 +42,8 @@ class ScheduleServiceDowntimeCommandForm extends ObjectsCommandForm */ public function getHelp() { - return $this->translate( + return mt( + 'monitoring', 'This command is used to schedule host and service downtimes. During the specified downtime,' . ' Icinga will not send notifications out about the hosts and services. When the scheduled' . ' downtime expires, Icinga will send out notifications for the hosts and services as it' @@ -66,8 +67,9 @@ class ScheduleServiceDowntimeCommandForm extends ObjectsCommandForm 'comment', array( 'required' => true, - 'label' => $this->translate('Comment'), - 'description' => $this->translate( + 'label' => mt('monitoring', 'Comment'), + 'description' => mt( + 'monitoring', 'If you work with other administrators, you may find it useful to share information about the' . ' the host or service that is having problems. Make sure you enter a brief description of' . ' what you are doing.' @@ -79,8 +81,8 @@ class ScheduleServiceDowntimeCommandForm extends ObjectsCommandForm 'start', array( 'required' => true, - 'label' => $this->translate('Start Time'), - 'description' => $this->translate('Set the start date and time for the downtime.'), + 'label' => mt('monitoring', 'Start Time'), + 'description' => mt('monitoring', 'Set the start date and time for the downtime.'), 'value' => $start ) ), @@ -89,8 +91,8 @@ class ScheduleServiceDowntimeCommandForm extends ObjectsCommandForm 'end', array( 'required' => true, - 'label' => $this->translate('End Time'), - 'description' => $this->translate('Set the end date and time for the downtime.'), + 'label' => mt('monitoring', 'End Time'), + 'description' => mt('monitoring', 'Set the end date and time for the downtime.'), 'value' => $end ) ), @@ -100,16 +102,17 @@ class ScheduleServiceDowntimeCommandForm extends ObjectsCommandForm array( 'required' => true, 'autosubmit' => true, - 'label' => $this->translate('Type'), - 'description' => $this->translate( + 'label' => mt('monitoring', 'Type'), + 'description' => mt( + 'monitoring', 'If you select the fixed option, the downtime will be in effect between the start and end' . ' times you specify whereas a flexible downtime starts when the host or service enters a' . ' problem state sometime between the start and end times you specified and lasts as long' . ' as the duration time you enter. The duration fields do not apply for fixed downtimes.' ), 'multiOptions' => array( - self::FIXED => $this->translate('Fixed'), - self::FLEXIBLE => $this->translate('Flexible') + self::FIXED => mt('monitoring', 'Fixed'), + self::FLEXIBLE => mt('monitoring', 'Flexible') ), 'validators' => array( array( @@ -138,7 +141,7 @@ class ScheduleServiceDowntimeCommandForm extends ObjectsCommandForm 'hours', array( 'required' => true, - 'label' => $this->translate('Hours'), + 'label' => mt('monitoring', 'Hours'), 'value' => 2, 'min' => -1 ) @@ -148,7 +151,7 @@ class ScheduleServiceDowntimeCommandForm extends ObjectsCommandForm 'minutes', array( 'required' => true, - 'label' => $this->translate('Minutes'), + 'label' => mt('monitoring', 'Minutes'), 'value' => 0, 'min' => -1 ) @@ -158,8 +161,9 @@ class ScheduleServiceDowntimeCommandForm extends ObjectsCommandForm array('hours', 'minutes'), 'duration', array( - 'legend' => $this->translate('Flexible Duration'), - 'description' => $this->translate( + 'legend' => mt('monitoring', 'Flexible Duration'), + 'description' => mt( + 'monitoring', 'Enter here the duration of the downtime. The downtime will be automatically deleted after this' . ' time expired.' ), diff --git a/modules/monitoring/application/forms/Command/Object/ToggleObjectFeaturesCommandForm.php b/modules/monitoring/application/forms/Command/Object/ToggleObjectFeaturesCommandForm.php index bf0a1d8b1..c33527895 100644 --- a/modules/monitoring/application/forms/Command/Object/ToggleObjectFeaturesCommandForm.php +++ b/modules/monitoring/application/forms/Command/Object/ToggleObjectFeaturesCommandForm.php @@ -33,7 +33,7 @@ class ToggleObjectFeaturesCommandForm extends ObjectsCommandForm 'checkbox', ToggleObjectFeatureCommand::FEATURE_ACTIVE_CHECKS, array( - 'label' => $this->translate('Active Checks'), + 'label' => mt('monitoring', 'Active Checks'), 'autosubmit' => true ) ), @@ -41,7 +41,7 @@ class ToggleObjectFeaturesCommandForm extends ObjectsCommandForm 'checkbox', ToggleObjectFeatureCommand::FEATURE_PASSIVE_CHECKS, array( - 'label' => $this->translate('Passive Checks'), + 'label' => mt('monitoring', 'Passive Checks'), 'autosubmit' => true ) ), @@ -49,7 +49,7 @@ class ToggleObjectFeaturesCommandForm extends ObjectsCommandForm 'checkbox', ToggleObjectFeatureCommand::FEATURE_OBSESSING, array( - 'label' => $this->translate('Obsessing'), + 'label' => mt('monitoring', 'Obsessing'), 'autosubmit' => true ) ), @@ -57,7 +57,7 @@ class ToggleObjectFeaturesCommandForm extends ObjectsCommandForm 'checkbox', ToggleObjectFeatureCommand::FEATURE_NOTIFICATIONS, array( - 'label' => $this->translate('Notifications'), + 'label' => mt('monitoring', 'Notifications'), 'autosubmit' => true ) ), @@ -65,7 +65,7 @@ class ToggleObjectFeaturesCommandForm extends ObjectsCommandForm 'checkbox', ToggleObjectFeatureCommand::FEATURE_EVENT_HANDLER, array( - 'label' => $this->translate('Event Handler'), + 'label' => mt('monitoring', 'Event Handler'), 'autosubmit' => true ) ), @@ -73,7 +73,7 @@ class ToggleObjectFeaturesCommandForm extends ObjectsCommandForm 'checkbox', ToggleObjectFeatureCommand::FEATURE_FLAP_DETECTION, array( - 'label' => $this->translate('Flap Detection'), + 'label' => mt('monitoring', 'Flap Detection'), 'autosubmit' => true ) ) @@ -95,7 +95,7 @@ class ToggleObjectFeaturesCommandForm extends ObjectsCommandForm $element = $this->getElement($feature); $element->setChecked($object->{$feature}); if ((bool) $object->{$feature . '_changed'} === true) { - $element->setDescription($this->translate('changed')); + $element->setDescription(mt('monitoring', 'changed')); } } return $this; @@ -120,7 +120,7 @@ class ToggleObjectFeaturesCommandForm extends ObjectsCommandForm } } } - Notification::success($this->translate('Toggling feature..')); + Notification::success(mt('monitoring', 'Toggling feature..')); return true; } } diff --git a/modules/monitoring/application/forms/Config/Instance/LocalInstanceForm.php b/modules/monitoring/application/forms/Config/Instance/LocalInstanceForm.php index 405bac144..daabe7e02 100644 --- a/modules/monitoring/application/forms/Config/Instance/LocalInstanceForm.php +++ b/modules/monitoring/application/forms/Config/Instance/LocalInstanceForm.php @@ -28,9 +28,9 @@ class LocalInstanceForm extends Form 'path', array( 'required' => true, - 'label' => $this->translate('Command File'), + 'label' => mt('monitoring', 'Command File'), 'value' => '/var/run/icinga2/cmd/icinga2.cmd', - 'description' => $this->translate('Path to the local Icinga command file') + 'description' => mt('monitoring', 'Path to the local Icinga command file') ) ); return $this; diff --git a/modules/monitoring/application/forms/Config/Instance/RemoteInstanceForm.php b/modules/monitoring/application/forms/Config/Instance/RemoteInstanceForm.php index 47b2a0316..7c55f655a 100644 --- a/modules/monitoring/application/forms/Config/Instance/RemoteInstanceForm.php +++ b/modules/monitoring/application/forms/Config/Instance/RemoteInstanceForm.php @@ -29,8 +29,8 @@ class RemoteInstanceForm extends Form 'host', array( 'required' => true, - 'label' => $this->translate('Host'), - 'description' => $this->translate( + 'label' => mt('monitoring', 'Host'), + 'description' => mt('monitoring', 'Hostname or address of the remote Icinga instance' ) ) @@ -40,8 +40,8 @@ class RemoteInstanceForm extends Form 'port', array( 'required' => true, - 'label' => $this->translate('Port'), - 'description' => $this->translate('SSH port to connect to on the remote Icinga instance'), + 'label' => mt('monitoring', 'Port'), + 'description' => mt('monitoring', 'SSH port to connect to on the remote Icinga instance'), 'value' => 22 ) ), @@ -50,8 +50,8 @@ class RemoteInstanceForm extends Form 'user', array( 'required' => true, - 'label' => $this->translate('User'), - 'description' => $this->translate( + 'label' => mt('monitoring', 'User'), + 'description' => mt('monitoring', 'User to log in as on the remote Icinga instance. Please note that key-based SSH login must be' . ' possible for this user' ) @@ -62,9 +62,9 @@ class RemoteInstanceForm extends Form 'path', array( 'required' => true, - 'label' => $this->translate('Command File'), + 'label' => mt('monitoring', 'Command File'), 'value' => '/var/run/icinga2/cmd/icinga2.cmd', - 'description' => $this->translate('Path to the Icinga command file on the remote Icinga instance') + 'description' => mt('monitoring', 'Path to the Icinga command file on the remote Icinga instance') ) ) )); diff --git a/modules/monitoring/application/forms/Config/Instance/RemoteInstanceKeyResourcePage.php b/modules/monitoring/application/forms/Config/Instance/RemoteInstanceKeyResourcePage.php deleted file mode 100644 index 454c67d47..000000000 --- a/modules/monitoring/application/forms/Config/Instance/RemoteInstanceKeyResourcePage.php +++ /dev/null @@ -1,54 +0,0 @@ -addElement( - 'button', - Wizard::BTN_NEXT, - array( - 'type' => 'submit', - 'value' => $pageName, - 'label' => $this->translate('Save Changes'), - 'decorators' => array('ViewHelper') - ) - ); - } - - public function addPreviousButton($pageName) - { - - } -} diff --git a/modules/monitoring/application/forms/Config/InstanceConfigForm.php b/modules/monitoring/application/forms/Config/InstanceConfigForm.php index 5618f27ee..b89e48c0a 100644 --- a/modules/monitoring/application/forms/Config/InstanceConfigForm.php +++ b/modules/monitoring/application/forms/Config/InstanceConfigForm.php @@ -25,7 +25,7 @@ class InstanceConfigForm extends ConfigForm public function init() { $this->setName('form_config_monitoring_instance'); - $this->setSubmitLabel($this->translate('Save Changes')); + $this->setSubmitLabel(mt('monitoring', 'Save Changes')); } /** @@ -48,7 +48,7 @@ class InstanceConfigForm extends ConfigForm break; default: throw new InvalidArgumentException( - sprintf($this->translate('Invalid instance type "%s" given'), $type) + sprintf(mt('monitoring', 'Invalid instance type "%s" given'), $type) ); } return $form; @@ -69,10 +69,10 @@ class InstanceConfigForm extends ConfigForm { $name = isset($values['name']) ? $values['name'] : ''; if (! $name) { - throw new InvalidArgumentException($this->translate('Instance name missing')); + throw new InvalidArgumentException(mt('monitoring', 'Instance name missing')); } if ($this->config->hasSection($name)) { - throw new InvalidArgumentException($this->translate('Instance already exists')); + throw new InvalidArgumentException(mt('monitoring', 'Instance already exists')); } unset($values['name']); @@ -93,11 +93,11 @@ class InstanceConfigForm extends ConfigForm public function edit($name, array $values) { if (! $name) { - throw new InvalidArgumentException($this->translate('Old instance name missing')); + throw new InvalidArgumentException(mt('monitoring', 'Old instance name missing')); } elseif (! ($newName = isset($values['name']) ? $values['name'] : '')) { - throw new InvalidArgumentException($this->translate('New instance name missing')); + throw new InvalidArgumentException(mt('monitoring', 'New instance name missing')); } elseif (! $this->config->hasSection($name)) { - throw new InvalidArgumentException($this->translate('Unknown instance name provided')); + throw new InvalidArgumentException(mt('monitoring', 'Unknown instance name provided')); } unset($values['name']); @@ -117,9 +117,9 @@ class InstanceConfigForm extends ConfigForm public function remove($name) { if (! $name) { - throw new InvalidArgumentException($this->translate('Instance name missing')); + throw new InvalidArgumentException(mt('monitoring', 'Instance name missing')); } elseif (! $this->config->hasSection($name)) { - throw new InvalidArgumentException($this->translate('Unknown instance name provided')); + throw new InvalidArgumentException(mt('monitoring', 'Unknown instance name provided')); } $instanceConfig = $this->config->getSection($name); @@ -136,10 +136,10 @@ class InstanceConfigForm extends ConfigForm $instanceName = $this->request->getQuery('instance'); if ($instanceName !== null) { if (! $instanceName) { - throw new ConfigurationError($this->translate('Instance name missing')); + throw new ConfigurationError(mt('monitoring', 'Instance name missing')); } if (! $this->config->hasSection($instanceName)) { - throw new ConfigurationError($this->translate('Unknown instance name given')); + throw new ConfigurationError(mt('monitoring', 'Unknown instance name given')); } $instanceConfig = $this->config->getSection($instanceName)->toArray(); @@ -158,10 +158,10 @@ class InstanceConfigForm extends ConfigForm try { if ($instanceName === null) { // create new instance $this->add($this->getValues()); - $message = $this->translate('Instance "%s" created successfully.'); + $message = mt('monitoring', 'Instance "%s" created successfully.'); } else { // edit existing instance $this->edit($instanceName, $this->getValues()); - $message = $this->translate('Instance "%s" edited successfully.'); + $message = mt('monitoring', 'Instance "%s" edited successfully.'); } } catch (InvalidArgumentException $e) { Notification::error($e->getMessage()); @@ -189,7 +189,7 @@ class InstanceConfigForm extends ConfigForm 'name', array( 'required' => true, - 'label' => $this->translate('Instance Name') + 'label' => mt('monitoring', 'Instance Name') ) ), array( @@ -198,10 +198,10 @@ class InstanceConfigForm extends ConfigForm array( 'required' => true, 'autosubmit' => true, - 'label' => $this->translate('Instance Type'), + 'label' => mt('monitoring', 'Instance Type'), 'multiOptions' => array( - LocalCommandFile::TRANSPORT => $this->translate('Local Command File'), - RemoteCommandFile::TRANSPORT => $this->translate('Remote Command File') + LocalCommandFile::TRANSPORT => mt('monitoring', 'Local Command File'), + RemoteCommandFile::TRANSPORT => mt('monitoring', 'Remote Command File') ), 'value' => $instanceType ) diff --git a/modules/monitoring/application/forms/Config/SecurityConfigForm.php b/modules/monitoring/application/forms/Config/SecurityConfigForm.php index b202f5938..40c0b7b8c 100644 --- a/modules/monitoring/application/forms/Config/SecurityConfigForm.php +++ b/modules/monitoring/application/forms/Config/SecurityConfigForm.php @@ -18,7 +18,7 @@ class SecurityConfigForm extends ConfigForm public function init() { $this->setName('form_config_monitoring_security'); - $this->setSubmitLabel($this->translate('Save Changes')); + $this->setSubmitLabel(mt('monitoring', 'Save Changes')); } /** @@ -29,7 +29,7 @@ class SecurityConfigForm extends ConfigForm $this->config->setSection('security', $this->getValues()); if ($this->save()) { - Notification::success($this->translate('New security configuration has successfully been stored')); + Notification::success(mt('monitoring', 'New security configuration has successfully been stored')); } else { return false; } @@ -54,8 +54,8 @@ class SecurityConfigForm extends ConfigForm array( 'allowEmpty' => true, 'value' => '*pw*,*pass*,community', - 'label' => $this->translate('Protected Custom Variables'), - 'description' => $this->translate( + 'label' => mt('monitoring', 'Protected Custom Variables'), + 'description' => mt('monitoring', 'Comma separated case insensitive list of protected custom variables.' . ' Use * as a placeholder for zero or more wildcard characters.' . ' Existance of those custom variables will be shown, but their values will be masked.' diff --git a/modules/monitoring/application/forms/EventOverviewForm.php b/modules/monitoring/application/forms/EventOverviewForm.php index dc697b940..25d268f76 100644 --- a/modules/monitoring/application/forms/EventOverviewForm.php +++ b/modules/monitoring/application/forms/EventOverviewForm.php @@ -44,7 +44,7 @@ class EventOverviewForm extends Form 'checkbox', 'statechange', array( - 'label' => $this->translate('State Changes'), + 'label' => t('State Changes'), 'class' => 'autosubmit', 'decorators' => $decorators, 'value' => strpos($url, $this->stateChangeFilter()->toQueryString()) === false ? 0 : 1 @@ -54,7 +54,7 @@ class EventOverviewForm extends Form 'checkbox', 'downtime', array( - 'label' => $this->translate('Downtimes'), + 'label' => t('Downtimes'), 'class' => 'autosubmit', 'decorators' => $decorators, 'value' => strpos($url, $this->downtimeFilter()->toQueryString()) === false ? 0 : 1 @@ -64,7 +64,7 @@ class EventOverviewForm extends Form 'checkbox', 'comment', array( - 'label' => $this->translate('Comments'), + 'label' => t('Comments'), 'class' => 'autosubmit', 'decorators' => $decorators, 'value' => strpos($url, $this->commentFilter()->toQueryString()) === false ? 0 : 1 @@ -74,7 +74,7 @@ class EventOverviewForm extends Form 'checkbox', 'notification', array( - 'label' => $this->translate('Notifications'), + 'label' => t('Notifications'), 'class' => 'autosubmit', 'decorators' => $decorators, 'value' => strpos($url, $this->notificationFilter()->toQueryString()) === false ? 0 : 1 @@ -84,7 +84,7 @@ class EventOverviewForm extends Form 'checkbox', 'flapping', array( - 'label' => $this->translate('Flapping'), + 'label' => t('Flapping'), 'class' => 'autosubmit', 'decorators' => $decorators, 'value' => strpos($url, $this->flappingFilter()->toQueryString()) === false ? 0 : 1 diff --git a/modules/monitoring/application/forms/Setup/BackendPage.php b/modules/monitoring/application/forms/Setup/BackendPage.php index b5ab2ffd6..1f6ef6894 100644 --- a/modules/monitoring/application/forms/Setup/BackendPage.php +++ b/modules/monitoring/application/forms/Setup/BackendPage.php @@ -20,7 +20,7 @@ class BackendPage extends Form 'note', 'title', array( - 'value' => $this->translate('Monitoring Backend', 'setup.page.title'), + 'value' => mt('monitoring', 'Monitoring Backend', 'setup.page.title'), 'decorators' => array( 'ViewHelper', array('HtmlTag', array('tag' => 'h2')) @@ -31,7 +31,8 @@ class BackendPage extends Form 'note', 'description', array( - 'value' => $this->translate( + 'value' => mt( + 'monitoring', 'Please configure below how Icinga Web 2 should retrieve monitoring information.' ) ) @@ -43,8 +44,8 @@ class BackendPage extends Form array( 'required' => true, 'value' => 'icinga', - 'label' => $this->translate('Backend Name'), - 'description' => $this->translate('The identifier of this backend') + 'label' => mt('monitoring', 'Backend Name'), + 'description' => mt('monitoring', 'The identifier of this backend') ) ); @@ -59,10 +60,8 @@ class BackendPage extends Form 'type', array( 'required' => true, - 'label' => $this->translate('Backend Type'), - 'description' => $this->translate( - 'The data source used for retrieving monitoring information' - ), + 'label' => mt('monitoring', 'Backend Type'), + 'description' => mt('monitoring', 'The data source used for retrieving monitoring information'), 'multiOptions' => $resourceTypes ) ); diff --git a/modules/monitoring/application/forms/Setup/IdoResourcePage.php b/modules/monitoring/application/forms/Setup/IdoResourcePage.php index c28b52e6b..189d65fea 100644 --- a/modules/monitoring/application/forms/Setup/IdoResourcePage.php +++ b/modules/monitoring/application/forms/Setup/IdoResourcePage.php @@ -28,7 +28,7 @@ class IdoResourcePage extends Form 'note', 'title', array( - 'value' => $this->translate('Monitoring IDO Resource', 'setup.page.title'), + 'value' => mt('monitoring', 'Monitoring IDO Resource', 'setup.page.title'), 'decorators' => array( 'ViewHelper', array('HtmlTag', array('tag' => 'h2')) @@ -39,7 +39,8 @@ class IdoResourcePage extends Form 'note', 'description', array( - 'value' => $this->translate( + 'value' => mt( + 'monitoring', 'Please fill out the connection details below to access' . ' the IDO database of your monitoring environment.' ) @@ -90,10 +91,8 @@ class IdoResourcePage extends Form 'skip_validation', array( 'required' => true, - 'label' => $this->translate('Skip Validation'), - 'description' => $this->translate( - 'Check this to not to validate connectivity with the given database server' - ) + 'label' => t('Skip Validation'), + 'description' => t('Check this to not to validate connectivity with the given database server') ) ); } diff --git a/modules/monitoring/application/forms/Setup/InstancePage.php b/modules/monitoring/application/forms/Setup/InstancePage.php index 8f151554d..dccfd1d91 100644 --- a/modules/monitoring/application/forms/Setup/InstancePage.php +++ b/modules/monitoring/application/forms/Setup/InstancePage.php @@ -20,7 +20,7 @@ class InstancePage extends Form 'note', 'title', array( - 'value' => $this->translate('Monitoring Instance', 'setup.page.title'), + 'value' => mt('monitoring', 'Monitoring Instance', 'setup.page.title'), 'decorators' => array( 'ViewHelper', array('HtmlTag', array('tag' => 'h2')) @@ -31,7 +31,8 @@ class InstancePage extends Form 'note', 'description', array( - 'value' => $this->translate( + 'value' => mt( + 'monitoring', 'Please define the settings specific to your monitoring instance below.' ) ) diff --git a/modules/monitoring/application/forms/Setup/LivestatusResourcePage.php b/modules/monitoring/application/forms/Setup/LivestatusResourcePage.php index 245d2abcc..4faa17416 100644 --- a/modules/monitoring/application/forms/Setup/LivestatusResourcePage.php +++ b/modules/monitoring/application/forms/Setup/LivestatusResourcePage.php @@ -28,7 +28,7 @@ class LivestatusResourcePage extends Form 'note', 'title', array( - 'value' => $this->translate('Monitoring Livestatus Resource', 'setup.page.title'), + 'value' => mt('monitoring', 'Monitoring Livestatus Resource', 'setup.page.title'), 'decorators' => array( 'ViewHelper', array('HtmlTag', array('tag' => 'h2')) @@ -39,7 +39,8 @@ class LivestatusResourcePage extends Form 'note', 'description', array( - 'value' => $this->translate( + 'value' => mt( + 'monitoring', 'Please fill out the connection details below to access the Livestatus' . ' socket interface for your monitoring environment.' ) @@ -90,10 +91,8 @@ class LivestatusResourcePage extends Form 'skip_validation', array( 'required' => true, - 'label' => $this->translate('Skip Validation'), - 'description' => $this->translate( - 'Check this to not to validate connectivity with the given Livestatus socket' - ) + 'label' => t('Skip Validation'), + 'description' => t('Check this to not to validate connectivity with the given Livestatus socket') ) ); } diff --git a/modules/monitoring/application/forms/Setup/SecurityPage.php b/modules/monitoring/application/forms/Setup/SecurityPage.php index ba8083e50..0c7d3d1de 100644 --- a/modules/monitoring/application/forms/Setup/SecurityPage.php +++ b/modules/monitoring/application/forms/Setup/SecurityPage.php @@ -20,7 +20,7 @@ class SecurityPage extends Form 'note', 'title', array( - 'value' => $this->translate('Monitoring Security', 'setup.page.title'), + 'value' => mt('monitoring', 'Monitoring Security', 'setup.page.title'), 'decorators' => array( 'ViewHelper', array('HtmlTag', array('tag' => 'h2')) @@ -31,7 +31,8 @@ class SecurityPage extends Form 'note', 'description', array( - 'value' => $this->translate( + 'value' => mt( + 'monitoring', 'To protect your monitoring environment against prying eyes please fill out the settings below.' ) ) diff --git a/modules/monitoring/application/forms/Setup/WelcomePage.php b/modules/monitoring/application/forms/Setup/WelcomePage.php index f79eb6c62..d910e2e01 100644 --- a/modules/monitoring/application/forms/Setup/WelcomePage.php +++ b/modules/monitoring/application/forms/Setup/WelcomePage.php @@ -19,7 +19,10 @@ class WelcomePage extends Form 'note', 'welcome', array( - 'value' => $this->translate('Welcome to the configuration of the monitoring module for Icinga Web 2!'), + 'value' => mt( + 'monitoring', + 'Welcome to the configuration of the monitoring module for Icinga Web 2!' + ), 'decorators' => array( 'ViewHelper', array('HtmlTag', array('tag' => 'h2')) @@ -31,7 +34,7 @@ class WelcomePage extends Form 'note', 'core_hint', array( - 'value' => $this->translate('This is the core module for Icinga Web 2.') + 'value' => mt('monitoring', 'This is the core module for Icinga Web 2.') ) ); @@ -39,7 +42,8 @@ class WelcomePage extends Form 'note', 'description', array( - 'value' => $this->translate( + 'value' => mt( + 'monitoring', 'It offers various status and reporting views with powerful filter capabilities that allow' . ' you to keep track of the most important events in your monitoring environment.' ) diff --git a/modules/monitoring/application/forms/StatehistoryForm.php b/modules/monitoring/application/forms/StatehistoryForm.php index d859f5815..9fa1bdc26 100644 --- a/modules/monitoring/application/forms/StatehistoryForm.php +++ b/modules/monitoring/application/forms/StatehistoryForm.php @@ -19,7 +19,7 @@ class StatehistoryForm extends Form public function init() { $this->setName('form_event_overview'); - $this->setSubmitLabel($this->translate('Apply')); + $this->setSubmitLabel(mt('monitoring', 'Apply')); } /** @@ -65,14 +65,14 @@ class StatehistoryForm extends Form 'select', 'from', array( - 'label' => $this->translate('From'), + 'label' => mt('monitoring', 'From'), 'value' => $this->getRequest()->getParam('from', strtotime('3 months ago')), 'multiOptions' => array( - strtotime('midnight 3 months ago') => $this->translate('3 Months'), - strtotime('midnight 4 months ago') => $this->translate('4 Months'), - strtotime('midnight 8 months ago') => $this->translate('8 Months'), - strtotime('midnight 12 months ago') => $this->translate('1 Year'), - strtotime('midnight 24 months ago') => $this->translate('2 Years') + strtotime('midnight 3 months ago') => mt('monitoring', '3 Months'), + strtotime('midnight 4 months ago') => mt('monitoring', '4 Months'), + strtotime('midnight 8 months ago') => mt('monitoring', '8 Months'), + strtotime('midnight 12 months ago') => mt('monitoring', '1 Year'), + strtotime('midnight 24 months ago') => mt('monitoring', '2 Years') ), 'class' => 'autosubmit' ) @@ -81,10 +81,10 @@ class StatehistoryForm extends Form 'select', 'to', array( - 'label' => $this->translate('To'), + 'label' => mt('monitoring', 'To'), 'value' => $this->getRequest()->getParam('to', time()), 'multiOptions' => array( - time() => $this->translate('Today') + time() => mt('monitoring', 'Today') ), 'class' => 'autosubmit' ) @@ -95,11 +95,11 @@ class StatehistoryForm extends Form 'select', 'objecttype', array( - 'label' => $this->translate('Object type'), + 'label' => mt('monitoring', 'Object type'), 'value' => $objectType, 'multiOptions' => array( - 'services' => $this->translate('Services'), - 'hosts' => $this->translate('Hosts') + 'services' => mt('monitoring', 'Services'), + 'hosts' => mt('monitoring', 'Hosts') ), 'class' => 'autosubmit' ) @@ -113,13 +113,13 @@ class StatehistoryForm extends Form 'select', 'state', array( - 'label' => $this->translate('State'), + 'label' => mt('monitoring', 'State'), 'value' => $serviceState, 'multiOptions' => array( - 'cnt_critical_hard' => $this->translate('Critical'), - 'cnt_warning_hard' => $this->translate('Warning'), - 'cnt_unknown_hard' => $this->translate('Unknown'), - 'cnt_ok' => $this->translate('Ok') + 'cnt_critical_hard' => mt('monitoring', 'Critical'), + 'cnt_warning_hard' => mt('monitoring', 'Warning'), + 'cnt_unknown_hard' => mt('monitoring', 'Unknown'), + 'cnt_ok' => mt('monitoring', 'Ok') ), 'class' => 'autosubmit' ) @@ -133,12 +133,12 @@ class StatehistoryForm extends Form 'select', 'state', array( - 'label' => $this->translate('State'), + 'label' => mt('monitoring', 'State'), 'value' => $hostState, 'multiOptions' => array( - 'cnt_up' => $this->translate('Up'), - 'cnt_down_hard' => $this->translate('Down'), - 'cnt_unreachable_hard' => $this->translate('Unreachable') + 'cnt_up' => mt('monitoring', 'Up'), + 'cnt_down_hard' => mt('monitoring', 'Down'), + 'cnt_unreachable_hard' => mt('monitoring', 'Unreachable') ), 'class' => 'autosubmit' ) From 7082ebaf7beb8d27db0f304b84ac728d1934d30f Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Mon, 19 Jan 2015 13:47:01 +0100 Subject: [PATCH 0205/2920] Replace t() and mt() with translate() in the monitoring module's forms refs #7551 --- .../DisableNotificationsExpireCommandForm.php | 11 +++-- .../ToggleInstanceFeaturesCommandForm.php | 28 ++++++------- .../Object/AcknowledgeProblemCommandForm.php | 34 +++++++-------- .../Command/Object/AddCommentCommandForm.php | 13 +++--- .../Command/Object/CheckNowCommandForm.php | 4 +- .../Object/DeleteCommentCommandForm.php | 4 +- .../Object/DeleteDowntimeCommandForm.php | 4 +- .../Object/ProcessCheckResultCommandForm.php | 30 +++++++------ .../Object/ScheduleHostCheckCommandForm.php | 5 +-- .../ScheduleHostDowntimeCommandForm.php | 16 ++++--- .../ScheduleServiceCheckCommandForm.php | 17 ++++---- .../ScheduleServiceDowntimeCommandForm.php | 34 +++++++-------- .../ToggleObjectFeaturesCommandForm.php | 16 +++---- .../Config/Instance/LocalInstanceForm.php | 4 +- .../Config/Instance/RemoteInstanceForm.php | 16 +++---- .../forms/Config/InstanceConfigForm.php | 34 +++++++-------- .../forms/Config/SecurityConfigForm.php | 8 ++-- .../application/forms/EventOverviewForm.php | 10 ++--- .../application/forms/Setup/BackendPage.php | 15 +++---- .../forms/Setup/IdoResourcePage.php | 11 ++--- .../application/forms/Setup/InstancePage.php | 5 +-- .../forms/Setup/LivestatusResourcePage.php | 11 ++--- .../application/forms/Setup/SecurityPage.php | 5 +-- .../application/forms/Setup/WelcomePage.php | 10 ++--- .../application/forms/StatehistoryForm.php | 42 +++++++++---------- 25 files changed, 183 insertions(+), 204 deletions(-) diff --git a/modules/monitoring/application/forms/Command/Instance/DisableNotificationsExpireCommandForm.php b/modules/monitoring/application/forms/Command/Instance/DisableNotificationsExpireCommandForm.php index 0e64a4b03..21d926b58 100644 --- a/modules/monitoring/application/forms/Command/Instance/DisableNotificationsExpireCommandForm.php +++ b/modules/monitoring/application/forms/Command/Instance/DisableNotificationsExpireCommandForm.php @@ -21,7 +21,7 @@ class DisableNotificationsExpireCommandForm extends CommandForm */ public function init() { - $this->setSubmitLabel(mt('monitoring', 'Disable Notifications')); + $this->setSubmitLabel($this->translate('Disable Notifications')); } /** @@ -30,8 +30,7 @@ class DisableNotificationsExpireCommandForm extends CommandForm */ public function getHelp() { - return mt( - 'monitoring', + return $this->translate( 'This command is used to disable host and service notifications for a specific time.' ); } @@ -49,8 +48,8 @@ class DisableNotificationsExpireCommandForm extends CommandForm 'expire_time', array( 'required' => true, - 'label' => mt('monitoring', 'Expire Time'), - 'description' => mt('monitoring', 'Set the expire time.'), + 'label' => $this->translate('Expire Time'), + 'description' => $this->translate('Set the expire time.'), 'value' => $expireTime ) ); @@ -67,7 +66,7 @@ class DisableNotificationsExpireCommandForm extends CommandForm $disableNotifications ->setExpireTime($this->getElement('expire_time')->getValue()->getTimestamp()); $this->getTransport($this->request)->send($disableNotifications); - Notification::success(mt('monitoring', 'Disabling host and service notifications..')); + Notification::success($this->translate('Disabling host and service notifications..')); return true; } } diff --git a/modules/monitoring/application/forms/Command/Instance/ToggleInstanceFeaturesCommandForm.php b/modules/monitoring/application/forms/Command/Instance/ToggleInstanceFeaturesCommandForm.php index 291619b2f..469c1b6eb 100644 --- a/modules/monitoring/application/forms/Command/Instance/ToggleInstanceFeaturesCommandForm.php +++ b/modules/monitoring/application/forms/Command/Instance/ToggleInstanceFeaturesCommandForm.php @@ -61,13 +61,13 @@ class ToggleInstanceFeaturesCommandForm extends CommandForm if ((bool) $this->status->notifications_enabled) { $notificationDescription = sprintf( '%s', - mt('monitoring', 'Disable notifications for a specific time on a program-wide basis'), + $this->translate('Disable notifications for a specific time on a program-wide basis'), $this->getView()->href('monitoring/process/disable-notifications'), - mt('monitoring', 'Disable temporarily') + $this->translate('Disable temporarily') ); } elseif ($this->status->disable_notif_expire_time) { $notificationDescription = sprintf( - mt('monitoring', 'Notifications will be re-enabled in %s'), + $this->translate('Notifications will be re-enabled in %s'), $this->getView()->timeUntil($this->status->disable_notif_expire_time) ); } else { @@ -78,7 +78,7 @@ class ToggleInstanceFeaturesCommandForm extends CommandForm 'checkbox', ToggleInstanceFeatureCommand::FEATURE_ACTIVE_HOST_CHECKS, array( - 'label' => mt('monitoring', 'Active Host Checks Being Executed'), + 'label' => $this->translate('Active Host Checks Being Executed'), 'autosubmit' => true ) ), @@ -86,7 +86,7 @@ class ToggleInstanceFeaturesCommandForm extends CommandForm 'checkbox', ToggleInstanceFeatureCommand::FEATURE_ACTIVE_SERVICE_CHECKS, array( - 'label' => mt('monitoring', 'Active Service Checks Being Executed'), + 'label' => $this->translate('Active Service Checks Being Executed'), 'autosubmit' => true ) ), @@ -94,7 +94,7 @@ class ToggleInstanceFeaturesCommandForm extends CommandForm 'checkbox', ToggleInstanceFeatureCommand::FEATURE_EVENT_HANDLERS, array( - 'label' => mt('monitoring', 'Event Handlers Enabled'), + 'label' => $this->translate('Event Handlers Enabled'), 'autosubmit' => true ) ), @@ -102,7 +102,7 @@ class ToggleInstanceFeaturesCommandForm extends CommandForm 'checkbox', ToggleInstanceFeatureCommand::FEATURE_FLAP_DETECTION, array( - 'label' => mt('monitoring', 'Flap Detection Enabled'), + 'label' => $this->translate('Flap Detection Enabled'), 'autosubmit' => true ) ), @@ -110,7 +110,7 @@ class ToggleInstanceFeaturesCommandForm extends CommandForm 'checkbox', ToggleInstanceFeatureCommand::FEATURE_NOTIFICATIONS, array( - 'label' => mt('monitoring', 'Notifications Enabled'), + 'label' => $this->translate('Notifications Enabled'), 'autosubmit' => true, 'description' => $notificationDescription, 'decorators' => array( @@ -129,7 +129,7 @@ class ToggleInstanceFeaturesCommandForm extends CommandForm 'checkbox', ToggleInstanceFeatureCommand::FEATURE_HOST_OBSESSING, array( - 'label' => mt('monitoring', 'Obsessing Over Hosts'), + 'label' => $this->translate('Obsessing Over Hosts'), 'autosubmit' => true ) ), @@ -137,7 +137,7 @@ class ToggleInstanceFeaturesCommandForm extends CommandForm 'checkbox', ToggleInstanceFeatureCommand::FEATURE_SERVICE_OBSESSING, array( - 'label' => mt('monitoring', 'Obsessing Over Services'), + 'label' => $this->translate('Obsessing Over Services'), 'autosubmit' => true ) ), @@ -145,7 +145,7 @@ class ToggleInstanceFeaturesCommandForm extends CommandForm 'checkbox', ToggleInstanceFeatureCommand::FEATURE_PASSIVE_HOST_CHECKS, array( - 'label' => mt('monitoring', 'Passive Host Checks Being Accepted'), + 'label' => $this->translate('Passive Host Checks Being Accepted'), 'autosubmit' => true ) ), @@ -153,7 +153,7 @@ class ToggleInstanceFeaturesCommandForm extends CommandForm 'checkbox', ToggleInstanceFeatureCommand::FEATURE_PASSIVE_SERVICE_CHECKS, array( - 'label' => mt('monitoring', 'Passive Service Checks Being Accepted'), + 'label' => $this->translate('Passive Service Checks Being Accepted'), 'autosubmit' => true ) ), @@ -161,7 +161,7 @@ class ToggleInstanceFeaturesCommandForm extends CommandForm 'checkbox', ToggleInstanceFeatureCommand::FEATURE_PERFORMANCE_DATA, array( - 'label' => mt('monitoring', 'Performance Data Being Processed'), + 'label' => $this->translate('Performance Data Being Processed'), 'autosubmit' => true ) ) @@ -198,7 +198,7 @@ class ToggleInstanceFeaturesCommandForm extends CommandForm ->setEnabled($enabled); $this->getTransport($this->request)->send($toggleFeature); } - Notification::success(mt('monitoring', 'Toggling feature..')); + Notification::success($this->translate('Toggling feature..')); return true; } } diff --git a/modules/monitoring/application/forms/Command/Object/AcknowledgeProblemCommandForm.php b/modules/monitoring/application/forms/Command/Object/AcknowledgeProblemCommandForm.php index 25ac76c25..df3731837 100644 --- a/modules/monitoring/application/forms/Command/Object/AcknowledgeProblemCommandForm.php +++ b/modules/monitoring/application/forms/Command/Object/AcknowledgeProblemCommandForm.php @@ -31,8 +31,7 @@ class AcknowledgeProblemCommandForm extends ObjectsCommandForm */ public function getHelp() { - return mt( - 'monitoring', + return $this->translate( 'This command is used to acknowledge host or service problems. When a problem is acknowledged,' . ' future notifications about problems are temporarily disabled until the host or service' . ' recovers.' @@ -51,9 +50,8 @@ class AcknowledgeProblemCommandForm extends ObjectsCommandForm 'comment', array( 'required' => true, - 'label' => mt('monitoring', 'Comment'), - 'description' => mt( - 'monitoring', + 'label' => $this->translate('Comment'), + 'description' => $this->translate( 'If you work with other administrators, you may find it useful to share information about the' . ' the host or service that is having problems. Make sure you enter a brief description of' . ' what you are doing.' @@ -64,9 +62,8 @@ class AcknowledgeProblemCommandForm extends ObjectsCommandForm 'checkbox', 'persistent', array( - 'label' => mt('monitoring', 'Persistent Comment'), - 'description' => mt( - 'monitoring', + 'label' => $this->translate('Persistent Comment'), + 'description' => $this->translate( 'If you would like the comment to remain even when the acknowledgement is removed, check this' . ' option.' ) @@ -76,8 +73,10 @@ class AcknowledgeProblemCommandForm extends ObjectsCommandForm 'checkbox', 'expire', array( - 'label' => mt('monitoring', 'Use Expire Time'), - 'description' => mt('monitoring', 'If the acknowledgement should expire, check this option.'), + 'label' => $this->translate('Use Expire Time'), + 'description' => $this->translate( + 'If the acknowledgement should expire, check this option.' + ), 'autosubmit' => true ) ) @@ -89,10 +88,9 @@ class AcknowledgeProblemCommandForm extends ObjectsCommandForm 'dateTimePicker', 'expire_time', array( - 'label' => mt('monitoring', 'Expire Time'), + 'label' => $this->translate('Expire Time'), 'value' => $expireTime, - 'description' => mt( - 'monitoring', + 'description' => $this->translate( 'Enter the expire date and time for this acknowledgement here. Icinga will delete the' . ' acknowledgement after this time expired.' ) @@ -114,10 +112,9 @@ class AcknowledgeProblemCommandForm extends ObjectsCommandForm 'checkbox', 'sticky', array( - 'label' => mt('monitoring', 'Sticky Acknowledgement'), + 'label' => $this->translate('Sticky Acknowledgement'), 'value' => true, - 'description' => mt( - 'monitoring', + 'description' => $this->translate( 'If you want the acknowledgement to disable notifications until the host or service recovers,' . ' check this option.' ) @@ -127,10 +124,9 @@ class AcknowledgeProblemCommandForm extends ObjectsCommandForm 'checkbox', 'notify', array( - 'label' => mt('monitoring', 'Send Notification'), + 'label' => $this->translate('Send Notification'), 'value' => true, - 'description' => mt( - 'monitoring', + 'description' => $this->translate( 'If you do not want an acknowledgement notification to be sent out to the appropriate contacts,' . ' uncheck this option.' ) diff --git a/modules/monitoring/application/forms/Command/Object/AddCommentCommandForm.php b/modules/monitoring/application/forms/Command/Object/AddCommentCommandForm.php index f5adf6c71..e7f7e91f9 100644 --- a/modules/monitoring/application/forms/Command/Object/AddCommentCommandForm.php +++ b/modules/monitoring/application/forms/Command/Object/AddCommentCommandForm.php @@ -29,8 +29,7 @@ class AddCommentCommandForm extends ObjectsCommandForm */ public function getHelp() { - return mt( - 'monitoring', + return $this->translate( 'This command is used to add host or service comments.' ); } @@ -47,9 +46,8 @@ class AddCommentCommandForm extends ObjectsCommandForm 'comment', array( 'required' => true, - 'label' => mt('monitoring', 'Comment'), - 'description' => mt( - 'monitoring', + 'label' => $this->translate('Comment'), + 'description' => $this->translate( 'If you work with other administrators, you may find it useful to share information about the' . ' the host or service that is having problems. Make sure you enter a brief description of' . ' what you are doing.' @@ -60,10 +58,9 @@ class AddCommentCommandForm extends ObjectsCommandForm 'checkbox', 'persistent', array( - 'label' => mt('monitoring', 'Persistent'), + 'label' => $this->translate('Persistent'), 'value' => true, - 'description' => mt( - 'monitoring', + 'description' => $this->translate( 'If you uncheck this option, the comment will automatically be deleted the next time Icinga is' . ' restarted.' ) diff --git a/modules/monitoring/application/forms/Command/Object/CheckNowCommandForm.php b/modules/monitoring/application/forms/Command/Object/CheckNowCommandForm.php index 01006683f..1054aae05 100644 --- a/modules/monitoring/application/forms/Command/Object/CheckNowCommandForm.php +++ b/modules/monitoring/application/forms/Command/Object/CheckNowCommandForm.php @@ -35,8 +35,8 @@ class CheckNowCommandForm extends ObjectsCommandForm array( 'ignore' => true, 'type' => 'submit', - 'value' => mt('monitoring', 'Check now'), - 'label' => ' ' . mt('monitoring', 'Check now'), + 'value' => $this->translate('Check now'), + 'label' => ' ' . $this->translate('Check now'), 'decorators' => array('ViewHelper'), 'escape' => false, 'class' => 'link-like' diff --git a/modules/monitoring/application/forms/Command/Object/DeleteCommentCommandForm.php b/modules/monitoring/application/forms/Command/Object/DeleteCommentCommandForm.php index 3d85afcec..0f7858ad9 100644 --- a/modules/monitoring/application/forms/Command/Object/DeleteCommentCommandForm.php +++ b/modules/monitoring/application/forms/Command/Object/DeleteCommentCommandForm.php @@ -55,7 +55,7 @@ class DeleteCommentCommandForm extends ObjectsCommandForm array( 'ignore' => true, 'label' => 'X', - 'title' => mt('monitoring', 'Delete comment'), + 'title' => $this->translate('Delete comment'), 'decorators' => array('ViewHelper') ) ); @@ -80,7 +80,7 @@ class DeleteCommentCommandForm extends ObjectsCommandForm if (! empty($redirect)) { $this->setRedirectUrl($redirect); } - Notification::success(mt('monitoring', 'Deleting comment..')); + Notification::success($this->translate('Deleting comment..')); return true; } } diff --git a/modules/monitoring/application/forms/Command/Object/DeleteDowntimeCommandForm.php b/modules/monitoring/application/forms/Command/Object/DeleteDowntimeCommandForm.php index 1c7095b82..43ca52b05 100644 --- a/modules/monitoring/application/forms/Command/Object/DeleteDowntimeCommandForm.php +++ b/modules/monitoring/application/forms/Command/Object/DeleteDowntimeCommandForm.php @@ -55,7 +55,7 @@ class DeleteDowntimeCommandForm extends ObjectsCommandForm array( 'ignore' => true, 'label' => 'X', - 'title' => mt('monitoring', 'Delete downtime'), + 'title' => $this->translate('Delete downtime'), 'decorators' => array('ViewHelper') ) ); @@ -80,7 +80,7 @@ class DeleteDowntimeCommandForm extends ObjectsCommandForm if (! empty($redirect)) { $this->setRedirectUrl($redirect); } - Notification::success(mt('monitoring', 'Deleting downtime..')); + Notification::success($this->translate('Deleting downtime..')); return true; } } diff --git a/modules/monitoring/application/forms/Command/Object/ProcessCheckResultCommandForm.php b/modules/monitoring/application/forms/Command/Object/ProcessCheckResultCommandForm.php index 48ee00ab3..44e248956 100644 --- a/modules/monitoring/application/forms/Command/Object/ProcessCheckResultCommandForm.php +++ b/modules/monitoring/application/forms/Command/Object/ProcessCheckResultCommandForm.php @@ -29,8 +29,7 @@ class ProcessCheckResultCommandForm extends ObjectsCommandForm */ public function getHelp() { - return mt( - 'monitoring', + return $this->translate( 'This command is used to submit passive host or service check results.' ); } @@ -53,17 +52,17 @@ class ProcessCheckResultCommandForm extends ObjectsCommandForm 'status', array( 'required' => true, - 'label' => mt('monitoring', 'Status'), - 'description' => mt('monitoring', 'The state this check result should report'), + 'label' => $this->translate('Status'), + 'description' => $this->translate('The state this check result should report'), 'multiOptions' => $object->getType() === $object::TYPE_HOST ? array( - ProcessCheckResultCommand::HOST_UP => mt('monitoring', 'UP', 'icinga.state'), - ProcessCheckResultCommand::HOST_DOWN => mt('monitoring', 'DOWN', 'icinga.state'), - ProcessCheckResultCommand::HOST_UNREACHABLE => mt('monitoring', 'UNREACHABLE', 'icinga.state') + ProcessCheckResultCommand::HOST_UP => $this->translate('UP', 'icinga.state'), + ProcessCheckResultCommand::HOST_DOWN => $this->translate('DOWN', 'icinga.state'), + ProcessCheckResultCommand::HOST_UNREACHABLE => $this->translate('UNREACHABLE', 'icinga.state') ) : array( - ProcessCheckResultCommand::SERVICE_OK => mt('monitoring', 'OK', 'icinga.state'), - ProcessCheckResultCommand::SERVICE_WARNING => mt('monitoring', 'WARNING', 'icinga.state'), - ProcessCheckResultCommand::SERVICE_CRITICAL => mt('monitoring', 'CRITICAL', 'icinga.state'), - ProcessCheckResultCommand::SERVICE_UNKNOWN => mt('monitoring', 'UNKNOWN', 'icinga.state') + ProcessCheckResultCommand::SERVICE_OK => $this->translate('OK', 'icinga.state'), + ProcessCheckResultCommand::SERVICE_WARNING => $this->translate('WARNING', 'icinga.state'), + ProcessCheckResultCommand::SERVICE_CRITICAL => $this->translate('CRITICAL', 'icinga.state'), + ProcessCheckResultCommand::SERVICE_UNKNOWN => $this->translate('UNKNOWN', 'icinga.state') ) ) ); @@ -72,8 +71,8 @@ class ProcessCheckResultCommandForm extends ObjectsCommandForm 'output', array( 'required' => true, - 'label' => mt('monitoring', 'Output'), - 'description' => mt('monitoring', 'The plugin output of this check result') + 'label' => $this->translate('Output'), + 'description' => $this->translate('The plugin output of this check result') ) ); $this->addElement( @@ -81,9 +80,8 @@ class ProcessCheckResultCommandForm extends ObjectsCommandForm 'perfdata', array( 'allowEmpty' => true, - 'label' => mt('monitoring', 'Performance Data'), - 'description' => mt( - 'monitoring', + 'label' => $this->translate('Performance Data'), + 'description' => $this->translate( 'The performance data of this check result. Leave empty' . ' if this check result has no performance data' ) diff --git a/modules/monitoring/application/forms/Command/Object/ScheduleHostCheckCommandForm.php b/modules/monitoring/application/forms/Command/Object/ScheduleHostCheckCommandForm.php index 82a9b2e52..949ec33e1 100644 --- a/modules/monitoring/application/forms/Command/Object/ScheduleHostCheckCommandForm.php +++ b/modules/monitoring/application/forms/Command/Object/ScheduleHostCheckCommandForm.php @@ -24,9 +24,8 @@ class ScheduleHostCheckCommandForm extends ScheduleServiceCheckCommandForm 'checkbox', 'all_services', array( - 'label' => mt('monitoring', 'All Services'), - 'description' => mt( - 'monitoring', + 'label' => $this->translate('All Services'), + 'description' => $this->translate( 'Schedule check for all services on the hosts and the hosts themselves.' ) ) diff --git a/modules/monitoring/application/forms/Command/Object/ScheduleHostDowntimeCommandForm.php b/modules/monitoring/application/forms/Command/Object/ScheduleHostDowntimeCommandForm.php index beb0793ef..f84069a9a 100644 --- a/modules/monitoring/application/forms/Command/Object/ScheduleHostDowntimeCommandForm.php +++ b/modules/monitoring/application/forms/Command/Object/ScheduleHostDowntimeCommandForm.php @@ -27,9 +27,8 @@ class ScheduleHostDowntimeCommandForm extends ScheduleServiceDowntimeCommandForm 'checkbox', 'all_services', array( - 'label' => mt('monitoring', 'All Services'), - 'description' => mt( - 'monitoring', + 'label' => $this->translate('All Services'), + 'description' => $this->translate( 'Schedule downtime for all services on the hosts and the hosts themselves.' ) ) @@ -38,15 +37,14 @@ class ScheduleHostDowntimeCommandForm extends ScheduleServiceDowntimeCommandForm 'select', 'child_hosts', array( - 'label' => mt('monitoring', 'Child Hosts'), + 'label' => $this->translate('Child Hosts'), 'required' => true, 'multiOptions' => array( - 0 => mt('monitoring', 'Do nothing with child hosts'), - 1 => mt('monitoring', 'Schedule triggered downtime for all child hosts'), - 2 => mt('monitoring', 'Schedule non-triggered downtime for all child hosts') + 0 => $this->translate('Do nothing with child hosts'), + 1 => $this->translate('Schedule triggered downtime for all child hosts'), + 2 => $this->translate('Schedule non-triggered downtime for all child hosts') ), - 'description' => mt( - 'monitoring', + 'description' => $this->translate( 'Define what should be done with the child hosts of the hosts.' ) ) diff --git a/modules/monitoring/application/forms/Command/Object/ScheduleServiceCheckCommandForm.php b/modules/monitoring/application/forms/Command/Object/ScheduleServiceCheckCommandForm.php index 9e04a2254..b34472d49 100644 --- a/modules/monitoring/application/forms/Command/Object/ScheduleServiceCheckCommandForm.php +++ b/modules/monitoring/application/forms/Command/Object/ScheduleServiceCheckCommandForm.php @@ -32,8 +32,7 @@ class ScheduleServiceCheckCommandForm extends ObjectsCommandForm */ public function getHelp() { - return mt( - 'monitoring', + return $this->translate( 'This command is used to schedule the next check of hosts or services. Icinga will re-queue the' . ' hosts or services to be checked at the time you specify.' ); @@ -52,8 +51,7 @@ class ScheduleServiceCheckCommandForm extends ObjectsCommandForm 'note', 'command-info', array( - 'value' => mt( - 'monitoring', + 'value' => $this->translate( 'This command is used to schedule the next check of hosts or services. Icinga will re-queue the' . ' hosts or services to be checked at the time you specify.' ) @@ -64,8 +62,10 @@ class ScheduleServiceCheckCommandForm extends ObjectsCommandForm 'check_time', array( 'required' => true, - 'label' => mt('monitoring', 'Check Time'), - 'description' => mt('monitoring', 'Set the date and time when the check should be scheduled.'), + 'label' => $this->translate('Check Time'), + 'description' => $this->translate( + 'Set the date and time when the check should be scheduled.' + ), 'value' => $checkTime ) ), @@ -73,9 +73,8 @@ class ScheduleServiceCheckCommandForm extends ObjectsCommandForm 'checkbox', 'force_check', array( - 'label' => mt('monitoring', 'Force Check'), - 'description' => mt( - 'monitoring', + 'label' => $this->translate('Force Check'), + 'description' => $this->translate( 'If you select this option, Icinga will force a check regardless of both what time the' . ' scheduled check occurs and whether or not checks are enabled.' ) diff --git a/modules/monitoring/application/forms/Command/Object/ScheduleServiceDowntimeCommandForm.php b/modules/monitoring/application/forms/Command/Object/ScheduleServiceDowntimeCommandForm.php index 9961d4b65..4f66898f6 100644 --- a/modules/monitoring/application/forms/Command/Object/ScheduleServiceDowntimeCommandForm.php +++ b/modules/monitoring/application/forms/Command/Object/ScheduleServiceDowntimeCommandForm.php @@ -42,8 +42,7 @@ class ScheduleServiceDowntimeCommandForm extends ObjectsCommandForm */ public function getHelp() { - return mt( - 'monitoring', + return $this->translate( 'This command is used to schedule host and service downtimes. During the specified downtime,' . ' Icinga will not send notifications out about the hosts and services. When the scheduled' . ' downtime expires, Icinga will send out notifications for the hosts and services as it' @@ -67,9 +66,8 @@ class ScheduleServiceDowntimeCommandForm extends ObjectsCommandForm 'comment', array( 'required' => true, - 'label' => mt('monitoring', 'Comment'), - 'description' => mt( - 'monitoring', + 'label' => $this->translate('Comment'), + 'description' => $this->translate( 'If you work with other administrators, you may find it useful to share information about the' . ' the host or service that is having problems. Make sure you enter a brief description of' . ' what you are doing.' @@ -81,8 +79,8 @@ class ScheduleServiceDowntimeCommandForm extends ObjectsCommandForm 'start', array( 'required' => true, - 'label' => mt('monitoring', 'Start Time'), - 'description' => mt('monitoring', 'Set the start date and time for the downtime.'), + 'label' => $this->translate('Start Time'), + 'description' => $this->translate('Set the start date and time for the downtime.'), 'value' => $start ) ), @@ -91,8 +89,8 @@ class ScheduleServiceDowntimeCommandForm extends ObjectsCommandForm 'end', array( 'required' => true, - 'label' => mt('monitoring', 'End Time'), - 'description' => mt('monitoring', 'Set the end date and time for the downtime.'), + 'label' => $this->translate('End Time'), + 'description' => $this->translate('Set the end date and time for the downtime.'), 'value' => $end ) ), @@ -102,17 +100,16 @@ class ScheduleServiceDowntimeCommandForm extends ObjectsCommandForm array( 'required' => true, 'autosubmit' => true, - 'label' => mt('monitoring', 'Type'), - 'description' => mt( - 'monitoring', + 'label' => $this->translate('Type'), + 'description' => $this->translate( 'If you select the fixed option, the downtime will be in effect between the start and end' . ' times you specify whereas a flexible downtime starts when the host or service enters a' . ' problem state sometime between the start and end times you specified and lasts as long' . ' as the duration time you enter. The duration fields do not apply for fixed downtimes.' ), 'multiOptions' => array( - self::FIXED => mt('monitoring', 'Fixed'), - self::FLEXIBLE => mt('monitoring', 'Flexible') + self::FIXED => $this->translate('Fixed'), + self::FLEXIBLE => $this->translate('Flexible') ), 'validators' => array( array( @@ -141,7 +138,7 @@ class ScheduleServiceDowntimeCommandForm extends ObjectsCommandForm 'hours', array( 'required' => true, - 'label' => mt('monitoring', 'Hours'), + 'label' => $this->translate('Hours'), 'value' => 2, 'min' => -1 ) @@ -151,7 +148,7 @@ class ScheduleServiceDowntimeCommandForm extends ObjectsCommandForm 'minutes', array( 'required' => true, - 'label' => mt('monitoring', 'Minutes'), + 'label' => $this->translate('Minutes'), 'value' => 0, 'min' => -1 ) @@ -161,9 +158,8 @@ class ScheduleServiceDowntimeCommandForm extends ObjectsCommandForm array('hours', 'minutes'), 'duration', array( - 'legend' => mt('monitoring', 'Flexible Duration'), - 'description' => mt( - 'monitoring', + 'legend' => $this->translate('Flexible Duration'), + 'description' => $this->translate( 'Enter here the duration of the downtime. The downtime will be automatically deleted after this' . ' time expired.' ), diff --git a/modules/monitoring/application/forms/Command/Object/ToggleObjectFeaturesCommandForm.php b/modules/monitoring/application/forms/Command/Object/ToggleObjectFeaturesCommandForm.php index c33527895..bf0a1d8b1 100644 --- a/modules/monitoring/application/forms/Command/Object/ToggleObjectFeaturesCommandForm.php +++ b/modules/monitoring/application/forms/Command/Object/ToggleObjectFeaturesCommandForm.php @@ -33,7 +33,7 @@ class ToggleObjectFeaturesCommandForm extends ObjectsCommandForm 'checkbox', ToggleObjectFeatureCommand::FEATURE_ACTIVE_CHECKS, array( - 'label' => mt('monitoring', 'Active Checks'), + 'label' => $this->translate('Active Checks'), 'autosubmit' => true ) ), @@ -41,7 +41,7 @@ class ToggleObjectFeaturesCommandForm extends ObjectsCommandForm 'checkbox', ToggleObjectFeatureCommand::FEATURE_PASSIVE_CHECKS, array( - 'label' => mt('monitoring', 'Passive Checks'), + 'label' => $this->translate('Passive Checks'), 'autosubmit' => true ) ), @@ -49,7 +49,7 @@ class ToggleObjectFeaturesCommandForm extends ObjectsCommandForm 'checkbox', ToggleObjectFeatureCommand::FEATURE_OBSESSING, array( - 'label' => mt('monitoring', 'Obsessing'), + 'label' => $this->translate('Obsessing'), 'autosubmit' => true ) ), @@ -57,7 +57,7 @@ class ToggleObjectFeaturesCommandForm extends ObjectsCommandForm 'checkbox', ToggleObjectFeatureCommand::FEATURE_NOTIFICATIONS, array( - 'label' => mt('monitoring', 'Notifications'), + 'label' => $this->translate('Notifications'), 'autosubmit' => true ) ), @@ -65,7 +65,7 @@ class ToggleObjectFeaturesCommandForm extends ObjectsCommandForm 'checkbox', ToggleObjectFeatureCommand::FEATURE_EVENT_HANDLER, array( - 'label' => mt('monitoring', 'Event Handler'), + 'label' => $this->translate('Event Handler'), 'autosubmit' => true ) ), @@ -73,7 +73,7 @@ class ToggleObjectFeaturesCommandForm extends ObjectsCommandForm 'checkbox', ToggleObjectFeatureCommand::FEATURE_FLAP_DETECTION, array( - 'label' => mt('monitoring', 'Flap Detection'), + 'label' => $this->translate('Flap Detection'), 'autosubmit' => true ) ) @@ -95,7 +95,7 @@ class ToggleObjectFeaturesCommandForm extends ObjectsCommandForm $element = $this->getElement($feature); $element->setChecked($object->{$feature}); if ((bool) $object->{$feature . '_changed'} === true) { - $element->setDescription(mt('monitoring', 'changed')); + $element->setDescription($this->translate('changed')); } } return $this; @@ -120,7 +120,7 @@ class ToggleObjectFeaturesCommandForm extends ObjectsCommandForm } } } - Notification::success(mt('monitoring', 'Toggling feature..')); + Notification::success($this->translate('Toggling feature..')); return true; } } diff --git a/modules/monitoring/application/forms/Config/Instance/LocalInstanceForm.php b/modules/monitoring/application/forms/Config/Instance/LocalInstanceForm.php index daabe7e02..405bac144 100644 --- a/modules/monitoring/application/forms/Config/Instance/LocalInstanceForm.php +++ b/modules/monitoring/application/forms/Config/Instance/LocalInstanceForm.php @@ -28,9 +28,9 @@ class LocalInstanceForm extends Form 'path', array( 'required' => true, - 'label' => mt('monitoring', 'Command File'), + 'label' => $this->translate('Command File'), 'value' => '/var/run/icinga2/cmd/icinga2.cmd', - 'description' => mt('monitoring', 'Path to the local Icinga command file') + 'description' => $this->translate('Path to the local Icinga command file') ) ); return $this; diff --git a/modules/monitoring/application/forms/Config/Instance/RemoteInstanceForm.php b/modules/monitoring/application/forms/Config/Instance/RemoteInstanceForm.php index 7c55f655a..47b2a0316 100644 --- a/modules/monitoring/application/forms/Config/Instance/RemoteInstanceForm.php +++ b/modules/monitoring/application/forms/Config/Instance/RemoteInstanceForm.php @@ -29,8 +29,8 @@ class RemoteInstanceForm extends Form 'host', array( 'required' => true, - 'label' => mt('monitoring', 'Host'), - 'description' => mt('monitoring', + 'label' => $this->translate('Host'), + 'description' => $this->translate( 'Hostname or address of the remote Icinga instance' ) ) @@ -40,8 +40,8 @@ class RemoteInstanceForm extends Form 'port', array( 'required' => true, - 'label' => mt('monitoring', 'Port'), - 'description' => mt('monitoring', 'SSH port to connect to on the remote Icinga instance'), + 'label' => $this->translate('Port'), + 'description' => $this->translate('SSH port to connect to on the remote Icinga instance'), 'value' => 22 ) ), @@ -50,8 +50,8 @@ class RemoteInstanceForm extends Form 'user', array( 'required' => true, - 'label' => mt('monitoring', 'User'), - 'description' => mt('monitoring', + 'label' => $this->translate('User'), + 'description' => $this->translate( 'User to log in as on the remote Icinga instance. Please note that key-based SSH login must be' . ' possible for this user' ) @@ -62,9 +62,9 @@ class RemoteInstanceForm extends Form 'path', array( 'required' => true, - 'label' => mt('monitoring', 'Command File'), + 'label' => $this->translate('Command File'), 'value' => '/var/run/icinga2/cmd/icinga2.cmd', - 'description' => mt('monitoring', 'Path to the Icinga command file on the remote Icinga instance') + 'description' => $this->translate('Path to the Icinga command file on the remote Icinga instance') ) ) )); diff --git a/modules/monitoring/application/forms/Config/InstanceConfigForm.php b/modules/monitoring/application/forms/Config/InstanceConfigForm.php index b89e48c0a..5618f27ee 100644 --- a/modules/monitoring/application/forms/Config/InstanceConfigForm.php +++ b/modules/monitoring/application/forms/Config/InstanceConfigForm.php @@ -25,7 +25,7 @@ class InstanceConfigForm extends ConfigForm public function init() { $this->setName('form_config_monitoring_instance'); - $this->setSubmitLabel(mt('monitoring', 'Save Changes')); + $this->setSubmitLabel($this->translate('Save Changes')); } /** @@ -48,7 +48,7 @@ class InstanceConfigForm extends ConfigForm break; default: throw new InvalidArgumentException( - sprintf(mt('monitoring', 'Invalid instance type "%s" given'), $type) + sprintf($this->translate('Invalid instance type "%s" given'), $type) ); } return $form; @@ -69,10 +69,10 @@ class InstanceConfigForm extends ConfigForm { $name = isset($values['name']) ? $values['name'] : ''; if (! $name) { - throw new InvalidArgumentException(mt('monitoring', 'Instance name missing')); + throw new InvalidArgumentException($this->translate('Instance name missing')); } if ($this->config->hasSection($name)) { - throw new InvalidArgumentException(mt('monitoring', 'Instance already exists')); + throw new InvalidArgumentException($this->translate('Instance already exists')); } unset($values['name']); @@ -93,11 +93,11 @@ class InstanceConfigForm extends ConfigForm public function edit($name, array $values) { if (! $name) { - throw new InvalidArgumentException(mt('monitoring', 'Old instance name missing')); + throw new InvalidArgumentException($this->translate('Old instance name missing')); } elseif (! ($newName = isset($values['name']) ? $values['name'] : '')) { - throw new InvalidArgumentException(mt('monitoring', 'New instance name missing')); + throw new InvalidArgumentException($this->translate('New instance name missing')); } elseif (! $this->config->hasSection($name)) { - throw new InvalidArgumentException(mt('monitoring', 'Unknown instance name provided')); + throw new InvalidArgumentException($this->translate('Unknown instance name provided')); } unset($values['name']); @@ -117,9 +117,9 @@ class InstanceConfigForm extends ConfigForm public function remove($name) { if (! $name) { - throw new InvalidArgumentException(mt('monitoring', 'Instance name missing')); + throw new InvalidArgumentException($this->translate('Instance name missing')); } elseif (! $this->config->hasSection($name)) { - throw new InvalidArgumentException(mt('monitoring', 'Unknown instance name provided')); + throw new InvalidArgumentException($this->translate('Unknown instance name provided')); } $instanceConfig = $this->config->getSection($name); @@ -136,10 +136,10 @@ class InstanceConfigForm extends ConfigForm $instanceName = $this->request->getQuery('instance'); if ($instanceName !== null) { if (! $instanceName) { - throw new ConfigurationError(mt('monitoring', 'Instance name missing')); + throw new ConfigurationError($this->translate('Instance name missing')); } if (! $this->config->hasSection($instanceName)) { - throw new ConfigurationError(mt('monitoring', 'Unknown instance name given')); + throw new ConfigurationError($this->translate('Unknown instance name given')); } $instanceConfig = $this->config->getSection($instanceName)->toArray(); @@ -158,10 +158,10 @@ class InstanceConfigForm extends ConfigForm try { if ($instanceName === null) { // create new instance $this->add($this->getValues()); - $message = mt('monitoring', 'Instance "%s" created successfully.'); + $message = $this->translate('Instance "%s" created successfully.'); } else { // edit existing instance $this->edit($instanceName, $this->getValues()); - $message = mt('monitoring', 'Instance "%s" edited successfully.'); + $message = $this->translate('Instance "%s" edited successfully.'); } } catch (InvalidArgumentException $e) { Notification::error($e->getMessage()); @@ -189,7 +189,7 @@ class InstanceConfigForm extends ConfigForm 'name', array( 'required' => true, - 'label' => mt('monitoring', 'Instance Name') + 'label' => $this->translate('Instance Name') ) ), array( @@ -198,10 +198,10 @@ class InstanceConfigForm extends ConfigForm array( 'required' => true, 'autosubmit' => true, - 'label' => mt('monitoring', 'Instance Type'), + 'label' => $this->translate('Instance Type'), 'multiOptions' => array( - LocalCommandFile::TRANSPORT => mt('monitoring', 'Local Command File'), - RemoteCommandFile::TRANSPORT => mt('monitoring', 'Remote Command File') + LocalCommandFile::TRANSPORT => $this->translate('Local Command File'), + RemoteCommandFile::TRANSPORT => $this->translate('Remote Command File') ), 'value' => $instanceType ) diff --git a/modules/monitoring/application/forms/Config/SecurityConfigForm.php b/modules/monitoring/application/forms/Config/SecurityConfigForm.php index 40c0b7b8c..b202f5938 100644 --- a/modules/monitoring/application/forms/Config/SecurityConfigForm.php +++ b/modules/monitoring/application/forms/Config/SecurityConfigForm.php @@ -18,7 +18,7 @@ class SecurityConfigForm extends ConfigForm public function init() { $this->setName('form_config_monitoring_security'); - $this->setSubmitLabel(mt('monitoring', 'Save Changes')); + $this->setSubmitLabel($this->translate('Save Changes')); } /** @@ -29,7 +29,7 @@ class SecurityConfigForm extends ConfigForm $this->config->setSection('security', $this->getValues()); if ($this->save()) { - Notification::success(mt('monitoring', 'New security configuration has successfully been stored')); + Notification::success($this->translate('New security configuration has successfully been stored')); } else { return false; } @@ -54,8 +54,8 @@ class SecurityConfigForm extends ConfigForm array( 'allowEmpty' => true, 'value' => '*pw*,*pass*,community', - 'label' => mt('monitoring', 'Protected Custom Variables'), - 'description' => mt('monitoring', + 'label' => $this->translate('Protected Custom Variables'), + 'description' => $this->translate( 'Comma separated case insensitive list of protected custom variables.' . ' Use * as a placeholder for zero or more wildcard characters.' . ' Existance of those custom variables will be shown, but their values will be masked.' diff --git a/modules/monitoring/application/forms/EventOverviewForm.php b/modules/monitoring/application/forms/EventOverviewForm.php index 25d268f76..dc697b940 100644 --- a/modules/monitoring/application/forms/EventOverviewForm.php +++ b/modules/monitoring/application/forms/EventOverviewForm.php @@ -44,7 +44,7 @@ class EventOverviewForm extends Form 'checkbox', 'statechange', array( - 'label' => t('State Changes'), + 'label' => $this->translate('State Changes'), 'class' => 'autosubmit', 'decorators' => $decorators, 'value' => strpos($url, $this->stateChangeFilter()->toQueryString()) === false ? 0 : 1 @@ -54,7 +54,7 @@ class EventOverviewForm extends Form 'checkbox', 'downtime', array( - 'label' => t('Downtimes'), + 'label' => $this->translate('Downtimes'), 'class' => 'autosubmit', 'decorators' => $decorators, 'value' => strpos($url, $this->downtimeFilter()->toQueryString()) === false ? 0 : 1 @@ -64,7 +64,7 @@ class EventOverviewForm extends Form 'checkbox', 'comment', array( - 'label' => t('Comments'), + 'label' => $this->translate('Comments'), 'class' => 'autosubmit', 'decorators' => $decorators, 'value' => strpos($url, $this->commentFilter()->toQueryString()) === false ? 0 : 1 @@ -74,7 +74,7 @@ class EventOverviewForm extends Form 'checkbox', 'notification', array( - 'label' => t('Notifications'), + 'label' => $this->translate('Notifications'), 'class' => 'autosubmit', 'decorators' => $decorators, 'value' => strpos($url, $this->notificationFilter()->toQueryString()) === false ? 0 : 1 @@ -84,7 +84,7 @@ class EventOverviewForm extends Form 'checkbox', 'flapping', array( - 'label' => t('Flapping'), + 'label' => $this->translate('Flapping'), 'class' => 'autosubmit', 'decorators' => $decorators, 'value' => strpos($url, $this->flappingFilter()->toQueryString()) === false ? 0 : 1 diff --git a/modules/monitoring/application/forms/Setup/BackendPage.php b/modules/monitoring/application/forms/Setup/BackendPage.php index 1f6ef6894..b5ab2ffd6 100644 --- a/modules/monitoring/application/forms/Setup/BackendPage.php +++ b/modules/monitoring/application/forms/Setup/BackendPage.php @@ -20,7 +20,7 @@ class BackendPage extends Form 'note', 'title', array( - 'value' => mt('monitoring', 'Monitoring Backend', 'setup.page.title'), + 'value' => $this->translate('Monitoring Backend', 'setup.page.title'), 'decorators' => array( 'ViewHelper', array('HtmlTag', array('tag' => 'h2')) @@ -31,8 +31,7 @@ class BackendPage extends Form 'note', 'description', array( - 'value' => mt( - 'monitoring', + 'value' => $this->translate( 'Please configure below how Icinga Web 2 should retrieve monitoring information.' ) ) @@ -44,8 +43,8 @@ class BackendPage extends Form array( 'required' => true, 'value' => 'icinga', - 'label' => mt('monitoring', 'Backend Name'), - 'description' => mt('monitoring', 'The identifier of this backend') + 'label' => $this->translate('Backend Name'), + 'description' => $this->translate('The identifier of this backend') ) ); @@ -60,8 +59,10 @@ class BackendPage extends Form 'type', array( 'required' => true, - 'label' => mt('monitoring', 'Backend Type'), - 'description' => mt('monitoring', 'The data source used for retrieving monitoring information'), + 'label' => $this->translate('Backend Type'), + 'description' => $this->translate( + 'The data source used for retrieving monitoring information' + ), 'multiOptions' => $resourceTypes ) ); diff --git a/modules/monitoring/application/forms/Setup/IdoResourcePage.php b/modules/monitoring/application/forms/Setup/IdoResourcePage.php index 189d65fea..c28b52e6b 100644 --- a/modules/monitoring/application/forms/Setup/IdoResourcePage.php +++ b/modules/monitoring/application/forms/Setup/IdoResourcePage.php @@ -28,7 +28,7 @@ class IdoResourcePage extends Form 'note', 'title', array( - 'value' => mt('monitoring', 'Monitoring IDO Resource', 'setup.page.title'), + 'value' => $this->translate('Monitoring IDO Resource', 'setup.page.title'), 'decorators' => array( 'ViewHelper', array('HtmlTag', array('tag' => 'h2')) @@ -39,8 +39,7 @@ class IdoResourcePage extends Form 'note', 'description', array( - 'value' => mt( - 'monitoring', + 'value' => $this->translate( 'Please fill out the connection details below to access' . ' the IDO database of your monitoring environment.' ) @@ -91,8 +90,10 @@ class IdoResourcePage extends Form 'skip_validation', array( 'required' => true, - 'label' => t('Skip Validation'), - 'description' => t('Check this to not to validate connectivity with the given database server') + 'label' => $this->translate('Skip Validation'), + 'description' => $this->translate( + 'Check this to not to validate connectivity with the given database server' + ) ) ); } diff --git a/modules/monitoring/application/forms/Setup/InstancePage.php b/modules/monitoring/application/forms/Setup/InstancePage.php index dccfd1d91..8f151554d 100644 --- a/modules/monitoring/application/forms/Setup/InstancePage.php +++ b/modules/monitoring/application/forms/Setup/InstancePage.php @@ -20,7 +20,7 @@ class InstancePage extends Form 'note', 'title', array( - 'value' => mt('monitoring', 'Monitoring Instance', 'setup.page.title'), + 'value' => $this->translate('Monitoring Instance', 'setup.page.title'), 'decorators' => array( 'ViewHelper', array('HtmlTag', array('tag' => 'h2')) @@ -31,8 +31,7 @@ class InstancePage extends Form 'note', 'description', array( - 'value' => mt( - 'monitoring', + 'value' => $this->translate( 'Please define the settings specific to your monitoring instance below.' ) ) diff --git a/modules/monitoring/application/forms/Setup/LivestatusResourcePage.php b/modules/monitoring/application/forms/Setup/LivestatusResourcePage.php index 4faa17416..245d2abcc 100644 --- a/modules/monitoring/application/forms/Setup/LivestatusResourcePage.php +++ b/modules/monitoring/application/forms/Setup/LivestatusResourcePage.php @@ -28,7 +28,7 @@ class LivestatusResourcePage extends Form 'note', 'title', array( - 'value' => mt('monitoring', 'Monitoring Livestatus Resource', 'setup.page.title'), + 'value' => $this->translate('Monitoring Livestatus Resource', 'setup.page.title'), 'decorators' => array( 'ViewHelper', array('HtmlTag', array('tag' => 'h2')) @@ -39,8 +39,7 @@ class LivestatusResourcePage extends Form 'note', 'description', array( - 'value' => mt( - 'monitoring', + 'value' => $this->translate( 'Please fill out the connection details below to access the Livestatus' . ' socket interface for your monitoring environment.' ) @@ -91,8 +90,10 @@ class LivestatusResourcePage extends Form 'skip_validation', array( 'required' => true, - 'label' => t('Skip Validation'), - 'description' => t('Check this to not to validate connectivity with the given Livestatus socket') + 'label' => $this->translate('Skip Validation'), + 'description' => $this->translate( + 'Check this to not to validate connectivity with the given Livestatus socket' + ) ) ); } diff --git a/modules/monitoring/application/forms/Setup/SecurityPage.php b/modules/monitoring/application/forms/Setup/SecurityPage.php index 0c7d3d1de..ba8083e50 100644 --- a/modules/monitoring/application/forms/Setup/SecurityPage.php +++ b/modules/monitoring/application/forms/Setup/SecurityPage.php @@ -20,7 +20,7 @@ class SecurityPage extends Form 'note', 'title', array( - 'value' => mt('monitoring', 'Monitoring Security', 'setup.page.title'), + 'value' => $this->translate('Monitoring Security', 'setup.page.title'), 'decorators' => array( 'ViewHelper', array('HtmlTag', array('tag' => 'h2')) @@ -31,8 +31,7 @@ class SecurityPage extends Form 'note', 'description', array( - 'value' => mt( - 'monitoring', + 'value' => $this->translate( 'To protect your monitoring environment against prying eyes please fill out the settings below.' ) ) diff --git a/modules/monitoring/application/forms/Setup/WelcomePage.php b/modules/monitoring/application/forms/Setup/WelcomePage.php index d910e2e01..f79eb6c62 100644 --- a/modules/monitoring/application/forms/Setup/WelcomePage.php +++ b/modules/monitoring/application/forms/Setup/WelcomePage.php @@ -19,10 +19,7 @@ class WelcomePage extends Form 'note', 'welcome', array( - 'value' => mt( - 'monitoring', - 'Welcome to the configuration of the monitoring module for Icinga Web 2!' - ), + 'value' => $this->translate('Welcome to the configuration of the monitoring module for Icinga Web 2!'), 'decorators' => array( 'ViewHelper', array('HtmlTag', array('tag' => 'h2')) @@ -34,7 +31,7 @@ class WelcomePage extends Form 'note', 'core_hint', array( - 'value' => mt('monitoring', 'This is the core module for Icinga Web 2.') + 'value' => $this->translate('This is the core module for Icinga Web 2.') ) ); @@ -42,8 +39,7 @@ class WelcomePage extends Form 'note', 'description', array( - 'value' => mt( - 'monitoring', + 'value' => $this->translate( 'It offers various status and reporting views with powerful filter capabilities that allow' . ' you to keep track of the most important events in your monitoring environment.' ) diff --git a/modules/monitoring/application/forms/StatehistoryForm.php b/modules/monitoring/application/forms/StatehistoryForm.php index 9fa1bdc26..d859f5815 100644 --- a/modules/monitoring/application/forms/StatehistoryForm.php +++ b/modules/monitoring/application/forms/StatehistoryForm.php @@ -19,7 +19,7 @@ class StatehistoryForm extends Form public function init() { $this->setName('form_event_overview'); - $this->setSubmitLabel(mt('monitoring', 'Apply')); + $this->setSubmitLabel($this->translate('Apply')); } /** @@ -65,14 +65,14 @@ class StatehistoryForm extends Form 'select', 'from', array( - 'label' => mt('monitoring', 'From'), + 'label' => $this->translate('From'), 'value' => $this->getRequest()->getParam('from', strtotime('3 months ago')), 'multiOptions' => array( - strtotime('midnight 3 months ago') => mt('monitoring', '3 Months'), - strtotime('midnight 4 months ago') => mt('monitoring', '4 Months'), - strtotime('midnight 8 months ago') => mt('monitoring', '8 Months'), - strtotime('midnight 12 months ago') => mt('monitoring', '1 Year'), - strtotime('midnight 24 months ago') => mt('monitoring', '2 Years') + strtotime('midnight 3 months ago') => $this->translate('3 Months'), + strtotime('midnight 4 months ago') => $this->translate('4 Months'), + strtotime('midnight 8 months ago') => $this->translate('8 Months'), + strtotime('midnight 12 months ago') => $this->translate('1 Year'), + strtotime('midnight 24 months ago') => $this->translate('2 Years') ), 'class' => 'autosubmit' ) @@ -81,10 +81,10 @@ class StatehistoryForm extends Form 'select', 'to', array( - 'label' => mt('monitoring', 'To'), + 'label' => $this->translate('To'), 'value' => $this->getRequest()->getParam('to', time()), 'multiOptions' => array( - time() => mt('monitoring', 'Today') + time() => $this->translate('Today') ), 'class' => 'autosubmit' ) @@ -95,11 +95,11 @@ class StatehistoryForm extends Form 'select', 'objecttype', array( - 'label' => mt('monitoring', 'Object type'), + 'label' => $this->translate('Object type'), 'value' => $objectType, 'multiOptions' => array( - 'services' => mt('monitoring', 'Services'), - 'hosts' => mt('monitoring', 'Hosts') + 'services' => $this->translate('Services'), + 'hosts' => $this->translate('Hosts') ), 'class' => 'autosubmit' ) @@ -113,13 +113,13 @@ class StatehistoryForm extends Form 'select', 'state', array( - 'label' => mt('monitoring', 'State'), + 'label' => $this->translate('State'), 'value' => $serviceState, 'multiOptions' => array( - 'cnt_critical_hard' => mt('monitoring', 'Critical'), - 'cnt_warning_hard' => mt('monitoring', 'Warning'), - 'cnt_unknown_hard' => mt('monitoring', 'Unknown'), - 'cnt_ok' => mt('monitoring', 'Ok') + 'cnt_critical_hard' => $this->translate('Critical'), + 'cnt_warning_hard' => $this->translate('Warning'), + 'cnt_unknown_hard' => $this->translate('Unknown'), + 'cnt_ok' => $this->translate('Ok') ), 'class' => 'autosubmit' ) @@ -133,12 +133,12 @@ class StatehistoryForm extends Form 'select', 'state', array( - 'label' => mt('monitoring', 'State'), + 'label' => $this->translate('State'), 'value' => $hostState, 'multiOptions' => array( - 'cnt_up' => mt('monitoring', 'Up'), - 'cnt_down_hard' => mt('monitoring', 'Down'), - 'cnt_unreachable_hard' => mt('monitoring', 'Unreachable') + 'cnt_up' => $this->translate('Up'), + 'cnt_down_hard' => $this->translate('Down'), + 'cnt_unreachable_hard' => $this->translate('Unreachable') ), 'class' => 'autosubmit' ) From 2d957205eff8103e155cf90677854eabc94578de Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Mon, 19 Jan 2015 13:47:53 +0100 Subject: [PATCH 0206/2920] Using $this when not in object context, doesn't work. refs #7551 --- application/forms/Config/Authentication/DbBackendForm.php | 4 ++-- application/forms/Config/Authentication/LdapBackendForm.php | 2 +- application/forms/Config/Resource/DbResourceForm.php | 2 +- application/forms/Config/Resource/LdapResourceForm.php | 2 +- application/forms/Config/Resource/LivestatusResourceForm.php | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/application/forms/Config/Authentication/DbBackendForm.php b/application/forms/Config/Authentication/DbBackendForm.php index f8a4fb832..d3a5af51d 100644 --- a/application/forms/Config/Authentication/DbBackendForm.php +++ b/application/forms/Config/Authentication/DbBackendForm.php @@ -109,11 +109,11 @@ class DbBackendForm extends Form try { $dbUserBackend = new DbUserBackend(ResourceFactory::createResource($form->getResourceConfig())); if ($dbUserBackend->count() < 1) { - $form->addError($this->translate('No users found under the specified database backend')); + $form->addError($form->translate('No users found under the specified database backend')); return false; } } catch (Exception $e) { - $form->addError(sprintf($this->translate('Using the specified backend failed: %s'), $e->getMessage())); + $form->addError(sprintf($form->translate('Using the specified backend failed: %s'), $e->getMessage())); return false; } diff --git a/application/forms/Config/Authentication/LdapBackendForm.php b/application/forms/Config/Authentication/LdapBackendForm.php index 5915a0a10..1b8fc3f11 100644 --- a/application/forms/Config/Authentication/LdapBackendForm.php +++ b/application/forms/Config/Authentication/LdapBackendForm.php @@ -150,7 +150,7 @@ class LdapBackendForm extends Form $form->addError($e->getMessage()); return false; } catch (Exception $e) { - $form->addError(sprintf($this->translate('Unable to validate authentication: %s'), $e->getMessage())); + $form->addError(sprintf($form->translate('Unable to validate authentication: %s'), $e->getMessage())); return false; } diff --git a/application/forms/Config/Resource/DbResourceForm.php b/application/forms/Config/Resource/DbResourceForm.php index 9e4027299..97dd951d1 100644 --- a/application/forms/Config/Resource/DbResourceForm.php +++ b/application/forms/Config/Resource/DbResourceForm.php @@ -133,7 +133,7 @@ class DbResourceForm extends Form $resource->getConnection()->getConnection(); } catch (Exception $e) { $form->addError( - $this->translate('Connectivity validation failed, connection to the given resource not possible.') + $form->translate('Connectivity validation failed, connection to the given resource not possible.') ); return false; } diff --git a/application/forms/Config/Resource/LdapResourceForm.php b/application/forms/Config/Resource/LdapResourceForm.php index c113e2471..3293546c5 100644 --- a/application/forms/Config/Resource/LdapResourceForm.php +++ b/application/forms/Config/Resource/LdapResourceForm.php @@ -124,7 +124,7 @@ class LdapResourceForm extends Form } } catch (Exception $e) { $form->addError( - $this->translate('Connectivity validation failed, connection to the given resource not possible.') + $form->translate('Connectivity validation failed, connection to the given resource not possible.') ); return false; } diff --git a/application/forms/Config/Resource/LivestatusResourceForm.php b/application/forms/Config/Resource/LivestatusResourceForm.php index 996827228..e893a4657 100644 --- a/application/forms/Config/Resource/LivestatusResourceForm.php +++ b/application/forms/Config/Resource/LivestatusResourceForm.php @@ -77,7 +77,7 @@ class LivestatusResourceForm extends Form $resource->connect()->disconnect(); } catch (Exception $_) { $form->addError( - $this->translate('Connectivity validation failed, connection to the given resource not possible.') + $form->translate('Connectivity validation failed, connection to the given resource not possible.') ); return false; } From 56640fa64fd6ab1371d2aec54442258766b1614f Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Mon, 19 Jan 2015 13:50:03 +0100 Subject: [PATCH 0207/2920] postgres: Use timestamp comparison instead of timezone offset comparison for detecting the default timestamp refs #7919 --- .../library/Monitoring/Backend/Ido/Query/IdoQuery.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/monitoring/library/Monitoring/Backend/Ido/Query/IdoQuery.php b/modules/monitoring/library/Monitoring/Backend/Ido/Query/IdoQuery.php index f2e5bd15f..cf6968ea3 100644 --- a/modules/monitoring/library/Monitoring/Backend/Ido/Query/IdoQuery.php +++ b/modules/monitoring/library/Monitoring/Backend/Ido/Query/IdoQuery.php @@ -324,8 +324,8 @@ abstract class IdoQuery extends DbQuery $value = preg_replace('/ COLLATE .+$/', '', $value); $value = preg_replace('/inet_aton\(([[:word:].]+)\)/i', '$1::inet - \'0.0.0.0\'', $value); $value = preg_replace( - '/(UNIX_TIMESTAMP(\((?>[^()]|(?-1))*\)))/i', - 'CASE WHEN ($1 = EXTRACT(TIMEZONE FROM NOW()) * -1) THEN 0 ELSE $1 END', + '/UNIX_TIMESTAMP(\((?>[^()]|(?-1))*\))/i', + 'CASE WHEN ($1 < \'1970-01-03 00:00:00+00\'::timestamp with time zone) THEN 0 ELSE UNIX_TIMESTAMP($1) END', $value ); } From ae927cf043779e631e45516e5dadb2c27c6fc436 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Mon, 19 Jan 2015 13:53:39 +0100 Subject: [PATCH 0208/2920] puppet/postgres: Allow connections made by Icinga 2 fixes #8109 --- .puppet/modules/pgsql/templates/pg_hba.conf.erb | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.puppet/modules/pgsql/templates/pg_hba.conf.erb b/.puppet/modules/pgsql/templates/pg_hba.conf.erb index f6fb19ebf..c37e6ffd4 100644 --- a/.puppet/modules/pgsql/templates/pg_hba.conf.erb +++ b/.puppet/modules/pgsql/templates/pg_hba.conf.erb @@ -71,6 +71,11 @@ local icinga icinga trust host icinga icinga 127.0.0.1/32 trust host icinga icinga ::1/128 trust +# icinga2 +local icinga2 icinga2 trust +host icinga2 icinga2 127.0.0.1/32 trust +host icinga2 icinga2 ::1/128 trust + # icinga_unittest local icinga_unittest icinga_unittest trust host icinga_unittest icinga_unittest 127.0.0.1/32 trust From a456c0434c87c36242c7dfa2e34c9a6f397027e9 Mon Sep 17 00:00:00 2001 From: Matthias Jentsch Date: Mon, 19 Jan 2015 13:58:04 +0100 Subject: [PATCH 0209/2920] Add better axis labels to the alert summary chart --- .../controllers/AlertsummaryController.php | 28 +++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) diff --git a/modules/monitoring/application/controllers/AlertsummaryController.php b/modules/monitoring/application/controllers/AlertsummaryController.php index 1344d03f4..c89f51f48 100644 --- a/modules/monitoring/application/controllers/AlertsummaryController.php +++ b/modules/monitoring/application/controllers/AlertsummaryController.php @@ -342,7 +342,7 @@ class Monitoring_AlertsummaryController extends Controller $gridChart = new GridChart(); $gridChart->alignTopLeft(); - $gridChart->setAxisLabel('', mt('monitoring', 'Notifications')) + $gridChart->setAxisLabel($this->createPeriodDescription(), mt('monitoring', 'Notifications')) ->setXAxis(new StaticAxis()) ->setYAxis(new LinearUnit(10)) ->setAxisMin(null, 0); @@ -470,7 +470,7 @@ class Monitoring_AlertsummaryController extends Controller $gridChart = new GridChart(); $gridChart->alignTopLeft(); - $gridChart->setAxisLabel('', mt('monitoring', 'Notifications')) + $gridChart->setAxisLabel($this->createPeriodDescription(), mt('monitoring', 'Notifications')) ->setXAxis(new StaticAxis()) ->setAxisMin(null, 0) ->setYAxis(new LinearUnit(10)); @@ -623,4 +623,28 @@ class Monitoring_AlertsummaryController extends Controller return $interval; } + + /** + * Create a human-readable description of the current interval size + * + * @return string The description of the current interval size + */ + private function createPeriodDescription() + { + $int = $this->getInterval(); + switch ($int) { + case '1d': + return t('Hour'); + break; + case '1w'; + return t('Day'); + break; + case '1m': + return t('Day'); + break; + case '1y': + return t('Month'); + break; + } + } } From 10ebc3432c0a81ef52f41679aeaae49ea088f2ad Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Mon, 19 Jan 2015 14:17:59 +0100 Subject: [PATCH 0210/2920] monitoring: Do not strip_tags when viewing host output in the host list refs #8248 --- modules/monitoring/application/views/scripts/list/hosts.phtml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/monitoring/application/views/scripts/list/hosts.phtml b/modules/monitoring/application/views/scripts/list/hosts.phtml index 2f339b1bf..4d60eacf4 100644 --- a/modules/monitoring/application/views/scripts/list/hosts.phtml +++ b/modules/monitoring/application/views/scripts/list/hosts.phtml @@ -115,7 +115,7 @@ if ($hosts->count() === 0) { array('style' => 'font-weight: normal') ) ?>) -

    escape(substr(strip_tags($host->host_output), 0, 10000)) ?>

    +

    escape(substr($host->host_output, 0, 10000)) ?>

    extraColumns as $col): ?> escape($host->$col) ?> From f56ffd3426671aeb28ba4fb682ef019e1769f264 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Mon, 19 Jan 2015 14:18:46 +0100 Subject: [PATCH 0211/2920] monitoring: Do not strip_tags when viewing service output in the service list refs #8248 --- .../monitoring/application/views/scripts/list/services.phtml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/monitoring/application/views/scripts/list/services.phtml b/modules/monitoring/application/views/scripts/list/services.phtml index 8ef6f7fe8..26249b710 100644 --- a/modules/monitoring/application/views/scripts/list/services.phtml +++ b/modules/monitoring/application/views/scripts/list/services.phtml @@ -112,7 +112,7 @@ foreach ($services as $service): (host_state, true)); ?>)
    -

    escape(substr(strip_tags($service->service_output), 0, 10000)); ?>

    +

    escape(substr($service->service_output, 0, 10000)); ?>

    extraColumns as $col): ?> escape($service->$col) ?> From a0a3241d1c42d138a588478f4199d3cdcd887d75 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Mon, 19 Jan 2015 14:20:37 +0100 Subject: [PATCH 0212/2920] lib: Add String::ellipsis() --- library/Icinga/Util/String.php | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/library/Icinga/Util/String.php b/library/Icinga/Util/String.php index 248ab0d34..69fb26927 100644 --- a/library/Icinga/Util/String.php +++ b/library/Icinga/Util/String.php @@ -36,4 +36,22 @@ class String { return str_replace(' ', '', ucwords(str_replace($separator, ' ', strtolower($name)))); } + + /** + * Add ellipsis when a string is longer than max length + * + * @param string $string + * @param int $maxLength + * @param string $ellipsis + * + * @return string + */ + public static function ellipsis($string, $maxLength, $ellipsis = '...') + { + if (strlen($string) > $maxLength) { + return substr($string, 0, $maxLength - strlen($ellipsis)) . $ellipsis; + } + + return $string; + } } From ab4cbc855f089d6a07ccfb200f9144b2afdbacab Mon Sep 17 00:00:00 2001 From: Matthias Jentsch Date: Mon, 19 Jan 2015 14:20:46 +0100 Subject: [PATCH 0213/2920] Fix order of setAxisMin calls --- .../application/controllers/AlertsummaryController.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/monitoring/application/controllers/AlertsummaryController.php b/modules/monitoring/application/controllers/AlertsummaryController.php index c89f51f48..79aad7f72 100644 --- a/modules/monitoring/application/controllers/AlertsummaryController.php +++ b/modules/monitoring/application/controllers/AlertsummaryController.php @@ -472,8 +472,8 @@ class Monitoring_AlertsummaryController extends Controller $gridChart->alignTopLeft(); $gridChart->setAxisLabel($this->createPeriodDescription(), mt('monitoring', 'Notifications')) ->setXAxis(new StaticAxis()) - ->setAxisMin(null, 0) - ->setYAxis(new LinearUnit(10)); + ->setYAxis(new LinearUnit(10)) + ->setAxisMin(null, 0); $gridChart->drawBars( array( From a1a36301fe551bb3957f2c7da93892bd93cc653e Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Mon, 19 Jan 2015 14:20:57 +0100 Subject: [PATCH 0214/2920] View: Add string helpers --- library/Icinga/Web/View/helpers/string.php | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 library/Icinga/Web/View/helpers/string.php diff --git a/library/Icinga/Web/View/helpers/string.php b/library/Icinga/Web/View/helpers/string.php new file mode 100644 index 000000000..1d79d885a --- /dev/null +++ b/library/Icinga/Web/View/helpers/string.php @@ -0,0 +1,8 @@ +addHelperFunction('ellipsis', function ($string, $maxLength, $ellipsis = '...') { + return String::ellipsis($string, $maxLength, $ellipsis); +}); From 7580d57c1d85d281ffdd5fe5d165167cd693b962 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Mon, 19 Jan 2015 14:21:55 +0100 Subject: [PATCH 0215/2920] monitoring: Use the ellipsis string helper when viewing plugin output in host and service list --- modules/monitoring/application/views/scripts/list/hosts.phtml | 2 +- .../monitoring/application/views/scripts/list/services.phtml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/monitoring/application/views/scripts/list/hosts.phtml b/modules/monitoring/application/views/scripts/list/hosts.phtml index 4d60eacf4..920a77e01 100644 --- a/modules/monitoring/application/views/scripts/list/hosts.phtml +++ b/modules/monitoring/application/views/scripts/list/hosts.phtml @@ -115,7 +115,7 @@ if ($hosts->count() === 0) { array('style' => 'font-weight: normal') ) ?>) -

    escape(substr($host->host_output, 0, 10000)) ?>

    +

    escape($this->ellipsis($host->host_output, 10000)) ?>

    extraColumns as $col): ?> escape($host->$col) ?> diff --git a/modules/monitoring/application/views/scripts/list/services.phtml b/modules/monitoring/application/views/scripts/list/services.phtml index 26249b710..0b63c7887 100644 --- a/modules/monitoring/application/views/scripts/list/services.phtml +++ b/modules/monitoring/application/views/scripts/list/services.phtml @@ -112,7 +112,7 @@ foreach ($services as $service): (host_state, true)); ?>)
    -

    escape(substr($service->service_output, 0, 10000)); ?>

    +

    escape($this->ellipsis($service->service_output, 10000)); ?>

    extraColumns as $col): ?> escape($service->$col) ?> From 5ccd29049060e7f25bab85449b7410da06387245 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Mon, 19 Jan 2015 15:07:37 +0100 Subject: [PATCH 0216/2920] puppet/postgres: Allow connections made by Icinga Web 2 --- .puppet/modules/pgsql/templates/pg_hba.conf.erb | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.puppet/modules/pgsql/templates/pg_hba.conf.erb b/.puppet/modules/pgsql/templates/pg_hba.conf.erb index c37e6ffd4..ca98bebd8 100644 --- a/.puppet/modules/pgsql/templates/pg_hba.conf.erb +++ b/.puppet/modules/pgsql/templates/pg_hba.conf.erb @@ -86,6 +86,11 @@ local icingaweb icingaweb trust host icingaweb icingaweb 127.0.0.1/32 trust host icingaweb icingaweb ::1/128 trust +# icingaweb2 +local <%= scope.function_hiera(['icingaweb2::db_user']) %> <%= scope.function_hiera(['icingaweb2::db_user']) %> trust +host <%= scope.function_hiera(['icingaweb2::db_user']) %> <%= scope.function_hiera(['icingaweb2::db_user']) %> 127.0.0.1/32 trust +host <%= scope.function_hiera(['icingaweb2::db_user']) %> <%= scope.function_hiera(['icingaweb2::db_user']) %> ::1/128 trust + # "local" is for Unix domain socket connections only local all all ident # IPv4 local connections: From ba1007465a8e5750c74cd455a4dd0e476152d215 Mon Sep 17 00:00:00 2001 From: Matthias Jentsch Date: Mon, 19 Jan 2015 15:12:00 +0100 Subject: [PATCH 0217/2920] Adapt bar width to amount of data points --- library/Icinga/Chart/Graph/BarGraph.php | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/library/Icinga/Chart/Graph/BarGraph.php b/library/Icinga/Chart/Graph/BarGraph.php index 0ec5e77a9..febad8d09 100644 --- a/library/Icinga/Chart/Graph/BarGraph.php +++ b/library/Icinga/Chart/Graph/BarGraph.php @@ -28,7 +28,7 @@ class BarGraph extends Styleable implements Drawable * * @var int */ - private $barWidth = 1; + private $barWidth = 3; /** * The dataset to use for this bar graph @@ -122,6 +122,14 @@ class BarGraph extends Styleable implements Drawable $doc = $ctx->getDocument(); $group = $doc->createElement('g'); $idx = 0; + + if (count($this->dataSet) > 15) { + $this->barWidth = 2; + } + if (count($this->dataSet) > 25) { + $this->barWidth = 1; + } + foreach ($this->dataSet as $x => $point) { // add white background bar, to prevent other bars from altering transparency effects $bar = $this->drawSingleBar($point, $idx++, 'white', $this->strokeWidth, $idx)->toSvg($ctx); From 80fc2a32db8036fd10e1c49c9f72215597bc4d3b Mon Sep 17 00:00:00 2001 From: Matthias Jentsch Date: Mon, 19 Jan 2015 15:14:09 +0100 Subject: [PATCH 0218/2920] Improve layout in AlertSummary Use brighter color for notifications, render hours more readable. --- .../application/controllers/AlertsummaryController.php | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/modules/monitoring/application/controllers/AlertsummaryController.php b/modules/monitoring/application/controllers/AlertsummaryController.php index 79aad7f72..652c09be3 100644 --- a/modules/monitoring/application/controllers/AlertsummaryController.php +++ b/modules/monitoring/application/controllers/AlertsummaryController.php @@ -429,11 +429,10 @@ class Monitoring_AlertsummaryController extends Controller $item[1] = $item[1]/60/60; } - $gridChart->drawBars( array( 'label' => $this->translate('Notifications'), - 'color' => '#049baf', + 'color' => '#07C0D9', 'data' => $notifications, 'showPoints' => true ) @@ -478,7 +477,7 @@ class Monitoring_AlertsummaryController extends Controller $gridChart->drawBars( array( 'label' => $this->translate('Notifications'), - 'color' => '#049baf', + 'color' => '#07C0D9', 'data' => $this->notificationData, 'showPoints' => true ) @@ -554,7 +553,7 @@ class Monitoring_AlertsummaryController extends Controller { $format = ''; if ($interval === '1d') { - $format = '%H:00:00'; + $format = '%H:00'; } elseif ($interval === '1w') { $format = '%Y-%m-%d'; } elseif ($interval === '1m') { From d275bc0762e3ac9c4811773ff72ec423916d7617 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Mon, 19 Jan 2015 15:50:05 +0100 Subject: [PATCH 0219/2920] rpm: Cover all dependencies fixes #6302 refs #4075 --- icingaweb2.spec | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/icingaweb2.spec b/icingaweb2.spec index c98a8c65f..56024a962 100644 --- a/icingaweb2.spec +++ b/icingaweb2.spec @@ -64,7 +64,7 @@ Icinga Web 2 %define logdir %{_localstatedir}/log/%{name} %define phpdir %{_datadir}/php %define icingawebgroup icingaweb2 -%define docsdir %{_datadir}/doc/%{name} +%define docsdir %{_datadir}/doc/%{name} %package common @@ -79,7 +79,10 @@ Common files for Icinga Web 2 and the Icinga CLI Summary: Icinga Web 2 PHP library Group: Development/Libraries Requires: %{php} >= 5.3.0 -%{?suse_version:Requires: %{php}-gettext %{php}-openssl} +Requires: %{php}-gd %{php}-intl +%{?fedora:Requires: php-pecl-imagick} +%{?rhel:Requires: php-pecl-imagick} +%{?suse_version:Requires: %{php}-gettext %{php}-openssl php5-imagick} %description -n php-Icinga Icinga Web 2 PHP library @@ -90,9 +93,9 @@ Summary: Icinga CLI Group: Applications/System Requires: %{name}-common = %{version}-%{release} Requires: php-Icinga = %{version}-%{release} +%{?fedora:Requires: %{php_cli} >= 5.3.0 bash-completion} +%{?rhel:Requires: %{php_cli} >= 5.3.0 bash-completion} %{?suse_version:Requires: %{php} >= 5.3.0} -%{?rhel:Requires: %{php_cli} >= 5.3.0} -%{?rhel:Requires: bash-completion} %description -n icingacli Icinga CLI From 2bd2f32b2e8da6d0bf0f008497d731ffdd594372 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Mon, 19 Jan 2015 16:43:19 +0100 Subject: [PATCH 0220/2920] postgresql/auth: Fix that users cannot login when using PostgreSQL >= version 9.0 fixes #8251 --- .../Icinga/Authentication/Backend/DbUserBackend.php | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/library/Icinga/Authentication/Backend/DbUserBackend.php b/library/Icinga/Authentication/Backend/DbUserBackend.php index d2d0147e5..7865aa905 100644 --- a/library/Icinga/Authentication/Backend/DbUserBackend.php +++ b/library/Icinga/Authentication/Backend/DbUserBackend.php @@ -87,9 +87,16 @@ class DbUserBackend extends UserBackend */ protected function getPasswordHash($username) { - $stmt = $this->conn->getDbAdapter()->prepare( - 'SELECT password_hash FROM icingaweb_user WHERE name = :name AND active = 1' - ); + if ($this->conn->getDbType() === 'pgsql') { + // Since PostgreSQL version 9.0 the default value for bytea_output is 'hex' instead of 'escape' + $stmt = $this->conn->getDbAdapter()->prepare( + 'SELECT ENCODE(password_hash, \'escape\') FROM icingaweb_user WHERE name = :name AND active = 1' + ); + } else { + $stmt = $this->conn->getDbAdapter()->prepare( + 'SELECT password_hash FROM icingaweb_user WHERE name = :name AND active = 1' + ); + } $stmt->execute(array(':name' => $username)); $stmt->bindColumn(1, $lob, PDO::PARAM_LOB); $stmt->fetch(PDO::FETCH_BOUND); From b065a9defd9ec4dd61ac09596871b1ef1b035259 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Tue, 20 Jan 2015 10:07:27 +0100 Subject: [PATCH 0221/2920] puppet: Provision the PHP ImageMagick Module resolves #8108 --- .puppet/modules/php_imagick/manifests/init.pp | 29 +++++++++++++++++++ .../profiles/icingaweb2_dev/manifests/init.pp | 1 + 2 files changed, 30 insertions(+) create mode 100644 .puppet/modules/php_imagick/manifests/init.pp diff --git a/.puppet/modules/php_imagick/manifests/init.pp b/.puppet/modules/php_imagick/manifests/init.pp new file mode 100644 index 000000000..5ef0453af --- /dev/null +++ b/.puppet/modules/php_imagick/manifests/init.pp @@ -0,0 +1,29 @@ +# Class: php_imagick +# +# This class installs the ImageMagick PHP module. +# +# Parameters: +# +# Actions: +# +# Requires: +# +# php +# +# Sample Usage: +# +# include php_imagick +# +class php_imagick { + include php + + $php_imagick = $::operatingsystem ? { + /(Debian|Ubuntu)/ => 'php5-imagick', + /(RedHat|CentOS|Fedora)/ => 'php-pecl-imagick', + /(SLES|OpenSuSE)/ => 'php5-imagick', + } + + package { $php_imagick: + ensure => latest, + } +} diff --git a/.puppet/profiles/icingaweb2_dev/manifests/init.pp b/.puppet/profiles/icingaweb2_dev/manifests/init.pp index 157a9d80a..7c2ec6828 100644 --- a/.puppet/profiles/icingaweb2_dev/manifests/init.pp +++ b/.puppet/profiles/icingaweb2_dev/manifests/init.pp @@ -9,6 +9,7 @@ class icingaweb2_dev ( ) { include apache include php + include php_imagick include icingaweb2::config include icingacli include icinga_packages From 478a0a0d47741733a9b4aec39ab5b113f96fc5b6 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Tue, 20 Jan 2015 10:11:00 +0100 Subject: [PATCH 0222/2920] puppet: Provision the intl and gd PHP module fixes #8107 --- .puppet/profiles/icingaweb2_dev/manifests/init.pp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.puppet/profiles/icingaweb2_dev/manifests/init.pp b/.puppet/profiles/icingaweb2_dev/manifests/init.pp index 7c2ec6828..404c6395e 100644 --- a/.puppet/profiles/icingaweb2_dev/manifests/init.pp +++ b/.puppet/profiles/icingaweb2_dev/manifests/init.pp @@ -21,7 +21,7 @@ class icingaweb2_dev ( } # TODO(el): icinga-gui is not a icingaweb2_dev package - package { [ 'php-pdo', 'php-ldap', 'php-phpunit-PHPUnit', 'icinga-gui' ]: + package { [ 'php-gd', 'php-intl', php-pdo', 'php-ldap', 'php-phpunit-PHPUnit', 'icinga-gui' ]: ensure => latest, notify => Service['apache'], require => Class['icinga_packages'], From 3a3b1fbe51459ea6e2ebcef5e6ee5755bbf53089 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Tue, 20 Jan 2015 12:54:14 +0100 Subject: [PATCH 0223/2920] puppet: Fix typo introduced by last commit --- .puppet/profiles/icingaweb2_dev/manifests/init.pp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.puppet/profiles/icingaweb2_dev/manifests/init.pp b/.puppet/profiles/icingaweb2_dev/manifests/init.pp index 404c6395e..b8bea040f 100644 --- a/.puppet/profiles/icingaweb2_dev/manifests/init.pp +++ b/.puppet/profiles/icingaweb2_dev/manifests/init.pp @@ -21,7 +21,7 @@ class icingaweb2_dev ( } # TODO(el): icinga-gui is not a icingaweb2_dev package - package { [ 'php-gd', 'php-intl', php-pdo', 'php-ldap', 'php-phpunit-PHPUnit', 'icinga-gui' ]: + package { [ 'php-gd', 'php-intl', 'php-pdo', 'php-ldap', 'php-phpunit-PHPUnit', 'icinga-gui' ]: ensure => latest, notify => Service['apache'], require => Class['icinga_packages'], From b0e27c4fe69da42244de373357440d3f6785bdf3 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Tue, 20 Jan 2015 13:43:53 +0100 Subject: [PATCH 0224/2920] monitoring: Remove duplicate array key 'host_check_command' in the StatusQuery --- .../library/Monitoring/Backend/Ido/Query/StatusQuery.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/modules/monitoring/library/Monitoring/Backend/Ido/Query/StatusQuery.php b/modules/monitoring/library/Monitoring/Backend/Ido/Query/StatusQuery.php index 28b06dc80..8dc6fa11e 100644 --- a/modules/monitoring/library/Monitoring/Backend/Ido/Query/StatusQuery.php +++ b/modules/monitoring/library/Monitoring/Backend/Ido/Query/StatusQuery.php @@ -118,7 +118,6 @@ class StatusQuery extends IdoQuery 'host_modified_host_attributes' => 'hs.modified_host_attributes', 'host_event_handler' => 'hs.event_handler', - 'host_check_command' => 'hs.check_command', 'host_normal_check_interval' => 'hs.normal_check_interval', 'host_retry_check_interval' => 'hs.retry_check_interval', 'host_check_timeperiod_object_id' => 'hs.check_timeperiod_object_id', @@ -368,7 +367,7 @@ class StatusQuery extends IdoQuery case 'CASE WHEN ss.current_state = 0 THEN 0 ELSE 1 END': if ($sign !== '=') break; - + if ($expression) { return 'ss.current_state > 0'; } else { From e708054e286452cf6e93cac451fe159db465da83 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Tue, 20 Jan 2015 13:50:05 +0100 Subject: [PATCH 0225/2920] doc/README.md: Rename 'General Information' to 'About' --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 16eb1444a..d25969cf5 100644 --- a/README.md +++ b/README.md @@ -2,12 +2,12 @@ ## Table of Contents -0. [General Information](#general information) +0. [About](#about) 1. [Installation](#installation) 2. [Support](#support) 3. [Vagrant - Virtual development environment](#vagrant) -## General Information +## About `Icinga Web 2` is the next generation monitoring web interface, framework and CLI tool developed by the [Icinga Project](https://www.icinga.org/community/team/). From a74a4d6ecac0c493b2876af772e08f4869525924 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Tue, 20 Jan 2015 14:08:55 +0100 Subject: [PATCH 0226/2920] doc/README.md: Update about section --- README.md | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index d25969cf5..6ba47025c 100644 --- a/README.md +++ b/README.md @@ -9,19 +9,11 @@ ## About -`Icinga Web 2` is the next generation monitoring web interface, framework -and CLI tool developed by the [Icinga Project](https://www.icinga.org/community/team/). +**Icinga Web 2** is the next generation open source monitoring web interface, framework +and command-line interface developed by the [Icinga Project](https://www.icinga.org/), supporting Icinga 2, +Icinga Core and any other monitoring backend compatible with the Livestatus Protocol. -Responsive and fast, rewritten from scratch supporting multiple backends and -providing a CLI tool. Compatible with Icinga Core 2.x and 1.x. - -Check the Icinga website for some [insights](https://www.icinga.org/icinga/screenshots/icinga-web-2/). - -> **Note** -> -> `Icinga Web 2` is still in development and not meant for production deployment. -> Watch the [development roadmap](https://dev.icinga.org/projects/icingaweb2/roadmap) -> and [Icinga website](https://www.icinga.org/) for release schedule updates! +![Icinga Web 2](https://www.icinga.org/wp-content/uploads/2014/06/service_detail.png "Icinga Web 2") ## Installation From efd7e0a3fe31cb2396717549c740e8a33ab42900 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Tue, 20 Jan 2015 14:46:44 +0100 Subject: [PATCH 0227/2920] doc/README.md: Update support --- README.md | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 6ba47025c..6b822c5b1 100644 --- a/README.md +++ b/README.md @@ -17,19 +17,15 @@ Icinga Core and any other monitoring backend compatible with the Livestatus Prot ## Installation -Please navigate to [doc/installation.md](doc/installation.md) for updated details. +For installing Icinga Web 2 please read [doc/installation.md](doc/installation.md). ## Support -Please head over to the [community support channels](https://www.icinga.org/icinga/faq/get-help/) -in case of questions, bugs, etc. +If you come across problems at some time, the [community support channels](https://support.icinga.org/) +are good places to ask for advice from other users and give some in return. -Please make sure to provide the following details: - -* OS, distribution, version -* PHP and/or MySQL/PostgreSQL version -* Which browser and its version -* Screenshot and problem description +For status updates check the [Icinga website](https://www.icinga.org/) and the +[Icinga Web 2 development roadmap](https://dev.icinga.org/projects/icingaweb2/roadmap). ## Vagrant From a83aea44408faa69ec55348bd429f30a7369cfa5 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Tue, 20 Jan 2015 14:47:49 +0100 Subject: [PATCH 0228/2920] doc/README.md: Remove vagrant --- README.md | 229 ------------------------------------------------------ 1 file changed, 229 deletions(-) diff --git a/README.md b/README.md index 6b822c5b1..55e4e77ee 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,6 @@ 0. [About](#about) 1. [Installation](#installation) 2. [Support](#support) -3. [Vagrant - Virtual development environment](#vagrant) ## About @@ -26,231 +25,3 @@ are good places to ask for advice from other users and give some in return. For status updates check the [Icinga website](https://www.icinga.org/) and the [Icinga Web 2 development roadmap](https://dev.icinga.org/projects/icingaweb2/roadmap). - - -## Vagrant - -### Requirements - -* Vagrant 1.2+ -* Virtualbox 4.2.16+ -* a fairly powerful hardware (quad core, 4gb ram, fast hdd) - -> **Note** -> -> The deployment of the virtual machine is tested against Vagrant starting with version 1.2. -> Unfortunately older versions will not work. - -### General - -The Icinga Web 2 project ships with a Vagrant virtual machine that integrates -the source code with various services and example data in a controlled -environment. This enables developers and users to test Livestatus, status.dat, -MySQL and PostgreSQL backends as well as the LDAP authentication. All you -have to do is install Vagrant and run: - - vagrant up - -> **Note** -> -> The first boot of the vm takes a fairly long time because -> you'll download a plain CentOS base box and Vagrant will automatically -> provision the environment on the first go. - -After you should be able to browse [localhost:8080/icingaweb](http://localhost:8080/icingaweb). - -### Environment - -**Forwarded ports**: - - - - - - - - - - - - - - - - - -
    ProctocolLocal port (virtual machine host)Remote port (the virtual machine)
    SSH222222
    HTTP808080
    - -**Installed packages**: - -* Apache2 with PHP enabled -* PHP with MySQL and PostgreSQL libraries -* MySQL server and client software -* PostgreSQL server and client software -* [Icinga prerequisites](http://docs.icinga.org/latest/en/quickstart-idoutils.html#installpackages) -* OpenLDAP servers and clients - -**Installed users and groups**: - -* User icinga with group icinga and icinga-cmd -* Webserver user added to group icinga-cmd - -**Installed software**: - -* Icinga with IDOUtils using a MySQL database -* Icinga with IDOUtils using a PostgreSQL database -* Icinga 2 - -**Installed files**: - -* `/usr/share/icinga/htpasswd.users` account information for logging into the Icinga classic web interface for both icinga instances -* `/usr/lib64/nagios/plugins` Monitoring Plugins for all Icinga instances - -#### Icinga with IDOUtils using a MySQL database - -**Installation path**: `/usr/local/icinga-mysql` - -**Services**: - -* `icinga-mysql` -* `ido2db-mysql` - -Connect to the **icinga mysql database** using the following command: - - mysql -u icinga -p icinga icinga - -Access the **Classic UI** (CGIs) via [localhost:8080/icinga-mysql](http://localhost:8080/icinga-mysql). -For **logging into** the Icinga classic web interface use user *icingaadmin* with password *icinga*. - -#### Icinga with IDOUtils using a PostgreSQL database - -**Installation path**: `/usr/local/icinga-pgsql` - -**Services**: - -* `icinga-pgsql` -* `ido2db-pgsql` - -Connect to the **icinga mysql database** using the following command: - - sudo -u postgres psql -U icinga -d icinga - -Access the **Classic UI** (CGIs) via [localhost:8080/icinga-pgsql](http://localhost:8080/icinga-pgsql). -For **logging into** the Icinga classic web interface use user *icingaadmin* with password *icinga*. - -#### Monitoring Test Config - -Test config is added to both the MySQL and PostgreSQL Icinga instance utilizing the Perl module -**Monitoring::Generator::TestConfig** to generate test config to **/usr/local/share/misc/monitoring_test_config** -which is then copied to **/etc/conf.d/test_config/**. -Configuration can be adjusted and recreated with **/usr/local/share/misc/monitoring_test_config/recreate.pl**. -**Note** that you have to run - - vagrant provision - -in the host after any modification to the script just mentioned. - -#### MK Livestatus - -MK Livestatus is added to the Icinga installation using a MySQL database. - -**Installation path**: - -* `/usr/local/icinga-mysql/bin/unixcat` -* `/usr/local/icinga-mysql/lib/mk-livestatus/livecheck` -* `/usr/local/icinga-mysql/lib/mk-livestatus/livestatus.o` -* `/usr/local/icinga-mysql/etc/modules/mk-livestatus.cfg` -* `/usr/local/icinga-mysql/var/rw/live` - -**Example usage**: - - echo "GET hosts" | /usr/local/icinga-mysql/bin/unixcat /usr/local/icinga-mysql/var/rw/live - -#### LDAP example data - -The environment includes a openldap server with example data. *Domain* suffix is **dc=icinga,dc=org**. -Administrator (*rootDN*) of the slapd configuration database is **cn=admin,cn=config** and the -administrator (*rootDN*) of our database instance is **cn=admin,dc=icinga,dc=org**. Both share -the *password* `admin`. - -Examples to query the slapd configuration database: - - ldapsearch -x -W -LLL -D cn=admin,cn=config -b cn=config dn - ldapsearch -Y EXTERNAL -H ldapi:/// -LLL -b cn=config dn - -Examples to query our database instance: - - ldapsearch -x -W -LLL -D cn=admin,dc=icinga,dc=org -b dc=icinga,dc=org dn - ldapsearch -Y EXTERNAL -H ldapi:/// -LLL -b dc=icinga,dc=org dn - -This is what the **dc=icinga,dc=org** *DIT* looks like: - -> dn: dc=icinga,dc=org -> -> dn: ou=people,dc=icinga,dc=org -> -> dn: ou=groups,dc=icinga,dc=org -> -> dn: cn=Users,ou=groups,dc=icinga,dc=org -> cn: Users -> uniqueMember: cn=Jon Doe,ou=people,dc=icinga,dc=org -> uniqueMember: cn=Jane Smith,ou=people,dc=icinga,dc=org -> uniqueMember: cn=John Q. Public,ou=people,dc=icinga,dc=org -> uniqueMember: cn=Richard Roe,ou=people,dc=icinga,dc=org -> -> dn: cn=John Doe,ou=people,dc=icinga,dc=org -> cn: John Doe -> uid: jdoe -> -> dn: cn=Jane Smith,ou=people,dc=icinga,dc=org -> cn: Jane Smith -> uid: jsmith -> -> dn: cn=John Q. Public,ou=people,dc=icinga,dc=org -> cn: John Q. Public -> uid: jqpublic -> -> dn: cn=Richard Roe,ou=people,dc=icinga,dc=org -> cn: Richard Roe -> uid: rroe - -All users share the password `password`. - -#### Testing the code - -All software required to run tests is installed in the virtual machine. -In order to run all tests you have to execute the following commands: - - vagrant ssh -c /vagrant/test/php/runtests - vagrant ssh -c /vagrant/test/php/checkswag - vagrant ssh -c /vagrant/test/js/runtests - vagrant ssh -c /vagrant/test/js/checkswag - vagrant ssh -c /vagrant/test/frontend/runtests - -`runtests` will execute unit and regression tests and `checkswag` will report -code style issues. - -#### Icinga 2 - -Installed from the Icinga [snapshot package repository](http://packages.icinga.org/epel/). -The configuration is located in `/etc/icinga2`. - -**Example usage**: - - /etc/init.d/icinga2 (start|stop|restart|reload) - - -## Log into Icinga Web 2 - -If you've configure LDAP as authentication backend (which is the default) use the following login credentials: - -> **Username**: jdoe -> **Password**: password - -Have a look at [LDAP example data](#ldap example data) for more accounts. - -Using MySQL as backend: - -> **Username**: icingaadmin -> **Password**: icinga - From 925bc80115282449e21c0fb9225bd8db145878a9 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Tue, 20 Jan 2015 15:12:43 +0100 Subject: [PATCH 0229/2920] puppet: Add vagrant to the icingaweb2 group --- .puppet/manifests/site.pp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.puppet/manifests/site.pp b/.puppet/manifests/site.pp index 08120d911..043f24dbb 100644 --- a/.puppet/manifests/site.pp +++ b/.puppet/manifests/site.pp @@ -13,5 +13,5 @@ node default { source => 'puppet:////vagrant/.puppet/files/etc/profile.d/env.sh' } @user { vagrant: ensure => present } - User <| title == vagrant |> { groups +> icingaweb } + User <| title == vagrant |> { groups +> hiera('icingaweb2::group') } } From e98b6f15605a78c57c9829337b8767ef3584237c Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Tue, 20 Jan 2015 15:13:07 +0100 Subject: [PATCH 0230/2920] puppet: Do not enable the Icinga 2 feature ido-pgsql Because Icinga 2 does not handle more than one IDO connection properly, the ido-pgsql will not be enabled by default. --- .puppet/modules/icinga2_pgsql/manifests/init.pp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/.puppet/modules/icinga2_pgsql/manifests/init.pp b/.puppet/modules/icinga2_pgsql/manifests/init.pp index 2326449af..95bc71034 100644 --- a/.puppet/modules/icinga2_pgsql/manifests/init.pp +++ b/.puppet/modules/icinga2_pgsql/manifests/init.pp @@ -11,7 +11,8 @@ class icinga2_pgsql { password => 'icinga2', schemafile => '/usr/share/icinga2-ido-pgsql/schema/pgsql.sql', } - -> icinga2::feature { 'ido-pgsql': - source => 'puppet:///modules/icinga2_pgsql', - } +# Because Icinga 2 does not handle more than one IDO connection properly, The ido-pgsql will not be enabled by default. +# -> icinga2::feature { 'ido-pgsql': +# source => 'puppet:///modules/icinga2_pgsql', +# } } From 9cecc4d6908ffe66c78e2365991485d46c94532c Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Tue, 20 Jan 2015 15:13:33 +0100 Subject: [PATCH 0231/2920] doc: Add vagrant.md --- doc/vagrant.md | 52 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 doc/vagrant.md diff --git a/doc/vagrant.md b/doc/vagrant.md new file mode 100644 index 000000000..6bcc2def9 --- /dev/null +++ b/doc/vagrant.md @@ -0,0 +1,52 @@ +# Vagrant + +## Requirements + +* Vagrant >= version 1.4 +* VirtualBox or Parallels + +> **Note:** The deployment of the virtual machine is tested against Vagrant starting with version 1.4. +> Unfortunately older versions will not work. + +## General + +The Icinga Web 2 project ships with a Vagrant virtual machine that integrates +the source code with various services and example data in a controlled +environment. This enables developers and users to test Livestatus, +MySQL and PostgreSQL backends as well as the LDAP authentication. All you +have to do is install Vagrant and run: + +```` +vagrant up +```` + +> **Note:** The first boot of the vm takes a fairly long time because +> you'll download a plain CentOS base box and Vagrant will automatically +> provision the environment on the first go. + +After you should be able to browse [localhost:8080/icingaweb2](http://localhost:8080/icingaweb2). + +## Log into Icinga Web 2 + +Both LDAP and a MySQL are configured as authentication backend. Please use one of the following login credentials: + +> LDAP: +>> **Username**: `jdoe` + +>> **Password**: `password` + +>MySQL: +>> **Username**: `icingaadmin` + +>> **Password**: `icinga` + + + +## Testing the Source Code + +All software required to run tests is installed in the virtual machine. +In order to run all tests you have to execute the following command: + +```` +vagrant ssh -c "icingacli test php unit" +```` From 2288e2a687bc2a1c62cf798e1f712333cd85cc54 Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Tue, 20 Jan 2015 15:54:14 +0100 Subject: [PATCH 0232/2920] Add support for nested wizards The amount of vertical dimensions is not limited as well as the location a nested wizard can occur in the main wizard's order. In case a custom implementation is used as nested wizard, all core functionalities are still being utilized. refs #8191 --- library/Icinga/Web/Wizard.php | 125 ++++++++++++++++++++++++++++++++-- 1 file changed, 119 insertions(+), 6 deletions(-) diff --git a/library/Icinga/Web/Wizard.php b/library/Icinga/Web/Wizard.php index 2cc4abe5a..811374259 100644 --- a/library/Icinga/Web/Wizard.php +++ b/library/Icinga/Web/Wizard.php @@ -39,6 +39,13 @@ class Wizard */ const BTN_PREV = 'btn_prev'; + /** + * This wizard's parent + * + * @var Wizard + */ + protected $parent; + /** * The name of the wizard's current page * @@ -71,19 +78,55 @@ class Wizard } + /** + * Return this wizard's parent or null in case it has none + * + * @return Wizard|null + */ + public function getParent() + { + return $this->parent; + } + + /** + * Set this wizard's parent + * + * @param Wizard $wizard The parent wizard + * + * @return self + */ + public function setParent(Wizard $wizard) + { + $this->parent = $wizard; + return $this; + } + /** * Return the pages being part of this wizard * + * In case this is a nested wizard a flattened array of all contained pages is returned. + * * @return array */ public function getPages() { - return $this->pages; + $pages = array(); + foreach ($this->pages as $page) { + if ($page instanceof self) { + $pages = array_merge($pages, $page->getPages()); + } else { + $pages[] = $page; + } + } + + return $pages; } /** * Return the page with the given name * + * Note that it's also possible to retrieve a nested wizard's page by using this method. + * * @param string $name The name of the page to return * * @return null|Form The page or null in case there is no page with the given name @@ -98,22 +141,31 @@ class Wizard } /** - * Add a new page to this wizard + * Add a new page or wizard to this wizard * - * @param Form $page The page to add to the wizard + * @param Form|Wizard $page The page or wizard to add to the wizard * * @return self */ - public function addPage(Form $page) + public function addPage($page) { + if (! $page instanceof Form && ! $page instanceof self) { + throw InvalidArgumentException( + 'The $page argument must be an instance of Icinga\Web\Form ' + . 'or Icinga\Web\Wizard but is of type: ' . get_class($page) + ); + } elseif ($page instanceof self) { + $page->setParent($this); + } + $this->pages[] = $page; return $this; } /** - * Add multiple pages to this wizard + * Add multiple pages or wizards to this wizard * - * @param array $pages The pages to add to the wizard + * @param array $pages The pages or wizards to add to the wizard * * @return self */ @@ -148,6 +200,10 @@ class Wizard */ public function getCurrentPage() { + if ($this->parent) { + return $this->parent->getCurrentPage(); + } + if ($this->currentPage === null) { $this->assertHasPages(); $pages = $this->getPages(); @@ -202,6 +258,10 @@ class Wizard { $page = $this->getCurrentPage(); + if (($wizard = $this->findWizard($page)) !== null) { + return $wizard->handleRequest($request); + } + if ($request === null) { $request = $page->getRequest(); } @@ -238,6 +298,39 @@ class Wizard return $request; } + /** + * Return the wizard for the given page or null if its not part of a wizard + * + * @param Form $page The page to return its wizard for + * + * @return Wizard|null + */ + protected function findWizard(Form $page) + { + foreach ($this->getWizards() as $wizard) { + if ($wizard->getPage($page->getName()) === $page) { + return $wizard; + } + } + } + + /** + * Return this wizard's child wizards + * + * @return array + */ + protected function getWizards() + { + $wizards = array(); + foreach ($this->pages as $pageOrWizard) { + if ($pageOrWizard instanceof self) { + $wizards[] = $pageOrWizard; + } + } + + return $wizards; + } + /** * Return the request data based on given form's request method * @@ -264,6 +357,10 @@ class Wizard */ protected function getRequestedPage(array $requestData) { + if ($this->parent) { + return $this->parent->getRequestedPage($requestData); + } + if (isset($requestData[static::BTN_NEXT])) { return $requestData[static::BTN_NEXT]; } elseif (isset($requestData[static::BTN_PREV])) { @@ -280,6 +377,10 @@ class Wizard */ protected function getDirection(Request $request = null) { + if ($this->parent) { + return $this->parent->getDirection($request); + } + $currentPage = $this->getCurrentPage(); if ($request === null) { @@ -312,6 +413,10 @@ class Wizard */ protected function getNewPage($requestedPage, Form $originPage) { + if ($this->parent) { + return $this->parent->getNewPage($requestedPage, $originPage); + } + if (($page = $this->getPage($requestedPage)) !== null) { $permitted = true; @@ -344,6 +449,10 @@ class Wizard */ protected function isLastPage(Form $page) { + if ($this->parent) { + return $this->parent->isLastPage($page); + } + $pages = $this->getPages(); return $page->getName() === end($pages)->getName(); } @@ -421,6 +530,10 @@ class Wizard */ public function getSession() { + if ($this->parent) { + return $this->parent->getSession(); + } + return Session::getSession()->getNamespace(get_class($this)); } From 0300a90d145a3e2254c5d3151292f1ba4215c2ec Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Tue, 20 Jan 2015 16:08:47 +0100 Subject: [PATCH 0233/2920] monitoring: Remove duplicate array key 'host_state' in the ListController --- modules/monitoring/application/controllers/ListController.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/modules/monitoring/application/controllers/ListController.php b/modules/monitoring/application/controllers/ListController.php index 35dcd811f..aa00673b1 100644 --- a/modules/monitoring/application/controllers/ListController.php +++ b/modules/monitoring/application/controllers/ListController.php @@ -143,8 +143,7 @@ class Monitoring_ListController extends Controller 'host_severity' => $this->translate('Severity'), 'host_name' => $this->translate('Hostname'), 'host_address' => $this->translate('Address'), - 'host_state' => $this->translate('Current State'), - 'host_state' => $this->translate('Hard State') + 'host_state' => $this->translate('Current State') )); $this->view->hosts = $query->paginate(); From 680b7e4ebab19781e3a8840fbd0d728c68944436 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Tue, 20 Jan 2015 16:11:41 +0100 Subject: [PATCH 0234/2920] monitoring: Prever 'Hostname' over 'Host name' in PHPDoc --- modules/monitoring/library/Monitoring/Object/Host.php | 8 ++++---- modules/monitoring/library/Monitoring/Object/Service.php | 6 +++--- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/modules/monitoring/library/Monitoring/Object/Host.php b/modules/monitoring/library/Monitoring/Object/Host.php index fd08f6a20..79a760d82 100644 --- a/modules/monitoring/library/Monitoring/Object/Host.php +++ b/modules/monitoring/library/Monitoring/Object/Host.php @@ -47,7 +47,7 @@ class Host extends MonitoredObject public $prefix = 'host_'; /** - * Host name + * Hostname * * @var string */ @@ -63,8 +63,8 @@ class Host extends MonitoredObject /** * Create a new host * - * @param MonitoringBackend $backend Backend to fetch host information from - * @param string $host Host name + * @param MonitoringBackend $backend Backend to fetch host information from + * @param string $host Hostname */ public function __construct(MonitoringBackend $backend, $host) { @@ -73,7 +73,7 @@ class Host extends MonitoredObject } /** - * Get the host name + * Get the hostname * * @return string */ diff --git a/modules/monitoring/library/Monitoring/Object/Service.php b/modules/monitoring/library/Monitoring/Object/Service.php index 6d5245f0d..64bfe530b 100644 --- a/modules/monitoring/library/Monitoring/Object/Service.php +++ b/modules/monitoring/library/Monitoring/Object/Service.php @@ -68,9 +68,9 @@ class Service extends MonitoredObject /** * Create a new service * - * @param MonitoringBackend $backend Backend to fetch service information from - * @param string $host Host name the service is running on - * @param string $service Service name + * @param MonitoringBackend $backend Backend to fetch service information from + * @param string $host Hostname the service is running on + * @param string $service Service name */ public function __construct(MonitoringBackend $backend, $host, $service) { From ab0910e09b5276172df8f743e33026715f0971fb Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Tue, 20 Jan 2015 16:12:10 +0100 Subject: [PATCH 0235/2920] monitoring: Prefer 'Hostname' over 'Host name' --- modules/monitoring/application/controllers/ListController.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/monitoring/application/controllers/ListController.php b/modules/monitoring/application/controllers/ListController.php index aa00673b1..a83a01e32 100644 --- a/modules/monitoring/application/controllers/ListController.php +++ b/modules/monitoring/application/controllers/ListController.php @@ -234,7 +234,7 @@ class Monitoring_ListController extends Controller 'service_state_type' => $this->translate('Hard State'), 'host_severity' => $this->translate('Host Severity'), 'host_state' => $this->translate('Current Host State'), - 'host_name' => $this->translate('Host Name'), + 'host_name' => $this->translate('Hostname'), 'host_address' => $this->translate('Host Address'), 'host_last_check' => $this->translate('Last Host Check') )); From f5acd0c7b50a14e9f5471f8d3b457e9d749e426a Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Tue, 20 Jan 2015 16:12:48 +0100 Subject: [PATCH 0236/2920] monitoring: Remove unused use ... in the ListController --- .../monitoring/application/controllers/ListController.php | 6 ------ 1 file changed, 6 deletions(-) diff --git a/modules/monitoring/application/controllers/ListController.php b/modules/monitoring/application/controllers/ListController.php index a83a01e32..a24982d93 100644 --- a/modules/monitoring/application/controllers/ListController.php +++ b/modules/monitoring/application/controllers/ListController.php @@ -1,6 +1,4 @@ Date: Tue, 20 Jan 2015 16:14:56 +0100 Subject: [PATCH 0237/2920] monitoring: Fix unused local variable 'stateType' in the ListController --- .../monitoring/application/controllers/ListController.php | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/modules/monitoring/application/controllers/ListController.php b/modules/monitoring/application/controllers/ListController.php index a24982d93..0b4066e7b 100644 --- a/modules/monitoring/application/controllers/ListController.php +++ b/modules/monitoring/application/controllers/ListController.php @@ -91,12 +91,10 @@ class Monitoring_ListController extends Controller } // Handle soft and hard states - $stateType = $this->params->shift('stateType', 'soft'); - if ($stateType == 'hard') { + if (strtolower($this->params->shift('stateType', 'soft')) === 'hard') { $stateColumn = 'host_hard_state'; $stateChangeColumn = 'host_last_hard_state_change'; } else { - $stateType = 'soft'; $stateColumn = 'host_state'; $stateChangeColumn = 'host_last_state_change'; } @@ -164,14 +162,12 @@ class Monitoring_ListController extends Controller } // Handle soft and hard states - $stateType = $this->params->shift('stateType', 'soft'); - if ($stateType == 'hard') { + if (strtolower($this->params->shift('stateType', 'soft')) === 'hard') { $stateColumn = 'service_hard_state'; $stateChangeColumn = 'service_last_hard_state_change'; } else { $stateColumn = 'service_state'; $stateChangeColumn = 'service_last_state_change'; - $stateType = 'soft'; } $this->addTitleTab('services', $this->translate('Services')); From ab7a5763a67512d895e8f93cd381fdede7a96952 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Tue, 20 Jan 2015 16:21:56 +0100 Subject: [PATCH 0238/2920] monitoring: Sort by host_display_name instead of name1 by default refs #7843 --- modules/monitoring/library/Monitoring/DataView/HostStatus.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/modules/monitoring/library/Monitoring/DataView/HostStatus.php b/modules/monitoring/library/Monitoring/DataView/HostStatus.php index e9b5b60dd..86bff52bf 100644 --- a/modules/monitoring/library/Monitoring/DataView/HostStatus.php +++ b/modules/monitoring/library/Monitoring/DataView/HostStatus.php @@ -24,6 +24,7 @@ class HostStatus extends DataView return array( 'host', 'host_name', + 'host_display_name', 'host_alias', 'host_address', 'host_state', @@ -90,7 +91,7 @@ class HostStatus extends DataView public function getSortRules() { return array( - 'host_name' => array( + 'host_display_name' => array( 'order' => self::SORT_ASC ), 'host_address' => array( From 9fd90c90cc84742c6f0e7871c0e24dace35a3c4f Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Tue, 20 Jan 2015 16:22:36 +0100 Subject: [PATCH 0239/2920] monitoring: Sort by host_display_name when sorting by 'Hostname' in the hosts overview refs #7843 --- modules/monitoring/application/controllers/ListController.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/monitoring/application/controllers/ListController.php b/modules/monitoring/application/controllers/ListController.php index 0b4066e7b..d680faaf8 100644 --- a/modules/monitoring/application/controllers/ListController.php +++ b/modules/monitoring/application/controllers/ListController.php @@ -133,7 +133,7 @@ class Monitoring_ListController extends Controller $this->setupSortControl(array( 'host_last_check' => $this->translate('Last Check'), 'host_severity' => $this->translate('Severity'), - 'host_name' => $this->translate('Hostname'), + 'host_display_name' => $this->translate('Hostname'), 'host_address' => $this->translate('Address'), 'host_state' => $this->translate('Current State') )); From f1ada110f8bdeac6756d2c3dac7a283db7d5366d Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Tue, 20 Jan 2015 16:23:12 +0100 Subject: [PATCH 0240/2920] monitoring: Select the host_display_name in the hosts overview refs #7843 --- modules/monitoring/application/controllers/ListController.php | 1 + 1 file changed, 1 insertion(+) diff --git a/modules/monitoring/application/controllers/ListController.php b/modules/monitoring/application/controllers/ListController.php index d680faaf8..46bb6245e 100644 --- a/modules/monitoring/application/controllers/ListController.php +++ b/modules/monitoring/application/controllers/ListController.php @@ -104,6 +104,7 @@ class Monitoring_ListController extends Controller $query = $this->backend->select()->from('hostStatus', array_merge(array( 'host_icon_image', 'host_name', + 'host_display_name', 'host_state' => $stateColumn, 'host_address', 'host_acknowledged', From fe3bbb712d32f4d30c575f6ec7228e707cbf400c Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Tue, 20 Jan 2015 16:25:35 +0100 Subject: [PATCH 0241/2920] monitoring: Use host_display_name for displaying the host name in the hosts overview refs #7843 --- modules/monitoring/application/views/scripts/list/hosts.phtml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/monitoring/application/views/scripts/list/hosts.phtml b/modules/monitoring/application/views/scripts/list/hosts.phtml index 920a77e01..91f59f422 100644 --- a/modules/monitoring/application/views/scripts/list/hosts.phtml +++ b/modules/monitoring/application/views/scripts/list/hosts.phtml @@ -98,7 +98,7 @@ if ($hosts->count() === 0) { icon($this->resolveMacros($host->host_icon_image, $host)) ?> - host_name ?> + host_display_name ?> host_unhandled_services) && $host->host_unhandled_services > 0): ?> getPages(); $finished = isset($success); -$configPages = array_slice($pages, 2, count($pages) - 4, true); +$configPages = array_slice($pages, 3, count($pages) - 1, true); $currentPos = array_search($wizard->getCurrentPage(), $pages, true); list($configPagesLeft, $configPagesRight) = array_chunk($configPages, count($configPages) / 2, true); @@ -41,19 +41,32 @@ if ($notifications->hasMessages()) {
    -

    +

    translate('Modules', 'setup.progress'); ?>

    1 ? ' complete' : ( $maxProgress > 1 ? ' visited' : ( $currentPos === 1 ? ' active' : '' ) ); ?> + + + + +
    +
    +
    +

    + 2 ? ' complete' : ( + $maxProgress > 2 ? ' visited' : ( + $currentPos === 2 ? ' active' : '' + ) + ); ?>
    -
    +

    @@ -64,7 +77,7 @@ if ($notifications->hasMessages()) { ?> $page): ?> 1 ? ' active' : '') + $pos < $maxProgress ? ' visited' : ($currentPos > 2 ? ' active' : '') ); ?>
    @@ -78,7 +91,7 @@ if ($notifications->hasMessages()) {
    @@ -91,7 +104,7 @@ if ($notifications->hasMessages()) { ?> $page): ?> 1 ? ' active' : '') + $pos < $maxProgress ? ' visited' : ($currentPos > 2 ? ' active' : '') ); ?>
    @@ -104,26 +117,6 @@ if ($notifications->hasMessages()) {
    -
    -

    - count($pages) - 2 ? ' complete' : ( - $maxProgress > count($pages) - 2 ? ' visited' : ($currentPos === count($pages) - 2 ? ' active' : '') - ); ?> - - - - -
    -
    -
    -

    - - - - - -
    -

    From 99699a14ad1f47b1b971e2e210456142dd043a66 Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Tue, 20 Jan 2015 17:39:47 +0100 Subject: [PATCH 0244/2920] Replace all mt() calls with translate() in the setup module's view scripts --- .../views/scripts/form/setup-modules.phtml | 10 +++++----- .../scripts/form/setup-requirements.phtml | 2 +- .../views/scripts/form/setup-summary.phtml | 3 +-- .../views/scripts/form/setup-welcome.phtml | 19 ++++++++----------- .../views/scripts/index/index.phtml | 8 ++++---- .../views/scripts/index/parts/finish.phtml | 8 ++++---- 6 files changed, 23 insertions(+), 27 deletions(-) diff --git a/modules/setup/application/views/scripts/form/setup-modules.phtml b/modules/setup/application/views/scripts/form/setup-modules.phtml index a352803d7..304aad9b8 100644 --- a/modules/setup/application/views/scripts/form/setup-modules.phtml +++ b/modules/setup/application/views/scripts/form/setup-modules.phtml @@ -4,8 +4,8 @@ use Icinga\Web\Wizard; ?>
    -

    -

    +

    translate('The following modules can be set up by using a web-based wizard as well. To setup a module, just complete its wizard and advance to the summary!'); ?>

    +

    translate('You can freely switch to a module\'s wizard by clicking its name below. The wizard you are currently looking at is written in bold. A small tick is shown on the right once a wizard has been completed.'); ?>

    getElement($form->getTokenElementName()); ?> getElement($form->getUidElementName()); ?> @@ -19,7 +19,7 @@ use Icinga\Web\Wizard; ' : '' ?>getTitle(); ?>' : '' ?> getSetupWizard()->isFinished()): ?> - icon('ok', mt('setup', 'Completed', 'setup.modules.wizard.state')); ?> + icon('ok', $this->translate('Completed', 'setup.modules.wizard.state')); ?> @@ -29,9 +29,9 @@ use Icinga\Web\Wizard;
    -

    +

    translate('You\'ve completed all module wizards!'); ?>

    -

    +

    translate('Note that you can skip a specific module by just not completing its wizard.'); ?>

    diff --git a/modules/setup/application/views/scripts/form/setup-requirements.phtml b/modules/setup/application/views/scripts/form/setup-requirements.phtml index ca2556b95..09d337a02 100644 --- a/modules/setup/application/views/scripts/form/setup-requirements.phtml +++ b/modules/setup/application/views/scripts/form/setup-requirements.phtml @@ -22,7 +22,7 @@ $requirements = $form->getRequirements(); diff --git a/modules/setup/application/views/scripts/form/setup-summary.phtml b/modules/setup/application/views/scripts/form/setup-summary.phtml index 714416833..fa354feb5 100644 --- a/modules/setup/application/views/scripts/form/setup-summary.phtml +++ b/modules/setup/application/views/scripts/form/setup-summary.phtml @@ -4,8 +4,7 @@ use Icinga\Web\Wizard; ?>

    translate( 'The wizard is now complete. You can review the changes supposed to be made before setting up %1$s.' . ' Make sure that everything is correct (Feel free to navigate back to make any corrections!) so' . ' that you can start using %1$s right after it has successfully been set up.' diff --git a/modules/setup/application/views/scripts/form/setup-welcome.phtml b/modules/setup/application/views/scripts/form/setup-welcome.phtml index 8d3ba67c5..aa51ffba6 100644 --- a/modules/setup/application/views/scripts/form/setup-welcome.phtml +++ b/modules/setup/application/views/scripts/form/setup-welcome.phtml @@ -11,16 +11,14 @@ $cliPath = realpath(Icinga::app()->getApplicationDir() . '/../bin/icingacli'); ?>

    -

    +

    translate('Welcome to the configuration of Icinga Web 2!') ?>

    -

    translate( 'You\'ve already completed the configuration of Icinga Web 2. Note that most of your configuration' . ' files will be overwritten in case you\'ll re-configure Icinga Web 2 using this wizard!' ); ?>

    -

    translate( 'This wizard will guide you through the configuration of Icinga Web 2. Once completed and successfully' . ' finished you are able to log in and to explore all the new and stunning features!' ); ?>

    @@ -39,23 +37,22 @@ $cliPath = realpath(Icinga::app()->getApplicationDir() . '/../bin/icingacli');

    translate( 'To run this wizard a user needs to authenticate using a token which is usually' . ' provided to him by an administrator who\'d followed the instructions below.' ); ?>

    -

    +

    translate('If you\'ve got the IcingaCLI installed you can do the following:'); ?>

    setup config directory --group ; setup token create;
    -

    +

    translate('In case the IcingaCLI is missing you can create the token manually:'); ?>

    su -c "mkdir -m 2770 ; head -c 12 /dev/urandom | base64 | tee ; chmod 0660 ;";

    ' . mt('setup', 'Icinga Web 2 documentation') . '' // TODO: Add link to iw2 docs which points to the installation topic + $this->translate('Please see the %s for an extensive description on how to access and use this wizard.'), + '' . $this->translate('Icinga Web 2 documentation') . '' // TODO: Add link to iw2 docs which points to the installation topic ); ?>

    diff --git a/modules/setup/application/views/scripts/index/index.phtml b/modules/setup/application/views/scripts/index/index.phtml index 1c614a0a6..d12343d5b 100644 --- a/modules/setup/application/views/scripts/index/index.phtml +++ b/modules/setup/application/views/scripts/index/index.phtml @@ -30,7 +30,7 @@ if ($notifications->hasMessages()) { img('img/logo_icinga_big.png'); ?>
    -

    +

    translate('Welcome', 'setup.progress'); ?>

    0 ? 'complete' : ( $maxProgress > 0 ? 'visited' : 'active' ); ?> @@ -54,7 +54,7 @@ if ($notifications->hasMessages()) {
    -

    +

    translate('Requirements', 'setup.progress'); ?>

    2 ? ' complete' : ( $maxProgress > 2 ? ' visited' : ( $currentPos === 2 ? ' active' : '' @@ -67,7 +67,7 @@ if ($notifications->hasMessages()) {
    -

    +

    translate('Configuration', 'setup.progress'); ?>

    hasMessages()) {
    -

    +

    translate('Finish', 'setup.progress'); ?>

    diff --git a/modules/setup/application/views/scripts/index/parts/finish.phtml b/modules/setup/application/views/scripts/index/parts/finish.phtml index 94217017d..e695d72ce 100644 --- a/modules/setup/application/views/scripts/index/parts/finish.phtml +++ b/modules/setup/application/views/scripts/index/parts/finish.phtml @@ -11,16 +11,16 @@ -

    +

    translate('Congratulations! Icinga Web 2 has been successfully set up.'); ?>

    -

    +

    translate('Sorry! Failed to set up Icinga Web 2 successfully.'); ?>

    \ No newline at end of file From 9e8c897d6faec2860e3cbc8fe9866f3ed7d1ac22 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Wed, 21 Jan 2015 09:13:10 +0100 Subject: [PATCH 0245/2920] monitoring: Order a data view before dumping --- modules/monitoring/library/Monitoring/DataView/DataView.php | 1 + 1 file changed, 1 insertion(+) diff --git a/modules/monitoring/library/Monitoring/DataView/DataView.php b/modules/monitoring/library/Monitoring/DataView/DataView.php index 1fdd8b4f9..5900df737 100644 --- a/modules/monitoring/library/Monitoring/DataView/DataView.php +++ b/modules/monitoring/library/Monitoring/DataView/DataView.php @@ -83,6 +83,7 @@ abstract class DataView implements Browsable, Countable, Filterable, Sortable public function dump() { + $this->order(); return $this->query->dump(); } From e602717bd96bfce12f65cf8d0ebe23469033eb50 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Wed, 21 Jan 2015 09:15:07 +0100 Subject: [PATCH 0246/2920] monitoring: Sort by display_names instead of name1 and name2 by default in the services overview refs #7843 --- .../library/Monitoring/DataView/ServiceStatus.php | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/modules/monitoring/library/Monitoring/DataView/ServiceStatus.php b/modules/monitoring/library/Monitoring/DataView/ServiceStatus.php index 9edcabc87..9ecc8e309 100644 --- a/modules/monitoring/library/Monitoring/DataView/ServiceStatus.php +++ b/modules/monitoring/library/Monitoring/DataView/ServiceStatus.php @@ -25,6 +25,7 @@ class ServiceStatus extends DataView { return array( 'host_name', + 'host_display_name', 'host_state', 'host_state_type', 'host_last_state_change', @@ -123,17 +124,17 @@ class ServiceStatus extends DataView public function getSortRules() { return array( - 'host_name' => array( + 'host_display_name' => array( 'columns' => array( - 'service_host_name', - 'service_description' + 'host_display_name', + 'service_display_name' ), 'order' => self::SORT_ASC ), 'host_address' => array( 'columns' => array( 'host_ipv4', - 'service_description' + 'service_display_name' ), 'order' => self::SORT_ASC ), From 9d5dccc484660d81bab277be4ea07af59293d264 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Wed, 21 Jan 2015 09:22:44 +0100 Subject: [PATCH 0247/2920] monitoring: Sort by display_name when sorting by 'Hostname' or 'Service Name' in the services overview refs #7843 --- modules/monitoring/application/controllers/ListController.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/monitoring/application/controllers/ListController.php b/modules/monitoring/application/controllers/ListController.php index 46bb6245e..136b9f9a4 100644 --- a/modules/monitoring/application/controllers/ListController.php +++ b/modules/monitoring/application/controllers/ListController.php @@ -221,11 +221,11 @@ class Monitoring_ListController extends Controller 'service_last_check' => $this->translate('Last Service Check'), 'service_severity' => $this->translate('Severity'), 'service_state' => $this->translate('Current Service State'), - 'service_description' => $this->translate('Service Name'), + 'service_display_name' => $this->translate('Service Name'), 'service_state_type' => $this->translate('Hard State'), 'host_severity' => $this->translate('Host Severity'), 'host_state' => $this->translate('Current Host State'), - 'host_name' => $this->translate('Hostname'), + 'host_display_name' => $this->translate('Hostname'), 'host_address' => $this->translate('Host Address'), 'host_last_check' => $this->translate('Last Host Check') )); From a6ad5ad865ded93eeb457b9bc2d847bfd7ae276c Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Wed, 21 Jan 2015 09:30:33 +0100 Subject: [PATCH 0248/2920] monitoring: Reorder sort column combo box in the hosts overview --- modules/monitoring/application/controllers/ListController.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/monitoring/application/controllers/ListController.php b/modules/monitoring/application/controllers/ListController.php index 136b9f9a4..80375a33d 100644 --- a/modules/monitoring/application/controllers/ListController.php +++ b/modules/monitoring/application/controllers/ListController.php @@ -132,11 +132,11 @@ class Monitoring_ListController extends Controller $this->filterQuery($query); $this->setupSortControl(array( - 'host_last_check' => $this->translate('Last Check'), 'host_severity' => $this->translate('Severity'), + 'host_state' => $this->translate('Current State'), 'host_display_name' => $this->translate('Hostname'), 'host_address' => $this->translate('Address'), - 'host_state' => $this->translate('Current State') + 'host_last_check' => $this->translate('Last Check') )); $this->view->hosts = $query->paginate(); From 5df6828889618a4924d37c8b1e14c08aa7c7c99f Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Wed, 21 Jan 2015 09:31:38 +0100 Subject: [PATCH 0249/2920] monitoring: Remove ununsed sort rule in the ServiceStatus --- .../monitoring/library/Monitoring/DataView/ServiceStatus.php | 3 --- 1 file changed, 3 deletions(-) diff --git a/modules/monitoring/library/Monitoring/DataView/ServiceStatus.php b/modules/monitoring/library/Monitoring/DataView/ServiceStatus.php index 9edcabc87..e90caef9e 100644 --- a/modules/monitoring/library/Monitoring/DataView/ServiceStatus.php +++ b/modules/monitoring/library/Monitoring/DataView/ServiceStatus.php @@ -137,9 +137,6 @@ class ServiceStatus extends DataView ), 'order' => self::SORT_ASC ), - 'host_last_state_change' => array( - 'order' => self::SORT_ASC - ), 'host_severity' => array( 'columns' => array( 'host_severity', From f661713bbb68e97ac80dc4f501d4212e4f1edced Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Wed, 21 Jan 2015 09:35:33 +0100 Subject: [PATCH 0250/2920] monitoring: Reorder the sort by combobox in the services overview --- .../monitoring/application/controllers/ListController.php | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/modules/monitoring/application/controllers/ListController.php b/modules/monitoring/application/controllers/ListController.php index 80375a33d..43fbd24c3 100644 --- a/modules/monitoring/application/controllers/ListController.php +++ b/modules/monitoring/application/controllers/ListController.php @@ -218,11 +218,10 @@ class Monitoring_ListController extends Controller $this->filterQuery($query); $this->setupSortControl(array( - 'service_last_check' => $this->translate('Last Service Check'), - 'service_severity' => $this->translate('Severity'), + 'service_severity' => $this->translate('Service Severity'), 'service_state' => $this->translate('Current Service State'), 'service_display_name' => $this->translate('Service Name'), - 'service_state_type' => $this->translate('Hard State'), + 'service_last_check' => $this->translate('Last Service Check'), 'host_severity' => $this->translate('Host Severity'), 'host_state' => $this->translate('Current Host State'), 'host_display_name' => $this->translate('Hostname'), From c77996d5b924340f114adae87dc32cac2815df74 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Wed, 21 Jan 2015 09:37:45 +0100 Subject: [PATCH 0251/2920] monitoring: Sort the services overview by service severity by default --- .../Monitoring/DataView/ServiceStatus.php | 28 +++++++++---------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/modules/monitoring/library/Monitoring/DataView/ServiceStatus.php b/modules/monitoring/library/Monitoring/DataView/ServiceStatus.php index a4c9cfee8..e7e2accb2 100644 --- a/modules/monitoring/library/Monitoring/DataView/ServiceStatus.php +++ b/modules/monitoring/library/Monitoring/DataView/ServiceStatus.php @@ -124,6 +124,20 @@ class ServiceStatus extends DataView public function getSortRules() { return array( + 'service_severity' => array( + 'columns' => array( + 'service_severity', + 'service_last_state_change' + ), + 'order' => self::SORT_DESC + ), + 'host_severity' => array( + 'columns' => array( + 'host_severity', + 'host_last_state_change', + ), + 'order' => self::SORT_ASC + ), 'host_display_name' => array( 'columns' => array( 'host_display_name', @@ -137,20 +151,6 @@ class ServiceStatus extends DataView 'service_display_name' ), 'order' => self::SORT_ASC - ), - 'host_severity' => array( - 'columns' => array( - 'host_severity', - 'host_last_state_change', - ), - 'order' => self::SORT_ASC - ), - 'service_severity' => array( - 'columns' => array( - 'service_severity', - 'service_last_state_change', - ), - 'order' => self::SORT_DESC ) ); } From 3bb5a9c7024f0c1fde28f5e7937e3bffab95d52e Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Wed, 21 Jan 2015 09:41:52 +0100 Subject: [PATCH 0252/2920] monitoring: Select the host_display_name column in the services overview refs #7843 --- modules/monitoring/application/controllers/ListController.php | 1 + 1 file changed, 1 insertion(+) diff --git a/modules/monitoring/application/controllers/ListController.php b/modules/monitoring/application/controllers/ListController.php index 43fbd24c3..23400849c 100644 --- a/modules/monitoring/application/controllers/ListController.php +++ b/modules/monitoring/application/controllers/ListController.php @@ -182,6 +182,7 @@ class Monitoring_ListController extends Controller $columns = array_merge(array( 'host_name', + 'host_display_name', 'host_state', 'host_state_type', 'host_last_state_change', From 23243d40e393a3ae66628f5106159ebb003f11c1 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Wed, 21 Jan 2015 09:42:10 +0100 Subject: [PATCH 0253/2920] monitoring: Use host_display_name for displaying the host name in the services overview refs #7843 --- .../monitoring/application/views/scripts/list/services.phtml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/monitoring/application/views/scripts/list/services.phtml b/modules/monitoring/application/views/scripts/list/services.phtml index 0b63c7887..5241c009b 100644 --- a/modules/monitoring/application/views/scripts/list/services.phtml +++ b/modules/monitoring/application/views/scripts/list/services.phtml @@ -107,7 +107,7 @@ foreach ($services as $service): service_icon_image && ! preg_match('/[\'"]/', $service->service_icon_image)): ?> icon($this->resolveMacros($service->service_icon_image, $service)) ?> -service_display_name ?>showHost): ?> on host_name; ?> +service_display_name ?>showHost): ?> on host_display_name; ?> host_state != 0): ?> (host_state, true)); ?>) From e55cf73f3481f22eecfa1f8bf17872a8ce0c5c9d Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Wed, 21 Jan 2015 09:55:17 +0100 Subject: [PATCH 0254/2920] monitoring: Select the host and service display_name columns in the eventhistory overview refs #7843 --- modules/monitoring/application/controllers/ListController.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/modules/monitoring/application/controllers/ListController.php b/modules/monitoring/application/controllers/ListController.php index 23400849c..aefe93b15 100644 --- a/modules/monitoring/application/controllers/ListController.php +++ b/modules/monitoring/application/controllers/ListController.php @@ -580,7 +580,9 @@ class Monitoring_ListController extends Controller $query = $this->backend->select()->from('eventHistory', array( 'host_name', + 'host_display_name', 'service_description', + 'service_display_name', 'object_type', 'timestamp', 'state', From b468be2813ba2c073f46e281b8490591305eafba Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Wed, 21 Jan 2015 09:59:48 +0100 Subject: [PATCH 0255/2920] Drop the ModulePage refs #8191 --- .../setup/application/forms/ModulePage.php | 161 ------------------ modules/setup/library/Setup/WebWizard.php | 15 -- 2 files changed, 176 deletions(-) delete mode 100644 modules/setup/application/forms/ModulePage.php diff --git a/modules/setup/application/forms/ModulePage.php b/modules/setup/application/forms/ModulePage.php deleted file mode 100644 index 5e8927dbc..000000000 --- a/modules/setup/application/forms/ModulePage.php +++ /dev/null @@ -1,161 +0,0 @@ -setName('setup_modules'); - $this->setViewScript('form/setup-modules.phtml'); - $this->session = Session::getSession()->getNamespace(get_class($this)); - - $this->modulePaths = array(); - if (($appModulePath = realpath(Icinga::app()->getApplicationDir() . '/../modules')) !== false) { - $this->modulePaths[] = $appModulePath; - } - } - - public function setPageData(array $pageData) - { - $this->pageData = $pageData; - return $this; - } - - public function handleRequest(Request $request = null) - { - $isPost = strtolower($request->getMethod()) === 'post'; - if ($isPost && $this->wasSent($request->getPost())) { - if (($newModule = $request->getPost('module')) !== null) { - $this->setCurrentModule($newModule); - $this->getResponse()->redirectAndExit($this->getRedirectUrl()); - } else { - // The user submitted this form but with the parent wizard's navigation - // buttons so it's now up to the parent wizard to handle the request.. - } - } else { - $wizard = $this->getCurrentWizard(); - $wizardPage = $wizard->getCurrentPage(); - - $wizard->handleRequest($request); - if ($isPost && $wizard->isFinished() && $wizardPage->wasSent($request->getPost())) { - $wizards = $this->getWizards(); - - $newModule = null; - foreach ($wizards as $moduleName => $moduleWizard) { - if (false === $moduleWizard->isFinished()) { - $newModule = $moduleName; - } - } - - if ($newModule === null) { - // In case all module wizards were completed just pick the first one again - reset($wizards); - $newModule = key($wizards); - } - - $this->setCurrentModule($newModule); - } - } - } - - public function clearSession() - { - $this->session->clear(); - foreach ($this->getWizards() as $wizard) { - $wizard->clearSession(); - } - } - - public function setCurrentModule($moduleName) - { - if (false === array_key_exists($moduleName, $this->getWizards())) { - throw new InvalidArgumentException(sprintf('Module "%s" does not provide a setup wizard', $moduleName)); - } - - $this->session->currentModule = $moduleName; - } - - public function getCurrentModule() - { - $moduleName = $this->session->get('currentModule'); - if ($moduleName === null) { - $moduleName = key($this->getWizards()); - $this->setCurrentModule($moduleName); - } - - return $moduleName; - } - - public function getCurrentWizard() - { - $wizards = $this->getWizards(); - return $wizards[$this->getCurrentModule()]; - } - - public function getModules() - { - if ($this->modules !== null) { - return $this->modules; - } else { - $this->modules = array(); - } - - $moduleManager = Icinga::app()->getModuleManager(); - $moduleManager->detectInstalledModules($this->modulePaths); - foreach ($moduleManager->listInstalledModules() as $moduleName) { - $this->modules[] = $moduleManager->loadModule($moduleName)->getModule($moduleName); - } - - return $this->modules; - } - - public function getWizards() - { - if ($this->wizards !== null) { - return $this->wizards; - } else { - $this->wizards = array(); - } - - foreach ($this->getModules() as $module) { - if ($module->providesSetupWizard()) { - $this->wizards[$module->getName()] = $module->getSetupWizard(); - } - } - - $this->mergePageData($this->wizards); - return $this->wizards; - } - - protected function mergePageData(array $wizards) - { - foreach ($wizards as $wizard) { - $wizardPageData = & $wizard->getPageData(); - foreach ($this->pageData as $pageName => $pageData) { - $wizardPageData[$pageName] = $pageData; - } - } - } -} diff --git a/modules/setup/library/Setup/WebWizard.php b/modules/setup/library/Setup/WebWizard.php index 68632e305..a33b8c0d7 100644 --- a/modules/setup/library/Setup/WebWizard.php +++ b/modules/setup/library/Setup/WebWizard.php @@ -94,7 +94,6 @@ class WebWizard extends Wizard implements SetupWizard $this->addPage(new AdminAccountPage()); $this->addPage(new GeneralConfigPage()); $this->addPage(new DatabaseCreationPage()); - $this->addPage(new ModulePage()); $this->addPage(new SummaryPage()); } @@ -167,9 +166,6 @@ class WebWizard extends Wizard implements SetupWizard unset($pageData['setup_admin_account']); unset($pageData['setup_authentication_backend']); } - } elseif ($page->getName() === 'setup_modules') { - $page->setPageData($this->getPageData()); - $page->handleRequest($request); } } @@ -263,7 +259,6 @@ class WebWizard extends Wizard implements SetupWizard public function clearSession() { parent::clearSession(); - $this->getPage('setup_modules')->clearSession(); $tokenPath = Config::resolvePath('setup.token'); if (file_exists($tokenPath)) { @@ -358,12 +353,6 @@ class WebWizard extends Wizard implements SetupWizard ) ); - foreach ($this->getPage('setup_modules')->setPageData($this->getPageData())->getWizards() as $wizard) { - if ($wizard->isFinished()) { - $setup->addSteps($wizard->getSetup()->getSteps()); - } - } - return $setup; } @@ -548,10 +537,6 @@ class WebWizard extends Wizard implements SetupWizard ) ); - foreach ($this->getPage('setup_modules')->setPageData($this->getPageData())->getWizards() as $wizard) { - $requirements->merge($wizard->getRequirements()->allOptional()); - } - return $requirements; } } From 9018b36d7acad75f75428ae32b8c386da56066d0 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Wed, 21 Jan 2015 10:03:14 +0100 Subject: [PATCH 0256/2920] monitoring: Escape hostname, service name and event message in the eventhistory overview --- .../application/views/scripts/list/eventhistory.phtml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/modules/monitoring/application/views/scripts/list/eventhistory.phtml b/modules/monitoring/application/views/scripts/list/eventhistory.phtml index a9516aab1..6d6130a3d 100644 --- a/modules/monitoring/application/views/scripts/list/eventhistory.phtml +++ b/modules/monitoring/application/views/scripts/list/eventhistory.phtml @@ -110,21 +110,21 @@ use Icinga\Module\Monitoring\Object\Service; 'host' => $event->host, 'service' => $event->service )); ?>"> - service; ?> + escape($event->service) ?> - translate('on') . ' ' . $event->host; ?> + translate('on') . ' ' . $this->escape($event->host) ?> - host; ?> + escape($event->host) ?>
    - icon($icon, $title); ?> + icon($icon, $title); ?> escape($msg) ?>
    From bfd133289169bf4230ee839e6a0183dc9b0f3e8d Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Wed, 21 Jan 2015 10:04:14 +0100 Subject: [PATCH 0257/2920] monitoring: Escape host and service display_name in the services overview --- .../monitoring/application/views/scripts/list/services.phtml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/monitoring/application/views/scripts/list/services.phtml b/modules/monitoring/application/views/scripts/list/services.phtml index 5241c009b..962d22bda 100644 --- a/modules/monitoring/application/views/scripts/list/services.phtml +++ b/modules/monitoring/application/views/scripts/list/services.phtml @@ -107,7 +107,7 @@ foreach ($services as $service): service_icon_image && ! preg_match('/[\'"]/', $service->service_icon_image)): ?> icon($this->resolveMacros($service->service_icon_image, $service)) ?> -service_display_name ?>showHost): ?> on host_display_name; ?> +escape($service->service_display_name) ?>showHost): ?> on escape($service->host_display_name) ?> host_state != 0): ?> (host_state, true)); ?>) From d49c950aacde3834f01b5111bca2d709c1435705 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Wed, 21 Jan 2015 10:04:59 +0100 Subject: [PATCH 0258/2920] monitoring: Escape host_display_name in the hosts overview --- modules/monitoring/application/views/scripts/list/hosts.phtml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/monitoring/application/views/scripts/list/hosts.phtml b/modules/monitoring/application/views/scripts/list/hosts.phtml index 91f59f422..4afc14731 100644 --- a/modules/monitoring/application/views/scripts/list/hosts.phtml +++ b/modules/monitoring/application/views/scripts/list/hosts.phtml @@ -98,7 +98,7 @@ if ($hosts->count() === 0) { icon($this->resolveMacros($host->host_icon_image, $host)) ?> - host_display_name ?> + escape($host->host_display_name) ?> host_unhandled_services) && $host->host_unhandled_services > 0): ?> Date: Wed, 21 Jan 2015 10:12:14 +0100 Subject: [PATCH 0260/2920] monitoring: Fix code style in the StatehistoryQuery --- .../Backend/Ido/Query/StatehistoryQuery.php | 36 +++++++++---------- 1 file changed, 17 insertions(+), 19 deletions(-) diff --git a/modules/monitoring/library/Monitoring/Backend/Ido/Query/StatehistoryQuery.php b/modules/monitoring/library/Monitoring/Backend/Ido/Query/StatehistoryQuery.php index b8d320c9c..dfa81b1ef 100644 --- a/modules/monitoring/library/Monitoring/Backend/Ido/Query/StatehistoryQuery.php +++ b/modules/monitoring/library/Monitoring/Backend/Ido/Query/StatehistoryQuery.php @@ -1,6 +1,4 @@ 0, - 'hard_state' => 1, + 'hard_state' => 1 ); protected $columnMap = array( 'statehistory' => array( - 'raw_timestamp' => 'sh.state_time', - 'timestamp' => 'UNIX_TIMESTAMP(sh.state_time)', - 'state_time' => 'sh.state_time', - 'object_id' => 'sho.object_id', - 'type' => "(CASE WHEN sh.state_type = 1 THEN 'hard_state' ELSE 'soft_state' END)", - 'state' => 'sh.state', - 'state_type' => 'sh.state_type', - 'output' => 'sh.output', - 'attempt' => 'sh.current_check_attempt', - 'max_attempts' => 'sh.max_check_attempts', - 'host' => 'sho.name1 COLLATE latin1_general_ci', - 'host_name' => 'sho.name1 COLLATE latin1_general_ci', - 'service' => 'sho.name2 COLLATE latin1_general_ci', - 'service_description' => 'sho.name2 COLLATE latin1_general_ci', - 'service_host_name' => 'sho.name1 COLLATE latin1_general_ci', - 'object_type' => "CASE WHEN sho.objecttype_id = 1 THEN 'host' ELSE 'service' END" + 'raw_timestamp' => 'sh.state_time', + 'timestamp' => 'UNIX_TIMESTAMP(sh.state_time)', + 'state_time' => 'sh.state_time', + 'object_id' => 'sho.object_id', + 'type' => "(CASE WHEN sh.state_type = 1 THEN 'hard_state' ELSE 'soft_state' END)", + 'state' => 'sh.state', + 'state_type' => 'sh.state_type', + 'output' => 'sh.output', + 'attempt' => 'sh.current_check_attempt', + 'max_attempts' => 'sh.max_check_attempts', + 'host' => 'sho.name1 COLLATE latin1_general_ci', + 'host_name' => 'sho.name1 COLLATE latin1_general_ci', + 'service' => 'sho.name2 COLLATE latin1_general_ci', + 'service_description' => 'sho.name2 COLLATE latin1_general_ci', + 'service_host_name' => 'sho.name1 COLLATE latin1_general_ci', + 'object_type' => "CASE WHEN sho.objecttype_id = 1 THEN 'host' ELSE 'service' END" ) ); From 1bba0b3d0f1c0ceb2a69f608b605cdb7aa1a1e70 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Wed, 21 Jan 2015 10:15:58 +0100 Subject: [PATCH 0261/2920] monitoring: Fix coding style in the EventHistoryQuery --- .../Backend/Ido/Query/EventHistoryQuery.php | 29 +++++++++---------- 1 file changed, 13 insertions(+), 16 deletions(-) diff --git a/modules/monitoring/library/Monitoring/Backend/Ido/Query/EventHistoryQuery.php b/modules/monitoring/library/Monitoring/Backend/Ido/Query/EventHistoryQuery.php index 2d5a0a2d8..b95cb89de 100644 --- a/modules/monitoring/library/Monitoring/Backend/Ido/Query/EventHistoryQuery.php +++ b/modules/monitoring/library/Monitoring/Backend/Ido/Query/EventHistoryQuery.php @@ -1,11 +1,9 @@ subQueries as $sub) { - $sub->applyFilter(clone $filter); - } - return $this; + foreach ($this->subQueries as $sub) { + $sub->applyFilter(clone $filter); + } + return $this; } - public function where($condition, $value = null) - { - $this->requireColumn($condition); - foreach ($this->subQueries as $sub) { - $sub->where($condition, $value); - } - return $this; - } + public function where($condition, $value = null) + { + $this->requireColumn($condition); + foreach ($this->subQueries as $sub) { + $sub->where($condition, $value); + } + return $this; + } protected function joinHostgroups() { @@ -116,5 +114,4 @@ class EventHistoryQuery extends IdoQuery ); return $this; } - } From aa976c41981471db10aebab436520b8b239b3a65 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Wed, 21 Jan 2015 10:24:24 +0100 Subject: [PATCH 0262/2920] monitoring: Support host and service display_name in the EventHistoryQuery This adds two left joins to the query when selecting host_display_name and service_display_name. If performance suffers badly, we have to evaluate whether to support the display_name column for displaying the host and service name in the eventhistory overview. refs #7843 --- .../Backend/Ido/Query/EventHistoryQuery.php | 64 +++++++++++++------ 1 file changed, 45 insertions(+), 19 deletions(-) diff --git a/modules/monitoring/library/Monitoring/Backend/Ido/Query/EventHistoryQuery.php b/modules/monitoring/library/Monitoring/Backend/Ido/Query/EventHistoryQuery.php index b95cb89de..306180ae6 100644 --- a/modules/monitoring/library/Monitoring/Backend/Ido/Query/EventHistoryQuery.php +++ b/modules/monitoring/library/Monitoring/Backend/Ido/Query/EventHistoryQuery.php @@ -11,28 +11,34 @@ class EventHistoryQuery extends IdoQuery protected $columnMap = array( 'eventhistory' => array( - 'cnt_notification' => "SUM(CASE eh.type WHEN 'notify' THEN 1 ELSE 0 END)", - 'cnt_hard_state' => "SUM(CASE eh.type WHEN 'hard_state' THEN 1 ELSE 0 END)", - 'cnt_soft_state' => "SUM(CASE eh.type WHEN 'hard_state' THEN 1 ELSE 0 END)", - 'cnt_downtime_start' => "SUM(CASE eh.type WHEN 'dt_start' THEN 1 ELSE 0 END)", - 'cnt_downtime_end' => "SUM(CASE eh.type WHEN 'dt_end' THEN 1 ELSE 0 END)", - 'host' => 'eho.name1 COLLATE latin1_general_ci', - 'service' => 'eho.name2 COLLATE latin1_general_ci', - 'host_name' => 'eho.name1 COLLATE latin1_general_ci', - 'service_description' => 'eho.name2 COLLATE latin1_general_ci', - 'object_type' => 'eh.object_type', - 'timestamp' => 'eh.timestamp', - 'state' => 'eh.state', - 'attempt' => 'eh.attempt', - 'max_attempts' => 'eh.max_attempts', - 'output' => 'eh.output', // we do not want long_output - 'type' => 'eh.type', - 'service_host_name' => 'eho.name1 COLLATE latin1_general_ci', - 'service_description' => 'eho.name2 COLLATE latin1_general_ci' + 'cnt_notification' => "SUM(CASE eh.type WHEN 'notify' THEN 1 ELSE 0 END)", + 'cnt_hard_state' => "SUM(CASE eh.type WHEN 'hard_state' THEN 1 ELSE 0 END)", + 'cnt_soft_state' => "SUM(CASE eh.type WHEN 'hard_state' THEN 1 ELSE 0 END)", + 'cnt_downtime_start' => "SUM(CASE eh.type WHEN 'dt_start' THEN 1 ELSE 0 END)", + 'cnt_downtime_end' => "SUM(CASE eh.type WHEN 'dt_end' THEN 1 ELSE 0 END)", + 'host' => 'eho.name1 COLLATE latin1_general_ci', + 'service' => 'eho.name2 COLLATE latin1_general_ci', + 'host_name' => 'eho.name1 COLLATE latin1_general_ci', + 'service_description' => 'eho.name2 COLLATE latin1_general_ci', + 'object_type' => 'eh.object_type', + 'timestamp' => 'eh.timestamp', + 'state' => 'eh.state', + 'attempt' => 'eh.attempt', + 'max_attempts' => 'eh.max_attempts', + 'output' => 'eh.output', // we do not want long_output + 'type' => 'eh.type', + 'service_host_name' => 'eho.name1 COLLATE latin1_general_ci', + 'service_description' => 'eho.name2 COLLATE latin1_general_ci' ), 'hostgroups' => array( - 'hostgroup' => 'hgo.name1 COLLATE latin1_general_ci', + 'hostgroup' => 'hgo.name1 COLLATE latin1_general_ci', ), + 'hosts' => array( + 'host_display_name' => 'h.display_name' + ), + 'services' => array( + 'service_display_name' => 's.display_name' + ) ); protected $useSubqueryCount = true; @@ -114,4 +120,24 @@ class EventHistoryQuery extends IdoQuery ); return $this; } + + protected function joinHosts() + { + $this->select->joinLeft( + array('h' => $this->prefix . 'hosts'), + 'h.host_object_id = eho.object_id', + array() + ); + return $this; + } + + protected function joinServices() + { + $this->select->joinLeft( + array('s' => $this->prefix . 'services'), + 's.service_object_id = eho.object_id', + array() + ); + return $this; + } } From 25c2e99122af66334f3bca794c18c967a1610cb3 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Wed, 21 Jan 2015 10:26:12 +0100 Subject: [PATCH 0263/2920] monitoring: Fix duplicate array key 'service_description' in the EventHistoryQuery --- .../library/Monitoring/Backend/Ido/Query/EventHistoryQuery.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/modules/monitoring/library/Monitoring/Backend/Ido/Query/EventHistoryQuery.php b/modules/monitoring/library/Monitoring/Backend/Ido/Query/EventHistoryQuery.php index 306180ae6..e6efb1e45 100644 --- a/modules/monitoring/library/Monitoring/Backend/Ido/Query/EventHistoryQuery.php +++ b/modules/monitoring/library/Monitoring/Backend/Ido/Query/EventHistoryQuery.php @@ -27,8 +27,7 @@ class EventHistoryQuery extends IdoQuery 'max_attempts' => 'eh.max_attempts', 'output' => 'eh.output', // we do not want long_output 'type' => 'eh.type', - 'service_host_name' => 'eho.name1 COLLATE latin1_general_ci', - 'service_description' => 'eho.name2 COLLATE latin1_general_ci' + 'service_host_name' => 'eho.name1 COLLATE latin1_general_ci' ), 'hostgroups' => array( 'hostgroup' => 'hgo.name1 COLLATE latin1_general_ci', From 3e702ac255a5864b35fa7a94c9e9e669a6887797 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Wed, 21 Jan 2015 10:28:21 +0100 Subject: [PATCH 0264/2920] monitoring: Support host and service display_name in the EventHistory data view refs #7843 --- .../library/Monitoring/DataView/EventHistory.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/modules/monitoring/library/Monitoring/DataView/EventHistory.php b/modules/monitoring/library/Monitoring/DataView/EventHistory.php index 09779b27d..f13815aae 100644 --- a/modules/monitoring/library/Monitoring/DataView/EventHistory.php +++ b/modules/monitoring/library/Monitoring/DataView/EventHistory.php @@ -1,6 +1,4 @@ array( - 'columns' => array('timestamp'), - 'order' => 'DESC' + 'columns' => array('timestamp'), + 'order' => 'DESC' ) ); } From 7ff1948c1a508bba0125cc1e3f64d99a2d528fa1 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Wed, 21 Jan 2015 10:29:22 +0100 Subject: [PATCH 0265/2920] monitoring: Use host and service display_name for displaying host and service names in the eventhistory overview refs #7843 --- .../application/views/scripts/list/eventhistory.phtml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/modules/monitoring/application/views/scripts/list/eventhistory.phtml b/modules/monitoring/application/views/scripts/list/eventhistory.phtml index 6d6130a3d..d96a4914b 100644 --- a/modules/monitoring/application/views/scripts/list/eventhistory.phtml +++ b/modules/monitoring/application/views/scripts/list/eventhistory.phtml @@ -110,16 +110,16 @@ use Icinga\Module\Monitoring\Object\Service; 'host' => $event->host, 'service' => $event->service )); ?>"> - escape($event->service) ?> + escape($event->service_display_name) ?> - translate('on') . ' ' . $this->escape($event->host) ?> + translate('on') . ' ' . $this->escape($event->host_display_name) ?> - escape($event->host) ?> + escape($event->host_display_name) ?>
    From cd03c2164a508bf75200ed9a1486177e8d7880ed Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Wed, 21 Jan 2015 10:33:05 +0100 Subject: [PATCH 0266/2920] monitoring: Fix sorting by 'End Time' in the downtimes overview --- .../application/controllers/ListController.php | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/modules/monitoring/application/controllers/ListController.php b/modules/monitoring/application/controllers/ListController.php index aefe93b15..325c0d612 100644 --- a/modules/monitoring/application/controllers/ListController.php +++ b/modules/monitoring/application/controllers/ListController.php @@ -292,15 +292,15 @@ class Monitoring_ListController extends Controller $this->filterQuery($query); $this->setupSortControl(array( - 'downtime_is_in_effect' => $this->translate('Is In Effect'), - 'downtime_host' => $this->translate('Host / Service'), - 'downtime_entry_time' => $this->translate('Entry Time'), - 'downtime_author' => $this->translate('Author'), - 'downtime_start' => $this->translate('Start Time'), - 'downtime_start' => $this->translate('End Time'), - 'downtime_scheduled_start' => $this->translate('Scheduled Start'), - 'downtime_scheduled_end' => $this->translate('Scheduled End'), - 'downtime_duration' => $this->translate('Duration'), + 'downtime_is_in_effect' => $this->translate('Is In Effect'), + 'downtime_host' => $this->translate('Host / Service'), + 'downtime_entry_time' => $this->translate('Entry Time'), + 'downtime_author' => $this->translate('Author'), + 'downtime_start' => $this->translate('Start Time'), + 'downtime_end' => $this->translate('End Time'), + 'downtime_scheduled_start' => $this->translate('Scheduled Start'), + 'downtime_scheduled_end' => $this->translate('Scheduled End'), + 'downtime_duration' => $this->translate('Duration') )); $this->view->downtimes = $query->paginate(); From e881a0de33270d25d5e65600755f1744c908f571 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Wed, 21 Jan 2015 10:35:10 +0100 Subject: [PATCH 0267/2920] monitoring: Remove useless PHPDoc in the DowntimeQuery --- .../Monitoring/Backend/Ido/Query/DowntimeQuery.php | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/modules/monitoring/library/Monitoring/Backend/Ido/Query/DowntimeQuery.php b/modules/monitoring/library/Monitoring/Backend/Ido/Query/DowntimeQuery.php index a53fd18e9..f9d0d93a2 100644 --- a/modules/monitoring/library/Monitoring/Backend/Ido/Query/DowntimeQuery.php +++ b/modules/monitoring/library/Monitoring/Backend/Ido/Query/DowntimeQuery.php @@ -1,18 +1,9 @@ array( 'downtime_author' => 'sd.author_name', @@ -39,9 +30,6 @@ class DowntimeQuery extends IdoQuery ), ); - /** - * Join with scheduleddowntime - */ protected function joinBaseTables() { $this->select->from( From 2fdeabd39831968c5e84d65230ff9f5b65c05605 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Wed, 21 Jan 2015 10:47:20 +0100 Subject: [PATCH 0268/2920] monitoring: Escape host and service name, author and comment in the downtimes overview --- .../application/views/scripts/list/downtimes.phtml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/modules/monitoring/application/views/scripts/list/downtimes.phtml b/modules/monitoring/application/views/scripts/list/downtimes.phtml index 8a8e5576c..616f253c7 100644 --- a/modules/monitoring/application/views/scripts/list/downtimes.phtml +++ b/modules/monitoring/application/views/scripts/list/downtimes.phtml @@ -57,20 +57,20 @@ use Icinga\Module\Monitoring\Object\Service; 'host' => $downtime->host, 'service' => $downtime->service )); ?>"> - service; ?> + escape($downtime->service) ?> - translate('on'); ?> host; ?> + translate('on'); ?> escape($downtime->host) ?> icon('host'); ?> - host; ?> + escape($downtime->host) ?>
    - icon('comment'); ?> [author; ?>] comment; ?> + icon('comment') ?> [escape($downtime->author) ?>] escape($downtime->comment) ?>
    is_flexible): ?> From fdb3988efdecbeeeb16ca92af0650d0b829b5236 Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Wed, 21 Jan 2015 11:15:38 +0100 Subject: [PATCH 0269/2920] Fix float formatting in the progress bar's css refs #8191 --- modules/setup/application/views/scripts/index/index.phtml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/setup/application/views/scripts/index/index.phtml b/modules/setup/application/views/scripts/index/index.phtml index d12343d5b..a55cfa198 100644 --- a/modules/setup/application/views/scripts/index/index.phtml +++ b/modules/setup/application/views/scripts/index/index.phtml @@ -73,7 +73,7 @@ if ($notifications->hasMessages()) { $page): ?> hasMessages()) { $page): ?> Date: Wed, 21 Jan 2015 11:44:44 +0100 Subject: [PATCH 0270/2920] Ensure that the SummaryPage has a unique name when being utilized refs #8191 --- .../monitoring/library/Monitoring/MonitoringWizard.php | 4 ++-- modules/setup/application/forms/SummaryPage.php | 8 +++++++- .../application/views/scripts/form/setup-summary.phtml | 2 +- modules/setup/library/Setup/WebWizard.php | 2 +- public/css/icinga/setup.less | 2 +- 5 files changed, 12 insertions(+), 6 deletions(-) diff --git a/modules/monitoring/library/Monitoring/MonitoringWizard.php b/modules/monitoring/library/Monitoring/MonitoringWizard.php index 9c588e5b3..a21ee9706 100644 --- a/modules/monitoring/library/Monitoring/MonitoringWizard.php +++ b/modules/monitoring/library/Monitoring/MonitoringWizard.php @@ -37,7 +37,7 @@ class MonitoringWizard extends Wizard implements SetupWizard $this->addPage(new LivestatusResourcePage()); $this->addPage(new InstancePage()); $this->addPage(new SecurityPage()); - $this->addPage(new SummaryPage()); + $this->addPage(new SummaryPage(array('name' => 'setup_monitoring_summary'))); } /** @@ -47,7 +47,7 @@ class MonitoringWizard extends Wizard implements SetupWizard { if ($page->getName() === 'setup_requirements') { $page->setRequirements($this->getRequirements()); - } elseif ($page->getName() === 'setup_summary') { + } elseif ($page->getName() === 'setup_monitoring_summary') { $page->setSummary($this->getSetup()->getSummary()); $page->setSubjectTitle(mt('monitoring', 'the monitoring module', 'setup.summary.subject')); } elseif ( diff --git a/modules/setup/application/forms/SummaryPage.php b/modules/setup/application/forms/SummaryPage.php index 14ad93c56..9b42ec9d8 100644 --- a/modules/setup/application/forms/SummaryPage.php +++ b/modules/setup/application/forms/SummaryPage.php @@ -4,6 +4,7 @@ namespace Icinga\Module\Setup\Forms; +use LogicException; use Icinga\Web\Form; /** @@ -30,7 +31,12 @@ class SummaryPage extends Form */ public function init() { - $this->setName('setup_summary'); + if ($this->getName() === $this->filterName(get_class($this))) { + throw new LogicException( + 'When utilizing ' . get_class($this) . ' it is required to set a unique name by using the form options' + ); + } + $this->setViewScript('form/setup-summary.phtml'); } diff --git a/modules/setup/application/views/scripts/form/setup-summary.phtml b/modules/setup/application/views/scripts/form/setup-summary.phtml index fa354feb5..676dcd52f 100644 --- a/modules/setup/application/views/scripts/form/setup-summary.phtml +++ b/modules/setup/application/views/scripts/form/setup-summary.phtml @@ -20,7 +20,7 @@ use Icinga\Web\Wizard; -
    + getElement($form->getTokenElementName()); ?> getElement($form->getUidElementName()); ?>
    diff --git a/modules/setup/library/Setup/WebWizard.php b/modules/setup/library/Setup/WebWizard.php index a33b8c0d7..ad6f927cd 100644 --- a/modules/setup/library/Setup/WebWizard.php +++ b/modules/setup/library/Setup/WebWizard.php @@ -94,7 +94,7 @@ class WebWizard extends Wizard implements SetupWizard $this->addPage(new AdminAccountPage()); $this->addPage(new GeneralConfigPage()); $this->addPage(new DatabaseCreationPage()); - $this->addPage(new SummaryPage()); + $this->addPage(new SummaryPage(array('name' => 'setup_summary'))); } /** diff --git a/public/css/icinga/setup.less b/public/css/icinga/setup.less index 166e47ff8..8ca669bdd 100644 --- a/public/css/icinga/setup.less +++ b/public/css/icinga/setup.less @@ -270,7 +270,7 @@ } } - form#setup_summary { + form.summary { clear: left; } } From d528ddc64118221796f8dab0f38eff008b25c39f Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Wed, 21 Jan 2015 12:51:47 +0100 Subject: [PATCH 0271/2920] monitoring: Fix that host_display_name is NULL when the object is a service in the evenhistory overview refs #7843 --- .../Monitoring/Backend/Ido/Query/EventHistoryQuery.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/modules/monitoring/library/Monitoring/Backend/Ido/Query/EventHistoryQuery.php b/modules/monitoring/library/Monitoring/Backend/Ido/Query/EventHistoryQuery.php index e6efb1e45..2896f9536 100644 --- a/modules/monitoring/library/Monitoring/Backend/Ido/Query/EventHistoryQuery.php +++ b/modules/monitoring/library/Monitoring/Backend/Ido/Query/EventHistoryQuery.php @@ -33,7 +33,7 @@ class EventHistoryQuery extends IdoQuery 'hostgroup' => 'hgo.name1 COLLATE latin1_general_ci', ), 'hosts' => array( - 'host_display_name' => 'h.display_name' + 'host_display_name' => 'CASE WHEN sh.display_name IS NOT NULL THEN sh.display_name ELSE h.display_name END' ), 'services' => array( 'service_display_name' => 's.display_name' @@ -137,6 +137,11 @@ class EventHistoryQuery extends IdoQuery 's.service_object_id = eho.object_id', array() ); + $this->select->joinLeft( + array('sh' => $this->prefix . 'hosts'), + 'sh.host_object_id = s.host_object_id', + array() + ); return $this; } } From 85aa447516520759d26fa10aa4ae343cff74e416 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Wed, 21 Jan 2015 12:52:29 +0100 Subject: [PATCH 0272/2920] monitoring: Support host and service display_name in the DowntimeQuery refs #7843 --- .../Backend/Ido/Query/DowntimeQuery.php | 73 +++++++++++++------ 1 file changed, 52 insertions(+), 21 deletions(-) diff --git a/modules/monitoring/library/Monitoring/Backend/Ido/Query/DowntimeQuery.php b/modules/monitoring/library/Monitoring/Backend/Ido/Query/DowntimeQuery.php index f9d0d93a2..efc10f6a5 100644 --- a/modules/monitoring/library/Monitoring/Backend/Ido/Query/DowntimeQuery.php +++ b/modules/monitoring/library/Monitoring/Backend/Ido/Query/DowntimeQuery.php @@ -6,28 +6,34 @@ class DowntimeQuery extends IdoQuery { protected $columnMap = array( 'downtime' => array( - 'downtime_author' => 'sd.author_name', - 'author' => 'sd.author_name', - 'downtime_comment' => 'sd.comment_data', - 'downtime_entry_time' => 'UNIX_TIMESTAMP(sd.entry_time)', - 'downtime_is_fixed' => 'sd.is_fixed', - 'downtime_is_flexible' => 'CASE WHEN sd.is_fixed = 0 THEN 1 ELSE 0 END', - 'downtime_triggered_by_id' => 'sd.triggered_by_id', - 'downtime_scheduled_start' => 'UNIX_TIMESTAMP(sd.scheduled_start_time)', - 'downtime_scheduled_end' => 'UNIX_TIMESTAMP(sd.scheduled_end_time)', - 'downtime_start' => "UNIX_TIMESTAMP(CASE WHEN UNIX_TIMESTAMP(sd.trigger_time) > 0 then sd.trigger_time ELSE sd.scheduled_start_time END)", - 'downtime_end' => 'CASE WHEN sd.is_fixed > 0 THEN UNIX_TIMESTAMP(sd.scheduled_end_time) ELSE UNIX_TIMESTAMP(sd.trigger_time) + sd.duration END', - 'downtime_duration' => 'sd.duration', - 'downtime_is_in_effect' => 'sd.is_in_effect', - 'downtime_internal_id' => 'sd.internal_downtime_id', - 'downtime_host' => 'CASE WHEN ho.name1 IS NULL THEN so.name1 ELSE ho.name1 END COLLATE latin1_general_ci', // #7278, #7279 - 'host' => 'CASE WHEN ho.name1 IS NULL THEN so.name1 ELSE ho.name1 END COLLATE latin1_general_ci', - 'downtime_service' => 'so.name2 COLLATE latin1_general_ci', - 'service' => 'so.name2 COLLATE latin1_general_ci', // #7278, #7279 - 'downtime_objecttype' => "CASE WHEN ho.object_id IS NOT NULL THEN 'host' ELSE CASE WHEN so.object_id IS NOT NULL THEN 'service' ELSE NULL END END", - 'downtime_host_state' => 'CASE WHEN hs.has_been_checked = 0 OR hs.has_been_checked IS NULL THEN 99 ELSE hs.current_state END', - 'downtime_service_state' => 'CASE WHEN ss.has_been_checked = 0 OR ss.has_been_checked IS NULL THEN 99 ELSE ss.current_state END' + 'downtime_author' => 'sd.author_name', + 'author' => 'sd.author_name', + 'downtime_comment' => 'sd.comment_data', + 'downtime_entry_time' => 'UNIX_TIMESTAMP(sd.entry_time)', + 'downtime_is_fixed' => 'sd.is_fixed', + 'downtime_is_flexible' => 'CASE WHEN sd.is_fixed = 0 THEN 1 ELSE 0 END', + 'downtime_triggered_by_id' => 'sd.triggered_by_id', + 'downtime_scheduled_start' => 'UNIX_TIMESTAMP(sd.scheduled_start_time)', + 'downtime_scheduled_end' => 'UNIX_TIMESTAMP(sd.scheduled_end_time)', + 'downtime_start' => "UNIX_TIMESTAMP(CASE WHEN UNIX_TIMESTAMP(sd.trigger_time) > 0 then sd.trigger_time ELSE sd.scheduled_start_time END)", + 'downtime_end' => 'CASE WHEN sd.is_fixed > 0 THEN UNIX_TIMESTAMP(sd.scheduled_end_time) ELSE UNIX_TIMESTAMP(sd.trigger_time) + sd.duration END', + 'downtime_duration' => 'sd.duration', + 'downtime_is_in_effect' => 'sd.is_in_effect', + 'downtime_internal_id' => 'sd.internal_downtime_id', + 'downtime_host' => 'CASE WHEN ho.name1 IS NULL THEN so.name1 ELSE ho.name1 END COLLATE latin1_general_ci', // #7278, #7279 + 'host' => 'CASE WHEN ho.name1 IS NULL THEN so.name1 ELSE ho.name1 END COLLATE latin1_general_ci', + 'downtime_service' => 'so.name2 COLLATE latin1_general_ci', + 'service' => 'so.name2 COLLATE latin1_general_ci', // #7278, #7279 + 'downtime_objecttype' => "CASE WHEN ho.object_id IS NOT NULL THEN 'host' ELSE CASE WHEN so.object_id IS NOT NULL THEN 'service' ELSE NULL END END", + 'downtime_host_state' => 'CASE WHEN hs.has_been_checked = 0 OR hs.has_been_checked IS NULL THEN 99 ELSE hs.current_state END', + 'downtime_service_state' => 'CASE WHEN ss.has_been_checked = 0 OR ss.has_been_checked IS NULL THEN 99 ELSE ss.current_state END' ), + 'hosts' => array( + 'host_display_name' => 'CASE WHEN sh.display_name IS NOT NULL THEN sh.display_name ELSE h.display_name END' + ), + 'services' => array( + 'service_display_name' => 's.display_name' + ) ); protected function joinBaseTables() @@ -58,4 +64,29 @@ class DowntimeQuery extends IdoQuery ); $this->joinedVirtualTables = array('downtime' => true); } + + protected function joinHosts() + { + $this->select->joinLeft( + array('h' => $this->prefix . 'hosts'), + 'h.host_object_id = ho.object_id', + array() + ); + return $this; + } + + protected function joinServices() + { + $this->select->joinLeft( + array('s' => $this->prefix . 'services'), + 's.service_object_id = so.object_id', + array() + ); + $this->select->joinLeft( + array('sh' => $this->prefix . 'hosts'), + 'sh.host_object_id = s.host_object_id', + array() + ); + return $this; + } } From 5f0b809619dceef06c76859adbfc087f5e53d5b3 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Wed, 21 Jan 2015 12:52:58 +0100 Subject: [PATCH 0273/2920] monitoring: Support host and service display_name columns in the Downtime data view refs #7843 --- modules/monitoring/library/Monitoring/DataView/Downtime.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/modules/monitoring/library/Monitoring/DataView/Downtime.php b/modules/monitoring/library/Monitoring/DataView/Downtime.php index e075d658c..508620a6b 100644 --- a/modules/monitoring/library/Monitoring/DataView/Downtime.php +++ b/modules/monitoring/library/Monitoring/DataView/Downtime.php @@ -32,7 +32,9 @@ class Downtime extends DataView 'downtime_host', 'downtime_service', 'downtime_host_state', - 'downtime_service_state' + 'downtime_service_state', + 'host_display_name', + 'service_display_name' ); } @@ -51,7 +53,7 @@ class Downtime extends DataView 'downtime_service' ), 'order' => self::SORT_ASC - ), + ) ); } } From ab6eed03e5ceb7045b70966f357aa9a13c779aea Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Wed, 21 Jan 2015 12:53:26 +0100 Subject: [PATCH 0274/2920] monitoring: Select the host and service display_name in the downtimes overview refs #7843 --- modules/monitoring/application/controllers/ListController.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/modules/monitoring/application/controllers/ListController.php b/modules/monitoring/application/controllers/ListController.php index 325c0d612..dce93098c 100644 --- a/modules/monitoring/application/controllers/ListController.php +++ b/modules/monitoring/application/controllers/ListController.php @@ -285,7 +285,9 @@ class Monitoring_ListController extends Controller 'host' => 'downtime_host', 'service' => 'downtime_service', 'host_state' => 'downtime_host_state', - 'service_state' => 'downtime_service_state' + 'service_state' => 'downtime_service_state', + 'host_display_name', + 'service_display_name' ))->order('downtime_is_in_effect', 'DESC') ->order('downtime_scheduled_start', 'DESC'); From 86cc56afe6512394ed482fe99cd0559807d86fb5 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Wed, 21 Jan 2015 12:53:47 +0100 Subject: [PATCH 0275/2920] monitoring: Display host and service names using the display_name column in the downtimes overview refs #7843 --- .../application/views/scripts/list/downtimes.phtml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/modules/monitoring/application/views/scripts/list/downtimes.phtml b/modules/monitoring/application/views/scripts/list/downtimes.phtml index 616f253c7..98adb5883 100644 --- a/modules/monitoring/application/views/scripts/list/downtimes.phtml +++ b/modules/monitoring/application/views/scripts/list/downtimes.phtml @@ -57,16 +57,16 @@ use Icinga\Module\Monitoring\Object\Service; 'host' => $downtime->host, 'service' => $downtime->service )); ?>"> - escape($downtime->service) ?> + escape($downtime->service_display_name) ?> - translate('on'); ?> escape($downtime->host) ?> + translate('on'); ?> escape($downtime->host_display_name) ?> icon('host'); ?> - escape($downtime->host) ?> + escape($downtime->host_display_name) ?>
    From d340b0d49d0867d0e6214e5b7f1086a0168cb443 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Wed, 21 Jan 2015 12:55:41 +0100 Subject: [PATCH 0276/2920] monitoring: Let the data view handle the default ordering in the downtime overview refs #7843 --- modules/monitoring/application/controllers/ListController.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/modules/monitoring/application/controllers/ListController.php b/modules/monitoring/application/controllers/ListController.php index dce93098c..79a618616 100644 --- a/modules/monitoring/application/controllers/ListController.php +++ b/modules/monitoring/application/controllers/ListController.php @@ -288,8 +288,7 @@ class Monitoring_ListController extends Controller 'service_state' => 'downtime_service_state', 'host_display_name', 'service_display_name' - ))->order('downtime_is_in_effect', 'DESC') - ->order('downtime_scheduled_start', 'DESC'); + )); $this->filterQuery($query); From 5862fc98a54a594f0d96f7084bb98789be323bfa Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Wed, 21 Jan 2015 12:58:46 +0100 Subject: [PATCH 0277/2920] monitoring: Sort by 'downtime_scheduled_start' too when sorting by 'Is In Effect' --- modules/monitoring/library/Monitoring/DataView/Downtime.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/modules/monitoring/library/Monitoring/DataView/Downtime.php b/modules/monitoring/library/Monitoring/DataView/Downtime.php index 508620a6b..695cb256c 100644 --- a/modules/monitoring/library/Monitoring/DataView/Downtime.php +++ b/modules/monitoring/library/Monitoring/DataView/Downtime.php @@ -42,6 +42,10 @@ class Downtime extends DataView { return array( 'downtime_is_in_effect' => array( + 'columns' => array( + 'downtime_is_in_effect', + 'downtime_scheduled_start' + ), 'order' => self::SORT_DESC ), 'downtime_start' => array( From 91b7c31cda283ac12bd092784c1e45ac02d17b14 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Wed, 21 Jan 2015 13:06:03 +0100 Subject: [PATCH 0278/2920] monitoring: Support sorting downtimes by host and service display_name refs #7843 --- .../library/Monitoring/DataView/Downtime.php | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/modules/monitoring/library/Monitoring/DataView/Downtime.php b/modules/monitoring/library/Monitoring/DataView/Downtime.php index 695cb256c..681608b17 100644 --- a/modules/monitoring/library/Monitoring/DataView/Downtime.php +++ b/modules/monitoring/library/Monitoring/DataView/Downtime.php @@ -51,10 +51,17 @@ class Downtime extends DataView 'downtime_start' => array( 'order' => self::SORT_DESC ), - 'downtime_host' => array( + 'host_display_name' => array( 'columns' => array( - 'downtime_host', - 'downtime_service' + 'host_display_name', + 'service_display_name' + ), + 'order' => self::SORT_ASC + ), + 'service_display_name' => array( + 'columns' => array( + 'service_display_name', + 'host_display_name' ), 'order' => self::SORT_ASC ) From 7621de8ec02f080444aeb0d9b796ec3812675e0f Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Wed, 21 Jan 2015 13:06:32 +0100 Subject: [PATCH 0279/2920] monitoring: Add sort by 'Host' and 'Service' to the downtimes overview refs #7843 --- modules/monitoring/application/controllers/ListController.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/modules/monitoring/application/controllers/ListController.php b/modules/monitoring/application/controllers/ListController.php index 79a618616..df7081519 100644 --- a/modules/monitoring/application/controllers/ListController.php +++ b/modules/monitoring/application/controllers/ListController.php @@ -294,7 +294,8 @@ class Monitoring_ListController extends Controller $this->setupSortControl(array( 'downtime_is_in_effect' => $this->translate('Is In Effect'), - 'downtime_host' => $this->translate('Host / Service'), + 'host_display_name' => $this->translate('Host'), + 'service_display_name' => $this->translate('Service'), 'downtime_entry_time' => $this->translate('Entry Time'), 'downtime_author' => $this->translate('Author'), 'downtime_start' => $this->translate('Start Time'), From 1f6a81aefb553b91ca7cc7b916f64ecbc66a580e Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Wed, 21 Jan 2015 13:07:08 +0100 Subject: [PATCH 0280/2920] Add Wizard::skipPage() Required to not to duplicate code in custom wizards and to avoid errors when detecting the direction. refs #8191 --- library/Icinga/Web/Wizard.php | 30 +++++++++++++++++++ .../library/Monitoring/MonitoringWizard.php | 18 +---------- modules/setup/library/Setup/WebWizard.php | 18 +---------- 3 files changed, 32 insertions(+), 34 deletions(-) diff --git a/library/Icinga/Web/Wizard.php b/library/Icinga/Web/Wizard.php index 811374259..6fbfda533 100644 --- a/library/Icinga/Web/Wizard.php +++ b/library/Icinga/Web/Wizard.php @@ -440,6 +440,36 @@ class Wizard ); } + /** + * Return the next or previous page based on the given one + * + * @param Form $page The page to skip + * + * @return Form + */ + protected function skipPage(Form $page) + { + if ($this->parent) { + return $this->parent->skipPage($page); + } + + if ($this->hasPageData($page->getName())) { + $pageData = & $this->getPageData(); + unset($pageData[$page->getName()]); + } + + $pages = $this->getPages(); + if ($this->getDirection() === static::FORWARD) { + $nextPage = $pages[array_search($page, $pages, true) + 1]; + $newPage = $this->getNewPage($nextPage->getName(), $page); + } else { // $this->getDirection() === static::BACKWARD + $previousPage = $pages[array_search($page, $pages, true) - 1]; + $newPage = $this->getNewPage($previousPage->getName(), $page); + } + + return $newPage; + } + /** * Return whether the given page is this wizard's last page * diff --git a/modules/monitoring/library/Monitoring/MonitoringWizard.php b/modules/monitoring/library/Monitoring/MonitoringWizard.php index a21ee9706..58a63a6ea 100644 --- a/modules/monitoring/library/Monitoring/MonitoringWizard.php +++ b/modules/monitoring/library/Monitoring/MonitoringWizard.php @@ -79,23 +79,7 @@ class MonitoringWizard extends Wizard implements SetupWizard $skip = $backendData['type'] !== 'livestatus'; } - if ($skip) { - if ($this->hasPageData($newPage->getName())) { - $pageData = & $this->getPageData(); - unset($pageData[$newPage->getName()]); - } - - $pages = $this->getPages(); - if ($this->getDirection() === static::FORWARD) { - $nextPage = $pages[array_search($newPage, $pages, true) + 1]; - $newPage = $this->getNewPage($nextPage->getName(), $newPage); - } else { // $this->getDirection() === static::BACKWARD - $previousPage = $pages[array_search($newPage, $pages, true) - 1]; - $newPage = $this->getNewPage($previousPage->getName(), $newPage); - } - } - - return $newPage; + return $skip ? $this->skipPage($newPage) : $newPage; } /** diff --git a/modules/setup/library/Setup/WebWizard.php b/modules/setup/library/Setup/WebWizard.php index ad6f927cd..da606bd99 100644 --- a/modules/setup/library/Setup/WebWizard.php +++ b/modules/setup/library/Setup/WebWizard.php @@ -218,23 +218,7 @@ class WebWizard extends Wizard implements SetupWizard } } - if ($skip) { - if ($this->hasPageData($newPage->getName())) { - $pageData = & $this->getPageData(); - unset($pageData[$newPage->getName()]); - } - - $pages = $this->getPages(); - if ($this->getDirection() === static::FORWARD) { - $nextPage = $pages[array_search($newPage, $pages, true) + 1]; - $newPage = $this->getNewPage($nextPage->getName(), $newPage); - } else { // $this->getDirection() === static::BACKWARD - $previousPage = $pages[array_search($newPage, $pages, true) - 1]; - $newPage = $this->getNewPage($previousPage->getName(), $newPage); - } - } - - return $newPage; + return $skip ? $this->skipPage($newPage) : $newPage; } /** From 0bcca651b223257948cc289e77d2344417ea53b0 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Wed, 21 Jan 2015 13:12:26 +0100 Subject: [PATCH 0281/2920] monitoring: Remove useless PHPDoc in the NotificationQuery --- .../Monitoring/Backend/Ido/Query/NotificationQuery.php | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/modules/monitoring/library/Monitoring/Backend/Ido/Query/NotificationQuery.php b/modules/monitoring/library/Monitoring/Backend/Ido/Query/NotificationQuery.php index 00b6957b8..70962a1c0 100644 --- a/modules/monitoring/library/Monitoring/Backend/Ido/Query/NotificationQuery.php +++ b/modules/monitoring/library/Monitoring/Backend/Ido/Query/NotificationQuery.php @@ -1,19 +1,9 @@ array( 'notification_output' => 'n.output', From 64a8006973ac63a210f08f4d8ea8708696fa453e Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Wed, 21 Jan 2015 13:56:53 +0100 Subject: [PATCH 0282/2920] Add Wizard::isComplete() Wizard::isFinished() is not applicable in case a wizard is a child of another wizard. Wizard::isComplete() fulfills the need to check whether a user went through a wizard entirely. refs #8191 --- library/Icinga/Web/Wizard.php | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/library/Icinga/Web/Wizard.php b/library/Icinga/Web/Wizard.php index 6fbfda533..8e822abc9 100644 --- a/library/Icinga/Web/Wizard.php +++ b/library/Icinga/Web/Wizard.php @@ -487,6 +487,19 @@ class Wizard return $page->getName() === end($pages)->getName(); } + /** + * Return whether all of this wizard's pages were visited by the user + * + * The base implementation just verifies that the very last page has page data available. + * + * @return bool + */ + public function isComplete() + { + $pages = $this->getPages(); + return $this->hasPageData($pages[count($pages) - 1]->getName()); + } + /** * Set whether this wizard has been completed * From 08e600a376f7da93a902df9c5f963ee596401095 Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Wed, 21 Jan 2015 13:57:59 +0100 Subject: [PATCH 0283/2920] Re-introduce the ModulePage Now with pretty checkboxes :) refs #8191 --- .../setup/application/forms/ModulePage.php | 96 +++++++++++++++++++ 1 file changed, 96 insertions(+) create mode 100644 modules/setup/application/forms/ModulePage.php diff --git a/modules/setup/application/forms/ModulePage.php b/modules/setup/application/forms/ModulePage.php new file mode 100644 index 000000000..596a5d762 --- /dev/null +++ b/modules/setup/application/forms/ModulePage.php @@ -0,0 +1,96 @@ +setName('setup_modules'); + //$this->setViewScript('form/setup-modules.phtml'); + + $this->modulePaths = array(); + if (($appModulePath = realpath(Icinga::app()->getApplicationDir() . '/../modules')) !== false) { + $this->modulePaths[] = $appModulePath; + } + } + + public function createElements(array $formData) + { + foreach ($this->getModules() as $module) { + $this->addElement( + 'checkbox', + $module->getName(), + array( + 'label' => ucfirst($module->getName()) + ) + ); + $this->addElement( + 'note', + $module->getName() . '_desc', + array( + 'value' => $module->getDescription() + ) + ); + } + } + + protected function getModules() + { + if ($this->modules !== null) { + return $this->modules; + } else { + $this->modules = array(); + } + + $moduleManager = Icinga::app()->getModuleManager(); + $moduleManager->detectInstalledModules($this->modulePaths); + foreach ($moduleManager->listInstalledModules() as $moduleName) { + if ($moduleName !== 'setup') { + $this->modules[$moduleName] = $moduleManager->loadModule($moduleName)->getModule($moduleName); + } + } + + return $this->modules; + } + + public function getCheckedModules() + { + $modules = $this->getModules(); + + $checked = array(); + foreach ($this->getElements() as $name => $element) { + if (array_key_exists($name, $modules) && $element->isChecked()) { + $checked[$name] = $modules[$name]; + } + } + + return $checked; + } + + public function getModuleWizards() + { + $checked = $this->getCheckedModules(); + + $wizards = array(); + foreach ($checked as $name => $module) { + if ($module->providesSetupWizard()) { + $wizards[$name] = $module->getSetupWizard(); + } + } + + return $wizards; + } +} From 817e4e937c06495e20041d230afdaaf0b2d76e78 Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Wed, 21 Jan 2015 14:00:57 +0100 Subject: [PATCH 0284/2920] Run module wizards as part of the main application's wizard A user now chooses right after the start which modules to install and configures them as part of the main routine. refs #8191 --- modules/setup/library/Setup/WebWizard.php | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/modules/setup/library/Setup/WebWizard.php b/modules/setup/library/Setup/WebWizard.php index da606bd99..7e36a3274 100644 --- a/modules/setup/library/Setup/WebWizard.php +++ b/modules/setup/library/Setup/WebWizard.php @@ -83,6 +83,7 @@ class WebWizard extends Wizard implements SetupWizard protected function init() { $this->addPage(new WelcomePage()); + $this->addPage(new ModulePage()); $this->addPage(new RequirementsPage()); $this->addPage(new AuthenticationPage()); $this->addPage(new PreferencesPage()); @@ -95,6 +96,13 @@ class WebWizard extends Wizard implements SetupWizard $this->addPage(new GeneralConfigPage()); $this->addPage(new DatabaseCreationPage()); $this->addPage(new SummaryPage(array('name' => 'setup_summary'))); + + if (($modulePageData = $this->getPageData('setup_modules')) !== null) { + $modulePage = $this->getPage('setup_modules')->populate($modulePageData); + foreach ($modulePage->getModuleWizards() as $moduleWizard) { + $this->addPage($moduleWizard); + } + } } /** @@ -337,6 +345,12 @@ class WebWizard extends Wizard implements SetupWizard ) ); + foreach ($this->getWizards() as $wizard) { + if ($wizard->isComplete()) { + $setup->addSteps($wizard->getSetup()->getSteps()); + } + } + return $setup; } @@ -521,6 +535,12 @@ class WebWizard extends Wizard implements SetupWizard ) ); + foreach ($this->getWizards() as $wizard) { + // TODO(8191): Ensure that equal requirements are not shown individually but only + // once with their description properly being merged together! + $requirements->merge($wizard->getRequirements()); + } + return $requirements; } } From 96390d34bf5d04018d93ebeb7786da1864586466 Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Wed, 21 Jan 2015 15:03:34 +0100 Subject: [PATCH 0285/2920] Enable modules as part of the main installation routine refs #8191 --- .../library/Monitoring/MonitoringWizard.php | 7 --- .../library/Setup/Utils/EnableModuleStep.php | 48 +++++++++++-------- modules/setup/library/Setup/WebWizard.php | 11 +++-- 3 files changed, 36 insertions(+), 30 deletions(-) diff --git a/modules/monitoring/library/Monitoring/MonitoringWizard.php b/modules/monitoring/library/Monitoring/MonitoringWizard.php index 58a63a6ea..f02faa4f3 100644 --- a/modules/monitoring/library/Monitoring/MonitoringWizard.php +++ b/modules/monitoring/library/Monitoring/MonitoringWizard.php @@ -4,15 +4,12 @@ namespace Icinga\Module\Monitoring; -use Icinga\Application\Icinga; use Icinga\Web\Form; use Icinga\Web\Wizard; use Icinga\Web\Request; use Icinga\Module\Setup\Setup; use Icinga\Module\Setup\SetupWizard; use Icinga\Module\Setup\Requirements; -use Icinga\Module\Setup\Utils\MakeDirStep; -use Icinga\Module\Setup\Utils\EnableModuleStep; use Icinga\Module\Setup\Forms\SummaryPage; use Icinga\Module\Monitoring\Forms\Setup\WelcomePage; use Icinga\Module\Monitoring\Forms\Setup\BackendPage; @@ -109,8 +106,6 @@ class MonitoringWizard extends Wizard implements SetupWizard $pageData = $this->getPageData(); $setup = new Setup(); - $setup->addStep(new MakeDirStep(array(Icinga::app()->getConfigDir() . '/modules/monitoring'), 2770)); - $setup->addStep( new BackendStep(array( 'backendConfig' => $pageData['setup_monitoring_backend'], @@ -132,8 +127,6 @@ class MonitoringWizard extends Wizard implements SetupWizard )) ); - $setup->addStep(new EnableModuleStep('monitoring')); - return $setup; } diff --git a/modules/setup/library/Setup/Utils/EnableModuleStep.php b/modules/setup/library/Setup/Utils/EnableModuleStep.php index 3ca3eebd1..a23e532f2 100644 --- a/modules/setup/library/Setup/Utils/EnableModuleStep.php +++ b/modules/setup/library/Setup/Utils/EnableModuleStep.php @@ -12,13 +12,13 @@ class EnableModuleStep extends Step { protected $modulePaths; - protected $moduleName; + protected $moduleNames; - protected $error; + protected $errors; - public function __construct($moduleName) + public function __construct(array $moduleNames) { - $this->moduleName = $moduleName; + $this->moduleNames = $moduleNames; $this->modulePaths = array(); if (($appModulePath = realpath(Icinga::app()->getApplicationDir() . '/../modules')) !== false) { @@ -28,17 +28,20 @@ class EnableModuleStep extends Step public function apply() { - try { - $moduleManager = Icinga::app()->getModuleManager(); - $moduleManager->detectInstalledModules($this->modulePaths); - $moduleManager->enableModule($this->moduleName); - } catch (Exception $e) { - $this->error = $e; - return false; + $moduleManager = Icinga::app()->getModuleManager(); + $moduleManager->detectInstalledModules($this->modulePaths); + + $success = true; + foreach ($this->moduleNames as $moduleName) { + try { + $moduleManager->enableModule($moduleName); + } catch (Exception $e) { + $this->errors[$moduleName] = $e; + $success = false; + } } - $this->error = false; - return true; + return $success; } public function getSummary() @@ -48,12 +51,19 @@ class EnableModuleStep extends Step public function getReport() { - if ($this->error === false) { - return '

    ' . sprintf(mt('setup', 'Module "%s" has been successfully enabled.'), $this->moduleName) . '

    '; - } elseif ($this->error !== null) { - $message = mt('setup', 'Module "%s" could not be enabled. An error occured:'); - return '

    ' . sprintf($message, $this->moduleName) . '

    ' - . '

    ' . $this->error->getMessage() . '

    '; + $okMessage = mt('setup', 'Module "%s" has been successfully enabled.'); + $failMessage = mt('setup', 'Module "%s" could not be enabled. An error occured:'); + + $report = ''; + foreach ($this->moduleNames as $moduleName) { + if (isset($this->errors[$moduleName])) { + $report .= '

    ' . sprintf($failMessage, $moduleName) . '

    ' + . '

    ' . $this->errors[$moduleName]->getMessage() . '

    '; + } else { + $report .= '

    ' . sprintf($okMessage, $moduleName) . '

    '; + } } + + return $report; } } diff --git a/modules/setup/library/Setup/WebWizard.php b/modules/setup/library/Setup/WebWizard.php index 7e36a3274..395c5af8e 100644 --- a/modules/setup/library/Setup/WebWizard.php +++ b/modules/setup/library/Setup/WebWizard.php @@ -29,6 +29,7 @@ use Icinga\Module\Setup\Steps\DatabaseStep; use Icinga\Module\Setup\Steps\GeneralConfigStep; use Icinga\Module\Setup\Steps\ResourceStep; use Icinga\Module\Setup\Steps\AuthenticationStep; +use Icinga\Module\Setup\Utils\EnableModuleStep; use Icinga\Module\Setup\Utils\MakeDirStep; use Icinga\Module\Setup\Utils\DbTool; @@ -284,7 +285,7 @@ class WebWizard extends Wizard implements SetupWizard ? $pageData['setup_database_creation']['password'] : null, 'schemaPath' => Config::module('setup') - ->get('schema', 'path', Icinga::app()->getBaseDir('etc/schema')) + ->get('schema', 'path', Icinga::app()->getBaseDir('etc' . DIRECTORY_SEPARATOR . 'schema')) )) ); } @@ -337,9 +338,9 @@ class WebWizard extends Wizard implements SetupWizard $setup->addStep( new MakeDirStep( array( - $configDir . '/modules', - $configDir . '/preferences', - $configDir . '/enabledModules' + $configDir . DIRECTORY_SEPARATOR . 'modules', + $configDir . DIRECTORY_SEPARATOR . 'preferences', + $configDir . DIRECTORY_SEPARATOR . 'enabledModules' ), 2770 ) @@ -351,6 +352,8 @@ class WebWizard extends Wizard implements SetupWizard } } + $setup->addStep(new EnableModuleStep(array_keys($this->getPage('setup_modules')->getCheckedModules()))); + return $setup; } From 10eacf9682b0b09d755791207028da8be304d192 Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Wed, 21 Jan 2015 15:39:06 +0100 Subject: [PATCH 0286/2920] Allow jumping to already visited pages This was already possible using just the base implementation of Wizard but since WebWizard has optional pages it did not work with pages that had such an optional page as previous page. refs #8191 --- library/Icinga/Web/Wizard.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/library/Icinga/Web/Wizard.php b/library/Icinga/Web/Wizard.php index 8e822abc9..42dea5c1c 100644 --- a/library/Icinga/Web/Wizard.php +++ b/library/Icinga/Web/Wizard.php @@ -400,7 +400,7 @@ class Wizard /** * Return the new page to set as current page * - * Permission is checked by verifying that the requested page's previous page has page data available. + * Permission is checked by verifying that the requested page or its previous page has page data available. * The requested page is automatically permitted without any checks if the origin page is its previous * page or one that occurs later in order. * @@ -421,7 +421,7 @@ class Wizard $permitted = true; $pages = $this->getPages(); - if (($index = array_search($page, $pages, true)) > 0) { + if (! $this->hasPageData($requestedPage) && ($index = array_search($page, $pages, true)) > 0) { $previousPage = $pages[$index - 1]; if ($originPage === null || ($previousPage->getName() !== $originPage->getName() && array_search($originPage, $pages, true) < $index)) From b05316340cbe9c7bb061f43a3498b017bae56437 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Wed, 21 Jan 2015 15:46:41 +0100 Subject: [PATCH 0287/2920] monitoring: Add Link view helper Most of the monitoring overviews link to detail information, e.g. the full information of the involved monitored object. Instead of reintroducing link generation and translation in those views, this helper contains most frequently used jump links. --- .../application/views/helpers/Link.php | 59 +++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100644 modules/monitoring/application/views/helpers/Link.php diff --git a/modules/monitoring/application/views/helpers/Link.php b/modules/monitoring/application/views/helpers/Link.php new file mode 100644 index 000000000..0d8c35861 --- /dev/null +++ b/modules/monitoring/application/views/helpers/Link.php @@ -0,0 +1,59 @@ +view->qlink( + $linkText, + $this->view->href('monitoring/host/show', array('host' => $host)) + ); + } + + /** + * Create a service link + * + * @param string $service Service name + * @param string $serviceLinkText Text for the service link, e.g. the service's display name + * @param string $host Hostname + * @param string $hostLinkText Text for the host link, e.g. the host's display name + * + * @return string + */ + public function service($service, $serviceLinkText, $host, $hostLinkText) + { + return sprintf( + $this->view->translate('%s on %s', 'Service running on host'), + $this->view->qlink( + $serviceLinkText, + $this->view->href('monitoring/service/show', array('host' => $host, 'service' => $service)) + ), + $this->host($host, $hostLinkText) + ); + } +} From d8b1e632319c307ea943c002004b1fc5331f999b Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Wed, 21 Jan 2015 15:47:10 +0100 Subject: [PATCH 0288/2920] monitoring: Support host and service display_name in the NotificationQuery refs #7843 --- .../Backend/Ido/Query/NotificationQuery.php | 49 +++++++++++++++---- 1 file changed, 40 insertions(+), 9 deletions(-) diff --git a/modules/monitoring/library/Monitoring/Backend/Ido/Query/NotificationQuery.php b/modules/monitoring/library/Monitoring/Backend/Ido/Query/NotificationQuery.php index 70962a1c0..3181eebbf 100644 --- a/modules/monitoring/library/Monitoring/Backend/Ido/Query/NotificationQuery.php +++ b/modules/monitoring/library/Monitoring/Backend/Ido/Query/NotificationQuery.php @@ -6,26 +6,32 @@ class NotificationQuery extends IdoQuery { protected $columnMap = array( 'notification' => array( - 'notification_output' => 'n.output', - 'notification_start_time' => 'UNIX_TIMESTAMP(n.start_time)', - 'notification_state' => 'n.state', - 'notification_object_id' => 'n.object_id' + 'notification_output' => 'n.output', + 'notification_start_time' => 'UNIX_TIMESTAMP(n.start_time)', + 'notification_state' => 'n.state', + 'notification_object_id' => 'n.object_id' ), 'objects' => array( - 'host' => 'o.name1', - 'service' => 'o.name2' + 'host' => 'o.name1', + 'service' => 'o.name2' ), 'contact' => array( - 'notification_contact' => 'c_o.name1', - 'contact_object_id' => 'c_o.object_id' + 'notification_contact' => 'c_o.name1', + 'contact_object_id' => 'c_o.object_id' ), 'command' => array( - 'notification_command' => 'cmd_o.name1' + 'notification_command' => 'cmd_o.name1' ), 'acknowledgement' => array( 'acknowledgement_entry_time' => 'UNIX_TIMESTAMP(a.entry_time)', 'acknowledgement_author_name' => 'a.author_name', 'acknowledgement_comment_data' => 'a.comment_data' + ), + 'hosts' => array( + 'host_display_name' => 'CASE WHEN sh.display_name IS NOT NULL THEN sh.display_name ELSE h.display_name END' + ), + 'services' => array( + 'service_display_name' => 's.display_name' ) ); @@ -100,4 +106,29 @@ class NotificationQuery extends IdoQuery array() ); } + + protected function joinHosts() + { + $this->select->joinLeft( + array('h' => $this->prefix . 'hosts'), + 'h.host_object_id = o.object_id', + array() + ); + return $this; + } + + protected function joinServices() + { + $this->select->joinLeft( + array('s' => $this->prefix . 'services'), + 's.service_object_id = o.object_id', + array() + ); + $this->select->joinLeft( + array('sh' => $this->prefix . 'hosts'), + 'sh.host_object_id = s.host_object_id', + array() + ); + return $this; + } } From ad879b1ee61de4ed78ad982293be2ee361bdc5ad Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Wed, 21 Jan 2015 15:47:36 +0100 Subject: [PATCH 0289/2920] monitoring: Select the host and service display_name columns in the Notification data view refs #7843 --- .../monitoring/library/Monitoring/DataView/Notification.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/modules/monitoring/library/Monitoring/DataView/Notification.php b/modules/monitoring/library/Monitoring/DataView/Notification.php index 6156a5f15..7f6fd238f 100644 --- a/modules/monitoring/library/Monitoring/DataView/Notification.php +++ b/modules/monitoring/library/Monitoring/DataView/Notification.php @@ -20,7 +20,9 @@ class Notification extends DataView 'notification_start_time', 'notification_contact', 'notification_output', - 'notification_command' + 'notification_command', + 'host_display_name', + 'service_display_name' ); } From 846f39108094788bc0c05b3557230ab411957946 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Wed, 21 Jan 2015 15:48:04 +0100 Subject: [PATCH 0290/2920] monitoring: Select the host and service display_name columns in the notifications overview refs #7843 --- modules/monitoring/application/controllers/ListController.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/modules/monitoring/application/controllers/ListController.php b/modules/monitoring/application/controllers/ListController.php index df7081519..8e8cfa766 100644 --- a/modules/monitoring/application/controllers/ListController.php +++ b/modules/monitoring/application/controllers/ListController.php @@ -325,7 +325,9 @@ class Monitoring_ListController extends Controller 'notification_output', 'notification_contact', 'notification_start_time', - 'notification_state' + 'notification_state', + 'host_display_name', + 'service_display_name' )); $this->filterQuery($query); $this->view->notifications = $query->paginate(); From ece6bfe6bbcaeb43d5c324daf91a1ded87c4b254 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Wed, 21 Jan 2015 15:48:45 +0100 Subject: [PATCH 0291/2920] monitoring: Use display_name for displaying the host and service name in the notifications overview refs #7843 --- .../views/scripts/list/notifications.phtml | 23 ++++++++----------- 1 file changed, 9 insertions(+), 14 deletions(-) diff --git a/modules/monitoring/application/views/scripts/list/notifications.phtml b/modules/monitoring/application/views/scripts/list/notifications.phtml index 939d46eba..5e337dd24 100644 --- a/modules/monitoring/application/views/scripts/list/notifications.phtml +++ b/modules/monitoring/application/views/scripts/list/notifications.phtml @@ -25,20 +25,13 @@ use Icinga\Module\Monitoring\Object\Service;
    service)) { - $isService = true; - $href = $this->href('monitoring/show/service', array( - 'host' => $notification->host, - 'service' => $notification->service - )); - $stateName = Service::getStateText($notification->notification_state); + $isService = true; + $stateName = Service::getStateText($notification->notification_state); } else { $isService = false; - $href = $this->href('monitoring/show/host', array( - 'host' => $notification->host - )); $stateName = Host::getStateText($notification->notification_state); } - ?> + ?>
    dateTimeRenderer($notification->notification_start_time)->render( @@ -49,12 +42,14 @@ use Icinga\Module\Monitoring\Object\Service; - translate('%s on %s'), - $this->qlink($notification->service, $href), $notification->host + link()->service( + $notification->service, + $notification->service_display_name, + $notification->host, + $notification->host_display_name ) ?> - qlink($notification->host, $href) ?> + link()->host($notification->host, $notification->host_display_name) ?>
    escape(substr(strip_tags($notification->notification_output), 0, 10000)); ?> From 0ceec816c6aec832f5abbea0d5de175b4fde5029 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Wed, 21 Jan 2015 15:49:36 +0100 Subject: [PATCH 0292/2920] monitoring: Use notifications default ordering when showing a contact --- modules/monitoring/application/controllers/ShowController.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/monitoring/application/controllers/ShowController.php b/modules/monitoring/application/controllers/ShowController.php index ba865deaa..d09a0ce83 100644 --- a/modules/monitoring/application/controllers/ShowController.php +++ b/modules/monitoring/application/controllers/ShowController.php @@ -166,7 +166,7 @@ class Monitoring_ShowController extends Controller 'notification_contact', 'notification_start_time', 'notification_state' - ))->order('notification_start_time'); + )); $notifications->where('contact_object_id', $contact->contact_object_id); From b6f87df90ea2f9e0ea602dc66c61cc88a4f4e827 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Wed, 21 Jan 2015 15:50:32 +0100 Subject: [PATCH 0293/2920] monitoring: Select the host and service display_name column when viewing notifications for a contact refs #7843 --- modules/monitoring/application/controllers/ShowController.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/modules/monitoring/application/controllers/ShowController.php b/modules/monitoring/application/controllers/ShowController.php index d09a0ce83..0b7a2f897 100644 --- a/modules/monitoring/application/controllers/ShowController.php +++ b/modules/monitoring/application/controllers/ShowController.php @@ -165,7 +165,9 @@ class Monitoring_ShowController extends Controller 'notification_output', 'notification_contact', 'notification_start_time', - 'notification_state' + 'notification_state', + 'host_display_name', + 'service_display_name' )); $notifications->where('contact_object_id', $contact->contact_object_id); From cbbd811adb9dc83dc1844182b77c8484f690fcf0 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Wed, 21 Jan 2015 15:51:14 +0100 Subject: [PATCH 0294/2920] monitoring: Do not strip_tags in the notifications overview --- .../application/views/scripts/list/notifications.phtml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/monitoring/application/views/scripts/list/notifications.phtml b/modules/monitoring/application/views/scripts/list/notifications.phtml index 5e337dd24..7f1de0fde 100644 --- a/modules/monitoring/application/views/scripts/list/notifications.phtml +++ b/modules/monitoring/application/views/scripts/list/notifications.phtml @@ -52,7 +52,7 @@ use Icinga\Module\Monitoring\Object\Service; link()->host($notification->host, $notification->host_display_name) ?>
    - escape(substr(strip_tags($notification->notification_output), 0, 10000)); ?> + escape(substr($notification->notification_output, 0, 10000)); ?>
    contact): ?> From 423e4c55a87237d68dc7f369c93a5797a0400c4c Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Wed, 21 Jan 2015 15:52:24 +0100 Subject: [PATCH 0295/2920] monitoring: Use the ellipsis view helper in the notifications overview --- .../application/views/scripts/list/notifications.phtml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/monitoring/application/views/scripts/list/notifications.phtml b/modules/monitoring/application/views/scripts/list/notifications.phtml index 7f1de0fde..299144821 100644 --- a/modules/monitoring/application/views/scripts/list/notifications.phtml +++ b/modules/monitoring/application/views/scripts/list/notifications.phtml @@ -52,7 +52,7 @@ use Icinga\Module\Monitoring\Object\Service; link()->host($notification->host, $notification->host_display_name) ?>
    - escape(substr($notification->notification_output, 0, 10000)); ?> + escape($this->ellipsis($notification->notification_output, 10000)) ?>
    contact): ?> From 439052ad973a6738b0e097cc7cd4c1d74ed8a5d2 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Wed, 21 Jan 2015 15:56:58 +0100 Subject: [PATCH 0296/2920] monitoring: Use the link helper in the downtimes overview --- .../views/scripts/list/downtimes.phtml | 24 +++++++------------ 1 file changed, 9 insertions(+), 15 deletions(-) diff --git a/modules/monitoring/application/views/scripts/list/downtimes.phtml b/modules/monitoring/application/views/scripts/list/downtimes.phtml index 98adb5883..485782e3c 100644 --- a/modules/monitoring/application/views/scripts/list/downtimes.phtml +++ b/modules/monitoring/application/views/scripts/list/downtimes.phtml @@ -31,8 +31,10 @@ use Icinga\Module\Monitoring\Object\Service; service)) { + $isService = true; $stateName = Service::getStateText($downtime->service_state); } else { + $isService = false; $stateName = Host::getStateText($downtime->host_state); } ?> @@ -52,22 +54,14 @@ use Icinga\Module\Monitoring\Object\Service; ?>
    - service)): ?> - icon('service'); ?> - escape($downtime->service_display_name) ?> - - - translate('on'); ?> escape($downtime->host_display_name) ?> - + + icon('service') ?> + link()->service( + $downtime->service, $downtime->service_display_name, $downtime->host, $downtime->host_display_name + ) ?> - icon('host'); ?> - escape($downtime->host_display_name) ?> - + icon('host') ?> + link()->host($downtime->host, $downtime->host_display_name) ?>
    icon('comment') ?> [escape($downtime->author) ?>] escape($downtime->comment) ?> From 9b7e67919fb954cf2517bf7f727a71eb6f5353f0 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Wed, 21 Jan 2015 15:59:20 +0100 Subject: [PATCH 0297/2920] monitoring: Use host and service icons in the notifications overview --- .../application/views/scripts/list/notifications.phtml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/modules/monitoring/application/views/scripts/list/notifications.phtml b/modules/monitoring/application/views/scripts/list/notifications.phtml index 299144821..44f33851f 100644 --- a/modules/monitoring/application/views/scripts/list/notifications.phtml +++ b/modules/monitoring/application/views/scripts/list/notifications.phtml @@ -42,6 +42,7 @@ use Icinga\Module\Monitoring\Object\Service;
    + icon('service') ?> link()->service( $notification->service, $notification->service_display_name, @@ -49,6 +50,7 @@ use Icinga\Module\Monitoring\Object\Service; $notification->host_display_name ) ?> + icon('host') ?> link()->host($notification->host, $notification->host_display_name) ?>
    From a91a2eba6895b16e50cdcdbeaf8fd3c9962b41eb Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Wed, 21 Jan 2015 16:09:13 +0100 Subject: [PATCH 0298/2920] monitoring: Support host and service display_name columns in the CommentQuery refs #7843 --- .../Backend/Ido/Query/CommentQuery.php | 31 +++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/modules/monitoring/library/Monitoring/Backend/Ido/Query/CommentQuery.php b/modules/monitoring/library/Monitoring/Backend/Ido/Query/CommentQuery.php index 5145a96ad..a522d702e 100644 --- a/modules/monitoring/library/Monitoring/Backend/Ido/Query/CommentQuery.php +++ b/modules/monitoring/library/Monitoring/Backend/Ido/Query/CommentQuery.php @@ -23,6 +23,12 @@ class CommentQuery extends IdoQuery 'comment_service' => 'so.name2 COLLATE latin1_general_ci', 'service' => 'so.name2 COLLATE latin1_general_ci', // #7278, #7279 'comment_objecttype' => "CASE WHEN ho.object_id IS NOT NULL THEN 'host' ELSE CASE WHEN so.object_id IS NOT NULL THEN 'service' ELSE NULL END END", + ), + 'hosts' => array( + 'host_display_name' => 'CASE WHEN sh.display_name IS NOT NULL THEN sh.display_name ELSE h.display_name END' + ), + 'services' => array( + 'service_display_name' => 's.display_name' ) ); @@ -44,4 +50,29 @@ class CommentQuery extends IdoQuery ); $this->joinedVirtualTables = array('comments' => true); } + + protected function joinHosts() + { + $this->select->joinLeft( + array('h' => $this->prefix . 'hosts'), + 'h.host_object_id = ho.object_id', + array() + ); + return $this; + } + + protected function joinServices() + { + $this->select->joinLeft( + array('s' => $this->prefix . 'services'), + 's.service_object_id = so.object_id', + array() + ); + $this->select->joinLeft( + array('sh' => $this->prefix . 'hosts'), + 'sh.host_object_id = s.host_object_id', + array() + ); + return $this; + } } From 94be58e121f71c9cba9409c8b5d1e9d93bcb6117 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Wed, 21 Jan 2015 16:09:36 +0100 Subject: [PATCH 0299/2920] monitoring: Support host and service display_name columns in the Comment data view refs #7843 --- modules/monitoring/library/Monitoring/DataView/Comment.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/modules/monitoring/library/Monitoring/DataView/Comment.php b/modules/monitoring/library/Monitoring/DataView/Comment.php index 4d62fd27c..08928b5dd 100644 --- a/modules/monitoring/library/Monitoring/DataView/Comment.php +++ b/modules/monitoring/library/Monitoring/DataView/Comment.php @@ -29,6 +29,8 @@ class Comment extends DataView 'comment_service', 'host', 'service', + 'host_display_name', + 'service_display_name' ); } From e933b9174c76611919c9ed80332d45723903e4f0 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Wed, 21 Jan 2015 16:10:02 +0100 Subject: [PATCH 0300/2920] monitoring: Select the host and service display_name columns in the comments overview refs #7843 --- modules/monitoring/application/controllers/ListController.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/modules/monitoring/application/controllers/ListController.php b/modules/monitoring/application/controllers/ListController.php index 8e8cfa766..df12ff1f8 100644 --- a/modules/monitoring/application/controllers/ListController.php +++ b/modules/monitoring/application/controllers/ListController.php @@ -465,7 +465,9 @@ class Monitoring_ListController extends Controller 'persistent' => 'comment_is_persistent', 'expiration' => 'comment_expiration', 'host' => 'comment_host', - 'service' => 'comment_service' + 'service' => 'comment_service', + 'host_display_name', + 'service_display_name' )); $this->filterQuery($query); $this->view->comments = $query->paginate(); From cf391b056c99b4c111059965e7da5225cdf0d66c Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Wed, 21 Jan 2015 16:12:37 +0100 Subject: [PATCH 0301/2920] monitoring: Use display_name for displaying the host and service names in the comments overview refs #7843 --- .../views/scripts/list/comments.phtml | 20 ++++++------------- 1 file changed, 6 insertions(+), 14 deletions(-) diff --git a/modules/monitoring/application/views/scripts/list/comments.phtml b/modules/monitoring/application/views/scripts/list/comments.phtml index 677010f1b..29fc76d49 100644 --- a/modules/monitoring/application/views/scripts/list/comments.phtml +++ b/modules/monitoring/application/views/scripts/list/comments.phtml @@ -50,21 +50,13 @@
    objecttype === 'service'): ?> - icon('conf'); ?> - service; ?> - - - translate('on') . ' ' . $comment->host; ?> - + icon('service') ?> + link()->service( + $comment->service, $comment->service_display_name, $comment->host, $comment->host_display_name + ) ?> - icon('host'); ?> - host; ?> - + icon('host') ?> + link()->host($comment->host, $comment->host_display_name) ?>
    icon('comment'); ?> author) From 3055531e2db7f01ded2578f025c13977c5b7c2df Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Wed, 21 Jan 2015 16:15:09 +0100 Subject: [PATCH 0302/2920] monitoring: Support sorting by host and service display name in the Comment data view refs #7843 --- .../library/Monitoring/DataView/Comment.php | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/modules/monitoring/library/Monitoring/DataView/Comment.php b/modules/monitoring/library/Monitoring/DataView/Comment.php index 08928b5dd..4cd11e1a1 100644 --- a/modules/monitoring/library/Monitoring/DataView/Comment.php +++ b/modules/monitoring/library/Monitoring/DataView/Comment.php @@ -45,13 +45,20 @@ class Comment extends DataView 'comment_timestamp' => array( 'order' => self::SORT_DESC ), - 'comment_host' => array( + 'host_display_name' => array( 'columns' => array( - 'comment_host', - 'comment_service' + 'host_display_name', + 'service_display_name' ), 'order' => self::SORT_ASC ), + 'service_display_name' => array( + 'columns' => array( + 'service_display_name', + 'host_display_name' + ), + 'order' => self::SORT_ASC + ) ); } } From 6be0224d9d524786af9489ac0bd324bcb163da0b Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Wed, 21 Jan 2015 16:15:38 +0100 Subject: [PATCH 0303/2920] monitoring: Add sort by 'Host' and 'Service' in the comments overview refs #7843 --- .../application/controllers/ListController.php | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/modules/monitoring/application/controllers/ListController.php b/modules/monitoring/application/controllers/ListController.php index df12ff1f8..f5afc9a24 100644 --- a/modules/monitoring/application/controllers/ListController.php +++ b/modules/monitoring/application/controllers/ListController.php @@ -474,10 +474,11 @@ class Monitoring_ListController extends Controller $this->setupSortControl( array( - 'comment_timestamp' => $this->translate('Comment Timestamp'), - 'comment_host' => $this->translate('Host / Service'), - 'comment_type' => $this->translate('Comment Type'), - 'comment_expiration' => $this->translate('Expiration'), + 'comment_timestamp' => $this->translate('Comment Timestamp'), + 'host_display_name' => $this->translate('Host'), + 'service_display_name' => $this->translate('Service'), + 'comment_type' => $this->translate('Comment Type'), + 'comment_expiration' => $this->translate('Expiration') ) ); $this->view->delCommentForm = new DeleteCommentCommandForm(); From 913143f3a804802686143979ef3f46f587cf118e Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Wed, 21 Jan 2015 16:52:38 +0100 Subject: [PATCH 0304/2920] Update the SummaryPage's description A summary page isn't an indicator anymore for a complete wizard as there are multiple summary pages now. refs #8191 --- .../setup/application/views/scripts/form/setup-summary.phtml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/setup/application/views/scripts/form/setup-summary.phtml b/modules/setup/application/views/scripts/form/setup-summary.phtml index 676dcd52f..e8053a897 100644 --- a/modules/setup/application/views/scripts/form/setup-summary.phtml +++ b/modules/setup/application/views/scripts/form/setup-summary.phtml @@ -5,7 +5,7 @@ use Icinga\Web\Wizard; ?>

    translate( - 'The wizard is now complete. You can review the changes supposed to be made before setting up %1$s.' + 'You\'ve configured %1$s successfully. You can review the changes supposed to be made before setting it up.' . ' Make sure that everything is correct (Feel free to navigate back to make any corrections!) so' . ' that you can start using %1$s right after it has successfully been set up.' ), From 71fd1036deafd6ed12a2b5c02366f59fc1d84ee3 Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Wed, 21 Jan 2015 16:57:08 +0100 Subject: [PATCH 0305/2920] Pre-select the monitoring module in the setup wizard It's TEH module!!1 refs #8191 --- modules/setup/application/forms/ModulePage.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/modules/setup/application/forms/ModulePage.php b/modules/setup/application/forms/ModulePage.php index 596a5d762..7add2bb81 100644 --- a/modules/setup/application/forms/ModulePage.php +++ b/modules/setup/application/forms/ModulePage.php @@ -34,7 +34,8 @@ class ModulePage extends Form 'checkbox', $module->getName(), array( - 'label' => ucfirst($module->getName()) + 'label' => ucfirst($module->getName()), + 'value' => $module->getName() === 'monitoring' ? 1 : 0 ) ); $this->addElement( From 1ee873adfc031689f83d295619aaea584dd0e07a Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Wed, 21 Jan 2015 17:00:30 +0100 Subject: [PATCH 0306/2920] Remove the "old" ModulePage view script refs #8191 --- .../views/scripts/form/setup-modules.phtml | 47 ------------- public/css/icinga/setup.less | 69 ------------------- 2 files changed, 116 deletions(-) delete mode 100644 modules/setup/application/views/scripts/form/setup-modules.phtml diff --git a/modules/setup/application/views/scripts/form/setup-modules.phtml b/modules/setup/application/views/scripts/form/setup-modules.phtml deleted file mode 100644 index 304aad9b8..000000000 --- a/modules/setup/application/views/scripts/form/setup-modules.phtml +++ /dev/null @@ -1,47 +0,0 @@ - -

    -

    translate('The following modules can be set up by using a web-based wizard as well. To setup a module, just complete its wizard and advance to the summary!'); ?>

    -

    translate('You can freely switch to a module\'s wizard by clicking its name below. The wizard you are currently looking at is written in bold. A small tick is shown on the right once a wizard has been completed.'); ?>

    - - getElement($form->getTokenElementName()); ?> - getElement($form->getUidElementName()); ?> -
      - - getModules() as $module): ?> - providesSetupWizard()): ?> -
    • - getName() === $form->getCurrentModule(); ?> - - getSetupWizard()->isFinished()): ?> - icon('ok', $this->translate('Completed', 'setup.modules.wizard.state')); ?> - - - -
    • - - -
    - - -

    translate('You\'ve completed all module wizards!'); ?>

    - -

    translate('Note that you can skip a specific module by just not completing its wizard.'); ?>

    - -
    -
    - getCurrentWizard()->getForm()->render(); ?> -
    -
    - getElement($form->getTokenElementName()); ?> - getElement($form->getUidElementName()); ?> -
    - getElement(Wizard::BTN_PREV); ?> - getElement(Wizard::BTN_NEXT); ?> -
    -
    diff --git a/public/css/icinga/setup.less b/public/css/icinga/setup.less index 8ca669bdd..0f69355b3 100644 --- a/public/css/icinga/setup.less +++ b/public/css/icinga/setup.less @@ -394,72 +394,3 @@ margin-top: 0; } } - -#setup { - div.module-wizard { - width: auto; - padding: 1em; - overflow: hidden; - border: solid 1px lightgrey; - - div.buttons { - margin: 1.5em 0 0; - float: right; - - button[type=submit] { - padding: 0.5em; - line-height: 0.5em; - background-color: @colorPetrol; - - &:hover, &:focus, &:active { - background-color: #666; - } - } - } - } - - div.module-menu { - font-size: 0.9em; - width: 25%; - float: right; - margin-left: 1.5em; - - p { - margin-top: 0; - - &.all-completed { - .conspicuous-state-notification; - text-align: center; - font-size: 90%; - background-color: @colorOk; - } - } - - ul { - padding-left: 1.2em; - - button { - margin: 0 0 0.8em; - padding: 0; - color: black; - border: none; - outline: none; - font-size: 90%; - background-color: white; - - &:hover { - color: #666; - cursor: pointer; - } - - &:focus, &:active { - color: #666; - } - } - - img { - margin: 0 0.5em 0.2em; - } - } - } -} From d064b0ac791266716b1f04298c544a954266c3a0 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Wed, 21 Jan 2015 17:29:31 +0100 Subject: [PATCH 0307/2920] monitoring: Rename $showService to $isService in the header view script Most views use $isService to set whether we are about to show a service. --- .../application/views/scripts/show/components/header.phtml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/modules/monitoring/application/views/scripts/show/components/header.phtml b/modules/monitoring/application/views/scripts/show/components/header.phtml index ccf7d2d5e..25ed83cfd 100644 --- a/modules/monitoring/application/views/scripts/show/components/header.phtml +++ b/modules/monitoring/application/views/scripts/show/components/header.phtml @@ -3,7 +3,7 @@ use Icinga\Module\Monitoring\Object\Host; use Icinga\Module\Monitoring\Object\Service; -$showService = $object->getType() === $object::TYPE_SERVICE; +$isService = $object->getType() === $object::TYPE_SERVICE; ?> compact): ?> @@ -11,7 +11,7 @@ $showService = $object->getType() === $object::TYPE_SERVICE; - @@ -21,7 +21,7 @@ $showService = $object->getType() === $object::TYPE_SERVICE; - + From e61edaaffbfe88b38e5eb949e2a5ac189ee1ed0f Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Thu, 22 Jan 2015 10:30:55 +0100 Subject: [PATCH 0311/2920] monitoring: Show service_description in the detail area too if it's different from the display_name refs #7843 --- .../application/views/scripts/show/components/header.phtml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/modules/monitoring/application/views/scripts/show/components/header.phtml b/modules/monitoring/application/views/scripts/show/components/header.phtml index b6ed49ed5..f0c118539 100644 --- a/modules/monitoring/application/views/scripts/show/components/header.phtml +++ b/modules/monitoring/application/views/scripts/show/components/header.phtml @@ -32,6 +32,9 @@ $isService = $object->getType() === $object::TYPE_SERVICE; From 4539462bc7039d1cbc0dbfe9b8c8781d69a72bf7 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Thu, 22 Jan 2015 10:34:35 +0100 Subject: [PATCH 0312/2920] monitoring: Select host_display_name in the host and service object refs #7843 --- modules/monitoring/library/Monitoring/Object/Host.php | 1 + modules/monitoring/library/Monitoring/Object/Service.php | 1 + 2 files changed, 2 insertions(+) diff --git a/modules/monitoring/library/Monitoring/Object/Host.php b/modules/monitoring/library/Monitoring/Object/Host.php index 79a760d82..eeac94cb9 100644 --- a/modules/monitoring/library/Monitoring/Object/Host.php +++ b/modules/monitoring/library/Monitoring/Object/Host.php @@ -91,6 +91,7 @@ class Host extends MonitoredObject { $columns = array( 'host_name', + 'host_display_name', 'host_alias', 'host_address', 'host_state', diff --git a/modules/monitoring/library/Monitoring/Object/Service.php b/modules/monitoring/library/Monitoring/Object/Service.php index 64bfe530b..3b7bff4fa 100644 --- a/modules/monitoring/library/Monitoring/Object/Service.php +++ b/modules/monitoring/library/Monitoring/Object/Service.php @@ -108,6 +108,7 @@ class Service extends MonitoredObject { return $this->backend->select()->from('serviceStatus', array( 'host_name', + 'host_display_name', 'host_state', 'host_state_type', 'host_last_state_change', From 3d306c0a060bebd06622c236978fc78a4f5b9eec Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Thu, 22 Jan 2015 10:35:06 +0100 Subject: [PATCH 0313/2920] monitoring: Use display_name for displaying the host name in the detail area refs #7843 --- .../application/views/scripts/show/components/header.phtml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/modules/monitoring/application/views/scripts/show/components/header.phtml b/modules/monitoring/application/views/scripts/show/components/header.phtml index f0c118539..ad0a773ff 100644 --- a/modules/monitoring/application/views/scripts/show/components/header.phtml +++ b/modules/monitoring/application/views/scripts/show/components/header.phtml @@ -18,9 +18,10 @@ $isService = $object->getType() === $object::TYPE_SERVICE; prefixedTimeSince($object->host_last_state_change, true) ?> From 9e5d7f43ff2167ea46a5f8d579e127e57c323301 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Thu, 22 Jan 2015 10:36:02 +0100 Subject: [PATCH 0314/2920] monitoring: Show host_name in the detail area too if it's different from the display_name refs #7843 --- .../application/views/scripts/show/components/header.phtml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/modules/monitoring/application/views/scripts/show/components/header.phtml b/modules/monitoring/application/views/scripts/show/components/header.phtml index ad0a773ff..cfd093473 100644 --- a/modules/monitoring/application/views/scripts/show/components/header.phtml +++ b/modules/monitoring/application/views/scripts/show/components/header.phtml @@ -19,6 +19,9 @@ $isService = $object->getType() === $object::TYPE_SERVICE; From a64f546a7132d845d6dd8d0bd348770c579fbd08 Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Mon, 23 Feb 2015 17:24:22 +0100 Subject: [PATCH 0771/2920] Add proper titles to the host list view refs #8458 --- .../application/views/scripts/list/hosts.phtml | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/modules/monitoring/application/views/scripts/list/hosts.phtml b/modules/monitoring/application/views/scripts/list/hosts.phtml index b9fa25975..f5689c927 100644 --- a/modules/monitoring/application/views/scripts/list/hosts.phtml +++ b/modules/monitoring/application/views/scripts/list/hosts.phtml @@ -96,11 +96,18 @@ if ($hosts->count() === 0) { icon($this->resolveMacros($host->host_icon_image, $host)) ?> - escape($host->host_display_name) ?> + qlink( + $host->host_display_name, + $hostLink, + null, + array( + 'title' => sprintf($this->translate('Show detailed information for host %s'), $host->host_display_name) + ) + ); ?> host_unhandled_services) && $host->host_unhandled_services > 0): ?> (qlink( sprintf( - $this->translatePlural('%d unhandled service', '%d unhandled services', $host->host_unhandled_services), + $this->translatePlural('%u unhandled service', '%u unhandled services', $host->host_unhandled_services), $host->host_unhandled_services ), 'monitoring/show/services', @@ -113,8 +120,8 @@ if ($hosts->count() === 0) { 'style' => 'font-weight: normal', 'title' => sprintf( $this->translatePlural( - 'List %s service problem on host %s', - 'List %s service problems on host %s', + 'List %s unhandled service problem on host %s', + 'List %s unhandled service problems on host %s', $host->host_unhandled_services ), $host->host_unhandled_services, From c4aa02c3f00658a2521ad6cc25871723086fc5a9 Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Mon, 23 Feb 2015 17:24:46 +0100 Subject: [PATCH 0772/2920] Add proper titles to the service grid refs #8458 --- .../views/scripts/list/servicegrid.phtml | 57 ++++++++++++++----- 1 file changed, 42 insertions(+), 15 deletions(-) diff --git a/modules/monitoring/application/views/scripts/list/servicegrid.phtml b/modules/monitoring/application/views/scripts/list/servicegrid.phtml index dd9be0394..a102c36eb 100644 --- a/modules/monitoring/application/views/scripts/list/servicegrid.phtml +++ b/modules/monitoring/application/views/scripts/list/servicegrid.phtml @@ -37,18 +37,23 @@ $hostFilter = '(host_name=' . implode('|host_name=', array_keys($pivotData)) . ' ); ?> - + From ebdf68550b86e53d21268226c2077ec7daac1c8f Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Mon, 23 Feb 2015 17:25:02 +0100 Subject: [PATCH 0773/2920] Add proper titles to the servicegroups view refs #8458 --- .../views/scripts/list/servicegroups.phtml | 217 ++++++++++-------- 1 file changed, 118 insertions(+), 99 deletions(-) diff --git a/modules/monitoring/application/views/scripts/list/servicegroups.phtml b/modules/monitoring/application/views/scripts/list/servicegroups.phtml index 04e6975e1..0e958a3f7 100644 --- a/modules/monitoring/application/views/scripts/list/servicegroups.phtml +++ b/modules/monitoring/application/views/scripts/list/servicegroups.phtml @@ -79,9 +79,12 @@ From f11ad1183a7260a477bd3135153dd9bac9e97658 Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Mon, 23 Feb 2015 17:25:23 +0100 Subject: [PATCH 0774/2920] Add proper titles to the service list view refs #8458 --- .../views/scripts/list/services.phtml | 22 ++++++++++++++----- 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/modules/monitoring/application/views/scripts/list/services.phtml b/modules/monitoring/application/views/scripts/list/services.phtml index e8d39c7c3..3b17e1b63 100644 --- a/modules/monitoring/application/views/scripts/list/services.phtml +++ b/modules/monitoring/application/views/scripts/list/services.phtml @@ -102,13 +102,23 @@ foreach ($services as $service): service_icon_image && ! preg_match('/[\'"]/', $service->service_icon_image)): ?> - icon($this->resolveMacros($service->service_icon_image, $service)) ?> + icon($this->resolveMacros($service->service_icon_image, $service)) ?> -escape($service->service_display_name) ?>showHost): ?> on escape($service->host_display_name) ?> -host_state != 0): ?> - (host_state, true); ?>) - -
    + qlink( + $service->service_display_name, + $serviceLink, + null, + array('title' => sprintf( + $this->translate('Show detailed information for service %s on host %s'), + $service->service_display_name, + $service->host_display_name + )) + ); ?>showHost): ?> on qlink( + $service->host_display_name . ($service->host_state != 0 ? ' (' . Host::getStateText($service->host_state, true) . ')' : ''), + $hostLink, + null, + array('title' => sprintf($this->translate('Show detailed information for host %s'), $service->host_display_name)) + ); ?>

    escape($this->ellipsis($service->service_output, 10000)); ?>

    extraColumns as $col): ?> From 598294d2a2041e22cdaaedac7e8069b240127be2 Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Mon, 23 Feb 2015 17:25:55 +0100 Subject: [PATCH 0775/2920] Add proper titles to the servicesummary partial refs #8458 --- .../partials/host/servicesummary.phtml | 99 +++++++++++++++---- 1 file changed, 79 insertions(+), 20 deletions(-) diff --git a/modules/monitoring/application/views/scripts/partials/host/servicesummary.phtml b/modules/monitoring/application/views/scripts/partials/host/servicesummary.phtml index d45415c72..c0acdead4 100644 --- a/modules/monitoring/application/views/scripts/partials/host/servicesummary.phtml +++ b/modules/monitoring/application/views/scripts/partials/host/servicesummary.phtml @@ -1,23 +1,54 @@ $this->object->host_name)); +$selfUrl = Url::fromPath('monitoring/show/services', array('host' => $object->host_name)); $currentUrl = Url::fromRequest()->without('limit')->getRelativeUrl(); -?>
    compact ? ' data-base-target="col1"' : '' ?>> -stats->services_total > 0): ?> -qlink(sprintf($this->translatePlural('%d configured service:', '%d configured services:', $object->stats->services_total), $object->stats->services_total), $selfUrl) ?> +?>
    compact ? ' data-base-target="col1"' : ''; ?>> +stats->services_total): ?> +qlink( + sprintf( + $this->translatePlural( + '%u configured service:', + '%u configured services:', + $object->stats->services_total + ), + $object->stats->services_total + ), + $selfUrl, + null, + array('title' => sprintf( + $this->translatePlural( + 'List all %u service on host %s', + 'List all %u services on host %s', + $object->stats->services_total + ), + $object->stats->services_total, + $object->host_name + )) +); ?> translate('No services configured on this host'); ?> -stats->services_ok > 0): ?> - qlink( - $object->stats->services_ok, - $selfUrl, - array('service_state' => 0), - array('title' => sprintf($this->translate('Services with state %s'), $this->translate('OK'))) -) ?> +stats->services_ok): ?> + + qlink( + $object->stats->services_ok, + $selfUrl, + array('service_state' => 0), + array('title' => sprintf( + $this->translatePlural( + 'List %u service that is currently in state OK on host %s', + 'List %u services which are currently in state OK on host %s', + $object->stats->services_ok + ), + $object->stats->services_ok, + $object->host_name + )) + ); ?> + 'critical', 3 => 'unknown', 1 => 'warning') as $stateId => $state) { @@ -46,7 +77,16 @@ foreach (array(2 => 'critical', 3 => 'unknown', 1 => 'warning') as $stateId => $ $object->stats->$unhandled, $selfUrl, $paramsUnhandled, - array('title' => sprintf($this->translate('Unhandled services with state %s'), $this->translate(strtoupper($state)))) + array('title' => sprintf( + $this->translatePlural( + 'List %u service that is currently in state %s on host %s', + 'List %u services which are currently in state %s on host %s', + $object->stats->$unhandled + ), + $object->stats->$unhandled, + Service::getStateText($stateId, true), + $object->host_name + )) ); } if ($object->stats->$handled) { @@ -63,7 +103,16 @@ foreach (array(2 => 'critical', 3 => 'unknown', 1 => 'warning') as $stateId => $ $object->stats->$handled, $selfUrl, $paramsHandled, - array('title' => sprintf($this->translate('Handled services with state %s'), $this->translate(strtoupper($state)))) + array('title' => sprintf( + $this->translatePlural( + 'List %u service that is currently in state %s (Acknowledged) on host %s', + 'List %u services which are currently in state %s (Acknowledged) on host %s', + $object->stats->$handled + ), + $object->stats->$handled, + Service::getStateText($stateId, true), + $object->host_name + )) ); if ($object->stats->$unhandled) { echo "\n"; @@ -74,12 +123,22 @@ foreach (array(2 => 'critical', 3 => 'unknown', 1 => 'warning') as $stateId => $ } ?> stats->services_pending): ?> - qlink( - $object->stats->services_pending, - $selfUrl, - array('service_state' => 99), - array('title' => sprintf($this->translate('Services with state %s'), $this->translate('PENDING'))) -) ?> + + qlink( + $object->stats->services_pending, + $selfUrl, + array('service_state' => 99), + array('title' => sprintf( + $this->translatePlural( + 'List %u service that is currently in state PENDING on host %s', + 'List %u services which are currently in state PENDING on host %s', + $object->stats->services_pending + ), + $object->stats->services_pending, + $object->host_name + )) + ) ?> + -
    +
    \ No newline at end of file From 74360ee8e616a7dbcb4a8b3877294396205e5a39 Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Mon, 23 Feb 2015 17:26:21 +0100 Subject: [PATCH 0776/2920] Add proper titles to the acknowledgements component view refs #8458 --- .../scripts/show/components/acknowledgement.phtml | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/modules/monitoring/application/views/scripts/show/components/acknowledgement.phtml b/modules/monitoring/application/views/scripts/show/components/acknowledgement.phtml index 8da35590f..e5f85c021 100644 --- a/modules/monitoring/application/views/scripts/show/components/acknowledgement.phtml +++ b/modules/monitoring/application/views/scripts/show/components/acknowledgement.phtml @@ -35,9 +35,15 @@ if ($object->acknowledged): ?> ); } ?> - - icon('ok') ?> translate('Acknowledge') ?> - + qlink( + $this->icon('ok') . ' ' . $this->translate('Acknowledge'), + $ackLink, + null, + array('title' => $this->translate( + 'Acknowledge this problem, suppress all future notifications for it and tag it as being handled' + )), + false + ); ?> From 25e2baa566d413e46d2d3aee6fad64d1af631f1e Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Mon, 23 Feb 2015 17:26:42 +0100 Subject: [PATCH 0777/2920] Add proper titles to the checkstatistics component view refs #8458 --- .../show/components/checkstatistics.phtml | 32 ++++++++++++------- 1 file changed, 21 insertions(+), 11 deletions(-) diff --git a/modules/monitoring/application/views/scripts/show/components/checkstatistics.phtml b/modules/monitoring/application/views/scripts/show/components/checkstatistics.phtml index ec0c2792a..7feab9339 100644 --- a/modules/monitoring/application/views/scripts/show/components/checkstatistics.phtml +++ b/modules/monitoring/application/views/scripts/show/components/checkstatistics.phtml @@ -28,23 +28,33 @@ if ($object->getType() === $object::TYPE_HOST) {
    From 89ed498069e8b53bcdf4a23979d41b49d58384e4 Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Mon, 23 Feb 2015 17:26:56 +0100 Subject: [PATCH 0778/2920] Add proper titles to the command component view refs #8458 --- .../scripts/show/components/command.phtml | 31 ++++++++++--------- 1 file changed, 17 insertions(+), 14 deletions(-) diff --git a/modules/monitoring/application/views/scripts/show/components/command.phtml b/modules/monitoring/application/views/scripts/show/components/command.phtml index a74b5b884..771e0812c 100644 --- a/modules/monitoring/application/views/scripts/show/components/command.phtml +++ b/modules/monitoring/application/views/scripts/show/components/command.phtml @@ -6,26 +6,29 @@ $command = array_shift($parts); ?> - + From 9793bd52c7033995d635eefb2617330bcef12348 Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Mon, 23 Feb 2015 17:27:13 +0100 Subject: [PATCH 0779/2920] Add proper titles to the comments component view refs #8458 --- .../scripts/show/components/comments.phtml | 31 ++++++++++++------- 1 file changed, 19 insertions(+), 12 deletions(-) diff --git a/modules/monitoring/application/views/scripts/show/components/comments.phtml b/modules/monitoring/application/views/scripts/show/components/comments.phtml index a6503a70b..74da7d054 100644 --- a/modules/monitoring/application/views/scripts/show/components/comments.phtml +++ b/modules/monitoring/application/views/scripts/show/components/comments.phtml @@ -1,27 +1,34 @@ - + From 3a74ec3d09ed746039baf6c4e912d56c16bad017 Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Mon, 23 Feb 2015 17:27:27 +0100 Subject: [PATCH 0780/2920] Add proper titles to the contacts component view refs #8458 --- .../views/scripts/show/components/contacts.phtml | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/modules/monitoring/application/views/scripts/show/components/contacts.phtml b/modules/monitoring/application/views/scripts/show/components/contacts.phtml index 50b173381..c00714e9c 100644 --- a/modules/monitoring/application/views/scripts/show/components/contacts.phtml +++ b/modules/monitoring/application/views/scripts/show/components/contacts.phtml @@ -4,9 +4,12 @@ if (! empty($object->contacts)) { $list = array(); foreach ($object->contacts as $contact) { - $list[] = $this->qlink($contact->contact_alias, 'monitoring/show/contact', array( - 'contact' => $contact->contact_name - )); + $list[] = $this->qlink( + $contact->contact_alias, + 'monitoring/show/contact', + array('contact' => $contact->contact_name), + array('title' => sprintf($this->translate('Show detailed information about %s'), $contact->contact_alias)) + ); } printf( @@ -24,7 +27,8 @@ if (! empty($object->contactgroups)) { $list[] = $this->qlink( $contactgroup->contactgroup_alias, 'monitoring/list/contactgroups', - array('contactgroup' => $contactgroup->contactgroup_name) + array('contactgroup' => $contactgroup->contactgroup_name), + array('title' => sprintf($this->translate('List contacts in contact-group "%s"'), $contactgroup->contactgroup_alias)) ); } From 0d8bf462f5142fbc69ec59ef13aea99adc8bc44b Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Mon, 23 Feb 2015 17:27:45 +0100 Subject: [PATCH 0781/2920] Add proper titles to the downtime component view refs #8458 --- .../scripts/show/components/downtime.phtml | 35 ++++++++++++------- 1 file changed, 23 insertions(+), 12 deletions(-) diff --git a/modules/monitoring/application/views/scripts/show/components/downtime.phtml b/modules/monitoring/application/views/scripts/show/components/downtime.phtml index 4aa1e21c1..16f12f6ba 100644 --- a/modules/monitoring/application/views/scripts/show/components/downtime.phtml +++ b/modules/monitoring/application/views/scripts/show/components/downtime.phtml @@ -1,27 +1,38 @@ - + From 7247ea5191ad34231468c7726918a5588c9697e9 Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Mon, 23 Feb 2015 17:28:02 +0100 Subject: [PATCH 0782/2920] Add proper titles to the hostgroups component view refs #8458 --- .../views/scripts/show/components/hostgroups.phtml | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/modules/monitoring/application/views/scripts/show/components/hostgroups.phtml b/modules/monitoring/application/views/scripts/show/components/hostgroups.phtml index 165df627a..eed1ea328 100644 --- a/modules/monitoring/application/views/scripts/show/components/hostgroups.phtml +++ b/modules/monitoring/application/views/scripts/show/components/hostgroups.phtml @@ -4,9 +4,12 @@ if (empty($object->hostgroups)) return; $list = array(); foreach ($object->hostgroups as $name => $alias) { - $list[] = $this->qlink($alias, 'monitoring/list/hosts', array( - 'hostgroup' => $name - )); + $list[] = $this->qlink( + $alias, + 'monitoring/list/hosts', + array('hostgroup' => $name), + array('title' => sprintf($this->translate('List all hosts in the group "%s"'), $alias)) + ); } printf( "\n", From 18f6ff8702755ac0eaad9de5bf0dd8b3a08aaf41 Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Mon, 23 Feb 2015 17:28:20 +0100 Subject: [PATCH 0783/2920] Add proper titles to the servicegroups component view refs #8458 --- .../views/scripts/show/components/servicegroups.phtml | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/modules/monitoring/application/views/scripts/show/components/servicegroups.phtml b/modules/monitoring/application/views/scripts/show/components/servicegroups.phtml index 50b71d839..093e03286 100644 --- a/modules/monitoring/application/views/scripts/show/components/servicegroups.phtml +++ b/modules/monitoring/application/views/scripts/show/components/servicegroups.phtml @@ -4,9 +4,12 @@ if (empty($object->servicegroups)) return; $list = array(); foreach ($object->servicegroups as $name => $alias) { - $list[] = $this->qlink($alias, 'monitoring/list/services', array( - 'servicegroup' => $name - )); + $list[] = $this->qlink( + $alias, + 'monitoring/list/services', + array('servicegroup' => $name), + array('title' => sprintf($this->translate('List all services in the group "%s"'), $alias)) + ); } printf( From 8991b7ed83d779cff61d890d2e9d887161d1986c Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Mon, 23 Feb 2015 17:29:22 +0100 Subject: [PATCH 0784/2920] Add proper titles to the tactical overview refs #8458 --- .../components/hostservicechecks.phtml | 144 ++++-- .../components/monitoringfeatures.phtml | 274 +++++++--- .../tactical/components/ok_hosts.phtml | 42 +- .../servicestatesummarybyhoststate.phtml | 480 +++++++++++------- .../tactical/components/problem_hosts.phtml | 46 +- 5 files changed, 654 insertions(+), 332 deletions(-) diff --git a/modules/monitoring/application/views/scripts/tactical/components/hostservicechecks.phtml b/modules/monitoring/application/views/scripts/tactical/components/hostservicechecks.phtml index 64265304d..b85199962 100644 --- a/modules/monitoring/application/views/scripts/tactical/components/hostservicechecks.phtml +++ b/modules/monitoring/application/views/scripts/tactical/components/hostservicechecks.phtml @@ -12,66 +12,114 @@ diff --git a/modules/monitoring/application/views/scripts/tactical/components/monitoringfeatures.phtml b/modules/monitoring/application/views/scripts/tactical/components/monitoringfeatures.phtml index 36b88b050..a67e9057c 100644 --- a/modules/monitoring/application/views/scripts/tactical/components/monitoringfeatures.phtml +++ b/modules/monitoring/application/views/scripts/tactical/components/monitoringfeatures.phtml @@ -11,58 +11,112 @@ @@ -78,42 +132,70 @@ @@ -129,42 +211,70 @@ diff --git a/modules/monitoring/application/views/scripts/tactical/components/ok_hosts.phtml b/modules/monitoring/application/views/scripts/tactical/components/ok_hosts.phtml index cc9328262..8deebf19e 100644 --- a/modules/monitoring/application/views/scripts/tactical/components/ok_hosts.phtml +++ b/modules/monitoring/application/views/scripts/tactical/components/ok_hosts.phtml @@ -10,18 +10,40 @@ $service_problems = ( ?>
    statusSummary->hosts_up): ?> -

    - - translatePlural('%d Host UP', '%d Hosts UP', $this->statusSummary->hosts_up), $this->statusSummary->hosts_up); ?> - -

    +

    qlink( + sprintf( + $this->translatePlural('%u Host UP', '%u Hosts UP', $this->statusSummary->hosts_up), + $this->statusSummary->hosts_up + ), + 'monitoring/list/hosts', + array('host_state' => 0), + array('title' => sprintf( + $this->translatePlural( + 'List %u host that is currently in state UP', + 'List %u hosts which are currently in state UP', + $this->statusSummary->hosts_up + ), + $this->statusSummary->hosts_up + )) + ); ?>

    statusSummary->hosts_pending): ?> -

    - - translatePlural('%d Host PENDING', '%d Hosts PENDING', $this->statusSummary->hosts_pending), $this->statusSummary->hosts_pending); ?> - -

    +

    qlink( + sprintf( + $this->translatePlural('%u Host PENDING', '%u Hosts PENDING', $this->statusSummary->hosts_pending), + $this->statusSummary->hosts_pending + ), + 'monitoring/list/hosts', + array('host_state' => 99), + array('title' => sprintf( + $this->translatePlural( + 'List %u host that is currently in state PENDING', + 'List %u hosts which are currently in state PENDING', + $this->statusSummary->hosts_pending + ), + $this->statusSummary->hosts_pending + )) + ); ?>

    statusSummary->hosts_down || $this->statusSummary->hosts_unreachable): ?>
    diff --git a/modules/monitoring/application/views/scripts/tactical/components/parts/servicestatesummarybyhoststate.phtml b/modules/monitoring/application/views/scripts/tactical/components/parts/servicestatesummarybyhoststate.phtml index a5f3749e8..af88ae441 100644 --- a/modules/monitoring/application/views/scripts/tactical/components/parts/servicestatesummarybyhoststate.phtml +++ b/modules/monitoring/application/views/scripts/tactical/components/parts/servicestatesummarybyhoststate.phtml @@ -1,280 +1,396 @@ + -
    +
    - - translatePlural('%d CRITICAL', '%d CRITICAL', $services_critical_unhandled, 'icinga.state'), $services_critical_unhandled); ?> - + array( + 'host_problem' => $host_problem, + 'service_state' => 2, + 'service_acknowledged' => 0, + 'service_in_downtime' => 0 + ), + array('title' => sprintf( + $this->translatePlural( + 'List %u service that is currently in state CRITICAL', + 'List %u services which are currently in state CRITICAL', + $services_critical_unhandled + ), + $services_critical_unhandled + )) + ); ?> - - translate('Acknowledged') : $this->translate('CRITICAL', 'icinga.state')); ?> - + array( + 'host_problem' => $host_problem, + 'service_state' => 2, + 'service_handled' => 1 + ), + array('title' => sprintf( + $this->translatePlural( + 'List %u service that is currently in state CRITICAL (Acknowledged)', + 'List %u services which are currently in state CRITICAL (Acknowledged)', + $services_critical_handled + ), + $services_critical_handled + )) + ); ?> - - 1) { - printf( - $this->translate('%d are passively checked'), - $services_critical_passive - ); - } else { - printf( - $this->translate('%d is passively checked'), - $services_critical_passive - ); - } - ?> - + ), + array('title' => sprintf( + $this->translatePlural( + 'List %u service that is currently in state CRITICAL and passively checked', + 'List %u services which are currently in state CRITICAL and passively checked', + $services_critical_passive + ), + $services_critical_passive + )) + ); ?> - - 1) { - printf( - $this->translate('%d are not checked at all'), - $services_critical_not_checked - ); - } else { - printf( - $this->translate('%d is not checked at all'), - $services_critical_not_checked - ); - } - ?> - + ), + array('title' => sprintf( + $this->translatePlural( + 'List %u service that is currently in state CRITICAL and not checked at all', + 'List %u services which are currently in state CRITICAL and not checked at all', + $services_critical_not_checked + ), + $services_critical_not_checked + )) + ); ?>
    -
    +
    - - translate('WARNING', 'icinga.state') ?> - + array( + 'host_problem' => $host_problem, + 'service_state' => 1, + 'service_acknowledged' => 0, + 'service_in_downtime' => 0 + ), + array('title' => sprintf( + $this->translatePlural( + 'List %u service that is currently in state WARNING', + 'List %u services which are currently in state WARNING', + $services_warning_unhandled + ), + $services_warning_unhandled + )) + ); ?> - - translate('Acknowledged') : $this->translate('WARNING', 'icinga.state')); ?> - + array( + 'host_problem' => $host_problem, + 'service_state' => 1, + 'service_handled' => 1 + ), + array('title' => sprintf( + $this->translatePlural( + 'List %u service that is currently in state WARNING (Acknowledged)', + 'List %u services which are currently in state WARNING (Acknowledged)', + $services_warning_handled + ), + $services_warning_handled + )) + ); ?> - - 1) { - printf( - $this->translate('%d are passively checked'), - $services_warning_passive - ); - } else { - printf( - $this->translate('%d is passively checked'), - $services_warning_passive - ); - } - ?> - + ), + array('title' => sprintf( + $this->translatePlural( + 'List %u service that is currently in state WARNING and passively checked', + 'List %u services which are currently in state WARNING and passively checked', + $services_warning_passive + ), + $services_warning_passive + )) + ); ?> - - 1) { - printf( - $this->translate('%d are not checked at all'), - $services_warning_not_checked - ); - } else { - printf( - $this->translate('%d is not checked at all'), - $services_warning_not_checked - ); - } - ?> - + ), + array('title' => sprintf( + $this->translatePlural( + 'List %u service that is currently in state WARNING and not checked at all', + 'List %u services which are currently in state WARNING and not checked at all', + $services_warning_not_checked + ), + $services_warning_not_checked + )) + ); ?>
    -
    +
    - - translatePlural('%d UNKNOWN', '%d UNKNOWN', $services_unknown_unhandled, 'icinga.state'), $services_unknown_unhandled) ?> - + array( + 'host_problem' => $host_problem, + 'service_state' => 3, + 'service_acknowledged' => 0, + 'service_in_downtime' => 0 + ), + array('title' => sprintf( + $this->translatePlural( + 'List %u service that is currently in state UNKNOWN', + 'List %u services which are currently in state UNKNOWN', + $services_unknown_unhandled + ), + $services_unknown_unhandled + )) + ); ?> - - translate('Acknowledged') : $this->translate('UNKNOWN', 'icinga.state')); ?> - + array( + 'host_problem' => $host_problem, + 'service_state' => 3, + 'service_handled' => 1 + ), + array('title' => sprintf( + $this->translatePlural( + 'List %u service that is currently in state UNKNOWN (Acknowledged)', + 'List %u services which are currently in state UNKNOWN (Acknowledged)', + $services_unknown_handled + ), + $services_unknown_handled + )) + ); ?> - - 1) { - printf( - $this->translate('%d are passively checked'), - $services_unknown_passive - ); - } else { - printf( - $this->translate('%d is passively checked'), - $services_unknown_passive - ); - } - ?> - + ), + array('title' => sprintf( + $this->translatePlural( + 'List %u service that is currently in state UNKNOWN and passively checked', + 'List %u services which are currently in state UNKNOWN and passively checked', + $services_unknown_passive + ), + $services_unknown_passive + )) + ); ?> - - 1) { - printf( - $this->translate('%d are not checked at all'), - $services_unknown_not_checked - ); - } else { - printf( - $this->translate('%d is not checked at all'), - $services_unknown_not_checked - ); - } - ?> - + ), + array('title' => sprintf( + $this->translatePlural( + 'List %u service that is currently in state UNKNOWN and not checked at all', + 'List %u services which are currently in state UNKNOWN and not checked at all', + $services_unknown_not_checked + ), + $services_unknown_not_checked + )) + ); ?>
    -
    - "> + qlink( + $services_ok . ' ' . Service::getStateText(0, true), 'monitoring/list/services', - array('host_problem' => $host_problem, 'service_state' => 0) - ); ?>"> - translate('OK', 'icinga.state') ?> - + array( + 'host_problem' => $host_problem, + 'service_state' => 0 + ), + array('title' => sprintf( + $this->translatePlural( + 'List %u service that is currently in state OK', + 'List %u services which are currently in state OK', + $services_ok + ), + $services_ok + )) + ); ?> - - 1) { - printf( - $this->translate('%d are not checked at all'), - $services_ok_not_checked - ); - } else { - printf( - $this->translate('%d is not checked at all'), - $services_ok_not_checked - ); - } - ?> - + ), + array('title' => sprintf( + $this->translatePlural( + 'List %u service that is currently in state OK and not checked at all', + 'List %u services which are currently in state OK and not checked at all', + $services_ok_not_checked + ), + $services_ok_not_checked + )) + ); ?>
    -
    - "> + qlink( + $services_pending . ' ' . Service::getStateText(99, true), 'monitoring/list/services', - array('host_problem' => $host_problem, 'service_state' => 99) - ); ?>"> - translatePlural('%d PENDING', '%d PENDING', $services_pending, 'icinga.state'), $services_pending); ?> - + array( + 'host_problem' => $host_problem, + 'service_state' => 99 + ), + array('title' => sprintf( + $this->translatePlural( + 'List %u service that is currently in state PENDING', + 'List %u services which are currently in state PENDING', + $services_pending + ), + $services_pending + )) + ); ?> - - 1) { - printf( - $this->translate('%d are not checked at all'), - $services_pending_not_checked - ); - } else { - printf( - $this->translate('%d is not checked at all'), - $services_pending_not_checked - ); - } - ?> - + ), + array('title' => sprintf( + $this->translatePlural( + 'List %u service that is currently in state PENDING and not checked at all', + 'List %u services which are currently in state PENDING and not checked at all', + $services_pending_not_checked + ), + $services_pending_not_checked + )) + ); ?>
    - + \ No newline at end of file diff --git a/modules/monitoring/application/views/scripts/tactical/components/problem_hosts.phtml b/modules/monitoring/application/views/scripts/tactical/components/problem_hosts.phtml index 44199df55..bab0cfc8e 100644 --- a/modules/monitoring/application/views/scripts/tactical/components/problem_hosts.phtml +++ b/modules/monitoring/application/views/scripts/tactical/components/problem_hosts.phtml @@ -5,18 +5,44 @@ } ?>"> statusSummary->hosts_down): ?> -

    - - translatePlural('%d Host DOWN', '%d Hosts DOWN', $this->statusSummary->hosts_down), $this->statusSummary->hosts_down); ?> - -

    +

    qlink( + sprintf( + $this->translatePlural('%u Host DOWN', '%u Hosts DOWN', $this->statusSummary->hosts_down), + $this->statusSummary->hosts_down + ), + 'monitoring/list/hosts', + array('host_state' => 1), + array('title' => sprintf( + $this->translatePlural( + 'List %u host that is currently in state DOWN', + 'List %u hosts which are currently in state DOWN', + $this->statusSummary->hosts_down + ), + $this->statusSummary->hosts_down + )) + ); ?>

    statusSummary->hosts_unreachable): ?> -

    - - translatePlural('%d Host UNREACHABLE', '%d Hosts UNREACHABLE', $this->statusSummary->hosts_unreachable), $this->statusSummary->hosts_unreachable); ?> - -

    +

    qlink( + sprintf( + $this->translatePlural( + '%u Host UNREACHABLE', + '%u Hosts UNREACHABLE', + $this->statusSummary->hosts_unreachable + ), + $this->statusSummary->hosts_unreachable + ), + 'monitoring/list/hosts', + array('host_state' => 2), + array('title' => sprintf( + $this->translatePlural( + 'List %u host that is currently in state UNREACHABLE', + 'List %u hosts which are currently in state UNREACHABLE', + $this->statusSummary->hosts_unreachable + ), + $this->statusSummary->hosts_unreachable + )) + ); ?>

    translate('Services'); ?> From 32e048693aa42a4b055b2cee798cfb34b2e047d8 Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Mon, 23 Feb 2015 17:29:50 +0100 Subject: [PATCH 0785/2920] Add proper titles to service multi selection view refs #8458 --- .../views/scripts/services/show.phtml | 234 ++++++++---------- 1 file changed, 102 insertions(+), 132 deletions(-) diff --git a/modules/monitoring/application/views/scripts/services/show.phtml b/modules/monitoring/application/views/scripts/services/show.phtml index 8f818627a..cc88b09e3 100644 --- a/modules/monitoring/application/views/scripts/services/show.phtml +++ b/modules/monitoring/application/views/scripts/services/show.phtml @@ -1,159 +1,129 @@
    - render('partials/service/objects-header.phtml') ?> + render('partials/service/objects-header.phtml'); ?>
    - translate('No services matching the filter') ?> + translate('No services matching the filter'); ?> - +

    translatePlural('%u Service', '%u Services', $serviceCount), $serviceCount); ?>

    +
    qlink( + sprintf($this->translate('List all %u services'), $serviceCount), + $listAllLink + ); ?>
    - - +
    qlink( + $this->icon('reschedule') . ' ' . sprintf( + $this->translate('Reschedule the next check for all %u services'), + $serviceCount + ), + $rescheduleAllLink, + null, + null, + false + ); ?>
    +
    qlink( + $this->icon('plug') . ' ' . sprintf($this->translate('Schedule a downtime for all %u services'), $serviceCount), + $downtimeAllLink, + null, + null, + false + ); ?>
    +
    qlink( + $this->icon('reply') . ' ' . sprintf( + $this->translate('Submit a passive check result for all %u services'), + $serviceCount + ), + $processCheckResultAllLink, + null, + null, + false + ); ?>
    + 0): ?>
    - -
    - - - - - - - - -

    - - translatePlural( '%u Unhandled Service Problem', '%u Unhandled Service Problems', $unhandledCount ), $unhandledCount - ) ?> -

    - - - - -

    - - translatePlural( - '%u Acknowledged Service Problem', - '%u Acknowledged Service Problems', - $acknowledgedCount - ), + + 0): ?> +
    +

    translatePlural( + '%u Acknowledged Service Problem', + '%u Acknowledged Service Problems', $acknowledgedCount - ) ?> -

    -
    - -
    - - - -

    - - - icon('plug'); ?> - translatePlural( - 'List %u service currently in downtime', - 'List %u services currently in downtime', - $inDowntimeCount - ), - $inDowntimeCount - ) ?> - -

    - - - getComments()) ?> - -

    - - icon('comment'); ?> - translatePlural( - 'List %u service comment', - 'List %u service comments', - $commentCount - ), - $commentCount - ) ?> - -

    - + ), + $commentCount + ), + $commentsLink, + null, + null, + false + ); ?>

    + -
    +
    \ No newline at end of file From bb5799434c909235fc26ec211f78e543e815f723 Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Mon, 23 Feb 2015 17:30:37 +0100 Subject: [PATCH 0786/2920] Add proper titles to the contact view refs #8458 --- .../monitoring/application/views/scripts/show/contact.phtml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/modules/monitoring/application/views/scripts/show/contact.phtml b/modules/monitoring/application/views/scripts/show/contact.phtml index 0ccd0f5ec..c4142707a 100644 --- a/modules/monitoring/application/views/scripts/show/contact.phtml +++ b/modules/monitoring/application/views/scripts/show/contact.phtml @@ -19,8 +19,12 @@
    contact_email): ?> - + contact_pager): ?> From 52c17805c9415cd2401e2305b6acc3fa73c023e4 Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Mon, 23 Feb 2015 17:30:51 +0100 Subject: [PATCH 0787/2920] Add proper titles to the history view refs #8458 --- .../application/views/scripts/show/history.phtml | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/modules/monitoring/application/views/scripts/show/history.phtml b/modules/monitoring/application/views/scripts/show/history.phtml index 5c20e800b..d55258d90 100644 --- a/modules/monitoring/application/views/scripts/show/history.phtml +++ b/modules/monitoring/application/views/scripts/show/history.phtml @@ -29,7 +29,12 @@ $hostContext = $object->getType() === 'host'; function contactsLink($match, $view) { $links = array(); foreach (preg_split('/,\s/', $match[1]) as $contact) { - $links[] = $view->qlink($contact, 'monitoring/show/contact', array('contact' => $contact)); + $links[] = $view->qlink( + $contact, + 'monitoring/show/contact', + array('contact' => $contact), + array('title' => sprintf($view->translate('Show detailed information about %s'), $contact)) + ); } return '[' . implode(', ', $links) . ']'; } @@ -141,7 +146,12 @@ $output = $this->tickets ? preg_replace_callback( array( 'host' => $event->host_name, 'service' => $event->service_description - ) + ), + array('title' => sprintf( + $this->translate('Show detailed information for service %s on host %s'), + $event->service_display_name, + $event->host_display_name + )) ) : $this->escape($event->service_display_name), $event->host_display_name ) ?> @@ -150,7 +160,7 @@ $output = $this->tickets ? preg_replace_callback(
    - icon($icon, $title); ?> escape($msg) ?> + icon($icon, $title); ?>
    From be293f5e49e55015baeabacbdce1238262a872ea Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Mon, 23 Feb 2015 17:31:24 +0100 Subject: [PATCH 0788/2920] Add proper titles to the timeline refs #8458 --- .../views/scripts/timeline/index.phtml | 91 ++++++++++++++----- 1 file changed, 69 insertions(+), 22 deletions(-) diff --git a/modules/monitoring/application/views/scripts/timeline/index.phtml b/modules/monitoring/application/views/scripts/timeline/index.phtml index a6e32ac08..58c51fb05 100644 --- a/modules/monitoring/application/views/scripts/timeline/index.phtml +++ b/modules/monitoring/application/views/scripts/timeline/index.phtml @@ -27,19 +27,54 @@ $firstRow = !$beingExtended;
    - +getInterval()) { + case '1d': + $titleTime = sprintf( + $this->translate('on %s', 'timeline.link.title.time'), + $timeInfo[0]->end->format('d/m/Y') + ); + break; + case '1w': + $titleTime = sprintf( + $this->translate('in week %s of %s', 'timeline.link.title.week.and.year'), + $timeInfo[0]->end->format('W'), + $timeInfo[0]->end->format('Y') + ); + break; + case '1m': + $titleTime = sprintf( + $this->translate('in %s', 'timeline.link.title.month.and.year'), + $timeInfo[0]->end->format('F Y') + ); + break; + case '1y': + $titleTime = sprintf( + $this->translate('in %s', 'timeline.link.title.year'), + $timeInfo[0]->end->format('Y') + ); + break; + default: + $titleTime = sprintf( + $this->translate('between %s and %s', 'timeline.link.title.datetime.twice'), + $timeInfo[0]->end->format('d/m/Y g:i A'), + $timeInfo[0]->start->format('d/m/Y g:i A') + ); + } ?>
    - - - end->format($intervalFormat); ?> - - + qlink( + $timeInfo[0]->end->format($intervalFormat), + '/monitoring/list/eventhistory', + array( + 'timestamp<' => $timeInfo[0]->start->getTimestamp(), + 'timestamp>' => $timeInfo[0]->end->getTimestamp() + ), + array('title' => sprintf( + $this->translate('List all event records registered %s', 'timeline.link.title'), + $titleTime + )), + false + ); ?> $labelAndColor): ?> getExtrapolatedCircleWidth($timeInfo[1][$g $circleWidth ); ?>"> - + ); ?>
    From cebaa47aa955327b0d3cdfacbbbf6fc98e3b07e5 Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Mon, 23 Feb 2015 17:32:29 +0100 Subject: [PATCH 0789/2920] Hide the css-hidden link to extend the timeline from screen readers as well --- .../monitoring/application/views/scripts/timeline/index.phtml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/monitoring/application/views/scripts/timeline/index.phtml b/modules/monitoring/application/views/scripts/timeline/index.phtml index 58c51fb05..6557b4a28 100644 --- a/modules/monitoring/application/views/scripts/timeline/index.phtml +++ b/modules/monitoring/application/views/scripts/timeline/index.phtml @@ -129,7 +129,7 @@ $extrapolatedCircleWidth = $timeline->getExtrapolatedCircleWidth($timeInfo[1][$g -
    - translate('Refresh'); ?> + translate('You may also need to restart the web-server for the changes to take effect!'); ?> + qlink( + $this->translate('Refresh'), + null, + null, + array( + 'class' => 'button-like', + 'title' => $title, + 'aria-label' => sprintf($this->translate('Refresh the page; %s'), $title) + ) + ); ?>
    From e6957967f9afacadedab033d401ad5e4424e9528 Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Mon, 23 Feb 2015 17:33:23 +0100 Subject: [PATCH 0791/2920] Wizard: Add proper titles to the button-like links on the last page refs #8458 --- .../views/scripts/index/parts/finish.phtml | 20 +++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/modules/setup/application/views/scripts/index/parts/finish.phtml b/modules/setup/application/views/scripts/index/parts/finish.phtml index e695d72ce..0018d0d43 100644 --- a/modules/setup/application/views/scripts/index/parts/finish.phtml +++ b/modules/setup/application/views/scripts/index/parts/finish.phtml @@ -18,9 +18,25 @@
    - + qlink( + $this->translate('Login to Icinga Web 2'), + 'authentication/login', + null, + array( + 'class' => 'button-like login', + 'title' => $this->translate('Show the login page of Icinga Web 2') + ) + ); ?> - translate('Back'); ?> + qlink( + $this->translate('Back'), + null, + null, + array( + 'class' => 'button-like', + 'title' => $this->translate('Show previous wizard-page') + ) + ); ?>
    \ No newline at end of file From 61dc4c09f0f5945e70edfe01f3aa4766170f64c9 Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Mon, 23 Feb 2015 17:33:44 +0100 Subject: [PATCH 0792/2920] Fix css of the event grid --- public/css/icinga/widgets.less | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/public/css/icinga/widgets.less b/public/css/icinga/widgets.less index 85477db66..1da6b7bfb 100644 --- a/public/css/icinga/widgets.less +++ b/public/css/icinga/widgets.less @@ -29,7 +29,7 @@ table.historycolorgrid td.weekday { opacity: 1.0; } -table.historycolorgrid a { +table.historycolorgrid a, table.historycolorgrid span { margin: 0; text-decoration: none; display: block; From 907134cee2fb05fe02843b1941c172ab0b52ff1a Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Tue, 24 Feb 2015 09:03:47 +0100 Subject: [PATCH 0793/2920] Ensure that all link-like form buttons got proper titles refs #8458 --- .../application/forms/Command/Object/CheckNowCommandForm.php | 3 ++- .../forms/Command/Object/DeleteCommentCommandForm.php | 2 +- .../forms/Command/Object/DeleteDowntimeCommandForm.php | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/modules/monitoring/application/forms/Command/Object/CheckNowCommandForm.php b/modules/monitoring/application/forms/Command/Object/CheckNowCommandForm.php index 1a39574f6..c272b4c30 100644 --- a/modules/monitoring/application/forms/Command/Object/CheckNowCommandForm.php +++ b/modules/monitoring/application/forms/Command/Object/CheckNowCommandForm.php @@ -39,7 +39,8 @@ class CheckNowCommandForm extends ObjectsCommandForm . $this->translate('Check now'), 'decorators' => array('ViewHelper'), 'escape' => false, - 'class' => 'link-like' + 'class' => 'link-like', + 'title' => $this->translate('Schedule the next active check to run immediately') ) ) )); diff --git a/modules/monitoring/application/forms/Command/Object/DeleteCommentCommandForm.php b/modules/monitoring/application/forms/Command/Object/DeleteCommentCommandForm.php index e5bef88d8..6147ed5ff 100644 --- a/modules/monitoring/application/forms/Command/Object/DeleteCommentCommandForm.php +++ b/modules/monitoring/application/forms/Command/Object/DeleteCommentCommandForm.php @@ -54,7 +54,7 @@ class DeleteCommentCommandForm extends ObjectsCommandForm array( 'ignore' => true, 'label' => 'X', - 'title' => $this->translate('Delete comment'), + 'title' => $this->translate('Delete this comment'), 'decorators' => array('ViewHelper') ) ); diff --git a/modules/monitoring/application/forms/Command/Object/DeleteDowntimeCommandForm.php b/modules/monitoring/application/forms/Command/Object/DeleteDowntimeCommandForm.php index 3ef242b2f..2bbd22a4a 100644 --- a/modules/monitoring/application/forms/Command/Object/DeleteDowntimeCommandForm.php +++ b/modules/monitoring/application/forms/Command/Object/DeleteDowntimeCommandForm.php @@ -54,7 +54,7 @@ class DeleteDowntimeCommandForm extends ObjectsCommandForm array( 'ignore' => true, 'label' => 'X', - 'title' => $this->translate('Delete downtime'), + 'title' => $this->translate('Delete this downtime'), 'decorators' => array('ViewHelper') ) ); From 8e8bab0795e066bfc0e4f7a4ef9dc4fee55c03e6 Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Tue, 24 Feb 2015 11:35:25 +0100 Subject: [PATCH 0794/2920] Do only escape a qlink's label manually if necessary --- .../views/scripts/config/resource.phtml | 16 +++++--- .../views/scripts/dashboard/settings.phtml | 16 +++++--- .../scripts/form/reorder-authbackend.phtml | 16 +++++--- .../views/scripts/joystickPagination.phtml | 21 +++++----- application/views/scripts/roles/index.phtml | 8 ++-- library/Icinga/Web/View/helpers/url.php | 14 +++++-- library/Icinga/Web/Widget/FilterEditor.php | 16 ++++---- .../views/scripts/config/index.phtml | 32 +++++++++------ .../views/scripts/hosts/show.phtml | 41 +++++++------------ .../views/scripts/list/contacts.phtml | 9 ++-- .../views/scripts/services/show.phtml | 41 +++++++------------ .../show/components/acknowledgement.phtml | 12 +++--- .../show/components/checkstatistics.phtml | 12 +++--- .../scripts/show/components/command.phtml | 18 +++++--- .../scripts/show/components/comments.phtml | 12 +++--- .../scripts/show/components/downtime.phtml | 12 +++--- .../views/scripts/show/history.phtml | 2 +- 17 files changed, 155 insertions(+), 143 deletions(-) diff --git a/application/views/scripts/config/resource.phtml b/application/views/scripts/config/resource.phtml index c4eb9360f..342320ab9 100644 --- a/application/views/scripts/config/resource.phtml +++ b/application/views/scripts/config/resource.phtml @@ -26,21 +26,25 @@
    diff --git a/application/views/scripts/dashboard/settings.phtml b/application/views/scripts/dashboard/settings.phtml index 10ad613de..d1ed998d1 100644 --- a/application/views/scripts/dashboard/settings.phtml +++ b/application/views/scripts/dashboard/settings.phtml @@ -24,11 +24,13 @@ @@ -61,11 +63,13 @@ diff --git a/application/views/scripts/form/reorder-authbackend.phtml b/application/views/scripts/form/reorder-authbackend.phtml index 23a6a67f5..02f62572d 100644 --- a/application/views/scripts/form/reorder-authbackend.phtml +++ b/application/views/scripts/form/reorder-authbackend.phtml @@ -11,20 +11,24 @@ diff --git a/library/Icinga/Web/View/helpers/url.php b/library/Icinga/Web/View/helpers/url.php index d4518d2aa..925a225f9 100644 --- a/library/Icinga/Web/View/helpers/url.php +++ b/library/Icinga/Web/View/helpers/url.php @@ -28,15 +28,23 @@ $this->addHelperFunction('url', function ($path = null, $params = null) { }); $this->addHelperFunction('qlink', function ($title, $url, $params = null, $properties = null, $escape = true) use ($view) { - if ($properties && array_key_exists('title', $properties) && !array_key_exists('aria-label', $properties)) { - $properties['aria-label'] = $properties['title']; + $icon = ''; + if ($properties) { + if (array_key_exists('title', $properties) && !array_key_exists('aria-label', $properties)) { + $properties['aria-label'] = $properties['title']; + } + + if (array_key_exists('icon', $properties)) { + $icon = $view->icon($properties['icon']); + unset($properties['icon']); + } } return sprintf( '%s', $view->url($url, $params), $view->propertiesToString($properties), - $escape ? $view->escape($title) : $title + $icon . ($escape ? $view->escape($title) : $title) ); }); diff --git a/library/Icinga/Web/Widget/FilterEditor.php b/library/Icinga/Web/Widget/FilterEditor.php index 21dd0f04a..0a8de5586 100644 --- a/library/Icinga/Web/Widget/FilterEditor.php +++ b/library/Icinga/Web/Widget/FilterEditor.php @@ -310,8 +310,8 @@ class FilterEditor extends AbstractWidget $this->preservedUrl()->with('removeFilter', $filter->getId()), null, array( - 'title' => t('Remove this part of your filter'), - 'class' => 'icon-cancel' + 'icon' => 'icon-cancel', + 'title' => t('Remove this part of your filter') ) ); } @@ -323,8 +323,8 @@ class FilterEditor extends AbstractWidget $this->preservedUrl()->with('addFilter', $filter->getId()), null, array( - 'title' => t('Add another filter'), - 'class' => 'icon-plus' + 'icon' => 'icon-plus', + 'title' => t('Add another filter') ) ); } @@ -336,8 +336,8 @@ class FilterEditor extends AbstractWidget $this->preservedUrl()->with('stripFilter', $filter->getId()), null, array( - 'title' => t('Strip this filter'), - 'class' => 'icon-minus' + 'icon' => 'icon-minus', + 'title' => t('Strip this filter') ) ); } @@ -349,8 +349,8 @@ class FilterEditor extends AbstractWidget $this->preservedUrl()->without('addFilter'), null, array( - 'title' => t('Cancel this operation'), - 'class' => 'icon-cancel' + 'icon' => 'icon-cancel', + 'title' => t('Cancel this operation') ) ); } diff --git a/modules/monitoring/application/views/scripts/config/index.phtml b/modules/monitoring/application/views/scripts/config/index.phtml index 0fdb5f8c3..634da957c 100644 --- a/modules/monitoring/application/views/scripts/config/index.phtml +++ b/modules/monitoring/application/views/scripts/config/index.phtml @@ -19,11 +19,13 @@ @@ -59,11 +63,13 @@ diff --git a/modules/monitoring/application/views/scripts/hosts/show.phtml b/modules/monitoring/application/views/scripts/hosts/show.phtml index 5e2417335..8655a31b1 100644 --- a/modules/monitoring/application/views/scripts/hosts/show.phtml +++ b/modules/monitoring/application/views/scripts/hosts/show.phtml @@ -14,31 +14,22 @@
    qlink( - $this->icon('reschedule') . ' ' . sprintf( - $this->translate('Reschedule the next check for all %u hosts'), - $hostCount - ), + sprintf($this->translate('Reschedule the next check for all %u hosts'), $hostCount), $rescheduleAllLink, null, - null, - false + array('icon' => 'reschedule') ); ?>
    qlink( - $this->icon('plug') . ' ' . sprintf($this->translate('Schedule a downtime for all %u hosts'), $hostCount), + sprintf($this->translate('Schedule a downtime for all %u hosts'), $hostCount), $downtimeAllLink, null, - null, - false + array('icon' => 'plug') ); ?>
    qlink( - $this->icon('reply') . ' ' . sprintf( - $this->translate('Submit a passive check result for all %u hosts'), - $hostCount - ), + sprintf($this->translate('Submit a passive check result for all %u hosts'), $hostCount), $processCheckResultAllLink, null, - null, - false + array('icon' => 'reply') ); ?>
    0): ?>
    @@ -51,7 +42,7 @@ $unhandledCount ); ?>
    qlink( - $this->icon('plug') . ' ' . sprintf( + sprintf( $this->translatePlural( 'Schedule a downtime for %u unhandled host problem', 'Schedule a downtime for %u unhandled host problems', @@ -61,11 +52,10 @@ ), $downtimeUnhandledLink, null, - null, - false + array('icon' => 'plug') ); ?>
    qlink( - $this->icon('ok') . ' ' . sprintf( + sprintf( $this->translatePlural( 'Acknowledge %u unhandled host problem', 'Acknowledge %u unhandled host problems', @@ -75,8 +65,7 @@ ), $acknowledgeUnhandledLink, null, - null, - false + array('icon' => 'ok') ); ?>
    @@ -95,7 +84,7 @@ 0): ?>

    qlink( - $this->icon('plug') . ' ' . sprintf( + sprintf( $this->translatePlural( 'List %u host currently in downtime', 'List %u hosts currently in downtime', @@ -105,13 +94,12 @@ ), $inDowntimeLink, null, - null, - false + array('icon' => 'plug') ); ?>

    getComments())) > 0): ?>

    qlink( - $this->icon('comment') . ' ' . sprintf( + sprintf( $this->translatePlural( 'List %u host comment', 'List %u host comments', @@ -121,8 +109,7 @@ ), $commentsLink, null, - null, - false + array('icon' => 'comment') ); ?>

    diff --git a/modules/monitoring/application/views/scripts/list/contacts.phtml b/modules/monitoring/application/views/scripts/list/contacts.phtml index 78435fa3e..878b394c7 100644 --- a/modules/monitoring/application/views/scripts/list/contacts.phtml +++ b/modules/monitoring/application/views/scripts/list/contacts.phtml @@ -17,16 +17,15 @@ foreach ($contacts as $contact): ?>
    img('/static/gravatar', array('email' => $contact->contact_email)); ?> - qlink( - '' . $this->escape($contact->contact_name) . '', + qlink( + $contact->contact_name, 'monitoring/show/contact', array('contact' => $contact->contact_name), array('title' => sprintf( $this->translate('Show detailed information about %s'), $contact->contact_alias - )), - false - ); ?> (contact_alias; ?>) + )) + ); ?> (contact_alias; ?>)
    qlink( - $this->icon('reschedule') . ' ' . sprintf( - $this->translate('Reschedule the next check for all %u services'), - $serviceCount - ), + sprintf($this->translate('Reschedule the next check for all %u services'), $serviceCount), $rescheduleAllLink, null, - null, - false + array('icon' => 'reschedule') ); ?>
    qlink( - $this->icon('plug') . ' ' . sprintf($this->translate('Schedule a downtime for all %u services'), $serviceCount), + sprintf($this->translate('Schedule a downtime for all %u services'), $serviceCount), $downtimeAllLink, null, - null, - false + array('icon' => 'plug') ); ?>
    qlink( - $this->icon('reply') . ' ' . sprintf( - $this->translate('Submit a passive check result for all %u services'), - $serviceCount - ), + sprintf($this->translate('Submit a passive check result for all %u services'), $serviceCount), $processCheckResultAllLink, null, - null, - false + array('icon' => 'reply') ); ?>
    0): ?>
    @@ -51,7 +42,7 @@ $unhandledCount ); ?>
    qlink( - $this->icon('plug') . ' ' . sprintf( + sprintf( $this->translatePlural( 'Schedule a downtime for %u unhandled service problem', 'Schedule a downtime for %u unhandled service problems', @@ -61,11 +52,10 @@ ), $downtimeUnhandledLink, null, - null, - false + array('icon' => 'plug') ); ?>
    qlink( - $this->icon('ok') . ' ' . sprintf( + sprintf( $this->translatePlural( 'Acknowledge %u unhandled service problem', 'Acknowledge %u unhandled service problems', @@ -75,8 +65,7 @@ ), $acknowledgeUnhandledLink, null, - null, - false + array('icon' => 'ok') ); ?>
    @@ -95,7 +84,7 @@ 0): ?>

    qlink( - $this->icon('plug') . ' ' . sprintf( + sprintf( $this->translatePlural( 'List %u service currently in downtime', 'List %u services currently in downtime', @@ -105,13 +94,12 @@ ), $inDowntimeLink, null, - null, - false + array('icon' => 'plug') ); ?>

    getComments())) > 0): ?>

    qlink( - $this->icon('comment') . ' ' . sprintf( + sprintf( $this->translatePlural( 'List %u service comment', 'List %u service comments', @@ -121,8 +109,7 @@ ), $commentsLink, null, - null, - false + array('icon' => 'comment') ); ?>

    diff --git a/modules/monitoring/application/views/scripts/show/components/acknowledgement.phtml b/modules/monitoring/application/views/scripts/show/components/acknowledgement.phtml index e5f85c021..22a372151 100644 --- a/modules/monitoring/application/views/scripts/show/components/acknowledgement.phtml +++ b/modules/monitoring/application/views/scripts/show/components/acknowledgement.phtml @@ -36,13 +36,15 @@ if ($object->acknowledged): ?> } ?> qlink( - $this->icon('ok') . ' ' . $this->translate('Acknowledge'), + $this->translate('Acknowledge'), $ackLink, null, - array('title' => $this->translate( - 'Acknowledge this problem, suppress all future notifications for it and tag it as being handled' - )), - false + array( + 'icon' => 'ok', + 'title' => $this->translate( + 'Acknowledge this problem, suppress all future notifications for it and tag it as being handled' + ) + ) ); ?> getType() === $object::TYPE_HOST) { hasPermission('monitoring/command/schedule-check')) { if ($isService) { echo $this->qlink( - $this->icon('reschedule') . ' ' . $this->translate('Reschedule'), + $this->translate('Reschedule'), 'monitoring/service/reschedule-check', array('host' => $object->getHost()->getName(), 'service' => $object->getName()), array( + 'icon' => 'reschedule', 'data-base-target' => '_self', 'title' => $this->translate( 'Schedule the next active check at a different time than the current one' ) - ), - false + ) ); } else { echo $this->qlink( - $this->icon('reschedule') . ' ' . $this->translate('Reschedule'), + $this->translate('Reschedule'), 'monitoring/host/reschedule-check', array('host' => $object->getName()), array( + 'icon' => 'reschedule', 'data-base-target' => '_self', 'title' => $this->translate( 'Schedule the next active check at a different time than the current one' ) - ), - false + ) ); } } ?> timeUntil($object->next_check) ?> diff --git a/modules/monitoring/application/views/scripts/show/components/command.phtml b/modules/monitoring/application/views/scripts/show/components/command.phtml index 771e0812c..d7fca7cfa 100644 --- a/modules/monitoring/application/views/scripts/show/components/command.phtml +++ b/modules/monitoring/application/views/scripts/show/components/command.phtml @@ -13,19 +13,25 @@ $command = array_shift($parts); $title = sprintf($this->translate('Submit a one time or so called passive result for the %s check'), $command); if ($object->getType() === $object::TYPE_HOST) { echo $this->qlink( - $this->icon('reply') . ' ' . $this->translate('Process check result'), + $this->translate('Process check result'), 'monitoring/host/process-check-result', array('host' => $object->getName()), - array('data-base-target' => '_self', 'title' => $title), - false + array( + 'icon' => 'reply', + 'data-base-target' => '_self', + 'title' => $title + ) ); } else { echo $this->qlink( - $this->icon('reply') . ' ' . $this->translate('Process check result'), + $this->translate('Process check result'), 'monitoring/service/process-check-result', array('host' => $object->getHost()->getName(), 'service' => $object->getName()), - array('data-base-target' => '_self', 'title' => $title), - false + array( + 'icon' => 'reply', + 'data-base-target' => '_self', + 'title' => $title + ) ); } } ?> diff --git a/modules/monitoring/application/views/scripts/show/components/comments.phtml b/modules/monitoring/application/views/scripts/show/components/comments.phtml index 74da7d054..fa7d4606a 100644 --- a/modules/monitoring/application/views/scripts/show/components/comments.phtml +++ b/modules/monitoring/application/views/scripts/show/components/comments.phtml @@ -5,25 +5,25 @@ /** @type \Icinga\Module\Monitoring\Object\MonitoredObject $object */ if ($object->getType() === $object::TYPE_HOST) { echo $this->qlink( - $this->icon('comment') . ' ' . $this->translate('Add comment'), + $this->translate('Add comment'), 'monitoring/host/add-comment', array('host' => $object->getName()), array( + 'icon' => 'comment', 'data-base-target' => '_self', 'title' => $this->translate('Add a new comment to this host') - ), - false + ) ); } else { echo $this->qlink( - $this->icon('comment') . ' ' . $this->translate('Add comment'), + $this->translate('Add comment'), 'monitoring/service/add-comment', array('host' => $object->getHost()->getName(), 'service' => $object->getName()), array( + 'icon' => 'comment', 'data-base-target' => '_self', 'title' => $this->translate('Add a new comment to this service') - ), - false + ) ); } } else { diff --git a/modules/monitoring/application/views/scripts/show/components/downtime.phtml b/modules/monitoring/application/views/scripts/show/components/downtime.phtml index 16f12f6ba..76a4be005 100644 --- a/modules/monitoring/application/views/scripts/show/components/downtime.phtml +++ b/modules/monitoring/application/views/scripts/show/components/downtime.phtml @@ -5,29 +5,29 @@ /** @type \Icinga\Module\Monitoring\Object\MonitoredObject $object */ if ($object->getType() === $object::TYPE_HOST) { echo $this->qlink( - $this->icon('plug') . ' ' . $this->translate('Schedule downtime'), + $this->translate('Schedule downtime'), 'monitoring/host/schedule-downtime', array('host' => $object->getName()), array( + 'icon' => 'plug', 'data-base-target' => '_self', 'title' => $this->translate( 'Schedule a downtime to suppress all problem notifications within a specific period of time' ) - ), - false + ) ); } else { echo $this->qlink( - $this->icon('plug') . ' ' . $this->translate('Schedule downtime'), + $this->translate('Schedule downtime'), 'monitoring/service/schedule-downtime', array('host' => $object->getHost()->getName(), 'service' => $object->getName()), array( + 'icon' => 'plug', 'data-base-target' => '_self', 'title' => $this->translate( 'Schedule a downtime to suppress all problem notifications within a specific period of time' ) - ), - false + ) ); } } else { diff --git a/modules/monitoring/application/views/scripts/show/history.phtml b/modules/monitoring/application/views/scripts/show/history.phtml index d55258d90..0542294d6 100644 --- a/modules/monitoring/application/views/scripts/show/history.phtml +++ b/modules/monitoring/application/views/scripts/show/history.phtml @@ -141,7 +141,7 @@ $output = $this->tickets ? preg_replace_callback( translate('%s on %s', 'Service running on host'), $hostContext ? $this->qlink( - $this->escape($event->service_display_name), + $event->service_display_name, 'monitoring/show/service', array( 'host' => $event->host_name, From b70cda77d450a226382f5965ada170ae0c61d785 Mon Sep 17 00:00:00 2001 From: Matthias Jentsch Date: Tue, 24 Feb 2015 12:22:29 +0100 Subject: [PATCH 0795/2920] Fail gracefully if the page control is not available Execute the runPagedQuery without pagination instead of throwing an exception. fixes #8490 --- library/Icinga/Protocol/Ldap/Connection.php | 58 +++++++++++++++++---- 1 file changed, 48 insertions(+), 10 deletions(-) diff --git a/library/Icinga/Protocol/Ldap/Connection.php b/library/Icinga/Protocol/Ldap/Connection.php index 6db88365a..3d9ae90ab 100644 --- a/library/Icinga/Protocol/Ldap/Connection.php +++ b/library/Icinga/Protocol/Ldap/Connection.php @@ -4,6 +4,7 @@ namespace Icinga\Protocol\Ldap; use Exception; +use Icinga\Exception\ProgrammingError; use Icinga\Protocol\Ldap\Exception as LdapException; use Icinga\Application\Platform; use Icinga\Application\Config; @@ -267,13 +268,22 @@ class Connection $this->connect(); $this->bind(); - if ($query->getUsePagedResults() && version_compare(PHP_VERSION, '5.4.0') >= 0) { + if ($this->pageControlAvailable($query)) { return $this->runPagedQuery($query, $fields); } else { return $this->runQuery($query, $fields); } } + /** + * Execute the given LDAP query and return the resulting entries + * + * @param Query $query The query to execute + * @param array $fields The fields that will be fetched from the matches + * + * @return array The matched entries + * @throws LdapException + */ protected function runQuery(Query $query, $fields = array()) { $limit = $query->getLimit(); @@ -322,8 +332,35 @@ class Connection return $entries; } - protected function runPagedQuery(Query $query, $fields = array()) + /** + * Returns whether requesting the page control is available + */ + protected function pageControlAvailable(Query $query) { + return $query->getUsePagedResults() && version_compare(PHP_VERSION, '5.4.0') >= 0; + } + + /** + * Execute the given LDAP query while requesting pagination control to separate + * big responses into smaller chunks + * + * @param Query $query The query to execute + * @param array $fields The fields that will be fetched from the matches + * @param int $page_size The maximum page size, defaults to Connection::PAGE_SIZE + * + * @return array The matched entries + * @throws LdapException + * @throws ProgrammingError When executed without available page controls (check with pageControlAvailable() ) + */ + protected function runPagedQuery(Query $query, $fields = array(), $pageSize = null) + { + if (! $this->pageControlAvailable($query)) { + throw new ProgrammingError('LDAP: Page control not available.'); + } + if (! isset($pageSize)) { + $pageSize = static::PAGE_SIZE; + } + $limit = $query->getLimit(); $offset = $query->hasOffset() ? $query->getOffset() - 1 : 0; $queryString = $query->create(); @@ -337,7 +374,10 @@ class Connection $cookie = ''; $entries = array(); do { - ldap_control_paged_result($this->ds, static::PAGE_SIZE, true, $cookie); + // do not set controlPageResult as a critical extension, since we still want the + // server to return an answer in case the pagination extension is missing. + ldap_control_paged_result($this->ds, $pageSize, false, $cookie); + $results = @ldap_search($this->ds, $base, $queryString, $fields, 0, $limit ? $offset + $limit : 0); if ($results === false) { if (ldap_errno($this->ds) === self::LDAP_NO_SUCH_OBJECT) { @@ -375,18 +415,16 @@ class Connection } } while (($limit === 0 || $limit !== count($entries)) && ($entry = ldap_next_entry($this->ds, $entry))); - try { - ldap_control_paged_result_response($this->ds, $results, $cookie); - } catch (Exception $e) { + if (false === ldap_control_paged_result_response($this->ds, $results, $cookie)) { // If the page size is greater than or equal to the sizeLimit value, the server should ignore the // control as the request can be satisfied in a single page: https://www.ietf.org/rfc/rfc2696.txt // This applies no matter whether paged search requests are permitted or not. You're done once you // got everything you were out for. if (count($entries) !== $limit) { - Logger::warning( - 'Unable to request paged LDAP results. Does the server allow paged search requests? (%s)', - $e->getMessage() - ); + + // The server does not support pagination, but still returned a response by ignoring the + // pagedResultsControl. We output a warning to indicate that the pagination control was ignored. + Logger::warning('Unable to request paged LDAP results. Does the server allow paged search requests?'); } } From d4dc0177c0880ca3324b6854b219cef2d2ce9300 Mon Sep 17 00:00:00 2001 From: Matthias Jentsch Date: Tue, 24 Feb 2015 12:50:57 +0100 Subject: [PATCH 0796/2920] Sort LDAP user list fixes #7693 --- library/Icinga/Protocol/Ldap/Connection.php | 2 +- modules/setup/application/forms/AdminAccountPage.php | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/library/Icinga/Protocol/Ldap/Connection.php b/library/Icinga/Protocol/Ldap/Connection.php index 3d9ae90ab..1cd979a74 100644 --- a/library/Icinga/Protocol/Ldap/Connection.php +++ b/library/Icinga/Protocol/Ldap/Connection.php @@ -442,7 +442,7 @@ class Connection ldap_control_paged_result($this->ds, 0); } - return $entries; // TODO(7693): Sort entries post-processed + return $entries; } protected function cleanupAttributes($attrs) diff --git a/modules/setup/application/forms/AdminAccountPage.php b/modules/setup/application/forms/AdminAccountPage.php index de8650439..485baa64f 100644 --- a/modules/setup/application/forms/AdminAccountPage.php +++ b/modules/setup/application/forms/AdminAccountPage.php @@ -309,7 +309,9 @@ class AdminAccountPage extends Form } try { - return $backend->listUsers(); + $users = $backend->listUsers(); + natsort ($users); + return $users; } catch (Exception $e) { // No need to handle anything special here. Error means no users found. return array(); From d68c636359c65089a10ead606342d7024a715c96 Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Tue, 24 Feb 2015 13:15:59 +0100 Subject: [PATCH 0797/2920] Wizard: Disable the browser's form validation when navigating back formnovalidate... The fukin awesomeness of HTML5 is sometimes even impressing a god-damned h4x0r like me. fixes #8507 --- library/Icinga/Web/Wizard.php | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/library/Icinga/Web/Wizard.php b/library/Icinga/Web/Wizard.php index 0ef9b8212..d25cd56e5 100644 --- a/library/Icinga/Web/Wizard.php +++ b/library/Icinga/Web/Wizard.php @@ -612,10 +612,11 @@ class Wizard 'button', static::BTN_PREV, array( - 'type' => 'submit', - 'value' => $pages[$index - 1]->getName(), - 'label' => t('Back'), - 'decorators' => array('ViewHelper') + 'type' => 'submit', + 'value' => $pages[$index - 1]->getName(), + 'label' => t('Back'), + 'decorators' => array('ViewHelper'), + 'formnovalidate' => 'formnovalidate' ) ); $page->addElement( @@ -633,10 +634,11 @@ class Wizard 'button', static::BTN_PREV, array( - 'type' => 'submit', - 'value' => $pages[$index - 1]->getName(), - 'label' => t('Back'), - 'decorators' => array('ViewHelper') + 'type' => 'submit', + 'value' => $pages[$index - 1]->getName(), + 'label' => t('Back'), + 'decorators' => array('ViewHelper'), + 'formnovalidate' => 'formnovalidate' ) ); $page->addElement( From 3b2e3dcd36728c8ddc1b3b4f872ca70fa9bcc4e6 Mon Sep 17 00:00:00 2001 From: Alexander Fuhr Date: Wed, 25 Feb 2015 12:07:59 +0100 Subject: [PATCH 0798/2920] Revert the animate-spin css to the original refs #7968 --- application/fonts/fontello-ifont/css/animation.css | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/application/fonts/fontello-ifont/css/animation.css b/application/fonts/fontello-ifont/css/animation.css index 578d766f5..ac5a9562f 100644 --- a/application/fonts/fontello-ifont/css/animation.css +++ b/application/fonts/fontello-ifont/css/animation.css @@ -6,7 +6,7 @@ -o-animation: spin 2s infinite linear; -webkit-animation: spin 2s infinite linear; animation: spin 2s infinite linear; - /*display: inline-block;*/ + display: inline-block; } @-moz-keyframes spin { 0% { From 4505718ecc22241d967cbe85298d2ee7aa161421 Mon Sep 17 00:00:00 2001 From: Alexander Fuhr Date: Wed, 25 Feb 2015 12:10:08 +0100 Subject: [PATCH 0799/2920] Move spinner indicator functionality to linkClicked method refs #7968 --- public/js/icinga/events.js | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/public/js/icinga/events.js b/public/js/icinga/events.js index 814750a71..a3ee35dfa 100644 --- a/public/js/icinga/events.js +++ b/public/js/icinga/events.js @@ -115,8 +115,6 @@ $(document).on('click', 'a', { self: this }, this.linkClicked); $(document).on('click', 'tr[href]', { self: this }, this.linkClicked); - $(document).on('click', '.refresh', { self: this }, this.refreshContent); - // Select a table row $(document).on('click', 'table.multiselect tr[href]', { self: this }, this.rowSelected); @@ -440,6 +438,11 @@ return; } + // activate spinner indicator + if ($a.hasClass('spinner')) { + $a.addClass('active'); + } + // If link has hash tag... if (href.match(/#/)) { if (href === '#') { @@ -483,11 +486,6 @@ return false; }, - refreshContent: function () { - var $icon = $(this).children('i'); - $icon.addClass($icon.data('load-class')); - }, - /** * Detect the link/form target for a given element (link, form, whatever) */ From c583a351bb5406ef9e3204e3d2eda74b9ca4c65a Mon Sep 17 00:00:00 2001 From: Alexander Fuhr Date: Wed, 25 Feb 2015 12:11:58 +0100 Subject: [PATCH 0800/2920] Add .spinner css definition refs #7968 --- public/css/icinga/tabs.less | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/public/css/icinga/tabs.less b/public/css/icinga/tabs.less index e776469e0..86191860d 100644 --- a/public/css/icinga/tabs.less +++ b/public/css/icinga/tabs.less @@ -136,3 +136,14 @@ ul.tabs img.icon { a.close-tab { display: none; } + +.spinner > i { + line-height: 1; +} + +.spinner.active > i { + .animate-spin(); + &:before { + content: '\e874'; + } +} From 481c58ec039917ae7d1368a60f93bbd3bdb223c6 Mon Sep 17 00:00:00 2001 From: Alexander Fuhr Date: Wed, 25 Feb 2015 12:14:26 +0100 Subject: [PATCH 0801/2920] Add accessibility to renderRefreshTab refs #7968 --- library/Icinga/Web/Widget/Tab.php | 5 +++++ library/Icinga/Web/Widget/Tabs.php | 31 ++++++++++++++++++++++++++++-- 2 files changed, 34 insertions(+), 2 deletions(-) diff --git a/library/Icinga/Web/Widget/Tab.php b/library/Icinga/Web/Widget/Tab.php index 94e2bc678..a54f29db6 100644 --- a/library/Icinga/Web/Widget/Tab.php +++ b/library/Icinga/Web/Widget/Tab.php @@ -123,6 +123,11 @@ class Tab extends AbstractWidget $this->label = $label; } + public function getLabel() + { + return $this->label; + } + /** * @param mixed $title */ diff --git a/library/Icinga/Web/Widget/Tabs.php b/library/Icinga/Web/Widget/Tabs.php index 64b898e50..afe5673b9 100644 --- a/library/Icinga/Web/Widget/Tabs.php +++ b/library/Icinga/Web/Widget/Tabs.php @@ -68,7 +68,9 @@ EOT; */ private $refreshTpl = <<< 'EOT'
  • - + + +
  • EOT; @@ -330,7 +332,32 @@ EOT; private function renderRefreshTab() { $url = Url::fromRequest()->without('renderLayout'); - $tpl = str_replace('{URL}', $url, $this->refreshTpl); + $tab = $this->get($this->getActiveName()); + + if ($tab !== null) { + $caption = Icinga::app()->getViewRenderer()->view->escape( + $tab->getLabel() + ); + } else { + $caption = t('Content'); + } + + $label = t(sprintf('Refresh the %s', $caption)); + $title = $label; + + $tpl = str_replace( + array( + '{URL}', + '{TITLE}', + '{LABEL}' + ), + array( + $url, + $title, + $label + ), + $this->refreshTpl + ); return $tpl; } From e219bb1664f925668c8a7eb71b78cb4a5577f6c7 Mon Sep 17 00:00:00 2001 From: Alexander Fuhr Date: Wed, 25 Feb 2015 13:13:22 +0100 Subject: [PATCH 0802/2920] Add doc for the label refs #7968 --- library/Icinga/Web/Widget/Tab.php | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/library/Icinga/Web/Widget/Tab.php b/library/Icinga/Web/Widget/Tab.php index a54f29db6..c7fb30ff8 100644 --- a/library/Icinga/Web/Widget/Tab.php +++ b/library/Icinga/Web/Widget/Tab.php @@ -42,6 +42,11 @@ class Tab extends AbstractWidget */ private $title = ''; + /** + * The label displayed for this tab + * + * @var string + */ private $label = ''; /** @@ -118,11 +123,21 @@ class Tab extends AbstractWidget return $this->name; } + /** + * Set the tab label + * + * @param string $label + */ public function setLabel($label) { $this->label = $label; } + /** + * Get the tab label + * + * @return string + */ public function getLabel() { return $this->label; From 8669dcb078952ed6f3192ba861f5c1e0a9ffbac6 Mon Sep 17 00:00:00 2001 From: Alexander Fuhr Date: Wed, 25 Feb 2015 13:23:12 +0100 Subject: [PATCH 0803/2920] Add font-family to the active spinner icon refs #7968 --- public/css/icinga/tabs.less | 1 + 1 file changed, 1 insertion(+) diff --git a/public/css/icinga/tabs.less b/public/css/icinga/tabs.less index 86191860d..aaef3c7d4 100644 --- a/public/css/icinga/tabs.less +++ b/public/css/icinga/tabs.less @@ -144,6 +144,7 @@ a.close-tab { .spinner.active > i { .animate-spin(); &:before { + font-family: "ifont"; content: '\e874'; } } From 3a2b69a63ceedeb5e48c354e36eb74e5db11026b Mon Sep 17 00:00:00 2001 From: Alexander Fuhr Date: Wed, 25 Feb 2015 13:24:11 +0100 Subject: [PATCH 0804/2920] Remove refreshTab property from Tabs refs #7968 --- library/Icinga/Web/Widget/Tabs.php | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/library/Icinga/Web/Widget/Tabs.php b/library/Icinga/Web/Widget/Tabs.php index afe5673b9..b9a9a539d 100644 --- a/library/Icinga/Web/Widget/Tabs.php +++ b/library/Icinga/Web/Widget/Tabs.php @@ -116,13 +116,6 @@ EOT; */ private $title; - /** - * Whether the tabs should contain a refresh icon - * - * @var bool - */ - private $refreshTab = true; - /** * Set whether the current tab is closable */ @@ -335,7 +328,7 @@ EOT; $tab = $this->get($this->getActiveName()); if ($tab !== null) { - $caption = Icinga::app()->getViewRenderer()->view->escape( + $caption = $this->view()->escape( $tab->getLabel() ); } else { @@ -377,7 +370,7 @@ EOT; $drop = $this->renderDropdownTabs(); } $close = $this->closeTab ? $this->renderCloseTab() : ''; - $refresh = $this->refreshTab ? $this->renderRefreshTab() : ''; + $refresh = $this->renderRefreshTab(); return str_replace( array( From 85e6fce86770b374a21e672b422a3a5cf7ae3655 Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Wed, 25 Feb 2015 13:33:42 +0100 Subject: [PATCH 0805/2920] Rename Platform::zendClassExists() to Platform::classExists() --- library/Icinga/Application/Platform.php | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/library/Icinga/Application/Platform.php b/library/Icinga/Application/Platform.php index a2ef0a3ef..355311b97 100644 --- a/library/Icinga/Application/Platform.php +++ b/library/Icinga/Application/Platform.php @@ -182,19 +182,24 @@ class Platform } /** - * Return whether the given Zend framework class exists + * Return whether the given class exists * * @param string $name The name of the class to check * * @return bool */ - public static function zendClassExists($name) + public static function classExists($name) { if (@class_exists($name)) { return true; } - return (@include str_replace('_', '/', $name) . '.php') !== false; + if (strpos($name, '_') !== false) { + // Assume it's a Zend-Framework class + return (@include str_replace('_', '/', $name) . '.php') !== false; + } + + return false; } /** @@ -206,7 +211,7 @@ class Platform */ public static function hasMysqlSupport() { - return static::extensionLoaded('mysql') && static::zendClassExists('Zend_Db_Adapter_Pdo_Mysql'); + return static::extensionLoaded('mysql') && static::classExists('Zend_Db_Adapter_Pdo_Mysql'); } /** @@ -218,6 +223,6 @@ class Platform */ public static function hasPostgresqlSupport() { - return static::extensionLoaded('pgsql') && static::zendClassExists('Zend_Db_Adapter_Pdo_Pgsql'); + return static::extensionLoaded('pgsql') && static::classExists('Zend_Db_Adapter_Pdo_Pgsql'); } } From ef79d6bc12ba85f27cd39cf37acc2eb2cf0bce38 Mon Sep 17 00:00:00 2001 From: Alexander Fuhr Date: Wed, 25 Feb 2015 13:34:58 +0100 Subject: [PATCH 0806/2920] Replace spinner.active font-family css definition with a note refs #7968 --- public/css/icinga/tabs.less | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/public/css/icinga/tabs.less b/public/css/icinga/tabs.less index aaef3c7d4..4d7f43146 100644 --- a/public/css/icinga/tabs.less +++ b/public/css/icinga/tabs.less @@ -144,7 +144,7 @@ a.close-tab { .spinner.active > i { .animate-spin(); &:before { - font-family: "ifont"; + // icon-spin6 content: '\e874'; } } From 24d0999fa45800e96b02032e05f5ad6a50dfa7cb Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Wed, 25 Feb 2015 13:38:38 +0100 Subject: [PATCH 0807/2920] Register requirements as objects This neutralizes the need for a unique name per requirement as requirements are now compared based on their type and condition. It also allows to implement a solution to add simple conditional requirements. refs #8508 --- .../scripts/form/setup-requirements.phtml | 18 +- modules/setup/library/Setup/Requirement.php | 279 ++++++++++++++++++ modules/setup/library/Setup/Requirements.php | 149 ++-------- 3 files changed, 316 insertions(+), 130 deletions(-) create mode 100644 modules/setup/library/Setup/Requirement.php diff --git a/modules/setup/application/views/scripts/form/setup-requirements.phtml b/modules/setup/application/views/scripts/form/setup-requirements.phtml index b3cf30101..09ca98d7f 100644 --- a/modules/setup/application/views/scripts/form/setup-requirements.phtml +++ b/modules/setup/application/views/scripts/form/setup-requirements.phtml @@ -1,7 +1,6 @@ getRequirements(); @@ -10,21 +9,22 @@ $requirements = $form->getRequirements();
    - + - + diff --git a/modules/setup/library/Setup/Requirement.php b/modules/setup/library/Setup/Requirement.php new file mode 100644 index 000000000..37bb5663e --- /dev/null +++ b/modules/setup/library/Setup/Requirement.php @@ -0,0 +1,279 @@ +optional = false; + $this->descriptions = array(); + + foreach ($options as $key => $value) { + $setMethod = 'set' . ucfirst($key); + $addMethod = 'add' . ucfirst($key); + if (method_exists($this, $setMethod)) { + $this->$setMethod($value); + } elseif (method_exists($this, $addMethod)) { + $this->$addMethod($value); + } else { + throw LogicException('No setter found for option key: ' . $key); + } + } + } + + /** + * Set the state of this requirement + * + * @param bool $state + * + * @return Requirement + */ + public function setState($state) + { + $this->state = (bool) $state; + return $this; + } + + /** + * Return the state of this requirement + * + * Evaluates the requirement in case there is no state set yet. + * + * @return int + */ + public function getState() + { + if ($this->state === null) { + $this->state = $this->evaluate(); + } + + return $this->state; + } + + /** + * Set a descriptive text for this requirement's current state + * + * @param string $text + * + * @return Requirement + */ + public function setStateText($text) + { + $this->stateText = $text; + return $this; + } + + /** + * Return a descriptive text for this requirement's current state + * + * @return string + */ + public function getStateText() + { + return $this->stateText; + } + + /** + * Add a description for this requirement + * + * @param string $description + * + * @return Requirement + */ + public function addDescription($description) + { + $this->descriptions[] = $description; + return $this; + } + + /** + * Return the descriptions of this wizard + * + * @return array + */ + public function getDescriptions() + { + return $this->descriptions; + } + + /** + * Set the title for this requirement + * + * @param string $title + * + * @return Requirement + */ + public function setTitle($title) + { + $this->title = $title; + return $this; + } + + /** + * Return the title of this requirement + * + * In case there is no title set the alias is returned instead. + * + * @return string + */ + public function getTitle() + { + if ($this->title === null) { + return $this->getAlias(); + } + + return $this->title; + } + + /** + * Set the condition for this requirement + * + * @param mixed $condition + * + * @return Requirement + */ + public function setCondition($condition) + { + $this->condition = $condition; + return $this; + } + + /** + * Return the condition of this requirement + * + * @return mixed + */ + public function getCondition() + { + return $this->condition; + } + + /** + * Set whether this requirement is optional + * + * @param bool $state + * + * @return Requirement + */ + public function setOptional($state = true) + { + $this->optional = (bool) $state; + return $this; + } + + /** + * Return whether this requirement is optional + * + * @return bool + */ + public function isOptional() + { + return $this->optional; + } + + /** + * Set the alias to display the condition with in a human readable way + * + * @param string $alias + * + * @return Requirement + */ + public function setAlias($alias) + { + $this->alias = $alias; + return $this; + } + + /** + * Return the alias to display the condition with in a human readable way + * + * @return string + */ + public function getAlias() + { + return $this->alias; + } + + /** + * Evaluate this requirement and return whether it is fulfilled + * + * @return bool + */ + abstract protected function evaluate(); + + /** + * Return whether the given requirement equals this one + * + * @param Requirement $requirement + * + * @return bool + */ + public function equals(Requirement $requirement) + { + if ($requirement instanceof static) { + return $this->getCondition() === $requirement->getCondition(); + } + + return false; + } +} diff --git a/modules/setup/library/Setup/Requirements.php b/modules/setup/library/Setup/Requirements.php index bede70aa0..e96a0f7ac 100644 --- a/modules/setup/library/Setup/Requirements.php +++ b/modules/setup/library/Setup/Requirements.php @@ -8,27 +8,9 @@ use IteratorAggregate; /** * Container to store and handle requirements - * - * TODO: Requirements should be registered as objects with a specific purpose (PhpModRequirement, PhpIniRequirement, ..) - * so that it's not necessary to define unique identifiers which may differ between different modules. */ class Requirements implements IteratorAggregate { - /** - * Identifier representing the state OK - */ - const STATE_OK = 2; - - /** - * Identifier representing the state OPTIONAL - */ - const STATE_OPTIONAL = 1; - - /** - * Identifier representing the state MANDATORY - */ - const STATE_MANDATORY = 0; - /** * The registered requirements * @@ -39,44 +21,35 @@ class Requirements implements IteratorAggregate /** * Register a requirement * - * @param object $requirement The requirement to add + * @param Requirement $requirement The requirement to add * - * @return self + * @return Requirements */ - public function add($name, $requirement) + public function add(Requirement $requirement) { - $this->requirements[$name] = array_key_exists($name, $this->requirements) - ? $this->combine($this->requirements[$name], $requirement) - : $requirement; + $merged = false; + foreach ($this as $knownRequirement) { + if ($requirement->equals($knownRequirement)) { + if ($knownRequirement->isOptional() && !$requirement->isOptional()) { + $knownRequirement->setOptional(false); + } + + foreach ($requirement->getDescriptions() as $description) { + $knownRequirement->addDescription($description); + } + + $merged = true; + break; + } + } + + if (! $merged) { + $this->requirements[] = $requirement; + } + return $this; } - /** - * Combine the two given requirements - * - * Returns the most important requirement with the description from the other one being added. - * - * @param object $oldRequirement - * @param object $newRequirement - * - * @return object - */ - protected function combine($oldRequirement, $newRequirement) - { - if ($newRequirement->state === static::STATE_MANDATORY && $oldRequirement->state === static::STATE_OPTIONAL) { - $tempRequirement = $oldRequirement; - $oldRequirement = $newRequirement; - $newRequirement = $tempRequirement; - } - - if (! is_array($oldRequirement->description)) { - $oldRequirement->description = array($oldRequirement->description); - } - - $oldRequirement->description[] = $newRequirement->description; - return $oldRequirement; - } - /** * Return all registered requirements * @@ -97,83 +70,17 @@ class Requirements implements IteratorAggregate return new ArrayIterator($this->getAll()); } - /** - * Register an optional requirement - * - * @param string $name - * @param string $title - * @param string $description - * @param bool $state - * @param string $message - * - * @return self - */ - public function addOptional($name, $title, $description, $state, $message) - { - $this->add( - $name, - (object) array( - 'title' => $title, - 'message' => $message, - 'description' => $description, - 'state' => (bool) $state ? static::STATE_OK : static::STATE_OPTIONAL - ) - ); - return $this; - } - - /** - * Register a mandatory requirement - * - * @param string $name - * @param string $title - * @param string $description - * @param bool $state - * @param string $message - * - * @return self - */ - public function addMandatory($name, $title, $description, $state, $message) - { - $this->add( - $name, - (object) array( - 'title' => $title, - 'message' => $message, - 'description' => $description, - 'state' => (bool) $state ? static::STATE_OK : static::STATE_MANDATORY - ) - ); - return $this; - } - /** * Register the given requirements * * @param Requirements $requirements The requirements to register * - * @return self + * @return Requirements */ public function merge(Requirements $requirements) { - foreach ($requirements->getAll() as $name => $requirement) { - $this->add($name, $requirement); - } - - return $this; - } - - /** - * Make all registered requirements being optional - * - * @return self - */ - public function allOptional() - { - foreach ($this->getAll() as $requirement) { - if ($requirement->state === static::STATE_MANDATORY) { - $requirement->state = static::STATE_OPTIONAL; - } + foreach ($requirements as $requirement) { + $this->add($requirement); } return $this; @@ -186,8 +93,8 @@ class Requirements implements IteratorAggregate */ public function fulfilled() { - foreach ($this->getAll() as $requirement) { - if ($requirement->state === static::STATE_MANDATORY) { + foreach ($this as $requirement) { + if (! $requirement->getState() && !$requirement->isOptional()) { return false; } } From 04630a20beb53e500b5daf4fbd43f90b7325328c Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Wed, 25 Feb 2015 13:39:59 +0100 Subject: [PATCH 0808/2920] Implement all known requirements as object refs #8508 --- .../library/Monitoring/MonitoringWizard.php | 16 +- .../Setup/Requirement/ClassRequirement.php | 28 ++ .../ConfigDirectoryRequirement.php | 42 +++ .../Setup/Requirement/OSRequirement.php | 27 ++ .../Requirement/PhpConfigRequirement.php | 22 ++ .../Requirement/PhpModuleRequirement.php | 42 +++ .../Requirement/PhpVersionRequirement.php | 28 ++ modules/setup/library/Setup/WebWizard.php | 245 ++++++++---------- 8 files changed, 296 insertions(+), 154 deletions(-) create mode 100644 modules/setup/library/Setup/Requirement/ClassRequirement.php create mode 100644 modules/setup/library/Setup/Requirement/ConfigDirectoryRequirement.php create mode 100644 modules/setup/library/Setup/Requirement/OSRequirement.php create mode 100644 modules/setup/library/Setup/Requirement/PhpConfigRequirement.php create mode 100644 modules/setup/library/Setup/Requirement/PhpModuleRequirement.php create mode 100644 modules/setup/library/Setup/Requirement/PhpVersionRequirement.php diff --git a/modules/monitoring/library/Monitoring/MonitoringWizard.php b/modules/monitoring/library/Monitoring/MonitoringWizard.php index 4e342aa75..3c7dee886 100644 --- a/modules/monitoring/library/Monitoring/MonitoringWizard.php +++ b/modules/monitoring/library/Monitoring/MonitoringWizard.php @@ -3,7 +3,6 @@ namespace Icinga\Module\Monitoring; -use Icinga\Application\Platform; use Icinga\Web\Form; use Icinga\Web\Wizard; use Icinga\Web\Request; @@ -17,6 +16,7 @@ use Icinga\Module\Monitoring\Forms\Setup\InstancePage; use Icinga\Module\Monitoring\Forms\Setup\SecurityPage; use Icinga\Module\Monitoring\Forms\Setup\IdoResourcePage; use Icinga\Module\Monitoring\Forms\Setup\LivestatusResourcePage; +use Icinga\Module\Setup\Requirement\PhpModuleRequirement; /** * Monitoring Module Setup Wizard @@ -137,19 +137,15 @@ class MonitoringWizard extends Wizard implements SetupWizard { $requirements = new Requirements(); - $requirements->addOptional( - 'existing_php_mod_sockets', - mt('monitoring', 'PHP Module: Sockets'), - mt( + $requirements->add(new PhpModuleRequirement(array( + 'optional' => true, + 'condition' => 'Sockets', + 'description' => mt( 'monitoring', 'In case it\'s desired that a TCP connection is being used by Icinga Web 2 to' . ' access a Livestatus interface, the Sockets module for PHP is required.' - ), - Platform::extensionLoaded('sockets'), - Platform::extensionLoaded('sockets') ? mt('monitoring', 'The PHP Module sockets is available.') : ( - mt('monitoring', 'The PHP Module sockets is not available.') ) - ); + ))); return $requirements; } diff --git a/modules/setup/library/Setup/Requirement/ClassRequirement.php b/modules/setup/library/Setup/Requirement/ClassRequirement.php new file mode 100644 index 000000000..e0f25cf4e --- /dev/null +++ b/modules/setup/library/Setup/Requirement/ClassRequirement.php @@ -0,0 +1,28 @@ +getCondition(); + if (Platform::classExists($classNameOrPath)) { + $this->setStateText(sprintf( + mt('setup', 'The %s is available.', 'setup.requirement.class'), + $this->getAlias() ?: $classNameOrPath . ' ' . mt('setup', 'class', 'setup.requirement.class') + )); + return true; + } else { + $this->setStateText(sprintf( + mt('setup', 'The %s is missing.', 'setup.requirement.class'), + $this->getAlias() ?: $classNameOrPath . ' ' . mt('setup', 'class', 'setup.requirement.class') + )); + return false; + } + } +} diff --git a/modules/setup/library/Setup/Requirement/ConfigDirectoryRequirement.php b/modules/setup/library/Setup/Requirement/ConfigDirectoryRequirement.php new file mode 100644 index 000000000..3404717db --- /dev/null +++ b/modules/setup/library/Setup/Requirement/ConfigDirectoryRequirement.php @@ -0,0 +1,42 @@ +getCondition(); + if (file_exists($path)) { + $readable = is_readable($path); + if ($readable && is_writable($path)) { + $this->setStateText(sprintf(mt('setup', 'The directory %s is read- and writable.'), $path)); + return true; + } else { + $this->setStateText(sprintf( + $readable + ? mt('setup', 'The directory %s is not writable.') + : mt('setup', 'The directory %s is not readable.'), + $path + )); + return false; + } + } else { + $this->setStateText(sprintf(mt('setup', 'The directory %s does not exist.'), $path)); + return false; + } + } +} diff --git a/modules/setup/library/Setup/Requirement/OSRequirement.php b/modules/setup/library/Setup/Requirement/OSRequirement.php new file mode 100644 index 000000000..ff185bb3c --- /dev/null +++ b/modules/setup/library/Setup/Requirement/OSRequirement.php @@ -0,0 +1,27 @@ +getCondition())); + } + + return $title; + } + + protected function evaluate() + { + $phpOS = Platform::getOperatingSystemName(); + $this->setStateText(sprintf(mt('setup', 'You are running PHP on a %s system.'), ucfirst($phpOS))); + return strtolower($phpOS) === strtolower($this->getCondition()); + } +} diff --git a/modules/setup/library/Setup/Requirement/PhpConfigRequirement.php b/modules/setup/library/Setup/Requirement/PhpConfigRequirement.php new file mode 100644 index 000000000..670c988e4 --- /dev/null +++ b/modules/setup/library/Setup/Requirement/PhpConfigRequirement.php @@ -0,0 +1,22 @@ +getCondition(); + $configValue = Platform::getPhpConfig($configDirective); + $this->setStateText( + $configValue + ? sprintf(mt('setup', 'The PHP config `%s\' is set to "%s".'), $configDirective, $configValue) + : sprintf(mt('setup', 'The PHP config `%s\' is not defined.'), $configDirective) + ); + return is_bool($value) ? $configValue == $value : $configValue === $value; + } +} diff --git a/modules/setup/library/Setup/Requirement/PhpModuleRequirement.php b/modules/setup/library/Setup/Requirement/PhpModuleRequirement.php new file mode 100644 index 000000000..6581797ce --- /dev/null +++ b/modules/setup/library/Setup/Requirement/PhpModuleRequirement.php @@ -0,0 +1,42 @@ +getAlias()) { + if ($title === null) { + $title = $this->getCondition(); + } + + return sprintf(mt('setup', 'PHP Module: %s'), $title); + } + + return $title; + } + + protected function evaluate() + { + $moduleName = $this->getCondition(); + if (Platform::extensionLoaded($moduleName)) { + $this->setStateText(sprintf( + mt('setup', 'The PHP module %s is available.'), + $this->getAlias() ?: $moduleName + )); + return true; + } else { + $this->setStateText(sprintf( + mt('setup', 'The PHP module %s is missing.'), + $this->getAlias() ?: $moduleName + )); + return false; + } + } +} diff --git a/modules/setup/library/Setup/Requirement/PhpVersionRequirement.php b/modules/setup/library/Setup/Requirement/PhpVersionRequirement.php new file mode 100644 index 000000000..d6ca5f189 --- /dev/null +++ b/modules/setup/library/Setup/Requirement/PhpVersionRequirement.php @@ -0,0 +1,28 @@ +setStateText(sprintf(mt('setup', 'You are running PHP version %s.'), $phpVersion)); + list($operator, $requiredVersion) = $this->getCondition(); + return version_compare($phpVersion, $requiredVersion, $operator); + } +} diff --git a/modules/setup/library/Setup/WebWizard.php b/modules/setup/library/Setup/WebWizard.php index 7576adbb8..667237243 100644 --- a/modules/setup/library/Setup/WebWizard.php +++ b/modules/setup/library/Setup/WebWizard.php @@ -9,7 +9,6 @@ use Icinga\Web\Wizard; use Icinga\Web\Request; use Icinga\Application\Config; use Icinga\Application\Icinga; -use Icinga\Application\Platform; use Icinga\Module\Setup\Forms\ModulePage; use Icinga\Module\Setup\Forms\WelcomePage; use Icinga\Module\Setup\Forms\SummaryPage; @@ -29,8 +28,13 @@ use Icinga\Module\Setup\Steps\GeneralConfigStep; use Icinga\Module\Setup\Steps\ResourceStep; use Icinga\Module\Setup\Steps\AuthenticationStep; use Icinga\Module\Setup\Utils\EnableModuleStep; -use Icinga\Module\Setup\Utils\MakeDirStep; use Icinga\Module\Setup\Utils\DbTool; +use Icinga\Module\Setup\Requirement\OSRequirement; +use Icinga\Module\Setup\Requirement\ClassRequirement; +use Icinga\Module\Setup\Requirement\PhpConfigRequirement; +use Icinga\Module\Setup\Requirement\PhpModuleRequirement; +use Icinga\Module\Setup\Requirement\PhpVersionRequirement; +use Icinga\Module\Setup\Requirement\ConfigDirectoryRequirement; /** * Icinga Web 2 Setup Wizard @@ -351,194 +355,147 @@ class WebWizard extends Wizard implements SetupWizard { $requirements = new Requirements(); - $phpVersion = Platform::getPhpVersion(); - $requirements->addMandatory( - 'php_version_>=_5_3_2', - mt('setup', 'PHP Version'), - mt( + $requirements->add(new PhpVersionRequirement(array( + 'condition' => array('>=', '5.3.2'), + 'description' => mt( 'setup', 'Running Icinga Web 2 requires PHP version 5.3.2. Advanced features' . ' like the built-in web server require PHP version 5.4.' - ), - version_compare($phpVersion, '5.3.2', '>='), - sprintf(mt('setup', 'You are running PHP version %s.'), $phpVersion) - ); + ) + ))); - $defaultTimezone = Platform::getPhpConfig('date.timezone'); - $requirements->addMandatory( - 'existing_default_timezone', - mt('setup', 'Default Timezone'), - sprintf( + $requirements->add(new PhpConfigRequirement(array( + 'condition' => array('date.timezone', true), + 'title' => mt('setup', 'Default Timezone'), + 'description' => sprintf( mt('setup', 'It is required that a default timezone has been set using date.timezone in %s.'), php_ini_loaded_file() ?: 'php.ini' ), - $defaultTimezone, - $defaultTimezone ? sprintf(mt('setup', 'Your default timezone is: %s'), $defaultTimezone) : ( - mt('setup', 'You did not define a default timezone.') - ) - ); + ))); - $requirements->addOptional( - 'platform=linux', - mt('setup', 'Linux Platform'), - mt( + $requirements->add(new OSRequirement(array( + 'optional' => true, + 'condition' => 'linux', + 'description' => mt( 'setup', 'Icinga Web 2 is developed for and tested on Linux. While we cannot' . ' guarantee they will, other platforms may also perform as well.' - ), - Platform::isLinux(), - sprintf(mt('setup', 'You are running PHP on a %s system.'), Platform::getOperatingSystemName()) - ); - - $requirements->addMandatory( - 'existing_php_mod_openssl', - mt('setup', 'PHP Module: OpenSSL'), - mt('setup', 'The PHP module for OpenSSL is required to generate cryptographically safe password salts.'), - Platform::extensionLoaded('openssl'), - Platform::extensionLoaded('openssl') ? mt('setup', 'The PHP module for OpenSSL is available.') : ( - mt('setup', 'The PHP module for OpenSSL is missing.') ) - ); + ))); - $requirements->addOptional( - 'existing_php_mod_json', - mt('setup', 'PHP Module: JSON'), - mt('setup', 'The JSON module for PHP is required for various export functionalities as well as APIs.'), - Platform::extensionLoaded('json'), - Platform::extensionLoaded('json') ? mt('setup', 'The PHP module JSON is available.') : ( - mt('setup', 'The PHP module JSON is missing.') + $requirements->add(new PhpModuleRequirement(array( + 'condition' => 'OpenSSL', + 'description' => mt( + 'setup', + 'The PHP module for OpenSSL is required to generate cryptographically safe password salts.' ) - ); + ))); - $requirements->addOptional( - 'existing_php_mod_ldap', - mt('setup', 'PHP Module: LDAP'), - mt('setup', 'If you\'d like to authenticate users using LDAP the corresponding PHP module is required'), - Platform::extensionLoaded('ldap'), - Platform::extensionLoaded('ldap') ? mt('setup', 'The PHP module LDAP is available') : ( - mt('setup', 'The PHP module LDAP is missing') + $requirements->add(new PhpModuleRequirement(array( + 'optional' => true, + 'condition' => 'JSON', + 'description' => mt( + 'setup', + 'The JSON module for PHP is required for various export functionalities as well as APIs.' ) - ); + ))); - $requirements->addOptional( - 'existing_php_mod_intl', - mt('setup', 'PHP Module: INTL'), - mt( + $requirements->add(new PhpModuleRequirement(array( + 'optional' => true, + 'condition' => 'LDAP', + 'description' => mt( + 'setup', + 'If you\'d like to authenticate users using LDAP the corresponding PHP module is required.' + ) + ))); + + $requirements->add(new PhpModuleRequirement(array( + 'optional' => true, + 'condition' => 'INTL', + 'description' => mt( 'setup', 'If you want your users to benefit from language, timezone and date/time' . ' format negotiation, the INTL module for PHP is required.' - ), - Platform::extensionLoaded('intl'), - Platform::extensionLoaded('intl') ? mt('setup', 'The PHP module INTL is available') : ( - mt('setup', 'The PHP module INTL is missing') ) - ); + ))); // TODO(6172): Remove this requirement once we do not ship dompdf with Icinga Web 2 anymore - $requirements->addOptional( - 'existing_php_mod_dom', - mt('setup', 'PHP Module: DOM'), - mt('setup', 'To be able to export views and reports to PDF, the DOM module for PHP is required.'), - Platform::extensionLoaded('dom'), - Platform::extensionLoaded('dom') ? mt('setup', 'The PHP module DOM is available') : ( - mt('setup', 'The PHP module DOM is missing') - ) - ); - - $requirements->addOptional( - 'existing_php_mod_gd', - mt('setup', 'PHP Module: GD'), - mt( + $requirements->add(new PhpModuleRequirement(array( + 'optional' => true, + 'condition' => 'DOM', + 'description' => mt( 'setup', - 'In case you want views being exported to PDF,' - . ' you\'ll need the GD extension for PHP.' - ), - Platform::extensionLoaded('gd'), - Platform::extensionLoaded('gd') ? mt('setup', 'The PHP module GD is available') : ( - mt('setup', 'The PHP module GD is missing') + 'To be able to export views and reports to PDF, the DOM module for PHP is required.' ) - ); + ))); - $requirements->addOptional( - 'existing_php_mod_imagick', - mt('setup', 'PHP Module: Imagick'), - mt( + $requirements->add(new PhpModuleRequirement(array( + 'optional' => true, + 'condition' => 'GD', + 'description' => mt( 'setup', - 'In case you want graphs being exported to PDF as well' - . ', you\'ll need the ImageMagick extension for PHP.' - ), - Platform::extensionLoaded('imagick'), - Platform::extensionLoaded('imagick') ? mt('setup', 'The PHP module Imagick is available') : ( - mt('setup', 'The PHP module Imagick is missing') + 'In case you want views being exported to PDF, you\'ll need the GD extension for PHP.' ) - ); + ))); - $requirements->addOptional( - 'existing_php_mod_pdo_mysql', - mt('setup', 'PHP Module: PDO-MySQL'), - mt( + $requirements->add(new PhpModuleRequirement(array( + 'optional' => true, + 'condition' => 'Imagick', + 'description' => mt( + 'setup', + 'In case you want graphs being exported to PDF as well, you\'ll need the ImageMagick extension for PHP.' + ) + ))); + + $requirements->add(new PhpModuleRequirement(array( + 'optional' => true, + 'condition' => 'mysql', + 'alias' => 'PDO-MySQL', + 'description' => mt( 'setup', 'Is Icinga Web 2 supposed to access a MySQL database the PDO-MySQL module for PHP is required.' - ), - Platform::extensionLoaded('mysql'), - Platform::extensionLoaded('mysql') ? mt('setup', 'The PHP module PDO-MySQL is available.') : ( - mt('setup', 'The PHP module PDO-MySQL is missing.') ) - ); + ))); - $requirements->addOptional( - 'existing_php_mod_pdo_pgsql', - mt('setup', 'PHP Module: PDO-PostgreSQL'), - mt( + $requirements->add(new PhpModuleRequirement(array( + 'optional' => true, + 'condition' => 'pgsql', + 'alias' => 'PDO-PostgreSQL', + 'description' => mt( 'setup', 'Is Icinga Web 2 supposed to access a PostgreSQL database' . ' the PDO-PostgreSQL module for PHP is required.' - ), - Platform::extensionLoaded('pgsql'), - Platform::extensionLoaded('pgsql') ? mt('setup', 'The PHP module PDO-PostgreSQL is available.') : ( - mt('setup', 'The PHP module PDO-PostgreSQL is missing.') ) - ); + ))); - $mysqlAdapterFound = Platform::zendClassExists('Zend_Db_Adapter_Pdo_Mysql'); - $requirements->addOptional( - 'existing_class_Zend_Db_Adapter_Pdo_Mysql', - mt('setup', 'Zend Database Adapter For MySQL'), - mt('setup', 'The Zend database adapter for MySQL is required to access a MySQL database.'), - $mysqlAdapterFound, - $mysqlAdapterFound ? mt('setup', 'The Zend database adapter for MySQL is available.') : ( - mt('setup', 'The Zend database adapter for MySQL is missing.') + $requirements->add(new ClassRequirement(array( + 'optional' => true, + 'condition' => 'Zend_Db_Adapter_Pdo_Mysql', + 'alias' => mt('setup', 'Zend database adapter for MySQL'), + 'description' => mt( + 'setup', + 'The Zend database adapter for MySQL is required to access a MySQL database.' ) - ); + ))); - $pgsqlAdapterFound = Platform::zendClassExists('Zend_Db_Adapter_Pdo_Pgsql'); - $requirements->addOptional( - 'existing_class_Zend_Db_Adapter_Pdo_Pgsql', - mt('setup', 'Zend Database Adapter For PostgreSQL'), - mt('setup', 'The Zend database adapter for PostgreSQL is required to access a PostgreSQL database.'), - $pgsqlAdapterFound, - $pgsqlAdapterFound ? mt('setup', 'The Zend database adapter for PostgreSQL is available.') : ( - mt('setup', 'The Zend database adapter for PostgreSQL is missing.') + $requirements->add(new ClassRequirement(array( + 'optional' => true, + 'condition' => 'Zend_Db_Adapter_Pdo_Pgsql', + 'alias' => mt('setup', 'Zend database adapter for PostgreSQL'), + 'description' => mt( + 'setup', + 'The Zend database adapter for PostgreSQL is required to access a PostgreSQL database.' ) - ); + ))); - $configDir = Icinga::app()->getConfigDir(); - $requirements->addMandatory( - 'writable_directory_' . $configDir, - mt('setup', 'Writable Config Directory'), - mt( + $requirements->add(new ConfigDirectoryRequirement(array( + 'condition' => Icinga::app()->getConfigDir(), + 'description' => mt( 'setup', 'The Icinga Web 2 configuration directory defaults to "/etc/icingaweb2", if' . ' not explicitly set in the environment variable "ICINGAWEB_CONFIGDIR".' - ), - is_writable($configDir), - sprintf( - is_writable($configDir) ? mt('setup', 'The current configuration directory is writable: %s') : ( - mt('setup', 'The current configuration directory is not writable: %s') - ), - $configDir ) - ); + ))); foreach ($this->getWizards() as $wizard) { $requirements->merge($wizard->getRequirements()); From 7f883a47701dd4834258359ddeafff26b71846e9 Mon Sep 17 00:00:00 2001 From: Alexander Fuhr Date: Wed, 25 Feb 2015 13:51:26 +0100 Subject: [PATCH 0809/2920] Add own animation.less to provide own parameterized animate function refs #7968 --- library/Icinga/Web/StyleSheet.php | 1 + public/css/icinga/animation.less | 82 +++++++++++++++++++++++++++++++ 2 files changed, 83 insertions(+) create mode 100644 public/css/icinga/animation.less diff --git a/library/Icinga/Web/StyleSheet.php b/library/Icinga/Web/StyleSheet.php index c4b61f17f..b1bbba231 100644 --- a/library/Icinga/Web/StyleSheet.php +++ b/library/Icinga/Web/StyleSheet.php @@ -14,6 +14,7 @@ class StyleSheet '../application/fonts/fontello-ifont/css/ifont-embedded.css', 'css/vendor/tipsy.css', 'css/icinga/defaults.less', + 'css/icinga/animation.less', 'css/icinga/layout-colors.less', 'css/icinga/layout-structure.less', 'css/icinga/menu.less', diff --git a/public/css/icinga/animation.less b/public/css/icinga/animation.less new file mode 100644 index 000000000..928cdf526 --- /dev/null +++ b/public/css/icinga/animation.less @@ -0,0 +1,82 @@ +.animate(@animate) { + -moz-animation: @animate; + -o-animation: @animate; + -webkit-animation: @animate; + animation: @animate; +} + +@-moz-keyframes spin { + 0% { + -moz-transform: rotate(0deg); + -o-transform: rotate(0deg); + -webkit-transform: rotate(0deg); + transform: rotate(0deg); + } + + 100% { + -moz-transform: rotate(359deg); + -o-transform: rotate(359deg); + -webkit-transform: rotate(359deg); + transform: rotate(359deg); + } +} +@-webkit-keyframes spin { + 0% { + -moz-transform: rotate(0deg); + -o-transform: rotate(0deg); + -webkit-transform: rotate(0deg); + transform: rotate(0deg); + } + + 100% { + -moz-transform: rotate(359deg); + -o-transform: rotate(359deg); + -webkit-transform: rotate(359deg); + transform: rotate(359deg); + } +} +@-o-keyframes spin { + 0% { + -moz-transform: rotate(0deg); + -o-transform: rotate(0deg); + -webkit-transform: rotate(0deg); + transform: rotate(0deg); + } + + 100% { + -moz-transform: rotate(359deg); + -o-transform: rotate(359deg); + -webkit-transform: rotate(359deg); + transform: rotate(359deg); + } +} +@-ms-keyframes spin { + 0% { + -moz-transform: rotate(0deg); + -o-transform: rotate(0deg); + -webkit-transform: rotate(0deg); + transform: rotate(0deg); + } + + 100% { + -moz-transform: rotate(359deg); + -o-transform: rotate(359deg); + -webkit-transform: rotate(359deg); + transform: rotate(359deg); + } +} +@keyframes spin { + 0% { + -moz-transform: rotate(0deg); + -o-transform: rotate(0deg); + -webkit-transform: rotate(0deg); + transform: rotate(0deg); + } + + 100% { + -moz-transform: rotate(359deg); + -o-transform: rotate(359deg); + -webkit-transform: rotate(359deg); + transform: rotate(359deg); + } +} \ No newline at end of file From c029ec1af92abc86d03bac0f93ed00aef8e06fb4 Mon Sep 17 00:00:00 2001 From: Alexander Fuhr Date: Wed, 25 Feb 2015 13:53:00 +0100 Subject: [PATCH 0810/2920] Replace animate-spin with own animate implementation in spinner refs #7968 --- public/css/icinga/tabs.less | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/public/css/icinga/tabs.less b/public/css/icinga/tabs.less index 4d7f43146..d9161f672 100644 --- a/public/css/icinga/tabs.less +++ b/public/css/icinga/tabs.less @@ -142,7 +142,7 @@ a.close-tab { } .spinner.active > i { - .animate-spin(); + .animate(spin 2s infinite linear); &:before { // icon-spin6 content: '\e874'; From 08ace05ac750ce54810648ea202dd8c5f7d97904 Mon Sep 17 00:00:00 2001 From: Alexander Fuhr Date: Wed, 25 Feb 2015 13:56:32 +0100 Subject: [PATCH 0811/2920] Remove animations.css from StyleSheet loading lessFiles refs #7968 --- library/Icinga/Web/StyleSheet.php | 1 - 1 file changed, 1 deletion(-) diff --git a/library/Icinga/Web/StyleSheet.php b/library/Icinga/Web/StyleSheet.php index b1bbba231..3f1e2b2a7 100644 --- a/library/Icinga/Web/StyleSheet.php +++ b/library/Icinga/Web/StyleSheet.php @@ -10,7 +10,6 @@ use Icinga\Web\LessCompiler; class StyleSheet { protected static $lessFiles = array( - '../application/fonts/fontello-ifont/css/animation.css', '../application/fonts/fontello-ifont/css/ifont-embedded.css', 'css/vendor/tipsy.css', 'css/icinga/defaults.less', From 16200417ebb449869057c41cfd8520ea2e64c1e7 Mon Sep 17 00:00:00 2001 From: Alexander Fuhr Date: Wed, 25 Feb 2015 14:15:32 +0100 Subject: [PATCH 0812/2920] Add spinner active indicator for form submit buttons refs #7968 --- public/js/icinga/events.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/public/js/icinga/events.js b/public/js/icinga/events.js index a3ee35dfa..021b25f47 100644 --- a/public/js/icinga/events.js +++ b/public/js/icinga/events.js @@ -226,6 +226,11 @@ event.stopPropagation(); event.preventDefault(); + // activate spinner indicator + if ($button.hasClass('spinner')) { + $button.addClass('active'); + } + icinga.logger.debug('Submitting form: ' + method + ' ' + url, method); $target = self.getLinkTargetFor($form); From 797d37735d3ddfe775bb9d390234e529685ac873 Mon Sep 17 00:00:00 2001 From: Alexander Fuhr Date: Wed, 25 Feb 2015 14:16:35 +0100 Subject: [PATCH 0813/2920] Add .spinner class to CheckNowCommandForm submit button refs #7968 --- .../application/forms/Command/Object/CheckNowCommandForm.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/monitoring/application/forms/Command/Object/CheckNowCommandForm.php b/modules/monitoring/application/forms/Command/Object/CheckNowCommandForm.php index c272b4c30..e5cf6b9e4 100644 --- a/modules/monitoring/application/forms/Command/Object/CheckNowCommandForm.php +++ b/modules/monitoring/application/forms/Command/Object/CheckNowCommandForm.php @@ -39,7 +39,7 @@ class CheckNowCommandForm extends ObjectsCommandForm . $this->translate('Check now'), 'decorators' => array('ViewHelper'), 'escape' => false, - 'class' => 'link-like', + 'class' => 'link-like spinner', 'title' => $this->translate('Schedule the next active check to run immediately') ) ) From cc403806f764c1527afc78cc451b4745a945d475 Mon Sep 17 00:00:00 2001 From: Alexander Fuhr Date: Wed, 25 Feb 2015 15:28:09 +0100 Subject: [PATCH 0814/2920] Fix refresh accessibility lable if it is empty refs #7968 --- library/Icinga/Web/Widget/Tabs.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/library/Icinga/Web/Widget/Tabs.php b/library/Icinga/Web/Widget/Tabs.php index b9a9a539d..e83d10783 100644 --- a/library/Icinga/Web/Widget/Tabs.php +++ b/library/Icinga/Web/Widget/Tabs.php @@ -328,9 +328,13 @@ EOT; $tab = $this->get($this->getActiveName()); if ($tab !== null) { - $caption = $this->view()->escape( + $label = $this->view()->escape( $tab->getLabel() ); + } + + if (! empty($label)) { + $caption = $label; } else { $caption = t('Content'); } From 89451f30864c01ceedb2fae97355a4835486b4db Mon Sep 17 00:00:00 2001 From: Matthias Jentsch Date: Wed, 25 Feb 2015 18:00:28 +0100 Subject: [PATCH 0815/2920] Ensure that form ids are unique Add an unique prefix to each Form- or FormElement id, unless id protection is disabled explicitly, to prevent id collisions between different containers. fixes #8460 --- application/views/helpers/ProtectId.php | 12 +++++ .../config/authentication/reorder.phtml | 2 +- .../views/scripts/mixedPagination.phtml | 4 +- library/Icinga/Web/Form.php | 54 +++++++++++++++++++ library/Icinga/Web/Request.php | 20 +++++++ .../controllers/ListController.php | 2 +- 6 files changed, 90 insertions(+), 4 deletions(-) create mode 100644 application/views/helpers/ProtectId.php diff --git a/application/views/helpers/ProtectId.php b/application/views/helpers/ProtectId.php new file mode 100644 index 000000000..8795a3933 --- /dev/null +++ b/application/views/helpers/ProtectId.php @@ -0,0 +1,12 @@ +getRequest()->protectId($id); + } +} diff --git a/application/views/scripts/config/authentication/reorder.phtml b/application/views/scripts/config/authentication/reorder.phtml index 4583a23b3..0386cdd5e 100644 --- a/application/views/scripts/config/authentication/reorder.phtml +++ b/application/views/scripts/config/authentication/reorder.phtml @@ -2,7 +2,7 @@
    -

    +

    translate('Authentication Configuration'); ?>

    diff --git a/application/views/scripts/mixedPagination.phtml b/application/views/scripts/mixedPagination.phtml index 4704d8f51..160657b12 100644 --- a/application/views/scripts/mixedPagination.phtml +++ b/application/views/scripts/mixedPagination.phtml @@ -9,8 +9,8 @@ use Icinga\Web\Url; if ($this->pageCount <= 1) return; -?>

    -

    > + > host_state, true)); ?>
    prefixedTimeSince($object->host_last_state_change, true) ?>
    service_state, true)); ?>
    From 94d727dbb8d9ce3103b6f99876cd862e939aa5a6 Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Thu, 22 Jan 2015 09:21:50 +0100 Subject: [PATCH 0308/2920] Fix error in Icinga\Web\Form in case the label decorator is missing Zend_Form::getDecorator() returns false instead of null in case the decorator is not found. --- library/Icinga/Web/Form.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library/Icinga/Web/Form.php b/library/Icinga/Web/Form.php index 64712961f..1f3e0d4bd 100644 --- a/library/Icinga/Web/Form.php +++ b/library/Icinga/Web/Form.php @@ -512,7 +512,7 @@ class Form extends Zend_Form $el = parent::createElement($type, $name, $options); - if (($description = $el->getDescription()) !== null && ($label = $el->getDecorator('label')) !== null) { + if (($description = $el->getDescription()) !== null && ($label = $el->getDecorator('label')) !== false) { $label->setOptions(array( 'title' => $description, 'class' => 'has-feedback' From 98acc9166a5b80b7dd290a5d43e0582c6b698702 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Thu, 22 Jan 2015 10:24:44 +0100 Subject: [PATCH 0309/2920] monitoring: Fix coding style in components/header.phtml --- .../scripts/show/components/header.phtml | 46 +++++++++---------- 1 file changed, 23 insertions(+), 23 deletions(-) diff --git a/modules/monitoring/application/views/scripts/show/components/header.phtml b/modules/monitoring/application/views/scripts/show/components/header.phtml index 25ed83cfd..b57f1a482 100644 --- a/modules/monitoring/application/views/scripts/show/components/header.phtml +++ b/modules/monitoring/application/views/scripts/show/components/header.phtml @@ -6,34 +6,34 @@ use Icinga\Module\Monitoring\Object\Service; $isService = $object->getType() === $object::TYPE_SERVICE; ?> -compact): ?> + +compact): ?> + - - - + + + - - - + + + - -
    > - host_state, true)); ?>
    - prefixedTimeSince($object->host_last_state_change, true) ?> -
    escape($object->host_name) ?>host_address && $object->host_address !== $object->host_name): ?> -
    escape($object->host_address) ?> - -
    > + host_state, true)); ?>
    + prefixedTimeSince($object->host_last_state_change, true) ?> +
    + escape($object->host_name) ?> + host_address && $object->host_address !== $object->host_name): ?> +
    escape($object->host_address) ?> + +
    - service_state, true)); ?>
    - prefixedTimeSince($object->service_last_state_change, true) ?> -
    translate('Service') ?>: escape($object->service_description) ?> - - render('show/components/statusIcons.phtml') ?> - -
    + service_state, true)); ?>
    + prefixedTimeSince($object->service_last_state_change, true) ?> +
    + translate('Service') ?>: escape($object->service_description) ?> + render('show/components/statusIcons.phtml') ?> +
     
    From ed7dc1beb639294ab3f25b42a76b2110b5f089f4 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Thu, 22 Jan 2015 10:29:57 +0100 Subject: [PATCH 0310/2920] monitoring: Use display_name when displaying the service name in the detail area refs #7843 --- .../application/views/scripts/show/components/header.phtml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/monitoring/application/views/scripts/show/components/header.phtml b/modules/monitoring/application/views/scripts/show/components/header.phtml index b57f1a482..b6ed49ed5 100644 --- a/modules/monitoring/application/views/scripts/show/components/header.phtml +++ b/modules/monitoring/application/views/scripts/show/components/header.phtml @@ -31,7 +31,7 @@ $isService = $object->getType() === $object::TYPE_SERVICE; prefixedTimeSince($object->service_last_state_change, true) ?>
    - translate('Service') ?>: escape($object->service_description) ?> + translate('Service') ?>: escape($object->service_display_name) ?> render('show/components/statusIcons.phtml') ?>
    translate('Service') ?>: escape($object->service_display_name) ?> + service_display_name !== $object->service_description): ?> + (escape($object->service_description) ?>) + render('show/components/statusIcons.phtml') ?>
    - escape($object->host_name) ?> + escape($object->host_display_name) ?> host_address && $object->host_address !== $object->host_name): ?> -
    escape($object->host_address) ?> +
    + escape($object->host_address) ?>
    escape($object->host_display_name) ?> + host_display_name !== $object->host_name): ?> + (escape($object->host_name) ?>) + host_address && $object->host_address !== $object->host_name): ?>
    escape($object->host_address) ?> From a1f4d124b41da7e0aba0b7d7864ebb5da2930afa Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Thu, 22 Jan 2015 10:36:44 +0100 Subject: [PATCH 0315/2920] monitoring: Prefer
    over
    in components/header.phtml --- .../application/views/scripts/show/components/header.phtml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/monitoring/application/views/scripts/show/components/header.phtml b/modules/monitoring/application/views/scripts/show/components/header.phtml index cfd093473..7f58790f4 100644 --- a/modules/monitoring/application/views/scripts/show/components/header.phtml +++ b/modules/monitoring/application/views/scripts/show/components/header.phtml @@ -14,7 +14,7 @@ $isService = $object->getType() === $object::TYPE_SERVICE; From 1aa91f0228ccb03af277baee6d702664b8a127cb Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Thu, 22 Jan 2015 10:57:15 +0100 Subject: [PATCH 0319/2920] monitoring: Select host and service display_name for an object's history refs #7843 --- .../monitoring/library/Monitoring/Object/MonitoredObject.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/modules/monitoring/library/Monitoring/Object/MonitoredObject.php b/modules/monitoring/library/Monitoring/Object/MonitoredObject.php index 2d9f1f30c..8d3246aab 100644 --- a/modules/monitoring/library/Monitoring/Object/MonitoredObject.php +++ b/modules/monitoring/library/Monitoring/Object/MonitoredObject.php @@ -408,7 +408,9 @@ abstract class MonitoredObject $eventHistory = $this->backend->select()->from('eventHistory', array( 'object_type', 'host_name', + 'host_display_name', 'service_description', + 'service_display_name', 'timestamp', 'state', 'attempt', From c4c248cbb76d4a8d967765cefe3855f76973ac54 Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Thu, 22 Jan 2015 10:57:41 +0100 Subject: [PATCH 0320/2920] Make the ModulePage's design more appealing refs #8191 --- .../setup/application/forms/ModulePage.php | 16 +++---- .../views/scripts/form/setup-modules.phtml | 24 +++++++++++ public/css/icinga/setup.less | 42 +++++++++++++++++++ 3 files changed, 72 insertions(+), 10 deletions(-) create mode 100644 modules/setup/application/views/scripts/form/setup-modules.phtml diff --git a/modules/setup/application/forms/ModulePage.php b/modules/setup/application/forms/ModulePage.php index 7add2bb81..ef765c0e7 100644 --- a/modules/setup/application/forms/ModulePage.php +++ b/modules/setup/application/forms/ModulePage.php @@ -19,7 +19,7 @@ class ModulePage extends Form public function init() { $this->setName('setup_modules'); - //$this->setViewScript('form/setup-modules.phtml'); + $this->setViewScript('form/setup-modules.phtml'); $this->modulePaths = array(); if (($appModulePath = realpath(Icinga::app()->getApplicationDir() . '/../modules')) !== false) { @@ -34,15 +34,11 @@ class ModulePage extends Form 'checkbox', $module->getName(), array( - 'label' => ucfirst($module->getName()), - 'value' => $module->getName() === 'monitoring' ? 1 : 0 - ) - ); - $this->addElement( - 'note', - $module->getName() . '_desc', - array( - 'value' => $module->getDescription() + 'required' => true, + 'description' => $module->getDescription(), + 'label' => ucfirst($module->getName()), + 'value' => $module->getName() === 'monitoring' ? 1 : 0, + 'decorators' => array('ViewHelper') ) ); } diff --git a/modules/setup/application/views/scripts/form/setup-modules.phtml b/modules/setup/application/views/scripts/form/setup-modules.phtml new file mode 100644 index 000000000..8d8e9ecf9 --- /dev/null +++ b/modules/setup/application/views/scripts/form/setup-modules.phtml @@ -0,0 +1,24 @@ + +
    +

    translate('Modules', 'setup.page.title'); ?>

    +

    translate('The following modules were found in your Icinga Web 2 installation. To enable and configure a module, just tick it and click "Next".'); ?>

    +getElements() as $element): ?> + getName(), array(Wizard::BTN_PREV, Wizard::BTN_NEXT, $form->getTokenElementName(), $form->getUidElementName()))): ?> +
    +

    + + +
    + + + getElement($form->getTokenElementName()); ?> + getElement($form->getUidElementName()); ?> +
    + getElement(Wizard::BTN_PREV); ?> + getElement(Wizard::BTN_NEXT); ?> +
    + diff --git a/public/css/icinga/setup.less b/public/css/icinga/setup.less index 0f69355b3..d6692b501 100644 --- a/public/css/icinga/setup.less +++ b/public/css/icinga/setup.less @@ -394,3 +394,45 @@ margin-top: 0; } } + +#setup_modules { + div.module { + float: left; + width: 15em; + height: 15em; + margin: 1em; + padding: 0.3em; + border: 1px solid #ccc; + background-color: snow; + + h3 { + border: none; + margin: 0.5em 0; + text-align: center; + + label { + margin: 0; + width: 15em; + cursor: pointer; + } + } + + h3 + label { + width: 13.5em; + height: 13.9em; + overflow: auto; + cursor: pointer; + font-weight: normal; + } + + input[type=checkbox] { + height: 10em; + float: right; + } + } + + div.buttons { + padding-top: 1em; + clear: both; + } +} \ No newline at end of file From 4589621f58e1127db7e0309c2a55bf0017ababc5 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Thu, 22 Jan 2015 10:57:44 +0100 Subject: [PATCH 0321/2920] monitoring: Use host and service display_name for displaying host and service names for an object's history refs #7843 --- .../views/scripts/show/history.phtml | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/modules/monitoring/application/views/scripts/show/history.phtml b/modules/monitoring/application/views/scripts/show/history.phtml index 728b9bfc1..a0cc4944e 100644 --- a/modules/monitoring/application/views/scripts/show/history.phtml +++ b/modules/monitoring/application/views/scripts/show/history.phtml @@ -136,13 +136,18 @@ $output = $this->tickets ? preg_replace_callback( ?> - qlink( - $this->escape($event->service_description), - 'monitoring/show/service', - array( - 'host' => $event->host_name, - 'service' => $event->service_description) - ) : $this->escape($event->service_description); ?> translate('on') . ' ' . $this->escape($event->host_name); ?> + translate('%s on %s', 'Service running on host'), + $hostContext ? $this->qlink( + $this->escape($event->service_display_name), + 'monitoring/show/service', + array( + 'host' => $event->host_name, + 'service' => $event->service_description + ) + ) : $this->escape($event->service_display_name), + $event->host_display_name + ) ?> escape($event->host_name); ?> From 8bd56f4387c6f579bef062926bf5b94fe6e199da Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Thu, 22 Jan 2015 10:58:16 +0100 Subject: [PATCH 0322/2920] monitoring: Use the Link helper in the eventhistory overview --- .../views/scripts/list/eventhistory.phtml | 18 ++++-------------- 1 file changed, 4 insertions(+), 14 deletions(-) diff --git a/modules/monitoring/application/views/scripts/list/eventhistory.phtml b/modules/monitoring/application/views/scripts/list/eventhistory.phtml index d96a4914b..2970675e2 100644 --- a/modules/monitoring/application/views/scripts/list/eventhistory.phtml +++ b/modules/monitoring/application/views/scripts/list/eventhistory.phtml @@ -106,21 +106,11 @@ use Icinga\Module\Monitoring\Object\Service;
    - + diff --git a/modules/setup/library/Setup/Requirements.php b/modules/setup/library/Setup/Requirements.php index 4b3d411cb..ab9e693e5 100644 --- a/modules/setup/library/Setup/Requirements.php +++ b/modules/setup/library/Setup/Requirements.php @@ -9,6 +9,9 @@ use IteratorAggregate; /** * Container to store and handle requirements + * + * TODO: Requirements should be registered as objects with a specific purpose (PhpModRequirement, PhpIniRequirement, ..) + * so that it's not necessary to define unique identifiers which may differ between different modules. */ class Requirements implements IteratorAggregate { @@ -41,12 +44,40 @@ class Requirements implements IteratorAggregate * * @return self */ - public function add($requirement) + public function add($name, $requirement) { - $this->requirements[] = $requirement; + $this->requirements[$name] = array_key_exists($name, $this->requirements) + ? $this->combine($this->requirements[$name], $requirement) + : $requirement; return $this; } + /** + * Combine the two given requirements + * + * Returns the most important requirement with the description from the other one being added. + * + * @param object $oldRequirement + * @param object $newRequirement + * + * @return object + */ + protected function combine($oldRequirement, $newRequirement) + { + if ($newRequirement->state === static::STATE_MANDATORY && $oldRequirement->state === static::STATE_OPTIONAL) { + $tempRequirement = $oldRequirement; + $oldRequirement = $newRequirement; + $newRequirement = $tempRequirement; + } + + if (! is_array($oldRequirement->description)) { + $oldRequirement->description = array($oldRequirement->description); + } + + $oldRequirement->description[] = $newRequirement->description; + return $oldRequirement; + } + /** * Return all registered requirements * @@ -70,6 +101,7 @@ class Requirements implements IteratorAggregate /** * Register an optional requirement * + * @param string $name * @param string $title * @param string $description * @param bool $state @@ -77,20 +109,24 @@ class Requirements implements IteratorAggregate * * @return self */ - public function addOptional($title, $description, $state, $message) + public function addOptional($name, $title, $description, $state, $message) { - $this->add((object) array( - 'title' => $title, - 'message' => $message, - 'description' => $description, - 'state' => (bool) $state ? static::STATE_OK : static::STATE_OPTIONAL - )); + $this->add( + $name, + (object) array( + 'title' => $title, + 'message' => $message, + 'description' => $description, + 'state' => (bool) $state ? static::STATE_OK : static::STATE_OPTIONAL + ) + ); return $this; } /** * Register a mandatory requirement * + * @param string $name * @param string $title * @param string $description * @param bool $state @@ -98,14 +134,17 @@ class Requirements implements IteratorAggregate * * @return self */ - public function addMandatory($title, $description, $state, $message) + public function addMandatory($name, $title, $description, $state, $message) { - $this->add((object) array( - 'title' => $title, - 'message' => $message, - 'description' => $description, - 'state' => (bool) $state ? static::STATE_OK : static::STATE_MANDATORY - )); + $this->add( + $name, + (object) array( + 'title' => $title, + 'message' => $message, + 'description' => $description, + 'state' => (bool) $state ? static::STATE_OK : static::STATE_MANDATORY + ) + ); return $this; } @@ -118,8 +157,8 @@ class Requirements implements IteratorAggregate */ public function merge(Requirements $requirements) { - foreach ($requirements->getAll() as $requirement) { - $this->add($requirement); + foreach ($requirements->getAll() as $name => $requirement) { + $this->add($name, $requirement); } return $this; diff --git a/modules/setup/library/Setup/WebWizard.php b/modules/setup/library/Setup/WebWizard.php index 395c5af8e..58c7c6259 100644 --- a/modules/setup/library/Setup/WebWizard.php +++ b/modules/setup/library/Setup/WebWizard.php @@ -366,6 +366,7 @@ class WebWizard extends Wizard implements SetupWizard $phpVersion = Platform::getPhpVersion(); $requirements->addMandatory( + 'php_version_>=_5_3_2', mt('setup', 'PHP Version'), mt( 'setup', @@ -378,6 +379,7 @@ class WebWizard extends Wizard implements SetupWizard $defaultTimezone = Platform::getPhpConfig('date.timezone'); $requirements->addMandatory( + 'existing_default_timezone', mt('setup', 'Default Timezone'), sprintf( mt('setup', 'It is required that a default timezone has been set using date.timezone in %s.'), @@ -390,6 +392,7 @@ class WebWizard extends Wizard implements SetupWizard ); $requirements->addOptional( + 'platform=linux', mt('setup', 'Linux Platform'), mt( 'setup', @@ -401,6 +404,7 @@ class WebWizard extends Wizard implements SetupWizard ); $requirements->addMandatory( + 'existing_php_mod_openssl', mt('setup', 'PHP Module: OpenSSL'), mt('setup', 'The PHP module for OpenSSL is required to generate cryptographically safe password salts.'), Platform::extensionLoaded('openssl'), @@ -410,6 +414,7 @@ class WebWizard extends Wizard implements SetupWizard ); $requirements->addOptional( + 'existing_php_mod_json', mt('setup', 'PHP Module: JSON'), mt('setup', 'The JSON module for PHP is required for various export functionalities as well as APIs.'), Platform::extensionLoaded('json'), @@ -419,6 +424,7 @@ class WebWizard extends Wizard implements SetupWizard ); $requirements->addOptional( + 'existing_php_mod_ldap', mt('setup', 'PHP Module: LDAP'), mt('setup', 'If you\'d like to authenticate users using LDAP the corresponding PHP module is required'), Platform::extensionLoaded('ldap'), @@ -428,6 +434,7 @@ class WebWizard extends Wizard implements SetupWizard ); $requirements->addOptional( + 'existing_php_mod_intl', mt('setup', 'PHP Module: INTL'), mt( 'setup', @@ -442,6 +449,7 @@ class WebWizard extends Wizard implements SetupWizard // TODO(6172): Remove this requirement once we do not ship dompdf with Icinga Web 2 anymore $requirements->addOptional( + 'existing_php_mod_dom', mt('setup', 'PHP Module: DOM'), mt('setup', 'To be able to export views and reports to PDF, the DOM module for PHP is required.'), Platform::extensionLoaded('dom'), @@ -451,6 +459,7 @@ class WebWizard extends Wizard implements SetupWizard ); $requirements->addOptional( + 'existing_php_mod_gd', mt('setup', 'PHP Module: GD'), mt( 'setup', @@ -464,6 +473,7 @@ class WebWizard extends Wizard implements SetupWizard ); $requirements->addOptional( + 'existing_php_mod_imagick', mt('setup', 'PHP Module: Imagick'), mt( 'setup', @@ -477,6 +487,7 @@ class WebWizard extends Wizard implements SetupWizard ); $requirements->addOptional( + 'existing_php_mod_pdo_mysql', mt('setup', 'PHP Module: PDO-MySQL'), mt( 'setup', @@ -489,6 +500,7 @@ class WebWizard extends Wizard implements SetupWizard ); $requirements->addOptional( + 'existing_php_mod_pdo_pgsql', mt('setup', 'PHP Module: PDO-PostgreSQL'), mt( 'setup', @@ -503,6 +515,7 @@ class WebWizard extends Wizard implements SetupWizard $mysqlAdapterFound = Platform::zendClassExists('Zend_Db_Adapter_Pdo_Mysql'); $requirements->addOptional( + 'existing_class_Zend_Db_Adapter_Pdo_Mysql', mt('setup', 'Zend Database Adapter For MySQL'), mt('setup', 'The Zend database adapter for MySQL is required to access a MySQL database.'), $mysqlAdapterFound, @@ -513,6 +526,7 @@ class WebWizard extends Wizard implements SetupWizard $pgsqlAdapterFound = Platform::zendClassExists('Zend_Db_Adapter_Pdo_Pgsql'); $requirements->addOptional( + 'existing_class_Zend_Db_Adapter_Pdo_Pgsql', mt('setup', 'Zend Database Adapter For PostgreSQL'), mt('setup', 'The Zend database adapter for PostgreSQL is required to access a PostgreSQL database.'), $pgsqlAdapterFound, @@ -523,6 +537,7 @@ class WebWizard extends Wizard implements SetupWizard $configDir = Icinga::app()->getConfigDir(); $requirements->addMandatory( + 'writable_directory_' . $configDir, mt('setup', 'Writable Config Directory'), mt( 'setup', @@ -539,8 +554,6 @@ class WebWizard extends Wizard implements SetupWizard ); foreach ($this->getWizards() as $wizard) { - // TODO(8191): Ensure that equal requirements are not shown individually but only - // once with their description properly being merged together! $requirements->merge($wizard->getRequirements()); } diff --git a/public/css/icinga/setup.less b/public/css/icinga/setup.less index d6692b501..0bf8eb7b2 100644 --- a/public/css/icinga/setup.less +++ b/public/css/icinga/setup.less @@ -176,6 +176,12 @@ margin: 0 1em 0 0; } + ul { + margin: 0; + padding-left: 1em; + list-style-type: square; + } + &.state { color: white; padding: 0.4em; From 9c47b2d94943a2a4f81588c5e9c3b104c1731518 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Thu, 22 Jan 2015 12:49:02 +0100 Subject: [PATCH 0325/2920] monitoring: Fix permission description for 'monitoring/command/schedule' --- modules/monitoring/configuration.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/monitoring/configuration.php b/modules/monitoring/configuration.php index f56c23d5c..383f06a54 100644 --- a/modules/monitoring/configuration.php +++ b/modules/monitoring/configuration.php @@ -10,7 +10,7 @@ $this->providePermission( ); $this->providePermission( 'monitoring/command/schedule*', - $this->translate('Allow all scheduling checks and downtimes') + $this->translate('Allow scheduling checks and downtimes') ); $this->providePermission( 'monitoring/command/schedule-check', From 32c64f7e3dcc1592d9cd9ccdb14c3a5685bd6a03 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Thu, 22 Jan 2015 13:47:45 +0100 Subject: [PATCH 0326/2920] layout: Do not duplicate code from layout/menu.phtml in navigation.phtml --- .../layouts/scripts/parts/navigation.phtml | 24 +++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/application/layouts/scripts/parts/navigation.phtml b/application/layouts/scripts/parts/navigation.phtml index bed44ba5f..dc56b9199 100644 --- a/application/layouts/scripts/parts/navigation.phtml +++ b/application/layouts/scripts/parts/navigation.phtml @@ -3,7 +3,6 @@ use Icinga\Web\Url; use Icinga\Web\Menu; use Icinga\Web\MenuRenderer; -use Icinga\Web\Widget\SearchDashboard; // Don't render a menu for unauthenticated users unless menu is auth aware if (! $this->auth()->isAuthenticated()) { @@ -11,15 +10,16 @@ if (! $this->auth()->isAuthenticated()) { } ?> - diff --git a/modules/monitoring/application/views/scripts/show/components/downtime.phtml b/modules/monitoring/application/views/scripts/show/components/downtime.phtml index 37eeef14b..f95ea582c 100644 --- a/modules/monitoring/application/views/scripts/show/components/downtime.phtml +++ b/modules/monitoring/application/views/scripts/show/components/downtime.phtml @@ -1,32 +1,27 @@ From a166234e6d3242021c34a56b6f7ac67dcad6d2ba Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Fri, 23 Jan 2015 10:40:48 +0100 Subject: [PATCH 0355/2920] monitoring/security: Hide 'Reschedule check' link if user lacks the respective permission --- .../show/components/checkstatistics.phtml | 49 +++++++++++-------- 1 file changed, 29 insertions(+), 20 deletions(-) diff --git a/modules/monitoring/application/views/scripts/show/components/checkstatistics.phtml b/modules/monitoring/application/views/scripts/show/components/checkstatistics.phtml index e8c295298..5b54ae4ab 100644 --- a/modules/monitoring/application/views/scripts/show/components/checkstatistics.phtml +++ b/modules/monitoring/application/views/scripts/show/components/checkstatistics.phtml @@ -1,19 +1,13 @@ getType() === $object::TYPE_HOST) { - $reschedule = $this->href( - 'monitoring/host/reschedule-check', - array('host' => $object->getName()) - ); + $isService = false; $checkAttempts = $object->host_current_check_attempt . '/' . $object->host_max_check_attempts; $stateType = (int) $object->host_state_type; } else { - $reschedule = $this->href( - 'monitoring/service/reschedule-check', - array('host' => $object->getHost()->getName(), 'service' => $object->getName()) - ); + $isService = true; $checkAttempts = $object->service_attempt; $stateType = (int) $object->service_state_type; } @@ -32,29 +26,44 @@ if ($object->getType() === $object::TYPE_HOST) { - + - + check_execution_time): ?> - - - - + + + + check_latency): ?> - - - - + + + + From 27c15002956a0fbd3ae7c124a1426da64da87df4 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Fri, 23 Jan 2015 10:41:42 +0100 Subject: [PATCH 0356/2920] monitoring: Do not translate brackets --- .../views/scripts/show/components/checkstatistics.phtml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/monitoring/application/views/scripts/show/components/checkstatistics.phtml b/modules/monitoring/application/views/scripts/show/components/checkstatistics.phtml index 5b54ae4ab..9a6f24efc 100644 --- a/modules/monitoring/application/views/scripts/show/components/checkstatistics.phtml +++ b/modules/monitoring/application/views/scripts/show/components/checkstatistics.phtml @@ -50,9 +50,9 @@ if ($object->getType() === $object::TYPE_HOST) { - + - + check_execution_time): ?> From 2535d802b1d73e92d04ec17880abe7fac40fc668 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Fri, 23 Jan 2015 10:45:10 +0100 Subject: [PATCH 0357/2920] monitoring: Add missing td closing tag --- .../application/views/scripts/show/components/command.phtml | 1 + 1 file changed, 1 insertion(+) diff --git a/modules/monitoring/application/views/scripts/show/components/command.phtml b/modules/monitoring/application/views/scripts/show/components/command.phtml index a13ed1bee..dd8996d58 100644 --- a/modules/monitoring/application/views/scripts/show/components/command.phtml +++ b/modules/monitoring/application/views/scripts/show/components/command.phtml @@ -20,6 +20,7 @@ $command = array_shift($parts); ); ?>">icon('reply'); ?> translate('Process check result'); ?> + Date: Fri, 23 Jan 2015 10:48:21 +0100 Subject: [PATCH 0358/2920] monitoring/security: Hide 'Process check result' link if user lacks the respective permission --- .../scripts/show/components/command.phtml | 43 +++++++++++-------- 1 file changed, 25 insertions(+), 18 deletions(-) diff --git a/modules/monitoring/application/views/scripts/show/components/command.phtml b/modules/monitoring/application/views/scripts/show/components/command.phtml index dd8996d58..5239dad41 100644 --- a/modules/monitoring/application/views/scripts/show/components/command.phtml +++ b/modules/monitoring/application/views/scripts/show/components/command.phtml @@ -3,25 +3,32 @@ $parts = explode('!', $object->check_command); $command = array_shift($parts); -?> - - +?> + + + + + \n \n \n\n"; From 3cb2dd0e8b09880dbe6e2053910ac16318ac0756 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Fri, 23 Jan 2015 11:01:47 +0100 Subject: [PATCH 0359/2920] monitoring/security: Hide 'Acknowledge' link if user lacks the respective permission --- .../show/components/acknowledgement.phtml | 29 ++++++++++--------- .../scripts/show/components/comments.phtml | 2 +- .../scripts/show/components/downtime.phtml | 2 +- 3 files changed, 17 insertions(+), 16 deletions(-) diff --git a/modules/monitoring/application/views/scripts/show/components/acknowledgement.phtml b/modules/monitoring/application/views/scripts/show/components/acknowledgement.phtml index 02415ec19..339652113 100644 --- a/modules/monitoring/application/views/scripts/show/components/acknowledgement.phtml +++ b/modules/monitoring/application/views/scripts/show/components/acknowledgement.phtml @@ -7,18 +7,6 @@ if (in_array((int) $object->state, array(0, 99))) { return; } -if ($object->getType() === $object::TYPE_HOST) { - $ackLink = $this->href( - 'monitoring/host/acknowledge-problem', - array('host' => $object->getName()) - ); -} else { - $ackLink = $this->href( - 'monitoring/service/acknowledge-problem', - array('host' => $object->getHost()->getName(), 'service' => $object->getName()) - ); -} - if ($object->acknowledged): ?> @@ -34,12 +22,25 @@ if ($object->acknowledged): ?> diff --git a/modules/monitoring/application/views/scripts/show/components/comments.phtml b/modules/monitoring/application/views/scripts/show/components/comments.phtml index b967cc67e..dde42c747 100644 --- a/modules/monitoring/application/views/scripts/show/components/comments.phtml +++ b/modules/monitoring/application/views/scripts/show/components/comments.phtml @@ -21,7 +21,7 @@ + } // endif ?> diff --git a/modules/monitoring/application/views/scripts/show/components/downtime.phtml b/modules/monitoring/application/views/scripts/show/components/downtime.phtml index f95ea582c..8f42a865e 100644 --- a/modules/monitoring/application/views/scripts/show/components/downtime.phtml +++ b/modules/monitoring/application/views/scripts/show/components/downtime.phtml @@ -21,7 +21,7 @@ + } // endif ?> From 5ac1eaa513ba2eff9860951f31dec0245c5c961c Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Fri, 23 Jan 2015 11:11:34 +0100 Subject: [PATCH 0360/2920] monitoring: Fix indents in the GroupsummaryQuery --- .../Backend/Ido/Query/GroupsummaryQuery.php | 30 +++++++++---------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/modules/monitoring/library/Monitoring/Backend/Ido/Query/GroupsummaryQuery.php b/modules/monitoring/library/Monitoring/Backend/Ido/Query/GroupsummaryQuery.php index 20e98fc63..de94f3055 100644 --- a/modules/monitoring/library/Monitoring/Backend/Ido/Query/GroupsummaryQuery.php +++ b/modules/monitoring/library/Monitoring/Backend/Ido/Query/GroupsummaryQuery.php @@ -11,7 +11,7 @@ class GroupSummaryQuery extends IdoQuery protected $useSubqueryCount = true; protected $columnMap = array( - 'hoststatussummary' => array( + 'hoststatussummary' => array( 'hosts_up' => 'SUM(CASE WHEN object_type = \'host\' AND state = 0 THEN 1 ELSE 0 END)', 'hosts_unreachable' => 'SUM(CASE WHEN object_type = \'host\' AND state = 2 THEN 1 ELSE 0 END)', 'hosts_unreachable_handled' => 'SUM(CASE WHEN object_type = \'host\' AND state = 2 AND acknowledged + in_downtime != 0 THEN 1 ELSE 0 END)', @@ -22,19 +22,19 @@ class GroupSummaryQuery extends IdoQuery 'hosts_pending' => 'SUM(CASE WHEN object_type = \'host\' AND state = 99 THEN 1 ELSE 0 END)', 'hostgroup' => 'hostgroup' ), - 'servicestatussummary' => array( - 'services_total' => 'SUM(CASE WHEN object_type = \'service\' THEN 1 ELSE 0 END)', - 'services_ok' => 'SUM(CASE WHEN object_type = \'service\' AND state = 0 THEN 1 ELSE 0 END)', - 'services_pending' => 'SUM(CASE WHEN object_type = \'service\' AND state = 99 THEN 1 ELSE 0 END)', - 'services_warning' => 'SUM(CASE WHEN object_type = \'service\' AND state = 1 THEN 1 ELSE 0 END)', - 'services_warning_handled' => 'SUM(CASE WHEN object_type = \'service\' AND state = 1 AND acknowledged + in_downtime + host_state > 0 THEN 1 ELSE 0 END)', - 'services_critical' => 'SUM(CASE WHEN object_type = \'service\' AND state = 2 THEN 1 ELSE 0 END)', - 'services_critical_handled' => 'SUM(CASE WHEN object_type = \'service\' AND state = 2 AND acknowledged + in_downtime + host_state > 0 THEN 1 ELSE 0 END)', - 'services_unknown' => 'SUM(CASE WHEN object_type = \'service\' AND state = 3 THEN 1 ELSE 0 END)', - 'services_unknown_handled' => 'SUM(CASE WHEN object_type = \'service\' AND state = 3 AND acknowledged + in_downtime + host_state > 0 THEN 1 ELSE 0 END)', - 'services_warning_unhandled' => 'SUM(CASE WHEN object_type = \'service\' AND state = 1 AND acknowledged + in_downtime + host_state = 0 THEN 1 ELSE 0 END)', - 'services_critical_unhandled' => 'SUM(CASE WHEN object_type = \'service\' AND state = 2 AND acknowledged + in_downtime + host_state = 0 THEN 1 ELSE 0 END)', - 'services_unknown_unhandled' => 'SUM(CASE WHEN object_type = \'service\' AND state = 3 AND acknowledged + in_downtime + host_state = 0 THEN 1 ELSE 0 END)', + 'servicestatussummary' => array( + 'services_total' => 'SUM(CASE WHEN object_type = \'service\' THEN 1 ELSE 0 END)', + 'services_ok' => 'SUM(CASE WHEN object_type = \'service\' AND state = 0 THEN 1 ELSE 0 END)', + 'services_pending' => 'SUM(CASE WHEN object_type = \'service\' AND state = 99 THEN 1 ELSE 0 END)', + 'services_warning' => 'SUM(CASE WHEN object_type = \'service\' AND state = 1 THEN 1 ELSE 0 END)', + 'services_warning_handled' => 'SUM(CASE WHEN object_type = \'service\' AND state = 1 AND acknowledged + in_downtime + host_state > 0 THEN 1 ELSE 0 END)', + 'services_critical' => 'SUM(CASE WHEN object_type = \'service\' AND state = 2 THEN 1 ELSE 0 END)', + 'services_critical_handled' => 'SUM(CASE WHEN object_type = \'service\' AND state = 2 AND acknowledged + in_downtime + host_state > 0 THEN 1 ELSE 0 END)', + 'services_unknown' => 'SUM(CASE WHEN object_type = \'service\' AND state = 3 THEN 1 ELSE 0 END)', + 'services_unknown_handled' => 'SUM(CASE WHEN object_type = \'service\' AND state = 3 AND acknowledged + in_downtime + host_state > 0 THEN 1 ELSE 0 END)', + 'services_warning_unhandled' => 'SUM(CASE WHEN object_type = \'service\' AND state = 1 AND acknowledged + in_downtime + host_state = 0 THEN 1 ELSE 0 END)', + 'services_critical_unhandled' => 'SUM(CASE WHEN object_type = \'service\' AND state = 2 AND acknowledged + in_downtime + host_state = 0 THEN 1 ELSE 0 END)', + 'services_unknown_unhandled' => 'SUM(CASE WHEN object_type = \'service\' AND state = 3 AND acknowledged + in_downtime + host_state = 0 THEN 1 ELSE 0 END)', 'services_severity' => 'MAX(CASE WHEN object_type = \'service\' THEN severity ELSE 0 END)', 'services_ok_last_state_change' => 'MAX(CASE WHEN object_type = \'service\' AND state = 0 THEN state_change ELSE 0 END)', 'services_pending_last_state_change' => 'MAX(CASE WHEN object_type = \'service\' AND state = 99 THEN state_change ELSE 0 END)', @@ -44,7 +44,7 @@ class GroupSummaryQuery extends IdoQuery 'services_warning_last_state_change_unhandled' => 'MAX(CASE WHEN object_type = \'service\' AND state = 1 AND acknowledged + in_downtime + host_state = 0 THEN state_change ELSE 0 END)', 'services_critical_last_state_change_unhandled' => 'MAX(CASE WHEN object_type = \'service\' AND state = 2 AND acknowledged + in_downtime + host_state = 0 THEN state_change ELSE 0 END)', 'services_unknown_last_state_change_unhandled' => 'MAX(CASE WHEN object_type = \'service\' AND state = 3 AND acknowledged + in_downtime + host_state = 0 THEN state_change ELSE 0 END)', - 'servicegroup' => 'servicegroup' + 'servicegroup' => 'servicegroup' ) ); From b54564eb5c4843e1ad2aa2ff5b77f5a5c2dcbbad Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Fri, 23 Jan 2015 11:20:00 +0100 Subject: [PATCH 0361/2920] monitoring: Escape the host group's name in the hostgroups overview --- .../monitoring/application/views/scripts/list/hostgroups.phtml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/monitoring/application/views/scripts/list/hostgroups.phtml b/modules/monitoring/application/views/scripts/list/hostgroups.phtml index 0e21dc3ee..9fae0ac31 100644 --- a/modules/monitoring/application/views/scripts/list/hostgroups.phtml +++ b/modules/monitoring/application/views/scripts/list/hostgroups.phtml @@ -80,7 +80,7 @@ From f0784caaadaf0bf10bafb260804ace9009fb7c68 Mon Sep 17 00:00:00 2001 From: Alexander Klimov Date: Mon, 26 Jan 2015 14:09:39 +0100 Subject: [PATCH 0388/2920] Hosts view: show object amounts in titles --- .../views/scripts/hosts/show.phtml | 24 +++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/modules/monitoring/application/views/scripts/hosts/show.phtml b/modules/monitoring/application/views/scripts/hosts/show.phtml index 6ab717635..6e114f2d8 100644 --- a/modules/monitoring/application/views/scripts/hosts/show.phtml +++ b/modules/monitoring/application/views/scripts/hosts/show.phtml @@ -24,7 +24,10 @@ @@ -100,9 +103,19 @@

    + title="translate('List all hosts in downtime (%u)'), + count($objectsInDowntime) + ); ?>"> icon('plug') ?> - translate(sprintf('%u hosts are in downtime', count($objectsInDowntime))) ?> + translatePlural( + '%u host is in downtime', + '%u hosts are in downtime', + count($objectsInDowntime) + ), + count($objectsInDowntime) + ); ?>

    @@ -110,7 +123,10 @@ getComments())): ?>

    + title="translate('List all Comments (%u)'), + count($objects->getComments()) + ); ?>"> icon('comment') ?> translate(sprintf('%u comments', count($objects->getComments()))) ?> From 7006bbf8b228b47219e98d63a40bd9bff7a10475 Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Mon, 26 Jan 2015 14:13:10 +0100 Subject: [PATCH 0389/2920] Suggest "icingaweb2" as group instead of the webserver's user ..and note that it is necessary to create this group. --- .../application/views/scripts/form/setup-welcome.phtml | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/modules/setup/application/views/scripts/form/setup-welcome.phtml b/modules/setup/application/views/scripts/form/setup-welcome.phtml index aa51ffba6..d4bc1c3d7 100644 --- a/modules/setup/application/views/scripts/form/setup-welcome.phtml +++ b/modules/setup/application/views/scripts/form/setup-welcome.phtml @@ -41,14 +41,18 @@ $cliPath = realpath(Icinga::app()->getApplicationDir() . '/../bin/icingacli'); 'To run this wizard a user needs to authenticate using a token which is usually' . ' provided to him by an administrator who\'d followed the instructions below.' ); ?>

    +

    translate('In any case, make sure that a group called "icingaweb2" exists:'); ?>

    +
    + groupadd icingaweb2; +

    translate('If you\'ve got the IcingaCLI installed you can do the following:'); ?>

    - setup config directory --group ; + setup config directory --group icingaweb2; setup token create;

    translate('In case the IcingaCLI is missing you can create the token manually:'); ?>

    - su -c "mkdir -m 2770 ; head -c 12 /dev/urandom | base64 | tee ; chmod 0660 ;"; + su -c "mkdir -m 2770 ; chgrp icingaweb2 ; head -c 12 /dev/urandom | base64 | tee ; chmod 0660 ;";

    translate('Please see the %s for an extensive description on how to access and use this wizard.'), From fccc2ffbcfe8e972f64037d1ad7c315902525d67 Mon Sep 17 00:00:00 2001 From: Alexander Klimov Date: Mon, 26 Jan 2015 14:17:48 +0100 Subject: [PATCH 0390/2920] Hosts list: use $this->translatePlural() --- .../monitoring/application/views/scripts/list/hosts.phtml | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/modules/monitoring/application/views/scripts/list/hosts.phtml b/modules/monitoring/application/views/scripts/list/hosts.phtml index debef375c..3953db975 100644 --- a/modules/monitoring/application/views/scripts/list/hosts.phtml +++ b/modules/monitoring/application/views/scripts/list/hosts.phtml @@ -100,9 +100,11 @@ if ($hosts->count() === 0) { host_name ?> host_unhandled_services) && $host->host_unhandled_services > 0): ?> - (qlink( + host_unhandled_services), + $host->host_unhandled_services, + $host->host_name + ); ?>"> (qlink( sprintf( $this->translatePlural('%d unhandled service', '%d unhandled services', $host->host_unhandled_services), $host->host_unhandled_services), From 917e5b81ba0f8f773981ebb5683a353e6634a517 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Mon, 26 Jan 2015 15:31:57 +0100 Subject: [PATCH 0391/2920] rpm: Fix bad %if condition --- icingaweb2.spec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/icingaweb2.spec b/icingaweb2.spec index 56024a962..cd1ee485f 100644 --- a/icingaweb2.spec +++ b/icingaweb2.spec @@ -22,7 +22,7 @@ Packager: Icinga Team %define php php %define php_cli php-cli %endif -%if 0%{rhel} == 6 +%if 0%{?rhel} == 6 %define zend php-ZendFramework %else %define zend %{name}-vendor-Zend From 45408e45afd36dc91f92c2226d0b773ef409aaa7 Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Mon, 26 Jan 2015 15:51:34 +0100 Subject: [PATCH 0392/2920] Relax database permission checks in the setup wizard The wizard considered all permissions being exclusively associated to their most important context, which is, in the most common case, incorrect. Permissions assigned on database level do not need to be assigned on table level as well. refs #8267 --- modules/setup/library/Setup/Utils/DbTool.php | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/modules/setup/library/Setup/Utils/DbTool.php b/modules/setup/library/Setup/Utils/DbTool.php index a368bfa1a..63184acd0 100644 --- a/modules/setup/library/Setup/Utils/DbTool.php +++ b/modules/setup/library/Setup/Utils/DbTool.php @@ -641,7 +641,8 @@ EOD; foreach ($mysqlPrivileges as $privilege) { if (false === empty($context) && $this->mysqlGrantContexts[$privilege] & static::TABLE_LEVEL) { $tablePrivileges[] = $privilege; - } elseif ($this->mysqlGrantContexts[$privilege] & static::DATABASE_LEVEL) { + } + if ($this->mysqlGrantContexts[$privilege] & static::DATABASE_LEVEL) { $dbPrivileges[] = $privilege; } } @@ -661,7 +662,11 @@ EOD; } $tablePrivilegesGranted = true; - if (false === empty($tablePrivileges)) { + if ( + false === empty($tablePrivileges) && ( + !$dbPrivilegesGranted || array_intersect($dbPrivileges, $tablePrivileges) != $tablePrivileges + ) + ) { $tableCondition = 'table_name IN (' . join(',', array_map(array($this, 'quote'), $context)) . ')'; $query = $this->query( 'SELECT COUNT(*) as matches' From 0fa133abfb4dd636038baeab563c639e339d4ad7 Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Mon, 26 Jan 2015 16:58:40 +0100 Subject: [PATCH 0393/2920] setup: Display a note in case autologin is chosen while not being logged in In case the user chooses to use autologin as authentication while not being externally authenticated a note is displayed indicating that it is necessary to set up the webserver's authentication to be able to login once the wizard is complete. refs #8274 --- .../application/forms/AuthenticationPage.php | 27 +++++++++++++++++++ public/css/icinga/setup.less | 10 +++++++ 2 files changed, 37 insertions(+) diff --git a/modules/setup/application/forms/AuthenticationPage.php b/modules/setup/application/forms/AuthenticationPage.php index 88db9c6d8..ca182a4b1 100644 --- a/modules/setup/application/forms/AuthenticationPage.php +++ b/modules/setup/application/forms/AuthenticationPage.php @@ -36,6 +36,32 @@ class AuthenticationPage extends Form ) ) ); + + if (isset($formData['type']) && $formData['type'] === 'autologin' && !isset($_SERVER['REMOTE_USER'])) { + $this->addElement( + 'note', + 'autologin_note', + array( + 'value' => sprintf( + $this->translate( + 'You\'re currently not authenticated using any of the web server\'s authentication ' + . 'mechanisms. Make sure you\'ll configure such either by using the %s or by setting' + . ' it up manually, otherwise you\'ll not be able to log into Icinga Web 2 once the ' + . 'wizard is complete.' + ), + 'IcingaCLI' + ), + 'decorators' => array( + 'ViewHelper', + array( + 'HtmlTag', + array('tag' => 'p', 'class' => 'icon-info info') + ) + ) + ) + ); + } + $this->addElement( 'note', 'description', @@ -61,6 +87,7 @@ class AuthenticationPage extends Form 'type', array( 'required' => true, + 'autosubmit' => true, 'label' => $this->translate('Authentication Type'), 'description' => $this->translate('The type of authentication to use when accessing Icinga Web 2'), 'multiOptions' => $backendTypes diff --git a/public/css/icinga/setup.less b/public/css/icinga/setup.less index 0bf8eb7b2..2c86a985a 100644 --- a/public/css/icinga/setup.less +++ b/public/css/icinga/setup.less @@ -220,6 +220,16 @@ } } +#setup_authentication_type p.info { + padding: 0.5em; + border: 1px solid lightgrey; + background-color: infobackground; + + em { + text-decoration: underline; + } +} + #setup_ldap_discovery_confirm table { margin: 1em 0; border-collapse: separate; From 50fc85d7ffc1ab8aee0608569997299cc16a0f26 Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Tue, 27 Jan 2015 09:49:36 +0100 Subject: [PATCH 0394/2920] Rename authentication type "autologin" to "external" refs #8274 --- .../templates/authentication.ini.erb | 2 +- ...ackendForm.php => ExternalBackendForm.php} | 10 +++++----- .../AuthenticationBackendConfigForm.php | 20 +++++++++---------- doc/authentication.md | 2 +- ...toLoginBackend.php => ExternalBackend.php} | 6 +++--- library/Icinga/Authentication/UserBackend.php | 6 +++--- .../application/forms/AuthBackendPage.php | 8 ++++---- .../application/forms/AuthenticationPage.php | 6 +++--- .../Setup/Steps/AuthenticationStep.php | 2 +- 9 files changed, 31 insertions(+), 31 deletions(-) rename application/forms/Config/Authentication/{AutologinBackendForm.php => ExternalBackendForm.php} (88%) rename library/Icinga/Authentication/Backend/{AutoLoginBackend.php => ExternalBackend.php} (91%) diff --git a/.puppet/profiles/icingaweb2_dev/templates/authentication.ini.erb b/.puppet/profiles/icingaweb2_dev/templates/authentication.ini.erb index f28395e18..87f9f53ed 100644 --- a/.puppet/profiles/icingaweb2_dev/templates/authentication.ini.erb +++ b/.puppet/profiles/icingaweb2_dev/templates/authentication.ini.erb @@ -1,5 +1,5 @@ [autologin] -backend = autologin +backend = external [icingaweb-mysql] backend = db diff --git a/application/forms/Config/Authentication/AutologinBackendForm.php b/application/forms/Config/Authentication/ExternalBackendForm.php similarity index 88% rename from application/forms/Config/Authentication/AutologinBackendForm.php rename to application/forms/Config/Authentication/ExternalBackendForm.php index cd09d38ac..51000b2d2 100644 --- a/application/forms/Config/Authentication/AutologinBackendForm.php +++ b/application/forms/Config/Authentication/ExternalBackendForm.php @@ -8,16 +8,16 @@ use Zend_Validate_Callback; use Icinga\Web\Form; /** - * Form class for adding/modifying autologin authentication backends + * Form class for adding/modifying authentication backends of type "external" */ -class AutologinBackendForm extends Form +class ExternalBackendForm extends Form { /** * Initialize this form */ public function init() { - $this->setName('form_config_authbackend_autologin'); + $this->setName('form_config_authbackend_external'); } /** @@ -69,7 +69,7 @@ class AutologinBackendForm extends Form 'backend', array( 'disabled' => true, - 'value' => 'autologin' + 'value' => 'external' ) ); @@ -79,7 +79,7 @@ class AutologinBackendForm extends Form /** * Validate the configuration by creating a backend and requesting the user count * - * Returns always true as autologin backends are just "passive" backends. (The webserver authenticates users.) + * Returns always true as backends of type "external" are just "passive" backends. * * @param Form $form The form to fetch the configuration values from * diff --git a/application/forms/Config/AuthenticationBackendConfigForm.php b/application/forms/Config/AuthenticationBackendConfigForm.php index 076f8cb17..de3093ada 100644 --- a/application/forms/Config/AuthenticationBackendConfigForm.php +++ b/application/forms/Config/AuthenticationBackendConfigForm.php @@ -14,7 +14,7 @@ use Icinga\Data\ResourceFactory; use Icinga\Exception\ConfigurationError; use Icinga\Forms\Config\Authentication\DbBackendForm; use Icinga\Forms\Config\Authentication\LdapBackendForm; -use Icinga\Forms\Config\Authentication\AutologinBackendForm; +use Icinga\Forms\Config\Authentication\ExternalBackendForm; class AuthenticationBackendConfigForm extends ConfigForm { @@ -67,8 +67,8 @@ class AuthenticationBackendConfigForm extends ConfigForm } elseif ($type === 'ldap') { $form = new LdapBackendForm(); $form->setResources(isset($this->resources['ldap']) ? $this->resources['ldap'] : array()); - } elseif ($type === 'autologin') { - $form = new AutologinBackendForm(); + } elseif ($type === 'external') { + $form = new ExternalBackendForm(); } else { throw new InvalidArgumentException(sprintf($this->translate('Invalid backend type "%s" provided'), $type)); } @@ -251,14 +251,14 @@ class AuthenticationBackendConfigForm extends ConfigForm $configValues['name'] = $authBackend; $this->populate($configValues); } elseif (empty($this->resources)) { - $autologinBackends = array_filter( + $externalBackends = array_filter( $this->config->toArray(), function ($authBackendCfg) { - return isset($authBackendCfg['backend']) && $authBackendCfg['backend'] === 'autologin'; + return isset($authBackendCfg['backend']) && $authBackendCfg['backend'] === 'external'; } ); - if (false === empty($autologinBackends)) { + if (false === empty($externalBackends)) { throw new ConfigurationError($this->translate('Could not find any resources for authentication')); } } @@ -299,14 +299,14 @@ class AuthenticationBackendConfigForm extends ConfigForm $backendTypes['ldap'] = 'LDAP'; } - $autologinBackends = array_filter( + $externalBackends = array_filter( $this->config->toArray(), function ($authBackendCfg) { - return isset($authBackendCfg['backend']) && $authBackendCfg['backend'] === 'autologin'; + return isset($authBackendCfg['backend']) && $authBackendCfg['backend'] === 'external'; } ); - if ($backendType === 'autologin' || empty($autologinBackends)) { - $backendTypes['autologin'] = $this->translate('Autologin'); + if ($backendType === 'external' || empty($externalBackends)) { + $backendTypes['external'] = $this->translate('External'); } if ($backendType === null) { diff --git a/doc/authentication.md b/doc/authentication.md index d36051e8f..542eb9934 100644 --- a/doc/authentication.md +++ b/doc/authentication.md @@ -24,7 +24,7 @@ For delegating authentication to the web server simply add `autologin` to your a ```` [autologin] -backend = autologin +backend = external ```` If your web server is not configured for authentication though the `autologin` section has no effect. diff --git a/library/Icinga/Authentication/Backend/AutoLoginBackend.php b/library/Icinga/Authentication/Backend/ExternalBackend.php similarity index 91% rename from library/Icinga/Authentication/Backend/AutoLoginBackend.php rename to library/Icinga/Authentication/Backend/ExternalBackend.php index b4a70bd4f..d5eb491e5 100644 --- a/library/Icinga/Authentication/Backend/AutoLoginBackend.php +++ b/library/Icinga/Authentication/Backend/ExternalBackend.php @@ -11,7 +11,7 @@ use Icinga\User; /** * Test login with external authentication mechanism, e.g. Apache */ -class AutoLoginBackend extends UserBackend +class ExternalBackend extends UserBackend { /** * Regexp expression to strip values from a username @@ -21,7 +21,7 @@ class AutoLoginBackend extends UserBackend private $stripUsernameRegexp; /** - * Create new autologin backend + * Create new authentication backend of type "external" * * @param ConfigObject $config */ @@ -33,7 +33,7 @@ class AutoLoginBackend extends UserBackend /** * Count the available users * - * Autologin backends will always return 1 + * Authenticaton backends of type "external" will always return 1 * * @return int */ diff --git a/library/Icinga/Authentication/UserBackend.php b/library/Icinga/Authentication/UserBackend.php index eaf39e49d..7215f4d41 100644 --- a/library/Icinga/Authentication/UserBackend.php +++ b/library/Icinga/Authentication/UserBackend.php @@ -5,7 +5,7 @@ namespace Icinga\Authentication; use Countable; -use Icinga\Authentication\Backend\AutoLoginBackend; +use Icinga\Authentication\Backend\ExternalBackend; use Icinga\Authentication\Backend\DbUserBackend; use Icinga\Authentication\Backend\LdapUserBackend; use Icinga\Data\ConfigObject; @@ -69,8 +69,8 @@ abstract class UserBackend implements Countable ); } $backendType = strtolower($backendType); - if ($backendType === 'autologin') { - $backend = new AutoLoginBackend($backendConfig); + if ($backendType === 'external') { + $backend = new ExternalBackend($backendConfig); $backend->setName($name); return $backend; } diff --git a/modules/setup/application/forms/AuthBackendPage.php b/modules/setup/application/forms/AuthBackendPage.php index ced0d9c59..b123b5906 100644 --- a/modules/setup/application/forms/AuthBackendPage.php +++ b/modules/setup/application/forms/AuthBackendPage.php @@ -7,7 +7,7 @@ namespace Icinga\Module\Setup\Forms; use Icinga\Web\Form; use Icinga\Forms\Config\Authentication\DbBackendForm; use Icinga\Forms\Config\Authentication\LdapBackendForm; -use Icinga\Forms\Config\Authentication\AutologinBackendForm; +use Icinga\Forms\Config\Authentication\ExternalBackendForm; use Icinga\Data\ConfigObject; /** @@ -80,7 +80,7 @@ class AuthBackendPage extends Form 'Before you are able to authenticate using the LDAP connection defined earlier you need to' . ' provide some more information so that Icinga Web 2 is able to locate account details.' ); - } else { // if ($this->config['type'] === 'autologin' + } else { // if ($this->config['type'] === 'external' $note = $this->translate( 'You\'ve chosen to authenticate using a web server\'s mechanism so it may be necessary' . ' to adjust usernames before any permissions, restrictions, etc. are being applied.' @@ -103,8 +103,8 @@ class AuthBackendPage extends Form } elseif ($this->config['type'] === 'ldap') { $backendForm = new LdapBackendForm(); $backendForm->createElements($formData)->removeElement('resource'); - } else { // $this->config['type'] === 'autologin' - $backendForm = new AutologinBackendForm(); + } else { // $this->config['type'] === 'external' + $backendForm = new ExternalBackendForm(); $backendForm->createElements($formData); } diff --git a/modules/setup/application/forms/AuthenticationPage.php b/modules/setup/application/forms/AuthenticationPage.php index ca182a4b1..6b25868ac 100644 --- a/modules/setup/application/forms/AuthenticationPage.php +++ b/modules/setup/application/forms/AuthenticationPage.php @@ -37,10 +37,10 @@ class AuthenticationPage extends Form ) ); - if (isset($formData['type']) && $formData['type'] === 'autologin' && !isset($_SERVER['REMOTE_USER'])) { + if (isset($formData['type']) && $formData['type'] === 'external' && !isset($_SERVER['REMOTE_USER'])) { $this->addElement( 'note', - 'autologin_note', + 'external_note', array( 'value' => sprintf( $this->translate( @@ -80,7 +80,7 @@ class AuthenticationPage extends Form if (Platform::extensionLoaded('ldap')) { $backendTypes['ldap'] = 'LDAP'; } - $backendTypes['autologin'] = $this->translate('Autologin'); + $backendTypes['external'] = $this->translate('External'); $this->addElement( 'select', diff --git a/modules/setup/library/Setup/Steps/AuthenticationStep.php b/modules/setup/library/Setup/Steps/AuthenticationStep.php index a15198c57..ce0b49f58 100644 --- a/modules/setup/library/Setup/Steps/AuthenticationStep.php +++ b/modules/setup/library/Setup/Steps/AuthenticationStep.php @@ -139,7 +139,7 @@ class AuthenticationStep extends Step . '

    ' . '' . '' - ) : ($authType === 'autologin' ? ( + ) : ($authType === 'external' ? ( '' . '' . '' From afd4a9a134ebaedfaafd1ba055af41aa55fc7ca4 Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Tue, 27 Jan 2015 10:54:33 +0100 Subject: [PATCH 0395/2920] There will be '.. users create' instead of '.. setup config webserver --with..' refs #8274 --- modules/setup/application/forms/AuthenticationPage.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/modules/setup/application/forms/AuthenticationPage.php b/modules/setup/application/forms/AuthenticationPage.php index 6b25868ac..1377ce230 100644 --- a/modules/setup/application/forms/AuthenticationPage.php +++ b/modules/setup/application/forms/AuthenticationPage.php @@ -45,11 +45,11 @@ class AuthenticationPage extends Form 'value' => sprintf( $this->translate( 'You\'re currently not authenticated using any of the web server\'s authentication ' - . 'mechanisms. Make sure you\'ll configure such either by using the %s or by setting' - . ' it up manually, otherwise you\'ll not be able to log into Icinga Web 2 once the ' - . 'wizard is complete.' + . 'mechanisms. Make sure you\'ll configure such either by using the %s once the ' + . 'wizard is complete or by setting it up manually, otherwise you\'ll not be able ' + . 'to log into Icinga Web 2.' ), - 'IcingaCLI' + 'IcingaCLI' ), 'decorators' => array( 'ViewHelper', From 6c292f7e5659fc49fbe876c0655d0b6890aaf6bf Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Tue, 27 Jan 2015 13:31:14 +0100 Subject: [PATCH 0396/2920] Move the configuration warning on the login screen further up ..and add translation support to the login screen. refs #8274 refs #8134 --- .../views/scripts/authentication/login.phtml | 30 +++++++++---------- public/css/icinga/login.less | 2 +- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/application/views/scripts/authentication/login.phtml b/application/views/scripts/authentication/login.phtml index 7d8d15df8..f05e51e43 100644 --- a/application/views/scripts/authentication/login.phtml +++ b/application/views/scripts/authentication/login.phtml @@ -1,11 +1,23 @@
    -

    Welcome to Icinga Web 2

    + +
    translate( + 'It appears that you did not configure Icinga Web 2 yet so it\'s not possible to log in without any defined ' + . 'authentication method. Please define a authentication method by following the instructions in the' + . ' %1$sdocumentation%3$s or by using our %2$sweb-based setup-wizard%3$s.' + ), + '', // TODO: More exact documentation link.. + '', + '' + ); ?>
    + +

    translate('Welcome to Icinga Web 2'); ?>

    errorInfo)): ?> @@ -14,18 +26,6 @@
    form ?> - - -
    ', // TODO: Documentation link - '', - '' - ); ?>
    - +
    diff --git a/public/css/icinga/login.less b/public/css/icinga/login.less index cfae3c478..05649881f 100644 --- a/public/css/icinga/login.less +++ b/public/css/icinga/login.less @@ -116,7 +116,7 @@ div.config-note { width: 50%; padding: 1em; - margin: 5em auto 0; + margin: 0 auto 2.5em; text-align: center; color: white; background-color: @colorCritical; From 08795e7cf4dd63cca39dc985446b29f30ea56a3e Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Tue, 27 Jan 2015 13:33:52 +0100 Subject: [PATCH 0397/2920] monitoring/security: Expect restriction name in ListController::applyRestriction() Before, the restriction was hard coded to 'monitoring/filter'. This restriction will be removed because we can not use the very same filter for all views. --- .../controllers/ListController.php | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/modules/monitoring/application/controllers/ListController.php b/modules/monitoring/application/controllers/ListController.php index a9ccb7ee8..823cb6a4e 100644 --- a/modules/monitoring/application/controllers/ListController.php +++ b/modules/monitoring/application/controllers/ListController.php @@ -2,6 +2,7 @@ use Icinga\Module\Monitoring\Controller; use Icinga\Module\Monitoring\Backend; +use Icinga\Module\Monitoring\DataView\DataView; use Icinga\Module\Monitoring\Forms\Command\Object\DeleteCommentCommandForm; use Icinga\Module\Monitoring\Forms\Command\Object\DeleteDowntimeCommandForm; use Icinga\Web\Url; @@ -216,8 +217,8 @@ class Monitoring_ListController extends Controller 'max_check_attempts' => 'service_max_check_attempts' ), $this->extraColumns()); $query = $this->backend->select()->from('serviceStatus', $columns); - $this->filterQuery($query); + $this->setupSortControl(array( 'service_severity' => $this->translate('Service Severity'), 'service_state' => $this->translate('Current Service State'), @@ -661,20 +662,24 @@ class Monitoring_ListController extends Controller if ($sort = $this->params->get('sort')) { $query->order($sort, $this->params->get('dir')); } - $this->applyRestrictions($query); $this->handleFormatRequest($query); return $query; } /** - * Apply current user's `monitoring/filter' restrictions on the given data view + * Apply a restriction on the given data view + * + * @param string $restriction The name of restriction + * @param DataView $view The view to restrict + * + * @return DataView $view */ - protected function applyRestrictions($query) + protected function applyRestriction($restriction, DataView $view) { - foreach ($this->getRestrictions('monitoring/filter') as $restriction) { - // TODO: $query->applyFilter(Filter::fromQueryString()); + foreach ($this->getRestrictions($restriction) as $filter) { + $view->applyFilter(Filter::fromQueryString($filter)); } - return $query; + return $view; } protected function extraColumns() From 47b27fcfe44a482b334ada1a7cb6bfa8f634cc31 Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Tue, 27 Jan 2015 13:34:59 +0100 Subject: [PATCH 0398/2920] setup: Look for the authentication.ini instead of the config.ini The config.ini does not include any settings mandatory to operate Icinga Web 2, but the authentication.ini does. refs #8134 --- library/Icinga/Application/ApplicationBootstrap.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library/Icinga/Application/ApplicationBootstrap.php b/library/Icinga/Application/ApplicationBootstrap.php index 909431663..89bca7b97 100644 --- a/library/Icinga/Application/ApplicationBootstrap.php +++ b/library/Icinga/Application/ApplicationBootstrap.php @@ -407,7 +407,7 @@ abstract class ApplicationBootstrap */ protected function loadSetupModuleIfNecessary() { - if (! @file_exists($this->config->resolvePath('config.ini'))) { + if (! @file_exists($this->config->resolvePath('authentication.ini'))) { $this->requiresSetup = true; $this->moduleManager->loadModule('setup'); } elseif ($this->setupTokenExists()) { From 405e18a46f23634dd2e8ec77212955ebc7f02528 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Tue, 27 Jan 2015 13:37:28 +0100 Subject: [PATCH 0399/2920] monitoring: Fix PHPDoc for MonitoringBackend::from() --- .../library/Monitoring/Backend/MonitoringBackend.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/monitoring/library/Monitoring/Backend/MonitoringBackend.php b/modules/monitoring/library/Monitoring/Backend/MonitoringBackend.php index c8f75f540..d165f1252 100644 --- a/modules/monitoring/library/Monitoring/Backend/MonitoringBackend.php +++ b/modules/monitoring/library/Monitoring/Backend/MonitoringBackend.php @@ -145,7 +145,7 @@ class MonitoringBackend implements Selectable, Queryable, ConnectionInterface $this->type = lcfirst(substr($class, 0, -7)); } else { throw new ProgrammingError( - '%s is not a valid monitoring backend class name', + '%s is not a valid monitoring backend class name', $class ); } @@ -251,7 +251,7 @@ class MonitoringBackend implements Selectable, Queryable, ConnectionInterface * @param string $name * @param array $columns * - * @return DataView + * @return \Icinga\Module\Monitoring\DataView\DataView */ public function from($name, array $columns = null) { From d99d147901901f5fd266a7f19c34312e40a09762 Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Tue, 27 Jan 2015 13:45:13 +0100 Subject: [PATCH 0400/2920] Fix usages of AutoLoginBackend refs #8274 --- application/controllers/AuthenticationController.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/application/controllers/AuthenticationController.php b/application/controllers/AuthenticationController.php index 2d7926819..77925bd8c 100644 --- a/application/controllers/AuthenticationController.php +++ b/application/controllers/AuthenticationController.php @@ -8,7 +8,7 @@ use Icinga\Application\Config; use Icinga\Application\Icinga; use Icinga\Application\Logger; use Icinga\Authentication\AuthChain; -use Icinga\Authentication\Backend\AutoLoginBackend; +use Icinga\Authentication\Backend\ExternalBackend; use Icinga\Exception\AuthenticationException; use Icinga\Exception\ConfigurationError; use Icinga\Exception\NotReadableError; @@ -82,7 +82,7 @@ class AuthenticationController extends ActionController } foreach ($chain as $backend) { - if ($backend instanceof AutoLoginBackend) { + if ($backend instanceof ExternalBackend) { continue; } ++$backendsTried; @@ -126,7 +126,7 @@ class AuthenticationController extends ActionController } elseif ($request->isGet()) { $user = new User(''); foreach ($chain as $backend) { - if ($backend instanceof AutoLoginBackend) { + if ($backend instanceof ExternalBackend) { $authenticated = $backend->authenticate($user); if ($authenticated === true) { $auth->setAuthenticated($user); From f8aa9eb05c5693cddd726eac8bb97abb98a29464 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Tue, 27 Jan 2015 13:48:33 +0100 Subject: [PATCH 0401/2920] monitoring/security: Replace 'monitoring/filter' restrictions with filter for the hosts and the services view --- modules/monitoring/configuration.php | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/modules/monitoring/configuration.php b/modules/monitoring/configuration.php index 6b1fe1cda..72df4e73f 100644 --- a/modules/monitoring/configuration.php +++ b/modules/monitoring/configuration.php @@ -56,8 +56,13 @@ $this->providePermission( ); $this->provideRestriction( - 'monitoring/filter', - $this->translate('Restrict views to the hosts and services that match the filter') + 'monitoring/hosts/filter', + $this->translate('Restrict hosts view to the hosts that match the filter') +); + +$this->provideRestriction( + 'monitoring/services/filter', + $this->translate('Restrict services view to the services that match the filter') ); $this->provideConfigTab('backends', array( From c8084dde923bb6e0c66874004307130078c8bc37 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Tue, 27 Jan 2015 13:49:51 +0100 Subject: [PATCH 0402/2920] monitoring/security: Apply services restriction in the services overview --- modules/monitoring/application/controllers/ListController.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/modules/monitoring/application/controllers/ListController.php b/modules/monitoring/application/controllers/ListController.php index 823cb6a4e..bd7c66e1b 100644 --- a/modules/monitoring/application/controllers/ListController.php +++ b/modules/monitoring/application/controllers/ListController.php @@ -217,8 +217,11 @@ class Monitoring_ListController extends Controller 'max_check_attempts' => 'service_max_check_attempts' ), $this->extraColumns()); $query = $this->backend->select()->from('serviceStatus', $columns); + $this->filterQuery($query); + $this->applyRestriction('monitoring/services/filter', $query); + $this->setupSortControl(array( 'service_severity' => $this->translate('Service Severity'), 'service_state' => $this->translate('Current Service State'), From f37cd0cb95a28f8b1d5f424c74abf8438e64a853 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Tue, 27 Jan 2015 13:51:15 +0100 Subject: [PATCH 0403/2920] monitoring/security: Apply hosts restriction in the hosts overview --- modules/monitoring/application/controllers/ListController.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/modules/monitoring/application/controllers/ListController.php b/modules/monitoring/application/controllers/ListController.php index bd7c66e1b..cd9e8077a 100644 --- a/modules/monitoring/application/controllers/ListController.php +++ b/modules/monitoring/application/controllers/ListController.php @@ -132,6 +132,8 @@ class Monitoring_ListController extends Controller $this->filterQuery($query); + $this->applyRestriction('monitoring/hosts/filter', $query); + $this->setupSortControl(array( 'host_severity' => $this->translate('Severity'), 'host_state' => $this->translate('Current State'), From 4a245ed8e09d211bc948d2e1622ce58c86ff902a Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Tue, 27 Jan 2015 13:58:55 +0100 Subject: [PATCH 0404/2920] login: Wrap the config warning in paragraph tags instead of div --- application/views/scripts/authentication/login.phtml | 4 ++-- public/css/icinga/login.less | 10 +++++----- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/application/views/scripts/authentication/login.phtml b/application/views/scripts/authentication/login.phtml index f05e51e43..f372b6657 100644 --- a/application/views/scripts/authentication/login.phtml +++ b/application/views/scripts/authentication/login.phtml @@ -6,7 +6,7 @@
    -
    translate( 'It appears that you did not configure Icinga Web 2 yet so it\'s not possible to log in without any defined ' . 'authentication method. Please define a authentication method by following the instructions in the' @@ -15,7 +15,7 @@ '', // TODO: More exact documentation link.. '', '' - ); ?>
    + ); ?>

    translate('Welcome to Icinga Web 2'); ?>

    Date: Tue, 27 Jan 2015 14:05:41 +0100 Subject: [PATCH 0405/2920] Rename css class "info" to "info-box" and add it as generic box refs #8274 --- modules/setup/application/forms/AuthenticationPage.php | 2 +- public/css/icinga/main-content.less | 6 ++++++ public/css/icinga/setup.less | 10 ++-------- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/modules/setup/application/forms/AuthenticationPage.php b/modules/setup/application/forms/AuthenticationPage.php index 1377ce230..fdc076e60 100644 --- a/modules/setup/application/forms/AuthenticationPage.php +++ b/modules/setup/application/forms/AuthenticationPage.php @@ -55,7 +55,7 @@ class AuthenticationPage extends Form 'ViewHelper', array( 'HtmlTag', - array('tag' => 'p', 'class' => 'icon-info info') + array('tag' => 'p', 'class' => 'icon-info info-box') ) ) ) diff --git a/public/css/icinga/main-content.less b/public/css/icinga/main-content.less index 5b142184d..e3e31b397 100644 --- a/public/css/icinga/main-content.less +++ b/public/css/icinga/main-content.less @@ -203,3 +203,9 @@ table.benchmark { [class^="icon-"]:before, [class*=" icon-"]:before { text-decoration: none; } + +.info-box { + padding: 0.5em; + border: 1px solid lightgrey; + background-color: infobackground; +} diff --git a/public/css/icinga/setup.less b/public/css/icinga/setup.less index 2c86a985a..9dff6fecf 100644 --- a/public/css/icinga/setup.less +++ b/public/css/icinga/setup.less @@ -220,14 +220,8 @@ } } -#setup_authentication_type p.info { - padding: 0.5em; - border: 1px solid lightgrey; - background-color: infobackground; - - em { - text-decoration: underline; - } +#setup_authentication_type p.info-box em { + text-decoration: underline; } #setup_ldap_discovery_confirm table { From 3cbafe16f6923cf28550aa52677698951aafd3a3 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Tue, 27 Jan 2015 14:22:37 +0100 Subject: [PATCH 0406/2920] monitoring/security: Move applyRestriction() to the module's base controller --- .../controllers/ListController.php | 17 ---------------- .../library/Monitoring/Controller.php | 20 ++++++++++++++++++- 2 files changed, 19 insertions(+), 18 deletions(-) diff --git a/modules/monitoring/application/controllers/ListController.php b/modules/monitoring/application/controllers/ListController.php index cd9e8077a..faaea713a 100644 --- a/modules/monitoring/application/controllers/ListController.php +++ b/modules/monitoring/application/controllers/ListController.php @@ -2,7 +2,6 @@ use Icinga\Module\Monitoring\Controller; use Icinga\Module\Monitoring\Backend; -use Icinga\Module\Monitoring\DataView\DataView; use Icinga\Module\Monitoring\Forms\Command\Object\DeleteCommentCommandForm; use Icinga\Module\Monitoring\Forms\Command\Object\DeleteDowntimeCommandForm; use Icinga\Web\Url; @@ -671,22 +670,6 @@ class Monitoring_ListController extends Controller return $query; } - /** - * Apply a restriction on the given data view - * - * @param string $restriction The name of restriction - * @param DataView $view The view to restrict - * - * @return DataView $view - */ - protected function applyRestriction($restriction, DataView $view) - { - foreach ($this->getRestrictions($restriction) as $filter) { - $view->applyFilter(Filter::fromQueryString($filter)); - } - return $view; - } - protected function extraColumns() { $columns = preg_split( diff --git a/modules/monitoring/library/Monitoring/Controller.php b/modules/monitoring/library/Monitoring/Controller.php index 32bafb8b2..de9ea8161 100644 --- a/modules/monitoring/library/Monitoring/Controller.php +++ b/modules/monitoring/library/Monitoring/Controller.php @@ -4,9 +4,11 @@ namespace Icinga\Module\Monitoring; +use Icinga\Data\Filter\Filter; +use Icinga\File\Csv; +use Icinga\Module\Monitoring\DataView\DataView; use Icinga\Web\Controller\ModuleActionController; use Icinga\Web\Url; -use Icinga\File\Csv; /** * Base class for all monitoring action controller @@ -60,5 +62,21 @@ class Controller extends ModuleActionController exit; } } + + /** + * Apply a restriction on the given data view + * + * @param string $restriction The name of restriction + * @param DataView $view The view to restrict + * + * @return DataView $view + */ + protected function applyRestriction($restriction, DataView $view) + { + foreach ($this->getRestrictions($restriction) as $filter) { + $view->applyFilter(Filter::fromQueryString($filter)); + } + return $view; + } } From b2f93abb120bf6802edecdd0f02a977d1e27a94a Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Tue, 27 Jan 2015 14:24:56 +0100 Subject: [PATCH 0407/2920] monitoring/security: Require a Filterable instead of a DataView in applyRestriction() --- modules/monitoring/library/Monitoring/Controller.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/modules/monitoring/library/Monitoring/Controller.php b/modules/monitoring/library/Monitoring/Controller.php index de9ea8161..f294e9a2e 100644 --- a/modules/monitoring/library/Monitoring/Controller.php +++ b/modules/monitoring/library/Monitoring/Controller.php @@ -5,8 +5,8 @@ namespace Icinga\Module\Monitoring; use Icinga\Data\Filter\Filter; +use Icinga\Data\Filterable; use Icinga\File\Csv; -use Icinga\Module\Monitoring\DataView\DataView; use Icinga\Web\Controller\ModuleActionController; use Icinga\Web\Url; @@ -67,11 +67,11 @@ class Controller extends ModuleActionController * Apply a restriction on the given data view * * @param string $restriction The name of restriction - * @param DataView $view The view to restrict + * @param Filterable $filterable The filterable to restrict * - * @return DataView $view + * @return Filterable The filterable */ - protected function applyRestriction($restriction, DataView $view) + protected function applyRestriction($restriction, Filterable $view) { foreach ($this->getRestrictions($restriction) as $filter) { $view->applyFilter(Filter::fromQueryString($filter)); From 7ad44b8411b5bffc038d4e019263bd7fcc07ac85 Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Tue, 27 Jan 2015 14:26:06 +0100 Subject: [PATCH 0408/2920] login: Show a note if the only active external auth backend is not available refs #8274 --- application/controllers/AuthenticationController.php | 5 +++++ application/views/scripts/authentication/login.phtml | 9 +++++++++ public/css/icinga/login.less | 9 +++++++++ 3 files changed, 23 insertions(+) diff --git a/application/controllers/AuthenticationController.php b/application/controllers/AuthenticationController.php index 77925bd8c..4e70894a1 100644 --- a/application/controllers/AuthenticationController.php +++ b/application/controllers/AuthenticationController.php @@ -39,6 +39,7 @@ class AuthenticationController extends ActionController $this->redirectNow(Url::fromPath('setup')); } + $triedOnlyExternalAuth = null; $auth = $this->Auth(); $this->view->form = $form = new LoginForm(); $this->view->title = $this->translate('Icingaweb Login'); @@ -126,6 +127,7 @@ class AuthenticationController extends ActionController } elseif ($request->isGet()) { $user = new User(''); foreach ($chain as $backend) { + $triedOnlyExternalAuth = $triedOnlyExternalAuth === null; if ($backend instanceof ExternalBackend) { $authenticated = $backend->authenticate($user); if ($authenticated === true) { @@ -134,6 +136,8 @@ class AuthenticationController extends ActionController Url::fromPath(Url::fromRequest()->getParam('redirect', 'dashboard')) ); } + } else { + $triedOnlyExternalAuth = false; } } } @@ -141,6 +145,7 @@ class AuthenticationController extends ActionController $this->view->errorInfo = $e->getMessage(); } + $this->view->requiresExternalAuth = $triedOnlyExternalAuth && !$auth->isAuthenticated(); $this->view->requiresSetup = Icinga::app()->requiresSetup(); } diff --git a/application/views/scripts/authentication/login.phtml b/application/views/scripts/authentication/login.phtml index f372b6657..5f99aff17 100644 --- a/application/views/scripts/authentication/login.phtml +++ b/application/views/scripts/authentication/login.phtml @@ -16,6 +16,15 @@ '', '' ); ?>

    + +

    translate( + 'You\'re currently not authenticated using any of the web server\'s authentication mechanisms.' + . ' Make sure you\'ll configure such either by using the %s or by setting it up manually,' + . ' otherwise you\'ll not be able to login.' + ), + 'IcingaCLI' + ); ?>

    translate('Welcome to Icinga Web 2'); ?>

    Date: Tue, 27 Jan 2015 14:33:46 +0100 Subject: [PATCH 0409/2920] lib: Deprecate Data\Filterable because of ... addFilter and applyFilter do the same in all usages. addFilter could be replaced w/ getFilter()->add(). We must no require classes implementing this interface to implement redundant methods over and over again. The interface must be moved to the namespace Icinga\Data\Filter. It lacks documentation. --- library/Icinga/Data/Filterable.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/library/Icinga/Data/Filterable.php b/library/Icinga/Data/Filterable.php index 73ce5dcb4..25d1fc9f5 100644 --- a/library/Icinga/Data/Filterable.php +++ b/library/Icinga/Data/Filterable.php @@ -8,6 +8,11 @@ use Icinga\Data\Filter\Filter; /** * Interface for filtering a result set + * + * @deprecated(EL): addFilter and applyFilter do the same in all usages. + * addFilter could be replaced w/ getFilter()->add(). We must no require classes implementing this interface to + * implement redundant methods over and over again. This interface must be moved to the namespace Icinga\Data\Filter. + * It lacks documentation. */ interface Filterable { From e086905384837e49e772fc893451ad0c5a3cb0ce Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Tue, 27 Jan 2015 14:52:13 +0100 Subject: [PATCH 0410/2920] monitoring: Deprecate DataView::addFilter() and DataView::setFilter() The from now on deprecated interface Filterable has proven that it sucks in the DataView. Because of requiring us to implement trillion stupid methods, only DataView::applyFilter() does not forget to handle column validation. Thus only DataView::applyFilter() must be used in order to apply filters. For setFilter() a wrapping Filter::matchAny() for the IdoQuery (or the DbQuery or the SimpleQuery I didn't have a look) is required for the filter to work properly. The deprecation is just for the records. I guess we do not use the other methods. --- .../monitoring/library/Monitoring/DataView/DataView.php | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/modules/monitoring/library/Monitoring/DataView/DataView.php b/modules/monitoring/library/Monitoring/DataView/DataView.php index 5900df737..da48f31c3 100644 --- a/modules/monitoring/library/Monitoring/DataView/DataView.php +++ b/modules/monitoring/library/Monitoring/DataView/DataView.php @@ -355,12 +355,21 @@ abstract class DataView implements Browsable, Countable, Filterable, Sortable return $this; } + /** + * @deprecated(EL): Only use DataView::applyFilter() for applying filter because all other functions are missing + * column validation. Filter::matchAny() for the IdoQuery (or the DbQuery or the SimpleQuery I didn't have a look) + * is required for the filter to work properly. + */ public function setFilter(Filter $filter) { $this->query->setFilter($filter); return $this; } + /** + * @deprecated(EL): Only use DataView::applyFilter() for applying filter because all other functions are missing + * column validation. + */ public function addFilter(Filter $filter) { $this->query->addFilter(clone($filter)); From 7bf6bd39e9d2a21e25dfd04efc095ebe6f95eeb3 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Tue, 27 Jan 2015 14:54:21 +0100 Subject: [PATCH 0411/2920] monitoring: Implement Filterable in MonitoredObject --- .../Monitoring/Object/MonitoredObject.php | 42 ++++++++++++++++++- 1 file changed, 40 insertions(+), 2 deletions(-) diff --git a/modules/monitoring/library/Monitoring/Object/MonitoredObject.php b/modules/monitoring/library/Monitoring/Object/MonitoredObject.php index 8d3246aab..213cf47b8 100644 --- a/modules/monitoring/library/Monitoring/Object/MonitoredObject.php +++ b/modules/monitoring/library/Monitoring/Object/MonitoredObject.php @@ -7,13 +7,15 @@ namespace Icinga\Module\Monitoring\Object; use InvalidArgumentException; use Icinga\Application\Config; use Icinga\Exception\InvalidPropertyException; +use Icinga\Data\Filter\Filter; +use Icinga\Data\Filterable; use Icinga\Module\Monitoring\Backend\MonitoringBackend; use Icinga\Web\UrlParams; /** * A monitored Icinga object, i.e. host or service */ -abstract class MonitoredObject +abstract class MonitoredObject implements Filterable { /** * Type host @@ -116,6 +118,13 @@ abstract class MonitoredObject */ protected $stats; + /** + * Filter + * + * @type Filter + */ + protected $filter; + /** * Create a monitored object, i.e. host or service * @@ -133,6 +142,35 @@ abstract class MonitoredObject */ abstract protected function getDataView(); + public function applyFilter(Filter $filter) + { + $this->getFilter()->addFilter($filter); + return $this; + } + + public function setFilter(Filter $filter) + { + // Left out on purpose. Interface is deprecated. + } + + public function getFilter() + { + if ($this->filter === null) { + $this->filter = Filter::matchAny(); + } + return $this->filter; + } + + public function addFilter(Filter $filter) + { + // Left out on purpose. Interface is deprecated. + } + + public function where($condition, $value = null) + { + // Left out on purpose. Interface is deprecated. + } + /** * Fetch the object's properties * @@ -140,7 +178,7 @@ abstract class MonitoredObject */ public function fetch() { - $this->properties = $this->getDataView()->getQuery()->fetchRow(); + $this->properties = $this->getDataView()->applyFilter($this->getFilter())->getQuery()->fetchRow(); if ($this->properties === false) { return false; } From 49d4d74dbbefe25434621b716c46c443d292e62d Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Tue, 27 Jan 2015 14:57:22 +0100 Subject: [PATCH 0412/2920] monitoring/security: Apply hosts/filter restriction in the host detail view --- modules/monitoring/application/controllers/HostController.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/modules/monitoring/application/controllers/HostController.php b/modules/monitoring/application/controllers/HostController.php index d01335734..3a5038ad6 100644 --- a/modules/monitoring/application/controllers/HostController.php +++ b/modules/monitoring/application/controllers/HostController.php @@ -26,6 +26,9 @@ class Monitoring_HostController extends MonitoredObjectController public function init() { $host = new Host($this->backend, $this->params->get('host')); + + $this->applyRestriction('monitoring/hosts/filter', $host); + if ($host->fetch() === false) { throw new Zend_Controller_Action_Exception($this->translate('Host not found')); } From 49b82af70407c3cfafdc088556237423a3d98223 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Tue, 27 Jan 2015 14:57:54 +0100 Subject: [PATCH 0413/2920] monitoring/security: Apply services/filter restriction in the service detail view --- .../monitoring/application/controllers/ServiceController.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/modules/monitoring/application/controllers/ServiceController.php b/modules/monitoring/application/controllers/ServiceController.php index c05683400..fe4795fb1 100644 --- a/modules/monitoring/application/controllers/ServiceController.php +++ b/modules/monitoring/application/controllers/ServiceController.php @@ -26,6 +26,9 @@ class Monitoring_ServiceController extends MonitoredObjectController public function init() { $service = new Service($this->backend, $this->params->get('host'), $this->params->get('service')); + + $this->applyRestriction('monitoring/services/filter', $service); + if ($service->fetch() === false) { throw new Zend_Controller_Action_Exception($this->translate('Service not found')); } From 6fde4eec30054afa6f8580a864a3bf80ee1a0e44 Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Wed, 28 Jan 2015 12:50:29 +0100 Subject: [PATCH 0414/2920] Show all tabs except "Add to Dashboard" when issuing a command refs #8279 --- library/Icinga/Web/Widget/Tabs.php | 19 +++++++++++++++++++ .../controllers/HostController.php | 8 -------- .../controllers/ServiceController.php | 8 -------- .../views/scripts/partials/command-form.phtml | 2 +- 4 files changed, 20 insertions(+), 17 deletions(-) diff --git a/library/Icinga/Web/Widget/Tabs.php b/library/Icinga/Web/Widget/Tabs.php index 72522282e..c6a4bd31b 100644 --- a/library/Icinga/Web/Widget/Tabs.php +++ b/library/Icinga/Web/Widget/Tabs.php @@ -218,6 +218,25 @@ EOT; return $this; } + /** + * Remove a tab + * + * @param string $name + * + * @return self + */ + public function remove($name) + { + if ($this->has($name)) { + unset($this->tabs[$name]); + if (($dropdownIndex = array_search($name, $this->dropdownTabs)) !== false) { + array_splice($this->dropdownTabs, $dropdownIndex, 2); + } + } + + return $this; + } + /** * Add a tab to the dropdown on the right side of the tab-bar. * diff --git a/modules/monitoring/application/controllers/HostController.php b/modules/monitoring/application/controllers/HostController.php index 3a5038ad6..4eccb8899 100644 --- a/modules/monitoring/application/controllers/HostController.php +++ b/modules/monitoring/application/controllers/HostController.php @@ -34,15 +34,7 @@ class Monitoring_HostController extends MonitoredObjectController } $this->object = $host; $this->createTabs(); - } - - /** - * Show a host - */ - public function showAction() - { $this->getTabs()->activate('host'); - parent::showAction(); } /** diff --git a/modules/monitoring/application/controllers/ServiceController.php b/modules/monitoring/application/controllers/ServiceController.php index fe4795fb1..4e4e67402 100644 --- a/modules/monitoring/application/controllers/ServiceController.php +++ b/modules/monitoring/application/controllers/ServiceController.php @@ -34,15 +34,7 @@ class Monitoring_ServiceController extends MonitoredObjectController } $this->object = $service; $this->createTabs(); - } - - /** - * Show a service - */ - public function showAction() - { $this->getTabs()->activate('service'); - parent::showAction(); } /** diff --git a/modules/monitoring/application/views/scripts/partials/command-form.phtml b/modules/monitoring/application/views/scripts/partials/command-form.phtml index 9832bfe17..380687a00 100644 --- a/modules/monitoring/application/views/scripts/partials/command-form.phtml +++ b/modules/monitoring/application/views/scripts/partials/command-form.phtml @@ -1,5 +1,5 @@
    - tabs->showOnlyCloseButton() ?> + tabs->remove('dashboard') ?>

    icon('help', $form->getHelp()) ?>

    From c19ff289bfcf52cdedc8a97b8fbc1cbc78a5346f Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Wed, 28 Jan 2015 13:02:37 +0100 Subject: [PATCH 0415/2920] Open command forms in the same column where their link is located refs #8279 --- .../views/scripts/show/components/acknowledgement.phtml | 2 +- .../views/scripts/show/components/checkstatistics.phtml | 2 +- .../application/views/scripts/show/components/command.phtml | 2 +- .../application/views/scripts/show/components/comments.phtml | 2 +- .../application/views/scripts/show/components/downtime.phtml | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/modules/monitoring/application/views/scripts/show/components/acknowledgement.phtml b/modules/monitoring/application/views/scripts/show/components/acknowledgement.phtml index 339652113..8da35590f 100644 --- a/modules/monitoring/application/views/scripts/show/components/acknowledgement.phtml +++ b/modules/monitoring/application/views/scripts/show/components/acknowledgement.phtml @@ -35,7 +35,7 @@ if ($object->acknowledged): ?> ); } ?> - + icon('ok') ?> translate('Acknowledge') ?> getType() === $object::TYPE_HOST) { ); } ?> - + icon('reschedule') ?> translate('Reschedule') ?> diff --git a/modules/monitoring/application/views/scripts/show/components/command.phtml b/modules/monitoring/application/views/scripts/show/components/command.phtml index 5239dad41..a74b5b884 100644 --- a/modules/monitoring/application/views/scripts/show/components/command.phtml +++ b/modules/monitoring/application/views/scripts/show/components/command.phtml @@ -21,7 +21,7 @@ $command = array_shift($parts); array('host' => $object->getHost()->getName(), 'service' => $object->getName()) ); } ?> - + icon('reply') ?> translate('Process check result') ?> diff --git a/modules/monitoring/application/views/scripts/show/components/comments.phtml b/modules/monitoring/application/views/scripts/show/components/comments.phtml index dde42c747..a6503a70b 100644 --- a/modules/monitoring/application/views/scripts/show/components/comments.phtml +++ b/modules/monitoring/application/views/scripts/show/components/comments.phtml @@ -15,7 +15,7 @@ ); } ?> - + icon('comment') ?> translate('Add comment') ?> diff --git a/modules/monitoring/application/views/scripts/show/components/downtime.phtml b/modules/monitoring/application/views/scripts/show/components/downtime.phtml index 8f42a865e..4aa1e21c1 100644 --- a/modules/monitoring/application/views/scripts/show/components/downtime.phtml +++ b/modules/monitoring/application/views/scripts/show/components/downtime.phtml @@ -15,7 +15,7 @@ ); } ?> - + icon('plug') ?> translate('Schedule downtime') ?> From 7ef86ddf49cd1adba53c4a4c488b1d9c3ccb638c Mon Sep 17 00:00:00 2001 From: Marius Hein Date: Wed, 28 Jan 2015 13:19:49 +0100 Subject: [PATCH 0416/2920] Navigation: Bypass error-prone hover selector for IE8 refs #6417 --- public/js/icinga/behavior/navigation.js | 39 +++++++++++++++---------- 1 file changed, 23 insertions(+), 16 deletions(-) diff --git a/public/js/icinga/behavior/navigation.js b/public/js/icinga/behavior/navigation.js index 53fc5c8af..b8a12064d 100644 --- a/public/js/icinga/behavior/navigation.js +++ b/public/js/icinga/behavior/navigation.js @@ -130,23 +130,26 @@ } setTimeout(function () { - if (! $li.is('li:hover')) { - return; - } - if ($li.hasClass('active')) { - return; - } + try { + if (!$li.is('li:hover')) { + return; + } + if ($li.hasClass('active')) { + return; + } + } catch(e) { /* Bypass because if IE8 */ } $li.siblings().each(function () { var $sibling = $(this); - if ($sibling.is('li:hover')) { - return; - } + try { + if ($sibling.is('li:hover')) { + return; + } + } catch(e) { /* Bypass because if IE8 */ }; if ($sibling.hasClass('hover')) { $sibling.removeClass('hover'); } }); - self.hoverElement($li); }, delay); }; @@ -161,9 +164,11 @@ } setTimeout(function () { - if ($li.is('li:hover') || $sidebar.is('sidebar:hover') ) { - return; - } + try { + if ($li.is('li:hover') || $sidebar.is('sidebar:hover')) { + return; + } + } catch(e) { /* Bypass because if IE8 */ }; $li.removeClass('hover'); $('#layout').removeClass('hoveredmenu'); }, 500); @@ -183,9 +188,11 @@ self = event.data.self; setTimeout(function () { // TODO: make this behave well together with keyboard navigation - if (! $li.is('li:hover') /*&& ! $li.find('a:focus')*/) { - $li.removeClass('hover'); - } + try { + if (!$li.is('li:hover') /*&& ! $li.find('a:focus')*/) { + $li.removeClass('hover'); + } + } catch(e) { /* Bypass because if IE8 */ } }, 300); }; Icinga.Behaviors.Navigation = Navigation; From cf857c42571071ca760f8e66598dc5910de3b991 Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Wed, 28 Jan 2015 14:15:16 +0100 Subject: [PATCH 0417/2920] Close forms when switching between the main app's configuration tabs refs #6436 --- application/views/scripts/config/authentication/reorder.phtml | 2 +- application/views/scripts/config/index.phtml | 2 +- application/views/scripts/config/resource.phtml | 2 +- application/views/scripts/roles/index.phtml | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/application/views/scripts/config/authentication/reorder.phtml b/application/views/scripts/config/authentication/reorder.phtml index 688d99f88..807f80efe 100644 --- a/application/views/scripts/config/authentication/reorder.phtml +++ b/application/views/scripts/config/authentication/reorder.phtml @@ -1,4 +1,4 @@ -
    +
    diff --git a/application/views/scripts/config/index.phtml b/application/views/scripts/config/index.phtml index dab0acc4f..1ffd120b4 100644 --- a/application/views/scripts/config/index.phtml +++ b/application/views/scripts/config/index.phtml @@ -1,4 +1,4 @@ -
    +
    tabs->render($this); ?>
    diff --git a/application/views/scripts/config/resource.phtml b/application/views/scripts/config/resource.phtml index c5d4ca0fc..f93b2af82 100644 --- a/application/views/scripts/config/resource.phtml +++ b/application/views/scripts/config/resource.phtml @@ -1,4 +1,4 @@ -
    +
    diff --git a/application/views/scripts/roles/index.phtml b/application/views/scripts/roles/index.phtml index 79eda5dac..925cdfa4e 100644 --- a/application/views/scripts/roles/index.phtml +++ b/application/views/scripts/roles/index.phtml @@ -1,4 +1,4 @@ -
    +

    translate('Roles') ?>

    From 618ab4f4b9cdc3975cc096eaabfe04da70244fb0 Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Wed, 28 Jan 2015 14:21:06 +0100 Subject: [PATCH 0418/2920] Introduce link target "_right" to keep a column with tabs rightmost I'd have liked to get it to work that in case the tab control is not in the rightmost column a "go back" in the history is being simulated causing the preceding leftmost column(s) to be restored and the rightmost one set to the one containing the tab control. But the history api does not seem to support any read operations except for the current state.. refs #6436 --- application/views/scripts/config/module.phtml | 2 +- .../application/views/scripts/config/index.phtml | 2 +- .../application/views/scripts/config/security.phtml | 2 +- public/js/icinga/events.js | 10 ++++++++++ 4 files changed, 13 insertions(+), 3 deletions(-) diff --git a/application/views/scripts/config/module.phtml b/application/views/scripts/config/module.phtml index cd6ad5af8..e26ade195 100644 --- a/application/views/scripts/config/module.phtml +++ b/application/views/scripts/config/module.phtml @@ -1,4 +1,4 @@ -
    +
    tabs ?>

    escape($module->getTitle()) ?>

    diff --git a/modules/monitoring/application/views/scripts/config/index.phtml b/modules/monitoring/application/views/scripts/config/index.phtml index b1729f9b1..deca8d468 100644 --- a/modules/monitoring/application/views/scripts/config/index.phtml +++ b/modules/monitoring/application/views/scripts/config/index.phtml @@ -1,4 +1,4 @@ -
    +

    translate('Monitoring Backends') ?>

    diff --git a/modules/monitoring/application/views/scripts/config/security.phtml b/modules/monitoring/application/views/scripts/config/security.phtml index 71f2a341a..2a84b2469 100644 --- a/modules/monitoring/application/views/scripts/config/security.phtml +++ b/modules/monitoring/application/views/scripts/config/security.phtml @@ -1,4 +1,4 @@ -
    +
    tabs ?>
    diff --git a/public/js/icinga/events.js b/public/js/icinga/events.js index e7ac3e3f1..b7f2f5cee 100644 --- a/public/js/icinga/events.js +++ b/public/js/icinga/events.js @@ -482,6 +482,16 @@ targetId = 'col1'; $target = $('#' + targetId); self.icinga.ui.layout1col(); + } else if (targetId === '_right') { + // Ensure that the content is displayed in the rightmost column + $target = $el.closest('.container'); + if ($target.attr('id') === 'col1') { + // As it's not possible to detect what's preceding the current state in the + // history stack this just simulates _main in case the respective element + // is not part of the rightmost column + $target = $('#col1'); + self.icinga.ui.layout1col(); + } } else { $target = $('#' + targetId); } From f486dabe6dea7d5b9cd5299889de582996c938ea Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Wed, 28 Jan 2015 14:22:42 +0100 Subject: [PATCH 0419/2920] Drop view script config/logging.phtml as it's not used anywhere --- .../views/scripts/config/logging.phtml | 35 ------------------- 1 file changed, 35 deletions(-) delete mode 100644 application/views/scripts/config/logging.phtml diff --git a/application/views/scripts/config/logging.phtml b/application/views/scripts/config/logging.phtml deleted file mode 100644 index da6d886cc..000000000 --- a/application/views/scripts/config/logging.phtml +++ /dev/null @@ -1,35 +0,0 @@ -
    -tabs->render($this); ?> -
    - -
    -form->getErrorMessages(); ?> - -messageBox)): ?> - messageBox->render() ?> - - -successMessage): ?> -
    - - escape($this->successMessage); ?> -
    - - - -
    -

    Errors occured when trying to save the project.

    -

    - The following errors occured when trying to save the configuration: -

    -
      - -
    • escape($error) ?>
    • - -
    -
    - - -form ?> -
    - From 78f5bf4f3d313f111ec3dbcc4745c16b8bedb819 Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Wed, 28 Jan 2015 16:22:20 +0100 Subject: [PATCH 0420/2920] Phrase external auth warnings more neutral refs #8274 --- application/views/scripts/authentication/login.phtml | 10 +++------- .../setup/application/forms/AuthenticationPage.php | 12 ++++-------- public/css/icinga/login.less | 6 ++++++ 3 files changed, 13 insertions(+), 15 deletions(-) diff --git a/application/views/scripts/authentication/login.phtml b/application/views/scripts/authentication/login.phtml index 5f99aff17..805196b96 100644 --- a/application/views/scripts/authentication/login.phtml +++ b/application/views/scripts/authentication/login.phtml @@ -17,13 +17,9 @@ '' ); ?>

    -

    translate( - 'You\'re currently not authenticated using any of the web server\'s authentication mechanisms.' - . ' Make sure you\'ll configure such either by using the %s or by setting it up manually,' - . ' otherwise you\'ll not be able to login.' - ), - 'IcingaCLI' +

    translate( + 'You\'re currently not authenticated using any of the web server\'s authentication mechanisms.' + . ' Make sure you\'ll configure such, otherwise you\'ll not be able to login.' ); ?>

    translate('Welcome to Icinga Web 2'); ?>

    diff --git a/modules/setup/application/forms/AuthenticationPage.php b/modules/setup/application/forms/AuthenticationPage.php index fdc076e60..f51ef946a 100644 --- a/modules/setup/application/forms/AuthenticationPage.php +++ b/modules/setup/application/forms/AuthenticationPage.php @@ -42,14 +42,10 @@ class AuthenticationPage extends Form 'note', 'external_note', array( - 'value' => sprintf( - $this->translate( - 'You\'re currently not authenticated using any of the web server\'s authentication ' - . 'mechanisms. Make sure you\'ll configure such either by using the %s once the ' - . 'wizard is complete or by setting it up manually, otherwise you\'ll not be able ' - . 'to log into Icinga Web 2.' - ), - 'IcingaCLI' + 'value' => $this->translate( + 'You\'re currently not authenticated using any of the web server\'s authentication ' + . 'mechanisms. Make sure you\'ll configure such, otherwise you\'ll not be able to ' + . 'log into Icinga Web 2.' ), 'decorators' => array( 'ViewHelper', diff --git a/public/css/icinga/login.less b/public/css/icinga/login.less index 223a388d2..6b03b476a 100644 --- a/public/css/icinga/login.less +++ b/public/css/icinga/login.less @@ -129,8 +129,14 @@ p.info-box { width: 50%; + height: 2.2em; margin: 0 auto 2.5em; + span.icon-info { + float: left; + height: 100%; + } + em { text-decoration: underline; } From 9d051905173e72790b11465009891b3ab36a51fa Mon Sep 17 00:00:00 2001 From: Marius Hein Date: Wed, 28 Jan 2015 17:03:23 +0100 Subject: [PATCH 0421/2920] ifont: Fix empty font glyphs for IE8 The embedded font is included inline in the stylesheets. IE falls back and tries to load one of the other font sources which was not exported by the web server. This fix moves the fontello directory to public and add add a prefix path to the embedded stylesheet. refs #6417 --- library/Icinga/Web/LessCompiler.php | 6 ++++-- library/Icinga/Web/StyleSheet.php | 5 +++-- .../fonts/fontello-ifont/LICENSE.txt | 0 .../fonts/fontello-ifont/README.txt | 0 .../fonts/fontello-ifont/config.json | 0 .../fonts/fontello-ifont/css/animation.css | 0 .../fonts/fontello-ifont/css/ifont-codes.css | 0 .../fonts/fontello-ifont/css/ifont-embedded.less | 6 +++--- .../fonts/fontello-ifont/css/ifont-ie7-codes.css | 0 .../fonts/fontello-ifont/css/ifont-ie7.css | 0 .../fonts/fontello-ifont/css/ifont.css | 0 .../fonts/fontello-ifont/demo.html | 0 .../fonts/fontello-ifont/font/ifont.eot | Bin .../fonts/fontello-ifont/font/ifont.svg | 0 .../fonts/fontello-ifont/font/ifont.ttf | Bin .../fonts/fontello-ifont/font/ifont.woff | Bin public/fonts/fontello-ifont/icingaweb.md | 6 ++++++ 17 files changed, 16 insertions(+), 7 deletions(-) rename {application => public}/fonts/fontello-ifont/LICENSE.txt (100%) rename {application => public}/fonts/fontello-ifont/README.txt (100%) rename {application => public}/fonts/fontello-ifont/config.json (100%) rename {application => public}/fonts/fontello-ifont/css/animation.css (100%) rename {application => public}/fonts/fontello-ifont/css/ifont-codes.css (100%) rename application/fonts/fontello-ifont/css/ifont-embedded.css => public/fonts/fontello-ifont/css/ifont-embedded.less (99%) rename {application => public}/fonts/fontello-ifont/css/ifont-ie7-codes.css (100%) rename {application => public}/fonts/fontello-ifont/css/ifont-ie7.css (100%) rename {application => public}/fonts/fontello-ifont/css/ifont.css (100%) rename {application => public}/fonts/fontello-ifont/demo.html (100%) rename {application => public}/fonts/fontello-ifont/font/ifont.eot (100%) rename {application => public}/fonts/fontello-ifont/font/ifont.svg (100%) rename {application => public}/fonts/fontello-ifont/font/ifont.ttf (100%) rename {application => public}/fonts/fontello-ifont/font/ifont.woff (100%) create mode 100644 public/fonts/fontello-ifont/icingaweb.md diff --git a/library/Icinga/Web/LessCompiler.php b/library/Icinga/Web/LessCompiler.php index 791fdbab0..a5349f1a4 100644 --- a/library/Icinga/Web/LessCompiler.php +++ b/library/Icinga/Web/LessCompiler.php @@ -38,15 +38,17 @@ class LessCompiler /** * Create a new instance + * + * @param string $basePath Provide web base path optional */ - public function __construct() + public function __construct($basePath = null) { require_once 'lessphp/lessc.inc.php'; $this->lessc = new lessc(); $this->lessc->setVariables( array( - 'baseurl' => '\'' . Zend_Controller_Front::getInstance()->getBaseUrl(). '\'' + 'baseurl' => '\'' . $basePath. '\'' ) ); } diff --git a/library/Icinga/Web/StyleSheet.php b/library/Icinga/Web/StyleSheet.php index 719d1c829..52bc4b27b 100644 --- a/library/Icinga/Web/StyleSheet.php +++ b/library/Icinga/Web/StyleSheet.php @@ -11,7 +11,7 @@ use Icinga\Web\LessCompiler; class StyleSheet { protected static $lessFiles = array( - '../application/fonts/fontello-ifont/css/ifont-embedded.css', + 'fonts/fontello-ifont/css/ifont-embedded.less', 'css/vendor/tipsy.css', 'css/icinga/defaults.less', 'css/icinga/layout-colors.less', @@ -96,7 +96,8 @@ class StyleSheet $cache->send($cacheFile); return; } - $less = new LessCompiler(); + + $less = new LessCompiler(dirname($_SERVER['PHP_SELF'])); foreach ($lessFiles as $file) { $less->addFile($file); } diff --git a/application/fonts/fontello-ifont/LICENSE.txt b/public/fonts/fontello-ifont/LICENSE.txt similarity index 100% rename from application/fonts/fontello-ifont/LICENSE.txt rename to public/fonts/fontello-ifont/LICENSE.txt diff --git a/application/fonts/fontello-ifont/README.txt b/public/fonts/fontello-ifont/README.txt similarity index 100% rename from application/fonts/fontello-ifont/README.txt rename to public/fonts/fontello-ifont/README.txt diff --git a/application/fonts/fontello-ifont/config.json b/public/fonts/fontello-ifont/config.json similarity index 100% rename from application/fonts/fontello-ifont/config.json rename to public/fonts/fontello-ifont/config.json diff --git a/application/fonts/fontello-ifont/css/animation.css b/public/fonts/fontello-ifont/css/animation.css similarity index 100% rename from application/fonts/fontello-ifont/css/animation.css rename to public/fonts/fontello-ifont/css/animation.css diff --git a/application/fonts/fontello-ifont/css/ifont-codes.css b/public/fonts/fontello-ifont/css/ifont-codes.css similarity index 100% rename from application/fonts/fontello-ifont/css/ifont-codes.css rename to public/fonts/fontello-ifont/css/ifont-codes.css diff --git a/application/fonts/fontello-ifont/css/ifont-embedded.css b/public/fonts/fontello-ifont/css/ifont-embedded.less similarity index 99% rename from application/fonts/fontello-ifont/css/ifont-embedded.css rename to public/fonts/fontello-ifont/css/ifont-embedded.less index 92bcfdff9..294c342e3 100644 --- a/application/fonts/fontello-ifont/css/ifont-embedded.css +++ b/public/fonts/fontello-ifont/css/ifont-embedded.less @@ -1,8 +1,8 @@ @font-face { font-family: 'ifont'; - src: url('../font/ifont.eot?75097146'); - src: url('../font/ifont.eot?75097146#iefix') format('embedded-opentype'), - url('../font/ifont.svg?75097146#ifont') format('svg'); + src: url('@{baseurl}/fonts/fontello-ifont/font/ifont.eot?75097146'); + src: url('@{baseurl}/fonts/fontello-ifont/font/ifont.eot?75097146#iefix') format('embedded-opentype'), + url('@{baseurl}/fonts/fontello-ifont/ifont.svg?75097146#ifont') format('svg'); font-weight: normal; font-style: normal; } diff --git a/application/fonts/fontello-ifont/css/ifont-ie7-codes.css b/public/fonts/fontello-ifont/css/ifont-ie7-codes.css similarity index 100% rename from application/fonts/fontello-ifont/css/ifont-ie7-codes.css rename to public/fonts/fontello-ifont/css/ifont-ie7-codes.css diff --git a/application/fonts/fontello-ifont/css/ifont-ie7.css b/public/fonts/fontello-ifont/css/ifont-ie7.css similarity index 100% rename from application/fonts/fontello-ifont/css/ifont-ie7.css rename to public/fonts/fontello-ifont/css/ifont-ie7.css diff --git a/application/fonts/fontello-ifont/css/ifont.css b/public/fonts/fontello-ifont/css/ifont.css similarity index 100% rename from application/fonts/fontello-ifont/css/ifont.css rename to public/fonts/fontello-ifont/css/ifont.css diff --git a/application/fonts/fontello-ifont/demo.html b/public/fonts/fontello-ifont/demo.html similarity index 100% rename from application/fonts/fontello-ifont/demo.html rename to public/fonts/fontello-ifont/demo.html diff --git a/application/fonts/fontello-ifont/font/ifont.eot b/public/fonts/fontello-ifont/font/ifont.eot similarity index 100% rename from application/fonts/fontello-ifont/font/ifont.eot rename to public/fonts/fontello-ifont/font/ifont.eot diff --git a/application/fonts/fontello-ifont/font/ifont.svg b/public/fonts/fontello-ifont/font/ifont.svg similarity index 100% rename from application/fonts/fontello-ifont/font/ifont.svg rename to public/fonts/fontello-ifont/font/ifont.svg diff --git a/application/fonts/fontello-ifont/font/ifont.ttf b/public/fonts/fontello-ifont/font/ifont.ttf similarity index 100% rename from application/fonts/fontello-ifont/font/ifont.ttf rename to public/fonts/fontello-ifont/font/ifont.ttf diff --git a/application/fonts/fontello-ifont/font/ifont.woff b/public/fonts/fontello-ifont/font/ifont.woff similarity index 100% rename from application/fonts/fontello-ifont/font/ifont.woff rename to public/fonts/fontello-ifont/font/ifont.woff diff --git a/public/fonts/fontello-ifont/icingaweb.md b/public/fonts/fontello-ifont/icingaweb.md new file mode 100644 index 000000000..fa0a52c7d --- /dev/null +++ b/public/fonts/fontello-ifont/icingaweb.md @@ -0,0 +1,6 @@ +# fontello-ifont has been moved + +The font directory has been moved to the public structure because of Internet Explorer version 8 compatibility. The +common way for browsers is to include the binary embeded font type in the javascript. IE8 falls back and include one of +the provided font sources. Therefore it is important to have the font files available public and exported by the +HTTP server. \ No newline at end of file From 8383320f319ddea9a3bd0e730c13eb0c8c96d7be Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Wed, 28 Jan 2015 17:52:17 +0100 Subject: [PATCH 0422/2920] Update documentation covering external authentication refs #8274 --- doc/external_authentication.md | 125 ++++++++++++++++----------------- 1 file changed, 59 insertions(+), 66 deletions(-) diff --git a/doc/external_authentication.md b/doc/external_authentication.md index 240713038..15df1e1cf 100644 --- a/doc/external_authentication.md +++ b/doc/external_authentication.md @@ -1,90 +1,83 @@ -# Externel Authentication +# External Authentication -It is possible to use the authentication mechanism of the webserver, -instead of using the internal authentication-manager to -authenticate users. This might be useful if you only have very few users, and -user management over *.htaccess* is sufficient, or if you must use some other -authentication mechanism that is only available through your webserver. +It is possible to utilize the authentication mechanism of the webserver instead +of the internal authentication of Icinga Web 2 to authenticate users. This might +be useful if you only have very few users and user management over **.htaccess** +is not sufficient or if you are required to use some other authentication +mechanism that is only available by utilizing the webserver. -When external authentication is used, Icingaweb will entrust the -complete authentication process to the external authentication provider (the webserver): -The provider should take care of authenticating the user and declining -all requests with invalid or missing credentials. When the authentication -was succesful, it should provide the authenticated users name to its php-module -and Icingaweb will assume that the user is authorized to access the page. -Because of this it is very important that the webservers authentication is -configured correctly, as wrong configuration could lead to unauthorized -access to the site, or a broken login-process. +Icinga Web 2 will entrust the complete authentication process to the +authentication provider of the webserver, if external authentication is used. +So it is very important that the webserver's authentication is configured +correctly as wrong configuration might lead to unauthorized access or a +malfunction in the login-process. +## Using External Authentication -## Use External Authentication +External authentication in Icinga Web 2 requires the following preparations: -Using external authentication in Icingaweb requires two steps to work: +1. The external authentication must be set up properly to correctly + authenticate users +2. Icinga Web 2 must be configured to use external authentication -1. The external authentication must be set up correctly to always - authenticate the users. -2. Icingaweb must be configured to use the external authentication. +### Preparing the External Authentication Provider +This step depends heavily on the used webserver and authentication mechanism you +want to use. It is not possible to cover all possibillities and you should +probably read the documentation for your webserver to get detailed instructions +on how to set up authentication properly. -### Prepare the External Authentication Provider - -This step depends heavily on the used webserver and authentication -mechanism you want to use. It is not possible to cover all possibillities -and you should probably read the documentation for your webserver for -detailed instructions on how to set up authentication properly. - -In general, you need to make sure that: - - - All routes require authentication - - Only permitted users are allowed to authenticate +In general you need to make sure that: +- All routes require authentication +- Only permitted users are allowed to authenticate #### Example Configuration for Apache and HTTPDigestAuthentication -The following example will show how to enable external authentication in Apache using -*HTTP Digest Authentication*. +The following example will show how to enable external authentication in Apache +using *HTTP Digest Authentication*. -##### Create users +##### Creating users -To create users for a digest authentication we can use the tool *htdigest*. -We choose *.icingawebdigest* as a name for the created file, containing -the user credentials. +To create users for digest authentication you can use the tool *htdigest*. In +this example **.icingawebdigest** is the name of the file containing the user +credentials. -This command will create a new file with the user *jdoe*. *htdigest* -will prompt you for your password, after it has been executed. If you -want to add more users to the file you need to ommit the *-c* parameter -in all further commands to avoInid the file to be overwritten. +This command creates a new file with the user *jdoe*. *htdigest* will prompt +you for a password. If you want to add more users to the file you need to omit +the *-c* parameter in all following commands to not to overwrite the file. +```` +sudo htdigest -c /etc/icingaweb2/.icingawebdigest "Icinga Web 2" jdoe +```` - sudo htdigest -c /etc/httpd/conf.d/.icingawebdigest "Icingaweb 2" jdoe +##### Configuring the Webserver +The webserver should require authentication for all public Icinga Web 2 files. -##### Set up authentication +```` + + AuthType digest + AuthName "Icinga Web 2" + AuthDigestProvider file + AuthUserFile /etc/icingaweb2/.icingawebdigest + Require valid-user + +```` -The webserver should require authentication for all public icingaweb files. +### Preparing Icinga Web 2 +Once external authentication is set up correctly you need to configure Icinga +Web 2. In case you already completed the setup wizard it is likely that you are +now finished. - - AuthType digest - AuthName "Icingaweb 2" - AuthDigestProvider file - AuthUserFile /etc/httpd/conf.d/.icingawebdigest - Require valid-user - +To get Icinga Web 2 to use external authentication the file +**config/authentication.ini** is required. Just add the following section +called "autologin", or any name of your choice, and save your changes: - -### Prepare Icingaweb +```` +[autologin] +backend = external +```` -When the external authentication is set up correctly, we need -to configure IcingaWeb to use it as an authentication source. The -configuration key *authenticationMode* in the section *global* defines -if the authentication should be handled internally or externally. Since -we want to delegate the authentication to the Webserver we choose -"external" as the new value: - - - [global] - ; ... - authenticationMode = "external" - ; ... - +Congratulations! You are now logged in when visiting Icinga Web 2. \ No newline at end of file From 400fbccbb899b922931033165bda42c0dc44fc24 Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Wed, 28 Jan 2015 17:59:43 +0100 Subject: [PATCH 0423/2920] Add setup route to the installation documentation refs #7848 --- doc/installation.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/installation.md b/doc/installation.md index def23ffaf..170199832 100644 --- a/doc/installation.md +++ b/doc/installation.md @@ -107,4 +107,4 @@ In case you do not remember the token you can show it using the `icingacli`: **Step 5: Web Setup** -Visit Icinga Web 2 in your browser and complete installation using the web setup. +Visit Icinga Web 2 in your browser and complete installation using the web setup: /icingaweb2/setup From c1df1f822edeedd786fcb62fd0be4238dfc600de Mon Sep 17 00:00:00 2001 From: Marius Hein Date: Thu, 29 Jan 2015 11:25:37 +0100 Subject: [PATCH 0424/2920] ifont: Reorganize files and drop use less attributes fixes #6417 --- .../fonts/fontello-ifont/LICENSE.txt | 0 .../fonts/fontello-ifont/README.txt | 0 .../fonts/fontello-ifont/config.json | 0 .../fonts/fontello-ifont/css/animation.css | 0 .../fonts/fontello-ifont/css/ifont-codes.css | 0 .../fonts/fontello-ifont/css/ifont-embedded.css | 6 +++--- .../fonts/fontello-ifont/css/ifont-ie7-codes.css | 0 .../fonts/fontello-ifont/css/ifont-ie7.css | 0 .../fonts/fontello-ifont/css/ifont.css | 0 .../fonts/fontello-ifont/demo.html | 0 application/fonts/icingaweb.md | 9 +++++++++ library/Icinga/Web/LessCompiler.php | 8 -------- library/Icinga/Web/StyleSheet.php | 4 ++-- public/{fonts/fontello-ifont => }/font/ifont.eot | Bin public/{fonts/fontello-ifont => }/font/ifont.svg | 0 public/{fonts/fontello-ifont => }/font/ifont.ttf | Bin public/{fonts/fontello-ifont => }/font/ifont.woff | Bin public/fonts/fontello-ifont/icingaweb.md | 6 ------ 18 files changed, 14 insertions(+), 19 deletions(-) rename {public => application}/fonts/fontello-ifont/LICENSE.txt (100%) rename {public => application}/fonts/fontello-ifont/README.txt (100%) rename {public => application}/fonts/fontello-ifont/config.json (100%) rename {public => application}/fonts/fontello-ifont/css/animation.css (100%) rename {public => application}/fonts/fontello-ifont/css/ifont-codes.css (100%) rename public/fonts/fontello-ifont/css/ifont-embedded.less => application/fonts/fontello-ifont/css/ifont-embedded.css (99%) rename {public => application}/fonts/fontello-ifont/css/ifont-ie7-codes.css (100%) rename {public => application}/fonts/fontello-ifont/css/ifont-ie7.css (100%) rename {public => application}/fonts/fontello-ifont/css/ifont.css (100%) rename {public => application}/fonts/fontello-ifont/demo.html (100%) create mode 100644 application/fonts/icingaweb.md rename public/{fonts/fontello-ifont => }/font/ifont.eot (100%) rename public/{fonts/fontello-ifont => }/font/ifont.svg (100%) rename public/{fonts/fontello-ifont => }/font/ifont.ttf (100%) rename public/{fonts/fontello-ifont => }/font/ifont.woff (100%) delete mode 100644 public/fonts/fontello-ifont/icingaweb.md diff --git a/public/fonts/fontello-ifont/LICENSE.txt b/application/fonts/fontello-ifont/LICENSE.txt similarity index 100% rename from public/fonts/fontello-ifont/LICENSE.txt rename to application/fonts/fontello-ifont/LICENSE.txt diff --git a/public/fonts/fontello-ifont/README.txt b/application/fonts/fontello-ifont/README.txt similarity index 100% rename from public/fonts/fontello-ifont/README.txt rename to application/fonts/fontello-ifont/README.txt diff --git a/public/fonts/fontello-ifont/config.json b/application/fonts/fontello-ifont/config.json similarity index 100% rename from public/fonts/fontello-ifont/config.json rename to application/fonts/fontello-ifont/config.json diff --git a/public/fonts/fontello-ifont/css/animation.css b/application/fonts/fontello-ifont/css/animation.css similarity index 100% rename from public/fonts/fontello-ifont/css/animation.css rename to application/fonts/fontello-ifont/css/animation.css diff --git a/public/fonts/fontello-ifont/css/ifont-codes.css b/application/fonts/fontello-ifont/css/ifont-codes.css similarity index 100% rename from public/fonts/fontello-ifont/css/ifont-codes.css rename to application/fonts/fontello-ifont/css/ifont-codes.css diff --git a/public/fonts/fontello-ifont/css/ifont-embedded.less b/application/fonts/fontello-ifont/css/ifont-embedded.css similarity index 99% rename from public/fonts/fontello-ifont/css/ifont-embedded.less rename to application/fonts/fontello-ifont/css/ifont-embedded.css index 294c342e3..92bcfdff9 100644 --- a/public/fonts/fontello-ifont/css/ifont-embedded.less +++ b/application/fonts/fontello-ifont/css/ifont-embedded.css @@ -1,8 +1,8 @@ @font-face { font-family: 'ifont'; - src: url('@{baseurl}/fonts/fontello-ifont/font/ifont.eot?75097146'); - src: url('@{baseurl}/fonts/fontello-ifont/font/ifont.eot?75097146#iefix') format('embedded-opentype'), - url('@{baseurl}/fonts/fontello-ifont/ifont.svg?75097146#ifont') format('svg'); + src: url('../font/ifont.eot?75097146'); + src: url('../font/ifont.eot?75097146#iefix') format('embedded-opentype'), + url('../font/ifont.svg?75097146#ifont') format('svg'); font-weight: normal; font-style: normal; } diff --git a/public/fonts/fontello-ifont/css/ifont-ie7-codes.css b/application/fonts/fontello-ifont/css/ifont-ie7-codes.css similarity index 100% rename from public/fonts/fontello-ifont/css/ifont-ie7-codes.css rename to application/fonts/fontello-ifont/css/ifont-ie7-codes.css diff --git a/public/fonts/fontello-ifont/css/ifont-ie7.css b/application/fonts/fontello-ifont/css/ifont-ie7.css similarity index 100% rename from public/fonts/fontello-ifont/css/ifont-ie7.css rename to application/fonts/fontello-ifont/css/ifont-ie7.css diff --git a/public/fonts/fontello-ifont/css/ifont.css b/application/fonts/fontello-ifont/css/ifont.css similarity index 100% rename from public/fonts/fontello-ifont/css/ifont.css rename to application/fonts/fontello-ifont/css/ifont.css diff --git a/public/fonts/fontello-ifont/demo.html b/application/fonts/fontello-ifont/demo.html similarity index 100% rename from public/fonts/fontello-ifont/demo.html rename to application/fonts/fontello-ifont/demo.html diff --git a/application/fonts/icingaweb.md b/application/fonts/icingaweb.md new file mode 100644 index 000000000..5699f07b2 --- /dev/null +++ b/application/fonts/icingaweb.md @@ -0,0 +1,9 @@ +# fontello-ifont font files moved + +New target is: public/font + +The font directory has been moved to the public structure because of +Internet Explorer version 8 compatibility. The common way for browsers is to +include the binary embeded font type in the javascript. IE8 falls back and +include one of the provided font sources. Therefore it is important to have +the font files available public and exported by the HTTP server. diff --git a/library/Icinga/Web/LessCompiler.php b/library/Icinga/Web/LessCompiler.php index a5349f1a4..5d5e04b22 100644 --- a/library/Icinga/Web/LessCompiler.php +++ b/library/Icinga/Web/LessCompiler.php @@ -38,19 +38,11 @@ class LessCompiler /** * Create a new instance - * - * @param string $basePath Provide web base path optional */ public function __construct($basePath = null) { require_once 'lessphp/lessc.inc.php'; $this->lessc = new lessc(); - - $this->lessc->setVariables( - array( - 'baseurl' => '\'' . $basePath. '\'' - ) - ); } public function compress() diff --git a/library/Icinga/Web/StyleSheet.php b/library/Icinga/Web/StyleSheet.php index 52bc4b27b..9e6bd0bed 100644 --- a/library/Icinga/Web/StyleSheet.php +++ b/library/Icinga/Web/StyleSheet.php @@ -11,7 +11,7 @@ use Icinga\Web\LessCompiler; class StyleSheet { protected static $lessFiles = array( - 'fonts/fontello-ifont/css/ifont-embedded.less', + '../application/fonts/fontello-ifont/css/ifont-embedded.css', 'css/vendor/tipsy.css', 'css/icinga/defaults.less', 'css/icinga/layout-colors.less', @@ -97,7 +97,7 @@ class StyleSheet return; } - $less = new LessCompiler(dirname($_SERVER['PHP_SELF'])); + $less = new LessCompiler(); foreach ($lessFiles as $file) { $less->addFile($file); } diff --git a/public/fonts/fontello-ifont/font/ifont.eot b/public/font/ifont.eot similarity index 100% rename from public/fonts/fontello-ifont/font/ifont.eot rename to public/font/ifont.eot diff --git a/public/fonts/fontello-ifont/font/ifont.svg b/public/font/ifont.svg similarity index 100% rename from public/fonts/fontello-ifont/font/ifont.svg rename to public/font/ifont.svg diff --git a/public/fonts/fontello-ifont/font/ifont.ttf b/public/font/ifont.ttf similarity index 100% rename from public/fonts/fontello-ifont/font/ifont.ttf rename to public/font/ifont.ttf diff --git a/public/fonts/fontello-ifont/font/ifont.woff b/public/font/ifont.woff similarity index 100% rename from public/fonts/fontello-ifont/font/ifont.woff rename to public/font/ifont.woff diff --git a/public/fonts/fontello-ifont/icingaweb.md b/public/fonts/fontello-ifont/icingaweb.md deleted file mode 100644 index fa0a52c7d..000000000 --- a/public/fonts/fontello-ifont/icingaweb.md +++ /dev/null @@ -1,6 +0,0 @@ -# fontello-ifont has been moved - -The font directory has been moved to the public structure because of Internet Explorer version 8 compatibility. The -common way for browsers is to include the binary embeded font type in the javascript. IE8 falls back and include one of -the provided font sources. Therefore it is important to have the font files available public and exported by the -HTTP server. \ No newline at end of file From dd483d98df9483f50c16ddde5041077d513c679f Mon Sep 17 00:00:00 2001 From: Marius Hein Date: Thu, 29 Jan 2015 14:04:47 +0100 Subject: [PATCH 0425/2920] LessCompiler: Remove useless argument refs #6417 --- library/Icinga/Web/LessCompiler.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library/Icinga/Web/LessCompiler.php b/library/Icinga/Web/LessCompiler.php index 5d5e04b22..261790579 100644 --- a/library/Icinga/Web/LessCompiler.php +++ b/library/Icinga/Web/LessCompiler.php @@ -39,7 +39,7 @@ class LessCompiler /** * Create a new instance */ - public function __construct($basePath = null) + public function __construct() { require_once 'lessphp/lessc.inc.php'; $this->lessc = new lessc(); From 7e792f5d2eab3657d87969433d9506dc99085c4a Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Thu, 29 Jan 2015 15:40:37 +0100 Subject: [PATCH 0426/2920] Add explicit step-attribute to html5-datetime* input elements fixes #8314 --- application/views/helpers/FormDateTime.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/application/views/helpers/FormDateTime.php b/application/views/helpers/FormDateTime.php index cb760a620..b75dfec62 100644 --- a/application/views/helpers/FormDateTime.php +++ b/application/views/helpers/FormDateTime.php @@ -57,7 +57,7 @@ class Zend_View_Helper_FormDateTime extends Zend_View_Helper_FormElement $type = $attribs['local'] === true ? 'datetime-local' : 'datetime'; unset($attribs['local']); // Unset local to not render it again in $this->_htmlAttribs($attribs) $html5 = sprintf( - 'view->escape($name), $this->view->escape($id), From 2a115e71d4924f416cb9eea4da4a5913d97d8680 Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Thu, 29 Jan 2015 15:53:15 +0100 Subject: [PATCH 0427/2920] Add support for paged LDAP search results fixes #8261 refs #6176 --- .../Backend/LdapUserBackend.php | 2 +- library/Icinga/Protocol/Ldap/Connection.php | 122 ++++++++++++------ library/Icinga/Protocol/Ldap/Query.php | 13 ++ 3 files changed, 97 insertions(+), 40 deletions(-) diff --git a/library/Icinga/Authentication/Backend/LdapUserBackend.php b/library/Icinga/Authentication/Backend/LdapUserBackend.php index a9ffba0c5..69fe795fc 100644 --- a/library/Icinga/Authentication/Backend/LdapUserBackend.php +++ b/library/Icinga/Authentication/Backend/LdapUserBackend.php @@ -213,7 +213,7 @@ class LdapUserBackend extends UserBackend */ public function count() { - return $this->conn->count($this->selectUsers()); + return $this->selectUsers()->count(); } /** diff --git a/library/Icinga/Protocol/Ldap/Connection.php b/library/Icinga/Protocol/Ldap/Connection.php index 2f8737c8b..b0bf1f281 100644 --- a/library/Icinga/Protocol/Ldap/Connection.php +++ b/library/Icinga/Protocol/Ldap/Connection.php @@ -4,6 +4,7 @@ namespace Icinga\Protocol\Ldap; +use Exception; use Icinga\Protocol\Ldap\Exception as LdapException; use Icinga\Application\Platform; use Icinga\Application\Config; @@ -97,6 +98,9 @@ class Connection protected $namingContexts; protected $discoverySuccess = false; + protected $lastResult; + protected $pageCookie; + /** * Constructor * @@ -250,44 +254,55 @@ class Connection */ public function count(Query $query) { - $results = $this->runQuery($query, '+'); - if (! $results) { - return 0; + $this->connect(); + $this->bind(); + + $count = 0; + $results = $this->runQuery($query); + while (! empty($results)) { + $count += ldap_count_entries($this->ds, $results); + $results = $this->runQuery($query); } - return ldap_count_entries($this->ds, $results); + + return $count; } - public function fetchAll($query, $fields = array()) + public function fetchAll(Query $query, $fields = array()) { - $offset = null; - $limit = null; + $this->connect(); + $this->bind(); + + $offset = $limit = null; if ($query->hasLimit()) { $offset = $query->getOffset(); - $limit = $query->getLimit(); + $limit = $query->getLimit(); } + + $count = 0; $entries = array(); $results = $this->runQuery($query, $fields); - if (! $results) { - return array(); - } - $entry = ldap_first_entry($this->ds, $results); - $count = 0; - while ($entry) { - if (($offset === null || $offset <= $count) - && ($limit === null || ($offset + $limit) >= $count) - ) { - $attrs = ldap_get_attributes($this->ds, $entry); - $entries[ldap_get_dn($this->ds, $entry)] - = $this->cleanupAttributes($attrs); + while (! empty($results)) { + $entry = ldap_first_entry($this->ds, $results); + while ($entry) { + $count++; + if (($offset === null || $offset <= $count) + && ($limit === null || ($offset + $limit) > $count) + ) { + $entries[ldap_get_dn($this->ds, $entry)] = $this->cleanupAttributes( + ldap_get_attributes($this->ds, $entry) + ); + } + + $entry = ldap_next_entry($this->ds, $entry); } - $count++; - $entry = ldap_next_entry($this->ds, $entry); + + $results = $this->runQuery($query, $fields); } - ldap_free_result($results); + return $entries; } - public function cleanupAttributes(& $attrs) + protected function cleanupAttributes($attrs) { $clean = (object) array(); for ($i = 0; $i < $attrs['count']; $i++) { @@ -303,26 +318,55 @@ class Connection return $clean; } - protected function runQuery($query, $fields) + protected function runQuery(Query $query, $fields = array()) { - $this->connect(); - $this->bind(); - if ($query instanceof Query) { - $fields = $query->listFields(); + if ($query->getUsePagedResults()) { + if ($this->pageCookie === null) { + $this->pageCookie = ''; + } else { + try { + ldap_control_paged_result_response($this->ds, $this->lastResult, $this->pageCookie); + } catch (Exception $e) { + $this->pageCookie = ''; + Logger::error( + 'Unable to request paged LDAP results. Does the server allow paged search requests? (%s)', + $e->getMessage() + ); + } + + ldap_free_result($this->lastResult); + if (! $this->pageCookie) { + $this->pageCookie = $this->lastResult = null; + // Abandon the paged search request so that subsequent requests succeed + ldap_control_paged_result($this->ds, 0); + return false; + } + } + + // Does not matter whether we'll use a valid page size here, + // as the server applies its hard limit in case its too high + ldap_control_paged_result( + $this->ds, + $query->hasLimit() ? $query->getLimit() : 500, + true, + $this->pageCookie + ); + } elseif ($this->lastResult !== null) { + ldap_free_result($this->lastResult); + $this->lastResult = null; + return false; } - // WARNING: - // We do not support pagination right now, and there is no chance to - // do so for PHP < 5.4. Warnings about "Sizelimit exceeded" will - // therefore not be hidden right now. + $base = $query->hasBase() ? $query->getBase() : $this->root_dn; $results = @ldap_search( $this->ds, $base, $query->create(), - $fields, + empty($fields) ? $query->listFields() : $fields, 0, // Attributes and values 0 // No limit - at least where possible ); + if ($results === false) { if (ldap_errno($this->ds) === self::LDAP_NO_SUCH_OBJECT) { return false; @@ -336,12 +380,12 @@ class Connection ) ); } - $list = array(); - if ($query instanceof Query) { - foreach ($query->getSortColumns() as $col) { - ldap_sort($this->ds, $results, $col[0]); - } + + foreach ($query->getSortColumns() as $col) { + ldap_sort($this->ds, $results, $col[0]); } + + $this->lastResult = $results; return $results; } diff --git a/library/Icinga/Protocol/Ldap/Query.php b/library/Icinga/Protocol/Ldap/Query.php index 462c83d61..930cefa96 100644 --- a/library/Icinga/Protocol/Ldap/Query.php +++ b/library/Icinga/Protocol/Ldap/Query.php @@ -33,6 +33,7 @@ class Query protected $sort_columns = array(); protected $count; protected $base; + protected $usePagedResults; /** * Constructor @@ -43,6 +44,7 @@ class Query public function __construct(Connection $connection) { $this->connection = $connection; + $this->usePagedResults = version_compare(PHP_VERSION, '5.4.0') >= 0; } public function setBase($base) @@ -61,6 +63,17 @@ class Query return $this->base; } + public function setUsePagedResults($state = true) + { + $this->usePagedResults = (bool) $state && version_compare(PHP_VERSION, '5.4.0') >= 0; + return $this; + } + + public function getUsePagedResults() + { + return $this->usePagedResults; + } + /** * Count result set, ignoring limits * From 97cc37b99ca9c62f3bf75be77eef963544b7958c Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Thu, 29 Jan 2015 15:59:03 +0100 Subject: [PATCH 0428/2920] Move php version check from ...\Ldap\Query to ...\Ldap\Connection refs #8261 refs #6176 --- library/Icinga/Protocol/Ldap/Connection.php | 2 +- library/Icinga/Protocol/Ldap/Query.php | 5 ++--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/library/Icinga/Protocol/Ldap/Connection.php b/library/Icinga/Protocol/Ldap/Connection.php index b0bf1f281..e340efc25 100644 --- a/library/Icinga/Protocol/Ldap/Connection.php +++ b/library/Icinga/Protocol/Ldap/Connection.php @@ -320,7 +320,7 @@ class Connection protected function runQuery(Query $query, $fields = array()) { - if ($query->getUsePagedResults()) { + if ($query->getUsePagedResults() && version_compare(PHP_VERSION, '5.4.0') >= 0) { if ($this->pageCookie === null) { $this->pageCookie = ''; } else { diff --git a/library/Icinga/Protocol/Ldap/Query.php b/library/Icinga/Protocol/Ldap/Query.php index 930cefa96..c6f0d6fa1 100644 --- a/library/Icinga/Protocol/Ldap/Query.php +++ b/library/Icinga/Protocol/Ldap/Query.php @@ -33,7 +33,7 @@ class Query protected $sort_columns = array(); protected $count; protected $base; - protected $usePagedResults; + protected $usePagedResults = true; /** * Constructor @@ -44,7 +44,6 @@ class Query public function __construct(Connection $connection) { $this->connection = $connection; - $this->usePagedResults = version_compare(PHP_VERSION, '5.4.0') >= 0; } public function setBase($base) @@ -65,7 +64,7 @@ class Query public function setUsePagedResults($state = true) { - $this->usePagedResults = (bool) $state && version_compare(PHP_VERSION, '5.4.0') >= 0; + $this->usePagedResults = (bool) $state; return $this; } From 9ff0bbcfc02eb05e6062f472941096d14036e03a Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Thu, 29 Jan 2015 17:07:58 +0100 Subject: [PATCH 0429/2920] Fix that Icinga\Protocol\Ldap\Connection does not correctly apply limits --- library/Icinga/Protocol/Ldap/Connection.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/library/Icinga/Protocol/Ldap/Connection.php b/library/Icinga/Protocol/Ldap/Connection.php index e340efc25..7b1ca4567 100644 --- a/library/Icinga/Protocol/Ldap/Connection.php +++ b/library/Icinga/Protocol/Ldap/Connection.php @@ -285,8 +285,9 @@ class Connection $entry = ldap_first_entry($this->ds, $results); while ($entry) { $count++; - if (($offset === null || $offset <= $count) - && ($limit === null || ($offset + $limit) > $count) + if ( + ($offset === null || $offset <= $count) + && ($limit === null || $limit > count($entries)) ) { $entries[ldap_get_dn($this->ds, $entry)] = $this->cleanupAttributes( ldap_get_attributes($this->ds, $entry) From 6e533f223e85f6fb94263de93d911682de972f36 Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Thu, 29 Jan 2015 17:12:59 +0100 Subject: [PATCH 0430/2920] Log warnings emitted by ldap_control_paged_result_response() as debug Such a warning is emitted as well in case it's not critical. That is passing an alternative overall result limit using ldap_search() to the server causes it being applied across pages so ldap_control_paged_result_response() does not indicate the "end" of the resultset just by adjusting the cookie but by emitting the warning as well. --- library/Icinga/Protocol/Ldap/Connection.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library/Icinga/Protocol/Ldap/Connection.php b/library/Icinga/Protocol/Ldap/Connection.php index 7b1ca4567..37d8c4660 100644 --- a/library/Icinga/Protocol/Ldap/Connection.php +++ b/library/Icinga/Protocol/Ldap/Connection.php @@ -329,7 +329,7 @@ class Connection ldap_control_paged_result_response($this->ds, $this->lastResult, $this->pageCookie); } catch (Exception $e) { $this->pageCookie = ''; - Logger::error( + Logger::debug( 'Unable to request paged LDAP results. Does the server allow paged search requests? (%s)', $e->getMessage() ); From 3e128732b843ea2c22aab32b61ef43bd09a14080 Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Thu, 29 Jan 2015 17:29:11 +0100 Subject: [PATCH 0431/2920] Apply a limit to results fetched via Ldap\Connection::fetchRow() fixes #7993 --- library/Icinga/Protocol/Ldap/Connection.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/library/Icinga/Protocol/Ldap/Connection.php b/library/Icinga/Protocol/Ldap/Connection.php index 37d8c4660..1f58f34da 100644 --- a/library/Icinga/Protocol/Ldap/Connection.php +++ b/library/Icinga/Protocol/Ldap/Connection.php @@ -242,7 +242,8 @@ class Connection */ public function fetchRow($query, $fields = array()) { - // TODO: This is ugly, make it better! + $query = clone $query; + $query->limit(1); $results = $this->fetchAll($query, $fields); return array_shift($results); } @@ -365,7 +366,7 @@ class Connection $query->create(), empty($fields) ? $query->listFields() : $fields, 0, // Attributes and values - 0 // No limit - at least where possible + $query->hasLimit() ? $query->getOffset() + $query->getLimit() : 0 // No limit - at least where possible ); if ($results === false) { From 375345f8378a8988b9b2d56b1dd42dcf5c98da80 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Fri, 30 Jan 2015 09:06:10 +0100 Subject: [PATCH 0432/2920] lib: Add SecurityException All assertPermission() calls must throw this exception. --- library/Icinga/Security/SecurityException.php | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 library/Icinga/Security/SecurityException.php diff --git a/library/Icinga/Security/SecurityException.php b/library/Icinga/Security/SecurityException.php new file mode 100644 index 000000000..168d4a9be --- /dev/null +++ b/library/Icinga/Security/SecurityException.php @@ -0,0 +1,12 @@ + Date: Fri, 30 Jan 2015 09:31:05 +0100 Subject: [PATCH 0433/2920] Return HTTP 403 in case a SecurityException was thrown --- application/controllers/ErrorController.php | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/application/controllers/ErrorController.php b/application/controllers/ErrorController.php index 23051bd9a..0548b5c9c 100644 --- a/application/controllers/ErrorController.php +++ b/application/controllers/ErrorController.php @@ -1,12 +1,9 @@ getResponse()->setHttpResponseCode(403); + $this->view->message = $exception->getMessage(); + break; + } + // Move to default default: $title = preg_replace('/\r?\n.*$/s', '', $exception->getMessage()); $this->getResponse()->setHttpResponseCode(500); From 63305fdf9aca81a477f677659062b12136325446 Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Fri, 30 Jan 2015 09:32:08 +0100 Subject: [PATCH 0434/2920] Add Icinga\Application\Config::saveIni() Simplifies saving INI files. Icinga\File\Ini\IniWriter does already require an instance of Icinga\Application\Config so it's obvious to give "Config" the task to initialize the writer.. We do also have a central place to handle creating missing ancestor directories now. refs #8219 --- .../controllers/DashboardController.php | 41 ++++++++------- application/forms/ConfigForm.php | 12 +---- .../views/scripts/dashboard/error.phtml | 14 ++--- library/Icinga/Application/Config.php | 51 +++++++++++++++++++ .../User/Preferences/Store/IniStore.php | 39 +------------- library/Icinga/Web/Widget/Dashboard.php | 21 ++------ .../library/Monitoring/BackendStep.php | 17 ++----- .../library/Monitoring/InstanceStep.php | 9 ++-- .../library/Monitoring/SecurityStep.php | 9 ++-- .../Setup/Steps/AuthenticationStep.php | 17 +++---- .../library/Setup/Steps/GeneralConfigStep.php | 9 ++-- .../library/Setup/Steps/ResourceStep.php | 10 ++-- 12 files changed, 109 insertions(+), 140 deletions(-) diff --git a/application/controllers/DashboardController.php b/application/controllers/DashboardController.php index ba2125e12..7c70c9c5a 100644 --- a/application/controllers/DashboardController.php +++ b/application/controllers/DashboardController.php @@ -2,14 +2,13 @@ // {{{ICINGA_LICENSE_HEADER}}} // {{{ICINGA_LICENSE_HEADER}}} -use Icinga\Application\Logger; +use Exception; use Icinga\Exception\ProgrammingError; use Icinga\Forms\ConfirmRemovalForm; use Icinga\Forms\Dashboard\DashletForm; use Icinga\Web\Form; use Icinga\Web\Notification; use Icinga\Web\Controller\ActionController; -use Icinga\Web\Request; use Icinga\Web\Url; use Icinga\Web\Widget\Dashboard; use Icinga\Web\Widget\Tabextension\DashboardSettings; @@ -56,11 +55,12 @@ class DashboardController extends ActionController $dashlet = new Dashboard\Dashlet($form->getValue('dashlet'), $form->getValue('url'), $pane); $dashlet->setUserWidget(); $pane->addDashlet($dashlet); + $dashboardConfig = $dashboard->getConfig(); try { - $dashboard->write(); - } catch (\Zend_Config_Exception $e) { + $dashboardConfig->saveIni(); + } catch (Exception $e) { $action->view->error = $e; - $action->view->config = $dashboard->createWriter(); + $action->view->config = $dashboardConfig; $action->render('error'); return false; } @@ -117,11 +117,12 @@ class DashboardController extends ActionController $oldPane = $dashboard->getPane($form->getValue('org_pane')); $oldPane->removeDashlet($dashlet->getTitle()); } + $dashboardConfig = $dashboard->getConfig(); try { - $dashboard->write(); - } catch (\Zend_Config_Exception $e) { + $dashboardConfig->saveIni(); + } catch (Exception $e) { $action->view->error = $e; - $action->view->config = $dashboard->createWriter(); + $action->view->config = $dashboardConfig; $action->render('error'); return false; } @@ -158,15 +159,16 @@ class DashboardController extends ActionController $dashlet = $this->_request->getParam('dashlet'); $action = $this; $form->setOnSuccess(function (Form $form) use ($dashboard, $dashlet, $pane, $action) { + $pane = $dashboard->getPane($pane); + $pane->removeDashlet($dashlet); + $dashboardConfig = $dashboard->getConfig(); try { - $pane = $dashboard->getPane($pane); - $pane->removeDashlet($dashlet); - $dashboard->write(); + $dashboardConfig->saveIni(); Notification::success(t('Dashlet has been removed from') . ' ' . $pane->getTitle()); return true; - } catch (\Zend_Config_Exception $e) { + } catch (Exception $e) { $action->view->error = $e; - $action->view->config = $dashboard->createWriter(); + $action->view->config = $dashboardConfig; $action->render('error'); return false; } catch (ProgrammingError $e) { @@ -196,15 +198,16 @@ class DashboardController extends ActionController $pane = $this->_request->getParam('pane'); $action = $this; $form->setOnSuccess(function (Form $form) use ($dashboard, $pane, $action) { + $pane = $dashboard->getPane($pane); + $dashboard->removePane($pane->getTitle()); + $dashboardConfig = $dashboard->getConfig(); try { - $pane = $dashboard->getPane($pane); - $dashboard->removePane($pane->getTitle()); - $dashboard->write(); + $dashboardConfig->saveIni(); Notification::success(t('Dashboard has been removed') . ': ' . $pane->getTitle()); return true; - } catch (\Zend_Config_Exception $e) { + } catch (Exception $e) { $action->view->error = $e; - $action->view->config = $dashboard->createWriter(); + $action->view->config = $dashboardConfig; $action->render('error'); return false; } catch (ProgrammingError $e) { @@ -241,7 +244,7 @@ class DashboardController extends ActionController $this->view->title = $this->dashboard->getActivePane()->getTitle() . ' :: Dashboard'; if ($this->hasParam('remove')) { $this->dashboard->getActivePane()->removeDashlet($this->getParam('remove')); - $this->dashboard->write(); + $this->dashboard->getConfig()->saveIni(); $this->redirectNow(URL::fromRequest()->remove('remove')); } $this->view->tabs->add( diff --git a/application/forms/ConfigForm.php b/application/forms/ConfigForm.php index 28d3111ea..224633f1f 100644 --- a/application/forms/ConfigForm.php +++ b/application/forms/ConfigForm.php @@ -8,7 +8,6 @@ use Exception; use Zend_Form_Decorator_Abstract; use Icinga\Web\Form; use Icinga\Application\Config; -use Icinga\File\Ini\IniWriter; /** * Form base-class providing standard functionality for configuration forms @@ -44,21 +43,14 @@ class ConfigForm extends Form */ public function save() { - $writer = new IniWriter( - array( - 'config' => $this->config, - 'filename' => $this->config->getConfigFile() - ) - ); - try { - $writer->write(); + $this->config->saveIni(); } catch (Exception $e) { $this->addDecorator('ViewScript', array( 'viewModule' => 'default', 'viewScript' => 'showConfiguration.phtml', 'errorMessage' => $e->getMessage(), - 'configString' => $writer->render(), + 'configString' => $this->config, 'filePath' => $this->config->getConfigFile(), 'placement' => Zend_Form_Decorator_Abstract::PREPEND )); diff --git a/application/views/scripts/dashboard/error.phtml b/application/views/scripts/dashboard/error.phtml index e5a0f3939..56e32faf4 100644 --- a/application/views/scripts/dashboard/error.phtml +++ b/application/views/scripts/dashboard/error.phtml @@ -1,13 +1,13 @@
    -

    +

    translate('Could not persist dashboard'); ?>

    - - config->getFilename(); ?>;. + translate('Please copy the following dashboard snippet to '); ?> + config->getConfigFile(); ?>;.
    - + translate('Make sure that the webserver can write to this file.'); ?>

    -
    config->render(); ?>
    +
    config; ?>

    -

    +

    translate('Error details'); ?>

    error->getMessage(); ?>

    -
    +
    \ No newline at end of file diff --git a/library/Icinga/Application/Config.php b/library/Icinga/Application/Config.php index 361f5f11d..8d4914316 100644 --- a/library/Icinga/Application/Config.php +++ b/library/Icinga/Application/Config.php @@ -6,8 +6,10 @@ namespace Icinga\Application; use Iterator; use Countable; +use LogicException; use UnexpectedValueException; use Icinga\Data\ConfigObject; +use Icinga\File\Ini\IniWriter; use Icinga\Exception\NotReadableError; /** @@ -299,6 +301,45 @@ class Config implements Countable, Iterator return $emptyConfig; } + /** + * Save configuration to the given INI file + * + * @param string|null $filePath The path to the INI file or null in case this config's path should be used + * @param int $fileMode The file mode to store the file with + * + * @throws LogicException In case this config has no path and none is passed in either + * @throws NotWritableError In case the INI file cannot be written + * + * @todo create basepath and throw NotWritableError in case its not possible + */ + public function saveIni($filePath = null, $fileMode = 0660) + { + if ($filePath === null && $this->configFile) { + $filePath = $this->configFile; + } elseif ($filePath === null) { + throw new LogicException('You need to pass $filePath or set a path using Config::setConfigFile()'); + } + + $this->getIniWriter($filePath, $fileMode)->write(); + } + + /** + * Return a IniWriter for this config + * + * @param string|null $filePath + * @param int $fileMode + * + * @return IniWriter + */ + protected function getIniWriter($filePath = null, $fileMode = null) + { + return new IniWriter(array( + 'config' => $this, + 'filename' => $filePath, + 'filemode' => $fileMode + )); + } + /** * Prepend configuration base dir to the given relative path * @@ -354,4 +395,14 @@ class Config implements Countable, Iterator return $moduleConfigs[$configname]; } + + /** + * Return this config rendered as a INI structured string + * + * @return string + */ + public function __toString() + { + return $this->getIniWriter()->render(); + } } diff --git a/library/Icinga/User/Preferences/Store/IniStore.php b/library/Icinga/User/Preferences/Store/IniStore.php index 1ba780184..1a096ea7b 100644 --- a/library/Icinga/User/Preferences/Store/IniStore.php +++ b/library/Icinga/User/Preferences/Store/IniStore.php @@ -7,10 +7,8 @@ namespace Icinga\User\Preferences\Store; use Icinga\Application\Config; use Icinga\Exception\NotReadableError; use Icinga\Exception\NotWritableError; -use Icinga\File\Ini\IniWriter; use Icinga\User\Preferences; use Icinga\User\Preferences\PreferencesStore; -use Icinga\Util\File; /** * Load and save user preferences from and to INI files @@ -31,13 +29,6 @@ class IniStore extends PreferencesStore */ protected $preferences = array(); - /** - * Writer which stores the preferences - * - * @var IniWriter - */ - protected $writer; - /** * Initialize the store */ @@ -98,35 +89,7 @@ class IniStore extends PreferencesStore */ public function write() { - if ($this->writer === null) { - if (! file_exists($this->preferencesFile)) { - if (! is_writable($this->getStoreConfig()->location)) { - throw new NotWritableError( - 'Path to the preferences INI files %s is not writable', - $this->getStoreConfig()->location - ); - } - - File::create($this->preferencesFile, 0664); - } - - if (! is_writable($this->preferencesFile)) { - throw new NotWritableError( - 'Preferences INI file %s for user %s is not writable', - $this->preferencesFile, - $this->getUser()->getUsername() - ); - } - - $this->writer = new IniWriter( - array( - 'config' => Config::fromArray($this->preferences), - 'filename' => $this->preferencesFile - ) - ); - } - - $this->writer->write(); + Config::fromArray($this->preferences)->saveIni($this->preferencesFile); } /** diff --git a/library/Icinga/Web/Widget/Dashboard.php b/library/Icinga/Web/Widget/Dashboard.php index 45e1e6830..fe4bba803 100644 --- a/library/Icinga/Web/Widget/Dashboard.php +++ b/library/Icinga/Web/Widget/Dashboard.php @@ -6,12 +6,10 @@ namespace Icinga\Web\Widget; use Icinga\Application\Icinga; use Icinga\Application\Config; -use Icinga\Data\ConfigObject; use Icinga\Exception\ConfigurationError; use Icinga\Exception\NotReadableError; use Icinga\Exception\ProgrammingError; use Icinga\Exception\SystemPermissionException; -use Icinga\File\Ini\IniWriter; use Icinga\User; use Icinga\Web\Widget\Dashboard\Pane; use Icinga\Web\Widget\Dashboard\Dashlet as DashboardDashlet; @@ -86,13 +84,12 @@ class Dashboard extends AbstractWidget } /** - * Create a writer object + * Create and return a Config object for this dashboard * - * @return IniWriter + * @return Config */ - public function createWriter() + public function getConfig() { - $configFile = $this->getConfigFile(); $output = array(); foreach ($this->panes as $pane) { if ($pane->isUserWidget() === true) { @@ -105,17 +102,7 @@ class Dashboard extends AbstractWidget } } - $co = new ConfigObject($output); - $config = new Config($co); - return new IniWriter(array('config' => $config, 'filename' => $configFile)); - } - - /** - * Write user specific dashboards to disk - */ - public function write() - { - $this->createWriter()->write(); + return Config::fromArray($output)->setConfigFile($this->getConfigFile()); } /** diff --git a/modules/monitoring/library/Monitoring/BackendStep.php b/modules/monitoring/library/Monitoring/BackendStep.php index c0dc3d4ea..7f9fc11cf 100644 --- a/modules/monitoring/library/Monitoring/BackendStep.php +++ b/modules/monitoring/library/Monitoring/BackendStep.php @@ -7,7 +7,6 @@ namespace Icinga\Module\Monitoring; use Exception; use Icinga\Module\Setup\Step; use Icinga\Application\Config; -use Icinga\File\Ini\IniWriter; class BackendStep extends Step { @@ -38,11 +37,9 @@ class BackendStep extends Step ); try { - $writer = new IniWriter(array( - 'config' => Config::fromArray($config), - 'filename' => Config::resolvePath('modules/monitoring/backends.ini') - )); - $writer->write(); + Config::fromArray($config) + ->setConfigFile(Config::resolvePath('modules/monitoring/backends.ini')) + ->saveIni(); } catch (Exception $e) { $this->backendIniError = $e; return false; @@ -61,13 +58,7 @@ class BackendStep extends Step try { $config = Config::app('resources', true); $config->setSection($resourceName, $resourceConfig); - - $writer = new IniWriter(array( - 'config' => $config, - 'filename' => Config::resolvePath('resources.ini'), - 'filemode' => 0660 - )); - $writer->write(); + $config->saveIni(); } catch (Exception $e) { $this->resourcesIniError = $e; return false; diff --git a/modules/monitoring/library/Monitoring/InstanceStep.php b/modules/monitoring/library/Monitoring/InstanceStep.php index 2cb8d7d8d..ab54b6548 100644 --- a/modules/monitoring/library/Monitoring/InstanceStep.php +++ b/modules/monitoring/library/Monitoring/InstanceStep.php @@ -7,7 +7,6 @@ namespace Icinga\Module\Monitoring; use Exception; use Icinga\Module\Setup\Step; use Icinga\Application\Config; -use Icinga\File\Ini\IniWriter; class InstanceStep extends Step { @@ -27,11 +26,9 @@ class InstanceStep extends Step unset($instanceConfig['name']); try { - $writer = new IniWriter(array( - 'config' => Config::fromArray(array($instanceName => $instanceConfig)), - 'filename' => Config::resolvePath('modules/monitoring/instances.ini') - )); - $writer->write(); + Config::fromArray(array($instanceName => $instanceConfig)) + ->setConfigFile(Config::resolvePath('modules/monitoring/instances.ini')) + ->saveIni(); } catch (Exception $e) { $this->error = $e; return false; diff --git a/modules/monitoring/library/Monitoring/SecurityStep.php b/modules/monitoring/library/Monitoring/SecurityStep.php index 4a2c0f846..b3eda02c4 100644 --- a/modules/monitoring/library/Monitoring/SecurityStep.php +++ b/modules/monitoring/library/Monitoring/SecurityStep.php @@ -7,7 +7,6 @@ namespace Icinga\Module\Monitoring; use Exception; use Icinga\Module\Setup\Step; use Icinga\Application\Config; -use Icinga\File\Ini\IniWriter; class SecurityStep extends Step { @@ -26,11 +25,9 @@ class SecurityStep extends Step $config['security'] = $this->data['securityConfig']; try { - $writer = new IniWriter(array( - 'config' => Config::fromArray($config), - 'filename' => Config::resolvePath('modules/monitoring/config.ini') - )); - $writer->write(); + Config::fromArray($config) + ->setConfigFile(Config::resolvePath('modules/monitoring/config.ini')) + ->saveIni(); } catch (Exception $e) { $this->error = $e; return false; diff --git a/modules/setup/library/Setup/Steps/AuthenticationStep.php b/modules/setup/library/Setup/Steps/AuthenticationStep.php index ce0b49f58..c06b4e294 100644 --- a/modules/setup/library/Setup/Steps/AuthenticationStep.php +++ b/modules/setup/library/Setup/Steps/AuthenticationStep.php @@ -6,7 +6,6 @@ namespace Icinga\Module\Setup\Steps; use Exception; use Icinga\Application\Config; -use Icinga\File\Ini\IniWriter; use Icinga\Data\ConfigObject; use Icinga\Data\ResourceFactory; use Icinga\Authentication\Backend\DbUserBackend; @@ -50,11 +49,9 @@ class AuthenticationStep extends Step } try { - $writer = new IniWriter(array( - 'config' => Config::fromArray($config), - 'filename' => Config::resolvePath('authentication.ini') - )); - $writer->write(); + Config::fromArray($config) + ->setConfigFile(Config::resolvePath('authentication.ini')) + ->saveIni(); } catch (Exception $e) { $this->authIniError = $e; return false; @@ -73,11 +70,9 @@ class AuthenticationStep extends Step ); try { - $writer = new IniWriter(array( - 'config' => Config::fromArray($config), - 'filename' => Config::resolvePath('permissions.ini') - )); - $writer->write(); + Config::fromArray($config) + ->setConfigFile(Config::resolvePath('permissions.ini')) + ->saveIni(); } catch (Exception $e) { $this->permIniError = $e; return false; diff --git a/modules/setup/library/Setup/Steps/GeneralConfigStep.php b/modules/setup/library/Setup/Steps/GeneralConfigStep.php index 39c160628..bf3d8cb89 100644 --- a/modules/setup/library/Setup/Steps/GeneralConfigStep.php +++ b/modules/setup/library/Setup/Steps/GeneralConfigStep.php @@ -7,7 +7,6 @@ namespace Icinga\Module\Setup\Steps; use Exception; use Icinga\Application\Logger; use Icinga\Application\Config; -use Icinga\File\Ini\IniWriter; use Icinga\Module\Setup\Step; class GeneralConfigStep extends Step @@ -35,11 +34,9 @@ class GeneralConfigStep extends Step } try { - $writer = new IniWriter(array( - 'config' => Config::fromArray($config), - 'filename' => Config::resolvePath('config.ini') - )); - $writer->write(); + Config::fromArray($config) + ->setConfigFile(Config::resolvePath('config.ini')) + ->saveIni(); } catch (Exception $e) { $this->error = $e; return false; diff --git a/modules/setup/library/Setup/Steps/ResourceStep.php b/modules/setup/library/Setup/Steps/ResourceStep.php index c04cdbc79..aae1c3aca 100644 --- a/modules/setup/library/Setup/Steps/ResourceStep.php +++ b/modules/setup/library/Setup/Steps/ResourceStep.php @@ -6,7 +6,6 @@ namespace Icinga\Module\Setup\Steps; use Exception; use Icinga\Application\Config; -use Icinga\File\Ini\IniWriter; use Icinga\Module\Setup\Step; class ResourceStep extends Step @@ -38,12 +37,9 @@ class ResourceStep extends Step } try { - $writer = new IniWriter(array( - 'config' => Config::fromArray($resourceConfig), - 'filename' => Config::resolvePath('resources.ini'), - 'filemode' => 0660 - )); - $writer->write(); + Config::fromArray($resourceConfig) + ->setConfigFile(Config::resolvePath('resources.ini')) + ->saveIni(); } catch (Exception $e) { $this->error = $e; return false; From 2faf5f0ca16aefdac755ecfb22c72b4a83d2e179 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Fri, 30 Jan 2015 09:34:19 +0100 Subject: [PATCH 0435/2920] Throw SecurityException in ActionController::assertPermission() --- .../Web/Controller/ActionController.php | 37 ++++++++----------- 1 file changed, 16 insertions(+), 21 deletions(-) diff --git a/library/Icinga/Web/Controller/ActionController.php b/library/Icinga/Web/Controller/ActionController.php index 78fcaf7bf..87d293be6 100644 --- a/library/Icinga/Web/Controller/ActionController.php +++ b/library/Icinga/Web/Controller/ActionController.php @@ -1,23 +1,22 @@ Auth()->hasPermission($name)) { - // TODO: Shall this be an Auth Exception? Or a 404? - throw new IcingaException( - 'Auth error, no permission for "%s"', - $name - ); + if (! $this->Auth()->hasPermission($permission)) { + throw new SecurityException('No permission for %s', $permission); } } From df29dd0e7ca587cc42656dc70c59b33d821c806d Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Fri, 30 Jan 2015 09:35:01 +0100 Subject: [PATCH 0436/2920] Implement Form::hasPermission() and Form::getPermission() --- library/Icinga/Web/Form.php | 50 +++++++++++++++++++++++++++++++++++-- 1 file changed, 48 insertions(+), 2 deletions(-) diff --git a/library/Icinga/Web/Form.php b/library/Icinga/Web/Form.php index 1f3e0d4bd..daa6dcf40 100644 --- a/library/Icinga/Web/Form.php +++ b/library/Icinga/Web/Form.php @@ -1,6 +1,4 @@ create(); return parent::render($view); } + + /** + * Get the authentication manager + * + * @return Manager + */ + public function Auth() + { + if ($this->auth === null) { + $this->auth = Manager::getInstance(); + } + return $this->auth; + } + + /** + * Whether the current user has the given permission + * + * @param string $permission Name of the permission + * + * @return bool + */ + public function hasPermission($permission) + { + return $this->Auth()->hasPermission($permission); + } + + /** + * Assert that the current user has the given permission + * + * @param string $permission Name of the permission + * + * @throws SecurityException If the current user lacks the given permission + */ + public function assertPermission($permission) + { + if (! $this->Auth()->hasPermission($permission)) { + throw new SecurityException('No permission for %s', $permission); + } + } } From 0108d44d635e628004c6bc5b711ef9ba2f0e6f36 Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Fri, 30 Jan 2015 09:38:59 +0100 Subject: [PATCH 0437/2920] Fix "The use of non compound name 'Exception'..." --- application/controllers/DashboardController.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/application/controllers/DashboardController.php b/application/controllers/DashboardController.php index 7c70c9c5a..49a58426f 100644 --- a/application/controllers/DashboardController.php +++ b/application/controllers/DashboardController.php @@ -2,7 +2,7 @@ // {{{ICINGA_LICENSE_HEADER}}} // {{{ICINGA_LICENSE_HEADER}}} -use Exception; +use \Exception; use Icinga\Exception\ProgrammingError; use Icinga\Forms\ConfirmRemovalForm; use Icinga\Forms\Dashboard\DashletForm; From d19e36d9370542e8a62fb8c1ed0f2b41a5fbc5eb Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Fri, 30 Jan 2015 09:57:31 +0100 Subject: [PATCH 0438/2920] monitoring/security: Require monitoring/command/feature/instance permission for disabling notifications --- modules/monitoring/application/controllers/ProcessController.php | 1 + 1 file changed, 1 insertion(+) diff --git a/modules/monitoring/application/controllers/ProcessController.php b/modules/monitoring/application/controllers/ProcessController.php index bb5a4e5c2..5530f9c52 100644 --- a/modules/monitoring/application/controllers/ProcessController.php +++ b/modules/monitoring/application/controllers/ProcessController.php @@ -92,6 +92,7 @@ class Monitoring_ProcessController extends Controller */ public function disableNotificationsAction() { + $this->assertPermission('monitoring/command/feature/instance'); $this->view->title = $this->translate('Disable Notifications'); $programStatus = $this->backend ->select() From 7dbb8c684195b5e586ba34479a9452c04441cdbe Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Fri, 30 Jan 2015 09:58:10 +0100 Subject: [PATCH 0439/2920] monitoring/security: Require monitoring/command/feature/instance permission for toggling instance features --- .../forms/Command/Instance/ToggleInstanceFeaturesCommandForm.php | 1 + 1 file changed, 1 insertion(+) diff --git a/modules/monitoring/application/forms/Command/Instance/ToggleInstanceFeaturesCommandForm.php b/modules/monitoring/application/forms/Command/Instance/ToggleInstanceFeaturesCommandForm.php index 469c1b6eb..97a64dbd7 100644 --- a/modules/monitoring/application/forms/Command/Instance/ToggleInstanceFeaturesCommandForm.php +++ b/modules/monitoring/application/forms/Command/Instance/ToggleInstanceFeaturesCommandForm.php @@ -191,6 +191,7 @@ class ToggleInstanceFeaturesCommandForm extends CommandForm */ public function onSuccess() { + $this->assertPermission('monitoring/command/feature/instance'); foreach ($this->getValues() as $feature => $enabled) { $toggleFeature = new ToggleInstanceFeatureCommand(); $toggleFeature From 26613a010662f7b9e71eaa9a2bb0d2c8f9f3cd11 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Fri, 30 Jan 2015 09:58:30 +0100 Subject: [PATCH 0440/2920] monitoring/security: Rename permission monitoring/command/feature/program to monitoring/command/feature/instance --- modules/monitoring/configuration.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/monitoring/configuration.php b/modules/monitoring/configuration.php index 72df4e73f..7eb3bbedf 100644 --- a/modules/monitoring/configuration.php +++ b/modules/monitoring/configuration.php @@ -47,8 +47,8 @@ $this->providePermission( $this->translate('Allow processing host and service check results') ); $this->providePermission( - 'monitoring/command/feature/program', - $this->translate('Allow processing commands for toggling features on a program-wide basis') + 'monitoring/command/feature/instance', + $this->translate('Allow processing commands for toggling features on an instance-wide basis') ); $this->providePermission( 'monitoring/command/feature/object', From 3716be4a48ba79a0c2c9dffcdf048819a7202bdf Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Fri, 30 Jan 2015 10:01:03 +0100 Subject: [PATCH 0441/2920] monitoring/security: Disable toggling instance features if user lacks the permission monitoring/command/feature/instance --- .../ToggleInstanceFeaturesCommandForm.php | 31 +++++++++++++------ 1 file changed, 21 insertions(+), 10 deletions(-) diff --git a/modules/monitoring/application/forms/Command/Instance/ToggleInstanceFeaturesCommandForm.php b/modules/monitoring/application/forms/Command/Instance/ToggleInstanceFeaturesCommandForm.php index 97a64dbd7..997bd378c 100644 --- a/modules/monitoring/application/forms/Command/Instance/ToggleInstanceFeaturesCommandForm.php +++ b/modules/monitoring/application/forms/Command/Instance/ToggleInstanceFeaturesCommandForm.php @@ -73,13 +73,15 @@ class ToggleInstanceFeaturesCommandForm extends CommandForm } else { $notificationDescription = null; } + $toggleDisabled = ! $this->hasPermission('monitoring/command/feature/instance'); $this->addElements(array( array( 'checkbox', ToggleInstanceFeatureCommand::FEATURE_ACTIVE_HOST_CHECKS, array( 'label' => $this->translate('Active Host Checks Being Executed'), - 'autosubmit' => true + 'autosubmit' => true, + 'disabled' => $toggleDisabled ) ), array( @@ -87,7 +89,8 @@ class ToggleInstanceFeaturesCommandForm extends CommandForm ToggleInstanceFeatureCommand::FEATURE_ACTIVE_SERVICE_CHECKS, array( 'label' => $this->translate('Active Service Checks Being Executed'), - 'autosubmit' => true + 'autosubmit' => true, + 'disabled' => $toggleDisabled ) ), array( @@ -95,7 +98,8 @@ class ToggleInstanceFeaturesCommandForm extends CommandForm ToggleInstanceFeatureCommand::FEATURE_EVENT_HANDLERS, array( 'label' => $this->translate('Event Handlers Enabled'), - 'autosubmit' => true + 'autosubmit' => true, + 'disabled' => $toggleDisabled ) ), array( @@ -103,7 +107,8 @@ class ToggleInstanceFeaturesCommandForm extends CommandForm ToggleInstanceFeatureCommand::FEATURE_FLAP_DETECTION, array( 'label' => $this->translate('Flap Detection Enabled'), - 'autosubmit' => true + 'autosubmit' => true, + 'disabled' => $toggleDisabled ) ), array( @@ -122,7 +127,8 @@ class ToggleInstanceFeaturesCommandForm extends CommandForm ), 'Label', array('HtmlTag', array('tag' => 'div')) - ) + ), + 'disabled' => $toggleDisabled ) ), array( @@ -130,7 +136,8 @@ class ToggleInstanceFeaturesCommandForm extends CommandForm ToggleInstanceFeatureCommand::FEATURE_HOST_OBSESSING, array( 'label' => $this->translate('Obsessing Over Hosts'), - 'autosubmit' => true + 'autosubmit' => true, + 'disabled' => $toggleDisabled ) ), array( @@ -138,7 +145,8 @@ class ToggleInstanceFeaturesCommandForm extends CommandForm ToggleInstanceFeatureCommand::FEATURE_SERVICE_OBSESSING, array( 'label' => $this->translate('Obsessing Over Services'), - 'autosubmit' => true + 'autosubmit' => true, + 'disabled' => $toggleDisabled ) ), array( @@ -146,7 +154,8 @@ class ToggleInstanceFeaturesCommandForm extends CommandForm ToggleInstanceFeatureCommand::FEATURE_PASSIVE_HOST_CHECKS, array( 'label' => $this->translate('Passive Host Checks Being Accepted'), - 'autosubmit' => true + 'autosubmit' => true, + 'disabled' => $toggleDisabled ) ), array( @@ -154,7 +163,8 @@ class ToggleInstanceFeaturesCommandForm extends CommandForm ToggleInstanceFeatureCommand::FEATURE_PASSIVE_SERVICE_CHECKS, array( 'label' => $this->translate('Passive Service Checks Being Accepted'), - 'autosubmit' => true + 'autosubmit' => true, + 'disabled' => $toggleDisabled ) ), array( @@ -162,7 +172,8 @@ class ToggleInstanceFeaturesCommandForm extends CommandForm ToggleInstanceFeatureCommand::FEATURE_PERFORMANCE_DATA, array( 'label' => $this->translate('Performance Data Being Processed'), - 'autosubmit' => true + 'autosubmit' => true, + 'disabled' => $toggleDisabled ) ) )); From 35b33647cf5bf72610289cbcfa93e4fb84144233 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Fri, 30 Jan 2015 10:26:43 +0100 Subject: [PATCH 0442/2920] monitoring/security: Guard the link for disabling notifications on an instance-wide basis The link in the monitoring health view will only be shown if the user has the permission monitoring/command/feature/instance. --- .../ToggleInstanceFeaturesCommandForm.php | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/modules/monitoring/application/forms/Command/Instance/ToggleInstanceFeaturesCommandForm.php b/modules/monitoring/application/forms/Command/Instance/ToggleInstanceFeaturesCommandForm.php index 997bd378c..d99db37c4 100644 --- a/modules/monitoring/application/forms/Command/Instance/ToggleInstanceFeaturesCommandForm.php +++ b/modules/monitoring/application/forms/Command/Instance/ToggleInstanceFeaturesCommandForm.php @@ -59,12 +59,16 @@ class ToggleInstanceFeaturesCommandForm extends CommandForm public function createElements(array $formData = array()) { if ((bool) $this->status->notifications_enabled) { - $notificationDescription = sprintf( - '%s', - $this->translate('Disable notifications for a specific time on a program-wide basis'), - $this->getView()->href('monitoring/process/disable-notifications'), - $this->translate('Disable temporarily') - ); + if ($this->hasPermission('monitoring/command/feature/instance')) { + $notificationDescription = sprintf( + '%s', + $this->translate('Disable notifications for a specific time on a program-wide basis'), + $this->getView()->href('monitoring/process/disable-notifications'), + $this->translate('Disable temporarily') + ); + } else { + $notificationDescription = null; + } } elseif ($this->status->disable_notif_expire_time) { $notificationDescription = sprintf( $this->translate('Notifications will be re-enabled in %s'), From bdc637ff67af3506fa57eb71761bf61bb54d5fe9 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Fri, 30 Jan 2015 10:31:49 +0100 Subject: [PATCH 0443/2920] monitoring/security: Guard toggling object features Toggling object features will only be possible if the user has the permission monitoring/command/feature/object. --- .../forms/Command/Object/ToggleObjectFeaturesCommandForm.php | 1 + 1 file changed, 1 insertion(+) diff --git a/modules/monitoring/application/forms/Command/Object/ToggleObjectFeaturesCommandForm.php b/modules/monitoring/application/forms/Command/Object/ToggleObjectFeaturesCommandForm.php index bf0a1d8b1..46858555f 100644 --- a/modules/monitoring/application/forms/Command/Object/ToggleObjectFeaturesCommandForm.php +++ b/modules/monitoring/application/forms/Command/Object/ToggleObjectFeaturesCommandForm.php @@ -107,6 +107,7 @@ class ToggleObjectFeaturesCommandForm extends ObjectsCommandForm */ public function onSuccess() { + $this->assertPermission('monitoring/command/feature/object'); foreach ($this->objects as $object) { /** @var \Icinga\Module\Monitoring\Object\MonitoredObject $object */ foreach ($this->getValues() as $feature => $enabled) { From 1681f746c1ef5df9c1c14584a790a2b22757f389 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Fri, 30 Jan 2015 10:46:24 +0100 Subject: [PATCH 0444/2920] monitoring/security: Disable toggling object features if user lacks the permission monitoring/command/feature/object --- .../ToggleObjectFeaturesCommandForm.php | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/modules/monitoring/application/forms/Command/Object/ToggleObjectFeaturesCommandForm.php b/modules/monitoring/application/forms/Command/Object/ToggleObjectFeaturesCommandForm.php index 46858555f..d3cc63ecf 100644 --- a/modules/monitoring/application/forms/Command/Object/ToggleObjectFeaturesCommandForm.php +++ b/modules/monitoring/application/forms/Command/Object/ToggleObjectFeaturesCommandForm.php @@ -28,13 +28,15 @@ class ToggleObjectFeaturesCommandForm extends ObjectsCommandForm */ public function createElements(array $formData = array()) { + $toggleDisabled = $this->hasPermission('monitoring/command/feature/instance') ? null : ''; $this->addElements(array( array( 'checkbox', ToggleObjectFeatureCommand::FEATURE_ACTIVE_CHECKS, array( 'label' => $this->translate('Active Checks'), - 'autosubmit' => true + 'autosubmit' => true, + 'disabled' => $toggleDisabled ) ), array( @@ -42,7 +44,8 @@ class ToggleObjectFeaturesCommandForm extends ObjectsCommandForm ToggleObjectFeatureCommand::FEATURE_PASSIVE_CHECKS, array( 'label' => $this->translate('Passive Checks'), - 'autosubmit' => true + 'autosubmit' => true, + 'disabled' => $toggleDisabled ) ), array( @@ -50,7 +53,8 @@ class ToggleObjectFeaturesCommandForm extends ObjectsCommandForm ToggleObjectFeatureCommand::FEATURE_OBSESSING, array( 'label' => $this->translate('Obsessing'), - 'autosubmit' => true + 'autosubmit' => true, + 'disabled' => $toggleDisabled ) ), array( @@ -58,7 +62,8 @@ class ToggleObjectFeaturesCommandForm extends ObjectsCommandForm ToggleObjectFeatureCommand::FEATURE_NOTIFICATIONS, array( 'label' => $this->translate('Notifications'), - 'autosubmit' => true + 'autosubmit' => true, + 'disabled' => $toggleDisabled ) ), array( @@ -66,7 +71,8 @@ class ToggleObjectFeaturesCommandForm extends ObjectsCommandForm ToggleObjectFeatureCommand::FEATURE_EVENT_HANDLER, array( 'label' => $this->translate('Event Handler'), - 'autosubmit' => true + 'autosubmit' => true, + 'disabled' => $toggleDisabled ) ), array( @@ -74,7 +80,8 @@ class ToggleObjectFeaturesCommandForm extends ObjectsCommandForm ToggleObjectFeatureCommand::FEATURE_FLAP_DETECTION, array( 'label' => $this->translate('Flap Detection'), - 'autosubmit' => true + 'autosubmit' => true, + 'disabled' => $toggleDisabled ) ) )); From 127ce7abfe402c5102d070be342c56cf6f647dd4 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Fri, 30 Jan 2015 10:47:02 +0100 Subject: [PATCH 0445/2920] monitoring/security: Fix that toggling instance features is always disabled In HTML5 the presence of a boolean attribute on an element represents the true value, and the absence of the attribute represents the false value. In Zend we have to set null for the absence of the attribute and the empty string for the presence of the attribute. --- .../Command/Instance/ToggleInstanceFeaturesCommandForm.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/monitoring/application/forms/Command/Instance/ToggleInstanceFeaturesCommandForm.php b/modules/monitoring/application/forms/Command/Instance/ToggleInstanceFeaturesCommandForm.php index d99db37c4..60486307e 100644 --- a/modules/monitoring/application/forms/Command/Instance/ToggleInstanceFeaturesCommandForm.php +++ b/modules/monitoring/application/forms/Command/Instance/ToggleInstanceFeaturesCommandForm.php @@ -77,7 +77,7 @@ class ToggleInstanceFeaturesCommandForm extends CommandForm } else { $notificationDescription = null; } - $toggleDisabled = ! $this->hasPermission('monitoring/command/feature/instance'); + $toggleDisabled = $this->hasPermission('monitoring/command/feature/instance') ? null : ''; $this->addElements(array( array( 'checkbox', From e5b0b528747c2ff76b0568f8ca6929e61b072495 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Fri, 30 Jan 2015 11:20:05 +0100 Subject: [PATCH 0446/2920] lib: Reduce else { if { to elseif { in User::can() --- library/Icinga/User.php | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/library/Icinga/User.php b/library/Icinga/User.php index db80c929a..bdc49275b 100644 --- a/library/Icinga/User.php +++ b/library/Icinga/User.php @@ -426,13 +426,11 @@ class User foreach ($this->permissions as $permitted) { $wildcard = strpos($permitted, '*'); if ($wildcard !== false) { - if (substr($permission, 0, $wildcard) === substr($permitted, 0, $wildcard)) { - return true; - } else { - if ($permission === $permitted) { - return true; - } - } + } + if (substr($permission, 0, $wildcard) === substr($permitted, 0, $wildcard)) { + return true; + } elseif ($permission === $permitted) { + return true; } } return false; From c8640cbae9eeec5f8e9269dfa691947ded14e09e Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Fri, 30 Jan 2015 12:44:34 +0100 Subject: [PATCH 0447/2920] rpm: Remove php5-imagick dependency for SUSE packages --- icingaweb2.spec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/icingaweb2.spec b/icingaweb2.spec index cd1ee485f..0d3766fdd 100644 --- a/icingaweb2.spec +++ b/icingaweb2.spec @@ -82,7 +82,7 @@ Requires: %{php} >= 5.3.0 Requires: %{php}-gd %{php}-intl %{?fedora:Requires: php-pecl-imagick} %{?rhel:Requires: php-pecl-imagick} -%{?suse_version:Requires: %{php}-gettext %{php}-openssl php5-imagick} +%{?suse_version:Requires: %{php}-gettext %{php}-openssl} %description -n php-Icinga Icinga Web 2 PHP library From 932496c58c2e4a437772e99f968275398740cefe Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Fri, 30 Jan 2015 12:51:06 +0100 Subject: [PATCH 0448/2920] rpm: Require json and posix PHP extensions for SUSE packages --- icingaweb2.spec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/icingaweb2.spec b/icingaweb2.spec index 0d3766fdd..312d6ee39 100644 --- a/icingaweb2.spec +++ b/icingaweb2.spec @@ -82,7 +82,7 @@ Requires: %{php} >= 5.3.0 Requires: %{php}-gd %{php}-intl %{?fedora:Requires: php-pecl-imagick} %{?rhel:Requires: php-pecl-imagick} -%{?suse_version:Requires: %{php}-gettext %{php}-openssl} +%{?suse_version:Requires: %{php}-gettext %{php}-json %{php}-openssl %{php}-posix} %description -n php-Icinga Icinga Web 2 PHP library From e8619686aef903c82a3eb2acc327b70b2df2a098 Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Fri, 30 Jan 2015 13:01:40 +0100 Subject: [PATCH 0449/2920] Add the sockets module as optional requirement of the monitoring module --- .../library/Monitoring/MonitoringWizard.php | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/modules/monitoring/library/Monitoring/MonitoringWizard.php b/modules/monitoring/library/Monitoring/MonitoringWizard.php index d7a3671a4..43061e608 100644 --- a/modules/monitoring/library/Monitoring/MonitoringWizard.php +++ b/modules/monitoring/library/Monitoring/MonitoringWizard.php @@ -5,6 +5,7 @@ namespace Icinga\Module\Monitoring; use Icinga\Application\Icinga; +use Icinga\Application\Platform; use Icinga\Web\Form; use Icinga\Web\Wizard; use Icinga\Web\Request; @@ -139,6 +140,22 @@ class MonitoringWizard extends Wizard implements SetupWizard */ public function getRequirements() { - return new Requirements(); + $requirements = new Requirements(); + + $requirements->addOptional( + 'existing_php_mod_sockets', + mt('monitoring', 'PHP Module: Sockets'), + mt( + 'monitoring', + 'In case it\'s desired that a TCP connection is being used by Icinga Web 2 to' + . ' access a Livestatus interface, the Sockets module for PHP is required.' + ), + Platform::extensionLoaded('sockets'), + Platform::extensionLoaded('sockets') ? mt('monitoring', 'The PHP Module sockets is available.') : ( + mt('monitoring', 'The PHP Module sockets is not available.') + ) + ); + + return $requirements; } } From 9dd179d8f387f7214a8c7b4b8b550acdbbd002c9 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Fri, 30 Jan 2015 13:18:29 +0100 Subject: [PATCH 0450/2920] rpm: Fix shadow-utils requirement on SUSE --- icingaweb2.spec | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/icingaweb2.spec b/icingaweb2.spec index 312d6ee39..ca1345dc2 100644 --- a/icingaweb2.spec +++ b/icingaweb2.spec @@ -29,7 +29,6 @@ Packager: Icinga Team %endif %endif - %if 0%{?suse_version} %define wwwconfigdir %{_sysconfdir}/apache2/conf.d %define wwwuser wwwrun @@ -43,15 +42,17 @@ Requires: apache2-mod_php5 %endif %endif -Requires(pre): shadow-utils -Requires: %{name}-common = %{version}-%{release} -Requires: php-Icinga = %{version}-%{release} -Requires: %{name}-vendor-dompdf -Requires: %{name}-vendor-HTMLPurifier -Requires: %{name}-vendor-JShrink -Requires: %{name}-vendor-lessphp -Requires: %{name}-vendor-Parsedown -Requires: %{zend} +%{?fedora:Requires(pre): shadow-utils} +%{?rhel:Requires(pre): shadow-utils} +%{?suse_version:Requires(pre): pwdutils} +Requires: %{name}-common = %{version}-%{release} +Requires: php-Icinga = %{version}-%{release} +Requires: %{name}-vendor-dompdf +Requires: %{name}-vendor-HTMLPurifier +Requires: %{name}-vendor-JShrink +Requires: %{name}-vendor-lessphp +Requires: %{name}-vendor-Parsedown +Requires: %{zend} %description @@ -68,8 +69,11 @@ Icinga Web 2 %package common -Summary: Common files for Icinga Web 2 and the Icinga CLI -Group: Applications/System +Summary: Common files for Icinga Web 2 and the Icinga CLI +Group: Applications/System +%{?fedora:Requires(pre): shadow-utils} +%{?rhel:Requires(pre): shadow-utils} +%{?suse_version:Requires(pre): pwdutils} %description common Common files for Icinga Web 2 and the Icinga CLI From 65a2c47506588c0e48827bf89f37b681da8d30d3 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Fri, 30 Jan 2015 13:29:47 +0100 Subject: [PATCH 0451/2920] security: Provide permissions for our config actions --- application/forms/Security/RoleForm.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/application/forms/Security/RoleForm.php b/application/forms/Security/RoleForm.php index f32c0cab4..18926972c 100644 --- a/application/forms/Security/RoleForm.php +++ b/application/forms/Security/RoleForm.php @@ -21,7 +21,14 @@ class RoleForm extends ConfigForm * * @type array */ - protected $providedPermissions = array('*' => '*'); + protected $providedPermissions = array( + '*' => '*', + 'system/config/*' => 'system/config/*', + 'system/config/application' => 'system/config/application', + 'system/config/authentication' => 'system/config/authentication', + 'system/config/resources' => 'system/config/resources', + 'system/config/roles' => 'system/config/roles' + ); /** * Provided restrictions by currently loaded modules From 72a616ede61c2bf3e25a32292593d55d0720ff42 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Fri, 30 Jan 2015 13:30:18 +0100 Subject: [PATCH 0452/2920] spec: Fix license of Icinga Web 2 Vendor packages not yet concerned. --- icingaweb2.spec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/icingaweb2.spec b/icingaweb2.spec index ca1345dc2..f747c3327 100644 --- a/icingaweb2.spec +++ b/icingaweb2.spec @@ -5,7 +5,7 @@ Version: 2.0.0 Release: %{revision}%{?dist} Summary: Icinga Web 2 Group: Applications/System -License: GPL +License: GPLv2+ URL: https://icinga.org Source0: https://github.com/Icinga/%{name}/archive/v%{version}.tar.gz BuildArch: noarch From d72e506202931488fb69740b47575272236549e0 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Fri, 30 Jan 2015 13:45:55 +0100 Subject: [PATCH 0453/2920] spec: Add lincese tag to vendor packages --- icingaweb2.spec | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/icingaweb2.spec b/icingaweb2.spec index f747c3327..94d280fb8 100644 --- a/icingaweb2.spec +++ b/icingaweb2.spec @@ -110,6 +110,7 @@ Version: 0.6.1 Release: 1%{?dist} Summary: Icinga Web 2 vendor library dompdf Group: Development/Libraries +License: LGPLv2.1 Requires: %{php} >= 5.3.0 %description vendor-dompdf @@ -121,6 +122,7 @@ Version: 4.6.0 Release: 1%{?dist} Summary: Icinga Web 2 vendor library HTMLPurifier Group: Development/Libraries +License: LGPLv2.1 Requires: %{php} >= 5.3.0 %description vendor-HTMLPurifier @@ -132,6 +134,7 @@ Version: 1.0.1 Release: 1%{?dist} Summary: Icinga Web 2 vendor library JShrink Group: Development/Libraries +License: BSD Requires: %{php} >= 5.3.0 %description vendor-JShrink @@ -143,6 +146,7 @@ Version: 0.4.0 Release: 1%{?dist} Summary: Icinga Web 2 vendor library lessphp Group: Development/Libraries +License: MIT Requires: %{php} >= 5.3.0 %description vendor-lessphp @@ -154,6 +158,7 @@ Version: 1.0.0 Release: 1%{?dist} Summary: Icinga Web 2 vendor library Parsedown Group: Development/Libraries +License: MIT Requires: %{php} >= 5.3.0 %description vendor-Parsedown @@ -165,6 +170,7 @@ Version: 1.12.9 Release: 1%{?dist} Summary: Icinga Web 2 vendor library Zend Framework Group: Development/Libraries +License: BSD Requires: %{php} >= 5.3.0 %description vendor-Zend From 17b6d8512b54c27bc9afd3b0614965a6772501cf Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Fri, 30 Jan 2015 13:46:49 +0100 Subject: [PATCH 0454/2920] spec: Add MIT and BSD to the license tag We ship jquery and some jquery plugins w/ Icinga Web 2. Their licenses must be noted too. --- icingaweb2.spec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/icingaweb2.spec b/icingaweb2.spec index 94d280fb8..a012751ea 100644 --- a/icingaweb2.spec +++ b/icingaweb2.spec @@ -5,7 +5,7 @@ Version: 2.0.0 Release: %{revision}%{?dist} Summary: Icinga Web 2 Group: Applications/System -License: GPLv2+ +License: GPLv2+ and MIT and BSD URL: https://icinga.org Source0: https://github.com/Icinga/%{name}/archive/v%{version}.tar.gz BuildArch: noarch From 6ec2ee753d2212b1a4c77505a06bfd3d6a846853 Mon Sep 17 00:00:00 2001 From: Marius Hein Date: Fri, 30 Jan 2015 14:50:25 +0100 Subject: [PATCH 0455/2920] Render error messages in the container itself fixes #6280 --- application/controllers/ErrorController.php | 1 + application/views/scripts/error/error.phtml | 5 +++-- public/js/icinga/loader.js | 16 +--------------- 3 files changed, 5 insertions(+), 17 deletions(-) diff --git a/application/controllers/ErrorController.php b/application/controllers/ErrorController.php index 0548b5c9c..e198eca1c 100644 --- a/application/controllers/ErrorController.php +++ b/application/controllers/ErrorController.php @@ -19,6 +19,7 @@ class ErrorController extends ActionController { $error = $this->_getParam('error_handler'); $exception = $error->exception; + $this->getTabs()->showOnlyCloseButton(); Logger::error($exception); Logger::error('Stacktrace: %s', $exception->getTraceAsString()); diff --git a/application/views/scripts/error/error.phtml b/application/views/scripts/error/error.phtml index 2a900651b..8e61e80f8 100644 --- a/application/views/scripts/error/error.phtml +++ b/application/views/scripts/error/error.phtml @@ -1,8 +1,9 @@ -title): ?>
    +tabs->render($this) ?> +title): ?>

    escape($title) ?>

    -
    +
    message): ?>

    escape($message)) ?>

    diff --git a/public/js/icinga/loader.js b/public/js/icinga/loader.js index 31a0d10a8..95ac5beeb 100644 --- a/public/js/icinga/loader.js +++ b/public/js/icinga/loader.js @@ -594,18 +594,7 @@ onFailure: function (req, textStatus, errorThrown) { var url = req.url; - if (req.status === 500) { - if (this.exception === null) { - req.$target.addClass('impact'); - - this.exception = this.createNotice( - 'error', - $('h1', $(req.responseText)).first().html(), - true - ); - this.icinga.ui.fixControls(); - } - } else if (req.status > 0) { + if (req.status > 0) { this.icinga.logger.error( req.status, errorThrown + ':', @@ -617,9 +606,6 @@ req.action, req.autorefresh ); - - // Header example: - // Icinga.debug(req.getResponseHeader('X-Icinga-Redirect')); } else { if (errorThrown === 'abort') { this.icinga.logger.debug( From 7b8332ccd89d102ea672a6d3eb4c48045969f97a Mon Sep 17 00:00:00 2001 From: Marius Hein Date: Fri, 30 Jan 2015 15:25:03 +0100 Subject: [PATCH 0456/2920] Notifications do not disappear after autorefresh This is not affected anymore because the errors goes directly into the container. But this commit fixes the codes if someone use the notifications in the loader. Also remove unused variable this.exception. fixes #6278 --- public/js/icinga/loader.js | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/public/js/icinga/loader.js b/public/js/icinga/loader.js index 95ac5beeb..7d590757b 100644 --- a/public/js/icinga/loader.js +++ b/public/js/icinga/loader.js @@ -24,8 +24,6 @@ this.failureNotice = null; - this.exception = null; - /** * Pending requests */ @@ -313,15 +311,12 @@ onResponse: function (data, textStatus, req) { var self = this; if (this.failureNotice !== null) { - this.failureNotice.remove(); + if (! this.failureNotice.hasClass('fading-out')) { + this.failureNotice.remove(); + } this.failureNotice = null; } - if (this.exception !== null) { - this.exception.remove(); - this.exception = null; - } - // Remove 'impact' class if there was such if (req.$target.hasClass('impact')) { req.$target.removeClass('impact'); @@ -646,7 +641,13 @@ var $notice = $( '
  • ' + message + '
  • ' ).appendTo($('#notifications')); + this.icinga.ui.fixControls(); + + if (!persist) { + this.icinga.ui.fadeNotificationsAway(); + } + return $notice; }, From fdcec046e057f0eb4a765459caa71ebd2e3affce Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Fri, 30 Jan 2015 15:42:22 +0100 Subject: [PATCH 0457/2920] Make File::create(.., $recursive = true) create missing nested directories refs #8219 --- library/Icinga/Util/File.php | 72 +++++++++++++++++++++++++++++++++--- 1 file changed, 66 insertions(+), 6 deletions(-) diff --git a/library/Icinga/Util/File.php b/library/Icinga/Util/File.php index 9ce1ec893..99421b33d 100644 --- a/library/Icinga/Util/File.php +++ b/library/Icinga/Util/File.php @@ -23,6 +23,13 @@ class File extends SplFileObject */ protected $openMode; + /** + * The access mode to use when creating directories + * + * @var int + */ + public static $dirMode = 1528; // 2770 + /** * @see SplFileObject::__construct() */ @@ -37,21 +44,74 @@ class File extends SplFileObject } /** - * Create a file with an access mode + * Create a file using the given access mode and return a instance of File open for writing * * @param string $path The path to the file * @param int $accessMode The access mode to set + * @param bool $recursive Whether missing nested directories of the given path should be created + * + * @return File * * @throws RuntimeException In case the file cannot be created or the access mode cannot be set + * @throws NotWritableError In case the path's (existing) parent is not writable */ - public static function create($path, $accessMode) + public static function create($path, $accessMode, $recursive = true) { - if (!@touch($path)) { - throw new RuntimeException('Cannot create file "' . $path . '" with acces mode "' . $accessMode . '"'); + $dirPath = dirname($path); + if ($recursive && !is_dir($dirPath)) { + static::createDirectories($dirPath); + } elseif (! is_writable($dirPath)) { + throw new NotWritableError(sprintf('Path "%s" is not writable', $dirPath)); } - if (!@chmod($path, $accessMode)) { - throw new RuntimeException('Cannot set access mode "' . $accessMode . '" on file "' . $path . '"'); + $file = new static($path, 'x'); + + if (! @chmod($path, $accessMode)) { + $error = error_get_last(); + throw new RuntimeException(sprintf( + 'Cannot set access mode "%s" on file "%s" (%s)', + decoct($accessMode), + $path, + $error['message'] + )); + } + + return $file; + } + + /** + * Create missing directories + * + * @param string $path + * + * @throws RuntimeException In case a directory cannot be created or the access mode cannot be set + */ + protected static function createDirectories($path) + { + $part = strpos($path, DIRECTORY_SEPARATOR) === 0 ? DIRECTORY_SEPARATOR : ''; + foreach (explode(DIRECTORY_SEPARATOR, ltrim($path, DIRECTORY_SEPARATOR)) as $dir) { + $part .= $dir . DIRECTORY_SEPARATOR; + + if (! is_dir($part)) { + if (! @mkdir($part, static::$dirMode)) { + $error = error_get_last(); + throw new RuntimeException(sprintf( + 'Failed to create missing directory "%s" (%s)', + $part, + $error['message'] + )); + } + + if (! @chmod($part, static::$dirMode)) { + $error = error_get_last(); + throw new RuntimeException(sprintf( + 'Failed to set access mode "%s" for directory "%s" (%s)', + decoct(static::$dirMode), + $part, + $error['message'] + )); + } + } } } From 9426a5bd234ef75eb468cdb98d2468029dd0a57b Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Fri, 30 Jan 2015 15:43:02 +0100 Subject: [PATCH 0458/2920] Use File::create() in Config::saveIni() to create missing nested directories refs #8219 --- library/Icinga/Application/Config.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/library/Icinga/Application/Config.php b/library/Icinga/Application/Config.php index 8d4914316..484cff6df 100644 --- a/library/Icinga/Application/Config.php +++ b/library/Icinga/Application/Config.php @@ -8,6 +8,7 @@ use Iterator; use Countable; use LogicException; use UnexpectedValueException; +use Icinga\Util\File; use Icinga\Data\ConfigObject; use Icinga\File\Ini\IniWriter; use Icinga\Exception\NotReadableError; @@ -320,6 +321,10 @@ class Config implements Countable, Iterator throw new LogicException('You need to pass $filePath or set a path using Config::setConfigFile()'); } + if (! file_exists($filePath)) { + File::create($filePath, $fileMode); + } + $this->getIniWriter($filePath, $fileMode)->write(); } From 6416fc421c8c4d89edf92d4db5734b9a6131e4ab Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Fri, 30 Jan 2015 15:43:39 +0100 Subject: [PATCH 0459/2920] Do not create directories which are created automatically if necessary refs #8219 --- .../library/Monitoring/MonitoringWizard.php | 4 ---- modules/setup/library/Setup/WebWizard.php | 12 +----------- 2 files changed, 1 insertion(+), 15 deletions(-) diff --git a/modules/monitoring/library/Monitoring/MonitoringWizard.php b/modules/monitoring/library/Monitoring/MonitoringWizard.php index d7a3671a4..f02faa4f3 100644 --- a/modules/monitoring/library/Monitoring/MonitoringWizard.php +++ b/modules/monitoring/library/Monitoring/MonitoringWizard.php @@ -4,14 +4,12 @@ namespace Icinga\Module\Monitoring; -use Icinga\Application\Icinga; use Icinga\Web\Form; use Icinga\Web\Wizard; use Icinga\Web\Request; use Icinga\Module\Setup\Setup; use Icinga\Module\Setup\SetupWizard; use Icinga\Module\Setup\Requirements; -use Icinga\Module\Setup\Utils\MakeDirStep; use Icinga\Module\Setup\Forms\SummaryPage; use Icinga\Module\Monitoring\Forms\Setup\WelcomePage; use Icinga\Module\Monitoring\Forms\Setup\BackendPage; @@ -108,8 +106,6 @@ class MonitoringWizard extends Wizard implements SetupWizard $pageData = $this->getPageData(); $setup = new Setup(); - $setup->addStep(new MakeDirStep(array(Icinga::app()->getConfigDir() . '/modules/monitoring'), 2770)); - $setup->addStep( new BackendStep(array( 'backendConfig' => $pageData['setup_monitoring_backend'], diff --git a/modules/setup/library/Setup/WebWizard.php b/modules/setup/library/Setup/WebWizard.php index 8ae7344ea..c073723a3 100644 --- a/modules/setup/library/Setup/WebWizard.php +++ b/modules/setup/library/Setup/WebWizard.php @@ -334,17 +334,7 @@ class WebWizard extends Wizard implements SetupWizard ); } - $configDir = Icinga::app()->getConfigDir(); - $setup->addStep( - new MakeDirStep( - array( - $configDir . DIRECTORY_SEPARATOR . 'modules', - $configDir . DIRECTORY_SEPARATOR . 'preferences', - $configDir . DIRECTORY_SEPARATOR . 'enabledModules' - ), - 2770 - ) - ); + $setup->addStep(new MakeDirStep(array(Config::resolvePath('enabledModules')), 2770)); foreach ($this->getWizards() as $wizard) { if ($wizard->isComplete()) { From d2dd66c9fd25b63287ae94363415f73007a3c64b Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Fri, 30 Jan 2015 15:47:11 +0100 Subject: [PATCH 0460/2920] Revert "setup: Fix octdec for directory modes" This reverts commit c0444a81b24aea332b07eb1409af168c1c53f0c9. --- modules/setup/library/Setup/Utils/MakeDirStep.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/setup/library/Setup/Utils/MakeDirStep.php b/modules/setup/library/Setup/Utils/MakeDirStep.php index d7813541b..27919820b 100644 --- a/modules/setup/library/Setup/Utils/MakeDirStep.php +++ b/modules/setup/library/Setup/Utils/MakeDirStep.php @@ -21,7 +21,7 @@ class MakeDirStep extends Step public function __construct($paths, $dirmode) { $this->paths = $paths; - $this->dirmode = octdec((string) $dirmode); + $this->dirmode = octdec($dirmode); $this->errors = array(); } From a95fd561cd09c91f094bfd65f58560945863c92b Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Fri, 30 Jan 2015 15:47:21 +0100 Subject: [PATCH 0461/2920] Revert "setup: Convert octal directory mode to decimal notation" This reverts commit e93e8f633045d7fd0f844e797848d4d6fe32ca9e. --- modules/setup/library/Setup/Utils/MakeDirStep.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/setup/library/Setup/Utils/MakeDirStep.php b/modules/setup/library/Setup/Utils/MakeDirStep.php index 27919820b..b758ccd79 100644 --- a/modules/setup/library/Setup/Utils/MakeDirStep.php +++ b/modules/setup/library/Setup/Utils/MakeDirStep.php @@ -16,12 +16,12 @@ class MakeDirStep extends Step /** * @param array $paths - * @param int $dirmode Directory mode in octal notation + * @param int $dirmode */ public function __construct($paths, $dirmode) { $this->paths = $paths; - $this->dirmode = octdec($dirmode); + $this->dirmode = $dirmode; $this->errors = array(); } From f5a651664c2a2085c761aa8fbbff927c11fb310f Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Fri, 30 Jan 2015 16:16:12 +0100 Subject: [PATCH 0462/2920] Create the enabledModules directory when necessary only as well refs #8219 --- .../Icinga/Application/Modules/Manager.php | 46 +++++++++---------- modules/setup/library/Setup/WebWizard.php | 2 - 2 files changed, 23 insertions(+), 25 deletions(-) diff --git a/library/Icinga/Application/Modules/Manager.php b/library/Icinga/Application/Modules/Manager.php index 7ee2461f9..0a1b23f78 100644 --- a/library/Icinga/Application/Modules/Manager.php +++ b/library/Icinga/Application/Modules/Manager.php @@ -103,25 +103,22 @@ class Manager */ private function detectEnabledModules() { - $canonical = $this->enableDir; - if ($canonical === false || ! file_exists($canonical)) { - // TODO: I guess the check for false has something to do with a - // call to realpath no longer present + if (! file_exists($this->enableDir)) { return; } - if (!is_dir($this->enableDir)) { + if (! is_dir($this->enableDir)) { throw new NotReadableError( 'Cannot read enabled modules. Module directory "%s" is not a directory', $this->enableDir ); } - if (!is_readable($this->enableDir)) { + if (! is_readable($this->enableDir)) { throw new NotReadableError( 'Cannot read enabled modules. Module directory "%s" is not readable', $this->enableDir ); } - if (($dh = opendir($canonical)) !== false) { + if (($dh = opendir($this->enableDir)) !== false) { $this->enabledDirs = array(); while (($file = readdir($dh)) !== false) { @@ -129,7 +126,7 @@ class Manager continue; } - $link = $this->enableDir . '/' . $file; + $link = $this->enableDir . DIRECTORY_SEPARATOR . $file; if (! is_link($link)) { Logger::warning( 'Found invalid module in enabledModule directory "%s": "%s" is not a symlink', @@ -140,7 +137,7 @@ class Manager } $dir = realpath($link); - if (!file_exists($dir) || !is_dir($dir)) { + if (! file_exists($dir) || !is_dir($dir)) { Logger::warning( 'Found invalid module in enabledModule directory "%s": "%s" points to non existing path "%s"', $this->enableDir, @@ -208,7 +205,7 @@ class Manager */ public function enableModule($name) { - if (!$this->hasInstalled($name)) { + if (! $this->hasInstalled($name)) { throw new ConfigurationError( 'Cannot enable module "%s". Module is not installed.', $name @@ -217,11 +214,16 @@ class Manager clearstatcache(true); $target = $this->installedBaseDirs[$name]; - $link = $this->enableDir . '/' . $name; + $link = $this->enableDir . DIRECTORY_SEPARATOR . $name; - if (! is_dir($this->enableDir)) { - throw new NotFoundError('Cannot enable module "%s". Path "%s" not found.', $name, $this->enableDir); - } elseif (!is_writable($this->enableDir)) { + if (! is_dir($this->enableDir) && !@mkdir($this->enableDir, 02770, true)) { + $error = error_get_last(); + throw new SystemPermissionException( + 'Failed to create enabledModule directory "%s" (%s)', + $this->enableDir, + $error['message'] + ); + } elseif (! is_writable($this->enableDir)) { throw new SystemPermissionException( 'Cannot enable module "%s". Insufficient system permissions for enabling modules.', $name @@ -232,7 +234,7 @@ class Manager return $this; } - if (!@symlink($target, $link)) { + if (! @symlink($target, $link)) { $error = error_get_last(); if (strstr($error["message"], "File exists") === false) { throw new SystemPermissionException( @@ -246,9 +248,7 @@ class Manager } $this->enabledDirs[$name] = $link; - $this->loadModule($name); - return $this; } @@ -264,22 +264,22 @@ class Manager */ public function disableModule($name) { - if (!$this->hasEnabled($name)) { + if (! $this->hasEnabled($name)) { return $this; } - if (!is_writable($this->enableDir)) { + if (! is_writable($this->enableDir)) { throw new SystemPermissionException( 'Could not disable module. Module path is not writable.' ); } - $link = $this->enableDir . '/' . $name; - if (!file_exists($link)) { + $link = $this->enableDir . DIRECTORY_SEPARATOR . $name; + if (! file_exists($link)) { throw new ConfigurationError( 'Could not disable module. The module %s was not found.', $name ); } - if (!is_link($link)) { + if (! is_link($link)) { throw new ConfigurationError( 'Could not disable module. The module "%s" is not a symlink. ' . 'It looks like you have installed this module manually and moved it to your module folder. ' @@ -290,7 +290,7 @@ class Manager } if (file_exists($link) && is_link($link)) { - if (!@unlink($link)) { + if (! @unlink($link)) { $error = error_get_last(); throw new SystemPermissionException( 'Could not disable module "%s" due to file system errors. ' diff --git a/modules/setup/library/Setup/WebWizard.php b/modules/setup/library/Setup/WebWizard.php index c073723a3..b580101ed 100644 --- a/modules/setup/library/Setup/WebWizard.php +++ b/modules/setup/library/Setup/WebWizard.php @@ -334,8 +334,6 @@ class WebWizard extends Wizard implements SetupWizard ); } - $setup->addStep(new MakeDirStep(array(Config::resolvePath('enabledModules')), 2770)); - foreach ($this->getWizards() as $wizard) { if ($wizard->isComplete()) { $setup->addSteps($wizard->getSetup()->getSteps()); From ad4ebf8fa5b40d224b8d681440554b1357ee6237 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Sun, 1 Feb 2015 23:30:48 +0100 Subject: [PATCH 0463/2920] monitoring: Fix that selecting a hostgroup displays its services instead of its hosts fixes #8273 --- .../application/views/scripts/list/hostgroups.phtml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/monitoring/application/views/scripts/list/hostgroups.phtml b/modules/monitoring/application/views/scripts/list/hostgroups.phtml index cd3e68d7f..7d67c9d3a 100644 --- a/modules/monitoring/application/views/scripts/list/hostgroups.phtml +++ b/modules/monitoring/application/views/scripts/list/hostgroups.phtml @@ -28,7 +28,7 @@
    - + services_critical_last_state_change_unhandled): ?> From 4fc8850e25dbf77d9ad4e7e4a47163eb2da440f3 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Mon, 2 Feb 2015 16:48:13 +0100 Subject: [PATCH 0499/2920] Use transplatePlural for hosts in downtime and hosts having comments tooltips refs #8110 --- .../views/scripts/hosts/show.phtml | 30 ++++++++++++------- 1 file changed, 19 insertions(+), 11 deletions(-) diff --git a/modules/monitoring/application/views/scripts/hosts/show.phtml b/modules/monitoring/application/views/scripts/hosts/show.phtml index f21c09fd1..a5d36deb1 100644 --- a/modules/monitoring/application/views/scripts/hosts/show.phtml +++ b/modules/monitoring/application/views/scripts/hosts/show.phtml @@ -30,9 +30,9 @@
    - " title="translate('List all %u hosts'), + $hostCount ); ?>"> translate('List all') ?> @@ -112,10 +112,14 @@

    + title="translatePlural( + 'List %u host which is in downtime', + 'List %u hosts which are in downtime', + $inDowntimeCount + ), + $inDowntimeCount + ) ?>"> icon('plug') ?> translatePlural( @@ -133,10 +137,14 @@

    + title="translatePlural( + 'List %u host having comments', + 'List %u hosts having comments', + $havingCommentsLink + ), + $havingCommentsLink + ) ?>"> icon('comment') ?> translatePlural( From 8bb0e4e0a0ba9d3924a16f3f569ee38cbda0291c Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Mon, 2 Feb 2015 16:34:29 +0100 Subject: [PATCH 0500/2920] Failure requests: Fix auto refresh and history II Allow to change url's in history and stop auto auto refresh if the container URL is not up to date. Use variable after ajax call and the check is more robust. --- public/js/icinga/loader.js | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/public/js/icinga/loader.js b/public/js/icinga/loader.js index 6a85a5144..417c47c1c 100644 --- a/public/js/icinga/loader.js +++ b/public/js/icinga/loader.js @@ -118,6 +118,8 @@ req.historyTriggered = false; req.autorefresh = autorefresh; req.action = action; + req.failure = false; + if (id) { this.requests[id] = req; } @@ -555,7 +557,7 @@ // Update history when necessary. Don't do so for requests triggered // by history or autorefresh events if (! req.historyTriggered && ! req.autorefresh) { - if (req.$target.hasClass('container')) { + if (req.$target.hasClass('container') && ! req.failure) { // We only want to care about top-level containers if (req.$target.parent().closest('.container').length === 0) { this.icinga.history.pushCurrentState(); @@ -591,6 +593,17 @@ onFailure: function (req, textStatus, errorThrown) { var url = req.url; + req.failure = true; + + /* + * Test if a manual actions comes in and autorefresh is active: Stop refreshing + */ + if (! req.historyTriggered && ! req.autorefresh && req.$target.data('icingaRefresh') > 0 + && req.$target.data('icingaUrl') !== url) { + req.$target.data('icingaRefresh', 0); + req.$target.data('icingaUrl', url); + } + if (req.status > 0) { this.icinga.logger.error( req.status, From c4c6d36b00e2eb6ae76a8f5cd24210aa273ffd81 Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Mon, 2 Feb 2015 16:55:21 +0100 Subject: [PATCH 0501/2920] setup: Clarify that the db user's credentials may be insufficient as well --- modules/setup/application/forms/DatabaseCreationPage.php | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/modules/setup/application/forms/DatabaseCreationPage.php b/modules/setup/application/forms/DatabaseCreationPage.php index be2974a52..3b9ae649b 100644 --- a/modules/setup/application/forms/DatabaseCreationPage.php +++ b/modules/setup/application/forms/DatabaseCreationPage.php @@ -103,8 +103,9 @@ class DatabaseCreationPage extends Form array( 'value' => $this->translate( 'It seems that either the database you defined earlier does not yet exist and cannot be created' - . ' using the provided access credentials or the database does not have the required schema to ' - . 'be operated by Icinga Web 2. Please provide appropriate access credentials to solve this.' + . ' using the provided access credentials, the database does not have the required schema to be' + . ' operated by Icinga Web 2 or the provided access credentials do not have the sufficient ' + . 'permissions to access the database. Please provide appropriate access credentials to solve this.' ) ) ); @@ -116,7 +117,9 @@ class DatabaseCreationPage extends Form array( 'required' => false === $skipValidation, 'label' => $this->translate('Username'), - 'description' => $this->translate('A user which is able to create databases and/or touch the database schema') + 'description' => $this->translate( + 'A user which is able to create databases and/or touch the database schema' + ) ) ); $this->addElement( From 2722463372a462676546336989611a4a7f0409a9 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Mon, 2 Feb 2015 17:06:32 +0100 Subject: [PATCH 0502/2920] Prefix tooltips in the host groups overview with "List ..." refs #8110 --- .../views/scripts/list/hostgroups.phtml | 34 +++++++++---------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/modules/monitoring/application/views/scripts/list/hostgroups.phtml b/modules/monitoring/application/views/scripts/list/hostgroups.phtml index 69b30f717..0c5989bff 100644 --- a/modules/monitoring/application/views/scripts/list/hostgroups.phtml +++ b/modules/monitoring/application/views/scripts/list/hostgroups.phtml @@ -96,10 +96,10 @@ 'hostgroup' => $h->hostgroup, 'sort' => 'service_severity' ) - ); ?>" title="" title="translatePlural( - '%s Service OK in hostgroup `%s\'', - '%s Services OK in hostgroup `%s\'', + 'List %u service with status ok in host group %s', + 'List %u services with status ok in host group %s', $h->services_ok ), $h->services_ok, @@ -123,8 +123,8 @@ ) ); ?>" title="translatePlural( - '%s Service CRITICAL Unhandled in hostgroup `%s\'', - '%s Services CRITICAL Unhandled in hostgroup `%s\'', + 'List %u service with status critical unhandled in host group %s', + 'List %u services with status critical unhandled in host group %s', $h->services_critical_unhandled ), $h->services_critical_unhandled, @@ -145,8 +145,8 @@ ) ); ?>" title="translatePlural( - '%s Service CRITICAL Handled in hostgroup `%s\'', - '%s Services CRITICAL Handled in hostgroup `%s\'', + 'List %u service with status critical handled in host group %s', + 'List %u services with status critical handled in host group %s', $h->services_critical_handled ), $h->services_critical_handled, @@ -173,8 +173,8 @@ ) ); ?>" title="translatePlural( - '%s Service UNKNOWN Unhandled in hostgroup `%s\'', - '%s Services UNKNOWN Unhandled in hostgroup `%s\'', + 'List %u service with status unknown unhandled in host group %s', + 'List %u services with status unknown unhandled in host group %s', $h->services_unknown_unhandled ), $h->services_unknown_unhandled, @@ -195,8 +195,8 @@ ) ); ?>" title="translatePlural( - '%s Service UNKNOWN Handled in hostgroup `%s\'', - '%s Services UNKNOWN Handled in hostgroup `%s\'', + 'List %u service with status unknown handled in host group %s', + 'List %u services with status unknown handled in host group %s', $h->services_unknown_handled ), $h->services_unknown_handled, @@ -223,8 +223,8 @@ ) ); ?>" title="translatePlural( - '%s Service WARNING Unhandled in hostgroup `%s\'', - '%s Services WARNING Unhandled in hostgroup `%s\'', + 'List %u service with status warning unhandled in host group %s', + 'List %u services with status warning unhandled in host group %s', $h->services_warning_unhandled ), $h->services_warning_unhandled, @@ -245,8 +245,8 @@ ) ); ?>" title="translatePlural( - '%s Service WARNING Handled in hostgroup `%s\'', - '%s Services WARNING Handled in hostgroup `%s\'', + 'List %u service with status warning handled in host group %s', + 'List %u services with status warning handled in host group %s', $h->services_warning_handled ), $h->services_warning_handled, @@ -270,8 +270,8 @@ ) ); ?>" title="translatePlural( - '%s Service PENDING in hostgroup `%s\'', - '%s Services PENDING in hostgroup `%s\'', + 'List %u service with status pending in host group %s', + 'List %u services with status pending in host group %s', $h->services_pending ), $h->services_pending, From 3596e7ce62155eed4648143263ca199e879917e9 Mon Sep 17 00:00:00 2001 From: Thomas Gelf Date: Mon, 2 Feb 2015 17:07:54 +0100 Subject: [PATCH 0503/2920] FilterEditor: use preserved params fixes #7904 --- library/Icinga/Web/Widget/FilterEditor.php | 29 ++++++++++++++++------ 1 file changed, 21 insertions(+), 8 deletions(-) diff --git a/library/Icinga/Web/Widget/FilterEditor.php b/library/Icinga/Web/Widget/FilterEditor.php index 9ff8622b5..e694a32f2 100644 --- a/library/Icinga/Web/Widget/FilterEditor.php +++ b/library/Icinga/Web/Widget/FilterEditor.php @@ -34,6 +34,10 @@ class FilterEditor extends AbstractWidget protected $preserveParams = array(); + protected $preservedParams = array(); + + protected $preservedUrl; + protected $ignoreParams = array(); /** @@ -84,6 +88,14 @@ class FilterEditor extends AbstractWidget return $this->url; } + protected function preservedUrl() + { + if ($this->preservedUrl === null) { + $this->preservedUrl = $this->url()->with($this->preservedParams); + } + return $this->preservedUrl; + } + public function setQuery($query) { $this->query = $query; @@ -147,6 +159,7 @@ class FilterEditor extends AbstractWidget $preserve[$key] = $value; } } + $this->preservedParams = $preserve; $add = $params->shift('addFilter'); $remove = $params->shift('removeFilter'); @@ -232,7 +245,7 @@ class FilterEditor extends AbstractWidget if ($modify) { if ($request->isPost()) { if ($request->get('cancel') === 'Cancel') { - $this->redirectNow($this->url()->without('modifyFilter')); + $this->redirectNow($this->preservedUrl()->without('modifyFilter')); } $filter = $this->applyChanges($request->getPost()); @@ -295,7 +308,7 @@ class FilterEditor extends AbstractWidget { return $this->view()->qlink( '', - $this->url()->with('removeFilter', $filter->getId()), + $this->preservedUrl()->with('removeFilter', $filter->getId()), null, array( 'title' => t('Click to remove this part of your filter'), @@ -308,7 +321,7 @@ class FilterEditor extends AbstractWidget { return $this->view()->qlink( '', - $this->url()->with('addFilter', $filter->getId()), + $this->preservedUrl()->with('addFilter', $filter->getId()), null, array( 'title' => t('Click to add another filter'), @@ -321,7 +334,7 @@ class FilterEditor extends AbstractWidget { return $this->view()->qlink( '', - $this->url()->with('stripFilter', $filter->getId()), + $this->preservedUrl()->with('stripFilter', $filter->getId()), null, array( 'title' => t('Strip this filter'), @@ -334,7 +347,7 @@ class FilterEditor extends AbstractWidget { return $this->view()->qlink( '', - $this->url()->without('addFilter'), + $this->preservedUrl()->without('addFilter'), null, array( 'title' => t('Cancel this operation'), @@ -638,7 +651,7 @@ class FilterEditor extends AbstractWidget public function renderSearch() { $html = '
    '; @@ -653,7 +666,7 @@ class FilterEditor extends AbstractWidget } return $html . '
    ' @@ -663,7 +676,7 @@ class FilterEditor extends AbstractWidget public function render() { - if (! $this->url()->getParam('modifyFilter')) { + if (! $this->preservedUrl()->getParam('modifyFilter')) { return $this->renderSearch() . $this->shorten($this->filter, 50); } return $this->renderSearch() From a8de3c093afb58b49a6ddf07672245369bd24046 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Mon, 2 Feb 2015 17:27:59 +0100 Subject: [PATCH 0504/2920] monitoring/host: Add tooltip for the unhandled services link to the link refs #8110 --- .../views/scripts/list/hosts.phtml | 36 +++++++++++-------- 1 file changed, 22 insertions(+), 14 deletions(-) diff --git a/modules/monitoring/application/views/scripts/list/hosts.phtml b/modules/monitoring/application/views/scripts/list/hosts.phtml index 55242101c..07410ddc7 100644 --- a/modules/monitoring/application/views/scripts/list/hosts.phtml +++ b/modules/monitoring/application/views/scripts/list/hosts.phtml @@ -98,21 +98,29 @@ if ($hosts->count() === 0) { escape($host->host_display_name) ?> host_unhandled_services) && $host->host_unhandled_services > 0): ?> - host_unhandled_services), - $host->host_unhandled_services, - $host->host_name - ); ?>"> (qlink( - sprintf( - $this->translatePlural('%d unhandled service', '%d unhandled services', $host->host_unhandled_services), - $host->host_unhandled_services), - 'monitoring/show/services', - array( - 'host' => $host->host_name, - 'service_problem' => 1, - 'service_handled' => 0 + (qlink( + sprintf( + $this->translatePlural('%d unhandled service', '%d unhandled services', $host->host_unhandled_services), + $host->host_unhandled_services + ), + 'monitoring/show/services', + array( + 'host' => $host->host_name, + 'service_problem' => 1, + 'service_handled' => 0 ), - array('style' => 'font-weight: normal') + array( + 'style' => 'font-weight: normal', + 'title' => sprintf( + $this->translatePlural( + 'List %s service problem on host %s', + 'List %s service problems on host %s', + $host->host_unhandled_services + ), + $host->host_unhandled_services, + $host->host_name + ) + ) ) ?>)

    escape($this->ellipsis($host->host_output, 10000)) ?>

    From 61fde8b35961f9c064fecde8e644e87c9efb8c64 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Mon, 2 Feb 2015 17:29:30 +0100 Subject: [PATCH 0505/2920] monitoring: Prefix tooltips in the service groups overview with "List ..." refs #8110 --- .../views/scripts/list/servicegroups.phtml | 32 +++++++++---------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/modules/monitoring/application/views/scripts/list/servicegroups.phtml b/modules/monitoring/application/views/scripts/list/servicegroups.phtml index 71195ba61..04e6975e1 100644 --- a/modules/monitoring/application/views/scripts/list/servicegroups.phtml +++ b/modules/monitoring/application/views/scripts/list/servicegroups.phtml @@ -98,8 +98,8 @@ ) ); ?>" title="translatePlural( - '%s Service OK in servicegroup `%s\'', - '%s Services OK in servicegroup `%s\'', + 'List %s service with status ok in service group %s', + 'List %s Services with status ok in service group %s', $s->services_ok ), $s->services_ok, @@ -123,8 +123,8 @@ ) ); ?>" title="translatePlural( - '%s Service CRITICAL Unhandled in servicegroup `%s\'', - '%s Services CRITICAL Unhandled in servicegroup `%s\'', + 'List %s service with status critical unhandled in service group %s', + 'List %s Services with status critical unhandled in service group %s', $s->services_critical_unhandled ), $s->services_critical_unhandled, @@ -145,8 +145,8 @@ ) ); ?>" title="translatePlural( - '%s Service CRITICAL Handled in servicegroup `%s\'', - '%s Services CRITICAL Handled in servicegroup `%s\'', + 'List %s service with status critical handled in service group %s', + 'List %s services with status critical handled in service group %s', $s->services_critical_handled ), $s->services_critical_handled, @@ -173,8 +173,8 @@ ) ); ?>" title="translatePlural( - '%s Service UNKNOWN Unhandled in servicegroup `%s\'', - '%s Services UNKNOWN Unhandled in servicegroup `%s\'', + 'List %s service with status unknown unhandled in service group %s', + 'List %s services with status unknown unhandled in service group %s', $s->services_unknown_unhandled ), $s->services_unknown_unhandled, @@ -195,8 +195,8 @@ ) ); ?>" title="translatePlural( - '%s Service UNKNOWN Handled in servicegroup `%s\'', - '%s Services UNKNOWN Handled in servicegroup `%s\'', + 'List %s service with status unknown handled in service group %s', + 'List %s services with status unknown handled in service group %s', $s->services_unknown_handled ), $s->services_unknown_handled, @@ -223,8 +223,8 @@ ) ); ?>" title="translatePlural( - '%s Service WARNING Unhandled in servicegroup `%s\'', - '%s Services WARNING Unhandled in servicegroup `%s\'', + 'List %s service with status warning unhandled in service group %s', + 'List %s services with status warning unhandled in service group %s', $s->services_warning_unhandled ), $s->services_warning_unhandled, @@ -245,8 +245,8 @@ ) ); ?>" title="translatePlural( - '%s Service WARNING Handled in servicegroup `%s\'', - '%s Services WARNING Handled in servicegroup `%s\'', + 'List %s service with status warning handled in service group %s', + 'List %s services with status warning handled in service group %s', $s->services_warning_handled ), $s->services_warning_handled, @@ -270,8 +270,8 @@ ) ); ?>" title="translatePlural( - '%s Service PENDING in servicegroup `%s\'', - '%s Services PENDING in servicegroup `%s\'', + 'List %s service with status pending in service group %s', + 'List %s services with status pending in service group %s', $s->services_pending ), $s->services_pending, From f8c5bf68193136d4d49dc275ec94b0f1bca601e0 Mon Sep 17 00:00:00 2001 From: Thomas Gelf Date: Wed, 14 Jan 2015 10:58:36 +0100 Subject: [PATCH 0506/2920] Web\Hook: support hook base classes in modules refs #8207 --- library/Icinga/Web/Hook.php | 32 +++++++++++++++++++++++++++++--- 1 file changed, 29 insertions(+), 3 deletions(-) diff --git a/library/Icinga/Web/Hook.php b/library/Icinga/Web/Hook.php index 01d1e0e2c..7ace738d7 100644 --- a/library/Icinga/Web/Hook.php +++ b/library/Icinga/Web/Hook.php @@ -113,6 +113,18 @@ class Hook return $instance; } + protected static function splitHookName($name) + { + $sep = '\\'; + if (false === $module = strpos($name, $sep)) { + return array(null, $name); + } + return array( + substr($name, 0, $module), + substr($name, $module + 1) + ); + } + /** * Test for a valid class name * @@ -123,10 +135,24 @@ class Hook */ private static function assertValidHook($instance, $name) { - $base_class = self::$BASE_NS . ucfirst($name) . 'Hook'; + $suffix = self::$classSuffix; // 'Hook' + $base = self::$BASE_NS; // 'Icinga\\Web\\Hook\\' - if (strpos($base_class, self::$classSuffix) === false) { - $base_class .= self::$classSuffix; + list($module, $name) = self::splitHookName($name); + + if ($module === null) { + $base_class = $base . ucfirst($name) . 'Hook'; + + // I'm unsure whether this makes sense. Unused and Wrong. + if (strpos($base_class, $suffix) === false) { + $base_class .= $suffix; + } + } else { + $base_class = 'Icinga\\Module\\' + . ucfirst($module) + . '\\Web\\Hook\\' + . ucfirst($name) + . $suffix; } if (!$instance instanceof $base_class) { From 45bf071db603912154cadde32e67cc9f367ac5fb Mon Sep 17 00:00:00 2001 From: Thomas Gelf Date: Wed, 14 Jan 2015 11:00:26 +0100 Subject: [PATCH 0507/2920] HostActionsHook: initial very simple implementation refs #8208 --- .../library/Monitoring/Web/Hook/HostActionsHook.php | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 modules/monitoring/library/Monitoring/Web/Hook/HostActionsHook.php diff --git a/modules/monitoring/library/Monitoring/Web/Hook/HostActionsHook.php b/modules/monitoring/library/Monitoring/Web/Hook/HostActionsHook.php new file mode 100644 index 000000000..c1ccdfbca --- /dev/null +++ b/modules/monitoring/library/Monitoring/Web/Hook/HostActionsHook.php @@ -0,0 +1,10 @@ + Date: Wed, 14 Jan 2015 11:01:39 +0100 Subject: [PATCH 0508/2920] HostController: use host actions hook refs #8208 --- .../controllers/HostController.php | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/modules/monitoring/application/controllers/HostController.php b/modules/monitoring/application/controllers/HostController.php index 4eccb8899..150f9ae1a 100644 --- a/modules/monitoring/application/controllers/HostController.php +++ b/modules/monitoring/application/controllers/HostController.php @@ -9,6 +9,7 @@ use Icinga\Module\Monitoring\Forms\Command\Object\ScheduleHostCheckCommandForm; use Icinga\Module\Monitoring\Forms\Command\Object\ScheduleHostDowntimeCommandForm; use Icinga\Module\Monitoring\Object\Host; use Icinga\Module\Monitoring\Web\Controller\MonitoredObjectController; +use Icinga\Web\Hook; class Monitoring_HostController extends MonitoredObjectController { @@ -37,6 +38,28 @@ class Monitoring_HostController extends MonitoredObjectController $this->getTabs()->activate('host'); } + protected function getHostActions() + { + $urls = array(); + + foreach (Hook::all('Monitoring\\HostActions') as $hook) { + foreach ($hook->getActionsForHost($this->object) as $id => $url) { + $urls[$id] = $url; + } + } + + return $urls; + } + + /** + * Show a host + */ + public function showAction() + { + $this->view->hostActions = $this->getHostActions(); + parent::showAction(); + } + /** * Acknowledge a host problem */ From 6c8808875adafbd39ebafe04f118ee0ca326e70b Mon Sep 17 00:00:00 2001 From: Thomas Gelf Date: Wed, 14 Jan 2015 11:02:06 +0100 Subject: [PATCH 0509/2920] host/show: show action urls above perfdata --- modules/monitoring/application/views/scripts/host/show.phtml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/monitoring/application/views/scripts/host/show.phtml b/modules/monitoring/application/views/scripts/host/show.phtml index 00d579a29..867692301 100644 --- a/modules/monitoring/application/views/scripts/host/show.phtml +++ b/modules/monitoring/application/views/scripts/host/show.phtml @@ -13,9 +13,9 @@ render('show/components/notifications.phtml') ?> render('show/components/downtime.phtml') ?> render('show/components/flapping.phtml') ?> + render('show/components/actions.phtml') ?> render('show/components/perfdata.phtml') ?> render('show/components/checksource.phtml') ?> - render('show/components/actions.phtml') ?> render('show/components/command.phtml') ?> render('show/components/hostgroups.phtml') ?> render('show/components/contacts.phtml') ?> From 3038de5ad0ba125fd3c94739b226abe75f355197 Mon Sep 17 00:00:00 2001 From: Thomas Gelf Date: Wed, 14 Jan 2015 11:02:43 +0100 Subject: [PATCH 0510/2920] components/actions: show host action urls if given --- .../views/scripts/show/components/actions.phtml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/modules/monitoring/application/views/scripts/show/components/actions.phtml b/modules/monitoring/application/views/scripts/show/components/actions.phtml index 9f3211bd3..c34141084 100644 --- a/modules/monitoring/application/views/scripts/show/components/actions.phtml +++ b/modules/monitoring/application/views/scripts/show/components/actions.phtml @@ -6,6 +6,7 @@ if (! $object->action_url && ! $object->notes_url) { $links = array(); $linkText = '%s'; +$localLinkText = '%s'; if ($object->notes_url) { if (strpos($object->notes_url, "' ") === false) { @@ -32,6 +33,12 @@ if ($object->action_url) { } } +if (isset($this->hostActions)) { + foreach ($this->hostActions as $id => $action) { + $links[] = sprintf($localLinkText, $action, $id); + } +} + ?>

    From b4c47c51e7a354b69f7b85d6feb8e23ba693ac58 Mon Sep 17 00:00:00 2001 From: Thomas Gelf Date: Wed, 14 Jan 2015 11:50:03 +0100 Subject: [PATCH 0511/2920] components/actions: show links if available Now we show links regardless of whether we have host actions, there might be hook-provided links only. Renamed "Foreign URLs" to "Actions" and made it translatable. --- .../views/scripts/show/components/actions.phtml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/modules/monitoring/application/views/scripts/show/components/actions.phtml b/modules/monitoring/application/views/scripts/show/components/actions.phtml index c34141084..1d926b33a 100644 --- a/modules/monitoring/application/views/scripts/show/components/actions.phtml +++ b/modules/monitoring/application/views/scripts/show/components/actions.phtml @@ -1,9 +1,5 @@ action_url && ! $object->notes_url) { - return; -} - $links = array(); $linkText = '%s'; $localLinkText = '%s'; @@ -39,8 +35,12 @@ if (isset($this->hostActions)) { } } +if (empty($links)) { + return; +} + ?> - + From b54a12c2d5d7c15d18cc8046ac42b27852b76123 Mon Sep 17 00:00:00 2001 From: Thomas Gelf Date: Mon, 2 Feb 2015 18:17:30 +0100 Subject: [PATCH 0512/2920] HostActionsHook: document the new hook --- .../Monitoring/Web/Hook/HostActionsHook.php | 35 +++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/modules/monitoring/library/Monitoring/Web/Hook/HostActionsHook.php b/modules/monitoring/library/Monitoring/Web/Hook/HostActionsHook.php index c1ccdfbca..5025c414c 100644 --- a/modules/monitoring/library/Monitoring/Web/Hook/HostActionsHook.php +++ b/modules/monitoring/library/Monitoring/Web/Hook/HostActionsHook.php @@ -4,7 +4,42 @@ namespace Icinga\Module\Monitoring\Web\Hook; use Icinga\Module\Monitoring\Object\Host; +/** + * Base class for host action hooks + */ abstract class HostActionsHook { + /** + * Implementors of this method should return an array containing + * additional action links for a specific host. You get a full Host + * object, which allows you to return specific links only for nodes + * with specific properties. + * + * The result array should be in the form title => url, where title will + * be used as link caption. Url should be an Icinga\Web\Url object when + * the link should point to an Icinga Web url - otherwise a string would + * be fine. + * + * Mixed example: + * + * return array( + * 'Wiki' => 'http://my.wiki/host=' . rawurlencode($host->host_name), + * 'Logstash' => Url::fromPath( + * 'logstash/search/syslog', + * array('host' => $host->host_name) + * ) + * ); + * + * + * One might also provide ssh:// or rdp:// urls if equipped with fitting + * (safe) URL handlers for his browser(s). + * + * TODO: I'd love to see some kind of a Link/LinkSet object implemented + * for this and similar hooks. + * + * @param Host $host Monitoring host object + * + * @return array An array containing a list of host action links + */ abstract public function getActionsForHost(Host $host); } From a705e03affe33d5c42ff9fb9b389227812aea57d Mon Sep 17 00:00:00 2001 From: Thomas Gelf Date: Mon, 2 Feb 2015 18:21:01 +0100 Subject: [PATCH 0513/2920] HostController: fix merge BS --- .../application/controllers/HostController.php | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/modules/monitoring/application/controllers/HostController.php b/modules/monitoring/application/controllers/HostController.php index e2f7f8475..150f9ae1a 100644 --- a/modules/monitoring/application/controllers/HostController.php +++ b/modules/monitoring/application/controllers/HostController.php @@ -51,19 +51,6 @@ class Monitoring_HostController extends MonitoredObjectController return $urls; } - protected function getHostActions() - { - $urls = array(); - - foreach (Hook::all('Monitoring\\HostActions') as $hook) { - foreach ($hook->getActionsForHost($this->object) as $id => $url) { - $urls[$id] = $url; - } - } - - return $urls; - } - /** * Show a host */ From f6fc592b911b60e303d49026613429dd128ad937 Mon Sep 17 00:00:00 2001 From: Thomas Gelf Date: Mon, 2 Feb 2015 21:56:14 +0100 Subject: [PATCH 0514/2920] events.js: reduce logging noise Form submission by pressing return is not an error, and debug level should suffice for the other button-related notices too. --- public/js/icinga/events.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/public/js/icinga/events.js b/public/js/icinga/events.js index e7ac3e3f1..0a77db60e 100644 --- a/public/js/icinga/events.js +++ b/public/js/icinga/events.js @@ -204,16 +204,16 @@ if (typeof event.originalEvent !== 'undefined' && typeof event.originalEvent.explicitOriginalTarget === 'object') { // Firefox $el = $(event.originalEvent.explicitOriginalTarget); - icinga.logger.info('events/submitForm: Button is event.originalEvent.explicitOriginalTarget'); + icinga.logger.debug('events/submitForm: Button is event.originalEvent.explicitOriginalTarget'); } else { $el = $(event.currentTarget); - icinga.logger.info('events/submitForm: Button is event.currentTarget'); + icinga.logger.debug('events/submitForm: Button is event.currentTarget'); } if ($el && ($el.is('input[type=submit]') || $el.is('button[type=submit]'))) { $button = $el; } else { - icinga.logger.error( + icinga.logger.debug( 'events/submitForm: Can not determine submit button, using the first one in form' ); } From 7989b48248e001010b9bfb93f5fed9c4e5c3ef47 Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Tue, 3 Feb 2015 10:15:54 +0100 Subject: [PATCH 0515/2920] Fix ldap auth when the userNameAttribute holds multiple values fixes #8246 --- doc/authentication.md | 4 ++++ .../Authentication/Backend/LdapUserBackend.php | 16 ++++++++++++++-- library/Icinga/Protocol/Ldap/Connection.php | 6 +++--- 3 files changed, 21 insertions(+), 5 deletions(-) diff --git a/doc/authentication.md b/doc/authentication.md index 542eb9934..175403061 100644 --- a/doc/authentication.md +++ b/doc/authentication.md @@ -54,6 +54,10 @@ user_class = inetOrgPerson user_name_attribute = uid ``` +Note that in case the set *user_name_attribute* holds multiple values it is required that all of its +values are unique. Additionally, a user will be logged in using the exact user id used to authenticate +with Icinga Web 2 (e.g. an alias) no matter what the primary user id might actually be. + #### Active Directory Directive | Description diff --git a/library/Icinga/Authentication/Backend/LdapUserBackend.php b/library/Icinga/Authentication/Backend/LdapUserBackend.php index 69fe795fc..666ed69ae 100644 --- a/library/Icinga/Authentication/Backend/LdapUserBackend.php +++ b/library/Icinga/Authentication/Backend/LdapUserBackend.php @@ -150,7 +150,13 @@ class LdapUserBackend extends UserBackend public function hasUser(User $user) { $username = $user->getUsername(); - return strtolower($this->conn->fetchOne($this->selectUser($username))) === strtolower($username); + $entry = $this->conn->fetchOne($this->selectUser($username)); + + if (is_array($entry)) { + return in_array(strtolower($username), array_map('strtolower', $entry)); + } + + return strtolower($entry) === strtolower($username); } /** @@ -225,7 +231,13 @@ class LdapUserBackend extends UserBackend { $users = array(); foreach ($this->selectUsers()->fetchAll() as $row) { - $users[] = $row->{$this->userNameAttribute}; + if (is_array($row->{$this->userNameAttribute})) { + foreach ($row->{$this->userNameAttribute} as $col) { + $users[] = $col; + } + } else { + $users[] = $row->{$this->userNameAttribute}; + } } return $users; } diff --git a/library/Icinga/Protocol/Ldap/Connection.php b/library/Icinga/Protocol/Ldap/Connection.php index 1f58f34da..a576ab790 100644 --- a/library/Icinga/Protocol/Ldap/Connection.php +++ b/library/Icinga/Protocol/Ldap/Connection.php @@ -214,20 +214,20 @@ class Connection /** * Fetch the distinguished name of the first result of the given query * - * @param $query The query returning the result set + * @param Query $query The query returning the result set * @param array $fields The fields to fetch * * @return string Returns the distinguished name, or false when the given query yields no results * @throws LdapException When the query result is empty and contains no DN to fetch */ - public function fetchDN($query, $fields = array()) + public function fetchDN(Query $query, $fields = array()) { $rows = $this->fetchAll($query, $fields); if (count($rows) !== 1) { throw new LdapException( sprintf( 'Cannot fetch single DN for %s', - $query + $query->create() ) ); } From cb08b25e17051012eafbc3976c2b1e3abf5ea86d Mon Sep 17 00:00:00 2001 From: Markus Frosch Date: Tue, 3 Feb 2015 10:42:54 +0100 Subject: [PATCH 0516/2920] Remove executable flags from some PHP libraries Note: dompdf.php is actually a CLI script, but has no shebang and is not used in Icingaweb2. Fixes #8345 --- library/Icinga/Web/Session/PhpSession.php | 0 library/vendor/HTMLPurifier/DefinitionCache/Serializer/README | 0 library/vendor/Zend/Amf/Adobe/Auth.php | 0 library/vendor/Zend/Amf/Adobe/DbInspector.php | 0 library/vendor/Zend/Amf/Adobe/Introspector.php | 0 library/vendor/Zend/Amf/Auth/Abstract.php | 0 library/vendor/Zend/Amf/Parse/Resource/MysqlResult.php | 0 library/vendor/Zend/Amf/Parse/Resource/Stream.php | 0 library/vendor/Zend/Amf/Value/Messaging/ArrayCollection.php | 0 library/vendor/Zend/Cache/Backend/ZendServer.php | 0 library/vendor/Zend/Cache/Backend/ZendServer/Disk.php | 0 library/vendor/Zend/Cache/Backend/ZendServer/ShMem.php | 0 library/vendor/Zend/Cloud/AbstractFactory.php | 0 .../vendor/Zend/Cloud/DocumentService/Adapter/WindowsAzure.php | 0 .../Zend/Cloud/DocumentService/Adapter/WindowsAzure/Query.php | 0 library/vendor/Zend/Cloud/QueueService/Adapter/WindowsAzure.php | 0 library/vendor/Zend/Cloud/QueueService/Adapter/ZendQueue.php | 0 library/vendor/Zend/Cloud/QueueService/Message.php | 0 library/vendor/Zend/Config/Json.php | 0 library/vendor/Zend/Config/Writer/Json.php | 0 library/vendor/Zend/Config/Writer/Yaml.php | 0 library/vendor/Zend/Config/Yaml.php | 0 library/vendor/Zend/Http/Client/Adapter/Stream.php | 0 library/vendor/Zend/Http/Response/Stream.php | 0 library/vendor/dompdf/dompdf.php | 0 25 files changed, 0 insertions(+), 0 deletions(-) mode change 100755 => 100644 library/Icinga/Web/Session/PhpSession.php mode change 100755 => 100644 library/vendor/HTMLPurifier/DefinitionCache/Serializer/README mode change 100755 => 100644 library/vendor/Zend/Amf/Adobe/Auth.php mode change 100755 => 100644 library/vendor/Zend/Amf/Adobe/DbInspector.php mode change 100755 => 100644 library/vendor/Zend/Amf/Adobe/Introspector.php mode change 100755 => 100644 library/vendor/Zend/Amf/Auth/Abstract.php mode change 100755 => 100644 library/vendor/Zend/Amf/Parse/Resource/MysqlResult.php mode change 100755 => 100644 library/vendor/Zend/Amf/Parse/Resource/Stream.php mode change 100755 => 100644 library/vendor/Zend/Amf/Value/Messaging/ArrayCollection.php mode change 100755 => 100644 library/vendor/Zend/Cache/Backend/ZendServer.php mode change 100755 => 100644 library/vendor/Zend/Cache/Backend/ZendServer/Disk.php mode change 100755 => 100644 library/vendor/Zend/Cache/Backend/ZendServer/ShMem.php mode change 100755 => 100644 library/vendor/Zend/Cloud/AbstractFactory.php mode change 100755 => 100644 library/vendor/Zend/Cloud/DocumentService/Adapter/WindowsAzure.php mode change 100755 => 100644 library/vendor/Zend/Cloud/DocumentService/Adapter/WindowsAzure/Query.php mode change 100755 => 100644 library/vendor/Zend/Cloud/QueueService/Adapter/WindowsAzure.php mode change 100755 => 100644 library/vendor/Zend/Cloud/QueueService/Adapter/ZendQueue.php mode change 100755 => 100644 library/vendor/Zend/Cloud/QueueService/Message.php mode change 100755 => 100644 library/vendor/Zend/Config/Json.php mode change 100755 => 100644 library/vendor/Zend/Config/Writer/Json.php mode change 100755 => 100644 library/vendor/Zend/Config/Writer/Yaml.php mode change 100755 => 100644 library/vendor/Zend/Config/Yaml.php mode change 100755 => 100644 library/vendor/Zend/Http/Client/Adapter/Stream.php mode change 100755 => 100644 library/vendor/Zend/Http/Response/Stream.php mode change 100755 => 100644 library/vendor/dompdf/dompdf.php diff --git a/library/Icinga/Web/Session/PhpSession.php b/library/Icinga/Web/Session/PhpSession.php old mode 100755 new mode 100644 diff --git a/library/vendor/HTMLPurifier/DefinitionCache/Serializer/README b/library/vendor/HTMLPurifier/DefinitionCache/Serializer/README old mode 100755 new mode 100644 diff --git a/library/vendor/Zend/Amf/Adobe/Auth.php b/library/vendor/Zend/Amf/Adobe/Auth.php old mode 100755 new mode 100644 diff --git a/library/vendor/Zend/Amf/Adobe/DbInspector.php b/library/vendor/Zend/Amf/Adobe/DbInspector.php old mode 100755 new mode 100644 diff --git a/library/vendor/Zend/Amf/Adobe/Introspector.php b/library/vendor/Zend/Amf/Adobe/Introspector.php old mode 100755 new mode 100644 diff --git a/library/vendor/Zend/Amf/Auth/Abstract.php b/library/vendor/Zend/Amf/Auth/Abstract.php old mode 100755 new mode 100644 diff --git a/library/vendor/Zend/Amf/Parse/Resource/MysqlResult.php b/library/vendor/Zend/Amf/Parse/Resource/MysqlResult.php old mode 100755 new mode 100644 diff --git a/library/vendor/Zend/Amf/Parse/Resource/Stream.php b/library/vendor/Zend/Amf/Parse/Resource/Stream.php old mode 100755 new mode 100644 diff --git a/library/vendor/Zend/Amf/Value/Messaging/ArrayCollection.php b/library/vendor/Zend/Amf/Value/Messaging/ArrayCollection.php old mode 100755 new mode 100644 diff --git a/library/vendor/Zend/Cache/Backend/ZendServer.php b/library/vendor/Zend/Cache/Backend/ZendServer.php old mode 100755 new mode 100644 diff --git a/library/vendor/Zend/Cache/Backend/ZendServer/Disk.php b/library/vendor/Zend/Cache/Backend/ZendServer/Disk.php old mode 100755 new mode 100644 diff --git a/library/vendor/Zend/Cache/Backend/ZendServer/ShMem.php b/library/vendor/Zend/Cache/Backend/ZendServer/ShMem.php old mode 100755 new mode 100644 diff --git a/library/vendor/Zend/Cloud/AbstractFactory.php b/library/vendor/Zend/Cloud/AbstractFactory.php old mode 100755 new mode 100644 diff --git a/library/vendor/Zend/Cloud/DocumentService/Adapter/WindowsAzure.php b/library/vendor/Zend/Cloud/DocumentService/Adapter/WindowsAzure.php old mode 100755 new mode 100644 diff --git a/library/vendor/Zend/Cloud/DocumentService/Adapter/WindowsAzure/Query.php b/library/vendor/Zend/Cloud/DocumentService/Adapter/WindowsAzure/Query.php old mode 100755 new mode 100644 diff --git a/library/vendor/Zend/Cloud/QueueService/Adapter/WindowsAzure.php b/library/vendor/Zend/Cloud/QueueService/Adapter/WindowsAzure.php old mode 100755 new mode 100644 diff --git a/library/vendor/Zend/Cloud/QueueService/Adapter/ZendQueue.php b/library/vendor/Zend/Cloud/QueueService/Adapter/ZendQueue.php old mode 100755 new mode 100644 diff --git a/library/vendor/Zend/Cloud/QueueService/Message.php b/library/vendor/Zend/Cloud/QueueService/Message.php old mode 100755 new mode 100644 diff --git a/library/vendor/Zend/Config/Json.php b/library/vendor/Zend/Config/Json.php old mode 100755 new mode 100644 diff --git a/library/vendor/Zend/Config/Writer/Json.php b/library/vendor/Zend/Config/Writer/Json.php old mode 100755 new mode 100644 diff --git a/library/vendor/Zend/Config/Writer/Yaml.php b/library/vendor/Zend/Config/Writer/Yaml.php old mode 100755 new mode 100644 diff --git a/library/vendor/Zend/Config/Yaml.php b/library/vendor/Zend/Config/Yaml.php old mode 100755 new mode 100644 diff --git a/library/vendor/Zend/Http/Client/Adapter/Stream.php b/library/vendor/Zend/Http/Client/Adapter/Stream.php old mode 100755 new mode 100644 diff --git a/library/vendor/Zend/Http/Response/Stream.php b/library/vendor/Zend/Http/Response/Stream.php old mode 100755 new mode 100644 diff --git a/library/vendor/dompdf/dompdf.php b/library/vendor/dompdf/dompdf.php old mode 100755 new mode 100644 From a6cea24934f493d0131fb4813176c21da5315603 Mon Sep 17 00:00:00 2001 From: Alexander Klimov Date: Tue, 3 Feb 2015 12:16:25 +0100 Subject: [PATCH 0517/2920] Platform::zendClassExists(): don't fail if a Zend class file doesn't exist --- library/Icinga/Application/Platform.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library/Icinga/Application/Platform.php b/library/Icinga/Application/Platform.php index 6e5953887..d4d130220 100644 --- a/library/Icinga/Application/Platform.php +++ b/library/Icinga/Application/Platform.php @@ -191,7 +191,7 @@ class Platform */ public static function zendClassExists($name) { - if (class_exists($name)) { + if (@class_exists($name)) { return true; } From 31728fd024c0fc567e5de6969c43fd8047cc0ff8 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Tue, 3 Feb 2015 12:34:22 +0100 Subject: [PATCH 0518/2920] monitoring: Improve tooltips for hosts command links refs #8110 --- .../controllers/HostsController.php | 2 +- .../views/scripts/hosts/show.phtml | 64 +++++++++++++------ 2 files changed, 46 insertions(+), 20 deletions(-) diff --git a/modules/monitoring/application/controllers/HostsController.php b/modules/monitoring/application/controllers/HostsController.php index 869be92d8..27b9d28f4 100644 --- a/modules/monitoring/application/controllers/HostsController.php +++ b/modules/monitoring/application/controllers/HostsController.php @@ -121,7 +121,7 @@ class Monitoring_HostsController extends Controller $this->view->objectsInDowntime = $objectsInDowntime; $this->view->inDowntimeLink = Url::fromPath('monitoring/list/downtimes') ->setQueryString(Filter::matchAny($downtimeFilterExpressions)->toQueryString()); - $this->view->havingCommentsLink = Url::fromRequest() + $this->view->commentsLink = Url::fromRequest() ->setPath('monitoring/list/comments'); $this->view->hostStatesPieChart = $this->createPieChart( $hostStates, diff --git a/modules/monitoring/application/views/scripts/hosts/show.phtml b/modules/monitoring/application/views/scripts/hosts/show.phtml index a5d36deb1..109d6723b 100644 --- a/modules/monitoring/application/views/scripts/hosts/show.phtml +++ b/modules/monitoring/application/views/scripts/hosts/show.phtml @@ -76,17 +76,43 @@ ) ?> @@ -123,8 +149,8 @@ icon('plug') ?> translatePlural( - '%u host is in downtime', - '%u hosts are in downtime', + 'List %u host currently in downtime', + 'List %u hosts currently downtime', $inDowntimeCount ), $inDowntimeCount @@ -133,26 +159,26 @@ - getComments()) ?> - + getComments()) ?> +

    - icon('comment') ?> translatePlural( - '%u comment', - '%u comments', - $havingCommentsCount + 'List %u host comment', + 'List %u host comments', + $commentCount ), - $havingCommentsCount + $commentCount ) ?>

    From dd0638c5d03ded339c53b1cffd3943da6bdac308 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Tue, 3 Feb 2015 12:35:06 +0100 Subject: [PATCH 0519/2920] monitoring: Improve tooltips for services command links refs #8110 --- .../controllers/ServicesController.php | 2 +- .../views/scripts/services/show.phtml | 75 ++++++++++++++----- 2 files changed, 57 insertions(+), 20 deletions(-) diff --git a/modules/monitoring/application/controllers/ServicesController.php b/modules/monitoring/application/controllers/ServicesController.php index dc7feb2da..48ff64723 100644 --- a/modules/monitoring/application/controllers/ServicesController.php +++ b/modules/monitoring/application/controllers/ServicesController.php @@ -144,7 +144,7 @@ class Monitoring_ServicesController extends Controller $this->view->objectsInDowntime = $objectsInDowntime; $this->view->inDowntimeLink = Url::fromPath('monitoring/list/downtimes') ->setQueryString(Filter::matchAny($downtimeFilterExpressions)->toQueryString()); - $this->view->havingCommentsLink = Url::fromRequest() + $this->view->commentsLink = Url::fromRequest() ->setPath('monitoring/list/comments'); $this->view->serviceStatesPieChart = $this->createPieChart( $serviceStates, diff --git a/modules/monitoring/application/views/scripts/services/show.phtml b/modules/monitoring/application/views/scripts/services/show.phtml index 522d32ce7..1cc895dd3 100644 --- a/modules/monitoring/application/views/scripts/services/show.phtml +++ b/modules/monitoring/application/views/scripts/services/show.phtml @@ -37,7 +37,7 @@ @@ -81,17 +81,43 @@ ) ?> @@ -116,13 +142,18 @@

    - + icon('plug') ?> translatePlural( - '%u service is in downtime', - '%u services are in downtime', + 'List %u service currently in downtime', + 'List %u services currently in downtime', $inDowntimeCount ), $inDowntimeCount @@ -131,19 +162,25 @@

    - getComments()) ?> - + getComments()) ?> +

    - + icon('comment') ?> translatePlural( - '%u comment', - '%u comments', - $havingCommentsCount + 'List %u service comment', + 'List %u service comments', + $commentCount ), - $havingCommentsCount + $commentCount ) ?>

    From 08fd000496e3d030d57a2254be761dd84044ba55 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Tue, 3 Feb 2015 12:42:02 +0100 Subject: [PATCH 0520/2920] Remove any topbar related stuff It's not used anywhere. --- application/controllers/LayoutController.php | 20 --------- .../layouts/scripts/parts/topbar.phtml | 42 ------------------- library/Icinga/Web/Hook/TopBarHook.php | 23 ---------- 3 files changed, 85 deletions(-) delete mode 100644 application/layouts/scripts/parts/topbar.phtml delete mode 100644 library/Icinga/Web/Hook/TopBarHook.php diff --git a/application/controllers/LayoutController.php b/application/controllers/LayoutController.php index b2a260884..2d84faf3c 100644 --- a/application/controllers/LayoutController.php +++ b/application/controllers/LayoutController.php @@ -25,24 +25,4 @@ class LayoutController extends ActionController $menu = new MenuRenderer(Menu::load(), $url->getRelativeUrl()); $this->view->menuRenderer = $menu->useCustomRenderer(); } - - /** - * Render the top bar - */ - public function topbarAction() - { - $topbarHtmlParts = array(); - - /** @var Hook\TopBarHook $hook */ - $hook = null; - - foreach (Hook::all('TopBar') as $hook) { - $topbarHtmlParts[] = $hook->getHtml($this->getRequest()); - } - - $this->view->topbarHtmlParts = $topbarHtmlParts; - - - $this->renderScript('parts/topbar.phtml'); - } } diff --git a/application/layouts/scripts/parts/topbar.phtml b/application/layouts/scripts/parts/topbar.phtml deleted file mode 100644 index 68f919951..000000000 --- a/application/layouts/scripts/parts/topbar.phtml +++ /dev/null @@ -1,42 +0,0 @@ - diff --git a/library/Icinga/Web/Hook/TopBarHook.php b/library/Icinga/Web/Hook/TopBarHook.php deleted file mode 100644 index 183a0ca07..000000000 --- a/library/Icinga/Web/Hook/TopBarHook.php +++ /dev/null @@ -1,23 +0,0 @@ - Date: Tue, 3 Feb 2015 15:05:36 +0100 Subject: [PATCH 0521/2920] Add .mailmap and AUTHORS files --- .mailmap | 12 ++++++++++++ AUTHORS | 22 ++++++++++++++++++++++ 2 files changed, 34 insertions(+) create mode 100644 .mailmap create mode 100644 AUTHORS diff --git a/.mailmap b/.mailmap new file mode 100644 index 000000000..0ce0c9686 --- /dev/null +++ b/.mailmap @@ -0,0 +1,12 @@ + + + + +Jannis Moßhammer + + + + +Thomas Gelf +Thomas Gelf +Sylph Lin diff --git a/AUTHORS b/AUTHORS new file mode 100644 index 000000000..c225db6f6 --- /dev/null +++ b/AUTHORS @@ -0,0 +1,22 @@ +Alexander Fuhr +Alexander Klimov +Bernd Erk +Boden Garman +Carlos Cesario +Chris Rüll +Eric Lippmann +Goran Rakic +Gunnar Beutner +Jannis Moßhammer +Johannes Meyer +Marius Hein +Markus Frosch +Matthias Jentsch +Michael Friedrich +Rene Moser +Susanne Vestner-Ludwig +Sylph Lin +Thomas Gelf +Tom Ford +Ulf Lange +ayoubabid From a23752de63fede23710ae602983e385c48733e23 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Tue, 3 Feb 2015 15:10:18 +0100 Subject: [PATCH 0522/2920] security: Don't list permissions and restrictions in the roles overview fixes #8335 --- application/views/scripts/roles/index.phtml | 48 ++++++++++----------- 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/application/views/scripts/roles/index.phtml b/application/views/scripts/roles/index.phtml index 758376c53..c08a0b6a4 100644 --- a/application/views/scripts/roles/index.phtml +++ b/application/views/scripts/roles/index.phtml @@ -11,8 +11,8 @@
    - - +translate('Permissions') ?> +translate('Restrictions') ?> @@ -26,28 +26,28 @@ - - +escape($role->permissions, 0, 50) ?> + +without(...) or $role->shift(...) would be nice! +// $restrictions = clone $role; +// unset($restrictions['users']); +// unset($restrictions['groups']); +// unset($restrictions['permissions']); +// ?> + + + + $restriction): ?> + +escape($restrictionName) ?> +escape($restriction) ?> + + + + + +'; @@ -56,8 +56,13 @@ class Zend_View_Helper_Perfdata extends Zend_View_Helper_Abstract } } + if ($limit > 0) { + $table = array_slice ($table, 0, $limit); + $results = array_slice ($results, 0, $limit); + } + if ($compact) { - return $result; + return join('', $results); } else { $pieCharts = empty($table) ? '' : '
    > - host_state, true)); ?>
    + host_state, true)); ?>
    prefixedTimeSince($object->host_last_state_change, true) ?>
    @@ -31,7 +31,7 @@ $isService = $object->getType() === $object::TYPE_SERVICE;
    - service_state, true)); ?>
    + service_state, true)); ?>
    prefixedTimeSince($object->service_last_state_change, true) ?>
    From fc62a63899d229bbbcd2d5e09038334bb883fb20 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Thu, 22 Jan 2015 10:37:44 +0100 Subject: [PATCH 0316/2920] Remove require version comment in the Vagrantfile --- Vagrantfile | 1 - 1 file changed, 1 deletion(-) diff --git a/Vagrantfile b/Vagrantfile index 28b69cab9..1e5e3a073 100644 --- a/Vagrantfile +++ b/Vagrantfile @@ -4,7 +4,6 @@ VAGRANTFILE_API_VERSION = "2" VAGRANT_REQUIRED_VERSION = "1.5.0" -# Require 1.2.x at least if ! defined? Vagrant.require_version if Gem::Version.new(Vagrant::VERSION) < Gem::Version.new(VAGRANT_REQUIRED_VERSION) puts "Vagrant >= " + VAGRANT_REQUIRED_VERSION + " required. Your version is " + Vagrant::VERSION From dd83f6f75796abb7638d6d07ddf8bf21fd807573 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Thu, 22 Jan 2015 10:38:00 +0100 Subject: [PATCH 0317/2920] Fix copyright year --- application/views/scripts/authentication/login.phtml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/application/views/scripts/authentication/login.phtml b/application/views/scripts/authentication/login.phtml index a3d8fcfa9..7d8d15df8 100644 --- a/application/views/scripts/authentication/login.phtml +++ b/application/views/scripts/authentication/login.phtml @@ -14,7 +14,7 @@ form ?> - +
    Date: Thu, 22 Jan 2015 10:45:14 +0100 Subject: [PATCH 0318/2920] monitoring: Escape event message in an object's event history --- modules/monitoring/application/views/scripts/show/history.phtml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/monitoring/application/views/scripts/show/history.phtml b/modules/monitoring/application/views/scripts/show/history.phtml index 5b922d4a0..728b9bfc1 100644 --- a/modules/monitoring/application/views/scripts/show/history.phtml +++ b/modules/monitoring/application/views/scripts/show/history.phtml @@ -148,7 +148,7 @@ $output = $this->tickets ? preg_replace_callback(
    - icon($icon, $title); ?> + icon($icon, $title); ?> escape($msg) ?>
    - - escape($event->service_display_name) ?> - - - translate('on') . ' ' . $this->escape($event->host_display_name) ?> - + link()->service( + $event->service, $event->service_display_name, $event->host, $event->host_display_name + ) ?> - - escape($event->host_display_name) ?> - + link()->host($event->host, $event->host_display_name) ?>
    From db9e2fe4cae6435bfd64d5f9e7cfa988c2d38072 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Thu, 22 Jan 2015 11:06:05 +0100 Subject: [PATCH 0323/2920] doc/vagrant: Fix version requirement --- doc/vagrant.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/vagrant.md b/doc/vagrant.md index 6bcc2def9..b1b98b436 100644 --- a/doc/vagrant.md +++ b/doc/vagrant.md @@ -2,10 +2,10 @@ ## Requirements -* Vagrant >= version 1.4 +* Vagrant >= version 1.5 * VirtualBox or Parallels -> **Note:** The deployment of the virtual machine is tested against Vagrant starting with version 1.4. +> **Note:** The deployment of the virtual machine is tested against Vagrant starting with version 1.5. > Unfortunately older versions will not work. ## General From 3040116c129a4705649ee019602c9352844b77a2 Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Thu, 22 Jan 2015 12:47:18 +0100 Subject: [PATCH 0324/2920] Combine duplicate requirements refs #8191 --- .../scripts/form/setup-requirements.phtml | 12 ++- modules/setup/library/Setup/Requirements.php | 75 ++++++++++++++----- modules/setup/library/Setup/WebWizard.php | 17 ++++- public/css/icinga/setup.less | 6 ++ 4 files changed, 89 insertions(+), 21 deletions(-) diff --git a/modules/setup/application/views/scripts/form/setup-requirements.phtml b/modules/setup/application/views/scripts/form/setup-requirements.phtml index 09d337a02..47842efde 100644 --- a/modules/setup/application/views/scripts/form/setup-requirements.phtml +++ b/modules/setup/application/views/scripts/form/setup-requirements.phtml @@ -11,7 +11,17 @@ $requirements = $form->getRequirements();

    title; ?>

    description; ?> + description)): ?> +
      + description as $desc): ?> +
    • + +
    + + description; ?> + +
    message; ?>
    - host_state, true)); ?>
    + host_state, true); ?>
    host_state !== 99): ?> prefixedTimeSince($host->host_last_state_change, true) ?> host_state > 0 && (int) $host->host_state_type === 0): ?> diff --git a/modules/monitoring/application/views/scripts/list/services.phtml b/modules/monitoring/application/views/scripts/list/services.phtml index 0e211dfa5..45d59adf5 100644 --- a/modules/monitoring/application/views/scripts/list/services.phtml +++ b/modules/monitoring/application/views/scripts/list/services.phtml @@ -56,7 +56,7 @@ foreach ($services as $service): ?>
    - service_state, true)); ?>
    + service_state, true); ?>
    compact): ?>prefixedTimeSince($service->service_last_state_change); ?>timeSince($service->service_last_state_change); ?> service_state > 0 && (int) $service->service_state_type === 0): ?>
    @@ -106,7 +106,7 @@ foreach ($services as $service): escape($service->service_display_name) ?>showHost): ?> on escape($service->host_display_name) ?> host_state != 0): ?> - (host_state, true)); ?>) + (host_state, true); ?>)

    escape($this->ellipsis($service->service_output, 10000)); ?>

    diff --git a/modules/monitoring/application/views/scripts/services/show.phtml b/modules/monitoring/application/views/scripts/services/show.phtml index 93e4ae84a..522d32ce7 100644 --- a/modules/monitoring/application/views/scripts/services/show.phtml +++ b/modules/monitoring/application/views/scripts/services/show.phtml @@ -16,7 +16,7 @@
    $count) { - echo sprintf(' %s: %u
    ', strtoupper($text), $count); + echo sprintf(' %s: %u
    ', $this->translate(strtoupper($text)), $count); } ?>
    @@ -31,7 +31,7 @@
    $count) { - echo sprintf('%s: %u
    ', strtoupper($text), $count); + echo sprintf('%s: %u
    ', $this->translate(strtoupper($text)), $count); } ?>
    diff --git a/modules/monitoring/application/views/scripts/show/components/header.phtml b/modules/monitoring/application/views/scripts/show/components/header.phtml index 7f58790f4..8ba84da43 100644 --- a/modules/monitoring/application/views/scripts/show/components/header.phtml +++ b/modules/monitoring/application/views/scripts/show/components/header.phtml @@ -14,7 +14,7 @@ $isService = $object->getType() === $object::TYPE_SERVICE; diff --git a/modules/monitoring/library/Monitoring/Web/Controller/MonitoredObjectController.php b/modules/monitoring/library/Monitoring/Web/Controller/MonitoredObjectController.php index a89a3fc49..dd83f415b 100644 --- a/modules/monitoring/library/Monitoring/Web/Controller/MonitoredObjectController.php +++ b/modules/monitoring/library/Monitoring/Web/Controller/MonitoredObjectController.php @@ -57,11 +57,14 @@ abstract class MonitoredObjectController extends Controller public function showAction() { $this->setAutorefreshInterval(10); - $checkNowForm = new CheckNowCommandForm(); - $checkNowForm - ->setObjects($this->object) - ->handleRequest(); - $this->view->checkNowForm = $checkNowForm; + $auth = $this->Auth(); + if ($auth->hasPermission('monitoring/command/schedule-check')) { + $checkNowForm = new CheckNowCommandForm(); + $checkNowForm + ->setObjects($this->object) + ->handleRequest(); + $this->view->checkNowForm = $checkNowForm; + } if ( ! in_array((int) $this->object->state, array(0, 99))) { if ((bool) $this->object->acknowledged) { $removeAckForm = new RemoveAcknowledgementCommandForm(); From f46a5872666d2237c478baa3be10d589eef1e5b9 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Thu, 22 Jan 2015 17:25:30 +0100 Subject: [PATCH 0343/2920] monitoring/security: Hide 'Remove Problem Acknowledgement' action if user lacks the respective permission --- .../scripts/show/components/acknowledgement.phtml | 8 +++++++- .../Web/Controller/MonitoredObjectController.php | 12 +++++++----- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/modules/monitoring/application/views/scripts/show/components/acknowledgement.phtml b/modules/monitoring/application/views/scripts/show/components/acknowledgement.phtml index 9b323e2f5..02415ec19 100644 --- a/modules/monitoring/application/views/scripts/show/components/acknowledgement.phtml +++ b/modules/monitoring/application/views/scripts/show/components/acknowledgement.phtml @@ -22,7 +22,13 @@ if ($object->getType() === $object::TYPE_HOST) { if ($object->acknowledged): ?> - + diff --git a/modules/monitoring/library/Monitoring/Web/Controller/MonitoredObjectController.php b/modules/monitoring/library/Monitoring/Web/Controller/MonitoredObjectController.php index dd83f415b..c9ba70dca 100644 --- a/modules/monitoring/library/Monitoring/Web/Controller/MonitoredObjectController.php +++ b/modules/monitoring/library/Monitoring/Web/Controller/MonitoredObjectController.php @@ -67,11 +67,13 @@ abstract class MonitoredObjectController extends Controller } if ( ! in_array((int) $this->object->state, array(0, 99))) { if ((bool) $this->object->acknowledged) { - $removeAckForm = new RemoveAcknowledgementCommandForm(); - $removeAckForm - ->setObjects($this->object) - ->handleRequest(); - $this->view->removeAckForm = $removeAckForm; + if ($auth->hasPermission('monitoring/command/remove-acknowledgement')) { + $removeAckForm = new RemoveAcknowledgementCommandForm(); + $removeAckForm + ->setObjects($this->object) + ->handleRequest(); + $this->view->removeAckForm = $removeAckForm; + } } else { $ackForm = new AcknowledgeProblemCommandForm(); $ackForm From 4226f06d5d03fb1274a1a8dc610f318cf52e1388 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Thu, 22 Jan 2015 17:28:33 +0100 Subject: [PATCH 0344/2920] monitoring: Remove unused variable in the MonitoredObjectController --- .../Web/Controller/MonitoredObjectController.php | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/modules/monitoring/library/Monitoring/Web/Controller/MonitoredObjectController.php b/modules/monitoring/library/Monitoring/Web/Controller/MonitoredObjectController.php index c9ba70dca..cb87d22ad 100644 --- a/modules/monitoring/library/Monitoring/Web/Controller/MonitoredObjectController.php +++ b/modules/monitoring/library/Monitoring/Web/Controller/MonitoredObjectController.php @@ -1,11 +1,8 @@ handleRequest(); $this->view->removeAckForm = $removeAckForm; } - } else { - $ackForm = new AcknowledgeProblemCommandForm(); - $ackForm - ->setObjects($this->object) - ->handleRequest(); - $this->view->ackForm = $ackForm; } } if (count($this->object->comments) > 0) { From a19c155d9f647d9a3a5dd7676baaea1fb60fa998 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Thu, 22 Jan 2015 17:33:20 +0100 Subject: [PATCH 0345/2920] monitoring/security: Hide delete comment action if user lacks the respective permission --- .../views/scripts/show/components/comments.phtml | 11 ++++++----- .../Web/Controller/MonitoredObjectController.php | 2 +- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/modules/monitoring/application/views/scripts/show/components/comments.phtml b/modules/monitoring/application/views/scripts/show/components/comments.phtml index 07968dfc8..d20cec0c2 100644 --- a/modules/monitoring/application/views/scripts/show/components/comments.phtml +++ b/modules/monitoring/application/views/scripts/show/components/comments.phtml @@ -34,10 +34,6 @@ foreach ($object->comments as $comment) { $this->escape($comment->comment) ) : $this->escape($comment->comment); - - $form = clone $delCommentForm; - $form->populate(array('comment_id' => $comment->id)); - ?> @@ -46,7 +42,12 @@ foreach ($object->comments as $comment) {
    > - host_state, true)); ?>
    + host_state, true); ?>
    prefixedTimeSince($object->host_last_state_change, true) ?>
    @@ -31,7 +31,7 @@ $isService = $object->getType() === $object::TYPE_SERVICE;
    - service_state, true)); ?>
    + service_state, true); ?>
    prefixedTimeSince($object->service_last_state_change, true) ?>
    diff --git a/modules/monitoring/application/views/scripts/show/components/hostservicesummary.phtml b/modules/monitoring/application/views/scripts/show/components/hostservicesummary.phtml index 3c603786a..641dd026a 100644 --- a/modules/monitoring/application/views/scripts/show/components/hostservicesummary.phtml +++ b/modules/monitoring/application/views/scripts/show/components/hostservicesummary.phtml @@ -17,7 +17,7 @@ $currentUrl = Url::fromRequest()->without('limit')->getRelativeUrl(); $object->stats->services_ok, $selfUrl, array('service_state' => 0), - array('title' => sprintf($this->translate('Services with state %s'), strtoupper($this->translate('ok')))) + array('title' => sprintf($this->translate('Services with state %s'), $this->translate('OK'))) ) ?> 'critical', 3 => 'unknown', 1 => 'warning') as $stateId => $ $object->stats->$unhandled, $selfUrl, $paramsUnhandled, - array('title' => sprintf($this->translate('Unhandled services with state %s'), strtoupper($this->translate($state)))) + array('title' => sprintf($this->translate('Unhandled services with state %s'), $this->translate(strtoupper($state)))) ); } if ($object->stats->$handled) { @@ -65,7 +65,7 @@ foreach (array(2 => 'critical', 3 => 'unknown', 1 => 'warning') as $stateId => $ $object->stats->$handled, $selfUrl, $paramsHandled, - array('title' => sprintf($this->translate('Handled services with state %s'), strtoupper($this->translate($state)))) + array('title' => sprintf($this->translate('Handled services with state %s'), $this->translate(strtoupper($state)))) ); if ($object->stats->$unhandled) { echo "\n"; @@ -81,7 +81,7 @@ foreach (array(2 => 'critical', 3 => 'unknown', 1 => 'warning') as $stateId => $ $object->stats->services_pending, $selfUrl, array('service_state' => 99), - array('title' => sprintf($this->translate('Services with state %s'), strtoupper($this->translate('pending')))) + array('title' => sprintf($this->translate('Services with state %s'), $this->translate('PENDING'))) ) ?> diff --git a/modules/monitoring/application/views/scripts/show/history.phtml b/modules/monitoring/application/views/scripts/show/history.phtml index a0cc4944e..40fb15363 100644 --- a/modules/monitoring/application/views/scripts/show/history.phtml +++ b/modules/monitoring/application/views/scripts/show/history.phtml @@ -92,21 +92,13 @@ function contactsLink($match, $view) { $msg = '[ ' . $event->attempt . '/' . $event->max_attempts . ' ] ' . $this->escape($event->output); $stateClass = $isService ? Service::getStateText($event->state) : Host::getStateText($event->state); $icon = 'attention-alt'; - $title = strtoupper( - $isService - ? Service::getStateText($event->state) - : Host::getStateText($event->state) - ); + $title = $isService ? Service::getStateText($event->state) : Host::getStateText($event->state); break; case 'soft_state': $icon = 'spinner'; $msg = '[ ' . $event->attempt . '/' . $event->max_attempts . ' ] ' . $this->escape($event->output); $stateClass = $isService ? Service::getStateText($event->state) : Host::getStateText($event->state); - $title = strtoupper( - $isService - ? Service::getStateText($event->state) - : Host::getStateText($event->state) - ); + $title = $isService ? Service::getStateText($event->state) : Host::getStateText($event->state); break; case 'dt_start': $icon = 'downtime_start'; diff --git a/modules/monitoring/library/Monitoring/Object/Host.php b/modules/monitoring/library/Monitoring/Object/Host.php index eeac94cb9..8f7df07cb 100644 --- a/modules/monitoring/library/Monitoring/Object/Host.php +++ b/modules/monitoring/library/Monitoring/Object/Host.php @@ -173,16 +173,16 @@ class Host extends MonitoredObject $translate = (bool) $translate; switch ((int) $state) { case self::STATE_UP: - $text = $translate ? mt('monitoring', 'up') : 'up'; + $text = $translate ? mt('monitoring', 'UP') : 'up'; break; case self::STATE_DOWN: - $text = $translate ? mt('monitoring', 'down') : 'down'; + $text = $translate ? mt('monitoring', 'DOWN') : 'down'; break; case self::STATE_UNREACHABLE: - $text = $translate ? mt('monitoring', 'unreachable') : 'unreachable'; + $text = $translate ? mt('monitoring', 'UNREACHABLE') : 'unreachable'; break; case self::STATE_PENDING: - $text = $translate ? mt('monitoring', 'pending') : 'pending'; + $text = $translate ? mt('monitoring', 'PENDING') : 'pending'; break; default: throw new InvalidArgumentException('Invalid host state \'%s\'', $state); diff --git a/modules/monitoring/library/Monitoring/Object/Service.php b/modules/monitoring/library/Monitoring/Object/Service.php index 3b7bff4fa..870ff78ba 100644 --- a/modules/monitoring/library/Monitoring/Object/Service.php +++ b/modules/monitoring/library/Monitoring/Object/Service.php @@ -214,19 +214,19 @@ class Service extends MonitoredObject $translate = (bool) $translate; switch ((int) $state) { case self::STATE_OK: - $text = $translate ? mt('monitoring', 'ok') : 'ok'; + $text = $translate ? mt('monitoring', 'OK') : 'ok'; break; case self::STATE_WARNING: - $text = $translate ? mt('monitoring', 'warning') : 'warning'; + $text = $translate ? mt('monitoring', 'WARNING') : 'warning'; break; case self::STATE_CRITICAL: - $text = $translate ? mt('monitoring', 'critical') : 'critical'; + $text = $translate ? mt('monitoring', 'CRITICAL') : 'critical'; break; case self::STATE_UNKNOWN: - $text = $translate ? mt('monitoring', 'unknown') : 'unknown'; + $text = $translate ? mt('monitoring', 'UNKNOWN') : 'unknown'; break; case self::STATE_PENDING: - $text = $translate ? mt('monitoring', 'pending') : 'pending'; + $text = $translate ? mt('monitoring', 'PENDING') : 'pending'; break; default: throw new InvalidArgumentException('Invalid service state \'%s\'', $state); From f16aac515400a2521cae3179737be462261d80a9 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Thu, 22 Jan 2015 15:20:19 +0100 Subject: [PATCH 0332/2920] Security: Sort permissions only if not empty --- library/Icinga/User.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library/Icinga/User.php b/library/Icinga/User.php index 659767644..db80c929a 100644 --- a/library/Icinga/User.php +++ b/library/Icinga/User.php @@ -197,8 +197,8 @@ class User */ public function setPermissions(array $permissions) { - natcasesort($permissions); if (! empty($permissions)) { + natcasesort($permissions); $this->permissions = array_combine($permissions, $permissions); } return $this; From 9b7e75a616e753e25cda033c86fab44e1281d7e9 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Thu, 22 Jan 2015 15:20:38 +0100 Subject: [PATCH 0333/2920] Security: Temporary grant all permissions We'll introduce permissions and restrictions in the next hours. Because our web setup does not configure permissions yet, all permissions are granted for all users from now on. --- library/Icinga/Web/Controller/ActionController.php | 1 + 1 file changed, 1 insertion(+) diff --git a/library/Icinga/Web/Controller/ActionController.php b/library/Icinga/Web/Controller/ActionController.php index 013f31099..cc4af4432 100644 --- a/library/Icinga/Web/Controller/ActionController.php +++ b/library/Icinga/Web/Controller/ActionController.php @@ -176,6 +176,7 @@ class ActionController extends Zend_Controller_Action */ public function assertPermission($name) { + return; if (! $this->Auth()->hasPermission($name)) { // TODO: Shall this be an Auth Exception? Or a 404? throw new IcingaException( From 44718e50126e8d785416feb878e24a0a8aa75355 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Thu, 22 Jan 2015 15:22:20 +0100 Subject: [PATCH 0334/2920] Security: Require permissions for executing common host commands --- .../application/controllers/HostController.php | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/modules/monitoring/application/controllers/HostController.php b/modules/monitoring/application/controllers/HostController.php index ab62c3756..5daae0f23 100644 --- a/modules/monitoring/application/controllers/HostController.php +++ b/modules/monitoring/application/controllers/HostController.php @@ -47,6 +47,8 @@ class Monitoring_HostController extends MonitoredObjectController */ public function acknowledgeProblemAction() { + $this->assertPermission('monitoring/command/acknowledge-problem'); + $this->view->title = $this->translate('Acknowledge Host Problem'); $this->handleCommandForm(new AcknowledgeProblemCommandForm()); } @@ -56,6 +58,8 @@ class Monitoring_HostController extends MonitoredObjectController */ public function addCommentAction() { + $this->assertPermission('monitoring/command/add-comment'); + $this->view->title = $this->translate('Add Host Comment'); $this->handleCommandForm(new AddCommentCommandForm()); } @@ -65,6 +69,8 @@ class Monitoring_HostController extends MonitoredObjectController */ public function rescheduleCheckAction() { + $this->assertPermission('monitoring/command/schedule-check'); + $this->view->title = $this->translate('Reschedule Host Check'); $this->handleCommandForm(new ScheduleHostCheckCommandForm()); } @@ -74,6 +80,8 @@ class Monitoring_HostController extends MonitoredObjectController */ public function scheduleDowntimeAction() { + $this->assertPermission('monitoring/command/schedule-downtime'); + $this->view->title = $this->translate('Schedule Host Downtime'); $this->handleCommandForm(new ScheduleHostDowntimeCommandForm()); } @@ -83,6 +91,8 @@ class Monitoring_HostController extends MonitoredObjectController */ public function processCheckResultAction() { + $this->assertPermission('monitoring/command/process-check-result'); + $this->view->title = $this->translate('Submit Passive Host Check Result'); $this->handleCommandForm(new ProcessCheckResultCommandForm()); } From 3d7b375ab4f09ac810db5521f13a60b7072ac9f5 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Thu, 22 Jan 2015 15:23:02 +0100 Subject: [PATCH 0335/2920] Security: Require permissions for executing common service commands --- .../application/controllers/ServiceController.php | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/modules/monitoring/application/controllers/ServiceController.php b/modules/monitoring/application/controllers/ServiceController.php index 06417cc6e..522a02efc 100644 --- a/modules/monitoring/application/controllers/ServiceController.php +++ b/modules/monitoring/application/controllers/ServiceController.php @@ -47,6 +47,8 @@ class Monitoring_ServiceController extends MonitoredObjectController */ public function acknowledgeProblemAction() { + $this->assertPermission('monitoring/command/acknowledge-problem'); + $this->view->title = $this->translate('Acknowledge Service Problem'); $this->handleCommandForm(new AcknowledgeProblemCommandForm()); } @@ -56,6 +58,8 @@ class Monitoring_ServiceController extends MonitoredObjectController */ public function addCommentAction() { + $this->assertPermission('monitoring/command/add-comment'); + $this->view->title = $this->translate('Add Service Comment'); $this->handleCommandForm(new AddCommentCommandForm()); } @@ -65,6 +69,8 @@ class Monitoring_ServiceController extends MonitoredObjectController */ public function rescheduleCheckAction() { + $this->assertPermission('monitoring/command/schedule-check'); + $this->view->title = $this->translate('Reschedule Service Check'); $this->handleCommandForm(new ScheduleServiceCheckCommandForm()); } @@ -74,6 +80,8 @@ class Monitoring_ServiceController extends MonitoredObjectController */ public function scheduleDowntimeAction() { + $this->assertPermission('monitoring/command/schedule-downtime'); + $this->view->title = $this->translate('Schedule Service Downtime'); $this->handleCommandForm(new ScheduleServiceDowntimeCommandForm()); } @@ -83,6 +91,8 @@ class Monitoring_ServiceController extends MonitoredObjectController */ public function processCheckResultAction() { + $this->assertPermission('monitoring/command/process-check-result'); + $this->view->title = $this->translate('Submit Passive Service Check Result'); $this->handleCommandForm(new ProcessCheckResultCommandForm()); } From 0f13c0428c4639137176a0768f327cacde13f626 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Thu, 22 Jan 2015 15:47:16 +0100 Subject: [PATCH 0336/2920] Controller: Introduce method assertHttpMethod() We have actions where only certain HTTP methods, e.g. POST are allowed but they are not restricted yet. Controller::assertHttpMethod() takes a number of allowed HTTP methods and responds with HTTP 405 in case the current request's method is not one of the given methods. --- .../Icinga/Web/Controller/ActionController.php | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/library/Icinga/Web/Controller/ActionController.php b/library/Icinga/Web/Controller/ActionController.php index cc4af4432..ba75d366f 100644 --- a/library/Icinga/Web/Controller/ActionController.php +++ b/library/Icinga/Web/Controller/ActionController.php @@ -146,6 +146,22 @@ class ActionController extends Zend_Controller_Action return $this; } + /** + * Respond with HTTP 405 if the current request's method is not one of the given methods + * + * @param string $httpMethod Unlimited number of allowed HTTP methods + * + * @throws \Zend_Controller_Action_Exception If the request method is not one of the given methods + */ + public function assertHttpMethod($httpMethod) + { + $httpMethods = array_flip(array_map('strtoupper', func_get_args())); + if (! isset($httpMethods[$this->getRequest()->getMethod()])) { + $this->getResponse()->setHeader('Allow', implode(', ', array_keys($httpMethods))); + throw new \Zend_Controller_Action_Exception($this->translate('Method Not Allowed'), 405); + } + } + /** * Return restriction information for an eventually authenticated user * From ba7818db5f70c96c57c88411ac2998f40b81921c Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Thu, 22 Jan 2015 15:49:40 +0100 Subject: [PATCH 0337/2920] monitoring: Restrict delete downtime and delete comment to HTTP POST --- .../Web/Controller/MonitoredObjectController.php | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/modules/monitoring/library/Monitoring/Web/Controller/MonitoredObjectController.php b/modules/monitoring/library/Monitoring/Web/Controller/MonitoredObjectController.php index 94dbe3f10..c3b08a3d4 100644 --- a/modules/monitoring/library/Monitoring/Web/Controller/MonitoredObjectController.php +++ b/modules/monitoring/library/Monitoring/Web/Controller/MonitoredObjectController.php @@ -143,12 +143,7 @@ abstract class MonitoredObjectController extends Controller */ public function removeCommentAction() { - /* - * TODO(el): This is here because monitoring/list/comments has buttons to remove comments. Because of the nature - * of an action, the form is accessible via GET which does not make much sense because the form requires - * us to populate the ID of the comment which is to be deleted. We may introduce a combo box for choosing - * the comment ID on GET or deny GET access. - */ + $this->assertHttpMethod('POST'); $this->handleCommandForm(new DeleteCommentCommandForm()); } @@ -157,12 +152,7 @@ abstract class MonitoredObjectController extends Controller */ public function deleteDowntimeAction() { - /* - * TODO(el): This is here because monitoring/list/downtimes has buttons to remove comments. Because of the - * nature of an action, the form is accessible via GET which does not make much sense because the form requires - * us to populate the ID of the downtime which is to be deleted. We may introduce a combo box for choosing - * the downtime ID on GET or deny GET access. - */ + $this->assertHttpMethod('POST'); $this->handleCommandForm(new DeleteDowntimeCommandForm()); } From 251030e1d8e10a829bb65508227cd864b13b101e Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Thu, 22 Jan 2015 16:03:22 +0100 Subject: [PATCH 0338/2920] monitoring: Rename remove-downtime to delete-downtime --- .../application/views/scripts/list/comments.phtml | 4 ++-- .../Monitoring/Web/Controller/MonitoredObjectController.php | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/modules/monitoring/application/views/scripts/list/comments.phtml b/modules/monitoring/application/views/scripts/list/comments.phtml index 29fc76d49..98daceecd 100644 --- a/modules/monitoring/application/views/scripts/list/comments.phtml +++ b/modules/monitoring/application/views/scripts/list/comments.phtml @@ -80,9 +80,9 @@ $delCommentForm = clone $delCommentForm; $delCommentForm->populate(array('comment_id' => $comment->id, 'redirect' => $this->url)); if ($comment->objecttype === 'host') { - $delCommentForm->setAction($this->url('monitoring/host/remove-comment', array('host' => $comment->host))); + $delCommentForm->setAction($this->url('monitoring/host/delete-comment', array('host' => $comment->host))); } else { - $delCommentForm->setAction($this->url('monitoring/service/remove-comment', array('host' => $comment->host, 'service' => $comment->service))); + $delCommentForm->setAction($this->url('monitoring/service/delete-comment', array('host' => $comment->host, 'service' => $comment->service))); } echo $delCommentForm; ?> diff --git a/modules/monitoring/library/Monitoring/Web/Controller/MonitoredObjectController.php b/modules/monitoring/library/Monitoring/Web/Controller/MonitoredObjectController.php index c3b08a3d4..a89a3fc49 100644 --- a/modules/monitoring/library/Monitoring/Web/Controller/MonitoredObjectController.php +++ b/modules/monitoring/library/Monitoring/Web/Controller/MonitoredObjectController.php @@ -139,16 +139,16 @@ abstract class MonitoredObjectController extends Controller abstract public function scheduleDowntimeAction(); /** - * Remove a comment + * Delete a comment */ - public function removeCommentAction() + public function deleteCommentAction() { $this->assertHttpMethod('POST'); $this->handleCommandForm(new DeleteCommentCommandForm()); } /** - * Remove a downtime + * Delete a downtime */ public function deleteDowntimeAction() { From 9a59f3529c927516e7eaf1c26839d49a4e2a61bb Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Thu, 22 Jan 2015 16:56:00 +0100 Subject: [PATCH 0339/2920] monitoring: Group permissions by topic where it makes sense, i.e. downtime and comment --- .../controllers/HostController.php | 4 +- .../controllers/ServiceController.php | 4 +- modules/monitoring/configuration.php | 40 +++++++++---------- 3 files changed, 24 insertions(+), 24 deletions(-) diff --git a/modules/monitoring/application/controllers/HostController.php b/modules/monitoring/application/controllers/HostController.php index 5daae0f23..d01335734 100644 --- a/modules/monitoring/application/controllers/HostController.php +++ b/modules/monitoring/application/controllers/HostController.php @@ -58,7 +58,7 @@ class Monitoring_HostController extends MonitoredObjectController */ public function addCommentAction() { - $this->assertPermission('monitoring/command/add-comment'); + $this->assertPermission('monitoring/command/comment/add'); $this->view->title = $this->translate('Add Host Comment'); $this->handleCommandForm(new AddCommentCommandForm()); @@ -80,7 +80,7 @@ class Monitoring_HostController extends MonitoredObjectController */ public function scheduleDowntimeAction() { - $this->assertPermission('monitoring/command/schedule-downtime'); + $this->assertPermission('monitoring/command/downtime/schedule'); $this->view->title = $this->translate('Schedule Host Downtime'); $this->handleCommandForm(new ScheduleHostDowntimeCommandForm()); diff --git a/modules/monitoring/application/controllers/ServiceController.php b/modules/monitoring/application/controllers/ServiceController.php index 522a02efc..c05683400 100644 --- a/modules/monitoring/application/controllers/ServiceController.php +++ b/modules/monitoring/application/controllers/ServiceController.php @@ -58,7 +58,7 @@ class Monitoring_ServiceController extends MonitoredObjectController */ public function addCommentAction() { - $this->assertPermission('monitoring/command/add-comment'); + $this->assertPermission('monitoring/command/comment/add'); $this->view->title = $this->translate('Add Service Comment'); $this->handleCommandForm(new AddCommentCommandForm()); @@ -80,7 +80,7 @@ class Monitoring_ServiceController extends MonitoredObjectController */ public function scheduleDowntimeAction() { - $this->assertPermission('monitoring/command/schedule-downtime'); + $this->assertPermission('monitoring/command/downtime/schedule'); $this->view->title = $this->translate('Schedule Service Downtime'); $this->handleCommandForm(new ScheduleServiceDowntimeCommandForm()); diff --git a/modules/monitoring/configuration.php b/modules/monitoring/configuration.php index 432cb36ba..ed94f1545 100644 --- a/modules/monitoring/configuration.php +++ b/modules/monitoring/configuration.php @@ -8,41 +8,41 @@ $this->providePermission( 'monitoring/command/*', $this->translate('Allow all commands') ); -$this->providePermission( - 'monitoring/command/schedule*', - $this->translate('Allow scheduling checks and downtimes') -); $this->providePermission( 'monitoring/command/schedule-check', $this->translate('Allow scheduling host and service checks') ); -$this->providePermission( - 'monitoring/command/schedule-downtime', - $this->translate('Allow scheduling host and service downtimes') -); $this->providePermission( 'monitoring/command/acknowledge-problem', $this->translate('Allow acknowledging host and service problems') ); -$this->providePermission( - 'monitoring/command/add-comment', - $this->translate('Allow commenting on hosts and services') -); -$this->providePermission( - 'monitoring/command/remove*', - $this->translate('Allow removing problem acknowledgements, host and service comments and downtimes') -); $this->providePermission( 'monitoring/command/remove-acknowledgement', $this->translate('Allow removing problem acknowledgements') ); $this->providePermission( - 'monitoring/command/remove-comment', - $this->translate('Allow removing host and service comments') + 'monitoring/command/comment/*', + $this->translate('Allow adding and deleting host and service comments') ); $this->providePermission( - 'monitoring/command/remove-downtime', - $this->translate('Allow removing host and service downtimes') + 'monitoring/command/comment/add', + $this->translate('Allow commenting on hosts and services') +); +$this->providePermission( + 'monitoring/command/comment/delete', + $this->translate('Allow deleting host and service comments') +); +$this->providePermission( + 'monitoring/command/downtime/*', + $this->translate('Allow scheduling and deleting host and service downtimes') +); +$this->providePermission( + 'monitoring/command/downtime/schedule', + $this->translate('Allow scheduling host and service downtimes') +); +$this->providePermission( + 'monitoring/command/downtime/delete', + $this->translate('Allow deleting host and service downtimes') ); $this->providePermission( 'monitoring/command/process-check-result', From ef0a7c0e771f4e173ddec23f58dea31637d5a432 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Thu, 22 Jan 2015 17:11:53 +0100 Subject: [PATCH 0340/2920] Revert "Security: Temporary grant all permissions" This reverts commit 9b7e75a616e753e25cda033c86fab44e1281d7e9. Patching function hasPermission is not enough. A fix will follow. --- library/Icinga/Web/Controller/ActionController.php | 1 - 1 file changed, 1 deletion(-) diff --git a/library/Icinga/Web/Controller/ActionController.php b/library/Icinga/Web/Controller/ActionController.php index ba75d366f..64438fc1d 100644 --- a/library/Icinga/Web/Controller/ActionController.php +++ b/library/Icinga/Web/Controller/ActionController.php @@ -192,7 +192,6 @@ class ActionController extends Zend_Controller_Action */ public function assertPermission($name) { - return; if (! $this->Auth()->hasPermission($name)) { // TODO: Shall this be an Auth Exception? Or a 404? throw new IcingaException( From 44de790cc9d450370193e8e16e5ddb63dfdd03d5 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Thu, 22 Jan 2015 17:12:49 +0100 Subject: [PATCH 0341/2920] Security: Temporary grant all permissions --- library/Icinga/Authentication/Manager.php | 1 + 1 file changed, 1 insertion(+) diff --git a/library/Icinga/Authentication/Manager.php b/library/Icinga/Authentication/Manager.php index 0a9b40981..12269d98e 100644 --- a/library/Icinga/Authentication/Manager.php +++ b/library/Icinga/Authentication/Manager.php @@ -165,6 +165,7 @@ class Manager */ public function hasPermission($permission) { + return true; if (! $this->isAuthenticated()) { return false; } From a09ba158597798e862c2505f3eecd5761cde7427 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Thu, 22 Jan 2015 17:13:35 +0100 Subject: [PATCH 0342/2920] monitoring/security: Hide 'Check Now' action if user lacks the respective permission --- .../scripts/show/components/checkstatistics.phtml | 4 +++- .../Web/Controller/MonitoredObjectController.php | 13 ++++++++----- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/modules/monitoring/application/views/scripts/show/components/checkstatistics.phtml b/modules/monitoring/application/views/scripts/show/components/checkstatistics.phtml index 50b40cdcc..e8c295298 100644 --- a/modules/monitoring/application/views/scripts/show/components/checkstatistics.phtml +++ b/modules/monitoring/application/views/scripts/show/components/checkstatistics.phtml @@ -23,7 +23,9 @@ if ($object->getType() === $object::TYPE_HOST) {
    translate('Last check') ?> - + timeSince($object->last_check) ?>
    translate('Acknowledged') ?> + +
    - + diff --git a/modules/monitoring/application/views/scripts/show/components/downtime.phtml b/modules/monitoring/application/views/scripts/show/components/downtime.phtml index e9d2cc5b3..37eeef14b 100644 --- a/modules/monitoring/application/views/scripts/show/components/downtime.phtml +++ b/modules/monitoring/application/views/scripts/show/components/downtime.phtml @@ -34,7 +34,7 @@ foreach ($object->downtimes as $downtime) { // Ticket hook sample - $text = $this->tickets ? preg_replace_callback( + $commentText = $this->tickets ? preg_replace_callback( $this->tickets->getPattern(), array($this->tickets, 'createLink'), $this->escape($downtime->comment) @@ -66,7 +66,7 @@ foreach ($object->downtimes as $downtime) {
    - (type) ?>): + populate(array('comment_id' => $comment->id)); + echo $form; + } ?> + (type) ?>): ', $text) ?> diff --git a/modules/monitoring/library/Monitoring/Web/Controller/MonitoredObjectController.php b/modules/monitoring/library/Monitoring/Web/Controller/MonitoredObjectController.php index cb87d22ad..8cbea2d37 100644 --- a/modules/monitoring/library/Monitoring/Web/Controller/MonitoredObjectController.php +++ b/modules/monitoring/library/Monitoring/Web/Controller/MonitoredObjectController.php @@ -72,7 +72,7 @@ abstract class MonitoredObjectController extends Controller } } } - if (count($this->object->comments) > 0) { + if (count($this->object->comments) > 0 && $auth->hasPermission('monitoring/command/comment/delete')) { $delCommentForm = new DeleteCommentCommandForm(); $delCommentForm ->setObjects($this->object) From 5967d5fe0416f673f953e49668725d7cd79cde75 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Thu, 22 Jan 2015 17:35:34 +0100 Subject: [PATCH 0346/2920] monitoring/security: Hide delete downtime action if user lacks the respective permission --- .../views/scripts/show/components/downtime.phtml | 10 ++++++---- .../Web/Controller/MonitoredObjectController.php | 2 +- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/modules/monitoring/application/views/scripts/show/components/downtime.phtml b/modules/monitoring/application/views/scripts/show/components/downtime.phtml index 2cd7147f1..c96d1b287 100644 --- a/modules/monitoring/application/views/scripts/show/components/downtime.phtml +++ b/modules/monitoring/application/views/scripts/show/components/downtime.phtml @@ -33,9 +33,6 @@ foreach ($object->downtimes as $downtime) { $this->escape($downtime->comment) ) : $this->escape($downtime->comment); - $form = clone $delDowntimeForm; - $form->populate(array('downtime_id' => $downtime->id)); - if ((bool) $downtime->is_in_effect) { $state = 'in downtime since ' . $this->timeSince($downtime->start); } else { @@ -54,7 +51,12 @@ foreach ($object->downtimes as $downtime) { + + From bd65f4d50af3d46008bfb63dd32a29f8e5def676 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Fri, 23 Jan 2015 09:18:29 +0100 Subject: [PATCH 0348/2920] monitoring/security: Hide delete comment action in the comments overview if user lacks the respective permission --- .../monitoring/application/controllers/ListController.php | 5 ++++- .../monitoring/application/views/scripts/list/comments.phtml | 2 ++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/modules/monitoring/application/controllers/ListController.php b/modules/monitoring/application/controllers/ListController.php index 3ed9c4e62..cb334b421 100644 --- a/modules/monitoring/application/controllers/ListController.php +++ b/modules/monitoring/application/controllers/ListController.php @@ -484,7 +484,10 @@ class Monitoring_ListController extends Controller 'comment_expiration' => $this->translate('Expiration') ) ); - $this->view->delCommentForm = new DeleteCommentCommandForm(); + + if ($this->Auth()->hasPermission('monitoring/command/comment/delete')) { + $this->view->delCommentForm = new DeleteCommentCommandForm(); + } } public function servicegroupsAction() diff --git a/modules/monitoring/application/views/scripts/list/comments.phtml b/modules/monitoring/application/views/scripts/list/comments.phtml index 98daceecd..857017b4d 100644 --- a/modules/monitoring/application/views/scripts/list/comments.phtml +++ b/modules/monitoring/application/views/scripts/list/comments.phtml @@ -75,6 +75,7 @@ date('H:i', $comment->expiration) ) : $this->translate('This comment does not expire.'); ?> + + From 6da3cb84038a658f9fccce17de38677b952407e5 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Fri, 23 Jan 2015 09:36:05 +0100 Subject: [PATCH 0349/2920] lib: Reorder auth related functions in the ActionController --- .../Web/Controller/ActionController.php | 86 +++++++++++-------- 1 file changed, 49 insertions(+), 37 deletions(-) diff --git a/library/Icinga/Web/Controller/ActionController.php b/library/Icinga/Web/Controller/ActionController.php index 64438fc1d..78fcaf7bf 100644 --- a/library/Icinga/Web/Controller/ActionController.php +++ b/library/Icinga/Web/Controller/ActionController.php @@ -5,7 +5,7 @@ namespace Icinga\Web\Controller; use Exception; -use Icinga\Authentication\Manager as AuthManager; +use Icinga\Authentication\Manager; use Icinga\Application\Benchmark; use Icinga\Application\Config; use Icinga\Exception\IcingaException; @@ -47,6 +47,11 @@ class ActionController extends Zend_Controller_Action private $xhrLayout = 'inline'; + /** + * Authentication manager + * + * @type \Icinga\Authentication\Manager|null + */ private $auth; protected $params; @@ -101,6 +106,49 @@ class ActionController extends Zend_Controller_Action { } + + /** + * Get the authentication manager + * + * @return Manager + */ + public function Auth() + { + if ($this->auth === null) { + $this->auth = Manager::getInstance(); + } + return $this->auth; + } + + /** + * Whether the current user has the given permission + * + * @param string $permission Name of the permission + * + * @return bool + */ + public function hasPermission($permission) + { + return $this->Auth()->hasPermission($permission); + } + + /** + * Throw an exception if user lacks the given permission + * + * @param string $name Permission name + * @throws Exception + */ + public function assertPermission($name) + { + if (! $this->Auth()->hasPermission($name)) { + // TODO: Shall this be an Auth Exception? Or a 404? + throw new IcingaException( + 'Auth error, no permission for "%s"', + $name + ); + } + } + public function Config($file = null) { if ($file === null) { @@ -110,14 +158,6 @@ class ActionController extends Zend_Controller_Action } } - public function Auth() - { - if ($this->auth === null) { - $this->auth = AuthManager::getInstance(); - } - return $this->auth; - } - public function Window() { if ($this->window === null) { @@ -173,34 +213,6 @@ class ActionController extends Zend_Controller_Action return $this->Auth()->getRestrictions($name); } - /** - * Whether the user currently authenticated has the given permission - * - * @param string $name Permission name - * @return bool - */ - public function hasPermission($name) - { - return $this->Auth()->hasPermission($name); - } - - /** - * Throws an exception if user lacks the given permission - * - * @param string $name Permission name - * @throws Exception - */ - public function assertPermission($name) - { - if (! $this->Auth()->hasPermission($name)) { - // TODO: Shall this be an Auth Exception? Or a 404? - throw new IcingaException( - 'Auth error, no permission for "%s"', - $name - ); - } - } - /** * Check whether the controller requires a login. That is when the controller requires authentication and the * user is currently not authenticated From cd8822ceff7be9acc8ba7b93137d8231ce491f37 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Fri, 23 Jan 2015 09:36:45 +0100 Subject: [PATCH 0350/2920] lib: Add View::hasPermission() --- library/Icinga/Web/View.php | 37 +++++++++++++++++++++++++++++++++++-- 1 file changed, 35 insertions(+), 2 deletions(-) diff --git a/library/Icinga/Web/View.php b/library/Icinga/Web/View.php index 7a954934a..2122662ac 100644 --- a/library/Icinga/Web/View.php +++ b/library/Icinga/Web/View.php @@ -4,10 +4,11 @@ namespace Icinga\Web; +use Closure; +use Zend_View_Abstract; +use Icinga\Authentication\Manager; use Icinga\Exception\ProgrammingError; use Icinga\Util\Translator; -use Zend_View_Abstract; -use Closure; /** * Icinga view @@ -36,6 +37,13 @@ class View extends Zend_View_Abstract */ private $helperFunctions = array(); + /** + * Authentication manager + * + * @type \Icinga\Authentication\Manager|null + */ + private $auth; + /** * Create a new view object * @@ -154,6 +162,31 @@ class View extends Zend_View_Abstract } } + /** + * Get the authentication manager + * + * @return Manager + */ + public function Auth() + { + if ($this->auth === null) { + $this->auth = Manager::getInstance(); + } + return $this->auth; + } + + /** + * Whether the current user has the given permission + * + * @param string $permission Name of the permission + * + * @return bool + */ + public function hasPermission($permission) + { + return $this->Auth()->hasPermission($permission); + } + /** * Use to include the view script in a scope that only allows public * members. From 67be1b329b88ffa27244314a3dcff6d3ed69a9c7 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Fri, 23 Jan 2015 09:41:06 +0100 Subject: [PATCH 0351/2920] monitoring/security: Hide 'Add comment' link if user lacks the respective permission --- .../views/scripts/show/components/comments.phtml | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/modules/monitoring/application/views/scripts/show/components/comments.phtml b/modules/monitoring/application/views/scripts/show/components/comments.phtml index d20cec0c2..e128f8320 100644 --- a/modules/monitoring/application/views/scripts/show/components/comments.phtml +++ b/modules/monitoring/application/views/scripts/show/components/comments.phtml @@ -3,7 +3,7 @@ @@ -43,9 +49,9 @@ foreach ($object->comments as $comment) { From f47dae109283387144020ddd0ec37cff641c5dfb Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Fri, 23 Jan 2015 09:43:16 +0100 Subject: [PATCH 0352/2920] monitoring/security: Hide 'Schedule downtime' link if user lacks the respective permission --- .../scripts/show/components/downtime.phtml | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/modules/monitoring/application/views/scripts/show/components/downtime.phtml b/modules/monitoring/application/views/scripts/show/components/downtime.phtml index c96d1b287..e9d2cc5b3 100644 --- a/modules/monitoring/application/views/scripts/show/components/downtime.phtml +++ b/modules/monitoring/application/views/scripts/show/components/downtime.phtml @@ -3,7 +3,7 @@ @@ -52,9 +59,9 @@ foreach ($object->downtimes as $downtime) { @@ -66,4 +73,4 @@ foreach ($object->downtimes as $downtime) { - + From d07e1329e873edba3c490eda3f1bdbbce6e5328d Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Fri, 23 Jan 2015 09:45:43 +0100 Subject: [PATCH 0353/2920] monitoring: Use nl2br instead of str_replace for downtime comment and comment text --- .../views/scripts/show/components/comments.phtml | 6 +++--- .../views/scripts/show/components/downtime.phtml | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/modules/monitoring/application/views/scripts/show/components/comments.phtml b/modules/monitoring/application/views/scripts/show/components/comments.phtml index e128f8320..104f8176b 100644 --- a/modules/monitoring/application/views/scripts/show/components/comments.phtml +++ b/modules/monitoring/application/views/scripts/show/components/comments.phtml @@ -34,7 +34,7 @@ foreach ($object->comments as $comment) { // Ticket hook sample - $text = $this->tickets ? preg_replace_callback( + $commentText = $this->tickets ? preg_replace_callback( $this->tickets->getPattern(), array($this->tickets, 'createLink'), $this->escape($comment->comment) @@ -56,11 +56,11 @@ foreach ($object->comments as $comment) { (type) ?>):
    - + populate(array('downtime_id' => $downtime->id)); + echo $form; + } ?> + ', $text) ?> diff --git a/modules/monitoring/library/Monitoring/Web/Controller/MonitoredObjectController.php b/modules/monitoring/library/Monitoring/Web/Controller/MonitoredObjectController.php index 8cbea2d37..5de11e1e2 100644 --- a/modules/monitoring/library/Monitoring/Web/Controller/MonitoredObjectController.php +++ b/modules/monitoring/library/Monitoring/Web/Controller/MonitoredObjectController.php @@ -79,7 +79,7 @@ abstract class MonitoredObjectController extends Controller ->handleRequest(); $this->view->delCommentForm = $delCommentForm; } - if (count($this->object->downtimes > 0)) { + if (count($this->object->downtimes > 0) && $auth->hasPermission('monitoring/command/downtime/delete')) { $delDowntimeForm = new DeleteDowntimeCommandForm(); $delDowntimeForm ->setObjects($this->object) From ac5ac10feb2077735a1c19dcfd2bff85e7b37da5 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Fri, 23 Jan 2015 09:16:30 +0100 Subject: [PATCH 0347/2920] monitoring/security: Hide delete downtime action in the downtimes overview if user lacks the respective permission --- .../monitoring/application/controllers/ListController.php | 5 ++++- .../application/views/scripts/list/downtimes.phtml | 2 ++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/modules/monitoring/application/controllers/ListController.php b/modules/monitoring/application/controllers/ListController.php index f5afc9a24..3ed9c4e62 100644 --- a/modules/monitoring/application/controllers/ListController.php +++ b/modules/monitoring/application/controllers/ListController.php @@ -306,7 +306,10 @@ class Monitoring_ListController extends Controller )); $this->view->downtimes = $query->paginate(); - $this->view->delDowntimeForm = new DeleteDowntimeCommandForm(); + + if ($this->Auth()->hasPermission('monitoring/command/downtime/delete')) { + $this->view->delDowntimeForm = new DeleteDowntimeCommandForm(); + } } /** diff --git a/modules/monitoring/application/views/scripts/list/downtimes.phtml b/modules/monitoring/application/views/scripts/list/downtimes.phtml index 485782e3c..eaf4b7f8e 100644 --- a/modules/monitoring/application/views/scripts/list/downtimes.phtml +++ b/modules/monitoring/application/views/scripts/list/downtimes.phtml @@ -114,6 +114,7 @@ use Icinga\Module\Monitoring\Object\Service;
    getType() === $object::TYPE_HOST) { $addCommentLink = $this->href( @@ -18,9 +18,15 @@ } ?> + + hasPermission('monitoring/command/comment/add')): ?> - icon('comment') ?> translate('Add comment') ?> + icon('comment') ?> + translate('Add comment') ?> + + +
    populate(array('comment_id' => $comment->id)); - echo $form; + $delCommentForm = clone $delCommentForm; + $delCommentForm->populate(array('comment_id' => $comment->id)); + echo $delCommentForm; } ?> (type) ?>): getType() === $object::TYPE_HOST) { $scheduleDowntimeLink = $this->href( @@ -16,10 +16,17 @@ array('host' => $object->getHost()->getName(), 'service' => $object->getName()) ); } + ?> + + hasPermission('monitoring/command/downtime/schedule')): ?> - icon('plug') ?> translate('Schedule downtime') ?> + icon('plug') ?> + translate('Schedule downtime') ?> + + +
    populate(array('downtime_id' => $downtime->id)); - echo $form; + $delDowntimeForm = clone $delDowntimeForm; + $delDowntimeForm->populate(array('downtime_id' => $downtime->id)); + echo $delDowntimeForm; } ?>
    - ', $text) ?> +
    - ', $text) ?> +
    From af2698b075c1d4330bd364a5259362e0b6795123 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Fri, 23 Jan 2015 10:15:55 +0100 Subject: [PATCH 0354/2920] monitoring: Do not generate 'Schedule downtime' and 'Add comment' links if user lacks the respective permissions --- .../scripts/show/components/comments.phtml | 37 ++++++++----------- .../scripts/show/components/downtime.phtml | 37 ++++++++----------- 2 files changed, 32 insertions(+), 42 deletions(-) diff --git a/modules/monitoring/application/views/scripts/show/components/comments.phtml b/modules/monitoring/application/views/scripts/show/components/comments.phtml index 104f8176b..b967cc67e 100644 --- a/modules/monitoring/application/views/scripts/show/components/comments.phtml +++ b/modules/monitoring/application/views/scripts/show/components/comments.phtml @@ -1,32 +1,27 @@
    translate('Comments') ?> - getType() === $object::TYPE_HOST) { - $addCommentLink = $this->href( - 'monitoring/host/add-comment', - array('host' => $object->getName()) - ); - } else { - $addCommentLink = $this->href( - 'monitoring/service/add-comment', - array('host' => $object->getHost()->getName(), 'service' => $object->getName()) - ); - } - + hasPermission('monitoring/command/comment/add')) { + /** @type \Icinga\Module\Monitoring\Object\MonitoredObject $object */ + if ($object->getType() === $object::TYPE_HOST) { + $addCommentLink = $this->href( + 'monitoring/host/add-comment', + array('host' => $object->getName()) + ); + } else { + $addCommentLink = $this->href( + 'monitoring/service/add-comment', + array('host' => $object->getHost()->getName(), 'service' => $object->getName()) + ); + } ?> - - hasPermission('monitoring/command/comment/add')): ?> icon('comment') ?> translate('Add comment') ?> - - - +
    translate('Downtimes') ?> - getType() === $object::TYPE_HOST) { - $scheduleDowntimeLink = $this->href( - 'monitoring/host/schedule-downtime', - array('host' => $object->getName()) - ); - } else { - $scheduleDowntimeLink = $this->href( - 'monitoring/service/schedule-downtime', - array('host' => $object->getHost()->getName(), 'service' => $object->getName()) - ); - } - + hasPermission('monitoring/command/downtime/schedule')) { + /** @type \Icinga\Module\Monitoring\Object\MonitoredObject $object */ + if ($object->getType() === $object::TYPE_HOST) { + $scheduleDowntimeLink = $this->href( + 'monitoring/host/schedule-downtime', + array('host' => $object->getName()) + ); + } else { + $scheduleDowntimeLink = $this->href( + 'monitoring/service/schedule-downtime', + array('host' => $object->getHost()->getName(), 'service' => $object->getName()) + ); + } ?> - - hasPermission('monitoring/command/downtime/schedule')): ?> icon('plug') ?> translate('Schedule downtime') ?> - - - +
    translate('Next check') ?> + hasPermission('monitoring/command/schedule-check')) { + if ($isService) { + $reschedule = $this->href( + 'monitoring/service/reschedule-check', + array('host' => $object->getHost()->getName(), 'service' => $object->getName()) + ); + } else { + $reschedule = $this->href( + 'monitoring/host/reschedule-check', + array('host' => $object->getName()) + ); + } + ?> - icon('reschedule') ?> translate('Reschedule') ?> + icon('reschedule') ?> + translate('Reschedule') ?> + timeUntil($object->next_check) ?>
    translate('Check attempts') ?> translate('(soft state)') ?> translate('(soft state)') ?> translate('(hard state)') ?> translate('(hard state)') ?>
    translate('Check execution time') ?>check_execution_time ?>s
    translate('Check execution time') ?>check_execution_time ?>s
    translate('Check latency') ?>check_latency ?>s
    translate('Check latency') ?>check_latency ?>s
    translate('Check attempts') ?> translate('(soft state)') ?> (translate('soft state') ?>) translate('(hard state)') ?> (translate('hard state') ?>)
    translate('Command') ?> - escape($command) ?> - passive_checks_enabled): ?> - getType() === $object::TYPE_HOST): ?> - icon('reply'); ?> translate('Process check result'); ?> - - icon('reply'); ?> translate('Process check result'); ?> - - -
    translate('Command') ?> + escape($command) ?> + hasPermission('monitoring/command/schedule-check') && $object->passive_checks_enabled): ?> + getType() === $object::TYPE_HOST) { + $processCheckResult = $this->href( + 'monitoring/host/process-check-result', + array('host' => $object->getName()) + ); + } else { + $processCheckResult = $this->href( + 'monitoring/service/process-check-result', + array('host' => $object->getHost()->getName(), 'service' => $object->getName()) + ); + } ?> + + icon('reply') ?> + translate('Process check result') ?> + + +
    %s%s
    translate('Acknowledged') ?>
    translate('Not acknowledged') ?> - hasPermission('monitoring/command/acknowledge-problem')) { + if ($object->getType() === $object::TYPE_HOST) { + $ackLink = $this->href( + 'monitoring/host/acknowledge-problem', + array('host' => $object->getName()) + ); + } else { + $ackLink = $this->href( + 'monitoring/service/acknowledge-problem', + array('host' => $object->getHost()->getName(), 'service' => $object->getName()) + ); + } ?> icon('ok') ?> translate('Acknowledge') ?> +
    - hostgroup; ?> + escape($h->hostgroup) ?> From e15c085f19bb1fe1e5345adca51b31935c11fd56 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Fri, 23 Jan 2015 11:20:35 +0100 Subject: [PATCH 0362/2920] monitoring: Support selecting host group and service group alias in the StatusQuery refs #8266 --- .../library/Monitoring/Backend/Ido/Query/StatusQuery.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/modules/monitoring/library/Monitoring/Backend/Ido/Query/StatusQuery.php b/modules/monitoring/library/Monitoring/Backend/Ido/Query/StatusQuery.php index 8dc6fa11e..0cc807ac8 100644 --- a/modules/monitoring/library/Monitoring/Backend/Ido/Query/StatusQuery.php +++ b/modules/monitoring/library/Monitoring/Backend/Ido/Query/StatusQuery.php @@ -160,10 +160,12 @@ class StatusQuery extends IdoQuery END' ), 'hostgroups' => array( - 'hostgroup' => 'hgo.name1', + 'hostgroup' => 'hgo.name1 COLLATE latin1_general_ci', + 'hostgroup_alias' => 'hg.alias' ), 'servicegroups' => array( - 'servicegroup' => 'sgo.name1', + 'servicegroup' => 'sgo.name1 COLLATE latin1_general_ci', + 'servicegroup_alias' => 'sg.alias' ), 'services' => array( 'service_host_name' => 'so.name1 COLLATE latin1_general_ci', From 74a0c1e2747add0c99af45f6d3baf176fa0bc3a2 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Fri, 23 Jan 2015 11:21:10 +0100 Subject: [PATCH 0363/2920] monitoring: Support selecting host group and service group alias in the HoststatusQuery refs #8266 --- .../Monitoring/Backend/Ido/Query/HoststatusQuery.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/modules/monitoring/library/Monitoring/Backend/Ido/Query/HoststatusQuery.php b/modules/monitoring/library/Monitoring/Backend/Ido/Query/HoststatusQuery.php index e9903ec86..7cca01d31 100644 --- a/modules/monitoring/library/Monitoring/Backend/Ido/Query/HoststatusQuery.php +++ b/modules/monitoring/library/Monitoring/Backend/Ido/Query/HoststatusQuery.php @@ -84,10 +84,12 @@ class HoststatusQuery extends IdoQuery END' ), 'hostgroups' => array( - 'hostgroup' => 'hgo.name1 COLLATE latin1_general_ci', + 'hostgroup' => 'hgo.name1 COLLATE latin1_general_ci', + 'hostgroup_alias' => 'hg.alias' ), 'servicegroups' => array( - 'servicegroup' => 'sgo.name1 COLLATE latin1_general_ci', + 'servicegroup' => 'sgo.name1 COLLATE latin1_general_ci', + 'servicegroup_alias' => 'sg.alias' ), 'contactgroups' => array( 'contactgroup' => 'contactgroup', From 30eed015ba3022ba9817a8866b9b4c67a2fda692 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Fri, 23 Jan 2015 11:21:29 +0100 Subject: [PATCH 0364/2920] monitoring: Support selecting host group and service group alias in the GroupsummaryQuery refs #8266 --- .../Backend/Ido/Query/GroupsummaryQuery.php | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/modules/monitoring/library/Monitoring/Backend/Ido/Query/GroupsummaryQuery.php b/modules/monitoring/library/Monitoring/Backend/Ido/Query/GroupsummaryQuery.php index de94f3055..62447c7d6 100644 --- a/modules/monitoring/library/Monitoring/Backend/Ido/Query/GroupsummaryQuery.php +++ b/modules/monitoring/library/Monitoring/Backend/Ido/Query/GroupsummaryQuery.php @@ -20,7 +20,8 @@ class GroupSummaryQuery extends IdoQuery 'hosts_down_handled' => 'SUM(CASE WHEN object_type = \'host\' AND state = 1 AND acknowledged + in_downtime != 0 THEN 1 ELSE 0 END)', 'hosts_down_unhandled' => 'SUM(CASE WHEN object_type = \'host\' AND state = 1 AND acknowledged + in_downtime = 0 THEN 1 ELSE 0 END)', 'hosts_pending' => 'SUM(CASE WHEN object_type = \'host\' AND state = 99 THEN 1 ELSE 0 END)', - 'hostgroup' => 'hostgroup' + 'hostgroup' => 'hostgroup', + 'hostgroup_alias' => 'hostgroup_alias' ), 'servicestatussummary' => array( 'services_total' => 'SUM(CASE WHEN object_type = \'service\' THEN 1 ELSE 0 END)', @@ -44,7 +45,8 @@ class GroupSummaryQuery extends IdoQuery 'services_warning_last_state_change_unhandled' => 'MAX(CASE WHEN object_type = \'service\' AND state = 1 AND acknowledged + in_downtime + host_state = 0 THEN state_change ELSE 0 END)', 'services_critical_last_state_change_unhandled' => 'MAX(CASE WHEN object_type = \'service\' AND state = 2 AND acknowledged + in_downtime + host_state = 0 THEN state_change ELSE 0 END)', 'services_unknown_last_state_change_unhandled' => 'MAX(CASE WHEN object_type = \'service\' AND state = 3 AND acknowledged + in_downtime + host_state = 0 THEN state_change ELSE 0 END)', - 'servicegroup' => 'servicegroup' + 'servicegroup' => 'servicegroup', + 'servicegroup_alias' => 'servicegroup_alias' ) ); @@ -52,7 +54,7 @@ class GroupSummaryQuery extends IdoQuery { $columns = array( 'object_type', - 'host_state', + 'host_state' ); // Prepend group column since we'll use columns index 0 later for grouping @@ -61,6 +63,12 @@ class GroupSummaryQuery extends IdoQuery } else { array_unshift($columns, 'hostgroup'); } + if (in_array('hostgroup_alias', $this->desiredColumns)) { + $columns[] = 'hostgroup_alias'; + } + if (in_array('servicegroup_alias', $this->desiredColumns)) { + $columns[] = 'servicegroup_alias'; + } $hosts = $this->createSubQuery( 'Hoststatus', $columns + array( From 42071118afa5661b175c8adb1ce882be7d2cad81 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Fri, 23 Jan 2015 11:22:00 +0100 Subject: [PATCH 0365/2920] monitoring: Select hostgroup_alias in the hostgroups overview refs #8266 --- modules/monitoring/application/controllers/ListController.php | 1 + 1 file changed, 1 insertion(+) diff --git a/modules/monitoring/application/controllers/ListController.php b/modules/monitoring/application/controllers/ListController.php index cb334b421..102f56a33 100644 --- a/modules/monitoring/application/controllers/ListController.php +++ b/modules/monitoring/application/controllers/ListController.php @@ -546,6 +546,7 @@ class Monitoring_ListController extends Controller $this->setAutorefreshInterval(12); $query = $this->backend->select()->from('groupsummary', array( 'hostgroup', + 'hostgroup_alias', 'hosts_up', 'hosts_unreachable_handled', 'hosts_unreachable_unhandled', From 257186fb929341c9816d9ba4450297f2f578fcfd Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Fri, 23 Jan 2015 11:22:35 +0100 Subject: [PATCH 0366/2920] monitoring: Use hostgroup alias for displaying the host group's name in the hostgroups overview refs #8266 --- .../monitoring/application/views/scripts/list/hostgroups.phtml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/monitoring/application/views/scripts/list/hostgroups.phtml b/modules/monitoring/application/views/scripts/list/hostgroups.phtml index 9fae0ac31..cd3e68d7f 100644 --- a/modules/monitoring/application/views/scripts/list/hostgroups.phtml +++ b/modules/monitoring/application/views/scripts/list/hostgroups.phtml @@ -80,7 +80,7 @@ - escape($h->hostgroup) ?> + escape($h->hostgroup_alias) ?> From 9fe720e7154bae1ddcdd4dc895d6bdb5a3122e52 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Fri, 23 Jan 2015 11:23:42 +0100 Subject: [PATCH 0367/2920] monitoring: Escape the service group name in the servicegroups overview --- .../application/views/scripts/list/servicegroups.phtml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/monitoring/application/views/scripts/list/servicegroups.phtml b/modules/monitoring/application/views/scripts/list/servicegroups.phtml index ceb3929c0..91787b7b2 100644 --- a/modules/monitoring/application/views/scripts/list/servicegroups.phtml +++ b/modules/monitoring/application/views/scripts/list/servicegroups.phtml @@ -80,7 +80,7 @@ - servicegroup; ?> + translate($s->servicegroup) ?> From 7e05de1255953c71b109f99f61ab95507421a21b Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Fri, 23 Jan 2015 11:23:59 +0100 Subject: [PATCH 0368/2920] monitoring: Select the service group alias in the servicegroups ovweview refs #8266 --- modules/monitoring/application/controllers/ListController.php | 1 + 1 file changed, 1 insertion(+) diff --git a/modules/monitoring/application/controllers/ListController.php b/modules/monitoring/application/controllers/ListController.php index 102f56a33..9a0cd42a7 100644 --- a/modules/monitoring/application/controllers/ListController.php +++ b/modules/monitoring/application/controllers/ListController.php @@ -499,6 +499,7 @@ class Monitoring_ListController extends Controller $this->setAutorefreshInterval(12); $query = $this->backend->select()->from('groupsummary', array( 'servicegroup', + 'servicegroup_alias', 'hosts_up', 'hosts_unreachable_handled', 'hosts_unreachable_unhandled', From 86ac09d7b198940925535c09e5dd953aafc40599 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Fri, 23 Jan 2015 11:24:39 +0100 Subject: [PATCH 0369/2920] monitoring: Use the service group alias for displaying service group names in the servicegroups overview refs #8266 --- .../application/views/scripts/list/servicegroups.phtml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/monitoring/application/views/scripts/list/servicegroups.phtml b/modules/monitoring/application/views/scripts/list/servicegroups.phtml index 91787b7b2..0e180bfa7 100644 --- a/modules/monitoring/application/views/scripts/list/servicegroups.phtml +++ b/modules/monitoring/application/views/scripts/list/servicegroups.phtml @@ -80,7 +80,7 @@ - translate($s->servicegroup) ?> + translate($s->servicegroup_alias) ?> From c78d4aa0bd75bfefe411e1de7681325795d0c290 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Fri, 23 Jan 2015 13:29:47 +0100 Subject: [PATCH 0370/2920] monitoring/security: Provide permissions for the feature commands --- modules/monitoring/configuration.php | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/modules/monitoring/configuration.php b/modules/monitoring/configuration.php index ed94f1545..6b1fe1cda 100644 --- a/modules/monitoring/configuration.php +++ b/modules/monitoring/configuration.php @@ -1,6 +1,4 @@ providePermission( 'monitoring/command/process-check-result', $this->translate('Allow processing host and service check results') ); +$this->providePermission( + 'monitoring/command/feature/program', + $this->translate('Allow processing commands for toggling features on a program-wide basis') +); +$this->providePermission( + 'monitoring/command/feature/object', + $this->translate('Allow processing commands for toggling features on host and service objects') +); $this->provideRestriction( 'monitoring/filter', From 6284da451e2a3f1fecf8935f04701d889445203c Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Fri, 23 Jan 2015 14:41:14 +0100 Subject: [PATCH 0371/2920] Fix that when chosing to not to store preferences an invalid config is created fixes #8234 --- application/forms/Config/General/ApplicationConfigForm.php | 4 ++-- library/Icinga/Authentication/Manager.php | 5 ++--- modules/setup/application/forms/PreferencesPage.php | 4 ++-- 3 files changed, 6 insertions(+), 7 deletions(-) diff --git a/application/forms/Config/General/ApplicationConfigForm.php b/application/forms/Config/General/ApplicationConfigForm.php index 8f718ccdf..6d00a5b47 100644 --- a/application/forms/Config/General/ApplicationConfigForm.php +++ b/application/forms/Config/General/ApplicationConfigForm.php @@ -48,13 +48,13 @@ class ApplicationConfigForm extends Form 'select', 'preferences_type', array( - 'required' => true, + 'allowEmpty' => true, 'autosubmit' => true, 'label' => $this->translate('User Preference Storage Type'), 'multiOptions' => array( 'ini' => $this->translate('File System (INI Files)'), 'db' => $this->translate('Database'), - 'null' => $this->translate('Don\'t Store Preferences') + '' => $this->translate('Don\'t Store Preferences') ) ) ); diff --git a/library/Icinga/Authentication/Manager.php b/library/Icinga/Authentication/Manager.php index 12269d98e..887c9674d 100644 --- a/library/Icinga/Authentication/Manager.php +++ b/library/Icinga/Authentication/Manager.php @@ -63,11 +63,10 @@ class Manager ); $config = new Config(); } - if ($config->hasSection('preferences')) { - $preferencesConfig = $config->getSection('preferences'); + if ($config->get('preferences', 'type')) { try { $preferencesStore = PreferencesStore::create( - $preferencesConfig, + $config->getSection('preferences'), $user ); $preferences = new Preferences($preferencesStore->load()); diff --git a/modules/setup/application/forms/PreferencesPage.php b/modules/setup/application/forms/PreferencesPage.php index 07e011ee1..1309f59f9 100644 --- a/modules/setup/application/forms/PreferencesPage.php +++ b/modules/setup/application/forms/PreferencesPage.php @@ -66,13 +66,13 @@ class PreferencesPage extends Form if (Platform::hasMysqlSupport() || Platform::hasPostgresqlSupport()) { $storageTypes['db'] = $this->translate('Database'); } - $storageTypes['null'] = $this->translate('Don\'t Store Preferences'); + $storageTypes[''] = $this->translate('Don\'t Store Preferences'); $this->addElement( 'select', 'type', array( - 'required' => true, + 'allowEmpty' => true, 'label' => $this->translate('User Preference Storage Type'), 'multiOptions' => $storageTypes ) From 14a4aaeb776d470ad670151aa609238aa1fb1a5b Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Fri, 23 Jan 2015 15:23:43 +0100 Subject: [PATCH 0372/2920] Revert "Fix that when chosing to not to store preferences an invalid config is created" This reverts commit 6284da451e2a3f1fecf8935f04701d889445203c. --- application/forms/Config/General/ApplicationConfigForm.php | 4 ++-- library/Icinga/Authentication/Manager.php | 5 +++-- modules/setup/application/forms/PreferencesPage.php | 4 ++-- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/application/forms/Config/General/ApplicationConfigForm.php b/application/forms/Config/General/ApplicationConfigForm.php index 6d00a5b47..8f718ccdf 100644 --- a/application/forms/Config/General/ApplicationConfigForm.php +++ b/application/forms/Config/General/ApplicationConfigForm.php @@ -48,13 +48,13 @@ class ApplicationConfigForm extends Form 'select', 'preferences_type', array( - 'allowEmpty' => true, + 'required' => true, 'autosubmit' => true, 'label' => $this->translate('User Preference Storage Type'), 'multiOptions' => array( 'ini' => $this->translate('File System (INI Files)'), 'db' => $this->translate('Database'), - '' => $this->translate('Don\'t Store Preferences') + 'null' => $this->translate('Don\'t Store Preferences') ) ) ); diff --git a/library/Icinga/Authentication/Manager.php b/library/Icinga/Authentication/Manager.php index 887c9674d..12269d98e 100644 --- a/library/Icinga/Authentication/Manager.php +++ b/library/Icinga/Authentication/Manager.php @@ -63,10 +63,11 @@ class Manager ); $config = new Config(); } - if ($config->get('preferences', 'type')) { + if ($config->hasSection('preferences')) { + $preferencesConfig = $config->getSection('preferences'); try { $preferencesStore = PreferencesStore::create( - $config->getSection('preferences'), + $preferencesConfig, $user ); $preferences = new Preferences($preferencesStore->load()); diff --git a/modules/setup/application/forms/PreferencesPage.php b/modules/setup/application/forms/PreferencesPage.php index 1309f59f9..07e011ee1 100644 --- a/modules/setup/application/forms/PreferencesPage.php +++ b/modules/setup/application/forms/PreferencesPage.php @@ -66,13 +66,13 @@ class PreferencesPage extends Form if (Platform::hasMysqlSupport() || Platform::hasPostgresqlSupport()) { $storageTypes['db'] = $this->translate('Database'); } - $storageTypes[''] = $this->translate('Don\'t Store Preferences'); + $storageTypes['null'] = $this->translate('Don\'t Store Preferences'); $this->addElement( 'select', 'type', array( - 'allowEmpty' => true, + 'required' => true, 'label' => $this->translate('User Preference Storage Type'), 'multiOptions' => $storageTypes ) From 7500dd9c683600a354c5e85975547b12b73585c7 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Fri, 23 Jan 2015 15:16:34 +0100 Subject: [PATCH 0373/2920] Revert "GroupSummary/Postgres: Fix group by in initial join query" This reverts commit f47bc466547e5bfe5d7b666e4af68292da4f16fc. Conflicts: modules/monitoring/library/Monitoring/Backend/Ido/Query/GroupsummaryQuery.php No need to reintroduce group columns. --- .../Monitoring/Backend/Ido/Query/GroupsummaryQuery.php | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/modules/monitoring/library/Monitoring/Backend/Ido/Query/GroupsummaryQuery.php b/modules/monitoring/library/Monitoring/Backend/Ido/Query/GroupsummaryQuery.php index 62447c7d6..14320567f 100644 --- a/modules/monitoring/library/Monitoring/Backend/Ido/Query/GroupsummaryQuery.php +++ b/modules/monitoring/library/Monitoring/Backend/Ido/Query/GroupsummaryQuery.php @@ -100,16 +100,8 @@ class GroupSummaryQuery extends IdoQuery 'severity' => 'service_severity' ) ); - - $groupColumn = 'hostgroup'; - - if (in_array('servicegroup', $this->desiredColumns)) { - $groupColumn = 'servicegroup'; - } - $union = $this->db->select()->union(array($hosts, $services), Zend_Db_Select::SQL_UNION_ALL); - $this->select->from(array('statussummary' => $union), array())->group(array($groupColumn)); - + $this->select->from(array('statussummary' => $union), array())->group(array($columns[0])); $this->joinedVirtualTables = array( 'servicestatussummary' => true, 'hoststatussummary' => true From 7bd42b476fd8d837ad6a5a0ee4255358a53e0dea Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Fri, 23 Jan 2015 15:27:43 +0100 Subject: [PATCH 0374/2920] bootstrap: Load setup module in case the setup token exists The web setup may write the config.ini even if it errors. Thus our bootstrap has to load the setup module whenever the setup.token exists. Another approach would to write the config.ini in our web setup at the very end. --- library/Icinga/Application/ApplicationBootstrap.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/library/Icinga/Application/ApplicationBootstrap.php b/library/Icinga/Application/ApplicationBootstrap.php index 92e97ba39..909431663 100644 --- a/library/Icinga/Application/ApplicationBootstrap.php +++ b/library/Icinga/Application/ApplicationBootstrap.php @@ -401,7 +401,7 @@ abstract class ApplicationBootstrap } /** - * Load the setup module if Icinga Web 2 requires setup + * Load the setup module if Icinga Web 2 requires setup or the setup token exists * * @return $this */ @@ -410,6 +410,9 @@ abstract class ApplicationBootstrap if (! @file_exists($this->config->resolvePath('config.ini'))) { $this->requiresSetup = true; $this->moduleManager->loadModule('setup'); + } elseif ($this->setupTokenExists()) { + // Load setup module but do not require setup + $this->moduleManager->loadModule('setup'); } return $this; } From a07bff490f38dca91288c53a712787d561fe4e46 Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Fri, 23 Jan 2015 15:31:45 +0100 Subject: [PATCH 0375/2920] Fix that the monitoring module's config directory is not being created Forgot to re-add this when reverting a temporary change while adjusting the module installation as part of #8191. --- modules/monitoring/library/Monitoring/MonitoringWizard.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/modules/monitoring/library/Monitoring/MonitoringWizard.php b/modules/monitoring/library/Monitoring/MonitoringWizard.php index f02faa4f3..d7a3671a4 100644 --- a/modules/monitoring/library/Monitoring/MonitoringWizard.php +++ b/modules/monitoring/library/Monitoring/MonitoringWizard.php @@ -4,12 +4,14 @@ namespace Icinga\Module\Monitoring; +use Icinga\Application\Icinga; use Icinga\Web\Form; use Icinga\Web\Wizard; use Icinga\Web\Request; use Icinga\Module\Setup\Setup; use Icinga\Module\Setup\SetupWizard; use Icinga\Module\Setup\Requirements; +use Icinga\Module\Setup\Utils\MakeDirStep; use Icinga\Module\Setup\Forms\SummaryPage; use Icinga\Module\Monitoring\Forms\Setup\WelcomePage; use Icinga\Module\Monitoring\Forms\Setup\BackendPage; @@ -106,6 +108,8 @@ class MonitoringWizard extends Wizard implements SetupWizard $pageData = $this->getPageData(); $setup = new Setup(); + $setup->addStep(new MakeDirStep(array(Icinga::app()->getConfigDir() . '/modules/monitoring'), 2770)); + $setup->addStep( new BackendStep(array( 'backendConfig' => $pageData['setup_monitoring_backend'], From a1fbb3d93702b3980b1c527941447326518cbcdb Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Fri, 23 Jan 2015 15:40:33 +0100 Subject: [PATCH 0376/2920] monitoring: Fix host and service groups overviews when using PostgreSQL fixes #8268 --- .../Backend/Ido/Query/GroupsummaryQuery.php | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/modules/monitoring/library/Monitoring/Backend/Ido/Query/GroupsummaryQuery.php b/modules/monitoring/library/Monitoring/Backend/Ido/Query/GroupsummaryQuery.php index 14320567f..53c1d7ed7 100644 --- a/modules/monitoring/library/Monitoring/Backend/Ido/Query/GroupsummaryQuery.php +++ b/modules/monitoring/library/Monitoring/Backend/Ido/Query/GroupsummaryQuery.php @@ -57,17 +57,14 @@ class GroupSummaryQuery extends IdoQuery 'host_state' ); - // Prepend group column since we'll use columns index 0 later for grouping if (in_array('servicegroup', $this->desiredColumns)) { - array_unshift($columns, 'servicegroup'); - } else { - array_unshift($columns, 'hostgroup'); - } - if (in_array('hostgroup_alias', $this->desiredColumns)) { - $columns[] = 'hostgroup_alias'; - } - if (in_array('servicegroup_alias', $this->desiredColumns)) { + $columns[] = 'servicegroup'; $columns[] = 'servicegroup_alias'; + $groupColumns = array('servicegroup', 'servicegroup_alias'); + } else { + $columns[] = 'hostgroup'; + $columns[] = 'hostgroup_alias'; + $groupColumns = array('hostgroup', 'hostgroup_alias'); } $hosts = $this->createSubQuery( 'Hoststatus', @@ -83,6 +80,7 @@ class GroupSummaryQuery extends IdoQuery $hosts->group(array( 'sgo.name1', 'ho.object_id', + 'sg.alias', 'state', 'acknowledged', 'in_downtime', @@ -101,7 +99,7 @@ class GroupSummaryQuery extends IdoQuery ) ); $union = $this->db->select()->union(array($hosts, $services), Zend_Db_Select::SQL_UNION_ALL); - $this->select->from(array('statussummary' => $union), array())->group(array($columns[0])); + $this->select->from(array('statussummary' => $union), array())->group($groupColumns); $this->joinedVirtualTables = array( 'servicestatussummary' => true, 'hoststatussummary' => true From 910065436b3b95186a3a1ab1c53c45d672cb2e30 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Fri, 23 Jan 2015 15:41:58 +0100 Subject: [PATCH 0377/2920] monitoring: Support hostgroup_alias and servicegroup_alias filter --- .../monitoring/library/Monitoring/DataView/Groupsummary.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/modules/monitoring/library/Monitoring/DataView/Groupsummary.php b/modules/monitoring/library/Monitoring/DataView/Groupsummary.php index 7fe6d2e6d..a4736e47c 100644 --- a/modules/monitoring/library/Monitoring/DataView/Groupsummary.php +++ b/modules/monitoring/library/Monitoring/DataView/Groupsummary.php @@ -15,7 +15,9 @@ class Groupsummary extends DataView { return array( 'servicegroup', + 'servicegroup_alias', 'hostgroup', + 'hostgroup_alias', 'hosts_up', 'hosts_unreachable', 'hosts_unreachable_handled', @@ -47,7 +49,7 @@ class Groupsummary extends DataView 'services_unknown_last_state_change_unhandled' ); } - + public function getSortRules() { return array( From 53a4f10253806d7e78a9899d4141a8843468459e Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Fri, 23 Jan 2015 15:46:51 +0100 Subject: [PATCH 0378/2920] monitoring: Sort host groups and service groups by their alias refs #7843 --- .../controllers/ListController.php | 26 +++++++++++-------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/modules/monitoring/application/controllers/ListController.php b/modules/monitoring/application/controllers/ListController.php index 9a0cd42a7..a9ccb7ee8 100644 --- a/modules/monitoring/application/controllers/ListController.php +++ b/modules/monitoring/application/controllers/ListController.php @@ -523,18 +523,20 @@ class Monitoring_ListController extends Controller 'services_critical_last_state_change_unhandled', 'services_unknown_last_state_change_unhandled', 'services_total' - )); + ))->order('services_severity')->order('servicegroup_alias'); + // TODO(el): Can't default to the sort rules of the data view because it's meant for both host groups and + // service groups. We should separate them. $this->filterQuery($query); $this->view->servicegroups = $query->paginate(); $this->setupSortControl(array( - 'services_severity' => $this->translate('Severity'), - 'servicegroup' => $this->translate('Service Group Name'), - 'services_total' => $this->translate('Total Services'), - 'services_ok' => $this->translate('Services OK'), - 'services_unknown' => $this->translate('Services UNKNOWN'), - 'services_critical' => $this->translate('Services CRITICAL'), - 'services_warning' => $this->translate('Services WARNING'), - 'services_pending' => $this->translate('Services PENDING') + 'services_severity' => $this->translate('Severity'), + 'servicegroup_alias' => $this->translate('Service Group Name'), + 'services_total' => $this->translate('Total Services'), + 'services_ok' => $this->translate('Services OK'), + 'services_unknown' => $this->translate('Services UNKNOWN'), + 'services_critical' => $this->translate('Services CRITICAL'), + 'services_warning' => $this->translate('Services WARNING'), + 'services_pending' => $this->translate('Services PENDING') )); } @@ -571,12 +573,14 @@ class Monitoring_ListController extends Controller 'services_critical_last_state_change_unhandled', 'services_unknown_last_state_change_unhandled', 'services_total' - )); + ))->order('services_severity')->order('hostgroup_alias'); + // TODO(el): Can't default to the sort rules of the data view because it's meant for both host groups and + // service groups. We should separate them. $this->filterQuery($query); $this->view->hostgroups = $query->paginate(); $this->setupSortControl(array( 'services_severity' => $this->translate('Severity'), - 'hostgroup' => $this->translate('Host Group Name'), + 'hostgroup_alias' => $this->translate('Host Group Name'), 'services_total' => $this->translate('Total Services'), 'services_ok' => $this->translate('Services OK'), 'services_unknown' => $this->translate('Services UNKNOWN'), From 5fe5e2239519c89d2f566aff01e40a2e71715c30 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Fri, 23 Jan 2015 16:00:15 +0100 Subject: [PATCH 0379/2920] doc: Support any link having a fragment except http(s) links for linking between headings --- modules/doc/doc/1-module-documentation.md | 8 ++++++++ modules/doc/library/Doc/SectionRenderer.php | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/modules/doc/doc/1-module-documentation.md b/modules/doc/doc/1-module-documentation.md index 968dd32d7..edf20aac2 100644 --- a/modules/doc/doc/1-module-documentation.md +++ b/modules/doc/doc/1-module-documentation.md @@ -36,10 +36,18 @@ For linking between headings, place an anchor where you want to link to, e.g.: # Heading +Please note that anchors have to be unique across all your Markdown documentation files. + Now you can reference the anchor either in the same or **in another** Markdown documentation file, e.g.: This is a link to [Heading](#heading). +Other tools support linking between headings by giving the filename plus the anchor to link to, e.g.: + + This is a link to [About/Heading](1-about.md#heading.md) + +This syntax is also supported in Icinga Web 2. + ## Including Images Images must placed in the `img` directory beneath your module's `public` directory, e.g.: diff --git a/modules/doc/library/Doc/SectionRenderer.php b/modules/doc/library/Doc/SectionRenderer.php index 2fdaf8e90..f923783f6 100644 --- a/modules/doc/library/Doc/SectionRenderer.php +++ b/modules/doc/library/Doc/SectionRenderer.php @@ -232,7 +232,7 @@ class SectionRenderer extends Renderer $html ); $content[] = preg_replace_callback( - '/[^>]*?\s+)?href="#(?P[^"]+)"/', + '/[^>]*?\s+)?href="(?:(?!http:\/\/)[^#]*)#(?P[^"]+)"/', array($callback, 'render'), $html ); From 2a543bb5ae5f5430131894fe3dd7098192977c08 Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Fri, 23 Jan 2015 16:03:29 +0100 Subject: [PATCH 0380/2920] Rename the preference setting `type' to `store' refs #8234 --- application/forms/Config/General/ApplicationConfigForm.php | 6 ++---- library/Icinga/User/Preferences/PreferencesStore.php | 6 +++--- modules/setup/application/forms/PreferencesPage.php | 2 +- modules/setup/library/Setup/Steps/GeneralConfigStep.php | 6 +++--- modules/setup/library/Setup/WebWizard.php | 2 +- 5 files changed, 10 insertions(+), 12 deletions(-) diff --git a/application/forms/Config/General/ApplicationConfigForm.php b/application/forms/Config/General/ApplicationConfigForm.php index 8f718ccdf..f59454ff3 100644 --- a/application/forms/Config/General/ApplicationConfigForm.php +++ b/application/forms/Config/General/ApplicationConfigForm.php @@ -4,10 +4,8 @@ namespace Icinga\Forms\Config\General; -use DateTimeZone; use Icinga\Application\Icinga; use Icinga\Data\ResourceFactory; -use Icinga\Util\Translator; use Icinga\Web\Form; @@ -46,7 +44,7 @@ class ApplicationConfigForm extends Form $this->addElement( 'select', - 'preferences_type', + 'preferences_store', array( 'required' => true, 'autosubmit' => true, @@ -58,7 +56,7 @@ class ApplicationConfigForm extends Form ) ) ); - if (isset($formData['preferences_type']) && $formData['preferences_type'] === 'db') { + if (isset($formData['preferences_store']) && $formData['preferences_store'] === 'db') { $backends = array(); foreach (ResourceFactory::getResourceConfigs()->toArray() as $name => $resource) { if ($resource['type'] === 'db') { diff --git a/library/Icinga/User/Preferences/PreferencesStore.php b/library/Icinga/User/Preferences/PreferencesStore.php index c2cba0c41..a9d9ec033 100644 --- a/library/Icinga/User/Preferences/PreferencesStore.php +++ b/library/Icinga/User/Preferences/PreferencesStore.php @@ -26,7 +26,7 @@ use Icinga\Data\Db\DbConnection; * // Create a INI store * $store = PreferencesStore::create( * new ConfigObject( - * 'type' => 'ini', + * 'store' => 'ini', * 'config_path' => '/path/to/preferences' * ), * $user // Instance of \Icinga\User @@ -117,9 +117,9 @@ abstract class PreferencesStore */ public static function create(ConfigObject $config, User $user) { - if (($type = $config->type) === null) { + if (($type = $config->store) === null) { throw new ConfigurationError( - 'Preferences configuration is missing the type directive' + 'Preferences configuration is missing the store directive' ); } diff --git a/modules/setup/application/forms/PreferencesPage.php b/modules/setup/application/forms/PreferencesPage.php index 07e011ee1..83f036498 100644 --- a/modules/setup/application/forms/PreferencesPage.php +++ b/modules/setup/application/forms/PreferencesPage.php @@ -70,7 +70,7 @@ class PreferencesPage extends Form $this->addElement( 'select', - 'type', + 'store', array( 'required' => true, 'label' => $this->translate('User Preference Storage Type'), diff --git a/modules/setup/library/Setup/Steps/GeneralConfigStep.php b/modules/setup/library/Setup/Steps/GeneralConfigStep.php index ee9e2c581..39c160628 100644 --- a/modules/setup/library/Setup/Steps/GeneralConfigStep.php +++ b/modules/setup/library/Setup/Steps/GeneralConfigStep.php @@ -29,7 +29,7 @@ class GeneralConfigStep extends Step $config[$section][$property] = $value; } - $config['preferences']['type'] = $this->data['preferencesType']; + $config['preferences']['store'] = $this->data['preferencesStore']; if (isset($this->data['preferencesResource'])) { $config['preferences']['resource'] = $this->data['preferencesResource']; } @@ -58,11 +58,11 @@ class GeneralConfigStep extends Step $generalHtml = '' . '
      ' . '
    • ' . sprintf( - $this->data['preferencesType'] === 'ini' ? sprintf( + $this->data['preferencesStore'] === 'ini' ? sprintf( t('Preferences will be stored per user account in INI files at: %s'), Config::resolvePath('preferences') ) : ( - $this->data['preferencesType'] === 'db' ? t('Preferences will be stored using a database.') : ( + $this->data['preferencesStore'] === 'db' ? t('Preferences will be stored using a database.') : ( t('Preferences will not be persisted across browser sessions.') ) ) diff --git a/modules/setup/library/Setup/WebWizard.php b/modules/setup/library/Setup/WebWizard.php index 58c7c6259..d6874ed36 100644 --- a/modules/setup/library/Setup/WebWizard.php +++ b/modules/setup/library/Setup/WebWizard.php @@ -293,7 +293,7 @@ class WebWizard extends Wizard implements SetupWizard $setup->addStep( new GeneralConfigStep(array( 'generalConfig' => $pageData['setup_general_config'], - 'preferencesType' => $pageData['setup_preferences_type']['type'], + 'preferencesStore' => $pageData['setup_preferences_type']['store'], 'preferencesResource' => isset($pageData['setup_db_resource']['name']) ? $pageData['setup_db_resource']['name'] : null From 359336243c4f2aa3b1dceaee91ce723edec6472e Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Fri, 23 Jan 2015 16:04:45 +0100 Subject: [PATCH 0381/2920] Save "none" instead of "null" when choosing to not to store preferences refs #8234 --- application/forms/Config/General/ApplicationConfigForm.php | 2 +- modules/setup/application/forms/PreferencesPage.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/application/forms/Config/General/ApplicationConfigForm.php b/application/forms/Config/General/ApplicationConfigForm.php index f59454ff3..29b7b512e 100644 --- a/application/forms/Config/General/ApplicationConfigForm.php +++ b/application/forms/Config/General/ApplicationConfigForm.php @@ -52,7 +52,7 @@ class ApplicationConfigForm extends Form 'multiOptions' => array( 'ini' => $this->translate('File System (INI Files)'), 'db' => $this->translate('Database'), - 'null' => $this->translate('Don\'t Store Preferences') + 'none' => $this->translate('Don\'t Store Preferences') ) ) ); diff --git a/modules/setup/application/forms/PreferencesPage.php b/modules/setup/application/forms/PreferencesPage.php index 83f036498..211d16fac 100644 --- a/modules/setup/application/forms/PreferencesPage.php +++ b/modules/setup/application/forms/PreferencesPage.php @@ -66,7 +66,7 @@ class PreferencesPage extends Form if (Platform::hasMysqlSupport() || Platform::hasPostgresqlSupport()) { $storageTypes['db'] = $this->translate('Database'); } - $storageTypes['null'] = $this->translate('Don\'t Store Preferences'); + $storageTypes['none'] = $this->translate('Don\'t Store Preferences'); $this->addElement( 'select', From d452f3218d9a74b38f958d24f7e30bf5295fbfaf Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Fri, 23 Jan 2015 16:07:38 +0100 Subject: [PATCH 0382/2920] Use "ini" as preferences store in case preferences are not configured refs #8234 --- application/controllers/PreferenceController.php | 4 ---- library/Icinga/Authentication/Manager.php | 2 +- library/Icinga/User/Preferences/PreferencesStore.php | 8 +------- 3 files changed, 2 insertions(+), 12 deletions(-) diff --git a/application/controllers/PreferenceController.php b/application/controllers/PreferenceController.php index 7acab7c25..c45344fbf 100644 --- a/application/controllers/PreferenceController.php +++ b/application/controllers/PreferenceController.php @@ -7,7 +7,6 @@ use Icinga\Web\Url; use Icinga\Web\Widget\Tab; use Icinga\Application\Config; use Icinga\Forms\PreferenceForm; -use Icinga\Exception\ConfigurationError; use Icinga\User\Preferences\PreferencesStore; /** @@ -40,9 +39,6 @@ class PreferenceController extends BasePreferenceController public function indexAction() { $storeConfig = Config::app()->getSection('preferences'); - if ($storeConfig->isEmpty()) { - throw new ConfigurationError(t('You need to configure how to store preferences first.')); - } $user = $this->getRequest()->getUser(); $form = new PreferenceForm(); diff --git a/library/Icinga/Authentication/Manager.php b/library/Icinga/Authentication/Manager.php index 12269d98e..8aee93c0e 100644 --- a/library/Icinga/Authentication/Manager.php +++ b/library/Icinga/Authentication/Manager.php @@ -63,7 +63,7 @@ class Manager ); $config = new Config(); } - if ($config->hasSection('preferences')) { + if ($config->get('preferences', 'store', 'ini') !== 'none') { $preferencesConfig = $config->getSection('preferences'); try { $preferencesStore = PreferencesStore::create( diff --git a/library/Icinga/User/Preferences/PreferencesStore.php b/library/Icinga/User/Preferences/PreferencesStore.php index a9d9ec033..11454a2f8 100644 --- a/library/Icinga/User/Preferences/PreferencesStore.php +++ b/library/Icinga/User/Preferences/PreferencesStore.php @@ -117,13 +117,7 @@ abstract class PreferencesStore */ public static function create(ConfigObject $config, User $user) { - if (($type = $config->store) === null) { - throw new ConfigurationError( - 'Preferences configuration is missing the store directive' - ); - } - - $type = ucfirst(strtolower($type)); + $type = ucfirst(strtolower($config->get('store', 'ini'))); $storeClass = 'Icinga\\User\\Preferences\\Store\\' . $type . 'Store'; if (!class_exists($storeClass)) { throw new ConfigurationError( From 55c20abddc078156d1f6f95893f880f5fb2ca1f6 Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Fri, 23 Jan 2015 16:19:39 +0100 Subject: [PATCH 0383/2920] Only show the "save to session" button in case preferences store = none refs #8234 --- .../controllers/PreferenceController.php | 4 ++- application/forms/PreferenceForm.php | 28 ++++++++++--------- 2 files changed, 18 insertions(+), 14 deletions(-) diff --git a/application/controllers/PreferenceController.php b/application/controllers/PreferenceController.php index c45344fbf..832f57644 100644 --- a/application/controllers/PreferenceController.php +++ b/application/controllers/PreferenceController.php @@ -43,7 +43,9 @@ class PreferenceController extends BasePreferenceController $user = $this->getRequest()->getUser(); $form = new PreferenceForm(); $form->setPreferences($user->getPreferences()); - $form->setStore(PreferencesStore::create($storeConfig, $user)); + if ($storeConfig->get('store', 'ini') !== 'none') { + $form->setStore(PreferencesStore::create($storeConfig, $user)); + } $form->handleRequest(); $this->view->form = $form; diff --git a/application/forms/PreferenceForm.php b/application/forms/PreferenceForm.php index 9b5a3ecf8..ed20c58cd 100644 --- a/application/forms/PreferenceForm.php +++ b/application/forms/PreferenceForm.php @@ -86,7 +86,7 @@ class PreferenceForm extends Form */ public function onSuccess() { - $this->preferences = new Preferences($this->store->load()); + $this->preferences = new Preferences($this->store ? $this->store->load() : array()); $webPreferences = $this->preferences->get('icingaweb', array()); foreach ($this->getValues() as $key => $value) { @@ -103,7 +103,7 @@ class PreferenceForm extends Form Session::getSession()->user->setPreferences($this->preferences); try { - if ($this->getElement('btn_submit_preferences')->isChecked()) { + if ($this->store && $this->getElement('btn_submit_preferences')->isChecked()) { $this->save(); Notification::success($this->translate('Preferences successfully saved')); } else { @@ -186,18 +186,20 @@ class PreferenceForm extends Form ) ); - $this->addElement( - 'submit', - 'btn_submit_preferences', - array( - 'ignore' => true, - 'label' => $this->translate('Save to the Preferences'), - 'decorators' => array( - 'ViewHelper', - array('HtmlTag', array('tag' => 'div')) + if ($this->store) { + $this->addElement( + 'submit', + 'btn_submit_preferences', + array( + 'ignore' => true, + 'label' => $this->translate('Save to the Preferences'), + 'decorators' => array( + 'ViewHelper', + array('HtmlTag', array('tag' => 'div')) + ) ) - ) - ); + ); + } $this->addElement( 'submit', From fb97e7445365b40b6460f5c844098fa5ed19c248 Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Mon, 26 Jan 2015 07:39:31 +0100 Subject: [PATCH 0384/2920] Use the correct element identifier for the preference storage type selection Used to be `type' but has changed to `store' to get a more clear INI structure. fixes #8275 --- modules/setup/application/forms/PreferencesPage.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/setup/application/forms/PreferencesPage.php b/modules/setup/application/forms/PreferencesPage.php index 211d16fac..01b3296f4 100644 --- a/modules/setup/application/forms/PreferencesPage.php +++ b/modules/setup/application/forms/PreferencesPage.php @@ -27,7 +27,7 @@ class PreferencesPage extends Form */ public function showDatabaseNote() { - $this->getElement('type') + $this->getElement('store') ->setValue('db') ->setDescription( $this->translate( From 0b73dbdd6da30fa8aa5d88241096990f34fcafba Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Mon, 26 Jan 2015 10:32:33 +0100 Subject: [PATCH 0385/2920] Fix exception "Undefined index: type" in the WebWizard's page logic refs #8275 --- modules/setup/library/Setup/WebWizard.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/setup/library/Setup/WebWizard.php b/modules/setup/library/Setup/WebWizard.php index d6874ed36..8ae7344ea 100644 --- a/modules/setup/library/Setup/WebWizard.php +++ b/modules/setup/library/Setup/WebWizard.php @@ -188,7 +188,7 @@ class WebWizard extends Wizard implements SetupWizard if ($newPage->getName() === 'setup_db_resource') { $prefData = $this->getPageData('setup_preferences_type'); $authData = $this->getPageData('setup_authentication_type'); - $skip = $prefData['type'] !== 'db' && $authData['type'] !== 'db'; + $skip = $prefData['store'] !== 'db' && $authData['type'] !== 'db'; } elseif ($newPage->getname() === 'setup_ldap_discovery') { $authData = $this->getPageData('setup_authentication_type'); $skip = $authData['type'] !== 'ldap'; From 555ab77c3df1f93d18a363cb1d5295d60e48dc8e Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Mon, 26 Jan 2015 13:40:17 +0100 Subject: [PATCH 0386/2920] Fix "Undefined property: stdClass::$service_display_name" in the alert summary fixes #8284 --- .../application/controllers/AlertsummaryController.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/modules/monitoring/application/controllers/AlertsummaryController.php b/modules/monitoring/application/controllers/AlertsummaryController.php index 652c09be3..a4ef76b44 100644 --- a/modules/monitoring/application/controllers/AlertsummaryController.php +++ b/modules/monitoring/application/controllers/AlertsummaryController.php @@ -78,7 +78,9 @@ class Monitoring_AlertsummaryController extends Controller 'notification', array( 'host', + 'host_display_name', 'service', + 'service_display_name', 'notification_output', 'notification_contact', 'notification_start_time', @@ -506,7 +508,9 @@ class Monitoring_AlertsummaryController extends Controller 'notification', array( 'host', + 'host_display_name', 'service', + 'service_display_name', 'notification_output', 'notification_contact', 'notification_start_time', From 2ba78f24c3fd46aa65444598cabf6e42024f616c Mon Sep 17 00:00:00 2001 From: Alexander Klimov Date: Mon, 26 Jan 2015 14:02:47 +0100 Subject: [PATCH 0387/2920] Roles view: show role's name in the title of the remove-link --- application/views/scripts/roles/index.phtml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/application/views/scripts/roles/index.phtml b/application/views/scripts/roles/index.phtml index 0f40f8279..67c957661 100644 --- a/application/views/scripts/roles/index.phtml +++ b/application/views/scripts/roles/index.phtml @@ -52,7 +52,10 @@
    escape($role->groups) ?> + title="translate('Remove role "%s"'), + $name + ); ?>"> icon('cancel') ?> ' . t('User Name Attribute') . '' . $this->data['backendConfig']['user_name_attribute'] . '
    ' . t('Filter Pattern') . '' . $this->data['backendConfig']['strip_username_regexp'] . '
    translate('CRITICAL'); ?> @@ -84,7 +84,7 @@ - services_total; ?> + qlink($h->services_total, 'monitoring/list/services', array('hostgroup' => $h->hostgroup)) ?> services_ok): ?> From f2d639108f15f75796129d2005163ae2bea46c77 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Mon, 2 Feb 2015 00:08:25 +0100 Subject: [PATCH 0464/2920] monitoring: Move "Service Grid" beneath "Problems" The service grid is filtered by problems by default. Thus it makes sense to move it beneath the problems section. --- modules/monitoring/configuration.php | 39 +++++++++++++++------------- 1 file changed, 21 insertions(+), 18 deletions(-) diff --git a/modules/monitoring/configuration.php b/modules/monitoring/configuration.php index 7eb3bbedf..f34b4b0f5 100644 --- a/modules/monitoring/configuration.php +++ b/modules/monitoring/configuration.php @@ -87,29 +87,36 @@ $this->provideSearchUrl($this->translate('Servicegroups'), 'monitoring/list/serv * Problems Section */ $section = $this->menuSection($this->translate('Problems'), array( - 'renderer' => 'ProblemMenuItemRenderer', - 'icon' => 'block', - 'priority' => 20 + 'renderer' => 'ProblemMenuItemRenderer', + 'icon' => 'block', + 'priority' => 20 )); $section->add($this->translate('Unhandled Hosts'), array( - 'renderer' => 'UnhandledHostMenuItemRenderer', - 'url' => 'monitoring/list/hosts?host_problem=1&host_handled=0', - 'priority' => 40 + 'renderer' => 'UnhandledHostMenuItemRenderer', + 'url' => 'monitoring/list/hosts?host_problem=1&host_handled=0', + 'priority' => 30 )); $section->add($this->translate('Unhandled Services'), array( - 'renderer' => 'UnhandledServiceMenuItemRenderer', - 'url' => 'monitoring/list/services?service_problem=1&service_handled=0&sort=service_severity', - 'priority' => 40 + 'renderer' => 'UnhandledServiceMenuItemRenderer', + 'url' => 'monitoring/list/services?service_problem=1&service_handled=0&sort=service_severity', + 'priority' => 40 )); $section->add($this->translate('Host Problems'), array( - 'url' => 'monitoring/list/hosts?host_problem=1&sort=host_severity', - 'priority' => 50 + 'url' => 'monitoring/list/hosts?host_problem=1&sort=host_severity', + 'priority' => 50 )); $section->add($this->translate('Service Problems'), array( - 'url' => 'monitoring/list/services?service_problem=1&sort=service_severity&dir=desc', - 'priority' => 50 + 'url' => 'monitoring/list/services?service_problem=1&sort=service_severity&dir=desc', + 'priority' => 60 +)); +$section->add($this->translate('Service Grid'), array( + 'url' => 'monitoring/list/servicegrid?service_problem=1', + 'priority' => 70 +)); +$section->add($this->translate('Current Downtimes'), array( + 'url' => 'monitoring/list/downtimes?downtime_is_in_effect=1', + 'priority' => 80 )); -$section->add($this->translate('Current Downtimes'))->setUrl('monitoring/list/downtimes?downtime_is_in_effect=1'); /* * Overview Section @@ -130,10 +137,6 @@ $section->add($this->translate('Services'), array( 'url' => 'monitoring/list/services', 'priority' => 50 )); -$section->add($this->translate('Service Grid'), array( - 'url' => 'monitoring/list/servicegrid?service_problem=1', - 'priority' => 51 -)); $section->add($this->translate('Servicegroups'), array( 'url' => 'monitoring/list/servicegroups', 'priority' => 60 From 734c7b35466c42da5509ed3d0605190f69d9357e Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Mon, 2 Feb 2015 11:04:41 +0100 Subject: [PATCH 0465/2920] monitoring: Show close button when updating an instance --- .../application/views/scripts/config/editinstance.phtml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/modules/monitoring/application/views/scripts/config/editinstance.phtml b/modules/monitoring/application/views/scripts/config/editinstance.phtml index b12f262c3..2c91ee656 100644 --- a/modules/monitoring/application/views/scripts/config/editinstance.phtml +++ b/modules/monitoring/application/views/scripts/config/editinstance.phtml @@ -1,2 +1,5 @@ +
    + showOnlyCloseButton() ?> +

    translate('Edit Existing Instance'); ?>

    - \ No newline at end of file + From d7cbfebbd0c9b0c7a3e3db66b0d3725691b9b63a Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Mon, 2 Feb 2015 11:05:32 +0100 Subject: [PATCH 0466/2920] monitoring: Show close button when removing an instance --- .../application/views/scripts/config/removeinstance.phtml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/modules/monitoring/application/views/scripts/config/removeinstance.phtml b/modules/monitoring/application/views/scripts/config/removeinstance.phtml index 306d41815..eee29fb02 100644 --- a/modules/monitoring/application/views/scripts/config/removeinstance.phtml +++ b/modules/monitoring/application/views/scripts/config/removeinstance.phtml @@ -1,4 +1,7 @@ +
    + showOnlyCloseButton() ?> +

    translate('Remove Existing Instance'); ?>

    translate('Are you sure you want to remove this instance?'); ?>

    translate('If you have still any environments or views referring to this instance, you won\'t be able to send commands anymore after deletion.'); ?>

    - \ No newline at end of file + From cbc1a0313ab129e87a68672e93ac02a9df493f02 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Mon, 2 Feb 2015 11:05:50 +0100 Subject: [PATCH 0467/2920] monitoring: Show close button when creating a backend --- .../application/views/scripts/config/createbackend.phtml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/modules/monitoring/application/views/scripts/config/createbackend.phtml b/modules/monitoring/application/views/scripts/config/createbackend.phtml index 0ef51cd6a..10ee02541 100644 --- a/modules/monitoring/application/views/scripts/config/createbackend.phtml +++ b/modules/monitoring/application/views/scripts/config/createbackend.phtml @@ -1,2 +1,5 @@ +
    + showOnlyCloseButton() ?> +

    translate('Add New Backend'); ?>

    - \ No newline at end of file + From 42fe7079eee7ce804a890c7edef656ce4dcec211 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Mon, 2 Feb 2015 11:06:20 +0100 Subject: [PATCH 0468/2920] monitoring: Show close button when creating an instance --- .../application/views/scripts/config/createinstance.phtml | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/modules/monitoring/application/views/scripts/config/createinstance.phtml b/modules/monitoring/application/views/scripts/config/createinstance.phtml index 49c8b5ec5..3515514df 100644 --- a/modules/monitoring/application/views/scripts/config/createinstance.phtml +++ b/modules/monitoring/application/views/scripts/config/createinstance.phtml @@ -1,2 +1,5 @@ -

    translate('Add New Instance'); ?>

    - \ No newline at end of file +
    + showOnlyCloseButton() ?> +
    +

    translate('Add New Instance') ?>

    + From a62acb4a8205972998604c6f9cf9f90e35a48a5e Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Mon, 2 Feb 2015 11:06:40 +0100 Subject: [PATCH 0469/2920] monitoring: Show close button when updating a backend --- .../application/views/scripts/config/editbackend.phtml | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/modules/monitoring/application/views/scripts/config/editbackend.phtml b/modules/monitoring/application/views/scripts/config/editbackend.phtml index 58b6c18f1..630cb83f2 100644 --- a/modules/monitoring/application/views/scripts/config/editbackend.phtml +++ b/modules/monitoring/application/views/scripts/config/editbackend.phtml @@ -1,2 +1,5 @@ -

    translate('Edit Existing Backend'); ?>

    - \ No newline at end of file +
    + showOnlyCloseButton() ?> +
    +

    translate('Edit Existing Backend') ?>

    + From cf944a7daf5708e001b4f8f7b732970f2ebf489e Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Mon, 2 Feb 2015 11:07:01 +0100 Subject: [PATCH 0470/2920] monitoring: Show close button when removing a backend --- .../application/views/scripts/config/removebackend.phtml | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/modules/monitoring/application/views/scripts/config/removebackend.phtml b/modules/monitoring/application/views/scripts/config/removebackend.phtml index fc7da17e3..d297f615b 100644 --- a/modules/monitoring/application/views/scripts/config/removebackend.phtml +++ b/modules/monitoring/application/views/scripts/config/removebackend.phtml @@ -1,2 +1,5 @@ -

    translate('Remove Existing Backend'); ?>

    - \ No newline at end of file +
    + showOnlyCloseButton() ?> +
    +

    translate('Remove Existing Backend') ?>

    + From cfe6701a924e08e012195704db8bc6bcc730767a Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Mon, 2 Feb 2015 11:08:27 +0100 Subject: [PATCH 0471/2920] Show close button when creating a role refs #8087 --- application/views/scripts/roles/new.phtml | 1 + 1 file changed, 1 insertion(+) diff --git a/application/views/scripts/roles/new.phtml b/application/views/scripts/roles/new.phtml index d7b277008..4c21c6f6b 100644 --- a/application/views/scripts/roles/new.phtml +++ b/application/views/scripts/roles/new.phtml @@ -1,4 +1,5 @@
    + showOnlyCloseButton() ?>

    translate('New Role') ?>

    From 3818f1faec3d323cf064787bafb071f0ffb80f8e Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Mon, 2 Feb 2015 11:08:56 +0100 Subject: [PATCH 0472/2920] Show close button when removing a role refs #8087 --- application/views/scripts/roles/remove.phtml | 1 + 1 file changed, 1 insertion(+) diff --git a/application/views/scripts/roles/remove.phtml b/application/views/scripts/roles/remove.phtml index e2d01ed62..4abff566a 100644 --- a/application/views/scripts/roles/remove.phtml +++ b/application/views/scripts/roles/remove.phtml @@ -1,4 +1,5 @@
    + showOnlyCloseButton() ?>

    translate('Remove Role %s'), $name) ?>

    From d64ca3da99e6e8277e5f5d1bba37bc61efa489b2 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Mon, 2 Feb 2015 11:09:13 +0100 Subject: [PATCH 0473/2920] Show close button when updating a role fixes #8087 --- application/views/scripts/roles/update.phtml | 1 + 1 file changed, 1 insertion(+) diff --git a/application/views/scripts/roles/update.phtml b/application/views/scripts/roles/update.phtml index 44f756b06..f48f1ca69 100644 --- a/application/views/scripts/roles/update.phtml +++ b/application/views/scripts/roles/update.phtml @@ -1,4 +1,5 @@
    + showOnlyCloseButton() ?>

    translate('Update Role %s'), $name) ?>

    From f9047e85c50ca8b70851cbe2be78dad9286b503d Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Mon, 2 Feb 2015 11:12:27 +0100 Subject: [PATCH 0474/2920] monitoring: Fix wrong unhandled service problems count in the hosts overview The query was missing the is_active = 1 condition. I'll open an issue for the other affected queries. fixes #8013 --- .../Backend/Ido/Query/StatusQuery.php | 52 ++++++++++--------- 1 file changed, 28 insertions(+), 24 deletions(-) diff --git a/modules/monitoring/library/Monitoring/Backend/Ido/Query/StatusQuery.php b/modules/monitoring/library/Monitoring/Backend/Ido/Query/StatusQuery.php index 0cc807ac8..cd7d0aef7 100644 --- a/modules/monitoring/library/Monitoring/Backend/Ido/Query/StatusQuery.php +++ b/modules/monitoring/library/Monitoring/Backend/Ido/Query/StatusQuery.php @@ -518,31 +518,35 @@ class StatusQuery extends IdoQuery protected function joinServiceproblemsummary() { - $sub = new Zend_Db_Expr('(SELECT' - . ' SUM(CASE WHEN (ss.problem_has_been_acknowledged + ss.scheduled_downtime_depth + COALESCE(hs.current_state, 0)) > 0 THEN 0 ELSE 1 END) AS unhandled_services_count,' - . ' SUM(CASE WHEN (ss.problem_has_been_acknowledged + ss.scheduled_downtime_depth + COALESCE(hs.current_state, 0)) > 0 THEN 1 ELSE 0 END) AS handled_services_count,' - . ' s.host_object_id FROM icinga_servicestatus ss' - . ' JOIN icinga_services s' - . ' ON s.service_object_id = ss.service_object_id' - . ' AND ss.current_state > 0' - . ' JOIN icinga_hoststatus hs' - . ' ON hs.host_object_id = s.host_object_id' - . ' GROUP BY s.host_object_id)'); + $select = <<<'SQL' +SELECT + SUM( + CASE WHEN(ss.problem_has_been_acknowledged + ss.scheduled_downtime_depth + COALESCE(hs.current_state, 0)) > 0 + THEN 0 + ELSE 1 + END + ) AS unhandled_services_count, + SUM( + CASE WHEN (ss.problem_has_been_acknowledged + ss.scheduled_downtime_depth + COALESCE(hs.current_state, 0) ) > 0 + THEN 1 + ELSE 0 + END + ) AS handled_services_count, + s.host_object_id +FROM + icinga_servicestatus ss + JOIN icinga_objects o ON o.object_id = ss.service_object_id + JOIN icinga_services s ON s.service_object_id = o.object_id + JOIN icinga_hoststatus hs ON hs.host_object_id = s.host_object_id +WHERE + o.is_active = 1 + AND o.objecttype_id = 2 + AND ss.current_state > 0 +GROUP BY + s.host_object_id +SQL; $this->select->joinLeft( - array('sps' => $sub), - 'sps.host_object_id = hs.host_object_id', - array() - ); - return; - - $this->select->joinleft( - array ('sps' => new \Zend_Db_Expr( - '(SELECT COUNT(s.service_object_id) as unhandled_service_count, s.host_object_id as host_object_id '. - 'FROM icinga_services s INNER JOIN icinga_servicestatus ss ON ss.current_state != 0 AND '. - 'ss.problem_has_been_acknowledged = 0 AND ss.scheduled_downtime_depth = 0 AND '. - 'ss.service_object_id = s.service_object_id '. - 'GROUP BY s.host_object_id'. - ')')), + array('sps' => new Zend_Db_Expr('(' . $select . ')')), 'sps.host_object_id = hs.host_object_id', array() ); From c0c0e7d9e53e1153e7ca7b873e8e39e9e2a37616 Mon Sep 17 00:00:00 2001 From: Marius Hein Date: Mon, 2 Feb 2015 11:57:50 +0100 Subject: [PATCH 0475/2920] Dashboard: Always replace title This is needed if an error occurs and the exception title was rendered into the container. --- public/js/icinga/loader.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/public/js/icinga/loader.js b/public/js/icinga/loader.js index 7d590757b..507a914e3 100644 --- a/public/js/icinga/loader.js +++ b/public/js/icinga/loader.js @@ -708,11 +708,12 @@ // $container.html(content); } else { - if ($container.closest('.dashboard').length && - ! $('h1', $content).length + if ($container.closest('.dashboard').length ) { - var title = $('h1', $container).first().detach(); - $('h1', $content).first().detach(); + if (! $('h1', $content).length) { + var title = $('h1', $container).first().detach(); + $('h1', $content).first().detach(); + } $container.html(title).append(content); } else if (action === 'replace') { $container.html(content); From d1f13819e4e6e0a97b6dfed2c957f56c4ee1354a Mon Sep 17 00:00:00 2001 From: Marius Hein Date: Mon, 2 Feb 2015 12:01:40 +0100 Subject: [PATCH 0476/2920] Revert "Dashboard: Always replace title" This reverts commit c0c0e7d9e53e1153e7ca7b873e8e39e9e2a37616. Syntax error --- public/js/icinga/loader.js | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/public/js/icinga/loader.js b/public/js/icinga/loader.js index 507a914e3..7d590757b 100644 --- a/public/js/icinga/loader.js +++ b/public/js/icinga/loader.js @@ -708,12 +708,11 @@ // $container.html(content); } else { - if ($container.closest('.dashboard').length + if ($container.closest('.dashboard').length && + ! $('h1', $content).length ) { - if (! $('h1', $content).length) { - var title = $('h1', $container).first().detach(); - $('h1', $content).first().detach(); - } + var title = $('h1', $container).first().detach(); + $('h1', $content).first().detach(); $container.html(title).append(content); } else if (action === 'replace') { $container.html(content); From 190c1e8f042262f956d1d23019eb33d35feba0ca Mon Sep 17 00:00:00 2001 From: Marius Hein Date: Mon, 2 Feb 2015 12:04:28 +0100 Subject: [PATCH 0477/2920] Revert "Revert "Dashboard: Always replace title"" This reverts commit d1f13819e4e6e0a97b6dfed2c957f56c4ee1354a. Please do not ask. This was no syntax error. --- public/js/icinga/loader.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/public/js/icinga/loader.js b/public/js/icinga/loader.js index 7d590757b..507a914e3 100644 --- a/public/js/icinga/loader.js +++ b/public/js/icinga/loader.js @@ -708,11 +708,12 @@ // $container.html(content); } else { - if ($container.closest('.dashboard').length && - ! $('h1', $content).length + if ($container.closest('.dashboard').length ) { - var title = $('h1', $container).first().detach(); - $('h1', $content).first().detach(); + if (! $('h1', $content).length) { + var title = $('h1', $container).first().detach(); + $('h1', $content).first().detach(); + } $container.html(title).append(content); } else if (action === 'replace') { $container.html(content); From 8c24dde17bce31cbf9e7e25a7d5f13dd588f8126 Mon Sep 17 00:00:00 2001 From: Marius Hein Date: Mon, 2 Feb 2015 12:08:20 +0100 Subject: [PATCH 0478/2920] Error Controller: Move close tab creation to template --- application/controllers/ErrorController.php | 1 - application/views/scripts/error/error.phtml | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/application/controllers/ErrorController.php b/application/controllers/ErrorController.php index e198eca1c..0548b5c9c 100644 --- a/application/controllers/ErrorController.php +++ b/application/controllers/ErrorController.php @@ -19,7 +19,6 @@ class ErrorController extends ActionController { $error = $this->_getParam('error_handler'); $exception = $error->exception; - $this->getTabs()->showOnlyCloseButton(); Logger::error($exception); Logger::error('Stacktrace: %s', $exception->getTraceAsString()); diff --git a/application/views/scripts/error/error.phtml b/application/views/scripts/error/error.phtml index 8e61e80f8..d9422474c 100644 --- a/application/views/scripts/error/error.phtml +++ b/application/views/scripts/error/error.phtml @@ -1,5 +1,5 @@
    -tabs->render($this) ?> +tabs->showOnlyCloseButton() ?> title): ?>

    escape($title) ?>

    From 8c758a9f126f81cc50fe290691d284947ec1804d Mon Sep 17 00:00:00 2001 From: Marius Hein Date: Mon, 2 Feb 2015 13:32:40 +0100 Subject: [PATCH 0479/2920] Failure requests: Fix auto refresh and history Allow to change url's in history and stop auto auto refresh if the container URL is not up to date. --- public/js/icinga/loader.js | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/public/js/icinga/loader.js b/public/js/icinga/loader.js index 507a914e3..4c273ffdb 100644 --- a/public/js/icinga/loader.js +++ b/public/js/icinga/loader.js @@ -107,7 +107,8 @@ url : url, data : data, headers: headers, - context: self + context: self, + failure: false }); req.$target = $target; @@ -553,7 +554,7 @@ // Update history when necessary. Don't do so for requests triggered // by history or autorefresh events if (! req.historyTriggered && ! req.autorefresh) { - if (req.$target.hasClass('container')) { + if (req.$target.hasClass('container') && req.failure === false) { // We only want to care about top-level containers if (req.$target.parent().closest('.container').length === 0) { this.icinga.history.pushCurrentState(); @@ -589,6 +590,17 @@ onFailure: function (req, textStatus, errorThrown) { var url = req.url; + req.failure = true; + + /* + * Test if a manual actions comes in and autorefresh is active: Stop refreshing + */ + if (! req.historyTriggered && ! req.autorefresh && req.$target.data('icingaRefresh') > 0 + && req.$target.data('icingaUrl') !== url) { + req.$target.data('icingaRefresh', 0); + req.$target.data('icingaUrl', url); + } + if (req.status > 0) { this.icinga.logger.error( req.status, From 53e7b44308a43b9b67fcecdaeef05e7adbf69722 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Mon, 2 Feb 2015 13:29:55 +0100 Subject: [PATCH 0480/2920] security: Provide a permission for module configuration --- application/forms/Security/RoleForm.php | 1 + 1 file changed, 1 insertion(+) diff --git a/application/forms/Security/RoleForm.php b/application/forms/Security/RoleForm.php index 18926972c..cc5f4037e 100644 --- a/application/forms/Security/RoleForm.php +++ b/application/forms/Security/RoleForm.php @@ -26,6 +26,7 @@ class RoleForm extends ConfigForm 'system/config/*' => 'system/config/*', 'system/config/application' => 'system/config/application', 'system/config/authentication' => 'system/config/authentication', + 'system/config/modules' => 'system/config/modules', 'system/config/resources' => 'system/config/resources', 'system/config/roles' => 'system/config/roles' ); From 7a81133ad33231c62967ba721b4ca6147a54a8e7 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Mon, 2 Feb 2015 13:30:52 +0100 Subject: [PATCH 0481/2920] security: Guard configuring roles --- application/controllers/RolesController.php | 58 ++++++++++++++++----- 1 file changed, 46 insertions(+), 12 deletions(-) diff --git a/application/controllers/RolesController.php b/application/controllers/RolesController.php index 90163812e..f4c6aeed2 100644 --- a/application/controllers/RolesController.php +++ b/application/controllers/RolesController.php @@ -1,6 +1,4 @@ view->tabs = Widget::create('tabs')->add('index', array( - 'title' => $this->translate('Application'), - 'url' => 'config' - ))->add('authentication', array( - 'title' => $this->translate('Authentication'), - 'url' => 'config/authentication' - ))->add('resources', array( - 'title' => $this->translate('Resources'), - 'url' => 'config/resource' - ))->add('roles', array( + $this->assertPermission('system/config/roles'); + $tabs = $this->getTabs(); + $auth = $this->Auth(); + if ($auth->hasPermission('system/config/application')) { + $tabs->add('application', array( + 'title' => $this->translate('Application'), + 'url' => 'config' + )); + } + if ($auth->hasPermission('system/config/authentication')) { + $tabs->add('authentication', array( + 'title' => $this->translate('Authentication'), + 'url' => 'config/authentication' + )); + } + if ($auth->hasPermission('system/config/resources')) { + $tabs->add('resource', array( + 'title' => $this->translate('Resources'), + 'url' => 'config/resource' + )); + } + $tabs->add('roles', array( 'title' => $this->translate('Roles'), 'url' => 'roles' )); } + /** + * List roles + */ public function indexAction() { $this->view->tabs->activate('roles'); $this->view->roles = Config::app('roles', true); } + /** + * Create a new role + */ public function newAction() { $role = new RoleForm(array( @@ -61,6 +85,11 @@ class RolesController extends ActionController $this->view->form = $role; } + /** + * Update a role + * + * @throws Zend_Controller_Action_Exception If the required parameter 'role' is missing or the role does not exist + */ public function updateAction() { $name = $this->_request->getParam('role'); @@ -105,6 +134,11 @@ class RolesController extends ActionController $this->view->form = $role; } + /** + * Remove a role + * + * @throws Zend_Controller_Action_Exception If the required parameter 'role' is missing or the role does not exist + */ public function removeAction() { $name = $this->_request->getParam('role'); From 5a1ebf9c89f96afb8ba1e9ed8b04763826e55197 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Mon, 2 Feb 2015 13:32:09 +0100 Subject: [PATCH 0482/2920] lib: Implement Tab::getUrl() --- library/Icinga/Web/Widget/Tab.php | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/library/Icinga/Web/Widget/Tab.php b/library/Icinga/Web/Widget/Tab.php index a06389b98..7eb5abeb1 100644 --- a/library/Icinga/Web/Widget/Tab.php +++ b/library/Icinga/Web/Widget/Tab.php @@ -138,6 +138,16 @@ class Tab extends AbstractWidget $this->url = $url; } + /** + * Get the tab's target URL + * + * @return Url + */ + public function getUrl() + { + return $this->url; + } + /** * Set the parameters to be set for this tabs Url * From 9ac93421070bd7696cec8f003c44da7ed08515f7 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Mon, 2 Feb 2015 13:41:02 +0100 Subject: [PATCH 0483/2920] Revert "lib: Reduce else { if { to elseif { in User::can()" This reverts commit e5b0b528747c2ff76b0568f8ca6929e61b072495. --- library/Icinga/User.php | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/library/Icinga/User.php b/library/Icinga/User.php index bdc49275b..db80c929a 100644 --- a/library/Icinga/User.php +++ b/library/Icinga/User.php @@ -426,11 +426,13 @@ class User foreach ($this->permissions as $permitted) { $wildcard = strpos($permitted, '*'); if ($wildcard !== false) { - } - if (substr($permission, 0, $wildcard) === substr($permitted, 0, $wildcard)) { - return true; - } elseif ($permission === $permitted) { - return true; + if (substr($permission, 0, $wildcard) === substr($permitted, 0, $wildcard)) { + return true; + } else { + if ($permission === $permitted) { + return true; + } + } } } return false; From 94193abdc02a20ce6d4ed8ef62498f6e091d50d7 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Mon, 2 Feb 2015 13:44:54 +0100 Subject: [PATCH 0484/2920] lib: Fix User::can() --- library/Icinga/User.php | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/library/Icinga/User.php b/library/Icinga/User.php index db80c929a..54b3e7632 100644 --- a/library/Icinga/User.php +++ b/library/Icinga/User.php @@ -428,11 +428,9 @@ class User if ($wildcard !== false) { if (substr($permission, 0, $wildcard) === substr($permitted, 0, $wildcard)) { return true; - } else { - if ($permission === $permitted) { - return true; - } } + } elseif ($permission === $permitted) { + return true; } } return false; From 4bac5dfc3779291a6da9b10e18c7a73a5454bf9a Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Mon, 2 Feb 2015 13:46:35 +0100 Subject: [PATCH 0485/2920] security: Guard application and module configuration --- application/controllers/ConfigController.php | 139 +++++++++++++----- .../config/{index.phtml => application.phtml} | 0 2 files changed, 102 insertions(+), 37 deletions(-) rename application/views/scripts/config/{index.phtml => application.phtml} (100%) diff --git a/application/controllers/ConfigController.php b/application/controllers/ConfigController.php index 15ba0a6ff..078503346 100644 --- a/application/controllers/ConfigController.php +++ b/application/controllers/ConfigController.php @@ -1,41 +1,70 @@ view->tabs = Widget::create('tabs')->add('index', array( - 'title' => $this->translate('Application'), - 'url' => 'config' - ))->add('authentication', array( - 'title' => $this->translate('Authentication'), - 'url' => 'config/authentication' - ))->add('resources', array( - 'title' => $this->translate('Resources'), - 'url' => 'config/resource' - ))->add('roles', array( - 'title' => $this->translate('Roles'), - 'url' => 'roles' - )); + $tabs = $this->getTabs(); + $auth = $this->Auth(); + $allowedActions = array(); + if ($auth->hasPermission('system/config/application')) { + $tabs->add('application', array( + 'title' => $this->translate('Application'), + 'url' => 'config/application' + )); + $allowedActions[] = 'application'; + } + if ($auth->hasPermission('system/config/authentication')) { + $tabs->add('authentication', array( + 'title' => $this->translate('Authentication'), + 'url' => 'config/authentication' + )); + $allowedActions[] = 'authentication'; + } + if ($auth->hasPermission('system/config/resources')) { + $tabs->add('resource', array( + 'title' => $this->translate('Resources'), + 'url' => 'config/resource' + )); + $allowedActions[] = 'resource'; + } + if ($auth->hasPermission('system/config/roles')) { + $tabs->add('roles', array( + 'title' => $this->translate('Roles'), + 'url' => 'roles' + )); + $allowedActions[] = 'roles'; + } + $this->firstAllowedAction = array_shift($allowedActions); } public function devtoolsAction() @@ -44,16 +73,35 @@ class ConfigController extends ActionController } /** - * Index action, entry point for configuration + * Forward or redirect to the first allowed configuration action */ public function indexAction() { + if ($this->firstAllowedAction === null) { + throw new SecurityException('No permission for configuration'); + } + $action = $this->getTabs()->get($this->firstAllowedAction); + if (substr($action->getUrl()->getPath(), 0, 7) === 'config/') { + $this->forward($this->firstAllowedAction); + } else { + $this->redirectNow($action->getUrl()); + } + } + + /** + * Application configuration + * + * @throws SecurityException If the user lacks the permission for configuring the application + */ + public function applicationAction() + { + $this->assertPermission('system/config/application'); $form = new GeneralConfigForm(); $form->setIniConfig(Config::app()); $form->handleRequest(); $this->view->form = $form; - $this->view->tabs->activate('index'); + $this->view->tabs->activate('application'); } /** @@ -61,16 +109,19 @@ class ConfigController extends ActionController */ public function modulesAction() { - $this->view->tabs = Widget::create('tabs')->add('modules', array( - 'title' => $this->translate('Modules'), - 'url' => 'config/modules' - )); - - $this->view->tabs->activate('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') + ->add('modules', array( + 'title' => $this->translate('Modules'), + 'url' => 'config/modules' + )) + ->activate('modules'); $this->view->modules = Icinga::app()->getModuleManager()->select() ->from('modules') ->order('enabled', 'desc') - ->order('name')->paginate(); + ->order('name') + ->paginate(); } public function moduleAction() @@ -79,8 +130,12 @@ class ConfigController extends ActionController $app = Icinga::app(); $manager = $app->getModuleManager(); if ($manager->hasInstalled($name)) { - $this->view->moduleData = Icinga::app()->getModuleManager()->select() - ->from('modules')->where('name', $name)->fetchRow(); + $this->view->moduleData = Icinga::app() + ->getModuleManager() + ->select() + ->from('modules') + ->where('name', $name) + ->fetchRow(); $module = new Module($app, $name, $manager->getModuleDir($name)); $this->view->module = $module; } else { @@ -94,6 +149,7 @@ class ConfigController extends ActionController */ public function moduleenableAction() { + $this->assertPermission('system/config/modules'); $module = $this->getParam('name'); $manager = Icinga::app()->getModuleManager(); try { @@ -114,6 +170,7 @@ class ConfigController extends ActionController */ public function moduledisableAction() { + $this->assertPermission('system/config/modules'); $module = $this->getParam('name'); $manager = Icinga::app()->getModuleManager(); try { @@ -133,6 +190,7 @@ class ConfigController extends ActionController */ public function authenticationAction() { + $this->assertPermission('system/config/authentication'); $form = new AuthenticationBackendReorderForm(); $form->setIniConfig(Config::app('authentication')); $form->handleRequest(); @@ -147,6 +205,7 @@ class ConfigController extends ActionController */ public function createauthenticationbackendAction() { + $this->assertPermission('system/config/authentication'); $form = new AuthenticationBackendConfigForm(); $form->setIniConfig(Config::app('authentication')); $form->setResourceConfig(ResourceFactory::getResourceConfigs()); @@ -163,6 +222,7 @@ class ConfigController extends ActionController */ public function editauthenticationbackendAction() { + $this->assertPermission('system/config/authentication'); $form = new AuthenticationBackendConfigForm(); $form->setIniConfig(Config::app('authentication')); $form->setResourceConfig(ResourceFactory::getResourceConfigs()); @@ -179,6 +239,7 @@ class ConfigController extends ActionController */ public function removeauthenticationbackendAction() { + $this->assertPermission('system/config/authentication'); $form = new ConfirmRemovalForm(array( 'onSuccess' => function ($form) { $configForm = new AuthenticationBackendConfigForm(); @@ -215,8 +276,9 @@ class ConfigController extends ActionController */ public function resourceAction() { + $this->assertPermission('system/config/resources'); $this->view->resources = Config::app('resources', true)->keys(); - $this->view->tabs->activate('resources'); + $this->view->tabs->activate('resource'); } /** @@ -224,6 +286,7 @@ class ConfigController extends ActionController */ public function createresourceAction() { + $this->assertPermission('system/config/resources'); $form = new ResourceConfigForm(); $form->setIniConfig(Config::app('resources')); $form->setRedirectUrl('config/resource'); @@ -238,6 +301,7 @@ class ConfigController extends ActionController */ public function editresourceAction() { + $this->assertPermission('system/config/resources'); $form = new ResourceConfigForm(); $form->setIniConfig(Config::app('resources')); $form->setRedirectUrl('config/resource'); @@ -252,6 +316,7 @@ class ConfigController extends ActionController */ public function removeresourceAction() { + $this->assertPermission('system/config/resources'); $form = new ConfirmRemovalForm(array( 'onSuccess' => function ($form) { $configForm = new ResourceConfigForm(); diff --git a/application/views/scripts/config/index.phtml b/application/views/scripts/config/application.phtml similarity index 100% rename from application/views/scripts/config/index.phtml rename to application/views/scripts/config/application.phtml From 52c40bdc5b3bf3b32cbddf46bfa1039e7952b978 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Mon, 2 Feb 2015 14:15:09 +0100 Subject: [PATCH 0486/2920] lib/SimpleQuery: Increase default limit to 25 Please follow the referenced issues. fixes #8337 refs #8339 --- library/Icinga/Data/SimpleQuery.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library/Icinga/Data/SimpleQuery.php b/library/Icinga/Data/SimpleQuery.php index 41d050ea2..e865d86fa 100644 --- a/library/Icinga/Data/SimpleQuery.php +++ b/library/Icinga/Data/SimpleQuery.php @@ -320,7 +320,7 @@ class SimpleQuery implements QueryInterface, Queryable // Detect parameters from request $request = Icinga::app()->getFrontController()->getRequest(); if ($itemsPerPage === null) { - $itemsPerPage = $request->getParam('limit', 20); + $itemsPerPage = $request->getParam('limit', 25); } if ($pageNumber === null) { $pageNumber = $request->getParam('page', 0); From bfb2f710a1353407fe1f88f6fa23d39fb9003e4f Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Mon, 2 Feb 2015 14:28:47 +0100 Subject: [PATCH 0487/2920] monitoring: Fix exception in the alert summary report when using the "One month" interval fixes #8220 --- .../application/controllers/AlertsummaryController.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/monitoring/application/controllers/AlertsummaryController.php b/modules/monitoring/application/controllers/AlertsummaryController.php index a4ef76b44..d9cc798a7 100644 --- a/modules/monitoring/application/controllers/AlertsummaryController.php +++ b/modules/monitoring/application/controllers/AlertsummaryController.php @@ -375,7 +375,7 @@ class Monitoring_AlertsummaryController extends Controller $query->order('notification_start_time', 'asc'); - $records = $query->getQuery()->fetchAll(); + $records = $query->getQuery()->fetchAll(); $interval = $this->getInterval(); $period = $this->createPeriod($interval); @@ -582,7 +582,7 @@ class Monitoring_AlertsummaryController extends Controller } elseif ($interval === '1w') { return new DatePeriod($this->getBeginDate($interval), new DateInterval('P1D'), 7); } elseif ($interval === '1m') { - return new DatePeriod($this->getBeginDate($interval), new DateInterval('P1D'), 30); + return new DatePeriod($this->getBeginDate($interval), new DateInterval('P1D'), 31); } elseif ($interval === '1y') { return new DatePeriod($this->getBeginDate($interval), new DateInterval('P1M'), 12); } From 6555a2ec0a2d2c527dd7ca002f44bc9127073e51 Mon Sep 17 00:00:00 2001 From: Marius Hein Date: Mon, 2 Feb 2015 15:03:00 +0100 Subject: [PATCH 0488/2920] Menu: Move request handling to complete If a failure occur the menu is still working. --- public/js/icinga/loader.js | 66 ++++++++++++++++++++------------------ 1 file changed, 34 insertions(+), 32 deletions(-) diff --git a/public/js/icinga/loader.js b/public/js/icinga/loader.js index 4c273ffdb..1a8aadca5 100644 --- a/public/js/icinga/loader.js +++ b/public/js/icinga/loader.js @@ -342,42 +342,11 @@ var rendered = false; var classes; - if (! req.autorefresh) { - // TODO: Hook for response/url? - var $forms = $('[action="' + this.icinga.utils.parseUrl(url).path + '"]'); - var $matches = $.merge($('[href="' + url + '"]'), $forms); - $matches.each(function (idx, el) { - if ($(el).closest('#menu').length) { - if (req.$target[0].id === 'col1') { - self.icinga.behaviors.navigation.resetActive(); - } - } else if ($(el).closest('table.action').length) { - $(el).closest('table.action').find('.active').removeClass('active'); - } - }); - - $matches.each(function (idx, el) { - var $el = $(el); - if ($el.closest('#menu').length) { - if ($el.is('form')) { - $('input', $el).addClass('active'); - } else { - if (req.$target[0].id === 'col1') { - self.icinga.behaviors.navigation.setActive($el); - } - } - // Interrupt .each, only on menu item shall be active - return false; - } else if ($(el).closest('table.action').length) { - $el.addClass('active'); - } - }); - } else { + if (req.autorefresh) { // TODO: next container url active = $('[href].active', req.$target).attr('href'); } - var target = req.getResponseHeader('X-Icinga-Container'); var newBody = false; var oldNotifications = false; @@ -551,6 +520,39 @@ * Regardless of whether a request succeeded of failed, clean up */ onComplete: function (req, textStatus) { + if (! req.autorefresh) { + // TODO: Hook for response/url? + var url = req.url; + var $forms = $('[action="' + this.icinga.utils.parseUrl(url).path + '"]'); + var $matches = $.merge($('[href="' + url + '"]'), $forms); + $matches.each(function (idx, el) { + if ($(el).closest('#menu').length) { + if (req.$target[0].id === 'col1') { + self.icinga.behaviors.navigation.resetActive(); + } + } else if ($(el).closest('table.action').length) { + $(el).closest('table.action').find('.active').removeClass('active'); + } + }); + + $matches.each(function (idx, el) { + var $el = $(el); + if ($el.closest('#menu').length) { + if ($el.is('form')) { + $('input', $el).addClass('active'); + } else { + if (req.$target[0].id === 'col1') { + self.icinga.behaviors.navigation.setActive($el); + } + } + // Interrupt .each, only on menu item shall be active + return false; + } else if ($(el).closest('table.action').length) { + $el.addClass('active'); + } + }); + } + // Update history when necessary. Don't do so for requests triggered // by history or autorefresh events if (! req.historyTriggered && ! req.autorefresh) { From 9d6906bd6449a21598614a633adcb711e8bfca62 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Mon, 2 Feb 2015 15:05:47 +0100 Subject: [PATCH 0489/2920] Save user dashboards to Icinga Web 2's configuration directory fixes #8056 --- .../controllers/DashboardController.php | 4 +-- library/Icinga/Web/Widget/Dashboard.php | 25 ++----------------- 2 files changed, 4 insertions(+), 25 deletions(-) diff --git a/application/controllers/DashboardController.php b/application/controllers/DashboardController.php index 49a58426f..12a5180c8 100644 --- a/application/controllers/DashboardController.php +++ b/application/controllers/DashboardController.php @@ -24,11 +24,11 @@ class DashboardController extends ActionController * @var Dashboard; */ private $dashboard; - + public function init() { $this->dashboard = new Dashboard(); - $this->dashboard->setUser($this->getRequest()->getUser()); + $this->dashboard->setUser($this->Auth()->getUser()); $this->dashboard->load(); } diff --git a/library/Icinga/Web/Widget/Dashboard.php b/library/Icinga/Web/Widget/Dashboard.php index fe4bba803..bb62cc8f9 100644 --- a/library/Icinga/Web/Widget/Dashboard.php +++ b/library/Icinga/Web/Widget/Dashboard.php @@ -9,7 +9,6 @@ use Icinga\Application\Config; use Icinga\Exception\ConfigurationError; use Icinga\Exception\NotReadableError; use Icinga\Exception\ProgrammingError; -use Icinga\Exception\SystemPermissionException; use Icinga\User; use Icinga\Web\Widget\Dashboard\Pane; use Icinga\Web\Widget\Dashboard\Dashlet as DashboardDashlet; @@ -425,28 +424,8 @@ class Dashboard extends AbstractWidget public function getConfigFile() { if ($this->user === null) { - return ''; + throw new ProgrammingError('Can\'t load dashboards. User is not set'); } - - $baseDir = '/var/lib/icingaweb'; - - if (! file_exists($baseDir)) { - throw new NotReadableError('Could not read: ' . $baseDir); - } - - $userDir = $baseDir . '/' . $this->user->getUsername(); - - if (! file_exists($userDir)) { - $success = @mkdir($userDir); - if (!$success) { - throw new SystemPermissionException('Could not create: ' . $userDir); - } - } - - if (! file_exists($userDir)) { - throw new NotReadableError('Could not read: ' . $userDir); - } - - return $userDir . '/dashboard.ini'; + return Config::resolvePath('dashboards/' . $this->user->getUsername() . '/dashboard.ini'); } } From 67a426580d4c33ad00179d31f81005d6f32dc997 Mon Sep 17 00:00:00 2001 From: Marius Hein Date: Mon, 2 Feb 2015 15:18:05 +0100 Subject: [PATCH 0490/2920] loader: Remove gray out on complete handler A failure did not remove the impact class which colorize the background gray. --- public/js/icinga/loader.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/public/js/icinga/loader.js b/public/js/icinga/loader.js index 1a8aadca5..abf0d6684 100644 --- a/public/js/icinga/loader.js +++ b/public/js/icinga/loader.js @@ -318,11 +318,6 @@ this.failureNotice = null; } - // Remove 'impact' class if there was such - if (req.$target.hasClass('impact')) { - req.$target.removeClass('impact'); - } - var url = req.url; this.icinga.logger.debug( 'Got response for ', req.$target, ', URL was ' + url @@ -520,6 +515,11 @@ * Regardless of whether a request succeeded of failed, clean up */ onComplete: function (req, textStatus) { + // Remove 'impact' class if there was such + if (req.$target.hasClass('impact')) { + req.$target.removeClass('impact'); + } + if (! req.autorefresh) { // TODO: Hook for response/url? var url = req.url; From afa3431aedc826931becc1afc53bff3d5c6821f5 Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Mon, 2 Feb 2015 16:26:55 +0100 Subject: [PATCH 0491/2920] Introduce new object- and command-view scripts Represents how we plan to handle view scripts that are re-usable. Should supersede all /component/* view scripts in the upcoming future. --- .../command/object-command-form.phtml | 13 +++ .../command/objects-command-form.phtml | 32 +++++++ .../scripts/partials/host/object-header.phtml | 27 ++++++ .../partials/host/objects-header.phtml | 16 ++++ .../partials/host/servicesummary.phtml | 89 +++++++++++++++++++ .../scripts/partials/host/statusicons.phtml | 28 ++++++ .../partials/service/object-header.phtml | 41 +++++++++ .../partials/service/objects-header.phtml | 32 +++++++ .../partials/service/statusicons.phtml | 28 ++++++ 9 files changed, 306 insertions(+) create mode 100644 modules/monitoring/application/views/scripts/partials/command/object-command-form.phtml create mode 100644 modules/monitoring/application/views/scripts/partials/command/objects-command-form.phtml create mode 100644 modules/monitoring/application/views/scripts/partials/host/object-header.phtml create mode 100644 modules/monitoring/application/views/scripts/partials/host/objects-header.phtml create mode 100644 modules/monitoring/application/views/scripts/partials/host/servicesummary.phtml create mode 100644 modules/monitoring/application/views/scripts/partials/host/statusicons.phtml create mode 100644 modules/monitoring/application/views/scripts/partials/service/object-header.phtml create mode 100644 modules/monitoring/application/views/scripts/partials/service/objects-header.phtml create mode 100644 modules/monitoring/application/views/scripts/partials/service/statusicons.phtml diff --git a/modules/monitoring/application/views/scripts/partials/command/object-command-form.phtml b/modules/monitoring/application/views/scripts/partials/command/object-command-form.phtml new file mode 100644 index 000000000..7f4314cbf --- /dev/null +++ b/modules/monitoring/application/views/scripts/partials/command/object-command-form.phtml @@ -0,0 +1,13 @@ +
    + getType() === $object::TYPE_HOST): ?> + render('partials/host/object-header.phtml'); ?> + render('partials/host/servicesummary.phtml'); ?> + + render('partials/service/object-header.phtml'); ?> +
    + +
    +
    +

    icon('help', $form->getHelp()); ?>

    + +
    \ No newline at end of file diff --git a/modules/monitoring/application/views/scripts/partials/command/objects-command-form.phtml b/modules/monitoring/application/views/scripts/partials/command/objects-command-form.phtml new file mode 100644 index 000000000..da58fc9cb --- /dev/null +++ b/modules/monitoring/application/views/scripts/partials/command/objects-command-form.phtml @@ -0,0 +1,32 @@ +
    + + render('partials/service/objects-header.phtml'); ?> + + render('partials/host/objects-header.phtml'); ?> + +
    +
    + + + + + + + + + getObjects() as $object): /** @var \Icinga\Module\Monitoring\Object\MonitoredObject $object */ ?> + + getType() === $object::TYPE_HOST): ?> + + + + + + + + +
    icon('host'); ?> translate('Host'); ?>icon('conf'); ?> translate('Service'); ?>
    escape($object->getName()); ?>escape($object->getHost()->getName()); ?>escape($object->getName()); ?>
    +
    +

    icon('help', $form->getHelp()) ?>

    + +
    diff --git a/modules/monitoring/application/views/scripts/partials/host/object-header.phtml b/modules/monitoring/application/views/scripts/partials/host/object-header.phtml new file mode 100644 index 000000000..69d0f62f5 --- /dev/null +++ b/modules/monitoring/application/views/scripts/partials/host/object-header.phtml @@ -0,0 +1,27 @@ + +compact): ?> + + + + + + + +
    + host_state, true); ?>
    + prefixedTimeSince($object->host_last_state_change, true); ?> +
    + escape($object->host_display_name); ?> + host_display_name !== $object->host_name): ?> + (escape($object->host_name); ?>) + + host_address && $object->host_address !== $object->host_name): ?> +
    + escape($object->host_address); ?> + + render('partials/host/statusicons.phtml'); ?> +
    \ No newline at end of file diff --git a/modules/monitoring/application/views/scripts/partials/host/objects-header.phtml b/modules/monitoring/application/views/scripts/partials/host/objects-header.phtml new file mode 100644 index 000000000..f5edd0213 --- /dev/null +++ b/modules/monitoring/application/views/scripts/partials/host/objects-header.phtml @@ -0,0 +1,16 @@ +compact): ?> + + + 0): ?> +
    + translatePlural('Host (%u)', 'Hosts (%u)', $hostCount), $hostCount); ?> +
    +
    +   +
    +
    + $count): ?> + translate(strtoupper($text)), $count); ?>
    + +
    + \ No newline at end of file diff --git a/modules/monitoring/application/views/scripts/partials/host/servicesummary.phtml b/modules/monitoring/application/views/scripts/partials/host/servicesummary.phtml new file mode 100644 index 000000000..641dd026a --- /dev/null +++ b/modules/monitoring/application/views/scripts/partials/host/servicesummary.phtml @@ -0,0 +1,89 @@ + $this->object->host_name)); +$currentUrl = Url::fromRequest()->without('limit')->getRelativeUrl(); + +?> +

    compact ? ' data-base-target="col1"' : '' ?>> +stats->services_total > 0): ?> +qlink(sprintf($this->translatePlural('%d configured service:', '%d configured services:', $object->stats->services_total), $object->stats->services_total), $selfUrl) ?> + +translate('No services configured on this host'); ?> + + +stats->services_ok > 0): ?> + qlink( + $object->stats->services_ok, + $selfUrl, + array('service_state' => 0), + array('title' => sprintf($this->translate('Services with state %s'), $this->translate('OK'))) +) ?> + + 'critical', 3 => 'unknown', 1 => 'warning') as $stateId => $state) { + $pre = 'services_' . $state; + if ($object->stats->$pre) { + $handled = $pre . '_handled'; + $unhandled = $pre . '_unhandled'; + $paramsHandled = array('service_state' => $stateId, 'service_handled' => 1); + $paramsUnhandled = array('service_state' => $stateId, 'service_handled' => 0); + if ($object->stats->$unhandled) { + $compareUrl = $selfUrl->with($paramsUnhandled)->getRelativeUrl(); + } else { + $compareUrl = $selfUrl->with($paramsHandled)->getRelativeUrl(); + } + + if ($compareUrl === $currentUrl) { + $active = ' active'; + } else { + $active = ''; + } + + echo ''; + if ($object->stats->$unhandled) { + + echo $this->qlink( + $object->stats->$unhandled, + $selfUrl, + $paramsUnhandled, + array('title' => sprintf($this->translate('Unhandled services with state %s'), $this->translate(strtoupper($state)))) + ); + } + if ($object->stats->$handled) { + + if ($selfUrl->with($paramsHandled)->getRelativeUrl() === $currentUrl) { + $active = ' active'; + } else { + $active = ''; + } + if ($object->stats->$unhandled) { + echo ''; + } + echo $this->qlink( + $object->stats->$handled, + $selfUrl, + $paramsHandled, + array('title' => sprintf($this->translate('Handled services with state %s'), $this->translate(strtoupper($state)))) + ); + if ($object->stats->$unhandled) { + echo "\n"; + } + } + echo "\n"; + } +} + +?> +stats->services_pending): ?> + qlink( + $object->stats->services_pending, + $selfUrl, + array('service_state' => 99), + array('title' => sprintf($this->translate('Services with state %s'), $this->translate('PENDING'))) +) ?> + + +

    + diff --git a/modules/monitoring/application/views/scripts/partials/host/statusicons.phtml b/modules/monitoring/application/views/scripts/partials/host/statusicons.phtml new file mode 100644 index 000000000..4421c301f --- /dev/null +++ b/modules/monitoring/application/views/scripts/partials/host/statusicons.phtml @@ -0,0 +1,28 @@ +object->host_handled && $this->object->host_state > 0) { + $icons[] = $this->icon('attention-alt', $this->translate('Unhandled')); +} + +if ($this->object->host_acknowledged && !$this->object->host_in_downtime) { + $icons[] = $this->icon('ok', $this->translate('Acknowledged')); +} + +if (! $this->object->host_notifications_enabled) { + $icons[] = $this->icon('bell-off-empty', $this->translate('Notifications Disabled')); +} + +if ($this->object->host_in_downtime) { + $icons[] = $this->icon('plug', $this->translate('In Downtime')); +} + +if (! $this->object->host_active_checks_enabled) { + if ($this->object->host_passive_checks_enabled) { + $icons[] = $this->icon('eye-off', $this->translate('Active Checks Disabled')); + } else { + $icons[] = $this->icon('eye-off', $this->translate('Active And Passive Checks Disabled')); + } +} + +?> \ No newline at end of file diff --git a/modules/monitoring/application/views/scripts/partials/service/object-header.phtml b/modules/monitoring/application/views/scripts/partials/service/object-header.phtml new file mode 100644 index 000000000..5f3ccb70f --- /dev/null +++ b/modules/monitoring/application/views/scripts/partials/service/object-header.phtml @@ -0,0 +1,41 @@ + +compact): ?> + + + + + + + + + + + +
    + host_state, true); ?>
    + prefixedTimeSince($object->host_last_state_change, true); ?> +
    + escape($object->host_display_name); ?> + host_display_name !== $object->host_name): ?> + (escape($object->host_name); ?>) + + host_address && $object->host_address !== $object->host_name): ?> +
    + escape($object->host_address); ?> + + render('partials/host/statusicons.phtml'); ?> +
    + service_state, true); ?>
    + prefixedTimeSince($object->service_last_state_change, true); ?> +
    + translate('Service'); ?>: escape($object->service_display_name); ?> + service_display_name !== $object->service_description): ?> + (escape($object->service_description); ?>) + + render('partials/service/statusicons.phtml'); ?> +
    diff --git a/modules/monitoring/application/views/scripts/partials/service/objects-header.phtml b/modules/monitoring/application/views/scripts/partials/service/objects-header.phtml new file mode 100644 index 000000000..1ac27b934 --- /dev/null +++ b/modules/monitoring/application/views/scripts/partials/service/objects-header.phtml @@ -0,0 +1,32 @@ +compact): ?> + + + 0): ?> +
    +
    + translatePlural('Service (%u)', 'Services (%u)', $serviceCount), $serviceCount); ?> +
    +
    +   +
    +
    + $count): ?> + translate(strtoupper($text)), $count); ?>
    + +
    +
    +
    +
    + + translatePlural('Host (%u)', 'Hosts (%u)', $hostCount), $hostCount); ?> +
    +
    +   +
    +
    + $count): ?> + translate(strtoupper($text)), $count); ?>
    + +
    +
    + \ No newline at end of file diff --git a/modules/monitoring/application/views/scripts/partials/service/statusicons.phtml b/modules/monitoring/application/views/scripts/partials/service/statusicons.phtml new file mode 100644 index 000000000..8859bf189 --- /dev/null +++ b/modules/monitoring/application/views/scripts/partials/service/statusicons.phtml @@ -0,0 +1,28 @@ +object->service_handled && $this->object->service_state > 0) { + $icons[] = $this->icon('attention-alt', $this->translate('Unhandled')); +} + +if ($this->object->service_acknowledged && !$this->object->service_in_downtime) { + $icons[] = $this->icon('ok', $this->translate('Acknowledged')); +} + +if (! $this->object->service_notifications_enabled) { + $icons[] = $this->icon('bell-off-empty', $this->translate('Notifications Disabled')); +} + +if ($this->object->service_in_downtime) { + $icons[] = $this->icon('plug', $this->translate('In Downtime')); +} + +if (! $this->object->service_active_checks_enabled) { + if ($this->object->service_passive_checks_enabled) { + $icons[] = $this->icon('eye-off', $this->translate('Active Checks Disabled')); + } else { + $icons[] = $this->icon('eye-off', $this->translate('Active And Passive Checks Disabled')); + } +} + +?> \ No newline at end of file From 2e99e476fe900cadaaeac4f2ab2ef36f4e0376d2 Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Mon, 2 Feb 2015 16:28:35 +0100 Subject: [PATCH 0492/2920] Use the new object-view scripts --- .../application/views/scripts/host/show.phtml | 4 +-- .../views/scripts/hosts/show.phtml | 17 ++-------- .../views/scripts/service/show.phtml | 2 +- .../views/scripts/services/show.phtml | 34 ++----------------- .../views/scripts/show/history.phtml | 11 ++++-- .../views/scripts/show/services.phtml | 4 +-- 6 files changed, 17 insertions(+), 55 deletions(-) diff --git a/modules/monitoring/application/views/scripts/host/show.phtml b/modules/monitoring/application/views/scripts/host/show.phtml index 8023c1821..00d579a29 100644 --- a/modules/monitoring/application/views/scripts/host/show.phtml +++ b/modules/monitoring/application/views/scripts/host/show.phtml @@ -1,6 +1,6 @@
    - render('show/components/header.phtml') ?> - render('show/components/hostservicesummary.phtml') ?> + render('partials/host/object-header.phtml') ?> + render('partials/host/servicesummary.phtml') ?>
    render('show/components/output.phtml') ?> diff --git a/modules/monitoring/application/views/scripts/hosts/show.phtml b/modules/monitoring/application/views/scripts/hosts/show.phtml index 516e1be03..7f8d775ab 100644 --- a/modules/monitoring/application/views/scripts/hosts/show.phtml +++ b/modules/monitoring/application/views/scripts/hosts/show.phtml @@ -1,23 +1,10 @@
    - tabs ?> + render('partials/host/objects-header.phtml') ?>
    - - + translate('No hosts matching the filter') ?> -
    - translatePlural('Host (%u)', 'Hosts (%u)', $hostCount), $hostCount) ?> -
    -
    -  hostStatesPieChart ?> -
    -
    - $count) { - echo sprintf('%s: %u
    ', $this->translate(strtoupper($text)), $count); - } ?> -
    -

    translatePlural( diff --git a/modules/monitoring/application/views/scripts/service/show.phtml b/modules/monitoring/application/views/scripts/service/show.phtml index a5c95fd61..3a09e2bf4 100644 --- a/modules/monitoring/application/views/scripts/service/show.phtml +++ b/modules/monitoring/application/views/scripts/service/show.phtml @@ -1,5 +1,5 @@
    - render('show/components/header.phtml') ?> + render('partials/service/object-header.phtml') ?>

    translate("Service detail information") ?>

    diff --git a/modules/monitoring/application/views/scripts/services/show.phtml b/modules/monitoring/application/views/scripts/services/show.phtml index 522d32ce7..d5d9df2d9 100644 --- a/modules/monitoring/application/views/scripts/services/show.phtml +++ b/modules/monitoring/application/views/scripts/services/show.phtml @@ -1,41 +1,11 @@
    - tabs ?> + render('partials/service/objects-header.phtml') ?>
    - - + translate('No services matching the filter') ?> -
    -
    - translatePlural('Service (%u)', 'Services (%u)', $serviceCount), $serviceCount) ?> -
    -
    -  serviceStatesPieChart ?> -
    -
    - $count) { - echo sprintf(' %s: %u
    ', $this->translate(strtoupper($text)), $count); - } ?> -
    -
    - -
    -
    - - translatePlural('Host (%u)', 'Hosts (%u)', $hostCount), $hostCount) ?> -
    -
    -  hostStatesPieChart ?> -
    -
    - $count) { - echo sprintf('%s: %u
    ', $this->translate(strtoupper($text)), $count); - } ?> -
    -
    -
    translate('List all') ?> diff --git a/modules/monitoring/application/views/scripts/show/history.phtml b/modules/monitoring/application/views/scripts/show/history.phtml index 40fb15363..5c20e800b 100644 --- a/modules/monitoring/application/views/scripts/show/history.phtml +++ b/modules/monitoring/application/views/scripts/show/history.phtml @@ -3,10 +3,17 @@ use Icinga\Module\Monitoring\Object\Host; use Icinga\Module\Monitoring\Object\Service; +$self = $this; +$hostContext = $object->getType() === 'host'; + ?>
    - render('show/components/header.phtml'); ?> + + render('partials/host/object-header.phtml'); ?> + + render('partials/service/object-header.phtml'); ?> +

    translate('This Object\'s Event History'); ?>

    widget('limiter', array('url' => $url, 'max' => $history->count())); ?> paginationControl($history, null, null, array('preserve' => $this->preserve)); ?> @@ -19,8 +26,6 @@ use Icinga\Module\Monitoring\Object\Service; getType() === 'host'; function contactsLink($match, $view) { $links = array(); foreach (preg_split('/,\s/', $match[1]) as $contact) { diff --git a/modules/monitoring/application/views/scripts/show/services.phtml b/modules/monitoring/application/views/scripts/show/services.phtml index ae4f8f699..57b4b204e 100644 --- a/modules/monitoring/application/views/scripts/show/services.phtml +++ b/modules/monitoring/application/views/scripts/show/services.phtml @@ -1,5 +1,5 @@
    -render('show/components/header.phtml') ?> -render('show/components/hostservicesummary.phtml') ?> +render('partials/host/object-header.phtml') ?> +render('partials/host/servicesummary.phtml') ?>
    From 8b377cd65158f63da215132ac2c1d9ec5e79964e Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Mon, 2 Feb 2015 16:30:52 +0100 Subject: [PATCH 0493/2920] Use the new command-view scripts --- .../controllers/HostsController.php | 30 +++++++++++- .../controllers/ServicesController.php | 49 ++++++++++++++++++- .../Controller/MonitoredObjectController.php | 4 +- modules/monitoring/public/css/module.less | 9 ++++ 4 files changed, 88 insertions(+), 4 deletions(-) diff --git a/modules/monitoring/application/controllers/HostsController.php b/modules/monitoring/application/controllers/HostsController.php index 869be92d8..dbe395b28 100644 --- a/modules/monitoring/application/controllers/HostsController.php +++ b/modules/monitoring/application/controllers/HostsController.php @@ -12,7 +12,6 @@ use Icinga\Module\Monitoring\Forms\Command\Object\RemoveAcknowledgementCommandFo use Icinga\Module\Monitoring\Forms\Command\Object\ScheduleHostCheckCommandForm; use Icinga\Module\Monitoring\Forms\Command\Object\ScheduleHostDowntimeCommandForm; use Icinga\Module\Monitoring\Object\Host; -use Icinga\Module\Monitoring\Object\Service; use Icinga\Module\Monitoring\Object\HostList; use Icinga\Web\Url; use Icinga\Web\Widget\Chart\InlinePie; @@ -33,12 +32,39 @@ class Monitoring_HostsController extends Controller protected function handleCommandForm(ObjectsCommandForm $form) { + $this->hostList->setColumns(array( + 'host_name', + 'host_state', + 'host_problem', + 'host_handled', + 'host_acknowledged', + 'host_in_downtime' + )); + $form ->setObjects($this->hostList) ->setRedirectUrl(Url::fromPath('monitoring/hosts/show')->setParams($this->params)) ->handleRequest(); + + $hostStates = array( + Host::getStateText(Host::STATE_UP) => 0, + Host::getStateText(Host::STATE_DOWN) => 0, + Host::getStateText(Host::STATE_UNREACHABLE) => 0, + Host::getStateText(Host::STATE_PENDING) => 0, + ); + foreach ($this->hostList as $host) { + ++$hostStates[$host::getStateText($host->state)]; + } + $this->view->form = $form; - $this->_helper->viewRenderer('partials/command-form', null, true); + $this->view->objects = $this->hostList; + $this->view->hostStates = $hostStates; + $this->view->hostStatesPieChart = $this->createPieChart( + $hostStates, + $this->translate('Host State'), + array('#44bb77', '#FF5566', '#E066FF', '#77AAFF') + ); + $this->_helper->viewRenderer('partials/command/objects-command-form', null, true); return $form; } diff --git a/modules/monitoring/application/controllers/ServicesController.php b/modules/monitoring/application/controllers/ServicesController.php index dc7feb2da..88df52e46 100644 --- a/modules/monitoring/application/controllers/ServicesController.php +++ b/modules/monitoring/application/controllers/ServicesController.php @@ -33,12 +33,59 @@ class Monitoring_ServicesController extends Controller protected function handleCommandForm(ObjectsCommandForm $form) { + $this->serviceList->setColumns(array( + 'host_name', + 'host_state', + 'service_description', + 'service_state', + 'service_problem', + 'service_handled', + 'service_acknowledged', + 'service_in_downtime' + )); + $form ->setObjects($this->serviceList) ->setRedirectUrl(Url::fromPath('monitoring/services/show')->setParams($this->params)) ->handleRequest(); + + $serviceStates = array( + Service::getStateText(Service::STATE_OK) => 0, + Service::getStateText(Service::STATE_WARNING) => 0, + Service::getStateText(Service::STATE_CRITICAL) => 0, + Service::getStateText(Service::STATE_UNKNOWN) => 0, + Service::getStateText(Service::STATE_PENDING) => 0 + ); + $knownHostStates = array(); + $hostStates = array( + Host::getStateText(Host::STATE_UP) => 0, + Host::getStateText(Host::STATE_DOWN) => 0, + Host::getStateText(Host::STATE_UNREACHABLE) => 0, + Host::getStateText(Host::STATE_PENDING) => 0, + ); + foreach ($this->serviceList as $service) { + ++$serviceStates[$service::getStateText($service->state)]; + if (! isset($knownHostStates[$service->getHost()->getName()])) { + $knownHostStates[$service->getHost()->getName()] = true; + ++$hostStates[$service->getHost()->getStateText($service->host_state)]; + } + } + $this->view->form = $form; - $this->_helper->viewRenderer('partials/command-form', null, true); + $this->view->objects = $this->serviceList; + $this->view->serviceStates = $serviceStates; + $this->view->hostStates = $hostStates; + $this->view->serviceStatesPieChart = $this->createPieChart( + $serviceStates, + $this->translate('Service State'), + array('#44bb77', '#FFCC66', '#FF5566', '#E066FF', '#77AAFF') + ); + $this->view->hostStatesPieChart = $this->createPieChart( + $hostStates, + $this->translate('Host State'), + array('#44bb77', '#FF5566', '#E066FF', '#77AAFF') + ); + $this->_helper->viewRenderer('partials/command/objects-command-form', null, true); return $form; } diff --git a/modules/monitoring/library/Monitoring/Web/Controller/MonitoredObjectController.php b/modules/monitoring/library/Monitoring/Web/Controller/MonitoredObjectController.php index 5de11e1e2..1c3db0799 100644 --- a/modules/monitoring/library/Monitoring/Web/Controller/MonitoredObjectController.php +++ b/modules/monitoring/library/Monitoring/Web/Controller/MonitoredObjectController.php @@ -109,7 +109,9 @@ abstract class MonitoredObjectController extends Controller ->setRedirectUrl(Url::fromPath($this->commandRedirectUrl)->setParams($this->params)) ->handleRequest(); $this->view->form = $form; - $this->_helper->viewRenderer('partials/command-form', null, true); + $this->view->object = $this->object; + $this->view->tabs->remove('dashboard'); + $this->_helper->viewRenderer('partials/command/object-command-form', null, true); return $form; } diff --git a/modules/monitoring/public/css/module.less b/modules/monitoring/public/css/module.less index 675988056..82ee0b629 100644 --- a/modules/monitoring/public/css/module.less +++ b/modules/monitoring/public/css/module.less @@ -190,3 +190,12 @@ div.selection-info { .optionbox input { vertical-align: middle; } + +h1.command-title { + border: none; +} + +hr.command-separator { + border: none; + border-bottom: 2px solid @colorPetrol; +} \ No newline at end of file From 5382f73c535cc3c539f4481c0d6455eec86f264e Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Mon, 2 Feb 2015 16:31:25 +0100 Subject: [PATCH 0494/2920] Drop all old object- and command-view scripts --- .../views/scripts/partials/command-form.phtml | 28 ------ .../scripts/show/components/header.phtml | 46 ---------- .../show/components/hostservicesummary.phtml | 89 ------------------- .../scripts/show/components/statusIcons.phtml | 49 ---------- .../application/views/scripts/show/host.phtml | 31 ------- .../views/scripts/show/service.phtml | 31 ------- 6 files changed, 274 deletions(-) delete mode 100644 modules/monitoring/application/views/scripts/partials/command-form.phtml delete mode 100644 modules/monitoring/application/views/scripts/show/components/header.phtml delete mode 100644 modules/monitoring/application/views/scripts/show/components/hostservicesummary.phtml delete mode 100644 modules/monitoring/application/views/scripts/show/components/statusIcons.phtml delete mode 100644 modules/monitoring/application/views/scripts/show/host.phtml delete mode 100644 modules/monitoring/application/views/scripts/show/service.phtml diff --git a/modules/monitoring/application/views/scripts/partials/command-form.phtml b/modules/monitoring/application/views/scripts/partials/command-form.phtml deleted file mode 100644 index 380687a00..000000000 --- a/modules/monitoring/application/views/scripts/partials/command-form.phtml +++ /dev/null @@ -1,28 +0,0 @@ -
    - tabs->remove('dashboard') ?> -
    -
    -

    icon('help', $form->getHelp()) ?>

    - - - - - - - - - getObjects() as $object): /** @var \Icinga\Module\Monitoring\Object\MonitoredObject $object */ ?> - - getType() === $object::TYPE_HOST): ?> - - - - - - - - -
    icon('host') ?> translate('Host') ?>icon('conf') ?> translate('Service') ?>
    escape($object->getName()) ?>escape($object->getHost()->getName()) ?>escape($object->getName()) ?>
    -
    - -
    diff --git a/modules/monitoring/application/views/scripts/show/components/header.phtml b/modules/monitoring/application/views/scripts/show/components/header.phtml deleted file mode 100644 index 8ba84da43..000000000 --- a/modules/monitoring/application/views/scripts/show/components/header.phtml +++ /dev/null @@ -1,46 +0,0 @@ -getType() === $object::TYPE_SERVICE; - -?> - -compact): ?> - - - - - - - - - - - - - - -
    > - host_state, true); ?>
    - prefixedTimeSince($object->host_last_state_change, true) ?> -
    - escape($object->host_display_name) ?> - host_display_name !== $object->host_name): ?> - (escape($object->host_name) ?>) - - host_address && $object->host_address !== $object->host_name): ?> -
    - escape($object->host_address) ?> - -
    - service_state, true); ?>
    - prefixedTimeSince($object->service_last_state_change, true) ?> -
    - translate('Service') ?>: escape($object->service_display_name) ?> - service_display_name !== $object->service_description): ?> - (escape($object->service_description) ?>) - - render('show/components/statusIcons.phtml') ?> -
    diff --git a/modules/monitoring/application/views/scripts/show/components/hostservicesummary.phtml b/modules/monitoring/application/views/scripts/show/components/hostservicesummary.phtml deleted file mode 100644 index 641dd026a..000000000 --- a/modules/monitoring/application/views/scripts/show/components/hostservicesummary.phtml +++ /dev/null @@ -1,89 +0,0 @@ - $this->object->host_name)); -$currentUrl = Url::fromRequest()->without('limit')->getRelativeUrl(); - -?> -

    compact ? ' data-base-target="col1"' : '' ?>> -stats->services_total > 0): ?> -qlink(sprintf($this->translatePlural('%d configured service:', '%d configured services:', $object->stats->services_total), $object->stats->services_total), $selfUrl) ?> - -translate('No services configured on this host'); ?> - - -stats->services_ok > 0): ?> - qlink( - $object->stats->services_ok, - $selfUrl, - array('service_state' => 0), - array('title' => sprintf($this->translate('Services with state %s'), $this->translate('OK'))) -) ?> - - 'critical', 3 => 'unknown', 1 => 'warning') as $stateId => $state) { - $pre = 'services_' . $state; - if ($object->stats->$pre) { - $handled = $pre . '_handled'; - $unhandled = $pre . '_unhandled'; - $paramsHandled = array('service_state' => $stateId, 'service_handled' => 1); - $paramsUnhandled = array('service_state' => $stateId, 'service_handled' => 0); - if ($object->stats->$unhandled) { - $compareUrl = $selfUrl->with($paramsUnhandled)->getRelativeUrl(); - } else { - $compareUrl = $selfUrl->with($paramsHandled)->getRelativeUrl(); - } - - if ($compareUrl === $currentUrl) { - $active = ' active'; - } else { - $active = ''; - } - - echo ''; - if ($object->stats->$unhandled) { - - echo $this->qlink( - $object->stats->$unhandled, - $selfUrl, - $paramsUnhandled, - array('title' => sprintf($this->translate('Unhandled services with state %s'), $this->translate(strtoupper($state)))) - ); - } - if ($object->stats->$handled) { - - if ($selfUrl->with($paramsHandled)->getRelativeUrl() === $currentUrl) { - $active = ' active'; - } else { - $active = ''; - } - if ($object->stats->$unhandled) { - echo ''; - } - echo $this->qlink( - $object->stats->$handled, - $selfUrl, - $paramsHandled, - array('title' => sprintf($this->translate('Handled services with state %s'), $this->translate(strtoupper($state)))) - ); - if ($object->stats->$unhandled) { - echo "\n"; - } - } - echo "\n"; - } -} - -?> -stats->services_pending): ?> - qlink( - $object->stats->services_pending, - $selfUrl, - array('service_state' => 99), - array('title' => sprintf($this->translate('Services with state %s'), $this->translate('PENDING'))) -) ?> - - -

    - diff --git a/modules/monitoring/application/views/scripts/show/components/statusIcons.phtml b/modules/monitoring/application/views/scripts/show/components/statusIcons.phtml deleted file mode 100644 index d76c07cf2..000000000 --- a/modules/monitoring/application/views/scripts/show/components/statusIcons.phtml +++ /dev/null @@ -1,49 +0,0 @@ -object; - -$isService = $o instanceof Service; -$obj = new \stdClass(); -$obj->handled = - ($isService) ? $o->service_handled : $o->host_handled; -$obj->state = - ($isService) ? $o->service_state : $o->host_state; -$obj->acknowledged = - ($isService) ? $o->service_acknowledged : $o->host_acknowledged; -$obj->in_downtime = - ($isService) ? $o->in_downtime : $o->host_in_downtime; -$obj->notifications_enabled = - ($isService) ? $o->notifications_enabled : $o->service_notifications_enabled; -$obj->active_checks_enabled = - ($isService) ? $o->active_checks_enabled : $o->host_active_checks_enabled; -$obj->passive_checks_enabled = - ($isService) ? $o->passive_checks_enabled : $o->host_passive_checks_enabled; - -$i = array(); -if (! $obj->handled && $obj->state > 0) { - $i[] = $this->icon('attention-alt', $this->translate('Unhandled')); -} - -if ($obj->acknowledged && ! $obj->in_downtime) { - $i[] = $this->icon('ok', $this->translate('Acknowledged')); -} - -if (!$obj->notifications_enabled) { - $i[] = $this->icon('bell-of-empty', $this->translate('Notifications Disabled')); -} - -if ($obj->in_downtime) { - $i[] = $this->icon('plug', $this->translate('In Downtime')); -} - -if (! $obj->active_checks_enabled) { - if ($obj->passive_checks_enabled) { - $i[] = $this->icon('eye-off', $this->translate('Active Checks Disabled')); - } else { - $i[] = $this->icon('eye-off', $this->translate('Active And Passive Checks Disabled')); - } -} - -?> diff --git a/modules/monitoring/application/views/scripts/show/host.phtml b/modules/monitoring/application/views/scripts/show/host.phtml deleted file mode 100644 index c4e0ec9a8..000000000 --- a/modules/monitoring/application/views/scripts/show/host.phtml +++ /dev/null @@ -1,31 +0,0 @@ -host_name !== false): ?> -
    - render('show/components/header.phtml') ?> - render('show/components/hostservicesummary.phtml') ?> -
    -
    - render('show/components/output.phtml') ?> - render('show/components/grapher.phtml') ?> - - - - render('show/components/acknowledgement.phtml') ?> - render('show/components/comments.phtml') ?> - render('show/components/notifications.phtml') ?> - render('show/components/downtime.phtml') ?> - render('show/components/flapping.phtml') ?> - render('show/components/perfdata.phtml') ?> - render('show/components/checksource.phtml') ?> - render('show/components/actions.phtml') ?> - render('show/components/command.phtml') ?> - render('show/components/hostgroups.phtml') ?> - render('show/components/contacts.phtml') ?> - render('show/components/checkstatistics.phtml') ?> - render('show/components/customvars.phtml') ?> - render('show/components/flags.phtml') ?> - -
    -
    - -

    Host not found

    - diff --git a/modules/monitoring/application/views/scripts/show/service.phtml b/modules/monitoring/application/views/scripts/show/service.phtml deleted file mode 100644 index 126d60cb7..000000000 --- a/modules/monitoring/application/views/scripts/show/service.phtml +++ /dev/null @@ -1,31 +0,0 @@ -host_name !== false): ?> -
    - render('show/components/header.phtml') ?> -

    translate("Service detail information") ?>

    -
    -
    - render('show/components/output.phtml') ?> - render('show/components/grapher.phtml') ?> - - - - render('show/components/acknowledgement.phtml') ?> - render('show/components/comments.phtml') ?> - render('show/components/notifications.phtml') ?> - render('show/components/downtime.phtml') ?> - render('show/components/flapping.phtml') ?> - render('show/components/perfdata.phtml') ?> - render('show/components/checksource.phtml') ?> - render('show/components/actions.phtml') ?> - render('show/components/command.phtml') ?> - render('show/components/servicegroups.phtml') ?> - render('show/components/contacts.phtml') ?> - render('show/components/checkstatistics.phtml') ?> - render('show/components/customvars.phtml') ?> - render('show/components/flags.phtml') ?> - -
    -
    - -

    Service not found

    - From 9df2430cbe59e67232a671b20410897a26040db0 Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Mon, 2 Feb 2015 16:31:57 +0100 Subject: [PATCH 0495/2920] Remove redundant help message when scheduling host/service checks --- .../Command/Object/ScheduleServiceCheckCommandForm.php | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/modules/monitoring/application/forms/Command/Object/ScheduleServiceCheckCommandForm.php b/modules/monitoring/application/forms/Command/Object/ScheduleServiceCheckCommandForm.php index b34472d49..4921f54ff 100644 --- a/modules/monitoring/application/forms/Command/Object/ScheduleServiceCheckCommandForm.php +++ b/modules/monitoring/application/forms/Command/Object/ScheduleServiceCheckCommandForm.php @@ -47,16 +47,6 @@ class ScheduleServiceCheckCommandForm extends ObjectsCommandForm $checkTime = new DateTime(); $checkTime->add(new DateInterval('PT1H')); $this->addElements(array( - array( - 'note', - 'command-info', - array( - 'value' => $this->translate( - 'This command is used to schedule the next check of hosts or services. Icinga will re-queue the' - . ' hosts or services to be checked at the time you specify.' - ) - ) - ), array( 'dateTimePicker', 'check_time', From a5fe9a1fe1574f0b2cfba58723b0346937a7d7fe Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Mon, 2 Feb 2015 16:34:29 +0100 Subject: [PATCH 0496/2920] Revert "Introduce link target "_right" to keep a column with tabs rightmost" This reverts commit 618ab4f4b9cdc3975cc096eaabfe04da70244fb0. --- application/views/scripts/config/module.phtml | 2 +- .../application/views/scripts/config/index.phtml | 2 +- .../application/views/scripts/config/security.phtml | 2 +- public/js/icinga/events.js | 10 ---------- 4 files changed, 3 insertions(+), 13 deletions(-) diff --git a/application/views/scripts/config/module.phtml b/application/views/scripts/config/module.phtml index e26ade195..cd6ad5af8 100644 --- a/application/views/scripts/config/module.phtml +++ b/application/views/scripts/config/module.phtml @@ -1,4 +1,4 @@ -
    +
    tabs ?>

    escape($module->getTitle()) ?>

    diff --git a/modules/monitoring/application/views/scripts/config/index.phtml b/modules/monitoring/application/views/scripts/config/index.phtml index deca8d468..b1729f9b1 100644 --- a/modules/monitoring/application/views/scripts/config/index.phtml +++ b/modules/monitoring/application/views/scripts/config/index.phtml @@ -1,4 +1,4 @@ -
    +

    translate('Monitoring Backends') ?>

    diff --git a/modules/monitoring/application/views/scripts/config/security.phtml b/modules/monitoring/application/views/scripts/config/security.phtml index 2a84b2469..71f2a341a 100644 --- a/modules/monitoring/application/views/scripts/config/security.phtml +++ b/modules/monitoring/application/views/scripts/config/security.phtml @@ -1,4 +1,4 @@ -
    +
    tabs ?>
    diff --git a/public/js/icinga/events.js b/public/js/icinga/events.js index b7f2f5cee..e7ac3e3f1 100644 --- a/public/js/icinga/events.js +++ b/public/js/icinga/events.js @@ -482,16 +482,6 @@ targetId = 'col1'; $target = $('#' + targetId); self.icinga.ui.layout1col(); - } else if (targetId === '_right') { - // Ensure that the content is displayed in the rightmost column - $target = $el.closest('.container'); - if ($target.attr('id') === 'col1') { - // As it's not possible to detect what's preceding the current state in the - // history stack this just simulates _main in case the respective element - // is not part of the rightmost column - $target = $('#col1'); - self.icinga.ui.layout1col(); - } } else { $target = $('#' + targetId); } From bc69a3b20f9fb254a55ee8ae2956e02ef7b73e02 Mon Sep 17 00:00:00 2001 From: Marius Hein Date: Mon, 2 Feb 2015 16:40:05 +0100 Subject: [PATCH 0497/2920] Revert "Failure requests: Fix auto refresh and history" This reverts commit 8c758a9f126f81cc50fe290691d284947ec1804d. --- public/js/icinga/loader.js | 16 ++-------------- 1 file changed, 2 insertions(+), 14 deletions(-) diff --git a/public/js/icinga/loader.js b/public/js/icinga/loader.js index abf0d6684..6a85a5144 100644 --- a/public/js/icinga/loader.js +++ b/public/js/icinga/loader.js @@ -107,8 +107,7 @@ url : url, data : data, headers: headers, - context: self, - failure: false + context: self }); req.$target = $target; @@ -556,7 +555,7 @@ // Update history when necessary. Don't do so for requests triggered // by history or autorefresh events if (! req.historyTriggered && ! req.autorefresh) { - if (req.$target.hasClass('container') && req.failure === false) { + if (req.$target.hasClass('container')) { // We only want to care about top-level containers if (req.$target.parent().closest('.container').length === 0) { this.icinga.history.pushCurrentState(); @@ -592,17 +591,6 @@ onFailure: function (req, textStatus, errorThrown) { var url = req.url; - req.failure = true; - - /* - * Test if a manual actions comes in and autorefresh is active: Stop refreshing - */ - if (! req.historyTriggered && ! req.autorefresh && req.$target.data('icingaRefresh') > 0 - && req.$target.data('icingaUrl') !== url) { - req.$target.data('icingaRefresh', 0); - req.$target.data('icingaUrl', url); - } - if (req.status > 0) { this.icinga.logger.error( req.status, From 1d99780a617b44d43f4bb508c8f5bcacf850b22e Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Mon, 2 Feb 2015 16:47:28 +0100 Subject: [PATCH 0498/2920] Remove quotes from tooltip in the roles overview refs #8110 --- application/views/scripts/roles/index.phtml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/application/views/scripts/roles/index.phtml b/application/views/scripts/roles/index.phtml index db4a6aef2..758376c53 100644 --- a/application/views/scripts/roles/index.phtml +++ b/application/views/scripts/roles/index.phtml @@ -52,10 +52,10 @@

    escape($role->groups) ?> "> + title="translate('Remove role %s'), + $name + ) ?>"> icon('cancel') ?>
    Foreign URLs
    Foreign URLstranslate('Actions') ?>
    translate('Name') ?>translate('Permissions') ?>translate('Restrictions') ?> translate('Users') ?> translate('Groups') ?>
    escape($role->permissions, 0, 50) ?> - without(...) or $role->shift(...) would be nice! - $restrictions = clone $role; - unset($restrictions['users']); - unset($restrictions['groups']); - unset($restrictions['permissions']); - ?> - - - - $restriction): ?> - - - - - - -
    escape($restrictionName) ?>escape($restriction) ?>
    - -
    escape($role->users) ?> escape($role->groups) ?> From d9966995d825032698e22fb88b32343d3b5dd3b2 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Tue, 3 Feb 2015 15:14:03 +0100 Subject: [PATCH 0523/2920] git: Exclude Vagrant and Puppet related files when generating an archive --- .gitattributes | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.gitattributes b/.gitattributes index 40b06093e..a05c2f5cd 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,5 +1,8 @@ # Exclude files related to git when generating an archive .git* export-ignore +# Exclude Vagrant and Puppet related files when generating an archive +.puppet* export-ignore +Vagrantfile export-ignore # Normalize puppet manifests' line endings to LF on checkin and prevent conversion to CRLF when the files are checked out .puppet* eol=lf From 338d067aba41dd6e9178cebec5433eecd614196e Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Tue, 3 Feb 2015 15:49:34 +0100 Subject: [PATCH 0524/2920] Add license header fixes #7788 --- Vagrantfile | 2 ++ .../clicommands/AutocompleteCommand.php | 3 +-- application/clicommands/HelpCommand.php | 3 +-- application/clicommands/ModuleCommand.php | 3 +-- application/clicommands/WebCommand.php | 3 +-- .../controllers/AuthenticationController.php | 3 +-- application/controllers/ConfigController.php | 1 + .../controllers/DashboardController.php | 3 +-- application/controllers/ErrorController.php | 1 + application/controllers/FilterController.php | 3 +-- application/controllers/IndexController.php | 3 +-- application/controllers/LayoutController.php | 3 +-- application/controllers/ListController.php | 3 +-- .../controllers/PreferenceController.php | 3 +-- application/controllers/RolesController.php | 1 + application/controllers/SearchController.php | 3 +-- application/controllers/StaticController.php | 3 +-- .../forms/Authentication/LoginForm.php | 3 +-- .../Config/Authentication/DbBackendForm.php | 3 +-- .../Authentication/ExternalBackendForm.php | 3 +-- .../Config/Authentication/LdapBackendForm.php | 3 +-- .../AuthenticationBackendConfigForm.php | 3 +-- .../AuthenticationBackendReorderForm.php | 3 +-- .../Config/General/ApplicationConfigForm.php | 3 +-- .../Config/General/LoggingConfigForm.php | 3 +-- .../forms/Config/GeneralConfigForm.php | 3 +-- .../forms/Config/Resource/DbResourceForm.php | 3 +-- .../Config/Resource/FileResourceForm.php | 3 +-- .../Config/Resource/LdapResourceForm.php | 3 +-- .../Resource/LivestatusResourceForm.php | 3 +-- .../forms/Config/ResourceConfigForm.php | 3 +-- application/forms/ConfigForm.php | 3 +-- application/forms/ConfirmRemovalForm.php | 3 +-- application/forms/Dashboard/DashletForm.php | 3 +-- application/forms/LdapDiscoveryForm.php | 3 +-- application/forms/PreferenceForm.php | 3 +-- application/forms/Security/RoleForm.php | 3 +-- application/views/helpers/DateFormat.php | 3 +-- application/views/helpers/FormDateTime.php | 3 +-- application/views/helpers/FormNumber.php | 3 +-- .../views/helpers/FormTriStateCheckbox.php | 3 +-- application/views/helpers/Util.php | 3 +-- bin/icingacli | 3 +-- bin/license_writer.py | 3 +-- etc/bash_completion.d/icingacli | 3 --- etc/schema/mysql.schema.sql | 2 ++ etc/schema/pgsql.schema.sql | 19 +++------------ icingaweb2.spec | 2 ++ .../Application/ApplicationBootstrap.php | 3 +-- library/Icinga/Application/Benchmark.php | 3 +-- library/Icinga/Application/Cli.php | 3 +-- library/Icinga/Application/Config.php | 3 +-- library/Icinga/Application/EmbeddedWeb.php | 3 +-- library/Icinga/Application/Icinga.php | 3 +-- library/Icinga/Application/LegacyWeb.php | 3 +-- library/Icinga/Application/Loader.php | 3 +-- library/Icinga/Application/Logger.php | 3 +-- .../Icinga/Application/Logger/LogWriter.php | 3 +-- .../Application/Logger/Writer/FileWriter.php | 3 +-- .../Logger/Writer/StdoutWriter.php | 2 +- .../Logger/Writer/SyslogWriter.php | 3 +-- .../Icinga/Application/Modules/Manager.php | 3 +-- library/Icinga/Application/Modules/Module.php | 3 +-- library/Icinga/Application/Platform.php | 3 +-- library/Icinga/Application/Web.php | 3 +-- library/Icinga/Application/functions.php | 3 +-- library/Icinga/Application/webrouter.php | 3 +-- .../Icinga/Authentication/AdmissionLoader.php | 3 +-- library/Icinga/Authentication/AuthChain.php | 3 +-- .../Authentication/Backend/DbUserBackend.php | 3 +-- .../Backend/DbUserGroupBackend.php | 3 +-- .../Backend/ExternalBackend.php | 3 +-- .../Backend/IniUserGroupBackend.php | 3 +-- .../Backend/LdapUserBackend.php | 3 +-- library/Icinga/Authentication/Manager.php | 3 +-- library/Icinga/Authentication/UserBackend.php | 3 +-- .../Authentication/UserGroupBackend.php | 3 +-- library/Icinga/Chart/Axis.php | 3 +-- library/Icinga/Chart/Chart.php | 3 +-- library/Icinga/Chart/Format.php | 3 +-- library/Icinga/Chart/Graph/BarGraph.php | 3 +-- library/Icinga/Chart/Graph/LineGraph.php | 3 +-- library/Icinga/Chart/Graph/StackedGraph.php | 3 +-- library/Icinga/Chart/Graph/Tooltip.php | 5 ++-- library/Icinga/Chart/GridChart.php | 3 +-- library/Icinga/Chart/Inline/Inline.php | 3 +-- library/Icinga/Chart/Inline/PieChart.php | 3 +-- library/Icinga/Chart/Legend.php | 3 +-- library/Icinga/Chart/Palette.php | 3 +-- library/Icinga/Chart/PieChart.php | 3 +-- library/Icinga/Chart/Primitive/Animatable.php | 3 +-- library/Icinga/Chart/Primitive/Animation.php | 3 +-- library/Icinga/Chart/Primitive/Canvas.php | 3 +-- library/Icinga/Chart/Primitive/Circle.php | 3 +-- library/Icinga/Chart/Primitive/Drawable.php | 3 +-- library/Icinga/Chart/Primitive/Line.php | 3 +-- library/Icinga/Chart/Primitive/Path.php | 3 +-- library/Icinga/Chart/Primitive/PieSlice.php | 3 +-- library/Icinga/Chart/Primitive/RawElement.php | 3 +-- library/Icinga/Chart/Primitive/Rect.php | 3 +-- library/Icinga/Chart/Primitive/Styleable.php | 3 +-- library/Icinga/Chart/Primitive/Text.php | 3 +-- library/Icinga/Chart/Render/LayoutBox.php | 3 +-- library/Icinga/Chart/Render/RenderContext.php | 3 +-- library/Icinga/Chart/Render/Rotator.php | 7 ++---- library/Icinga/Chart/SVGRenderer.php | 3 +-- library/Icinga/Chart/Unit/AxisUnit.php | 3 +-- library/Icinga/Chart/Unit/CalendarUnit.php | 3 +-- library/Icinga/Chart/Unit/LinearUnit.php | 3 +-- library/Icinga/Chart/Unit/LogarithmicUnit.php | 3 +-- library/Icinga/Chart/Unit/StaticAxis.php | 3 +-- library/Icinga/Cli/AnsiScreen.php | 3 +-- library/Icinga/Cli/Command.php | 3 +-- library/Icinga/Cli/Documentation.php | 3 +-- .../Cli/Documentation/CommentParser.php | 3 +-- library/Icinga/Cli/Loader.php | 3 +-- library/Icinga/Cli/Params.php | 3 +-- library/Icinga/Cli/Screen.php | 3 +-- library/Icinga/Data/Browsable.php | 3 +-- library/Icinga/Data/ConfigObject.php | 3 +-- library/Icinga/Data/ConnectionInterface.php | 3 +-- .../Icinga/Data/DataArray/ArrayDatasource.php | 5 ++-- library/Icinga/Data/Db/DbConnection.php | 3 +-- library/Icinga/Data/Db/DbQuery.php | 3 +-- library/Icinga/Data/Fetchable.php | 3 +-- library/Icinga/Data/Filter/Filter.php | 3 +-- library/Icinga/Data/Filter/FilterAnd.php | 5 ++-- library/Icinga/Data/Filter/FilterChain.php | 7 +++--- library/Icinga/Data/Filter/FilterEqual.php | 3 +-- .../Data/Filter/FilterEqualOrGreaterThan.php | 3 +-- .../Data/Filter/FilterEqualOrLessThan.php | 3 +-- .../Icinga/Data/Filter/FilterException.php | 3 +-- .../Icinga/Data/Filter/FilterExpression.php | 3 +-- .../Icinga/Data/Filter/FilterGreaterThan.php | 3 +-- library/Icinga/Data/Filter/FilterLessThan.php | 3 +-- library/Icinga/Data/Filter/FilterMatch.php | 3 +-- library/Icinga/Data/Filter/FilterMatchNot.php | 3 +-- library/Icinga/Data/Filter/FilterNot.php | 3 +-- library/Icinga/Data/Filter/FilterNotEqual.php | 3 +-- library/Icinga/Data/Filter/FilterOr.php | 3 +-- .../Data/Filter/FilterParseException.php | 3 +-- .../Icinga/Data/Filter/FilterQueryString.php | 3 +-- library/Icinga/Data/Filterable.php | 3 +-- library/Icinga/Data/Identifiable.php | 3 +-- library/Icinga/Data/Limitable.php | 3 +-- library/Icinga/Data/PivotTable.php | 3 +-- library/Icinga/Data/QueryInterface.php | 3 +-- library/Icinga/Data/Queryable.php | 3 +-- library/Icinga/Data/ResourceFactory.php | 3 +-- library/Icinga/Data/Selectable.php | 3 +-- library/Icinga/Data/SimpleQuery.php | 3 +-- library/Icinga/Data/Sortable.php | 3 +-- library/Icinga/Data/Tree/Node.php | 3 +-- library/Icinga/Data/Tree/NodeInterface.php | 3 +-- .../Exception/AuthenticationException.php | 3 +-- .../Icinga/Exception/ConfigurationError.php | 3 +-- library/Icinga/Exception/IcingaException.php | 3 +-- .../Exception/InvalidPropertyException.php | 3 +-- .../Exception/MissingParameterException.php | 3 +-- library/Icinga/Exception/NotFoundError.php | 3 +-- .../Icinga/Exception/NotImplementedError.php | 3 +-- library/Icinga/Exception/NotReadableError.php | 3 +-- library/Icinga/Exception/NotWritableError.php | 3 +-- library/Icinga/Exception/ProgrammingError.php | 3 +-- library/Icinga/Exception/QueryException.php | 3 +-- .../Exception/SystemPermissionException.php | 3 +-- library/Icinga/File/Csv.php | 3 +-- .../File/FileExtensionFilterIterator.php | 3 +-- library/Icinga/File/Ini/IniEditor.php | 3 +-- library/Icinga/File/Ini/IniWriter.php | 3 +-- library/Icinga/File/NonEmptyFileIterator.php | 3 +-- library/Icinga/File/Pdf.php | 3 +-- library/Icinga/Protocol/Dns.php | 3 +-- .../File/Exception/FileReaderException.php | 2 +- library/Icinga/Protocol/File/FileIterator.php | 3 +-- library/Icinga/Protocol/File/FileQuery.php | 3 +-- library/Icinga/Protocol/File/FileReader.php | 3 +-- library/Icinga/Protocol/Ldap/Connection.php | 3 +-- library/Icinga/Protocol/Ldap/Discovery.php | 5 ++-- library/Icinga/Protocol/Ldap/Exception.php | 3 +-- library/Icinga/Protocol/Ldap/LdapUtils.php | 3 +-- library/Icinga/Protocol/Ldap/Node.php | 3 +-- library/Icinga/Protocol/Ldap/Query.php | 3 +-- library/Icinga/Protocol/Ldap/Root.php | 3 +-- .../Icinga/Protocol/Livestatus/Connection.php | 5 ++-- library/Icinga/Protocol/Livestatus/Query.php | 9 ++++---- .../Protocol/Livestatus/ResponseRow.php | 1 + library/Icinga/Protocol/Nrpe/Connection.php | 3 +-- library/Icinga/Protocol/Nrpe/Packet.php | 3 +-- library/Icinga/Security/SecurityException.php | 1 + library/Icinga/Test/BaseTestCase.php | 3 +-- library/Icinga/Test/DbTest.php | 3 +-- library/Icinga/User.php | 3 +-- library/Icinga/User/Preferences.php | 3 +-- .../User/Preferences/PreferencesStore.php | 3 +-- .../Icinga/User/Preferences/Store/DbStore.php | 3 +-- .../User/Preferences/Store/IniStore.php | 3 +-- library/Icinga/Util/Color.php | 3 +-- library/Icinga/Util/ConfigAwareFactory.php | 3 +-- library/Icinga/Util/DateTimeFactory.php | 3 +-- library/Icinga/Util/Dimension.php | 3 +-- .../Icinga/Util/EnumeratingFilterIterator.php | 3 +-- library/Icinga/Util/File.php | 3 +-- library/Icinga/Util/Format.php | 3 +-- library/Icinga/Util/String.php | 3 +-- library/Icinga/Util/TimezoneDetect.php | 3 +-- library/Icinga/Util/Translator.php | 3 +-- library/Icinga/Web/Controller.php | 1 + .../Web/Controller/ActionController.php | 1 + .../Controller/BasePreferenceController.php | 3 +-- .../Web/Controller/ControllerTabCollector.php | 3 +-- .../Web/Controller/ModuleActionController.php | 3 +-- library/Icinga/Web/FileCache.php | 2 +- library/Icinga/Web/Form.php | 1 + .../Web/Form/Decorator/ConditionalHidden.php | 3 +-- .../Web/Form/Decorator/ElementDoubler.php | 3 +-- .../Web/Form/Decorator/NoScriptApply.php | 3 +-- library/Icinga/Web/Form/Element/Button.php | 3 +-- .../Web/Form/Element/CsrfCounterMeasure.php | 3 +-- .../Web/Form/Element/DateTimePicker.php | 3 +-- library/Icinga/Web/Form/Element/Note.php | 3 +-- library/Icinga/Web/Form/Element/Number.php | 3 +-- .../Web/Form/Element/TriStateCheckbox.php | 3 +-- library/Icinga/Web/Form/FormElement.php | 3 +-- .../Web/Form/InvalidCSRFTokenException.php | 3 +-- .../Form/Validator/DateFormatValidator.php | 3 +-- .../Web/Form/Validator/DateTimeValidator.php | 3 +-- .../Form/Validator/ReadablePathValidator.php | 3 +-- .../Form/Validator/TimeFormatValidator.php | 3 +-- .../Web/Form/Validator/TriStateValidator.php | 3 +-- .../Form/Validator/WritablePathValidator.php | 3 +-- library/Icinga/Web/Hook.php | 3 +-- library/Icinga/Web/Hook/GrapherHook.php | 3 +-- library/Icinga/Web/Hook/TicketHook.php | 3 +-- library/Icinga/Web/Hook/WebBaseHook.php | 5 ++-- library/Icinga/Web/JavaScript.php | 3 +-- library/Icinga/Web/LessCompiler.php | 3 +-- library/Icinga/Web/Menu.php | 3 +-- .../Web/Menu/ForeignMenuItemRenderer.php | 3 +-- library/Icinga/Web/Menu/MenuItemRenderer.php | 3 +-- .../Web/Menu/MonitoringMenuItemRenderer.php | 3 +-- .../Web/Menu/ProblemMenuItemRenderer.php | 1 + .../Menu/UnhandledHostMenuItemRenderer.php | 1 + .../Menu/UnhandledServiceMenuItemRenderer.php | 1 + library/Icinga/Web/MenuRenderer.php | 3 +-- library/Icinga/Web/Notification.php | 3 +-- .../Web/Paginator/Adapter/QueryAdapter.php | 3 +-- .../ScrollingStyle/SlidingWithBorder.php | 5 ++-- library/Icinga/Web/Request.php | 3 +-- library/Icinga/Web/Response.php | 3 +-- library/Icinga/Web/Session.php | 3 +-- library/Icinga/Web/Session/PhpSession.php | 3 +-- library/Icinga/Web/Session/Session.php | 3 +-- .../Icinga/Web/Session/SessionNamespace.php | 3 +-- library/Icinga/Web/StyleSheet.php | 3 +-- library/Icinga/Web/Url.php | 3 +-- library/Icinga/Web/UrlParams.php | 5 ++-- library/Icinga/Web/View.php | 3 +-- library/Icinga/Web/View/DateTimeRenderer.php | 3 +-- library/Icinga/Web/View/helpers/format.php | 3 +-- library/Icinga/Web/View/helpers/generic.php | 3 +-- library/Icinga/Web/View/helpers/url.php | 5 ++-- library/Icinga/Web/ViewStream.php | 3 +-- library/Icinga/Web/Widget.php | 3 +-- library/Icinga/Web/Widget/AbstractWidget.php | 3 +-- .../Web/Widget/Chart/HistoryColorGrid.php | 3 +-- library/Icinga/Web/Widget/Chart/InlinePie.php | 3 +-- library/Icinga/Web/Widget/Dashboard.php | 3 +-- .../Icinga/Web/Widget/Dashboard/Dashlet.php | 3 +-- library/Icinga/Web/Widget/Dashboard/Pane.php | 3 +-- .../Web/Widget/Dashboard/UserWidget.php | 3 +-- library/Icinga/Web/Widget/FilterEditor.php | 9 ++++---- library/Icinga/Web/Widget/FilterWidget.php | 5 ++-- library/Icinga/Web/Widget/Limiter.php | 3 +-- library/Icinga/Web/Widget/SearchDashboard.php | 3 +-- library/Icinga/Web/Widget/SortBox.php | 3 +-- library/Icinga/Web/Widget/Tab.php | 3 +-- .../Web/Widget/Tabextension/BasketAction.php | 3 +-- .../Widget/Tabextension/DashboardAction.php | 3 +-- .../Widget/Tabextension/DashboardSettings.php | 5 ++-- .../Web/Widget/Tabextension/OutputFormat.php | 3 +-- .../Web/Widget/Tabextension/Tabextension.php | 3 +-- library/Icinga/Web/Widget/Tabs.php | 3 +-- library/Icinga/Web/Widget/Widget.php | 3 +-- library/Icinga/Web/Window.php | 3 +-- library/Icinga/Web/Wizard.php | 3 +-- .../controllers/IcingawebController.php | 3 +-- .../controllers/IndexController.php | 3 +-- .../controllers/ModuleController.php | 3 +-- .../controllers/StyleController.php | 1 + modules/doc/configuration.php | 3 +-- modules/doc/library/Doc/DocController.php | 3 +-- modules/doc/library/Doc/DocIterator.php | 3 +-- modules/doc/library/Doc/DocParser.php | 3 +-- modules/doc/library/Doc/DocTree.php | 3 +-- .../Exception/ChapterNotFoundException.php | 3 +-- .../Doc/Exception/DocEmptyException.php | 3 +-- .../library/Doc/Exception/DocException.php | 3 +-- modules/doc/library/Doc/Renderer.php | 3 +-- modules/doc/library/Doc/Section.php | 3 +-- .../doc/library/Doc/SectionFilterIterator.php | 3 +-- modules/doc/library/Doc/SectionRenderer.php | 3 +-- modules/doc/library/Doc/TocRenderer.php | 3 +-- modules/doc/public/css/module.less | 2 ++ modules/doc/run.php | 1 + .../clicommands/ConferenceCommand.php | 3 +-- .../application/clicommands/ListCommand.php | 3 +-- .../application/clicommands/NrpeCommand.php | 3 +-- .../controllers/AlertsummaryController.php | 3 +-- .../controllers/ChartController.php | 3 +-- .../controllers/ConfigController.php | 3 +-- .../controllers/HostController.php | 3 +-- .../controllers/HostsController.php | 3 +-- .../controllers/ListController.php | 1 + .../controllers/ProcessController.php | 3 +-- .../controllers/ServiceController.php | 3 +-- .../controllers/ServicesController.php | 3 +-- .../controllers/ShowController.php | 3 +-- .../controllers/TacticalController.php | 3 +-- .../controllers/TimelineController.php | 3 +-- .../application/forms/Command/CommandForm.php | 3 +-- .../DisableNotificationsExpireCommandForm.php | 3 +-- .../ToggleInstanceFeaturesCommandForm.php | 3 +-- .../Object/AcknowledgeProblemCommandForm.php | 3 +-- .../Command/Object/AddCommentCommandForm.php | 3 +-- .../Command/Object/CheckNowCommandForm.php | 3 +-- .../Object/DeleteCommentCommandForm.php | 3 +-- .../Object/DeleteDowntimeCommandForm.php | 3 +-- .../Command/Object/ObjectsCommandForm.php | 3 +-- .../Object/ProcessCheckResultCommandForm.php | 3 +-- .../RemoveAcknowledgementCommandForm.php | 3 +-- .../Object/ScheduleHostCheckCommandForm.php | 3 +-- .../ScheduleHostDowntimeCommandForm.php | 3 +-- .../ScheduleServiceCheckCommandForm.php | 3 +-- .../ScheduleServiceDowntimeCommandForm.php | 3 +-- .../ToggleObjectFeaturesCommandForm.php | 3 +-- .../forms/Config/BackendConfigForm.php | 3 +-- .../Config/Instance/LocalInstanceForm.php | 3 +-- .../Config/Instance/RemoteInstanceForm.php | 3 +-- .../forms/Config/InstanceConfigForm.php | 3 +-- .../forms/Config/SecurityConfigForm.php | 3 +-- .../application/forms/EventOverviewForm.php | 3 +-- .../application/forms/Setup/BackendPage.php | 3 +-- .../forms/Setup/IdoResourcePage.php | 3 +-- .../application/forms/Setup/InstancePage.php | 3 +-- .../forms/Setup/LivestatusResourcePage.php | 3 +-- .../application/forms/Setup/SecurityPage.php | 3 +-- .../application/forms/Setup/WelcomePage.php | 3 +-- .../application/forms/StatehistoryForm.php | 3 +-- .../views/helpers/CheckPerformance.php | 3 +-- .../views/helpers/ContactFlags.php | 3 +-- .../application/views/helpers/Customvar.php | 1 + .../application/views/helpers/Link.php | 1 + .../views/helpers/MonitoringFlags.php | 3 +-- .../application/views/helpers/Perfdata.php | 3 +-- .../views/helpers/PluginOutput.php | 3 +-- .../views/helpers/ResolveMacros.php | 3 +-- .../views/helpers/RuntimeVariables.php | 3 +-- .../views/helpers/SelectionToolbar.php | 3 +-- modules/monitoring/configuration.php | 1 + .../monitoring/library/Monitoring/Backend.php | 1 + .../Monitoring/Backend/Ido/IdoBackend.php | 1 + .../Backend/Ido/Query/AllcontactsQuery.php | 3 +-- .../Backend/Ido/Query/CommandQuery.php | 5 ++-- .../Backend/Ido/Query/CommentQuery.php | 3 +-- .../Ido/Query/CommentdeletionhistoryQuery.php | 3 +-- .../Backend/Ido/Query/CommenthistoryQuery.php | 3 +-- .../Backend/Ido/Query/ContactQuery.php | 3 +-- .../Backend/Ido/Query/ContactgroupQuery.php | 3 +-- .../Backend/Ido/Query/CustomvarQuery.php | 3 +-- .../Backend/Ido/Query/DowntimeQuery.php | 1 + .../Ido/Query/DowntimeendhistoryQuery.php | 3 +-- .../Ido/Query/DowntimestarthistoryQuery.php | 3 +-- .../Backend/Ido/Query/EventHistoryQuery.php | 1 + .../Backend/Ido/Query/EventgridQuery.php | 3 +-- .../Backend/Ido/Query/GroupsummaryQuery.php | 3 +-- .../Backend/Ido/Query/HostgroupQuery.php | 3 +-- .../Backend/Ido/Query/HoststatusQuery.php | 3 +-- .../Monitoring/Backend/Ido/Query/IdoQuery.php | 3 +-- .../Backend/Ido/Query/NotificationQuery.php | 1 + .../Ido/Query/NotificationhistoryQuery.php | 3 +-- .../Backend/Ido/Query/ProgramstatusQuery.php | 3 +-- .../Backend/Ido/Query/RuntimesummaryQuery.php | 3 +-- .../Ido/Query/RuntimevariablesQuery.php | 3 +-- .../Backend/Ido/Query/ServicegroupQuery.php | 3 +-- .../Backend/Ido/Query/StatehistoryQuery.php | 1 + .../Backend/Ido/Query/StatusQuery.php | 3 +-- .../Backend/Ido/Query/StatusSummaryQuery.php | 3 +-- .../Backend/Livestatus/LivestatusBackend.php | 1 + .../Livestatus/Query/DowntimeQuery.php | 3 +-- .../Livestatus/Query/HostgroupQuery.php | 3 +-- .../Livestatus/Query/ServicegroupQuery.php | 3 +-- .../Backend/Livestatus/Query/StatusQuery.php | 3 +-- .../Livestatus/Query/StatusSummaryQuery.php | 7 +++--- .../Monitoring/Backend/MonitoringBackend.php | 1 + .../library/Monitoring/BackendStep.php | 3 +-- .../library/Monitoring/Cli/CliUtils.php | 3 +-- .../Command/Exception/TransportException.php | 3 +-- .../Monitoring/Command/IcingaCommand.php | 3 +-- .../DisableNotificationsExpireCommand.php | 3 +-- .../Instance/ToggleInstanceFeatureCommand.php | 3 +-- .../Object/AcknowledgeProblemCommand.php | 3 +-- .../Command/Object/AddCommentCommand.php | 3 +-- .../Command/Object/DeleteCommentCommand.php | 3 +-- .../Command/Object/DeleteDowntimeCommand.php | 3 +-- .../Command/Object/ObjectCommand.php | 3 +-- .../Object/ProcessCheckResultCommand.php | 3 +-- .../Object/PropagateHostDowntimeCommand.php | 3 +-- .../Object/RemoveAcknowledgementCommand.php | 3 +-- .../Object/ScheduleHostCheckCommand.php | 3 +-- .../Object/ScheduleHostDowntimeCommand.php | 3 +-- .../Object/ScheduleServiceCheckCommand.php | 3 +-- .../Object/ScheduleServiceDowntimeCommand.php | 3 +-- .../Object/ToggleObjectFeatureCommand.php | 3 +-- .../Command/Object/WithCommentCommand.php | 3 +-- .../IcingaCommandFileCommandRenderer.php | 1 + .../IcingaCommandRendererInterface.php | 1 + .../Command/Transport/CommandTransport.php | 3 +-- .../Transport/CommandTransportInterface.php | 3 +-- .../Command/Transport/LocalCommandFile.php | 3 +-- .../Command/Transport/RemoteCommandFile.php | 3 +-- .../library/Monitoring/Controller.php | 3 +-- .../library/Monitoring/DataView/Command.php | 5 ++-- .../library/Monitoring/DataView/Comment.php | 3 +-- .../library/Monitoring/DataView/Contact.php | 3 +-- .../Monitoring/DataView/Contactgroup.php | 3 +-- .../library/Monitoring/DataView/Customvar.php | 3 +-- .../library/Monitoring/DataView/DataView.php | 3 +-- .../library/Monitoring/DataView/Downtime.php | 3 +-- .../Monitoring/DataView/EventHistory.php | 1 + .../library/Monitoring/DataView/Eventgrid.php | 3 +-- .../Monitoring/DataView/Groupsummary.php | 3 +-- .../Monitoring/DataView/HostStatus.php | 3 +-- .../library/Monitoring/DataView/Hostgroup.php | 3 +-- .../Monitoring/DataView/Notification.php | 3 +-- .../Monitoring/DataView/Programstatus.php | 3 +-- .../Monitoring/DataView/Runtimesummary.php | 3 +-- .../Monitoring/DataView/Runtimevariables.php | 3 +-- .../Monitoring/DataView/ServiceStatus.php | 3 +-- .../Monitoring/DataView/Servicegroup.php | 3 +-- .../Monitoring/DataView/StatusSummary.php | 3 +-- .../library/Monitoring/Environment.php | 3 +-- .../Exception/UnsupportedBackendException.php | 3 +-- .../library/Monitoring/InstanceStep.php | 3 +-- .../library/Monitoring/MonitoringWizard.php | 3 +-- .../library/Monitoring/Object/Host.php | 3 +-- .../library/Monitoring/Object/HostList.php | 1 + .../Monitoring/Object/MonitoredObject.php | 3 +-- .../library/Monitoring/Object/ObjectList.php | 1 + .../library/Monitoring/Object/Service.php | 3 +-- .../library/Monitoring/Object/ServiceList.php | 1 + .../monitoring/library/Monitoring/Plugin.php | 3 +-- .../library/Monitoring/Plugin/Perfdata.php | 3 +-- .../library/Monitoring/Plugin/PerfdataSet.php | 3 +-- .../library/Monitoring/SecurityStep.php | 5 ++-- .../library/Monitoring/Timeline/TimeEntry.php | 3 +-- .../library/Monitoring/Timeline/TimeLine.php | 3 +-- .../library/Monitoring/Timeline/TimeRange.php | 3 +-- .../Controller/MonitoredObjectController.php | 1 + .../Monitoring/Web/Hook/HostActionsHook.php | 1 + .../Web/Hook/TimelineProviderHook.php | 3 +-- .../Monitoring/Web/Widget/SelectBox.php | 5 ++-- modules/monitoring/public/css/module.less | 7 +++--- modules/monitoring/public/js/module.js | 3 +-- .../views/helpers/MonitoringFlagsTest.php | 3 +-- .../views/helpers/ResolveMacrosTest.php | 3 +-- .../Monitoring/Plugin/PerfdataSetTest.php | 3 +-- .../Monitoring/Plugin/PerfdataTest.php | 3 +-- .../test/php/regression/Bug6088Test.php | 3 +-- .../test/php/regression/Bug7043Test.php | 3 ++- .../application/clicommands/ConfigCommand.php | 3 +-- .../application/clicommands/TokenCommand.php | 3 +-- .../controllers/IndexController.php | 3 +-- .../application/forms/AdminAccountPage.php | 3 +-- .../application/forms/AuthBackendPage.php | 3 +-- .../application/forms/AuthenticationPage.php | 3 +-- .../forms/DatabaseCreationPage.php | 3 +-- .../application/forms/DbResourcePage.php | 3 +-- .../application/forms/GeneralConfigPage.php | 3 +-- .../forms/LdapDiscoveryConfirmPage.php | 3 +-- .../application/forms/LdapDiscoveryPage.php | 3 +-- .../application/forms/LdapResourcePage.php | 3 +-- .../setup/application/forms/ModulePage.php | 3 +-- .../application/forms/PreferencesPage.php | 3 +-- .../application/forms/RequirementsPage.php | 3 +-- .../setup/application/forms/SummaryPage.php | 3 +-- .../setup/application/forms/WelcomePage.php | 3 +-- .../Setup/Exception/SetupException.php | 5 ++-- modules/setup/library/Setup/Requirements.php | 3 +-- modules/setup/library/Setup/Setup.php | 3 +-- modules/setup/library/Setup/SetupWizard.php | 3 +-- modules/setup/library/Setup/Step.php | 3 +-- .../Setup/Steps/AuthenticationStep.php | 3 +-- .../library/Setup/Steps/DatabaseStep.php | 3 +-- .../library/Setup/Steps/GeneralConfigStep.php | 3 +-- .../library/Setup/Steps/ResourceStep.php | 3 +-- modules/setup/library/Setup/Utils/DbTool.php | 3 +-- .../library/Setup/Utils/EnableModuleStep.php | 3 +-- .../setup/library/Setup/Utils/MakeDirStep.php | 3 +-- .../Web/Form/Validator/TokenValidator.php | 3 +-- modules/setup/library/Setup/WebWizard.php | 3 +-- modules/setup/library/Setup/Webserver.php | 3 +-- .../setup/library/Setup/Webserver/Apache.php | 3 +-- .../setup/library/Setup/Webserver/Nginx.php | 3 +-- .../application/clicommands/PhpCommand.php | 3 +-- .../clicommands/CompileCommand.php | 3 +-- .../clicommands/RefreshCommand.php | 3 +-- .../Translation/Cli/TranslationCommand.php | 3 +-- .../Util/GettextTranslationHelper.php | 3 +-- packages/files/bin/icingacli | 1 + packages/files/public/index.php | 1 + public/css/icinga/defaults.less | 3 +-- public/css/icinga/forms.less | 3 +-- public/css/icinga/header-elements.less | 3 +-- public/css/icinga/layout-colors.less | 3 +-- public/css/icinga/layout-structure.less | 3 +-- public/css/icinga/login.less | 5 ++-- public/css/icinga/main-content.less | 5 ++-- public/css/icinga/menu.less | 3 +-- public/css/icinga/monitoring-colors.less | 17 +++++++------- public/css/icinga/pagination.less | 3 +-- public/css/icinga/selection-toolbar.less | 3 +-- public/css/icinga/setup.less | 4 +++- public/css/icinga/tabs.less | 3 +-- public/css/icinga/widgets.less | 5 ++-- public/css/pdf/pdfprint.less | 3 +-- public/index.php | 3 +-- public/js/helpers.js | 3 +-- public/js/icinga.js | 3 +-- public/js/icinga/behavior/form.js | 3 +-- public/js/icinga/behavior/navigation.js | 5 ++-- public/js/icinga/behavior/sparkline.js | 3 +-- public/js/icinga/behavior/tooltip.js | 3 +-- public/js/icinga/behavior/tristate.js | 5 ++-- public/js/icinga/eventlistener.js | 3 +-- public/js/icinga/events.js | 3 +-- public/js/icinga/history.js | 3 +-- public/js/icinga/loader.js | 3 +-- public/js/icinga/logger.js | 3 +-- public/js/icinga/module.js | 3 +-- public/js/icinga/timer.js | 3 +-- public/js/icinga/timezone.js | 4 +++- public/js/icinga/ui.js | 23 +++++++++---------- public/js/icinga/utils.js | 3 +-- .../Authentication/DbBackendFormTest.php | 3 +-- .../Authentication/LdapBackendFormTest.php | 3 +-- .../AuthenticationBackendReorderFormTest.php | 3 +-- .../Config/Resource/DbResourceFormTest.php | 3 +-- .../Config/Resource/LdapResourceFormTest.php | 3 +-- .../Resource/LivestatusResourceFormTest.php | 3 +-- .../views/helpers/DateFormatTestBroken.php | 3 +-- test/php/bootstrap.php | 3 +-- .../library/Icinga/Application/ConfigTest.php | 3 +-- .../library/Icinga/Application/LoaderTest.php | 3 +-- .../library/Icinga/Chart/GraphChartTest.php | 3 +-- .../php/library/Icinga/Chart/PieChartTest.php | 5 ++-- .../library/Icinga/Data/ConfigObjectTest.php | 3 +-- .../Data/DataArray/ArrayDatasourceTest.php | 3 +-- .../library/Icinga/Data/Filter/FilterTest.php | 3 +-- test/php/library/Icinga/File/CsvTest.php | 3 +-- .../library/Icinga/File/Ini/IniWriterTest.php | 3 +-- .../Icinga/Logger/Writer/StreamWriterTest.php | 3 +-- .../Icinga/Protocol/Ldap/QueryTest.php | 3 +-- .../library/Icinga/Test/BaseTestCaseTest.php | 3 +-- .../library/Icinga/User/PreferencesTest.php | 3 +-- .../library/Icinga/User/Store/DbStoreTest.php | 3 +-- .../Icinga/User/Store/IniStoreTest.php | 3 +-- test/php/library/Icinga/UserTest.php | 3 +-- .../Icinga/Util/DateTimeFactoryTest.php | 3 +-- .../php/library/Icinga/Util/DimensionTest.php | 3 +-- test/php/library/Icinga/Util/FileTest.php | 3 +-- test/php/library/Icinga/Util/StringTest.php | 3 +-- .../library/Icinga/Util/TranslatorTest.php | 3 +-- .../Web/Form/Element/DateTimePickerTest.php | 3 +-- .../Validator/DateFormatValidatorTest.php | 3 +-- .../Validator/TimeFormatValidatorTest.php | 3 +-- .../Validator/WritablePathValidatorTest.php | 3 +-- test/php/library/Icinga/Web/FormTest.php | 3 +-- test/php/library/Icinga/Web/HookTest.php | 3 +-- test/php/library/Icinga/Web/MenuTest.php | 3 +-- .../ScrollingStyle/SlidingWithBorderTest.php | 3 +-- .../Icinga/Web/Session/PhpSessionTest.php | 3 +-- .../Web/Session/SessionNamespaceTest.php | 3 +-- test/php/library/Icinga/Web/UrlTest.php | 3 +-- .../Icinga/Web/View/DateTimeRendererTest.php | 3 +-- .../Icinga/Web/Widget/DashboardTest.php | 3 +-- .../Icinga/Web/Widget/SearchDashboardTest.php | 3 +-- test/php/regression/Bug4102Test.php | 3 +-- test/php/regression/Bug6284Test.php | 3 +-- test/php/regression/Bug6432Test.php | 3 +-- 590 files changed, 652 insertions(+), 1165 deletions(-) diff --git a/Vagrantfile b/Vagrantfile index 1e5e3a073..9090b23aa 100644 --- a/Vagrantfile +++ b/Vagrantfile @@ -1,6 +1,8 @@ # -*- mode: ruby -*- # vi: set ft=ruby : +# Icinga Web 2 | (c) 2013-2015 Icinga Development Team | http://www.gnu.org/licenses/gpl-2.0.txt + VAGRANTFILE_API_VERSION = "2" VAGRANT_REQUIRED_VERSION = "1.5.0" diff --git a/application/clicommands/AutocompleteCommand.php b/application/clicommands/AutocompleteCommand.php index 5a5a0e0c0..045ee8cdc 100644 --- a/application/clicommands/AutocompleteCommand.php +++ b/application/clicommands/AutocompleteCommand.php @@ -1,6 +1,5 @@ render($order, $data, $format)); } -} \ No newline at end of file +} diff --git a/library/Icinga/Chart/GridChart.php b/library/Icinga/Chart/GridChart.php index 190e09bf9..b95fa1fc4 100644 --- a/library/Icinga/Chart/GridChart.php +++ b/library/Icinga/Chart/GridChart.php @@ -1,6 +1,5 @@ element->toSvg($ctx); return $this->rotate($ctx, $el, $this->degrees); } -} \ No newline at end of file +} diff --git a/library/Icinga/Chart/SVGRenderer.php b/library/Icinga/Chart/SVGRenderer.php index da6015ceb..7de8463bb 100644 --- a/library/Icinga/Chart/SVGRenderer.php +++ b/library/Icinga/Chart/SVGRenderer.php @@ -1,6 +1,5 @@ filters as & $filter) { $filter = clone $filter; } - } + } } diff --git a/library/Icinga/Data/Filter/FilterEqual.php b/library/Icinga/Data/Filter/FilterEqual.php index 66e4c06ad..1e567dbf1 100644 --- a/library/Icinga/Data/Filter/FilterEqual.php +++ b/library/Icinga/Data/Filter/FilterEqual.php @@ -1,6 +1,5 @@ matches($res)) continue; $result[] = $res; } - + if ($query->hasOrder()) { usort($result, array($query, 'compare')); } diff --git a/library/Icinga/Protocol/Livestatus/Query.php b/library/Icinga/Protocol/Livestatus/Query.php index a421c7e71..94380dfa6 100644 --- a/library/Icinga/Protocol/Livestatus/Query.php +++ b/library/Icinga/Protocol/Livestatus/Query.php @@ -1,6 +1,5 @@ raw SplArray // $res -> object - // $cv -> + // $cv -> // $result -> object to be returned $result = (object) array(); $res = $this->withHeaders($row); @@ -142,7 +141,7 @@ class Query extends SimpleQuery } } - + return $result; } @@ -313,7 +312,7 @@ class Query extends SimpleQuery } elseif (is_array($col)) { foreach ($col as $k) { $columns[$k] = true; - } + } } else { $columns[$col] = true; } diff --git a/library/Icinga/Protocol/Livestatus/ResponseRow.php b/library/Icinga/Protocol/Livestatus/ResponseRow.php index d4b0fd7cb..9cb67ccf3 100644 --- a/library/Icinga/Protocol/Livestatus/ResponseRow.php +++ b/library/Icinga/Protocol/Livestatus/ResponseRow.php @@ -1,4 +1,5 @@ view; } -} \ No newline at end of file +} diff --git a/library/Icinga/Web/JavaScript.php b/library/Icinga/Web/JavaScript.php index 9fa687042..a8913d3e7 100644 --- a/library/Icinga/Web/JavaScript.php +++ b/library/Icinga/Web/JavaScript.php @@ -1,6 +1,5 @@ reIndexAll(); - return $this; + return $this; } public function remove($param) diff --git a/library/Icinga/Web/View.php b/library/Icinga/Web/View.php index 2122662ac..fe232af86 100644 --- a/library/Icinga/Web/View.php +++ b/library/Icinga/Web/View.php @@ -1,6 +1,5 @@ addHelperFunction('icon', function ($img, $title = null, array $propertie $properties['alt'] = $title; $properties['title'] = $title; } - + if ($class !== null) { if (isset($props['class'])) { $properties['class'] .= ' ' . $class; diff --git a/library/Icinga/Web/ViewStream.php b/library/Icinga/Web/ViewStream.php index e5dacd879..6abf49ac3 100644 --- a/library/Icinga/Web/ViewStream.php +++ b/library/Icinga/Web/ViewStream.php @@ -1,6 +1,5 @@ filter === null) { - $this->filter = Filter::fromQueryString((string) $this->url()->getParams()); + $this->filter = Filter::fromQueryString((string) $this->url()->getParams()); } return $this->filter; } @@ -404,7 +403,7 @@ class FilterEditor extends AbstractWidget protected function renderFilterExpression(FilterExpression $filter) { if ($this->addTo && $this->addTo === $filter->getId()) { - return + return preg_replace( '/ class="autosubmit"/', ' class="autofocus"', @@ -544,7 +543,7 @@ class FilterEditor extends AbstractWidget $cols[$active] = str_replace('_', ' ', ucfirst(ltrim($active, '_'))); } - return $this->select($this->elementId('column', $filter), $cols, $active); + return $this->select($this->elementId('column', $filter), $cols, $active); } protected function applyChanges($changes) diff --git a/library/Icinga/Web/Widget/FilterWidget.php b/library/Icinga/Web/Widget/FilterWidget.php index cf47ef581..bd79c25e0 100644 --- a/library/Icinga/Web/Widget/FilterWidget.php +++ b/library/Icinga/Web/Widget/FilterWidget.php @@ -1,6 +1,5 @@ renderFilter($this->filter); - + $editorUrl = clone $url; $editorUrl->setParam('modifyFilter', true); if ($this->filter->isEmpty()) { diff --git a/library/Icinga/Web/Widget/Limiter.php b/library/Icinga/Web/Widget/Limiter.php index 5afa7e4b8..acc66c885 100644 --- a/library/Icinga/Web/Widget/Limiter.php +++ b/library/Icinga/Web/Widget/Limiter.php @@ -1,6 +1,5 @@ 'host_name', - + 'services_total' => 'state != 9999', 'services_problem' => 'state > 0', 'services_problem_handled' => 'state > 0 & (scheduled_downtime_depth > 0 | acknowledged = 1 | host_state > 0)', @@ -50,7 +49,7 @@ if (! array_key_exists($col, $this->available_columns)) { throw new ProgrammingError('No such column: %s', $col); } $filter = $this->filterStringToFilter($this->available_columns[$col]); - + //Filter::fromQueryString(str_replace(' ', '', $this->available_columns[$col])); $parts[] = $this->renderFilter( $filter, 'Stats', 0, false); } diff --git a/modules/monitoring/library/Monitoring/Backend/MonitoringBackend.php b/modules/monitoring/library/Monitoring/Backend/MonitoringBackend.php index d165f1252..0a1baad7d 100644 --- a/modules/monitoring/library/Monitoring/Backend/MonitoringBackend.php +++ b/modules/monitoring/library/Monitoring/Backend/MonitoringBackend.php @@ -1,4 +1,5 @@

    ' . $this->error->getMessage() . '

    '; } } -} \ No newline at end of file +} diff --git a/modules/monitoring/library/Monitoring/Timeline/TimeEntry.php b/modules/monitoring/library/Monitoring/Timeline/TimeEntry.php index bd83a42cd..112bd1e8b 100644 --- a/modules/monitoring/library/Monitoring/Timeline/TimeEntry.php +++ b/modules/monitoring/library/Monitoring/Timeline/TimeEntry.php @@ -1,6 +1,5 @@ assertEquals('backendName', $defaultBackend->getName(), 'Default backend has name set'); } -} \ No newline at end of file +} diff --git a/modules/setup/application/clicommands/ConfigCommand.php b/modules/setup/application/clicommands/ConfigCommand.php index e63e770b8..f9a73aba4 100644 --- a/modules/setup/application/clicommands/ConfigCommand.php +++ b/modules/setup/application/clicommands/ConfigCommand.php @@ -1,6 +1,5 @@ .tabs, .dontprint { display: none !important; diff --git a/public/index.php b/public/index.php index 48a500666..0062bf94f 100644 --- a/public/index.php +++ b/public/index.php @@ -1,5 +1,4 @@ 0 ? 1 : 0; - + // fetch current value from radiobuttons var value = $target.find('input:checked').first().val(); - + $target.append( ' ' - ); + ); if (triState) { // TODO: find a better way to activate indeterminate checkboxes after load. $target.append( '' ); } diff --git a/public/js/icinga/utils.js b/public/js/icinga/utils.js index ba4d7a040..8539d29ca 100644 --- a/public/js/icinga/utils.js +++ b/public/js/icinga/utils.js @@ -1,5 +1,4 @@ -// {{{ICINGA_LICENSE_HEADER}}} -// {{{ICINGA_LICENSE_HEADER}}} +/*! Icinga Web 2 | (c) 2013-2015 Icinga Development Team | http://www.gnu.org/licenses/gpl-2.0.txt */ /** * Icinga utility functions diff --git a/test/php/application/forms/Config/Authentication/DbBackendFormTest.php b/test/php/application/forms/Config/Authentication/DbBackendFormTest.php index 6af628b06..8067b6259 100644 --- a/test/php/application/forms/Config/Authentication/DbBackendFormTest.php +++ b/test/php/application/forms/Config/Authentication/DbBackendFormTest.php @@ -1,6 +1,5 @@ query('//x:path[@data-icinga-graph-type="pieslice"]'); $this->assertEquals(3, $path->length, 'Assert the correct number of datapoints being drawn as SVG bars'); } -} \ No newline at end of file +} diff --git a/test/php/library/Icinga/Data/ConfigObjectTest.php b/test/php/library/Icinga/Data/ConfigObjectTest.php index c4b825e58..40b095267 100644 --- a/test/php/library/Icinga/Data/ConfigObjectTest.php +++ b/test/php/library/Icinga/Data/ConfigObjectTest.php @@ -1,6 +1,5 @@ Date: Tue, 3 Feb 2015 16:08:35 +0100 Subject: [PATCH 0525/2920] security: Activate permissions --- library/Icinga/Authentication/Manager.php | 1 - 1 file changed, 1 deletion(-) diff --git a/library/Icinga/Authentication/Manager.php b/library/Icinga/Authentication/Manager.php index 64d20d9dd..0982d8fe9 100644 --- a/library/Icinga/Authentication/Manager.php +++ b/library/Icinga/Authentication/Manager.php @@ -164,7 +164,6 @@ class Manager */ public function hasPermission($permission) { - return true; if (! $this->isAuthenticated()) { return false; } From d701f9a354f408fbff728682fc33c32d9389f220 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Tue, 3 Feb 2015 16:11:29 +0100 Subject: [PATCH 0526/2920] monitoring/security: Guard delete downtime action --- .../Monitoring/Web/Controller/MonitoredObjectController.php | 1 + 1 file changed, 1 insertion(+) diff --git a/modules/monitoring/library/Monitoring/Web/Controller/MonitoredObjectController.php b/modules/monitoring/library/Monitoring/Web/Controller/MonitoredObjectController.php index 0407fac1c..d12bc7712 100644 --- a/modules/monitoring/library/Monitoring/Web/Controller/MonitoredObjectController.php +++ b/modules/monitoring/library/Monitoring/Web/Controller/MonitoredObjectController.php @@ -151,6 +151,7 @@ abstract class MonitoredObjectController extends Controller public function deleteDowntimeAction() { $this->assertHttpMethod('POST'); + $this->assertPermission('monitoring/command/downtime/delete'); $this->handleCommandForm(new DeleteDowntimeCommandForm()); } From 4ef5f0c813767fb18dd415e67aa9f36673de0315 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Tue, 3 Feb 2015 16:11:56 +0100 Subject: [PATCH 0527/2920] monitoring/security: Guard delete comment action --- library/Icinga/Web/Widget/FilterEditor.php | 69 +++++++++++++------ .../Controller/MonitoredObjectController.php | 1 + 2 files changed, 50 insertions(+), 20 deletions(-) diff --git a/library/Icinga/Web/Widget/FilterEditor.php b/library/Icinga/Web/Widget/FilterEditor.php index c7a240da8..c515ee79d 100644 --- a/library/Icinga/Web/Widget/FilterEditor.php +++ b/library/Icinga/Web/Widget/FilterEditor.php @@ -123,26 +123,55 @@ class FilterEditor extends AbstractWidget { $found = false; if ($filter->isChain() && $filter->getOperatorName() === 'AND') { - foreach ($filter->filters() as $f) { - if ($f->isExpression() - && $f->getColumn() === $column - && $f->getSign() === $sign - ) { - $f->setExpression($expression); - $found = true; - break; + if (is_array($column)) { + foreach ($filter->filters() as $f) { + if ($f->isChain() && $f->getOperatorName() === 'OR') { + + } + } + } else { + foreach ($filter->filters() as $f) { + if ($f->isExpression() + && $f->getColumn() === $column + && $f->getSign() === $sign + ) { + $f->setExpression($expression); + $found = true; + break; + } } } - } elseif ($filter->isExpression()) { - if ($filter->getColumn() === $column && $filter->getSign() === $sign) { + } elseif ($filter->isExpression() && $filter->getSign() === $sign) { + if (is_array($column)) { + if (in_array($filter->getColumn(), $column)) { + $or = Filter::matchAny(); + foreach ($column as $col) { + $or->addFilter( + Filter::expression($col, $sign, $expression) + ); + } + $filter = $filter->andFilter($or); + $found = true; + } + } elseif ($filter->getColumn() === $column) { $filter->setExpression($expression); $found = true; } } if (! $found) { - $filter = $filter->andFilter( - Filter::expression($column, $sign, $expression) - ); + if (is_array($column)) { + $or = Filter::matchAny(); + foreach ($column as $col) { + $or->addFilter( + Filter::expression($col, $sign, $expression) + ); + } + $filter = $filter->andFilter($or); + } else { + $filter = $filter->andFilter( + Filter::expression($column, $sign, $expression) + ); + } } return $filter; } @@ -183,25 +212,25 @@ class FilterEditor extends AbstractWidget // TODO: Ask the view for (multiple) search columns switch($request->getActionName()) { case 'services': - $searchCol = 'service_description'; + $searchCols = array('service_description', 'service_display_name'); break; case 'hosts': - $searchCol = 'host_name'; + $searchCols = array('host_name', 'host_display_name'); break; case 'hostgroups': - $searchCol = 'hostgroup'; + $searchCols = array('hostgroup', 'hostgroup_alias'); break; case 'servicegroups': - $searchCol = 'servicegroup'; + $searchCols = array('servicegroup', 'servicegroup_alias'); break; default: - $searchCol = null; + $searchCols = null; } - if ($searchCol === null) { + if ($searchCols === null) { throw new Exception('Cannot search here'); } - $filter = $this->mergeRootExpression($filter, $searchCol, '=', "*$search*"); + $filter = $this->mergeRootExpression($filter, $searchCols, '=', "*$search*"); } else { list($k, $v) = preg_split('/=/', $search); diff --git a/modules/monitoring/library/Monitoring/Web/Controller/MonitoredObjectController.php b/modules/monitoring/library/Monitoring/Web/Controller/MonitoredObjectController.php index d12bc7712..cd2ed175f 100644 --- a/modules/monitoring/library/Monitoring/Web/Controller/MonitoredObjectController.php +++ b/modules/monitoring/library/Monitoring/Web/Controller/MonitoredObjectController.php @@ -142,6 +142,7 @@ abstract class MonitoredObjectController extends Controller public function deleteCommentAction() { $this->assertHttpMethod('POST'); + $this->assertPermission('monitoring/command/comment/delete'); $this->handleCommandForm(new DeleteCommentCommandForm()); } From 9fa1fd626c27a49b2acf5e8cbf37d767d3217ecb Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Tue, 3 Feb 2015 16:13:22 +0100 Subject: [PATCH 0528/2920] Fix typo in UserBackend --- library/Icinga/Authentication/UserBackend.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library/Icinga/Authentication/UserBackend.php b/library/Icinga/Authentication/UserBackend.php index 2117c2f29..beb5df5b9 100644 --- a/library/Icinga/Authentication/UserBackend.php +++ b/library/Icinga/Authentication/UserBackend.php @@ -1,5 +1,5 @@ Date: Tue, 3 Feb 2015 16:14:13 +0100 Subject: [PATCH 0529/2920] Fix typo in UserGroupBackend --- library/Icinga/Authentication/UserGroupBackend.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library/Icinga/Authentication/UserGroupBackend.php b/library/Icinga/Authentication/UserGroupBackend.php index 49c6e4575..2fc0a5ada 100644 --- a/library/Icinga/Authentication/UserGroupBackend.php +++ b/library/Icinga/Authentication/UserGroupBackend.php @@ -1,5 +1,5 @@ Date: Tue, 3 Feb 2015 16:15:50 +0100 Subject: [PATCH 0530/2920] Fix that the search is case-sensitive in case of a PostgreSQL backend fixes #8083 --- .../Monitoring/Backend/Ido/Query/IdoQuery.php | 46 ++++++++++++++++++- 1 file changed, 45 insertions(+), 1 deletion(-) diff --git a/modules/monitoring/library/Monitoring/Backend/Ido/Query/IdoQuery.php b/modules/monitoring/library/Monitoring/Backend/Ido/Query/IdoQuery.php index f7f612ce4..391048ceb 100644 --- a/modules/monitoring/library/Monitoring/Backend/Ido/Query/IdoQuery.php +++ b/modules/monitoring/library/Monitoring/Backend/Ido/Query/IdoQuery.php @@ -172,6 +172,16 @@ abstract class IdoQuery extends DbQuery */ protected static $idoVersion; + /** + * List of columns where the COLLATE SQL-instruction has been removed + * + * This list is being populated in case of a PostgreSQL backend only, + * to ensure case-insensitive string comparison in WHERE clauses. + * + * @var array + */ + protected $columnsWithoutCollation = array(); + /** * Return true when the column is an aggregate column * @@ -267,6 +277,37 @@ abstract class IdoQuery extends DbQuery parent::addFilter($filter); } + /** + * Recurse the given filter and ensure that any string conversion is case-insensitive + * + * @param Filter $filter + */ + protected function lowerColumnsWithoutCollation(Filter $filter) + { + if ($filter instanceof FilterExpression) { + if ( + in_array($filter->getColumn(), $this->columnsWithoutCollation) + && strpos($filter->getColumn(), 'LOWER') !== 0 + ) { + $filter->setColumn('LOWER(' . $filter->getColumn() . ')'); + $filter->setExpression(strtolower($filter->getExpression())); + } + } else { + foreach ($filter->filters() as $chainedFilter) { + $this->lowerColumnsWithoutCollation($chainedFilter); + } + } + } + + protected function applyFilterSql($select) + { + if (! empty($this->columnsWithoutCollation)) { + $this->lowerColumnsWithoutCollation($this->filter); + } + + parent::applyFilterSql($select); + } + public function where($condition, $value = null) { $this->requireColumn($condition); @@ -320,7 +361,10 @@ abstract class IdoQuery extends DbQuery { foreach ($this->columnMap as $table => & $columns) { foreach ($columns as $key => & $value) { - $value = preg_replace('/ COLLATE .+$/', '', $value); + $value = preg_replace('/ COLLATE .+$/', '', $value, -1, $count); + if ($count > 0) { + $this->columnsWithoutCollation[] = $this->getMappedField($key); + } $value = preg_replace('/inet_aton\(([[:word:].]+)\)/i', '$1::inet - \'0.0.0.0\'', $value); $value = preg_replace( '/UNIX_TIMESTAMP(\((?>[^()]|(?-1))*\))/i', From 160b3a96cad666215e98ac26a67d14d0aec7ea57 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Tue, 3 Feb 2015 16:15:50 +0100 Subject: [PATCH 0531/2920] Revert "Fix typo in UserGroupBackend" This reverts commit e8c4f45d6811777da286647ec3263af195d5c69f. --- library/Icinga/Authentication/UserGroupBackend.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library/Icinga/Authentication/UserGroupBackend.php b/library/Icinga/Authentication/UserGroupBackend.php index 2fc0a5ada..49c6e4575 100644 --- a/library/Icinga/Authentication/UserGroupBackend.php +++ b/library/Icinga/Authentication/UserGroupBackend.php @@ -1,5 +1,5 @@ Date: Tue, 3 Feb 2015 16:15:57 +0100 Subject: [PATCH 0532/2920] Revert "Fix typo in UserBackend" This reverts commit 9fa1fd626c27a49b2acf5e8cbf37d767d3217ecb. --- library/Icinga/Authentication/UserBackend.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library/Icinga/Authentication/UserBackend.php b/library/Icinga/Authentication/UserBackend.php index beb5df5b9..2117c2f29 100644 --- a/library/Icinga/Authentication/UserBackend.php +++ b/library/Icinga/Authentication/UserBackend.php @@ -1,5 +1,5 @@ Date: Tue, 3 Feb 2015 16:16:10 +0100 Subject: [PATCH 0533/2920] Revert "Add license header" This reverts commit 338d067aba41dd6e9178cebec5433eecd614196e. --- Vagrantfile | 2 -- .../clicommands/AutocompleteCommand.php | 3 ++- application/clicommands/HelpCommand.php | 3 ++- application/clicommands/ModuleCommand.php | 3 ++- application/clicommands/WebCommand.php | 3 ++- .../controllers/AuthenticationController.php | 3 ++- application/controllers/ConfigController.php | 1 - .../controllers/DashboardController.php | 3 ++- application/controllers/ErrorController.php | 1 - application/controllers/FilterController.php | 3 ++- application/controllers/IndexController.php | 3 ++- application/controllers/LayoutController.php | 3 ++- application/controllers/ListController.php | 3 ++- .../controllers/PreferenceController.php | 3 ++- application/controllers/RolesController.php | 1 - application/controllers/SearchController.php | 3 ++- application/controllers/StaticController.php | 3 ++- .../forms/Authentication/LoginForm.php | 3 ++- .../Config/Authentication/DbBackendForm.php | 3 ++- .../Authentication/ExternalBackendForm.php | 3 ++- .../Config/Authentication/LdapBackendForm.php | 3 ++- .../AuthenticationBackendConfigForm.php | 3 ++- .../AuthenticationBackendReorderForm.php | 3 ++- .../Config/General/ApplicationConfigForm.php | 3 ++- .../Config/General/LoggingConfigForm.php | 3 ++- .../forms/Config/GeneralConfigForm.php | 3 ++- .../forms/Config/Resource/DbResourceForm.php | 3 ++- .../Config/Resource/FileResourceForm.php | 3 ++- .../Config/Resource/LdapResourceForm.php | 3 ++- .../Resource/LivestatusResourceForm.php | 3 ++- .../forms/Config/ResourceConfigForm.php | 3 ++- application/forms/ConfigForm.php | 3 ++- application/forms/ConfirmRemovalForm.php | 3 ++- application/forms/Dashboard/DashletForm.php | 3 ++- application/forms/LdapDiscoveryForm.php | 3 ++- application/forms/PreferenceForm.php | 3 ++- application/forms/Security/RoleForm.php | 3 ++- application/views/helpers/DateFormat.php | 3 ++- application/views/helpers/FormDateTime.php | 3 ++- application/views/helpers/FormNumber.php | 3 ++- .../views/helpers/FormTriStateCheckbox.php | 3 ++- application/views/helpers/Util.php | 3 ++- bin/icingacli | 3 ++- bin/license_writer.py | 3 ++- etc/bash_completion.d/icingacli | 3 +++ etc/schema/mysql.schema.sql | 2 -- etc/schema/pgsql.schema.sql | 19 ++++++++++++--- icingaweb2.spec | 2 -- .../Application/ApplicationBootstrap.php | 3 ++- library/Icinga/Application/Benchmark.php | 3 ++- library/Icinga/Application/Cli.php | 3 ++- library/Icinga/Application/Config.php | 3 ++- library/Icinga/Application/EmbeddedWeb.php | 3 ++- library/Icinga/Application/Icinga.php | 3 ++- library/Icinga/Application/LegacyWeb.php | 3 ++- library/Icinga/Application/Loader.php | 3 ++- library/Icinga/Application/Logger.php | 3 ++- .../Icinga/Application/Logger/LogWriter.php | 3 ++- .../Application/Logger/Writer/FileWriter.php | 3 ++- .../Logger/Writer/StdoutWriter.php | 2 +- .../Logger/Writer/SyslogWriter.php | 3 ++- .../Icinga/Application/Modules/Manager.php | 3 ++- library/Icinga/Application/Modules/Module.php | 3 ++- library/Icinga/Application/Platform.php | 3 ++- library/Icinga/Application/Web.php | 3 ++- library/Icinga/Application/functions.php | 3 ++- library/Icinga/Application/webrouter.php | 3 ++- .../Icinga/Authentication/AdmissionLoader.php | 3 ++- library/Icinga/Authentication/AuthChain.php | 3 ++- .../Authentication/Backend/DbUserBackend.php | 3 ++- .../Backend/DbUserGroupBackend.php | 3 ++- .../Backend/ExternalBackend.php | 3 ++- .../Backend/IniUserGroupBackend.php | 3 ++- .../Backend/LdapUserBackend.php | 3 ++- library/Icinga/Authentication/Manager.php | 3 ++- library/Icinga/Authentication/UserBackend.php | 3 ++- .../Authentication/UserGroupBackend.php | 3 ++- library/Icinga/Chart/Axis.php | 3 ++- library/Icinga/Chart/Chart.php | 3 ++- library/Icinga/Chart/Format.php | 3 ++- library/Icinga/Chart/Graph/BarGraph.php | 3 ++- library/Icinga/Chart/Graph/LineGraph.php | 3 ++- library/Icinga/Chart/Graph/StackedGraph.php | 3 ++- library/Icinga/Chart/Graph/Tooltip.php | 5 ++-- library/Icinga/Chart/GridChart.php | 3 ++- library/Icinga/Chart/Inline/Inline.php | 3 ++- library/Icinga/Chart/Inline/PieChart.php | 3 ++- library/Icinga/Chart/Legend.php | 3 ++- library/Icinga/Chart/Palette.php | 3 ++- library/Icinga/Chart/PieChart.php | 3 ++- library/Icinga/Chart/Primitive/Animatable.php | 3 ++- library/Icinga/Chart/Primitive/Animation.php | 3 ++- library/Icinga/Chart/Primitive/Canvas.php | 3 ++- library/Icinga/Chart/Primitive/Circle.php | 3 ++- library/Icinga/Chart/Primitive/Drawable.php | 3 ++- library/Icinga/Chart/Primitive/Line.php | 3 ++- library/Icinga/Chart/Primitive/Path.php | 3 ++- library/Icinga/Chart/Primitive/PieSlice.php | 3 ++- library/Icinga/Chart/Primitive/RawElement.php | 3 ++- library/Icinga/Chart/Primitive/Rect.php | 3 ++- library/Icinga/Chart/Primitive/Styleable.php | 3 ++- library/Icinga/Chart/Primitive/Text.php | 3 ++- library/Icinga/Chart/Render/LayoutBox.php | 3 ++- library/Icinga/Chart/Render/RenderContext.php | 3 ++- library/Icinga/Chart/Render/Rotator.php | 7 ++++-- library/Icinga/Chart/SVGRenderer.php | 3 ++- library/Icinga/Chart/Unit/AxisUnit.php | 3 ++- library/Icinga/Chart/Unit/CalendarUnit.php | 3 ++- library/Icinga/Chart/Unit/LinearUnit.php | 3 ++- library/Icinga/Chart/Unit/LogarithmicUnit.php | 3 ++- library/Icinga/Chart/Unit/StaticAxis.php | 3 ++- library/Icinga/Cli/AnsiScreen.php | 3 ++- library/Icinga/Cli/Command.php | 3 ++- library/Icinga/Cli/Documentation.php | 3 ++- .../Cli/Documentation/CommentParser.php | 3 ++- library/Icinga/Cli/Loader.php | 3 ++- library/Icinga/Cli/Params.php | 3 ++- library/Icinga/Cli/Screen.php | 3 ++- library/Icinga/Data/Browsable.php | 3 ++- library/Icinga/Data/ConfigObject.php | 3 ++- library/Icinga/Data/ConnectionInterface.php | 3 ++- .../Icinga/Data/DataArray/ArrayDatasource.php | 5 ++-- library/Icinga/Data/Db/DbConnection.php | 3 ++- library/Icinga/Data/Db/DbQuery.php | 3 ++- library/Icinga/Data/Fetchable.php | 3 ++- library/Icinga/Data/Filter/Filter.php | 3 ++- library/Icinga/Data/Filter/FilterAnd.php | 5 ++-- library/Icinga/Data/Filter/FilterChain.php | 7 +++--- library/Icinga/Data/Filter/FilterEqual.php | 3 ++- .../Data/Filter/FilterEqualOrGreaterThan.php | 3 ++- .../Data/Filter/FilterEqualOrLessThan.php | 3 ++- .../Icinga/Data/Filter/FilterException.php | 3 ++- .../Icinga/Data/Filter/FilterExpression.php | 3 ++- .../Icinga/Data/Filter/FilterGreaterThan.php | 3 ++- library/Icinga/Data/Filter/FilterLessThan.php | 3 ++- library/Icinga/Data/Filter/FilterMatch.php | 3 ++- library/Icinga/Data/Filter/FilterMatchNot.php | 3 ++- library/Icinga/Data/Filter/FilterNot.php | 3 ++- library/Icinga/Data/Filter/FilterNotEqual.php | 3 ++- library/Icinga/Data/Filter/FilterOr.php | 3 ++- .../Data/Filter/FilterParseException.php | 3 ++- .../Icinga/Data/Filter/FilterQueryString.php | 3 ++- library/Icinga/Data/Filterable.php | 3 ++- library/Icinga/Data/Identifiable.php | 3 ++- library/Icinga/Data/Limitable.php | 3 ++- library/Icinga/Data/PivotTable.php | 3 ++- library/Icinga/Data/QueryInterface.php | 3 ++- library/Icinga/Data/Queryable.php | 3 ++- library/Icinga/Data/ResourceFactory.php | 3 ++- library/Icinga/Data/Selectable.php | 3 ++- library/Icinga/Data/SimpleQuery.php | 3 ++- library/Icinga/Data/Sortable.php | 3 ++- library/Icinga/Data/Tree/Node.php | 3 ++- library/Icinga/Data/Tree/NodeInterface.php | 3 ++- .../Exception/AuthenticationException.php | 3 ++- .../Icinga/Exception/ConfigurationError.php | 3 ++- library/Icinga/Exception/IcingaException.php | 3 ++- .../Exception/InvalidPropertyException.php | 3 ++- .../Exception/MissingParameterException.php | 3 ++- library/Icinga/Exception/NotFoundError.php | 3 ++- .../Icinga/Exception/NotImplementedError.php | 3 ++- library/Icinga/Exception/NotReadableError.php | 3 ++- library/Icinga/Exception/NotWritableError.php | 3 ++- library/Icinga/Exception/ProgrammingError.php | 3 ++- library/Icinga/Exception/QueryException.php | 3 ++- .../Exception/SystemPermissionException.php | 3 ++- library/Icinga/File/Csv.php | 3 ++- .../File/FileExtensionFilterIterator.php | 3 ++- library/Icinga/File/Ini/IniEditor.php | 3 ++- library/Icinga/File/Ini/IniWriter.php | 3 ++- library/Icinga/File/NonEmptyFileIterator.php | 3 ++- library/Icinga/File/Pdf.php | 3 ++- library/Icinga/Protocol/Dns.php | 3 ++- .../File/Exception/FileReaderException.php | 2 +- library/Icinga/Protocol/File/FileIterator.php | 3 ++- library/Icinga/Protocol/File/FileQuery.php | 3 ++- library/Icinga/Protocol/File/FileReader.php | 3 ++- library/Icinga/Protocol/Ldap/Connection.php | 3 ++- library/Icinga/Protocol/Ldap/Discovery.php | 5 ++-- library/Icinga/Protocol/Ldap/Exception.php | 3 ++- library/Icinga/Protocol/Ldap/LdapUtils.php | 3 ++- library/Icinga/Protocol/Ldap/Node.php | 3 ++- library/Icinga/Protocol/Ldap/Query.php | 3 ++- library/Icinga/Protocol/Ldap/Root.php | 3 ++- .../Icinga/Protocol/Livestatus/Connection.php | 5 ++-- library/Icinga/Protocol/Livestatus/Query.php | 9 ++++---- .../Protocol/Livestatus/ResponseRow.php | 1 - library/Icinga/Protocol/Nrpe/Connection.php | 3 ++- library/Icinga/Protocol/Nrpe/Packet.php | 3 ++- library/Icinga/Security/SecurityException.php | 1 - library/Icinga/Test/BaseTestCase.php | 3 ++- library/Icinga/Test/DbTest.php | 3 ++- library/Icinga/User.php | 3 ++- library/Icinga/User/Preferences.php | 3 ++- .../User/Preferences/PreferencesStore.php | 3 ++- .../Icinga/User/Preferences/Store/DbStore.php | 3 ++- .../User/Preferences/Store/IniStore.php | 3 ++- library/Icinga/Util/Color.php | 3 ++- library/Icinga/Util/ConfigAwareFactory.php | 3 ++- library/Icinga/Util/DateTimeFactory.php | 3 ++- library/Icinga/Util/Dimension.php | 3 ++- .../Icinga/Util/EnumeratingFilterIterator.php | 3 ++- library/Icinga/Util/File.php | 3 ++- library/Icinga/Util/Format.php | 3 ++- library/Icinga/Util/String.php | 3 ++- library/Icinga/Util/TimezoneDetect.php | 3 ++- library/Icinga/Util/Translator.php | 3 ++- library/Icinga/Web/Controller.php | 1 - .../Web/Controller/ActionController.php | 1 - .../Controller/BasePreferenceController.php | 3 ++- .../Web/Controller/ControllerTabCollector.php | 3 ++- .../Web/Controller/ModuleActionController.php | 3 ++- library/Icinga/Web/FileCache.php | 2 +- library/Icinga/Web/Form.php | 1 - .../Web/Form/Decorator/ConditionalHidden.php | 3 ++- .../Web/Form/Decorator/ElementDoubler.php | 3 ++- .../Web/Form/Decorator/NoScriptApply.php | 3 ++- library/Icinga/Web/Form/Element/Button.php | 3 ++- .../Web/Form/Element/CsrfCounterMeasure.php | 3 ++- .../Web/Form/Element/DateTimePicker.php | 3 ++- library/Icinga/Web/Form/Element/Note.php | 3 ++- library/Icinga/Web/Form/Element/Number.php | 3 ++- .../Web/Form/Element/TriStateCheckbox.php | 3 ++- library/Icinga/Web/Form/FormElement.php | 3 ++- .../Web/Form/InvalidCSRFTokenException.php | 3 ++- .../Form/Validator/DateFormatValidator.php | 3 ++- .../Web/Form/Validator/DateTimeValidator.php | 3 ++- .../Form/Validator/ReadablePathValidator.php | 3 ++- .../Form/Validator/TimeFormatValidator.php | 3 ++- .../Web/Form/Validator/TriStateValidator.php | 3 ++- .../Form/Validator/WritablePathValidator.php | 3 ++- library/Icinga/Web/Hook.php | 3 ++- library/Icinga/Web/Hook/GrapherHook.php | 3 ++- library/Icinga/Web/Hook/TicketHook.php | 3 ++- library/Icinga/Web/Hook/WebBaseHook.php | 5 ++-- library/Icinga/Web/JavaScript.php | 3 ++- library/Icinga/Web/LessCompiler.php | 3 ++- library/Icinga/Web/Menu.php | 3 ++- .../Web/Menu/ForeignMenuItemRenderer.php | 3 ++- library/Icinga/Web/Menu/MenuItemRenderer.php | 3 ++- .../Web/Menu/MonitoringMenuItemRenderer.php | 3 ++- .../Web/Menu/ProblemMenuItemRenderer.php | 1 - .../Menu/UnhandledHostMenuItemRenderer.php | 1 - .../Menu/UnhandledServiceMenuItemRenderer.php | 1 - library/Icinga/Web/MenuRenderer.php | 3 ++- library/Icinga/Web/Notification.php | 3 ++- .../Web/Paginator/Adapter/QueryAdapter.php | 3 ++- .../ScrollingStyle/SlidingWithBorder.php | 5 ++-- library/Icinga/Web/Request.php | 3 ++- library/Icinga/Web/Response.php | 3 ++- library/Icinga/Web/Session.php | 3 ++- library/Icinga/Web/Session/PhpSession.php | 3 ++- library/Icinga/Web/Session/Session.php | 3 ++- .../Icinga/Web/Session/SessionNamespace.php | 3 ++- library/Icinga/Web/StyleSheet.php | 3 ++- library/Icinga/Web/Url.php | 3 ++- library/Icinga/Web/UrlParams.php | 5 ++-- library/Icinga/Web/View.php | 3 ++- library/Icinga/Web/View/DateTimeRenderer.php | 3 ++- library/Icinga/Web/View/helpers/format.php | 3 ++- library/Icinga/Web/View/helpers/generic.php | 3 ++- library/Icinga/Web/View/helpers/url.php | 5 ++-- library/Icinga/Web/ViewStream.php | 3 ++- library/Icinga/Web/Widget.php | 3 ++- library/Icinga/Web/Widget/AbstractWidget.php | 3 ++- .../Web/Widget/Chart/HistoryColorGrid.php | 3 ++- library/Icinga/Web/Widget/Chart/InlinePie.php | 3 ++- library/Icinga/Web/Widget/Dashboard.php | 3 ++- .../Icinga/Web/Widget/Dashboard/Dashlet.php | 3 ++- library/Icinga/Web/Widget/Dashboard/Pane.php | 3 ++- .../Web/Widget/Dashboard/UserWidget.php | 3 ++- library/Icinga/Web/Widget/FilterEditor.php | 9 ++++---- library/Icinga/Web/Widget/FilterWidget.php | 5 ++-- library/Icinga/Web/Widget/Limiter.php | 3 ++- library/Icinga/Web/Widget/SearchDashboard.php | 3 ++- library/Icinga/Web/Widget/SortBox.php | 3 ++- library/Icinga/Web/Widget/Tab.php | 3 ++- .../Web/Widget/Tabextension/BasketAction.php | 3 ++- .../Widget/Tabextension/DashboardAction.php | 3 ++- .../Widget/Tabextension/DashboardSettings.php | 5 ++-- .../Web/Widget/Tabextension/OutputFormat.php | 3 ++- .../Web/Widget/Tabextension/Tabextension.php | 3 ++- library/Icinga/Web/Widget/Tabs.php | 3 ++- library/Icinga/Web/Widget/Widget.php | 3 ++- library/Icinga/Web/Window.php | 3 ++- library/Icinga/Web/Wizard.php | 3 ++- .../controllers/IcingawebController.php | 3 ++- .../controllers/IndexController.php | 3 ++- .../controllers/ModuleController.php | 3 ++- .../controllers/StyleController.php | 1 - modules/doc/configuration.php | 3 ++- modules/doc/library/Doc/DocController.php | 3 ++- modules/doc/library/Doc/DocIterator.php | 3 ++- modules/doc/library/Doc/DocParser.php | 3 ++- modules/doc/library/Doc/DocTree.php | 3 ++- .../Exception/ChapterNotFoundException.php | 3 ++- .../Doc/Exception/DocEmptyException.php | 3 ++- .../library/Doc/Exception/DocException.php | 3 ++- modules/doc/library/Doc/Renderer.php | 3 ++- modules/doc/library/Doc/Section.php | 3 ++- .../doc/library/Doc/SectionFilterIterator.php | 3 ++- modules/doc/library/Doc/SectionRenderer.php | 3 ++- modules/doc/library/Doc/TocRenderer.php | 3 ++- modules/doc/public/css/module.less | 2 -- modules/doc/run.php | 1 - .../clicommands/ConferenceCommand.php | 3 ++- .../application/clicommands/ListCommand.php | 3 ++- .../application/clicommands/NrpeCommand.php | 3 ++- .../controllers/AlertsummaryController.php | 3 ++- .../controllers/ChartController.php | 3 ++- .../controllers/ConfigController.php | 3 ++- .../controllers/HostController.php | 3 ++- .../controllers/HostsController.php | 3 ++- .../controllers/ListController.php | 1 - .../controllers/ProcessController.php | 3 ++- .../controllers/ServiceController.php | 3 ++- .../controllers/ServicesController.php | 3 ++- .../controllers/ShowController.php | 3 ++- .../controllers/TacticalController.php | 3 ++- .../controllers/TimelineController.php | 3 ++- .../application/forms/Command/CommandForm.php | 3 ++- .../DisableNotificationsExpireCommandForm.php | 3 ++- .../ToggleInstanceFeaturesCommandForm.php | 3 ++- .../Object/AcknowledgeProblemCommandForm.php | 3 ++- .../Command/Object/AddCommentCommandForm.php | 3 ++- .../Command/Object/CheckNowCommandForm.php | 3 ++- .../Object/DeleteCommentCommandForm.php | 3 ++- .../Object/DeleteDowntimeCommandForm.php | 3 ++- .../Command/Object/ObjectsCommandForm.php | 3 ++- .../Object/ProcessCheckResultCommandForm.php | 3 ++- .../RemoveAcknowledgementCommandForm.php | 3 ++- .../Object/ScheduleHostCheckCommandForm.php | 3 ++- .../ScheduleHostDowntimeCommandForm.php | 3 ++- .../ScheduleServiceCheckCommandForm.php | 3 ++- .../ScheduleServiceDowntimeCommandForm.php | 3 ++- .../ToggleObjectFeaturesCommandForm.php | 3 ++- .../forms/Config/BackendConfigForm.php | 3 ++- .../Config/Instance/LocalInstanceForm.php | 3 ++- .../Config/Instance/RemoteInstanceForm.php | 3 ++- .../forms/Config/InstanceConfigForm.php | 3 ++- .../forms/Config/SecurityConfigForm.php | 3 ++- .../application/forms/EventOverviewForm.php | 3 ++- .../application/forms/Setup/BackendPage.php | 3 ++- .../forms/Setup/IdoResourcePage.php | 3 ++- .../application/forms/Setup/InstancePage.php | 3 ++- .../forms/Setup/LivestatusResourcePage.php | 3 ++- .../application/forms/Setup/SecurityPage.php | 3 ++- .../application/forms/Setup/WelcomePage.php | 3 ++- .../application/forms/StatehistoryForm.php | 3 ++- .../views/helpers/CheckPerformance.php | 3 ++- .../views/helpers/ContactFlags.php | 3 ++- .../application/views/helpers/Customvar.php | 1 - .../application/views/helpers/Link.php | 1 - .../views/helpers/MonitoringFlags.php | 3 ++- .../application/views/helpers/Perfdata.php | 3 ++- .../views/helpers/PluginOutput.php | 3 ++- .../views/helpers/ResolveMacros.php | 3 ++- .../views/helpers/RuntimeVariables.php | 3 ++- .../views/helpers/SelectionToolbar.php | 3 ++- modules/monitoring/configuration.php | 1 - .../monitoring/library/Monitoring/Backend.php | 1 - .../Monitoring/Backend/Ido/IdoBackend.php | 1 - .../Backend/Ido/Query/AllcontactsQuery.php | 3 ++- .../Backend/Ido/Query/CommandQuery.php | 5 ++-- .../Backend/Ido/Query/CommentQuery.php | 3 ++- .../Ido/Query/CommentdeletionhistoryQuery.php | 3 ++- .../Backend/Ido/Query/CommenthistoryQuery.php | 3 ++- .../Backend/Ido/Query/ContactQuery.php | 3 ++- .../Backend/Ido/Query/ContactgroupQuery.php | 3 ++- .../Backend/Ido/Query/CustomvarQuery.php | 3 ++- .../Backend/Ido/Query/DowntimeQuery.php | 1 - .../Ido/Query/DowntimeendhistoryQuery.php | 3 ++- .../Ido/Query/DowntimestarthistoryQuery.php | 3 ++- .../Backend/Ido/Query/EventHistoryQuery.php | 1 - .../Backend/Ido/Query/EventgridQuery.php | 3 ++- .../Backend/Ido/Query/GroupsummaryQuery.php | 3 ++- .../Backend/Ido/Query/HostgroupQuery.php | 3 ++- .../Backend/Ido/Query/HoststatusQuery.php | 3 ++- .../Monitoring/Backend/Ido/Query/IdoQuery.php | 3 ++- .../Backend/Ido/Query/NotificationQuery.php | 1 - .../Ido/Query/NotificationhistoryQuery.php | 3 ++- .../Backend/Ido/Query/ProgramstatusQuery.php | 3 ++- .../Backend/Ido/Query/RuntimesummaryQuery.php | 3 ++- .../Ido/Query/RuntimevariablesQuery.php | 3 ++- .../Backend/Ido/Query/ServicegroupQuery.php | 3 ++- .../Backend/Ido/Query/StatehistoryQuery.php | 1 - .../Backend/Ido/Query/StatusQuery.php | 3 ++- .../Backend/Ido/Query/StatusSummaryQuery.php | 3 ++- .../Backend/Livestatus/LivestatusBackend.php | 1 - .../Livestatus/Query/DowntimeQuery.php | 3 ++- .../Livestatus/Query/HostgroupQuery.php | 3 ++- .../Livestatus/Query/ServicegroupQuery.php | 3 ++- .../Backend/Livestatus/Query/StatusQuery.php | 3 ++- .../Livestatus/Query/StatusSummaryQuery.php | 7 +++--- .../Monitoring/Backend/MonitoringBackend.php | 1 - .../library/Monitoring/BackendStep.php | 3 ++- .../library/Monitoring/Cli/CliUtils.php | 3 ++- .../Command/Exception/TransportException.php | 3 ++- .../Monitoring/Command/IcingaCommand.php | 3 ++- .../DisableNotificationsExpireCommand.php | 3 ++- .../Instance/ToggleInstanceFeatureCommand.php | 3 ++- .../Object/AcknowledgeProblemCommand.php | 3 ++- .../Command/Object/AddCommentCommand.php | 3 ++- .../Command/Object/DeleteCommentCommand.php | 3 ++- .../Command/Object/DeleteDowntimeCommand.php | 3 ++- .../Command/Object/ObjectCommand.php | 3 ++- .../Object/ProcessCheckResultCommand.php | 3 ++- .../Object/PropagateHostDowntimeCommand.php | 3 ++- .../Object/RemoveAcknowledgementCommand.php | 3 ++- .../Object/ScheduleHostCheckCommand.php | 3 ++- .../Object/ScheduleHostDowntimeCommand.php | 3 ++- .../Object/ScheduleServiceCheckCommand.php | 3 ++- .../Object/ScheduleServiceDowntimeCommand.php | 3 ++- .../Object/ToggleObjectFeatureCommand.php | 3 ++- .../Command/Object/WithCommentCommand.php | 3 ++- .../IcingaCommandFileCommandRenderer.php | 1 - .../IcingaCommandRendererInterface.php | 1 - .../Command/Transport/CommandTransport.php | 3 ++- .../Transport/CommandTransportInterface.php | 3 ++- .../Command/Transport/LocalCommandFile.php | 3 ++- .../Command/Transport/RemoteCommandFile.php | 3 ++- .../library/Monitoring/Controller.php | 3 ++- .../library/Monitoring/DataView/Command.php | 5 ++-- .../library/Monitoring/DataView/Comment.php | 3 ++- .../library/Monitoring/DataView/Contact.php | 3 ++- .../Monitoring/DataView/Contactgroup.php | 3 ++- .../library/Monitoring/DataView/Customvar.php | 3 ++- .../library/Monitoring/DataView/DataView.php | 3 ++- .../library/Monitoring/DataView/Downtime.php | 3 ++- .../Monitoring/DataView/EventHistory.php | 1 - .../library/Monitoring/DataView/Eventgrid.php | 3 ++- .../Monitoring/DataView/Groupsummary.php | 3 ++- .../Monitoring/DataView/HostStatus.php | 3 ++- .../library/Monitoring/DataView/Hostgroup.php | 3 ++- .../Monitoring/DataView/Notification.php | 3 ++- .../Monitoring/DataView/Programstatus.php | 3 ++- .../Monitoring/DataView/Runtimesummary.php | 3 ++- .../Monitoring/DataView/Runtimevariables.php | 3 ++- .../Monitoring/DataView/ServiceStatus.php | 3 ++- .../Monitoring/DataView/Servicegroup.php | 3 ++- .../Monitoring/DataView/StatusSummary.php | 3 ++- .../library/Monitoring/Environment.php | 3 ++- .../Exception/UnsupportedBackendException.php | 3 ++- .../library/Monitoring/InstanceStep.php | 3 ++- .../library/Monitoring/MonitoringWizard.php | 3 ++- .../library/Monitoring/Object/Host.php | 3 ++- .../library/Monitoring/Object/HostList.php | 1 - .../Monitoring/Object/MonitoredObject.php | 3 ++- .../library/Monitoring/Object/ObjectList.php | 1 - .../library/Monitoring/Object/Service.php | 3 ++- .../library/Monitoring/Object/ServiceList.php | 1 - .../monitoring/library/Monitoring/Plugin.php | 3 ++- .../library/Monitoring/Plugin/Perfdata.php | 3 ++- .../library/Monitoring/Plugin/PerfdataSet.php | 3 ++- .../library/Monitoring/SecurityStep.php | 5 ++-- .../library/Monitoring/Timeline/TimeEntry.php | 3 ++- .../library/Monitoring/Timeline/TimeLine.php | 3 ++- .../library/Monitoring/Timeline/TimeRange.php | 3 ++- .../Controller/MonitoredObjectController.php | 1 - .../Monitoring/Web/Hook/HostActionsHook.php | 1 - .../Web/Hook/TimelineProviderHook.php | 3 ++- .../Monitoring/Web/Widget/SelectBox.php | 5 ++-- modules/monitoring/public/css/module.less | 7 +++--- modules/monitoring/public/js/module.js | 3 ++- .../views/helpers/MonitoringFlagsTest.php | 3 ++- .../views/helpers/ResolveMacrosTest.php | 3 ++- .../Monitoring/Plugin/PerfdataSetTest.php | 3 ++- .../Monitoring/Plugin/PerfdataTest.php | 3 ++- .../test/php/regression/Bug6088Test.php | 3 ++- .../test/php/regression/Bug7043Test.php | 3 +-- .../application/clicommands/ConfigCommand.php | 3 ++- .../application/clicommands/TokenCommand.php | 3 ++- .../controllers/IndexController.php | 3 ++- .../application/forms/AdminAccountPage.php | 3 ++- .../application/forms/AuthBackendPage.php | 3 ++- .../application/forms/AuthenticationPage.php | 3 ++- .../forms/DatabaseCreationPage.php | 3 ++- .../application/forms/DbResourcePage.php | 3 ++- .../application/forms/GeneralConfigPage.php | 3 ++- .../forms/LdapDiscoveryConfirmPage.php | 3 ++- .../application/forms/LdapDiscoveryPage.php | 3 ++- .../application/forms/LdapResourcePage.php | 3 ++- .../setup/application/forms/ModulePage.php | 3 ++- .../application/forms/PreferencesPage.php | 3 ++- .../application/forms/RequirementsPage.php | 3 ++- .../setup/application/forms/SummaryPage.php | 3 ++- .../setup/application/forms/WelcomePage.php | 3 ++- .../Setup/Exception/SetupException.php | 5 ++-- modules/setup/library/Setup/Requirements.php | 3 ++- modules/setup/library/Setup/Setup.php | 3 ++- modules/setup/library/Setup/SetupWizard.php | 3 ++- modules/setup/library/Setup/Step.php | 3 ++- .../Setup/Steps/AuthenticationStep.php | 3 ++- .../library/Setup/Steps/DatabaseStep.php | 3 ++- .../library/Setup/Steps/GeneralConfigStep.php | 3 ++- .../library/Setup/Steps/ResourceStep.php | 3 ++- modules/setup/library/Setup/Utils/DbTool.php | 3 ++- .../library/Setup/Utils/EnableModuleStep.php | 3 ++- .../setup/library/Setup/Utils/MakeDirStep.php | 3 ++- .../Web/Form/Validator/TokenValidator.php | 3 ++- modules/setup/library/Setup/WebWizard.php | 3 ++- modules/setup/library/Setup/Webserver.php | 3 ++- .../setup/library/Setup/Webserver/Apache.php | 3 ++- .../setup/library/Setup/Webserver/Nginx.php | 3 ++- .../application/clicommands/PhpCommand.php | 3 ++- .../clicommands/CompileCommand.php | 3 ++- .../clicommands/RefreshCommand.php | 3 ++- .../Translation/Cli/TranslationCommand.php | 3 ++- .../Util/GettextTranslationHelper.php | 3 ++- packages/files/bin/icingacli | 1 - packages/files/public/index.php | 1 - public/css/icinga/defaults.less | 3 ++- public/css/icinga/forms.less | 3 ++- public/css/icinga/header-elements.less | 3 ++- public/css/icinga/layout-colors.less | 3 ++- public/css/icinga/layout-structure.less | 3 ++- public/css/icinga/login.less | 5 ++-- public/css/icinga/main-content.less | 5 ++-- public/css/icinga/menu.less | 3 ++- public/css/icinga/monitoring-colors.less | 17 +++++++------- public/css/icinga/pagination.less | 3 ++- public/css/icinga/selection-toolbar.less | 3 ++- public/css/icinga/setup.less | 4 +--- public/css/icinga/tabs.less | 3 ++- public/css/icinga/widgets.less | 5 ++-- public/css/pdf/pdfprint.less | 3 ++- public/index.php | 3 ++- public/js/helpers.js | 3 ++- public/js/icinga.js | 3 ++- public/js/icinga/behavior/form.js | 3 ++- public/js/icinga/behavior/navigation.js | 5 ++-- public/js/icinga/behavior/sparkline.js | 3 ++- public/js/icinga/behavior/tooltip.js | 3 ++- public/js/icinga/behavior/tristate.js | 5 ++-- public/js/icinga/eventlistener.js | 3 ++- public/js/icinga/events.js | 3 ++- public/js/icinga/history.js | 3 ++- public/js/icinga/loader.js | 3 ++- public/js/icinga/logger.js | 3 ++- public/js/icinga/module.js | 3 ++- public/js/icinga/timer.js | 3 ++- public/js/icinga/timezone.js | 4 +--- public/js/icinga/ui.js | 23 ++++++++++--------- public/js/icinga/utils.js | 3 ++- .../Authentication/DbBackendFormTest.php | 3 ++- .../Authentication/LdapBackendFormTest.php | 3 ++- .../AuthenticationBackendReorderFormTest.php | 3 ++- .../Config/Resource/DbResourceFormTest.php | 3 ++- .../Config/Resource/LdapResourceFormTest.php | 3 ++- .../Resource/LivestatusResourceFormTest.php | 3 ++- .../views/helpers/DateFormatTestBroken.php | 3 ++- test/php/bootstrap.php | 3 ++- .../library/Icinga/Application/ConfigTest.php | 3 ++- .../library/Icinga/Application/LoaderTest.php | 3 ++- .../library/Icinga/Chart/GraphChartTest.php | 3 ++- .../php/library/Icinga/Chart/PieChartTest.php | 5 ++-- .../library/Icinga/Data/ConfigObjectTest.php | 3 ++- .../Data/DataArray/ArrayDatasourceTest.php | 3 ++- .../library/Icinga/Data/Filter/FilterTest.php | 3 ++- test/php/library/Icinga/File/CsvTest.php | 3 ++- .../library/Icinga/File/Ini/IniWriterTest.php | 3 ++- .../Icinga/Logger/Writer/StreamWriterTest.php | 3 ++- .../Icinga/Protocol/Ldap/QueryTest.php | 3 ++- .../library/Icinga/Test/BaseTestCaseTest.php | 3 ++- .../library/Icinga/User/PreferencesTest.php | 3 ++- .../library/Icinga/User/Store/DbStoreTest.php | 3 ++- .../Icinga/User/Store/IniStoreTest.php | 3 ++- test/php/library/Icinga/UserTest.php | 3 ++- .../Icinga/Util/DateTimeFactoryTest.php | 3 ++- .../php/library/Icinga/Util/DimensionTest.php | 3 ++- test/php/library/Icinga/Util/FileTest.php | 3 ++- test/php/library/Icinga/Util/StringTest.php | 3 ++- .../library/Icinga/Util/TranslatorTest.php | 3 ++- .../Web/Form/Element/DateTimePickerTest.php | 3 ++- .../Validator/DateFormatValidatorTest.php | 3 ++- .../Validator/TimeFormatValidatorTest.php | 3 ++- .../Validator/WritablePathValidatorTest.php | 3 ++- test/php/library/Icinga/Web/FormTest.php | 3 ++- test/php/library/Icinga/Web/HookTest.php | 3 ++- test/php/library/Icinga/Web/MenuTest.php | 3 ++- .../ScrollingStyle/SlidingWithBorderTest.php | 3 ++- .../Icinga/Web/Session/PhpSessionTest.php | 3 ++- .../Web/Session/SessionNamespaceTest.php | 3 ++- test/php/library/Icinga/Web/UrlTest.php | 3 ++- .../Icinga/Web/View/DateTimeRendererTest.php | 3 ++- .../Icinga/Web/Widget/DashboardTest.php | 3 ++- .../Icinga/Web/Widget/SearchDashboardTest.php | 3 ++- test/php/regression/Bug4102Test.php | 3 ++- test/php/regression/Bug6284Test.php | 3 ++- test/php/regression/Bug6432Test.php | 3 ++- 590 files changed, 1165 insertions(+), 652 deletions(-) diff --git a/Vagrantfile b/Vagrantfile index 9090b23aa..1e5e3a073 100644 --- a/Vagrantfile +++ b/Vagrantfile @@ -1,8 +1,6 @@ # -*- mode: ruby -*- # vi: set ft=ruby : -# Icinga Web 2 | (c) 2013-2015 Icinga Development Team | http://www.gnu.org/licenses/gpl-2.0.txt - VAGRANTFILE_API_VERSION = "2" VAGRANT_REQUIRED_VERSION = "1.5.0" diff --git a/application/clicommands/AutocompleteCommand.php b/application/clicommands/AutocompleteCommand.php index 045ee8cdc..5a5a0e0c0 100644 --- a/application/clicommands/AutocompleteCommand.php +++ b/application/clicommands/AutocompleteCommand.php @@ -1,5 +1,6 @@ render($order, $data, $format)); } -} +} \ No newline at end of file diff --git a/library/Icinga/Chart/GridChart.php b/library/Icinga/Chart/GridChart.php index b95fa1fc4..190e09bf9 100644 --- a/library/Icinga/Chart/GridChart.php +++ b/library/Icinga/Chart/GridChart.php @@ -1,5 +1,6 @@ element->toSvg($ctx); return $this->rotate($ctx, $el, $this->degrees); } -} +} \ No newline at end of file diff --git a/library/Icinga/Chart/SVGRenderer.php b/library/Icinga/Chart/SVGRenderer.php index 7de8463bb..da6015ceb 100644 --- a/library/Icinga/Chart/SVGRenderer.php +++ b/library/Icinga/Chart/SVGRenderer.php @@ -1,5 +1,6 @@ filters as & $filter) { $filter = clone $filter; } - } + } } diff --git a/library/Icinga/Data/Filter/FilterEqual.php b/library/Icinga/Data/Filter/FilterEqual.php index 1e567dbf1..66e4c06ad 100644 --- a/library/Icinga/Data/Filter/FilterEqual.php +++ b/library/Icinga/Data/Filter/FilterEqual.php @@ -1,5 +1,6 @@ matches($res)) continue; $result[] = $res; } - + if ($query->hasOrder()) { usort($result, array($query, 'compare')); } diff --git a/library/Icinga/Protocol/Livestatus/Query.php b/library/Icinga/Protocol/Livestatus/Query.php index 94380dfa6..a421c7e71 100644 --- a/library/Icinga/Protocol/Livestatus/Query.php +++ b/library/Icinga/Protocol/Livestatus/Query.php @@ -1,5 +1,6 @@ raw SplArray // $res -> object - // $cv -> + // $cv -> // $result -> object to be returned $result = (object) array(); $res = $this->withHeaders($row); @@ -141,7 +142,7 @@ class Query extends SimpleQuery } } - + return $result; } @@ -312,7 +313,7 @@ class Query extends SimpleQuery } elseif (is_array($col)) { foreach ($col as $k) { $columns[$k] = true; - } + } } else { $columns[$col] = true; } diff --git a/library/Icinga/Protocol/Livestatus/ResponseRow.php b/library/Icinga/Protocol/Livestatus/ResponseRow.php index 9cb67ccf3..d4b0fd7cb 100644 --- a/library/Icinga/Protocol/Livestatus/ResponseRow.php +++ b/library/Icinga/Protocol/Livestatus/ResponseRow.php @@ -1,5 +1,4 @@ view; } -} +} \ No newline at end of file diff --git a/library/Icinga/Web/JavaScript.php b/library/Icinga/Web/JavaScript.php index a8913d3e7..9fa687042 100644 --- a/library/Icinga/Web/JavaScript.php +++ b/library/Icinga/Web/JavaScript.php @@ -1,5 +1,6 @@ reIndexAll(); - return $this; + return $this; } public function remove($param) diff --git a/library/Icinga/Web/View.php b/library/Icinga/Web/View.php index fe232af86..2122662ac 100644 --- a/library/Icinga/Web/View.php +++ b/library/Icinga/Web/View.php @@ -1,5 +1,6 @@ addHelperFunction('icon', function ($img, $title = null, array $propertie $properties['alt'] = $title; $properties['title'] = $title; } - + if ($class !== null) { if (isset($props['class'])) { $properties['class'] .= ' ' . $class; diff --git a/library/Icinga/Web/ViewStream.php b/library/Icinga/Web/ViewStream.php index 6abf49ac3..e5dacd879 100644 --- a/library/Icinga/Web/ViewStream.php +++ b/library/Icinga/Web/ViewStream.php @@ -1,5 +1,6 @@ filter === null) { - $this->filter = Filter::fromQueryString((string) $this->url()->getParams()); + $this->filter = Filter::fromQueryString((string) $this->url()->getParams()); } return $this->filter; } @@ -432,7 +433,7 @@ class FilterEditor extends AbstractWidget protected function renderFilterExpression(FilterExpression $filter) { if ($this->addTo && $this->addTo === $filter->getId()) { - return + return preg_replace( '/ class="autosubmit"/', ' class="autofocus"', @@ -572,7 +573,7 @@ class FilterEditor extends AbstractWidget $cols[$active] = str_replace('_', ' ', ucfirst(ltrim($active, '_'))); } - return $this->select($this->elementId('column', $filter), $cols, $active); + return $this->select($this->elementId('column', $filter), $cols, $active); } protected function applyChanges($changes) diff --git a/library/Icinga/Web/Widget/FilterWidget.php b/library/Icinga/Web/Widget/FilterWidget.php index bd79c25e0..cf47ef581 100644 --- a/library/Icinga/Web/Widget/FilterWidget.php +++ b/library/Icinga/Web/Widget/FilterWidget.php @@ -1,5 +1,6 @@ renderFilter($this->filter); - + $editorUrl = clone $url; $editorUrl->setParam('modifyFilter', true); if ($this->filter->isEmpty()) { diff --git a/library/Icinga/Web/Widget/Limiter.php b/library/Icinga/Web/Widget/Limiter.php index acc66c885..5afa7e4b8 100644 --- a/library/Icinga/Web/Widget/Limiter.php +++ b/library/Icinga/Web/Widget/Limiter.php @@ -1,5 +1,6 @@ 'host_name', - + 'services_total' => 'state != 9999', 'services_problem' => 'state > 0', 'services_problem_handled' => 'state > 0 & (scheduled_downtime_depth > 0 | acknowledged = 1 | host_state > 0)', @@ -49,7 +50,7 @@ if (! array_key_exists($col, $this->available_columns)) { throw new ProgrammingError('No such column: %s', $col); } $filter = $this->filterStringToFilter($this->available_columns[$col]); - + //Filter::fromQueryString(str_replace(' ', '', $this->available_columns[$col])); $parts[] = $this->renderFilter( $filter, 'Stats', 0, false); } diff --git a/modules/monitoring/library/Monitoring/Backend/MonitoringBackend.php b/modules/monitoring/library/Monitoring/Backend/MonitoringBackend.php index 0a1baad7d..d165f1252 100644 --- a/modules/monitoring/library/Monitoring/Backend/MonitoringBackend.php +++ b/modules/monitoring/library/Monitoring/Backend/MonitoringBackend.php @@ -1,5 +1,4 @@

    ' . $this->error->getMessage() . '

    '; } } -} +} \ No newline at end of file diff --git a/modules/monitoring/library/Monitoring/Timeline/TimeEntry.php b/modules/monitoring/library/Monitoring/Timeline/TimeEntry.php index 112bd1e8b..bd83a42cd 100644 --- a/modules/monitoring/library/Monitoring/Timeline/TimeEntry.php +++ b/modules/monitoring/library/Monitoring/Timeline/TimeEntry.php @@ -1,5 +1,6 @@ assertEquals('backendName', $defaultBackend->getName(), 'Default backend has name set'); } -} +} \ No newline at end of file diff --git a/modules/setup/application/clicommands/ConfigCommand.php b/modules/setup/application/clicommands/ConfigCommand.php index f9a73aba4..e63e770b8 100644 --- a/modules/setup/application/clicommands/ConfigCommand.php +++ b/modules/setup/application/clicommands/ConfigCommand.php @@ -1,5 +1,6 @@ .tabs, .dontprint { display: none !important; diff --git a/public/index.php b/public/index.php index 0062bf94f..48a500666 100644 --- a/public/index.php +++ b/public/index.php @@ -1,4 +1,5 @@ 0 ? 1 : 0; - + // fetch current value from radiobuttons var value = $target.find('input:checked').first().val(); - + $target.append( ' ' - ); + ); if (triState) { // TODO: find a better way to activate indeterminate checkboxes after load. $target.append( '' ); } diff --git a/public/js/icinga/utils.js b/public/js/icinga/utils.js index 8539d29ca..ba4d7a040 100644 --- a/public/js/icinga/utils.js +++ b/public/js/icinga/utils.js @@ -1,4 +1,5 @@ -/*! Icinga Web 2 | (c) 2013-2015 Icinga Development Team | http://www.gnu.org/licenses/gpl-2.0.txt */ +// {{{ICINGA_LICENSE_HEADER}}} +// {{{ICINGA_LICENSE_HEADER}}} /** * Icinga utility functions diff --git a/test/php/application/forms/Config/Authentication/DbBackendFormTest.php b/test/php/application/forms/Config/Authentication/DbBackendFormTest.php index 8067b6259..6af628b06 100644 --- a/test/php/application/forms/Config/Authentication/DbBackendFormTest.php +++ b/test/php/application/forms/Config/Authentication/DbBackendFormTest.php @@ -1,5 +1,6 @@ query('//x:path[@data-icinga-graph-type="pieslice"]'); $this->assertEquals(3, $path->length, 'Assert the correct number of datapoints being drawn as SVG bars'); } -} +} \ No newline at end of file diff --git a/test/php/library/Icinga/Data/ConfigObjectTest.php b/test/php/library/Icinga/Data/ConfigObjectTest.php index 40b095267..c4b825e58 100644 --- a/test/php/library/Icinga/Data/ConfigObjectTest.php +++ b/test/php/library/Icinga/Data/ConfigObjectTest.php @@ -1,5 +1,6 @@ Date: Tue, 3 Feb 2015 16:27:59 +0100 Subject: [PATCH 0534/2920] Add license header This time without syntax errors hopefully :) --- Vagrantfile | 2 ++ .../clicommands/AutocompleteCommand.php | 3 +-- application/clicommands/HelpCommand.php | 3 +-- application/clicommands/ModuleCommand.php | 3 +-- application/clicommands/WebCommand.php | 3 +-- .../controllers/AuthenticationController.php | 3 +-- application/controllers/ConfigController.php | 1 + .../controllers/DashboardController.php | 3 +-- application/controllers/ErrorController.php | 1 + application/controllers/FilterController.php | 3 +-- application/controllers/IndexController.php | 3 +-- application/controllers/LayoutController.php | 3 +-- application/controllers/ListController.php | 3 +-- .../controllers/PreferenceController.php | 3 +-- application/controllers/RolesController.php | 1 + application/controllers/SearchController.php | 3 +-- application/controllers/StaticController.php | 3 +-- .../forms/Authentication/LoginForm.php | 3 +-- .../Config/Authentication/DbBackendForm.php | 3 +-- .../Authentication/ExternalBackendForm.php | 3 +-- .../Config/Authentication/LdapBackendForm.php | 3 +-- .../AuthenticationBackendConfigForm.php | 3 +-- .../AuthenticationBackendReorderForm.php | 3 +-- .../Config/General/ApplicationConfigForm.php | 3 +-- .../Config/General/LoggingConfigForm.php | 3 +-- .../forms/Config/GeneralConfigForm.php | 3 +-- .../forms/Config/Resource/DbResourceForm.php | 3 +-- .../Config/Resource/FileResourceForm.php | 3 +-- .../Config/Resource/LdapResourceForm.php | 3 +-- .../Resource/LivestatusResourceForm.php | 3 +-- .../forms/Config/ResourceConfigForm.php | 3 +-- application/forms/ConfigForm.php | 3 +-- application/forms/ConfirmRemovalForm.php | 3 +-- application/forms/Dashboard/DashletForm.php | 3 +-- application/forms/LdapDiscoveryForm.php | 3 +-- application/forms/PreferenceForm.php | 3 +-- application/forms/Security/RoleForm.php | 3 +-- application/views/helpers/DateFormat.php | 3 +-- application/views/helpers/FormDateTime.php | 3 +-- application/views/helpers/FormNumber.php | 3 +-- .../views/helpers/FormTriStateCheckbox.php | 3 +-- application/views/helpers/Util.php | 3 +-- bin/icingacli | 3 +-- bin/license_writer.py | 3 +-- etc/bash_completion.d/icingacli | 3 --- etc/schema/mysql.schema.sql | 2 ++ etc/schema/pgsql.schema.sql | 19 +++------------ icingaweb2.spec | 2 ++ .../Application/ApplicationBootstrap.php | 3 +-- library/Icinga/Application/Benchmark.php | 3 +-- library/Icinga/Application/Cli.php | 3 +-- library/Icinga/Application/Config.php | 3 +-- library/Icinga/Application/EmbeddedWeb.php | 3 +-- library/Icinga/Application/Icinga.php | 3 +-- library/Icinga/Application/LegacyWeb.php | 3 +-- library/Icinga/Application/Loader.php | 3 +-- library/Icinga/Application/Logger.php | 3 +-- .../Icinga/Application/Logger/LogWriter.php | 3 +-- .../Application/Logger/Writer/FileWriter.php | 3 +-- .../Logger/Writer/StdoutWriter.php | 2 +- .../Logger/Writer/SyslogWriter.php | 3 +-- .../Icinga/Application/Modules/Manager.php | 3 +-- library/Icinga/Application/Modules/Module.php | 3 +-- library/Icinga/Application/Platform.php | 3 +-- library/Icinga/Application/Web.php | 3 +-- library/Icinga/Application/functions.php | 3 +-- library/Icinga/Application/webrouter.php | 3 +-- .../Icinga/Authentication/AdmissionLoader.php | 3 +-- library/Icinga/Authentication/AuthChain.php | 3 +-- .../Authentication/Backend/DbUserBackend.php | 3 +-- .../Backend/DbUserGroupBackend.php | 3 +-- .../Backend/ExternalBackend.php | 3 +-- .../Backend/IniUserGroupBackend.php | 3 +-- .../Backend/LdapUserBackend.php | 3 +-- library/Icinga/Authentication/Manager.php | 3 +-- library/Icinga/Authentication/UserBackend.php | 3 +-- .../Authentication/UserGroupBackend.php | 3 +-- library/Icinga/Chart/Axis.php | 3 +-- library/Icinga/Chart/Chart.php | 3 +-- library/Icinga/Chart/Format.php | 3 +-- library/Icinga/Chart/Graph/BarGraph.php | 3 +-- library/Icinga/Chart/Graph/LineGraph.php | 3 +-- library/Icinga/Chart/Graph/StackedGraph.php | 3 +-- library/Icinga/Chart/Graph/Tooltip.php | 5 ++-- library/Icinga/Chart/GridChart.php | 3 +-- library/Icinga/Chart/Inline/Inline.php | 3 +-- library/Icinga/Chart/Inline/PieChart.php | 3 +-- library/Icinga/Chart/Legend.php | 3 +-- library/Icinga/Chart/Palette.php | 3 +-- library/Icinga/Chart/PieChart.php | 3 +-- library/Icinga/Chart/Primitive/Animatable.php | 3 +-- library/Icinga/Chart/Primitive/Animation.php | 3 +-- library/Icinga/Chart/Primitive/Canvas.php | 3 +-- library/Icinga/Chart/Primitive/Circle.php | 3 +-- library/Icinga/Chart/Primitive/Drawable.php | 3 +-- library/Icinga/Chart/Primitive/Line.php | 3 +-- library/Icinga/Chart/Primitive/Path.php | 3 +-- library/Icinga/Chart/Primitive/PieSlice.php | 3 +-- library/Icinga/Chart/Primitive/RawElement.php | 3 +-- library/Icinga/Chart/Primitive/Rect.php | 3 +-- library/Icinga/Chart/Primitive/Styleable.php | 3 +-- library/Icinga/Chart/Primitive/Text.php | 3 +-- library/Icinga/Chart/Render/LayoutBox.php | 3 +-- library/Icinga/Chart/Render/RenderContext.php | 3 +-- library/Icinga/Chart/Render/Rotator.php | 7 ++---- library/Icinga/Chart/SVGRenderer.php | 3 +-- library/Icinga/Chart/Unit/AxisUnit.php | 3 +-- library/Icinga/Chart/Unit/CalendarUnit.php | 3 +-- library/Icinga/Chart/Unit/LinearUnit.php | 3 +-- library/Icinga/Chart/Unit/LogarithmicUnit.php | 3 +-- library/Icinga/Chart/Unit/StaticAxis.php | 3 +-- library/Icinga/Cli/AnsiScreen.php | 3 +-- library/Icinga/Cli/Command.php | 3 +-- library/Icinga/Cli/Documentation.php | 3 +-- .../Cli/Documentation/CommentParser.php | 3 +-- library/Icinga/Cli/Loader.php | 3 +-- library/Icinga/Cli/Params.php | 3 +-- library/Icinga/Cli/Screen.php | 3 +-- library/Icinga/Data/Browsable.php | 3 +-- library/Icinga/Data/ConfigObject.php | 3 +-- library/Icinga/Data/ConnectionInterface.php | 3 +-- .../Icinga/Data/DataArray/ArrayDatasource.php | 5 ++-- library/Icinga/Data/Db/DbConnection.php | 3 +-- library/Icinga/Data/Db/DbQuery.php | 3 +-- library/Icinga/Data/Fetchable.php | 3 +-- library/Icinga/Data/Filter/Filter.php | 3 +-- library/Icinga/Data/Filter/FilterAnd.php | 5 ++-- library/Icinga/Data/Filter/FilterChain.php | 7 +++--- library/Icinga/Data/Filter/FilterEqual.php | 3 +-- .../Data/Filter/FilterEqualOrGreaterThan.php | 3 +-- .../Data/Filter/FilterEqualOrLessThan.php | 3 +-- .../Icinga/Data/Filter/FilterException.php | 3 +-- .../Icinga/Data/Filter/FilterExpression.php | 3 +-- .../Icinga/Data/Filter/FilterGreaterThan.php | 3 +-- library/Icinga/Data/Filter/FilterLessThan.php | 3 +-- library/Icinga/Data/Filter/FilterMatch.php | 3 +-- library/Icinga/Data/Filter/FilterMatchNot.php | 3 +-- library/Icinga/Data/Filter/FilterNot.php | 3 +-- library/Icinga/Data/Filter/FilterNotEqual.php | 3 +-- library/Icinga/Data/Filter/FilterOr.php | 3 +-- .../Data/Filter/FilterParseException.php | 3 +-- .../Icinga/Data/Filter/FilterQueryString.php | 3 +-- library/Icinga/Data/Filterable.php | 3 +-- library/Icinga/Data/Identifiable.php | 3 +-- library/Icinga/Data/Limitable.php | 3 +-- library/Icinga/Data/PivotTable.php | 3 +-- library/Icinga/Data/QueryInterface.php | 3 +-- library/Icinga/Data/Queryable.php | 3 +-- library/Icinga/Data/ResourceFactory.php | 3 +-- library/Icinga/Data/Selectable.php | 3 +-- library/Icinga/Data/SimpleQuery.php | 3 +-- library/Icinga/Data/Sortable.php | 3 +-- library/Icinga/Data/Tree/Node.php | 3 +-- library/Icinga/Data/Tree/NodeInterface.php | 3 +-- .../Exception/AuthenticationException.php | 3 +-- .../Icinga/Exception/ConfigurationError.php | 3 +-- library/Icinga/Exception/IcingaException.php | 3 +-- .../Exception/InvalidPropertyException.php | 3 +-- .../Exception/MissingParameterException.php | 3 +-- library/Icinga/Exception/NotFoundError.php | 3 +-- .../Icinga/Exception/NotImplementedError.php | 3 +-- library/Icinga/Exception/NotReadableError.php | 3 +-- library/Icinga/Exception/NotWritableError.php | 3 +-- library/Icinga/Exception/ProgrammingError.php | 3 +-- library/Icinga/Exception/QueryException.php | 3 +-- .../Exception/SystemPermissionException.php | 3 +-- library/Icinga/File/Csv.php | 3 +-- .../File/FileExtensionFilterIterator.php | 3 +-- library/Icinga/File/Ini/IniEditor.php | 3 +-- library/Icinga/File/Ini/IniWriter.php | 3 +-- library/Icinga/File/NonEmptyFileIterator.php | 3 +-- library/Icinga/File/Pdf.php | 3 +-- library/Icinga/Protocol/Dns.php | 3 +-- .../File/Exception/FileReaderException.php | 2 +- library/Icinga/Protocol/File/FileIterator.php | 3 +-- library/Icinga/Protocol/File/FileQuery.php | 3 +-- library/Icinga/Protocol/File/FileReader.php | 3 +-- library/Icinga/Protocol/Ldap/Connection.php | 3 +-- library/Icinga/Protocol/Ldap/Discovery.php | 5 ++-- library/Icinga/Protocol/Ldap/Exception.php | 3 +-- library/Icinga/Protocol/Ldap/LdapUtils.php | 3 +-- library/Icinga/Protocol/Ldap/Node.php | 3 +-- library/Icinga/Protocol/Ldap/Query.php | 3 +-- library/Icinga/Protocol/Ldap/Root.php | 3 +-- .../Icinga/Protocol/Livestatus/Connection.php | 5 ++-- library/Icinga/Protocol/Livestatus/Query.php | 9 ++++---- .../Protocol/Livestatus/ResponseRow.php | 1 + library/Icinga/Protocol/Nrpe/Connection.php | 3 +-- library/Icinga/Protocol/Nrpe/Packet.php | 3 +-- library/Icinga/Security/SecurityException.php | 1 + library/Icinga/Test/BaseTestCase.php | 3 +-- library/Icinga/Test/DbTest.php | 3 +-- library/Icinga/User.php | 3 +-- library/Icinga/User/Preferences.php | 3 +-- .../User/Preferences/PreferencesStore.php | 3 +-- .../Icinga/User/Preferences/Store/DbStore.php | 3 +-- .../User/Preferences/Store/IniStore.php | 3 +-- library/Icinga/Util/Color.php | 3 +-- library/Icinga/Util/ConfigAwareFactory.php | 3 +-- library/Icinga/Util/DateTimeFactory.php | 3 +-- library/Icinga/Util/Dimension.php | 3 +-- .../Icinga/Util/EnumeratingFilterIterator.php | 3 +-- library/Icinga/Util/File.php | 3 +-- library/Icinga/Util/Format.php | 3 +-- library/Icinga/Util/String.php | 3 +-- library/Icinga/Util/TimezoneDetect.php | 3 +-- library/Icinga/Util/Translator.php | 3 +-- library/Icinga/Web/Controller.php | 1 + .../Web/Controller/ActionController.php | 1 + .../Controller/BasePreferenceController.php | 3 +-- .../Web/Controller/ControllerTabCollector.php | 3 +-- .../Web/Controller/ModuleActionController.php | 3 +-- library/Icinga/Web/FileCache.php | 2 +- library/Icinga/Web/Form.php | 1 + .../Web/Form/Decorator/ConditionalHidden.php | 3 +-- .../Web/Form/Decorator/ElementDoubler.php | 3 +-- .../Web/Form/Decorator/NoScriptApply.php | 3 +-- library/Icinga/Web/Form/Element/Button.php | 3 +-- .../Web/Form/Element/CsrfCounterMeasure.php | 3 +-- .../Web/Form/Element/DateTimePicker.php | 3 +-- library/Icinga/Web/Form/Element/Note.php | 3 +-- library/Icinga/Web/Form/Element/Number.php | 3 +-- .../Web/Form/Element/TriStateCheckbox.php | 3 +-- library/Icinga/Web/Form/FormElement.php | 3 +-- .../Web/Form/InvalidCSRFTokenException.php | 3 +-- .../Form/Validator/DateFormatValidator.php | 3 +-- .../Web/Form/Validator/DateTimeValidator.php | 3 +-- .../Form/Validator/ReadablePathValidator.php | 3 +-- .../Form/Validator/TimeFormatValidator.php | 3 +-- .../Web/Form/Validator/TriStateValidator.php | 3 +-- .../Form/Validator/WritablePathValidator.php | 3 +-- library/Icinga/Web/Hook.php | 3 +-- library/Icinga/Web/Hook/GrapherHook.php | 3 +-- library/Icinga/Web/Hook/TicketHook.php | 3 +-- library/Icinga/Web/Hook/WebBaseHook.php | 5 ++-- library/Icinga/Web/JavaScript.php | 3 +-- library/Icinga/Web/LessCompiler.php | 3 +-- library/Icinga/Web/Menu.php | 3 +-- .../Web/Menu/ForeignMenuItemRenderer.php | 3 +-- library/Icinga/Web/Menu/MenuItemRenderer.php | 3 +-- .../Web/Menu/MonitoringMenuItemRenderer.php | 3 +-- .../Web/Menu/ProblemMenuItemRenderer.php | 1 + .../Menu/UnhandledHostMenuItemRenderer.php | 1 + .../Menu/UnhandledServiceMenuItemRenderer.php | 1 + library/Icinga/Web/MenuRenderer.php | 3 +-- library/Icinga/Web/Notification.php | 3 +-- .../Web/Paginator/Adapter/QueryAdapter.php | 3 +-- .../ScrollingStyle/SlidingWithBorder.php | 5 ++-- library/Icinga/Web/Request.php | 3 +-- library/Icinga/Web/Response.php | 3 +-- library/Icinga/Web/Session.php | 3 +-- library/Icinga/Web/Session/PhpSession.php | 3 +-- library/Icinga/Web/Session/Session.php | 3 +-- .../Icinga/Web/Session/SessionNamespace.php | 3 +-- library/Icinga/Web/StyleSheet.php | 3 +-- library/Icinga/Web/Url.php | 3 +-- library/Icinga/Web/UrlParams.php | 5 ++-- library/Icinga/Web/View.php | 3 +-- library/Icinga/Web/View/DateTimeRenderer.php | 3 +-- library/Icinga/Web/View/helpers/format.php | 3 +-- library/Icinga/Web/View/helpers/generic.php | 3 +-- library/Icinga/Web/View/helpers/url.php | 5 ++-- library/Icinga/Web/ViewStream.php | 3 +-- library/Icinga/Web/Widget.php | 3 +-- library/Icinga/Web/Widget/AbstractWidget.php | 3 +-- .../Web/Widget/Chart/HistoryColorGrid.php | 3 +-- library/Icinga/Web/Widget/Chart/InlinePie.php | 3 +-- library/Icinga/Web/Widget/Dashboard.php | 3 +-- .../Icinga/Web/Widget/Dashboard/Dashlet.php | 3 +-- library/Icinga/Web/Widget/Dashboard/Pane.php | 3 +-- .../Web/Widget/Dashboard/UserWidget.php | 3 +-- library/Icinga/Web/Widget/FilterEditor.php | 9 ++++---- library/Icinga/Web/Widget/FilterWidget.php | 5 ++-- library/Icinga/Web/Widget/Limiter.php | 3 +-- library/Icinga/Web/Widget/SearchDashboard.php | 3 +-- library/Icinga/Web/Widget/SortBox.php | 3 +-- library/Icinga/Web/Widget/Tab.php | 3 +-- .../Web/Widget/Tabextension/BasketAction.php | 3 +-- .../Widget/Tabextension/DashboardAction.php | 3 +-- .../Widget/Tabextension/DashboardSettings.php | 5 ++-- .../Web/Widget/Tabextension/OutputFormat.php | 3 +-- .../Web/Widget/Tabextension/Tabextension.php | 3 +-- library/Icinga/Web/Widget/Tabs.php | 3 +-- library/Icinga/Web/Widget/Widget.php | 3 +-- library/Icinga/Web/Window.php | 3 +-- library/Icinga/Web/Wizard.php | 3 +-- .../controllers/IcingawebController.php | 3 +-- .../controllers/IndexController.php | 3 +-- .../controllers/ModuleController.php | 3 +-- .../controllers/StyleController.php | 1 + modules/doc/configuration.php | 3 +-- modules/doc/library/Doc/DocController.php | 3 +-- modules/doc/library/Doc/DocIterator.php | 3 +-- modules/doc/library/Doc/DocParser.php | 3 +-- modules/doc/library/Doc/DocTree.php | 3 +-- .../Exception/ChapterNotFoundException.php | 3 +-- .../Doc/Exception/DocEmptyException.php | 3 +-- .../library/Doc/Exception/DocException.php | 3 +-- modules/doc/library/Doc/Renderer.php | 3 +-- modules/doc/library/Doc/Section.php | 3 +-- .../doc/library/Doc/SectionFilterIterator.php | 3 +-- modules/doc/library/Doc/SectionRenderer.php | 3 +-- modules/doc/library/Doc/TocRenderer.php | 3 +-- modules/doc/public/css/module.less | 2 ++ modules/doc/run.php | 1 + .../clicommands/ConferenceCommand.php | 3 +-- .../application/clicommands/ListCommand.php | 3 +-- .../application/clicommands/NrpeCommand.php | 3 +-- .../controllers/AlertsummaryController.php | 3 +-- .../controllers/ChartController.php | 3 +-- .../controllers/ConfigController.php | 3 +-- .../controllers/HostController.php | 3 +-- .../controllers/HostsController.php | 3 +-- .../controllers/ListController.php | 1 + .../controllers/ProcessController.php | 3 +-- .../controllers/ServiceController.php | 3 +-- .../controllers/ServicesController.php | 3 +-- .../controllers/ShowController.php | 3 +-- .../controllers/TacticalController.php | 3 +-- .../controllers/TimelineController.php | 3 +-- .../application/forms/Command/CommandForm.php | 3 +-- .../DisableNotificationsExpireCommandForm.php | 3 +-- .../ToggleInstanceFeaturesCommandForm.php | 3 +-- .../Object/AcknowledgeProblemCommandForm.php | 3 +-- .../Command/Object/AddCommentCommandForm.php | 3 +-- .../Command/Object/CheckNowCommandForm.php | 3 +-- .../Object/DeleteCommentCommandForm.php | 3 +-- .../Object/DeleteDowntimeCommandForm.php | 3 +-- .../Command/Object/ObjectsCommandForm.php | 3 +-- .../Object/ProcessCheckResultCommandForm.php | 3 +-- .../RemoveAcknowledgementCommandForm.php | 3 +-- .../Object/ScheduleHostCheckCommandForm.php | 3 +-- .../ScheduleHostDowntimeCommandForm.php | 3 +-- .../ScheduleServiceCheckCommandForm.php | 3 +-- .../ScheduleServiceDowntimeCommandForm.php | 3 +-- .../ToggleObjectFeaturesCommandForm.php | 3 +-- .../forms/Config/BackendConfigForm.php | 3 +-- .../Config/Instance/LocalInstanceForm.php | 3 +-- .../Config/Instance/RemoteInstanceForm.php | 3 +-- .../forms/Config/InstanceConfigForm.php | 3 +-- .../forms/Config/SecurityConfigForm.php | 3 +-- .../application/forms/EventOverviewForm.php | 3 +-- .../application/forms/Setup/BackendPage.php | 3 +-- .../forms/Setup/IdoResourcePage.php | 3 +-- .../application/forms/Setup/InstancePage.php | 3 +-- .../forms/Setup/LivestatusResourcePage.php | 3 +-- .../application/forms/Setup/SecurityPage.php | 3 +-- .../application/forms/Setup/WelcomePage.php | 3 +-- .../application/forms/StatehistoryForm.php | 3 +-- .../views/helpers/CheckPerformance.php | 3 +-- .../views/helpers/ContactFlags.php | 3 +-- .../application/views/helpers/Customvar.php | 1 + .../application/views/helpers/Link.php | 1 + .../views/helpers/MonitoringFlags.php | 3 +-- .../application/views/helpers/Perfdata.php | 3 +-- .../views/helpers/PluginOutput.php | 3 +-- .../views/helpers/ResolveMacros.php | 3 +-- .../views/helpers/RuntimeVariables.php | 3 +-- .../views/helpers/SelectionToolbar.php | 3 +-- modules/monitoring/configuration.php | 1 + .../monitoring/library/Monitoring/Backend.php | 1 + .../Monitoring/Backend/Ido/IdoBackend.php | 1 + .../Backend/Ido/Query/AllcontactsQuery.php | 3 +-- .../Backend/Ido/Query/CommandQuery.php | 5 ++-- .../Backend/Ido/Query/CommentQuery.php | 3 +-- .../Ido/Query/CommentdeletionhistoryQuery.php | 3 +-- .../Backend/Ido/Query/CommenthistoryQuery.php | 3 +-- .../Backend/Ido/Query/ContactQuery.php | 3 +-- .../Backend/Ido/Query/ContactgroupQuery.php | 3 +-- .../Backend/Ido/Query/CustomvarQuery.php | 3 +-- .../Backend/Ido/Query/DowntimeQuery.php | 1 + .../Ido/Query/DowntimeendhistoryQuery.php | 3 +-- .../Ido/Query/DowntimestarthistoryQuery.php | 3 +-- .../Backend/Ido/Query/EventHistoryQuery.php | 1 + .../Backend/Ido/Query/EventgridQuery.php | 3 +-- .../Backend/Ido/Query/GroupsummaryQuery.php | 3 +-- .../Backend/Ido/Query/HostgroupQuery.php | 3 +-- .../Backend/Ido/Query/HoststatusQuery.php | 3 +-- .../Monitoring/Backend/Ido/Query/IdoQuery.php | 3 +-- .../Backend/Ido/Query/NotificationQuery.php | 1 + .../Ido/Query/NotificationhistoryQuery.php | 3 +-- .../Backend/Ido/Query/ProgramstatusQuery.php | 3 +-- .../Backend/Ido/Query/RuntimesummaryQuery.php | 3 +-- .../Ido/Query/RuntimevariablesQuery.php | 3 +-- .../Backend/Ido/Query/ServicegroupQuery.php | 3 +-- .../Backend/Ido/Query/StatehistoryQuery.php | 1 + .../Backend/Ido/Query/StatusQuery.php | 3 +-- .../Backend/Ido/Query/StatusSummaryQuery.php | 3 +-- .../Backend/Livestatus/LivestatusBackend.php | 1 + .../Livestatus/Query/DowntimeQuery.php | 3 +-- .../Livestatus/Query/HostgroupQuery.php | 3 +-- .../Livestatus/Query/ServicegroupQuery.php | 3 +-- .../Backend/Livestatus/Query/StatusQuery.php | 3 +-- .../Livestatus/Query/StatusSummaryQuery.php | 7 +++--- .../Monitoring/Backend/MonitoringBackend.php | 1 + .../library/Monitoring/BackendStep.php | 3 +-- .../library/Monitoring/Cli/CliUtils.php | 3 +-- .../Command/Exception/TransportException.php | 3 +-- .../Monitoring/Command/IcingaCommand.php | 3 +-- .../DisableNotificationsExpireCommand.php | 3 +-- .../Instance/ToggleInstanceFeatureCommand.php | 3 +-- .../Object/AcknowledgeProblemCommand.php | 3 +-- .../Command/Object/AddCommentCommand.php | 3 +-- .../Command/Object/DeleteCommentCommand.php | 3 +-- .../Command/Object/DeleteDowntimeCommand.php | 3 +-- .../Command/Object/ObjectCommand.php | 3 +-- .../Object/ProcessCheckResultCommand.php | 3 +-- .../Object/PropagateHostDowntimeCommand.php | 3 +-- .../Object/RemoveAcknowledgementCommand.php | 3 +-- .../Object/ScheduleHostCheckCommand.php | 3 +-- .../Object/ScheduleHostDowntimeCommand.php | 3 +-- .../Object/ScheduleServiceCheckCommand.php | 3 +-- .../Object/ScheduleServiceDowntimeCommand.php | 3 +-- .../Object/ToggleObjectFeatureCommand.php | 3 +-- .../Command/Object/WithCommentCommand.php | 3 +-- .../IcingaCommandFileCommandRenderer.php | 1 + .../IcingaCommandRendererInterface.php | 1 + .../Command/Transport/CommandTransport.php | 3 +-- .../Transport/CommandTransportInterface.php | 3 +-- .../Command/Transport/LocalCommandFile.php | 3 +-- .../Command/Transport/RemoteCommandFile.php | 3 +-- .../library/Monitoring/Controller.php | 3 +-- .../library/Monitoring/DataView/Command.php | 5 ++-- .../library/Monitoring/DataView/Comment.php | 3 +-- .../library/Monitoring/DataView/Contact.php | 3 +-- .../Monitoring/DataView/Contactgroup.php | 3 +-- .../library/Monitoring/DataView/Customvar.php | 3 +-- .../library/Monitoring/DataView/DataView.php | 3 +-- .../library/Monitoring/DataView/Downtime.php | 3 +-- .../Monitoring/DataView/EventHistory.php | 1 + .../library/Monitoring/DataView/Eventgrid.php | 3 +-- .../Monitoring/DataView/Groupsummary.php | 3 +-- .../Monitoring/DataView/HostStatus.php | 3 +-- .../library/Monitoring/DataView/Hostgroup.php | 3 +-- .../Monitoring/DataView/Notification.php | 3 +-- .../Monitoring/DataView/Programstatus.php | 3 +-- .../Monitoring/DataView/Runtimesummary.php | 3 +-- .../Monitoring/DataView/Runtimevariables.php | 3 +-- .../Monitoring/DataView/ServiceStatus.php | 3 +-- .../Monitoring/DataView/Servicegroup.php | 3 +-- .../Monitoring/DataView/StatusSummary.php | 3 +-- .../library/Monitoring/Environment.php | 3 +-- .../Exception/UnsupportedBackendException.php | 3 +-- .../library/Monitoring/InstanceStep.php | 3 +-- .../library/Monitoring/MonitoringWizard.php | 3 +-- .../library/Monitoring/Object/Host.php | 3 +-- .../library/Monitoring/Object/HostList.php | 1 + .../Monitoring/Object/MonitoredObject.php | 3 +-- .../library/Monitoring/Object/ObjectList.php | 1 + .../library/Monitoring/Object/Service.php | 3 +-- .../library/Monitoring/Object/ServiceList.php | 1 + .../monitoring/library/Monitoring/Plugin.php | 3 +-- .../library/Monitoring/Plugin/Perfdata.php | 3 +-- .../library/Monitoring/Plugin/PerfdataSet.php | 3 +-- .../library/Monitoring/SecurityStep.php | 5 ++-- .../library/Monitoring/Timeline/TimeEntry.php | 3 +-- .../library/Monitoring/Timeline/TimeLine.php | 3 +-- .../library/Monitoring/Timeline/TimeRange.php | 3 +-- .../Controller/MonitoredObjectController.php | 1 + .../Monitoring/Web/Hook/HostActionsHook.php | 1 + .../Web/Hook/TimelineProviderHook.php | 3 +-- .../Monitoring/Web/Widget/SelectBox.php | 5 ++-- modules/monitoring/public/css/module.less | 7 +++--- modules/monitoring/public/js/module.js | 3 +-- .../views/helpers/MonitoringFlagsTest.php | 3 +-- .../views/helpers/ResolveMacrosTest.php | 3 +-- .../Monitoring/Plugin/PerfdataSetTest.php | 3 +-- .../Monitoring/Plugin/PerfdataTest.php | 3 +-- .../test/php/regression/Bug6088Test.php | 3 +-- .../test/php/regression/Bug7043Test.php | 3 ++- .../application/clicommands/ConfigCommand.php | 3 +-- .../application/clicommands/TokenCommand.php | 3 +-- .../controllers/IndexController.php | 3 +-- .../application/forms/AdminAccountPage.php | 3 +-- .../application/forms/AuthBackendPage.php | 3 +-- .../application/forms/AuthenticationPage.php | 3 +-- .../forms/DatabaseCreationPage.php | 3 +-- .../application/forms/DbResourcePage.php | 3 +-- .../application/forms/GeneralConfigPage.php | 3 +-- .../forms/LdapDiscoveryConfirmPage.php | 3 +-- .../application/forms/LdapDiscoveryPage.php | 3 +-- .../application/forms/LdapResourcePage.php | 3 +-- .../setup/application/forms/ModulePage.php | 3 +-- .../application/forms/PreferencesPage.php | 3 +-- .../application/forms/RequirementsPage.php | 3 +-- .../setup/application/forms/SummaryPage.php | 3 +-- .../setup/application/forms/WelcomePage.php | 3 +-- .../Setup/Exception/SetupException.php | 5 ++-- modules/setup/library/Setup/Requirements.php | 3 +-- modules/setup/library/Setup/Setup.php | 3 +-- modules/setup/library/Setup/SetupWizard.php | 3 +-- modules/setup/library/Setup/Step.php | 3 +-- .../Setup/Steps/AuthenticationStep.php | 3 +-- .../library/Setup/Steps/DatabaseStep.php | 3 +-- .../library/Setup/Steps/GeneralConfigStep.php | 3 +-- .../library/Setup/Steps/ResourceStep.php | 3 +-- modules/setup/library/Setup/Utils/DbTool.php | 3 +-- .../library/Setup/Utils/EnableModuleStep.php | 3 +-- .../setup/library/Setup/Utils/MakeDirStep.php | 3 +-- .../Web/Form/Validator/TokenValidator.php | 3 +-- modules/setup/library/Setup/WebWizard.php | 3 +-- modules/setup/library/Setup/Webserver.php | 3 +-- .../setup/library/Setup/Webserver/Apache.php | 3 +-- .../setup/library/Setup/Webserver/Nginx.php | 3 +-- .../application/clicommands/PhpCommand.php | 3 +-- .../clicommands/CompileCommand.php | 3 +-- .../clicommands/RefreshCommand.php | 3 +-- .../Translation/Cli/TranslationCommand.php | 3 +-- .../Util/GettextTranslationHelper.php | 3 +-- packages/files/bin/icingacli | 1 + packages/files/public/index.php | 1 + public/css/icinga/defaults.less | 3 +-- public/css/icinga/forms.less | 3 +-- public/css/icinga/header-elements.less | 3 +-- public/css/icinga/layout-colors.less | 3 +-- public/css/icinga/layout-structure.less | 3 +-- public/css/icinga/login.less | 5 ++-- public/css/icinga/main-content.less | 5 ++-- public/css/icinga/menu.less | 3 +-- public/css/icinga/monitoring-colors.less | 17 +++++++------- public/css/icinga/pagination.less | 3 +-- public/css/icinga/selection-toolbar.less | 3 +-- public/css/icinga/setup.less | 4 +++- public/css/icinga/tabs.less | 3 +-- public/css/icinga/widgets.less | 5 ++-- public/css/pdf/pdfprint.less | 3 +-- public/index.php | 3 +-- public/js/helpers.js | 3 +-- public/js/icinga.js | 3 +-- public/js/icinga/behavior/form.js | 3 +-- public/js/icinga/behavior/navigation.js | 5 ++-- public/js/icinga/behavior/sparkline.js | 3 +-- public/js/icinga/behavior/tooltip.js | 3 +-- public/js/icinga/behavior/tristate.js | 5 ++-- public/js/icinga/eventlistener.js | 3 +-- public/js/icinga/events.js | 3 +-- public/js/icinga/history.js | 3 +-- public/js/icinga/loader.js | 3 +-- public/js/icinga/logger.js | 3 +-- public/js/icinga/module.js | 3 +-- public/js/icinga/timer.js | 3 +-- public/js/icinga/timezone.js | 4 +++- public/js/icinga/ui.js | 23 +++++++++---------- public/js/icinga/utils.js | 3 +-- .../Authentication/DbBackendFormTest.php | 3 +-- .../Authentication/LdapBackendFormTest.php | 3 +-- .../AuthenticationBackendReorderFormTest.php | 3 +-- .../Config/Resource/DbResourceFormTest.php | 3 +-- .../Config/Resource/LdapResourceFormTest.php | 3 +-- .../Resource/LivestatusResourceFormTest.php | 3 +-- .../views/helpers/DateFormatTestBroken.php | 3 +-- test/php/bootstrap.php | 3 +-- .../library/Icinga/Application/ConfigTest.php | 3 +-- .../library/Icinga/Application/LoaderTest.php | 3 +-- .../library/Icinga/Chart/GraphChartTest.php | 3 +-- .../php/library/Icinga/Chart/PieChartTest.php | 5 ++-- .../library/Icinga/Data/ConfigObjectTest.php | 3 +-- .../Data/DataArray/ArrayDatasourceTest.php | 3 +-- .../library/Icinga/Data/Filter/FilterTest.php | 3 +-- test/php/library/Icinga/File/CsvTest.php | 3 +-- .../library/Icinga/File/Ini/IniWriterTest.php | 3 +-- .../Icinga/Logger/Writer/StreamWriterTest.php | 3 +-- .../Icinga/Protocol/Ldap/QueryTest.php | 3 +-- .../library/Icinga/Test/BaseTestCaseTest.php | 3 +-- .../library/Icinga/User/PreferencesTest.php | 3 +-- .../library/Icinga/User/Store/DbStoreTest.php | 3 +-- .../Icinga/User/Store/IniStoreTest.php | 3 +-- test/php/library/Icinga/UserTest.php | 3 +-- .../Icinga/Util/DateTimeFactoryTest.php | 3 +-- .../php/library/Icinga/Util/DimensionTest.php | 3 +-- test/php/library/Icinga/Util/FileTest.php | 3 +-- test/php/library/Icinga/Util/StringTest.php | 3 +-- .../library/Icinga/Util/TranslatorTest.php | 3 +-- .../Web/Form/Element/DateTimePickerTest.php | 3 +-- .../Validator/DateFormatValidatorTest.php | 3 +-- .../Validator/TimeFormatValidatorTest.php | 3 +-- .../Validator/WritablePathValidatorTest.php | 3 +-- test/php/library/Icinga/Web/FormTest.php | 3 +-- test/php/library/Icinga/Web/HookTest.php | 3 +-- test/php/library/Icinga/Web/MenuTest.php | 3 +-- .../ScrollingStyle/SlidingWithBorderTest.php | 3 +-- .../Icinga/Web/Session/PhpSessionTest.php | 3 +-- .../Web/Session/SessionNamespaceTest.php | 3 +-- test/php/library/Icinga/Web/UrlTest.php | 3 +-- .../Icinga/Web/View/DateTimeRendererTest.php | 3 +-- .../Icinga/Web/Widget/DashboardTest.php | 3 +-- .../Icinga/Web/Widget/SearchDashboardTest.php | 3 +-- test/php/regression/Bug4102Test.php | 3 +-- test/php/regression/Bug6284Test.php | 3 +-- test/php/regression/Bug6432Test.php | 3 +-- 590 files changed, 652 insertions(+), 1165 deletions(-) diff --git a/Vagrantfile b/Vagrantfile index 1e5e3a073..9090b23aa 100644 --- a/Vagrantfile +++ b/Vagrantfile @@ -1,6 +1,8 @@ # -*- mode: ruby -*- # vi: set ft=ruby : +# Icinga Web 2 | (c) 2013-2015 Icinga Development Team | http://www.gnu.org/licenses/gpl-2.0.txt + VAGRANTFILE_API_VERSION = "2" VAGRANT_REQUIRED_VERSION = "1.5.0" diff --git a/application/clicommands/AutocompleteCommand.php b/application/clicommands/AutocompleteCommand.php index 5a5a0e0c0..045ee8cdc 100644 --- a/application/clicommands/AutocompleteCommand.php +++ b/application/clicommands/AutocompleteCommand.php @@ -1,6 +1,5 @@ render($order, $data, $format)); } -} \ No newline at end of file +} diff --git a/library/Icinga/Chart/GridChart.php b/library/Icinga/Chart/GridChart.php index 190e09bf9..b95fa1fc4 100644 --- a/library/Icinga/Chart/GridChart.php +++ b/library/Icinga/Chart/GridChart.php @@ -1,6 +1,5 @@ element->toSvg($ctx); return $this->rotate($ctx, $el, $this->degrees); } -} \ No newline at end of file +} diff --git a/library/Icinga/Chart/SVGRenderer.php b/library/Icinga/Chart/SVGRenderer.php index da6015ceb..7de8463bb 100644 --- a/library/Icinga/Chart/SVGRenderer.php +++ b/library/Icinga/Chart/SVGRenderer.php @@ -1,6 +1,5 @@ filters as & $filter) { $filter = clone $filter; } - } + } } diff --git a/library/Icinga/Data/Filter/FilterEqual.php b/library/Icinga/Data/Filter/FilterEqual.php index 66e4c06ad..1e567dbf1 100644 --- a/library/Icinga/Data/Filter/FilterEqual.php +++ b/library/Icinga/Data/Filter/FilterEqual.php @@ -1,6 +1,5 @@ matches($res)) continue; $result[] = $res; } - + if ($query->hasOrder()) { usort($result, array($query, 'compare')); } diff --git a/library/Icinga/Protocol/Livestatus/Query.php b/library/Icinga/Protocol/Livestatus/Query.php index a421c7e71..94380dfa6 100644 --- a/library/Icinga/Protocol/Livestatus/Query.php +++ b/library/Icinga/Protocol/Livestatus/Query.php @@ -1,6 +1,5 @@ raw SplArray // $res -> object - // $cv -> + // $cv -> // $result -> object to be returned $result = (object) array(); $res = $this->withHeaders($row); @@ -142,7 +141,7 @@ class Query extends SimpleQuery } } - + return $result; } @@ -313,7 +312,7 @@ class Query extends SimpleQuery } elseif (is_array($col)) { foreach ($col as $k) { $columns[$k] = true; - } + } } else { $columns[$col] = true; } diff --git a/library/Icinga/Protocol/Livestatus/ResponseRow.php b/library/Icinga/Protocol/Livestatus/ResponseRow.php index d4b0fd7cb..9cb67ccf3 100644 --- a/library/Icinga/Protocol/Livestatus/ResponseRow.php +++ b/library/Icinga/Protocol/Livestatus/ResponseRow.php @@ -1,4 +1,5 @@ view; } -} \ No newline at end of file +} diff --git a/library/Icinga/Web/JavaScript.php b/library/Icinga/Web/JavaScript.php index 9fa687042..a8913d3e7 100644 --- a/library/Icinga/Web/JavaScript.php +++ b/library/Icinga/Web/JavaScript.php @@ -1,6 +1,5 @@ reIndexAll(); - return $this; + return $this; } public function remove($param) diff --git a/library/Icinga/Web/View.php b/library/Icinga/Web/View.php index 2122662ac..fe232af86 100644 --- a/library/Icinga/Web/View.php +++ b/library/Icinga/Web/View.php @@ -1,6 +1,5 @@ addHelperFunction('icon', function ($img, $title = null, array $propertie $properties['alt'] = $title; $properties['title'] = $title; } - + if ($class !== null) { if (isset($props['class'])) { $properties['class'] .= ' ' . $class; diff --git a/library/Icinga/Web/ViewStream.php b/library/Icinga/Web/ViewStream.php index e5dacd879..6abf49ac3 100644 --- a/library/Icinga/Web/ViewStream.php +++ b/library/Icinga/Web/ViewStream.php @@ -1,6 +1,5 @@ filter === null) { - $this->filter = Filter::fromQueryString((string) $this->url()->getParams()); + $this->filter = Filter::fromQueryString((string) $this->url()->getParams()); } return $this->filter; } @@ -433,7 +432,7 @@ class FilterEditor extends AbstractWidget protected function renderFilterExpression(FilterExpression $filter) { if ($this->addTo && $this->addTo === $filter->getId()) { - return + return preg_replace( '/ class="autosubmit"/', ' class="autofocus"', @@ -573,7 +572,7 @@ class FilterEditor extends AbstractWidget $cols[$active] = str_replace('_', ' ', ucfirst(ltrim($active, '_'))); } - return $this->select($this->elementId('column', $filter), $cols, $active); + return $this->select($this->elementId('column', $filter), $cols, $active); } protected function applyChanges($changes) diff --git a/library/Icinga/Web/Widget/FilterWidget.php b/library/Icinga/Web/Widget/FilterWidget.php index cf47ef581..bd79c25e0 100644 --- a/library/Icinga/Web/Widget/FilterWidget.php +++ b/library/Icinga/Web/Widget/FilterWidget.php @@ -1,6 +1,5 @@ renderFilter($this->filter); - + $editorUrl = clone $url; $editorUrl->setParam('modifyFilter', true); if ($this->filter->isEmpty()) { diff --git a/library/Icinga/Web/Widget/Limiter.php b/library/Icinga/Web/Widget/Limiter.php index 5afa7e4b8..acc66c885 100644 --- a/library/Icinga/Web/Widget/Limiter.php +++ b/library/Icinga/Web/Widget/Limiter.php @@ -1,6 +1,5 @@ 'host_name', - + 'services_total' => 'state != 9999', 'services_problem' => 'state > 0', 'services_problem_handled' => 'state > 0 & (scheduled_downtime_depth > 0 | acknowledged = 1 | host_state > 0)', @@ -50,7 +49,7 @@ if (! array_key_exists($col, $this->available_columns)) { throw new ProgrammingError('No such column: %s', $col); } $filter = $this->filterStringToFilter($this->available_columns[$col]); - + //Filter::fromQueryString(str_replace(' ', '', $this->available_columns[$col])); $parts[] = $this->renderFilter( $filter, 'Stats', 0, false); } diff --git a/modules/monitoring/library/Monitoring/Backend/MonitoringBackend.php b/modules/monitoring/library/Monitoring/Backend/MonitoringBackend.php index d165f1252..0a1baad7d 100644 --- a/modules/monitoring/library/Monitoring/Backend/MonitoringBackend.php +++ b/modules/monitoring/library/Monitoring/Backend/MonitoringBackend.php @@ -1,4 +1,5 @@

    ' . $this->error->getMessage() . '

    '; } } -} \ No newline at end of file +} diff --git a/modules/monitoring/library/Monitoring/Timeline/TimeEntry.php b/modules/monitoring/library/Monitoring/Timeline/TimeEntry.php index bd83a42cd..112bd1e8b 100644 --- a/modules/monitoring/library/Monitoring/Timeline/TimeEntry.php +++ b/modules/monitoring/library/Monitoring/Timeline/TimeEntry.php @@ -1,6 +1,5 @@ assertEquals('backendName', $defaultBackend->getName(), 'Default backend has name set'); } -} \ No newline at end of file +} diff --git a/modules/setup/application/clicommands/ConfigCommand.php b/modules/setup/application/clicommands/ConfigCommand.php index e63e770b8..f9a73aba4 100644 --- a/modules/setup/application/clicommands/ConfigCommand.php +++ b/modules/setup/application/clicommands/ConfigCommand.php @@ -1,6 +1,5 @@ .tabs, .dontprint { display: none !important; diff --git a/public/index.php b/public/index.php index 48a500666..0062bf94f 100644 --- a/public/index.php +++ b/public/index.php @@ -1,5 +1,4 @@ 0 ? 1 : 0; - + // fetch current value from radiobuttons var value = $target.find('input:checked').first().val(); - + $target.append( ' ' - ); + ); if (triState) { // TODO: find a better way to activate indeterminate checkboxes after load. $target.append( '' ); } diff --git a/public/js/icinga/utils.js b/public/js/icinga/utils.js index ba4d7a040..8539d29ca 100644 --- a/public/js/icinga/utils.js +++ b/public/js/icinga/utils.js @@ -1,5 +1,4 @@ -// {{{ICINGA_LICENSE_HEADER}}} -// {{{ICINGA_LICENSE_HEADER}}} +/*! Icinga Web 2 | (c) 2013-2015 Icinga Development Team | http://www.gnu.org/licenses/gpl-2.0.txt */ /** * Icinga utility functions diff --git a/test/php/application/forms/Config/Authentication/DbBackendFormTest.php b/test/php/application/forms/Config/Authentication/DbBackendFormTest.php index 6af628b06..8067b6259 100644 --- a/test/php/application/forms/Config/Authentication/DbBackendFormTest.php +++ b/test/php/application/forms/Config/Authentication/DbBackendFormTest.php @@ -1,6 +1,5 @@ query('//x:path[@data-icinga-graph-type="pieslice"]'); $this->assertEquals(3, $path->length, 'Assert the correct number of datapoints being drawn as SVG bars'); } -} \ No newline at end of file +} diff --git a/test/php/library/Icinga/Data/ConfigObjectTest.php b/test/php/library/Icinga/Data/ConfigObjectTest.php index c4b825e58..40b095267 100644 --- a/test/php/library/Icinga/Data/ConfigObjectTest.php +++ b/test/php/library/Icinga/Data/ConfigObjectTest.php @@ -1,6 +1,5 @@ Date: Tue, 3 Feb 2015 16:38:32 +0100 Subject: [PATCH 0535/2920] It's not the "permissions.ini" but the "roles.ini" that holds the role settings --- modules/setup/library/Setup/Steps/AuthenticationStep.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/setup/library/Setup/Steps/AuthenticationStep.php b/modules/setup/library/Setup/Steps/AuthenticationStep.php index 407ef4182..9c40679c2 100644 --- a/modules/setup/library/Setup/Steps/AuthenticationStep.php +++ b/modules/setup/library/Setup/Steps/AuthenticationStep.php @@ -65,12 +65,12 @@ class AuthenticationStep extends Step $config = array(); $config['admins'] = array( 'users' => $this->data['adminAccountData']['username'], - 'permission' => '*' + 'permissions' => '*' ); try { Config::fromArray($config) - ->setConfigFile(Config::resolvePath('permissions.ini')) + ->setConfigFile(Config::resolvePath('roles.ini')) ->saveIni(); } catch (Exception $e) { $this->permIniError = $e; From e8466ec7bed7a16533b64945eb64796493c5b764 Mon Sep 17 00:00:00 2001 From: Matthias Jentsch Date: Tue, 3 Feb 2015 16:45:01 +0100 Subject: [PATCH 0536/2920] Fix inlinePie borders and SVG sizes Add white border to inline piecharts in the list, to make them more visible on mouse hovering. Set a default image size for the loaded svg charts. --- library/Icinga/Web/Widget/Chart/InlinePie.php | 7 +++---- .../application/views/helpers/Perfdata.php | 13 +++++++++---- .../application/views/scripts/list/services.phtml | 2 +- public/css/icinga/widgets.less | 9 +++++++++ public/js/icinga/behavior/navigation.js | 3 +-- public/js/icinga/behavior/sparkline.js | 8 +++++--- 6 files changed, 28 insertions(+), 14 deletions(-) diff --git a/library/Icinga/Web/Widget/Chart/InlinePie.php b/library/Icinga/Web/Widget/Chart/InlinePie.php index 310a88b3c..bd86acde1 100644 --- a/library/Icinga/Web/Widget/Chart/InlinePie.php +++ b/library/Icinga/Web/Widget/Chart/InlinePie.php @@ -33,14 +33,14 @@ class InlinePie extends AbstractWidget * @var string */ private $template =<<<'EOD' - + {noscript} EOD; private $noscript =<<<'EOD' EOD; @@ -216,8 +216,7 @@ EOD; $template = str_replace('{class}', $this->class, $template); // style - $template = str_replace('{size}', - isset($this->size) ? 'sparkWidth="' . $this->size . '" sparkHeight="' . $this->size . '" ' : '', $template); + $template = str_replace('{size}', isset($this->size) ? $this->size : 16, $template); $template = str_replace('{title}', $this->title, $template); $template = str_replace('{colors}', implode(',', $this->colors), $template); diff --git a/modules/monitoring/application/views/helpers/Perfdata.php b/modules/monitoring/application/views/helpers/Perfdata.php index e3b92510f..8e79fceeb 100644 --- a/modules/monitoring/application/views/helpers/Perfdata.php +++ b/modules/monitoring/application/views/helpers/Perfdata.php @@ -18,11 +18,11 @@ class Zend_View_Helper_Perfdata extends Zend_View_Helper_Abstract * * @return string */ - public function perfdata($perfdataStr, $compact = false, $color = Perfdata::PERFDATA_OK) + public function perfdata($perfdataStr, $compact = false, $limit = 0, $color = Perfdata::PERFDATA_OK) { $pieChartData = PerfdataSet::fromString($perfdataStr)->asArray(); - $result = ''; + $results = array(); $table = array( '
    ' . implode( '', @@ -32,7 +32,7 @@ class Zend_View_Helper_Perfdata extends Zend_View_Helper_Abstract foreach ($pieChartData as $perfdata) { if ($compact && $perfdata->isVisualizable()) { - $result .= $perfdata->asInlinePie($color)->render(); + $results[] = $perfdata->asInlinePie($color)->render(); } else { $row = '
    ' . implode("\n", $table) . '
    '; return $pieCharts; diff --git a/modules/monitoring/application/views/scripts/list/services.phtml b/modules/monitoring/application/views/scripts/list/services.phtml index 45d59adf5..f7bbffe57 100644 --- a/modules/monitoring/application/views/scripts/list/services.phtml +++ b/modules/monitoring/application/views/scripts/list/services.phtml @@ -65,7 +65,7 @@ foreach ($services as $service):
    - perfdata($service->service_perfdata, true) ?> +
    perfdata($service->service_perfdata, true, 8) ?>
    service_handled && $service->service_state > 0): ?> icon('attention-alt', $this->translate('Unhandled')) ?> diff --git a/public/css/icinga/widgets.less b/public/css/icinga/widgets.less index 87818bbaa..6263a6f0b 100644 --- a/public/css/icinga/widgets.less +++ b/public/css/icinga/widgets.less @@ -285,6 +285,15 @@ li li .badge { background-color: #eee; } +.sparkline-box { + position: relative; + top: -9px; +} + +.dashboard .sparkline-box { + top: -3px; +} + .sparkline { width: 12px; height: 12px; diff --git a/public/js/icinga/behavior/navigation.js b/public/js/icinga/behavior/navigation.js index ebe74b422..d9f2060a6 100644 --- a/public/js/icinga/behavior/navigation.js +++ b/public/js/icinga/behavior/navigation.js @@ -85,8 +85,7 @@ $menu.data('icinga-url', menuDataUrl); }; - Navigation.prototype.setActiveByUrl = function(url) - { + Navigation.prototype.setActiveByUrl = function(url) { this.resetActive(); this.setActive($('#menu [href="' + url + '"]')); } diff --git a/public/js/icinga/behavior/sparkline.js b/public/js/icinga/behavior/sparkline.js index 43fa2a4c9..4a5cbefd5 100644 --- a/public/js/icinga/behavior/sparkline.js +++ b/public/js/icinga/behavior/sparkline.js @@ -28,10 +28,12 @@ if ($spark.hasClass('sparkline-perfdata')) { options = { enableTagOptions: true, - width: 12, - height: 12, + width: 16, + height: 16, title: title, - disableTooltips: true + disableTooltips: true, + borderWidth: 1.4, + borderColor: '#FFF' }; $spark.sparkline('html', options); } else if ($spark.hasClass('sparkline-multi')) { From 49e96b72009e6d2c7363e096335cb0e478713ab5 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Tue, 3 Feb 2015 16:49:39 +0100 Subject: [PATCH 0537/2920] Revert "monitoring/security: Guard delete comment action" This reverts commit 4ef5f0c813767fb18dd415e67aa9f36673de0315. --- library/Icinga/Web/Widget/FilterEditor.php | 69 ++++++------------- .../Controller/MonitoredObjectController.php | 1 - 2 files changed, 20 insertions(+), 50 deletions(-) diff --git a/library/Icinga/Web/Widget/FilterEditor.php b/library/Icinga/Web/Widget/FilterEditor.php index c515ee79d..c7a240da8 100644 --- a/library/Icinga/Web/Widget/FilterEditor.php +++ b/library/Icinga/Web/Widget/FilterEditor.php @@ -123,55 +123,26 @@ class FilterEditor extends AbstractWidget { $found = false; if ($filter->isChain() && $filter->getOperatorName() === 'AND') { - if (is_array($column)) { - foreach ($filter->filters() as $f) { - if ($f->isChain() && $f->getOperatorName() === 'OR') { - - } - } - } else { - foreach ($filter->filters() as $f) { - if ($f->isExpression() - && $f->getColumn() === $column - && $f->getSign() === $sign - ) { - $f->setExpression($expression); - $found = true; - break; - } + foreach ($filter->filters() as $f) { + if ($f->isExpression() + && $f->getColumn() === $column + && $f->getSign() === $sign + ) { + $f->setExpression($expression); + $found = true; + break; } } - } elseif ($filter->isExpression() && $filter->getSign() === $sign) { - if (is_array($column)) { - if (in_array($filter->getColumn(), $column)) { - $or = Filter::matchAny(); - foreach ($column as $col) { - $or->addFilter( - Filter::expression($col, $sign, $expression) - ); - } - $filter = $filter->andFilter($or); - $found = true; - } - } elseif ($filter->getColumn() === $column) { + } elseif ($filter->isExpression()) { + if ($filter->getColumn() === $column && $filter->getSign() === $sign) { $filter->setExpression($expression); $found = true; } } if (! $found) { - if (is_array($column)) { - $or = Filter::matchAny(); - foreach ($column as $col) { - $or->addFilter( - Filter::expression($col, $sign, $expression) - ); - } - $filter = $filter->andFilter($or); - } else { - $filter = $filter->andFilter( - Filter::expression($column, $sign, $expression) - ); - } + $filter = $filter->andFilter( + Filter::expression($column, $sign, $expression) + ); } return $filter; } @@ -212,25 +183,25 @@ class FilterEditor extends AbstractWidget // TODO: Ask the view for (multiple) search columns switch($request->getActionName()) { case 'services': - $searchCols = array('service_description', 'service_display_name'); + $searchCol = 'service_description'; break; case 'hosts': - $searchCols = array('host_name', 'host_display_name'); + $searchCol = 'host_name'; break; case 'hostgroups': - $searchCols = array('hostgroup', 'hostgroup_alias'); + $searchCol = 'hostgroup'; break; case 'servicegroups': - $searchCols = array('servicegroup', 'servicegroup_alias'); + $searchCol = 'servicegroup'; break; default: - $searchCols = null; + $searchCol = null; } - if ($searchCols === null) { + if ($searchCol === null) { throw new Exception('Cannot search here'); } - $filter = $this->mergeRootExpression($filter, $searchCols, '=', "*$search*"); + $filter = $this->mergeRootExpression($filter, $searchCol, '=', "*$search*"); } else { list($k, $v) = preg_split('/=/', $search); diff --git a/modules/monitoring/library/Monitoring/Web/Controller/MonitoredObjectController.php b/modules/monitoring/library/Monitoring/Web/Controller/MonitoredObjectController.php index cd2ed175f..d12bc7712 100644 --- a/modules/monitoring/library/Monitoring/Web/Controller/MonitoredObjectController.php +++ b/modules/monitoring/library/Monitoring/Web/Controller/MonitoredObjectController.php @@ -142,7 +142,6 @@ abstract class MonitoredObjectController extends Controller public function deleteCommentAction() { $this->assertHttpMethod('POST'); - $this->assertPermission('monitoring/command/comment/delete'); $this->handleCommandForm(new DeleteCommentCommandForm()); } From 2fe3f4c6c24c8fb9f369177897c2923bb253b487 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Tue, 3 Feb 2015 16:52:36 +0100 Subject: [PATCH 0538/2920] doc: Add "Upgrading to Icinga Web 2 Beta 2" --- doc/installation.md | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/doc/installation.md b/doc/installation.md index 170199832..e506b921b 100644 --- a/doc/installation.md +++ b/doc/installation.md @@ -108,3 +108,16 @@ In case you do not remember the token you can show it using the `icingacli`: **Step 5: Web Setup** Visit Icinga Web 2 in your browser and complete installation using the web setup: /icingaweb2/setup + +## Upgrading to Icinga Web 2 Beta 2 + +Icinga Web 2 Beta 2 introduces access control based on roles for secured actions. If you've already set up Icinga Web 2, +you are required to create the file **roles.ini** beneath Icinga Web 2's configuration directory with the following +content: +```` +[administrators] +users = "your_user_name, another_user_name" +permissions = "*" +```` + +After please log out from Icinga Web 2 and log in again for having all permissions granted. From ed411ec9b6cc9dc9b3f8ece62c7ff56b187444fd Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Tue, 3 Feb 2015 16:58:53 +0100 Subject: [PATCH 0539/2920] Increase size of the permissions set input fixes #7762 --- application/forms/Security/RoleForm.php | 3 ++- public/css/icinga/forms.less | 5 +++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/application/forms/Security/RoleForm.php b/application/forms/Security/RoleForm.php index 0e3c97c0a..caf3fb872 100644 --- a/application/forms/Security/RoleForm.php +++ b/application/forms/Security/RoleForm.php @@ -108,7 +108,8 @@ class RoleForm extends ConfigForm 'description' => $this->translate( 'The permissions to grant. You may select more than one permission' ), - 'multiOptions' => $this->providedPermissions + 'multiOptions' => $this->providedPermissions, + 'class' => 'grant-permissions' ) ) )); diff --git a/public/css/icinga/forms.less b/public/css/icinga/forms.less index 172536856..874ecfecc 100644 --- a/public/css/icinga/forms.less +++ b/public/css/icinga/forms.less @@ -220,3 +220,8 @@ form label.has-feedback:after { /* Uncomment for 3D effect */ /* text-shadow: 1px 1px 1px rgba(127, 127, 127, 0.3); */ } + +select.grant-permissions { + height: 20em; + width: auto; +} From 38ad802bd522f9445825dc4bddcc2d49e5a4c27d Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Tue, 3 Feb 2015 17:01:04 +0100 Subject: [PATCH 0540/2920] Bump version to v2.0.0-beta2 --- VERSION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VERSION b/VERSION index 71282c063..2f8540190 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -v2.0.0-beta1 +v2.0.0-beta2 From 2f254851e3fe4fbddd3047740f525955183a8617 Mon Sep 17 00:00:00 2001 From: Matthias Jentsch Date: Tue, 3 Feb 2015 17:33:30 +0100 Subject: [PATCH 0541/2920] Fix pieChart layout and add indicator for truncated piecharts --- .../monitoring/application/views/helpers/Perfdata.php | 5 +++++ .../application/views/scripts/list/services.phtml | 2 +- public/css/icinga/monitoring-colors.less | 9 --------- public/css/icinga/widgets.less | 5 ++++- public/js/icinga/behavior/sparkline.js | 2 +- 5 files changed, 11 insertions(+), 12 deletions(-) diff --git a/modules/monitoring/application/views/helpers/Perfdata.php b/modules/monitoring/application/views/helpers/Perfdata.php index 8e79fceeb..930a4e61e 100644 --- a/modules/monitoring/application/views/helpers/Perfdata.php +++ b/modules/monitoring/application/views/helpers/Perfdata.php @@ -57,8 +57,13 @@ class Zend_View_Helper_Perfdata extends Zend_View_Helper_Abstract } if ($limit > 0) { + $count = max (count($table), count ($results)); $table = array_slice ($table, 0, $limit); $results = array_slice ($results, 0, $limit); + if ($count > $limit) { + $mess = sprintf(t('%d more ...'), $count - $limit); + $results[] = '...'; + } } if ($compact) { diff --git a/modules/monitoring/application/views/scripts/list/services.phtml b/modules/monitoring/application/views/scripts/list/services.phtml index f7bbffe57..4cb073fc3 100644 --- a/modules/monitoring/application/views/scripts/list/services.phtml +++ b/modules/monitoring/application/views/scripts/list/services.phtml @@ -65,7 +65,7 @@ foreach ($services as $service):
    -
    perfdata($service->service_perfdata, true, 8) ?>
    +
    perfdata($service->service_perfdata, true, 8) ?>
    service_handled && $service->service_state > 0): ?> icon('attention-alt', $this->translate('Unhandled')) ?> diff --git a/public/css/icinga/monitoring-colors.less b/public/css/icinga/monitoring-colors.less index c7a24ed5f..0b365e503 100644 --- a/public/css/icinga/monitoring-colors.less +++ b/public/css/icinga/monitoring-colors.less @@ -64,15 +64,6 @@ table.action td a:hover { text-decoration: underline; } -table.action span.sparkline, table.action img.inlinepie { - margin: 0.5em 0.25em 0.5em 0.25em; - float:right; -} - -.dashboard table.action span.sparkline, .dashboard table.action img.inlinepie { - margin: 0em 0.25em 0em 0.25em; -} - /* END of Action table */ diff --git a/public/css/icinga/widgets.less b/public/css/icinga/widgets.less index 6263a6f0b..cfe5bb6e1 100644 --- a/public/css/icinga/widgets.less +++ b/public/css/icinga/widgets.less @@ -287,7 +287,8 @@ li li .badge { .sparkline-box { position: relative; - top: -9px; + top: -3px; + float: right; } .dashboard .sparkline-box { @@ -299,4 +300,6 @@ li li .badge { height: 12px; position: relative; top: 4px; + + margin: 0em 0em 0em 0.1em; } diff --git a/public/js/icinga/behavior/sparkline.js b/public/js/icinga/behavior/sparkline.js index 4a5cbefd5..44bac4fb9 100644 --- a/public/js/icinga/behavior/sparkline.js +++ b/public/js/icinga/behavior/sparkline.js @@ -15,7 +15,7 @@ Sparkline.prototype.onRendered = function(evt) { var el = evt.target; - $('span.sparkline', el).each(function(i, element) { + $('.sparkline', el).each(function(i, element) { // read custom options var $spark = $(element); var title = $spark.attr('title'); From 5b5ad0acb93b5dbb48f5832a21a56dc77de6b3d1 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Tue, 3 Feb 2015 17:36:16 +0100 Subject: [PATCH 0542/2920] monitoring/security: Add missing permission checks of command actions --- .../application/controllers/HostsController.php | 8 ++++++++ .../application/controllers/ServicesController.php | 8 ++++++++ .../Web/Controller/MonitoredObjectController.php | 1 + 3 files changed, 17 insertions(+) diff --git a/modules/monitoring/application/controllers/HostsController.php b/modules/monitoring/application/controllers/HostsController.php index 862ba529f..79db43ea6 100644 --- a/modules/monitoring/application/controllers/HostsController.php +++ b/modules/monitoring/application/controllers/HostsController.php @@ -169,6 +169,8 @@ class Monitoring_HostsController extends Controller */ public function acknowledgeProblemAction() { + $this->assertPermission('monitoring/command/acknowledge-problem'); + $this->view->title = $this->translate('Acknowledge Host Problems'); $this->handleCommandForm(new AcknowledgeProblemCommandForm()); } @@ -178,6 +180,8 @@ class Monitoring_HostsController extends Controller */ public function rescheduleCheckAction() { + $this->assertPermission('monitoring/command/schedule-check'); + $this->view->title = $this->translate('Reschedule Host Checks'); $this->handleCommandForm(new ScheduleHostCheckCommandForm()); } @@ -187,6 +191,8 @@ class Monitoring_HostsController extends Controller */ public function scheduleDowntimeAction() { + $this->assertPermission('monitoring/command/downtime/schedule'); + $this->view->title = $this->translate('Schedule Host Downtimes'); $this->handleCommandForm(new ScheduleHostDowntimeCommandForm()); } @@ -196,6 +202,8 @@ class Monitoring_HostsController extends Controller */ public function processCheckResultAction() { + $this->assertPermission('monitoring/command/process-check-result'); + $this->view->title = $this->translate('Submit Passive Host Check Results'); $this->handleCommandForm(new ProcessCheckResultCommandForm()); } diff --git a/modules/monitoring/application/controllers/ServicesController.php b/modules/monitoring/application/controllers/ServicesController.php index 600979eb6..a50c849fe 100644 --- a/modules/monitoring/application/controllers/ServicesController.php +++ b/modules/monitoring/application/controllers/ServicesController.php @@ -218,6 +218,8 @@ class Monitoring_ServicesController extends Controller */ public function acknowledgeProblemAction() { + $this->assertPermission('monitoring/command/acknowledge-problem'); + $this->view->title = $this->translate('Acknowledge Service Problems'); $this->handleCommandForm(new AcknowledgeProblemCommandForm()); } @@ -227,6 +229,8 @@ class Monitoring_ServicesController extends Controller */ public function rescheduleCheckAction() { + $this->assertPermission('monitoring/command/schedule-check'); + $this->view->title = $this->translate('Reschedule Service Checks'); $this->handleCommandForm(new ScheduleServiceCheckCommandForm()); } @@ -236,6 +240,8 @@ class Monitoring_ServicesController extends Controller */ public function scheduleDowntimeAction() { + $this->assertPermission('monitoring/command/downtime/schedule'); + $this->view->title = $this->translate('Schedule Service Downtimes'); $this->handleCommandForm(new ScheduleServiceDowntimeCommandForm()); } @@ -245,6 +251,8 @@ class Monitoring_ServicesController extends Controller */ public function processCheckResultAction() { + $this->assertPermission('monitoring/command/process-check-result'); + $this->view->title = $this->translate('Submit Passive Service Check Results'); $this->handleCommandForm(new ProcessCheckResultCommandForm()); } diff --git a/modules/monitoring/library/Monitoring/Web/Controller/MonitoredObjectController.php b/modules/monitoring/library/Monitoring/Web/Controller/MonitoredObjectController.php index d12bc7712..cd2ed175f 100644 --- a/modules/monitoring/library/Monitoring/Web/Controller/MonitoredObjectController.php +++ b/modules/monitoring/library/Monitoring/Web/Controller/MonitoredObjectController.php @@ -142,6 +142,7 @@ abstract class MonitoredObjectController extends Controller public function deleteCommentAction() { $this->assertHttpMethod('POST'); + $this->assertPermission('monitoring/command/comment/delete'); $this->handleCommandForm(new DeleteCommentCommandForm()); } From 3b30821ee9f66431798d0ec59ff8befb3277b2cb Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Wed, 4 Feb 2015 09:22:27 +0100 Subject: [PATCH 0543/2920] doc: Note that external replaced autologin and not storing preferences means none --- doc/installation.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/doc/installation.md b/doc/installation.md index e506b921b..aa6968e26 100644 --- a/doc/installation.md +++ b/doc/installation.md @@ -121,3 +121,7 @@ permissions = "*" ```` After please log out from Icinga Web 2 and log in again for having all permissions granted. + +If you delegated authentication to your web server using the `autologin` backend, you have to switch to the `external` +authentication backend to be able to log in again. The new name better reflects what’s going on. A similar change +affects environments that opted for not storing preferences, your new backend is `none`. From ef754140666be828436fd0d7ef3afbefa940ff45 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Wed, 4 Feb 2015 09:41:36 +0100 Subject: [PATCH 0544/2920] rpm: Bump revision to 2.rc1 --- icingaweb2.spec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/icingaweb2.spec b/icingaweb2.spec index 9dfe5d0df..c69cbca6c 100644 --- a/icingaweb2.spec +++ b/icingaweb2.spec @@ -1,6 +1,6 @@ # Icinga Web 2 | (c) 2013-2015 Icinga Development Team | http://www.gnu.org/licenses/gpl-2.0.txt -%define revision 1.beta2 +%define revision 2.rc1 Name: icingaweb2 Version: 2.0.0 From 5f624e42fd6ffe9df9a1da8e2510cec9a66c091c Mon Sep 17 00:00:00 2001 From: Marcus Cobden Date: Tue, 3 Feb 2015 13:47:56 +0000 Subject: [PATCH 0545/2920] Fix minor mistakes in Ldap/Connection Signed-off-by: Eric Lippmann --- library/Icinga/Protocol/Ldap/Connection.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/library/Icinga/Protocol/Ldap/Connection.php b/library/Icinga/Protocol/Ldap/Connection.php index 6d23854d0..f10cd670e 100644 --- a/library/Icinga/Protocol/Ldap/Connection.php +++ b/library/Icinga/Protocol/Ldap/Connection.php @@ -375,7 +375,7 @@ class Connection throw new LdapException( sprintf( 'LDAP query "%s" (root %s) failed: %s', - $query, + $query->create(), $this->root_dn, ldap_error($this->ds) ) @@ -478,7 +478,7 @@ class Connection throw new LdapException( sprintf( 'TLS is required but not announced by %s', - $this->host_name + $this->hostname ) ); } else { From 75f65593e6f854d4b4759093cfe4252b8e70cf0f Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Wed, 4 Feb 2015 09:45:40 +0100 Subject: [PATCH 0546/2920] Add Marcus Cobden to the AUTHORS file --- AUTHORS | 1 + 1 file changed, 1 insertion(+) diff --git a/AUTHORS b/AUTHORS index c225db6f6..7a6d660d6 100644 --- a/AUTHORS +++ b/AUTHORS @@ -10,6 +10,7 @@ Gunnar Beutner Jannis Moßhammer Johannes Meyer Marius Hein +Marcus Cobden Markus Frosch Matthias Jentsch Michael Friedrich From 8f9e970360a9efce5e231ab3827406d08c8ec901 Mon Sep 17 00:00:00 2001 From: Matthias Jentsch Date: Wed, 4 Feb 2015 09:53:20 +0100 Subject: [PATCH 0547/2920] Ignore negative values in reaction time Negative values for reaction time make no sense in the reaction time chart. When the notification was acknowledged before it startet we assume a reaction time of 0. fixes #8198 --- .../application/controllers/AlertsummaryController.php | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/modules/monitoring/application/controllers/AlertsummaryController.php b/modules/monitoring/application/controllers/AlertsummaryController.php index 4d711ade9..2ff909cb8 100644 --- a/modules/monitoring/application/controllers/AlertsummaryController.php +++ b/modules/monitoring/application/controllers/AlertsummaryController.php @@ -400,6 +400,15 @@ class Monitoring_AlertsummaryController extends Controller $recover = 0; if ($item->acknowledgement_entry_time) { $recover = $item->acknowledgement_entry_time - $item->notification_start_time; + + /* + * Acknowledgements may happen before the actual notification starts, since notifications + * can be configured to start a certain time after the problem. In that case we assume + * a reaction time of 0s. + */ + if ($recover < 0) { + $recover = 0; + } } $rData[$item->notification_object_id] = array( 'id' => $id, From 12497749fcb983618f93cf1610950b20bbe9f00c Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Wed, 4 Feb 2015 10:50:17 +0100 Subject: [PATCH 0548/2920] Do not log when using a limited query for a paged search operation --- library/Icinga/Protocol/Ldap/Connection.php | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/library/Icinga/Protocol/Ldap/Connection.php b/library/Icinga/Protocol/Ldap/Connection.php index f10cd670e..0f3bde998 100644 --- a/library/Icinga/Protocol/Ldap/Connection.php +++ b/library/Icinga/Protocol/Ldap/Connection.php @@ -30,7 +30,8 @@ use Icinga\Data\ConfigObject; */ class Connection { - const LDAP_NO_SUCH_OBJECT = 0x20; + const LDAP_NO_SUCH_OBJECT = 32; + const LDAP_SIZELIMIT_EXCEEDED = 4; protected $ds; protected $hostname; @@ -329,10 +330,12 @@ class Connection ldap_control_paged_result_response($this->ds, $this->lastResult, $this->pageCookie); } catch (Exception $e) { $this->pageCookie = ''; - Logger::debug( - 'Unable to request paged LDAP results. Does the server allow paged search requests? (%s)', - $e->getMessage() - ); + if (! $query->hasLimit() || ldap_errno($this->ds) !== static::LDAP_SIZELIMIT_EXCEEDED) { + Logger::error( + 'Unable to request paged LDAP results. Does the server allow paged search requests? (%s)', + $e->getMessage() + ); + } } ldap_free_result($this->lastResult); From 6bae2e0a5346d7533a497bb090500f4b44461722 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Wed, 4 Feb 2015 10:46:36 +0100 Subject: [PATCH 0549/2920] Note that our license is GPL v2 or any later version in our license header instead of pointing to the license's URL --- Vagrantfile | 2 +- application/clicommands/AutocompleteCommand.php | 2 +- application/clicommands/HelpCommand.php | 2 +- application/clicommands/ModuleCommand.php | 2 +- application/clicommands/WebCommand.php | 2 +- application/controllers/AuthenticationController.php | 2 +- application/controllers/ConfigController.php | 2 +- application/controllers/DashboardController.php | 2 +- application/controllers/ErrorController.php | 2 +- application/controllers/FilterController.php | 2 +- application/controllers/IndexController.php | 2 +- application/controllers/LayoutController.php | 2 +- application/controllers/ListController.php | 2 +- application/controllers/PreferenceController.php | 2 +- application/controllers/RolesController.php | 2 +- application/controllers/SearchController.php | 2 +- application/controllers/StaticController.php | 2 +- application/forms/Authentication/LoginForm.php | 2 +- application/forms/Config/Authentication/DbBackendForm.php | 2 +- application/forms/Config/Authentication/ExternalBackendForm.php | 2 +- application/forms/Config/Authentication/LdapBackendForm.php | 2 +- application/forms/Config/AuthenticationBackendConfigForm.php | 2 +- application/forms/Config/AuthenticationBackendReorderForm.php | 2 +- application/forms/Config/General/ApplicationConfigForm.php | 2 +- application/forms/Config/General/LoggingConfigForm.php | 2 +- application/forms/Config/GeneralConfigForm.php | 2 +- application/forms/Config/Resource/DbResourceForm.php | 2 +- application/forms/Config/Resource/FileResourceForm.php | 2 +- application/forms/Config/Resource/LdapResourceForm.php | 2 +- application/forms/Config/Resource/LivestatusResourceForm.php | 2 +- application/forms/Config/ResourceConfigForm.php | 2 +- application/forms/ConfigForm.php | 2 +- application/forms/ConfirmRemovalForm.php | 2 +- application/forms/Dashboard/DashletForm.php | 2 +- application/forms/LdapDiscoveryForm.php | 2 +- application/forms/PreferenceForm.php | 2 +- application/forms/Security/RoleForm.php | 2 +- application/views/helpers/DateFormat.php | 2 +- application/views/helpers/FormDateTime.php | 2 +- application/views/helpers/FormNumber.php | 2 +- application/views/helpers/FormTriStateCheckbox.php | 2 +- application/views/helpers/Util.php | 2 +- bin/icingacli | 2 +- bin/license_writer.py | 2 +- etc/schema/mysql.schema.sql | 2 +- etc/schema/pgsql.schema.sql | 2 +- icingaweb2.spec | 2 +- library/Icinga/Application/ApplicationBootstrap.php | 2 +- library/Icinga/Application/Benchmark.php | 2 +- library/Icinga/Application/Cli.php | 2 +- library/Icinga/Application/Config.php | 2 +- library/Icinga/Application/EmbeddedWeb.php | 2 +- library/Icinga/Application/Icinga.php | 2 +- library/Icinga/Application/LegacyWeb.php | 2 +- library/Icinga/Application/Loader.php | 2 +- library/Icinga/Application/Logger.php | 2 +- library/Icinga/Application/Logger/LogWriter.php | 2 +- library/Icinga/Application/Logger/Writer/FileWriter.php | 2 +- library/Icinga/Application/Logger/Writer/StdoutWriter.php | 2 +- library/Icinga/Application/Logger/Writer/SyslogWriter.php | 2 +- library/Icinga/Application/Modules/Manager.php | 2 +- library/Icinga/Application/Modules/Module.php | 2 +- library/Icinga/Application/Platform.php | 2 +- library/Icinga/Application/Web.php | 2 +- library/Icinga/Application/functions.php | 2 +- library/Icinga/Application/webrouter.php | 2 +- library/Icinga/Authentication/AdmissionLoader.php | 2 +- library/Icinga/Authentication/AuthChain.php | 2 +- library/Icinga/Authentication/Backend/DbUserBackend.php | 2 +- library/Icinga/Authentication/Backend/DbUserGroupBackend.php | 2 +- library/Icinga/Authentication/Backend/ExternalBackend.php | 2 +- library/Icinga/Authentication/Backend/IniUserGroupBackend.php | 2 +- library/Icinga/Authentication/Backend/LdapUserBackend.php | 2 +- library/Icinga/Authentication/Manager.php | 2 +- library/Icinga/Authentication/UserBackend.php | 2 +- library/Icinga/Authentication/UserGroupBackend.php | 2 +- library/Icinga/Chart/Axis.php | 2 +- library/Icinga/Chart/Chart.php | 2 +- library/Icinga/Chart/Format.php | 2 +- library/Icinga/Chart/Graph/BarGraph.php | 2 +- library/Icinga/Chart/Graph/LineGraph.php | 2 +- library/Icinga/Chart/Graph/StackedGraph.php | 2 +- library/Icinga/Chart/Graph/Tooltip.php | 2 +- library/Icinga/Chart/GridChart.php | 2 +- library/Icinga/Chart/Inline/Inline.php | 2 +- library/Icinga/Chart/Inline/PieChart.php | 2 +- library/Icinga/Chart/Legend.php | 2 +- library/Icinga/Chart/Palette.php | 2 +- library/Icinga/Chart/PieChart.php | 2 +- library/Icinga/Chart/Primitive/Animatable.php | 2 +- library/Icinga/Chart/Primitive/Animation.php | 2 +- library/Icinga/Chart/Primitive/Canvas.php | 2 +- library/Icinga/Chart/Primitive/Circle.php | 2 +- library/Icinga/Chart/Primitive/Drawable.php | 2 +- library/Icinga/Chart/Primitive/Line.php | 2 +- library/Icinga/Chart/Primitive/Path.php | 2 +- library/Icinga/Chart/Primitive/PieSlice.php | 2 +- library/Icinga/Chart/Primitive/RawElement.php | 2 +- library/Icinga/Chart/Primitive/Rect.php | 2 +- library/Icinga/Chart/Primitive/Styleable.php | 2 +- library/Icinga/Chart/Primitive/Text.php | 2 +- library/Icinga/Chart/Render/LayoutBox.php | 2 +- library/Icinga/Chart/Render/RenderContext.php | 2 +- library/Icinga/Chart/Render/Rotator.php | 2 +- library/Icinga/Chart/SVGRenderer.php | 2 +- library/Icinga/Chart/Unit/AxisUnit.php | 2 +- library/Icinga/Chart/Unit/CalendarUnit.php | 2 +- library/Icinga/Chart/Unit/LinearUnit.php | 2 +- library/Icinga/Chart/Unit/LogarithmicUnit.php | 2 +- library/Icinga/Chart/Unit/StaticAxis.php | 2 +- library/Icinga/Cli/AnsiScreen.php | 2 +- library/Icinga/Cli/Command.php | 2 +- library/Icinga/Cli/Documentation.php | 2 +- library/Icinga/Cli/Documentation/CommentParser.php | 2 +- library/Icinga/Cli/Loader.php | 2 +- library/Icinga/Cli/Params.php | 2 +- library/Icinga/Cli/Screen.php | 2 +- library/Icinga/Data/Browsable.php | 2 +- library/Icinga/Data/ConfigObject.php | 2 +- library/Icinga/Data/ConnectionInterface.php | 2 +- library/Icinga/Data/DataArray/ArrayDatasource.php | 2 +- library/Icinga/Data/Db/DbConnection.php | 2 +- library/Icinga/Data/Db/DbQuery.php | 2 +- library/Icinga/Data/Fetchable.php | 2 +- library/Icinga/Data/Filter/Filter.php | 2 +- library/Icinga/Data/Filter/FilterAnd.php | 2 +- library/Icinga/Data/Filter/FilterChain.php | 2 +- library/Icinga/Data/Filter/FilterEqual.php | 2 +- library/Icinga/Data/Filter/FilterEqualOrGreaterThan.php | 2 +- library/Icinga/Data/Filter/FilterEqualOrLessThan.php | 2 +- library/Icinga/Data/Filter/FilterException.php | 2 +- library/Icinga/Data/Filter/FilterExpression.php | 2 +- library/Icinga/Data/Filter/FilterGreaterThan.php | 2 +- library/Icinga/Data/Filter/FilterLessThan.php | 2 +- library/Icinga/Data/Filter/FilterMatch.php | 2 +- library/Icinga/Data/Filter/FilterMatchNot.php | 2 +- library/Icinga/Data/Filter/FilterNot.php | 2 +- library/Icinga/Data/Filter/FilterNotEqual.php | 2 +- library/Icinga/Data/Filter/FilterOr.php | 2 +- library/Icinga/Data/Filter/FilterParseException.php | 2 +- library/Icinga/Data/Filter/FilterQueryString.php | 2 +- library/Icinga/Data/Filterable.php | 2 +- library/Icinga/Data/Identifiable.php | 2 +- library/Icinga/Data/Limitable.php | 2 +- library/Icinga/Data/PivotTable.php | 2 +- library/Icinga/Data/QueryInterface.php | 2 +- library/Icinga/Data/Queryable.php | 2 +- library/Icinga/Data/ResourceFactory.php | 2 +- library/Icinga/Data/Selectable.php | 2 +- library/Icinga/Data/SimpleQuery.php | 2 +- library/Icinga/Data/Sortable.php | 2 +- library/Icinga/Data/Tree/Node.php | 2 +- library/Icinga/Data/Tree/NodeInterface.php | 2 +- library/Icinga/Exception/AuthenticationException.php | 2 +- library/Icinga/Exception/ConfigurationError.php | 2 +- library/Icinga/Exception/IcingaException.php | 2 +- library/Icinga/Exception/InvalidPropertyException.php | 2 +- library/Icinga/Exception/MissingParameterException.php | 2 +- library/Icinga/Exception/NotFoundError.php | 2 +- library/Icinga/Exception/NotImplementedError.php | 2 +- library/Icinga/Exception/NotReadableError.php | 2 +- library/Icinga/Exception/NotWritableError.php | 2 +- library/Icinga/Exception/ProgrammingError.php | 2 +- library/Icinga/Exception/QueryException.php | 2 +- library/Icinga/Exception/SystemPermissionException.php | 2 +- library/Icinga/File/Csv.php | 2 +- library/Icinga/File/FileExtensionFilterIterator.php | 2 +- library/Icinga/File/Ini/IniEditor.php | 2 +- library/Icinga/File/Ini/IniWriter.php | 2 +- library/Icinga/File/NonEmptyFileIterator.php | 2 +- library/Icinga/File/Pdf.php | 2 +- library/Icinga/Protocol/Dns.php | 2 +- library/Icinga/Protocol/File/Exception/FileReaderException.php | 2 +- library/Icinga/Protocol/File/FileIterator.php | 2 +- library/Icinga/Protocol/File/FileQuery.php | 2 +- library/Icinga/Protocol/File/FileReader.php | 2 +- library/Icinga/Protocol/Ldap/Connection.php | 2 +- library/Icinga/Protocol/Ldap/Discovery.php | 2 +- library/Icinga/Protocol/Ldap/Exception.php | 2 +- library/Icinga/Protocol/Ldap/LdapUtils.php | 2 +- library/Icinga/Protocol/Ldap/Node.php | 2 +- library/Icinga/Protocol/Ldap/Query.php | 2 +- library/Icinga/Protocol/Ldap/Root.php | 2 +- library/Icinga/Protocol/Livestatus/Connection.php | 2 +- library/Icinga/Protocol/Livestatus/Query.php | 2 +- library/Icinga/Protocol/Livestatus/ResponseRow.php | 2 +- library/Icinga/Protocol/Nrpe/Connection.php | 2 +- library/Icinga/Protocol/Nrpe/Packet.php | 2 +- library/Icinga/Security/SecurityException.php | 2 +- library/Icinga/Test/BaseTestCase.php | 2 +- library/Icinga/Test/DbTest.php | 2 +- library/Icinga/User.php | 2 +- library/Icinga/User/Preferences.php | 2 +- library/Icinga/User/Preferences/PreferencesStore.php | 2 +- library/Icinga/User/Preferences/Store/DbStore.php | 2 +- library/Icinga/User/Preferences/Store/IniStore.php | 2 +- library/Icinga/Util/Color.php | 2 +- library/Icinga/Util/ConfigAwareFactory.php | 2 +- library/Icinga/Util/DateTimeFactory.php | 2 +- library/Icinga/Util/Dimension.php | 2 +- library/Icinga/Util/EnumeratingFilterIterator.php | 2 +- library/Icinga/Util/File.php | 2 +- library/Icinga/Util/Format.php | 2 +- library/Icinga/Util/String.php | 2 +- library/Icinga/Util/TimezoneDetect.php | 2 +- library/Icinga/Util/Translator.php | 2 +- library/Icinga/Web/Controller.php | 2 +- library/Icinga/Web/Controller/ActionController.php | 2 +- library/Icinga/Web/Controller/BasePreferenceController.php | 2 +- library/Icinga/Web/Controller/ControllerTabCollector.php | 2 +- library/Icinga/Web/Controller/ModuleActionController.php | 2 +- library/Icinga/Web/FileCache.php | 2 +- library/Icinga/Web/Form.php | 2 +- library/Icinga/Web/Form/Decorator/ConditionalHidden.php | 2 +- library/Icinga/Web/Form/Decorator/ElementDoubler.php | 2 +- library/Icinga/Web/Form/Decorator/NoScriptApply.php | 2 +- library/Icinga/Web/Form/Element/Button.php | 2 +- library/Icinga/Web/Form/Element/CsrfCounterMeasure.php | 2 +- library/Icinga/Web/Form/Element/DateTimePicker.php | 2 +- library/Icinga/Web/Form/Element/Note.php | 2 +- library/Icinga/Web/Form/Element/Number.php | 2 +- library/Icinga/Web/Form/Element/TriStateCheckbox.php | 2 +- library/Icinga/Web/Form/FormElement.php | 2 +- library/Icinga/Web/Form/InvalidCSRFTokenException.php | 2 +- library/Icinga/Web/Form/Validator/DateFormatValidator.php | 2 +- library/Icinga/Web/Form/Validator/DateTimeValidator.php | 2 +- library/Icinga/Web/Form/Validator/ReadablePathValidator.php | 2 +- library/Icinga/Web/Form/Validator/TimeFormatValidator.php | 2 +- library/Icinga/Web/Form/Validator/TriStateValidator.php | 2 +- library/Icinga/Web/Form/Validator/WritablePathValidator.php | 2 +- library/Icinga/Web/Hook.php | 2 +- library/Icinga/Web/Hook/GrapherHook.php | 2 +- library/Icinga/Web/Hook/TicketHook.php | 2 +- library/Icinga/Web/Hook/WebBaseHook.php | 2 +- library/Icinga/Web/JavaScript.php | 2 +- library/Icinga/Web/LessCompiler.php | 2 +- library/Icinga/Web/Menu.php | 2 +- library/Icinga/Web/Menu/ForeignMenuItemRenderer.php | 2 +- library/Icinga/Web/Menu/MenuItemRenderer.php | 2 +- library/Icinga/Web/Menu/MonitoringMenuItemRenderer.php | 2 +- library/Icinga/Web/Menu/ProblemMenuItemRenderer.php | 2 +- library/Icinga/Web/Menu/UnhandledHostMenuItemRenderer.php | 2 +- library/Icinga/Web/Menu/UnhandledServiceMenuItemRenderer.php | 2 +- library/Icinga/Web/MenuRenderer.php | 2 +- library/Icinga/Web/Notification.php | 2 +- library/Icinga/Web/Paginator/Adapter/QueryAdapter.php | 2 +- .../Icinga/Web/Paginator/ScrollingStyle/SlidingWithBorder.php | 2 +- library/Icinga/Web/Request.php | 2 +- library/Icinga/Web/Response.php | 2 +- library/Icinga/Web/Session.php | 2 +- library/Icinga/Web/Session/PhpSession.php | 2 +- library/Icinga/Web/Session/Session.php | 2 +- library/Icinga/Web/Session/SessionNamespace.php | 2 +- library/Icinga/Web/StyleSheet.php | 2 +- library/Icinga/Web/Url.php | 2 +- library/Icinga/Web/UrlParams.php | 2 +- library/Icinga/Web/View.php | 2 +- library/Icinga/Web/View/DateTimeRenderer.php | 2 +- library/Icinga/Web/View/helpers/format.php | 2 +- library/Icinga/Web/View/helpers/generic.php | 2 +- library/Icinga/Web/View/helpers/url.php | 2 +- library/Icinga/Web/ViewStream.php | 2 +- library/Icinga/Web/Widget.php | 2 +- library/Icinga/Web/Widget/AbstractWidget.php | 2 +- library/Icinga/Web/Widget/Chart/HistoryColorGrid.php | 2 +- library/Icinga/Web/Widget/Chart/InlinePie.php | 2 +- library/Icinga/Web/Widget/Dashboard.php | 2 +- library/Icinga/Web/Widget/Dashboard/Dashlet.php | 2 +- library/Icinga/Web/Widget/Dashboard/Pane.php | 2 +- library/Icinga/Web/Widget/Dashboard/UserWidget.php | 2 +- library/Icinga/Web/Widget/FilterEditor.php | 2 +- library/Icinga/Web/Widget/FilterWidget.php | 2 +- library/Icinga/Web/Widget/Limiter.php | 2 +- library/Icinga/Web/Widget/SearchDashboard.php | 2 +- library/Icinga/Web/Widget/SortBox.php | 2 +- library/Icinga/Web/Widget/Tab.php | 2 +- library/Icinga/Web/Widget/Tabextension/BasketAction.php | 2 +- library/Icinga/Web/Widget/Tabextension/DashboardAction.php | 2 +- library/Icinga/Web/Widget/Tabextension/DashboardSettings.php | 2 +- library/Icinga/Web/Widget/Tabextension/OutputFormat.php | 2 +- library/Icinga/Web/Widget/Tabextension/Tabextension.php | 2 +- library/Icinga/Web/Widget/Tabs.php | 2 +- library/Icinga/Web/Widget/Widget.php | 2 +- library/Icinga/Web/Window.php | 2 +- library/Icinga/Web/Wizard.php | 2 +- modules/doc/application/controllers/IcingawebController.php | 2 +- modules/doc/application/controllers/IndexController.php | 2 +- modules/doc/application/controllers/ModuleController.php | 2 +- modules/doc/application/controllers/StyleController.php | 2 +- modules/doc/configuration.php | 2 +- modules/doc/library/Doc/DocController.php | 2 +- modules/doc/library/Doc/DocIterator.php | 2 +- modules/doc/library/Doc/DocParser.php | 2 +- modules/doc/library/Doc/DocTree.php | 2 +- modules/doc/library/Doc/Exception/ChapterNotFoundException.php | 2 +- modules/doc/library/Doc/Exception/DocEmptyException.php | 2 +- modules/doc/library/Doc/Exception/DocException.php | 2 +- modules/doc/library/Doc/Renderer.php | 2 +- modules/doc/library/Doc/Section.php | 2 +- modules/doc/library/Doc/SectionFilterIterator.php | 2 +- modules/doc/library/Doc/SectionRenderer.php | 2 +- modules/doc/library/Doc/TocRenderer.php | 2 +- modules/doc/public/css/module.less | 2 +- modules/doc/run.php | 2 +- .../monitoring/application/clicommands/ConferenceCommand.php | 2 +- modules/monitoring/application/clicommands/ListCommand.php | 2 +- modules/monitoring/application/clicommands/NrpeCommand.php | 2 +- .../application/controllers/AlertsummaryController.php | 2 +- modules/monitoring/application/controllers/ChartController.php | 2 +- modules/monitoring/application/controllers/ConfigController.php | 2 +- modules/monitoring/application/controllers/HostController.php | 2 +- modules/monitoring/application/controllers/HostsController.php | 2 +- modules/monitoring/application/controllers/ListController.php | 2 +- .../monitoring/application/controllers/ProcessController.php | 2 +- .../monitoring/application/controllers/ServiceController.php | 2 +- .../monitoring/application/controllers/ServicesController.php | 2 +- modules/monitoring/application/controllers/ShowController.php | 2 +- .../monitoring/application/controllers/TacticalController.php | 2 +- .../monitoring/application/controllers/TimelineController.php | 2 +- modules/monitoring/application/forms/Command/CommandForm.php | 2 +- .../Command/Instance/DisableNotificationsExpireCommandForm.php | 2 +- .../Command/Instance/ToggleInstanceFeaturesCommandForm.php | 2 +- .../forms/Command/Object/AcknowledgeProblemCommandForm.php | 2 +- .../application/forms/Command/Object/AddCommentCommandForm.php | 2 +- .../application/forms/Command/Object/CheckNowCommandForm.php | 2 +- .../forms/Command/Object/DeleteCommentCommandForm.php | 2 +- .../forms/Command/Object/DeleteDowntimeCommandForm.php | 2 +- .../application/forms/Command/Object/ObjectsCommandForm.php | 2 +- .../forms/Command/Object/ProcessCheckResultCommandForm.php | 2 +- .../forms/Command/Object/RemoveAcknowledgementCommandForm.php | 2 +- .../forms/Command/Object/ScheduleHostCheckCommandForm.php | 2 +- .../forms/Command/Object/ScheduleHostDowntimeCommandForm.php | 2 +- .../forms/Command/Object/ScheduleServiceCheckCommandForm.php | 2 +- .../forms/Command/Object/ScheduleServiceDowntimeCommandForm.php | 2 +- .../forms/Command/Object/ToggleObjectFeaturesCommandForm.php | 2 +- .../monitoring/application/forms/Config/BackendConfigForm.php | 2 +- .../application/forms/Config/Instance/LocalInstanceForm.php | 2 +- .../application/forms/Config/Instance/RemoteInstanceForm.php | 2 +- .../monitoring/application/forms/Config/InstanceConfigForm.php | 2 +- .../monitoring/application/forms/Config/SecurityConfigForm.php | 2 +- modules/monitoring/application/forms/EventOverviewForm.php | 2 +- modules/monitoring/application/forms/Setup/BackendPage.php | 2 +- modules/monitoring/application/forms/Setup/IdoResourcePage.php | 2 +- modules/monitoring/application/forms/Setup/InstancePage.php | 2 +- .../application/forms/Setup/LivestatusResourcePage.php | 2 +- modules/monitoring/application/forms/Setup/SecurityPage.php | 2 +- modules/monitoring/application/forms/Setup/WelcomePage.php | 2 +- modules/monitoring/application/forms/StatehistoryForm.php | 2 +- .../monitoring/application/views/helpers/CheckPerformance.php | 2 +- modules/monitoring/application/views/helpers/ContactFlags.php | 2 +- modules/monitoring/application/views/helpers/Customvar.php | 2 +- modules/monitoring/application/views/helpers/Link.php | 2 +- .../monitoring/application/views/helpers/MonitoringFlags.php | 2 +- modules/monitoring/application/views/helpers/Perfdata.php | 2 +- modules/monitoring/application/views/helpers/PluginOutput.php | 2 +- modules/monitoring/application/views/helpers/ResolveMacros.php | 2 +- .../monitoring/application/views/helpers/RuntimeVariables.php | 2 +- .../monitoring/application/views/helpers/SelectionToolbar.php | 2 +- modules/monitoring/configuration.php | 2 +- modules/monitoring/library/Monitoring/Backend.php | 2 +- .../monitoring/library/Monitoring/Backend/Ido/IdoBackend.php | 2 +- .../library/Monitoring/Backend/Ido/Query/AllcontactsQuery.php | 2 +- .../library/Monitoring/Backend/Ido/Query/CommandQuery.php | 2 +- .../library/Monitoring/Backend/Ido/Query/CommentQuery.php | 2 +- .../Backend/Ido/Query/CommentdeletionhistoryQuery.php | 2 +- .../Monitoring/Backend/Ido/Query/CommenthistoryQuery.php | 2 +- .../library/Monitoring/Backend/Ido/Query/ContactQuery.php | 2 +- .../library/Monitoring/Backend/Ido/Query/ContactgroupQuery.php | 2 +- .../library/Monitoring/Backend/Ido/Query/CustomvarQuery.php | 2 +- .../library/Monitoring/Backend/Ido/Query/DowntimeQuery.php | 2 +- .../Monitoring/Backend/Ido/Query/DowntimeendhistoryQuery.php | 2 +- .../Monitoring/Backend/Ido/Query/DowntimestarthistoryQuery.php | 2 +- .../library/Monitoring/Backend/Ido/Query/EventHistoryQuery.php | 2 +- .../library/Monitoring/Backend/Ido/Query/EventgridQuery.php | 2 +- .../library/Monitoring/Backend/Ido/Query/GroupsummaryQuery.php | 2 +- .../library/Monitoring/Backend/Ido/Query/HostgroupQuery.php | 2 +- .../library/Monitoring/Backend/Ido/Query/HoststatusQuery.php | 2 +- .../library/Monitoring/Backend/Ido/Query/IdoQuery.php | 2 +- .../library/Monitoring/Backend/Ido/Query/NotificationQuery.php | 2 +- .../Monitoring/Backend/Ido/Query/NotificationhistoryQuery.php | 2 +- .../library/Monitoring/Backend/Ido/Query/ProgramstatusQuery.php | 2 +- .../Monitoring/Backend/Ido/Query/RuntimesummaryQuery.php | 2 +- .../Monitoring/Backend/Ido/Query/RuntimevariablesQuery.php | 2 +- .../library/Monitoring/Backend/Ido/Query/ServicegroupQuery.php | 2 +- .../library/Monitoring/Backend/Ido/Query/StatehistoryQuery.php | 2 +- .../library/Monitoring/Backend/Ido/Query/StatusQuery.php | 2 +- .../library/Monitoring/Backend/Ido/Query/StatusSummaryQuery.php | 2 +- .../library/Monitoring/Backend/Livestatus/LivestatusBackend.php | 2 +- .../Monitoring/Backend/Livestatus/Query/DowntimeQuery.php | 2 +- .../Monitoring/Backend/Livestatus/Query/HostgroupQuery.php | 2 +- .../Monitoring/Backend/Livestatus/Query/ServicegroupQuery.php | 2 +- .../library/Monitoring/Backend/Livestatus/Query/StatusQuery.php | 2 +- .../Monitoring/Backend/Livestatus/Query/StatusSummaryQuery.php | 2 +- .../monitoring/library/Monitoring/Backend/MonitoringBackend.php | 2 +- modules/monitoring/library/Monitoring/BackendStep.php | 2 +- modules/monitoring/library/Monitoring/Cli/CliUtils.php | 2 +- .../library/Monitoring/Command/Exception/TransportException.php | 2 +- modules/monitoring/library/Monitoring/Command/IcingaCommand.php | 2 +- .../Command/Instance/DisableNotificationsExpireCommand.php | 2 +- .../Command/Instance/ToggleInstanceFeatureCommand.php | 2 +- .../Monitoring/Command/Object/AcknowledgeProblemCommand.php | 2 +- .../library/Monitoring/Command/Object/AddCommentCommand.php | 2 +- .../library/Monitoring/Command/Object/DeleteCommentCommand.php | 2 +- .../library/Monitoring/Command/Object/DeleteDowntimeCommand.php | 2 +- .../library/Monitoring/Command/Object/ObjectCommand.php | 2 +- .../Monitoring/Command/Object/ProcessCheckResultCommand.php | 2 +- .../Monitoring/Command/Object/PropagateHostDowntimeCommand.php | 2 +- .../Monitoring/Command/Object/RemoveAcknowledgementCommand.php | 2 +- .../Monitoring/Command/Object/ScheduleHostCheckCommand.php | 2 +- .../Monitoring/Command/Object/ScheduleHostDowntimeCommand.php | 2 +- .../Monitoring/Command/Object/ScheduleServiceCheckCommand.php | 2 +- .../Command/Object/ScheduleServiceDowntimeCommand.php | 2 +- .../Monitoring/Command/Object/ToggleObjectFeatureCommand.php | 2 +- .../library/Monitoring/Command/Object/WithCommentCommand.php | 2 +- .../Command/Renderer/IcingaCommandFileCommandRenderer.php | 2 +- .../Command/Renderer/IcingaCommandRendererInterface.php | 2 +- .../library/Monitoring/Command/Transport/CommandTransport.php | 2 +- .../Monitoring/Command/Transport/CommandTransportInterface.php | 2 +- .../library/Monitoring/Command/Transport/LocalCommandFile.php | 2 +- .../library/Monitoring/Command/Transport/RemoteCommandFile.php | 2 +- modules/monitoring/library/Monitoring/Controller.php | 2 +- modules/monitoring/library/Monitoring/DataView/Command.php | 2 +- modules/monitoring/library/Monitoring/DataView/Comment.php | 2 +- modules/monitoring/library/Monitoring/DataView/Contact.php | 2 +- modules/monitoring/library/Monitoring/DataView/Contactgroup.php | 2 +- modules/monitoring/library/Monitoring/DataView/Customvar.php | 2 +- modules/monitoring/library/Monitoring/DataView/DataView.php | 2 +- modules/monitoring/library/Monitoring/DataView/Downtime.php | 2 +- modules/monitoring/library/Monitoring/DataView/EventHistory.php | 2 +- modules/monitoring/library/Monitoring/DataView/Eventgrid.php | 2 +- modules/monitoring/library/Monitoring/DataView/Groupsummary.php | 2 +- modules/monitoring/library/Monitoring/DataView/HostStatus.php | 2 +- modules/monitoring/library/Monitoring/DataView/Hostgroup.php | 2 +- modules/monitoring/library/Monitoring/DataView/Notification.php | 2 +- .../monitoring/library/Monitoring/DataView/Programstatus.php | 2 +- .../monitoring/library/Monitoring/DataView/Runtimesummary.php | 2 +- .../monitoring/library/Monitoring/DataView/Runtimevariables.php | 2 +- .../monitoring/library/Monitoring/DataView/ServiceStatus.php | 2 +- modules/monitoring/library/Monitoring/DataView/Servicegroup.php | 2 +- .../monitoring/library/Monitoring/DataView/StatusSummary.php | 2 +- modules/monitoring/library/Monitoring/Environment.php | 2 +- .../Monitoring/Exception/UnsupportedBackendException.php | 2 +- modules/monitoring/library/Monitoring/InstanceStep.php | 2 +- modules/monitoring/library/Monitoring/MonitoringWizard.php | 2 +- modules/monitoring/library/Monitoring/Object/Host.php | 2 +- modules/monitoring/library/Monitoring/Object/HostList.php | 2 +- .../monitoring/library/Monitoring/Object/MonitoredObject.php | 2 +- modules/monitoring/library/Monitoring/Object/ObjectList.php | 2 +- modules/monitoring/library/Monitoring/Object/Service.php | 2 +- modules/monitoring/library/Monitoring/Object/ServiceList.php | 2 +- modules/monitoring/library/Monitoring/Plugin.php | 2 +- modules/monitoring/library/Monitoring/Plugin/Perfdata.php | 2 +- modules/monitoring/library/Monitoring/Plugin/PerfdataSet.php | 2 +- modules/monitoring/library/Monitoring/SecurityStep.php | 2 +- modules/monitoring/library/Monitoring/Timeline/TimeEntry.php | 2 +- modules/monitoring/library/Monitoring/Timeline/TimeLine.php | 2 +- modules/monitoring/library/Monitoring/Timeline/TimeRange.php | 2 +- .../Monitoring/Web/Controller/MonitoredObjectController.php | 2 +- .../monitoring/library/Monitoring/Web/Hook/HostActionsHook.php | 2 +- .../library/Monitoring/Web/Hook/TimelineProviderHook.php | 2 +- modules/monitoring/library/Monitoring/Web/Widget/SelectBox.php | 2 +- modules/monitoring/public/css/module.less | 2 +- modules/monitoring/public/js/module.js | 2 +- .../test/php/application/views/helpers/MonitoringFlagsTest.php | 2 +- .../test/php/application/views/helpers/ResolveMacrosTest.php | 2 +- .../test/php/library/Monitoring/Plugin/PerfdataSetTest.php | 2 +- .../test/php/library/Monitoring/Plugin/PerfdataTest.php | 2 +- modules/monitoring/test/php/regression/Bug6088Test.php | 2 +- modules/monitoring/test/php/regression/Bug7043Test.php | 2 +- modules/setup/application/clicommands/ConfigCommand.php | 2 +- modules/setup/application/clicommands/TokenCommand.php | 2 +- modules/setup/application/controllers/IndexController.php | 2 +- modules/setup/application/forms/AdminAccountPage.php | 2 +- modules/setup/application/forms/AuthBackendPage.php | 2 +- modules/setup/application/forms/AuthenticationPage.php | 2 +- modules/setup/application/forms/DatabaseCreationPage.php | 2 +- modules/setup/application/forms/DbResourcePage.php | 2 +- modules/setup/application/forms/GeneralConfigPage.php | 2 +- modules/setup/application/forms/LdapDiscoveryConfirmPage.php | 2 +- modules/setup/application/forms/LdapDiscoveryPage.php | 2 +- modules/setup/application/forms/LdapResourcePage.php | 2 +- modules/setup/application/forms/ModulePage.php | 2 +- modules/setup/application/forms/PreferencesPage.php | 2 +- modules/setup/application/forms/RequirementsPage.php | 2 +- modules/setup/application/forms/SummaryPage.php | 2 +- modules/setup/application/forms/WelcomePage.php | 2 +- modules/setup/library/Setup/Exception/SetupException.php | 2 +- modules/setup/library/Setup/Requirements.php | 2 +- modules/setup/library/Setup/Setup.php | 2 +- modules/setup/library/Setup/SetupWizard.php | 2 +- modules/setup/library/Setup/Step.php | 2 +- modules/setup/library/Setup/Steps/AuthenticationStep.php | 2 +- modules/setup/library/Setup/Steps/DatabaseStep.php | 2 +- modules/setup/library/Setup/Steps/GeneralConfigStep.php | 2 +- modules/setup/library/Setup/Steps/ResourceStep.php | 2 +- modules/setup/library/Setup/Utils/DbTool.php | 2 +- modules/setup/library/Setup/Utils/EnableModuleStep.php | 2 +- modules/setup/library/Setup/Utils/MakeDirStep.php | 2 +- .../setup/library/Setup/Web/Form/Validator/TokenValidator.php | 2 +- modules/setup/library/Setup/WebWizard.php | 2 +- modules/setup/library/Setup/Webserver.php | 2 +- modules/setup/library/Setup/Webserver/Apache.php | 2 +- modules/setup/library/Setup/Webserver/Nginx.php | 2 +- modules/test/application/clicommands/PhpCommand.php | 2 +- modules/translation/application/clicommands/CompileCommand.php | 2 +- modules/translation/application/clicommands/RefreshCommand.php | 2 +- .../translation/library/Translation/Cli/TranslationCommand.php | 2 +- .../library/Translation/Util/GettextTranslationHelper.php | 2 +- packages/files/bin/icingacli | 2 +- packages/files/public/index.php | 2 +- public/css/icinga/defaults.less | 2 +- public/css/icinga/forms.less | 2 +- public/css/icinga/header-elements.less | 2 +- public/css/icinga/layout-colors.less | 2 +- public/css/icinga/layout-structure.less | 2 +- public/css/icinga/login.less | 2 +- public/css/icinga/main-content.less | 2 +- public/css/icinga/menu.less | 2 +- public/css/icinga/monitoring-colors.less | 2 +- public/css/icinga/pagination.less | 2 +- public/css/icinga/selection-toolbar.less | 2 +- public/css/icinga/setup.less | 2 +- public/css/icinga/tabs.less | 2 +- public/css/icinga/widgets.less | 2 +- public/css/pdf/pdfprint.less | 2 +- public/index.php | 2 +- public/js/helpers.js | 2 +- public/js/icinga.js | 2 +- public/js/icinga/behavior/form.js | 2 +- public/js/icinga/behavior/navigation.js | 2 +- public/js/icinga/behavior/sparkline.js | 2 +- public/js/icinga/behavior/tooltip.js | 2 +- public/js/icinga/behavior/tristate.js | 2 +- public/js/icinga/eventlistener.js | 2 +- public/js/icinga/events.js | 2 +- public/js/icinga/history.js | 2 +- public/js/icinga/loader.js | 2 +- public/js/icinga/logger.js | 2 +- public/js/icinga/module.js | 2 +- public/js/icinga/timer.js | 2 +- public/js/icinga/timezone.js | 2 +- public/js/icinga/ui.js | 2 +- public/js/icinga/utils.js | 2 +- .../forms/Config/Authentication/DbBackendFormTest.php | 2 +- .../forms/Config/Authentication/LdapBackendFormTest.php | 2 +- .../forms/Config/AuthenticationBackendReorderFormTest.php | 2 +- .../application/forms/Config/Resource/DbResourceFormTest.php | 2 +- .../application/forms/Config/Resource/LdapResourceFormTest.php | 2 +- .../forms/Config/Resource/LivestatusResourceFormTest.php | 2 +- test/php/application/views/helpers/DateFormatTestBroken.php | 2 +- test/php/bootstrap.php | 2 +- test/php/library/Icinga/Application/ConfigTest.php | 2 +- test/php/library/Icinga/Application/LoaderTest.php | 2 +- test/php/library/Icinga/Chart/GraphChartTest.php | 2 +- test/php/library/Icinga/Chart/PieChartTest.php | 2 +- test/php/library/Icinga/Data/ConfigObjectTest.php | 2 +- test/php/library/Icinga/Data/DataArray/ArrayDatasourceTest.php | 2 +- test/php/library/Icinga/Data/Filter/FilterTest.php | 2 +- test/php/library/Icinga/File/CsvTest.php | 2 +- test/php/library/Icinga/File/Ini/IniWriterTest.php | 2 +- test/php/library/Icinga/Logger/Writer/StreamWriterTest.php | 2 +- test/php/library/Icinga/Protocol/Ldap/QueryTest.php | 2 +- test/php/library/Icinga/Test/BaseTestCaseTest.php | 2 +- test/php/library/Icinga/User/PreferencesTest.php | 2 +- test/php/library/Icinga/User/Store/DbStoreTest.php | 2 +- test/php/library/Icinga/User/Store/IniStoreTest.php | 2 +- test/php/library/Icinga/UserTest.php | 2 +- test/php/library/Icinga/Util/DateTimeFactoryTest.php | 2 +- test/php/library/Icinga/Util/DimensionTest.php | 2 +- test/php/library/Icinga/Util/FileTest.php | 2 +- test/php/library/Icinga/Util/StringTest.php | 2 +- test/php/library/Icinga/Util/TranslatorTest.php | 2 +- test/php/library/Icinga/Web/Form/Element/DateTimePickerTest.php | 2 +- .../Icinga/Web/Form/Validator/DateFormatValidatorTest.php | 2 +- .../Icinga/Web/Form/Validator/TimeFormatValidatorTest.php | 2 +- .../Icinga/Web/Form/Validator/WritablePathValidatorTest.php | 2 +- test/php/library/Icinga/Web/FormTest.php | 2 +- test/php/library/Icinga/Web/HookTest.php | 2 +- test/php/library/Icinga/Web/MenuTest.php | 2 +- .../Web/Paginator/ScrollingStyle/SlidingWithBorderTest.php | 2 +- test/php/library/Icinga/Web/Session/PhpSessionTest.php | 2 +- test/php/library/Icinga/Web/Session/SessionNamespaceTest.php | 2 +- test/php/library/Icinga/Web/UrlTest.php | 2 +- test/php/library/Icinga/Web/View/DateTimeRendererTest.php | 2 +- test/php/library/Icinga/Web/Widget/DashboardTest.php | 2 +- test/php/library/Icinga/Web/Widget/SearchDashboardTest.php | 2 +- test/php/regression/Bug4102Test.php | 2 +- test/php/regression/Bug6284Test.php | 2 +- test/php/regression/Bug6432Test.php | 2 +- 589 files changed, 589 insertions(+), 589 deletions(-) diff --git a/Vagrantfile b/Vagrantfile index 9090b23aa..86de14bb1 100644 --- a/Vagrantfile +++ b/Vagrantfile @@ -1,7 +1,7 @@ # -*- mode: ruby -*- # vi: set ft=ruby : -# Icinga Web 2 | (c) 2013-2015 Icinga Development Team | http://www.gnu.org/licenses/gpl-2.0.txt +# Icinga Web 2 | (c) 2013-2015 Icinga Development Team | GPLv2+ VAGRANTFILE_API_VERSION = "2" VAGRANT_REQUIRED_VERSION = "1.5.0" diff --git a/application/clicommands/AutocompleteCommand.php b/application/clicommands/AutocompleteCommand.php index 045ee8cdc..045110af7 100644 --- a/application/clicommands/AutocompleteCommand.php +++ b/application/clicommands/AutocompleteCommand.php @@ -1,5 +1,5 @@ .tabs, .dontprint { display: none !important; diff --git a/public/index.php b/public/index.php index 0062bf94f..3040f0589 100644 --- a/public/index.php +++ b/public/index.php @@ -1,4 +1,4 @@ Date: Wed, 4 Feb 2015 13:20:41 +0100 Subject: [PATCH 0550/2920] Fix usage of the PostgreSQL system function has_database/table_privilege On PostgreSQL < 8.4 the system functions has_database_privilege() and has_table_privilege() do no support comma separated privilege types. fixes #8354 --- modules/setup/library/Setup/Utils/DbTool.php | 40 +++++++++++--------- 1 file changed, 22 insertions(+), 18 deletions(-) diff --git a/modules/setup/library/Setup/Utils/DbTool.php b/modules/setup/library/Setup/Utils/DbTool.php index f6d3939a7..f9628484c 100644 --- a/modules/setup/library/Setup/Utils/DbTool.php +++ b/modules/setup/library/Setup/Utils/DbTool.php @@ -727,28 +727,32 @@ EOD; } if (false === empty($dbPrivileges)) { - $query = $this->query( - 'SELECT has_database_privilege(:user, :dbname, :privileges) AS db_privileges_granted', - array( - ':user' => $username !== null ? $username : $this->config['username'], - ':dbname' => $this->config['dbname'], - ':privileges' => join(',', $dbPrivileges) . ($requireGrants ? ' WITH GRANT OPTION' : '') - ) - ); - $privilegesGranted &= $query->fetchObject()->db_privileges_granted; + foreach ($dbPrivileges as $dbPrivilege) { + $query = $this->query( + 'SELECT has_database_privilege(:user, :dbname, :privilege) AS db_privilege_granted', + array( + ':user' => $username !== null ? $username : $this->config['username'], + ':dbname' => $this->config['dbname'], + ':privilege' => $dbPrivilege . ($requireGrants ? ' WITH GRANT OPTION' : '') + ) + ); + $privilegesGranted &= $query->fetchObject()->db_privilege_granted; + } } if (false === empty($tablePrivileges)) { foreach (array_intersect($context, $this->listTables()) as $table) { - $query = $this->query( - 'SELECT has_table_privilege(:user, :table, :privileges) AS table_privileges_granted', - array( - ':user' => $username !== null ? $username : $this->config['username'], - ':table' => $table, - ':privileges' => join(',', $tablePrivileges) . ($requireGrants ? ' WITH GRANT OPTION' : '') - ) - ); - $privilegesGranted &= $query->fetchObject()->table_privileges_granted; + foreach ($tablePrivileges as $tablePrivilege) { + $query = $this->query( + 'SELECT has_table_privilege(:user, :table, :privilege) AS table_privilege_granted', + array( + ':user' => $username !== null ? $username : $this->config['username'], + ':table' => $table, + ':privilege' => $tablePrivilege . ($requireGrants ? ' WITH GRANT OPTION' : '') + ) + ); + $privilegesGranted &= $query->fetchObject()->table_privilege_granted; + } } } } else { From cef9a5c1a2e51f85d2b79c7ffe4a8cdc095cabd3 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Wed, 4 Feb 2015 16:15:14 +0100 Subject: [PATCH 0551/2920] WCAG/1.1.1: Add example for accessible icon fonts refs #8358 --- doc/accessibility/ifont.html | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 doc/accessibility/ifont.html diff --git a/doc/accessibility/ifont.html b/doc/accessibility/ifont.html new file mode 100644 index 000000000..481cbff71 --- /dev/null +++ b/doc/accessibility/ifont.html @@ -0,0 +1,31 @@ + + + + + + Accessibility: Icon Fonts + + + + + + + + Top rated article + + + From 04357d21b6c2b857387756ac833128978a3474d1 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Wed, 4 Feb 2015 16:40:33 +0100 Subject: [PATCH 0552/2920] WCAG/1.1.1: Add example for screen reader muted icon refs #8360 --- doc/accessibility/ifont-mute.html | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 doc/accessibility/ifont-mute.html diff --git a/doc/accessibility/ifont-mute.html b/doc/accessibility/ifont-mute.html new file mode 100644 index 000000000..f8252e36a --- /dev/null +++ b/doc/accessibility/ifont-mute.html @@ -0,0 +1,21 @@ + + + + + + Accessibility: Muted Icon Fonts + + + + + + + + Visit top rated article + + + From 5014b5dc46dc48d4b29ced2516abc842ec23c483 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Wed, 4 Feb 2015 17:23:07 +0100 Subject: [PATCH 0553/2920] Fix usermod for SUSE and SLES fixes #8359 --- doc/installation.md | 2 +- icingaweb2.spec | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/installation.md b/doc/installation.md index aa6968e26..d9483faef 100644 --- a/doc/installation.md +++ b/doc/installation.md @@ -81,7 +81,7 @@ usermod -a -G icingaweb2 apache SLES and OpenSUSE: ```` -usermod -G icingaweb2 wwwrun +usermod -A icingaweb2 wwwrun ```` Debian and Ubuntu: diff --git a/icingaweb2.spec b/icingaweb2.spec index 9a40e59e6..1d97819d9 100644 --- a/icingaweb2.spec +++ b/icingaweb2.spec @@ -202,7 +202,7 @@ cp -prv packages/files/config/modules/setup %{buildroot}/%{configdir}/modules/ %pre getent group icingacmd >/dev/null || groupadd -r icingacmd %if 0%{?suse_version} -usermod -G icingacmd,%{icingawebgroup} %{wwwuser} +usermod -A icingacmd,%{icingawebgroup} %{wwwuser} %else usermod -a -G icingacmd,%{icingawebgroup} %{wwwuser} %endif From b56eb7b66952169c6d68a1d1d780a3e67e5c0f2a Mon Sep 17 00:00:00 2001 From: Matthias Jentsch Date: Wed, 4 Feb 2015 17:57:31 +0100 Subject: [PATCH 0554/2920] Fix keyboard navigation Store current focus position before reload and apply it after rendering. fixes #8350 --- public/js/icinga/events.js | 3 -- public/js/icinga/loader.js | 9 ++++-- public/js/icinga/utils.js | 62 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 68 insertions(+), 6 deletions(-) diff --git a/public/js/icinga/events.js b/public/js/icinga/events.js index 9ae61148b..7bcbc8e3b 100644 --- a/public/js/icinga/events.js +++ b/public/js/icinga/events.js @@ -74,9 +74,6 @@ } }); - if (document.activeElement === document.body) { - $('input.autofocus', el).focus(); - } var searchField = $('#menu input.search', el); // Remember initial search field value if any if (searchField.length && searchField.val().length) { diff --git a/public/js/icinga/loader.js b/public/js/icinga/loader.js index d71c1d19f..6a82a6ee5 100644 --- a/public/js/icinga/loader.js +++ b/public/js/icinga/loader.js @@ -672,7 +672,7 @@ // Container update happens here var scrollPos = false; var self = this; - var origFocus = document.activeElement; + var origFocus = self.icinga.utils.getDomPath(document.activeElement); var containerId = $container.attr('id'); if (typeof containerId !== 'undefined') { if (autorefresh) { @@ -737,8 +737,11 @@ } this.icinga.ui.assignUniqueContainerIds(); - if (origFocus) { - $(origFocus).focus(); + console.log(origFocus); + if (origFocus.length == origFocus[0] !== '') { + setTimeout(function() { + $(self.icinga.utils.getElementByDomPath(origFocus)).focus(); + }, 0); } // TODO: this.icinga.events.refreshContainer(container); diff --git a/public/js/icinga/utils.js b/public/js/icinga/utils.js index bdde78ada..bd64e586e 100644 --- a/public/js/icinga/utils.js +++ b/public/js/icinga/utils.js @@ -233,6 +233,68 @@ return !(at > (bt + bh) || bt > (at + ah)) && !(bl > (al + aw) || al > (bl + bw)); }, + /** + * Create a selector that can be used to fetch the element the same position in the DOM-Tree + * + * Create the path to the given element in the DOM-Tree, comparable to an X-Path. Climb the + * DOM tree upwards until an element with an unique ID is found, this id is used as the anchor, + * all other elements will be addressed by their position in the parent. + * + * @param {HTMLElement} el The element to extract the path for. + * + * @returns {Array} The path of the element, that can be passed to getElementByPath + */ + getDomPath: function (el) { + if (! el) { + return []; + } + if (el.id !== '') { + return ['#' + el.id]; + } + if (el === document.body) { + return ['body']; + } + + var siblings = el.parentNode.childNodes; + var index = 0; + for (var i = 0; i < siblings.length; i ++) { + if (siblings[i].nodeType === 1) { + index ++; + } + + if (siblings[i] === el) { + var p = this.getDomPath(el.parentNode); + p.push(':nth-child(' + (index) + ')'); + return p; + } + } + }, + + /** + * Climbs up the given dom path and returns the element + * + * This is the counterpart + * + * @param path {Array} The selector + * @returns {HTMLElement} The corresponding element + */ + getElementByDomPath: function (path) { + var $element; + $.each(path, function (i, selector) { + if (! $element) { + $element = $(selector); + } else { + console.log(selector); + $element = $element.children(selector).first(); + if (! $element[0]) { + console.log("element not existing stopping..."); + return false; + } + } + }); + return $element[0]; + }, + /** * Cleanup */ From e315d8c35847520d56c447d545edc3dec9b66e3f Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Thu, 5 Feb 2015 09:15:25 +0100 Subject: [PATCH 0555/2920] Clarify external authentication documentation It's necessary to enable the HTTPDigestAuthentication module and to restart the webserver.. --- doc/external_authentication.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/doc/external_authentication.md b/doc/external_authentication.md index 15df1e1cf..05225fb82 100644 --- a/doc/external_authentication.md +++ b/doc/external_authentication.md @@ -65,6 +65,9 @@ The webserver should require authentication for all public Icinga Web 2 files. ```` +To get these changes to work, make sure to enable the module for +HTTPDigestAuthentication and restart the webserver. + ### Preparing Icinga Web 2 Once external authentication is set up correctly you need to configure Icinga From d8c40d40a0f3f7edbd1dec61211a4f565945d03a Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Thu, 5 Feb 2015 10:16:50 +0100 Subject: [PATCH 0556/2920] WCAG/1.1.1: Add example for accessible SVGs refs #8364 --- doc/accessibility/svg.html | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 doc/accessibility/svg.html diff --git a/doc/accessibility/svg.html b/doc/accessibility/svg.html new file mode 100644 index 000000000..8ee548f38 --- /dev/null +++ b/doc/accessibility/svg.html @@ -0,0 +1,19 @@ + + + + + + Accessibility: SVGs + + + + + + A Circle + A red circle with a black border. + + + + + + From 707d977cfcf42dff5287ebd93cbf7aa5f027dc2b Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Thu, 5 Feb 2015 13:14:29 +0100 Subject: [PATCH 0557/2920] WCAG/3.3.3: Add example for required form elements refs #8349 --- doc/accessibility/required-form-elements.html | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 doc/accessibility/required-form-elements.html diff --git a/doc/accessibility/required-form-elements.html b/doc/accessibility/required-form-elements.html new file mode 100644 index 000000000..86fc9374e --- /dev/null +++ b/doc/accessibility/required-form-elements.html @@ -0,0 +1,19 @@ + + + + + + Accessibility: Required form elements + + + + +
    + + +
    + + \ No newline at end of file From c5b6d7ee41cb0edf272847a5d63d55e6c3452116 Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Thu, 5 Feb 2015 13:15:18 +0100 Subject: [PATCH 0558/2920] Ensure that all required form elements are marked as such in HTML markup refs #8349 --- library/Icinga/Web/Form.php | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/library/Icinga/Web/Form.php b/library/Icinga/Web/Form.php index 1a75cb852..606a74f98 100644 --- a/library/Icinga/Web/Form.php +++ b/library/Icinga/Web/Form.php @@ -6,6 +6,7 @@ namespace Icinga\Web; use LogicException; use Zend_Config; use Zend_Form; +use Zend_Form_Element; use Zend_View_Interface; use Icinga\Application\Icinga; use Icinga\Authentication\Manager; @@ -550,7 +551,24 @@ class Form extends Zend_Form unset($el->autosubmit); } - return $el; + return $this->ensureElementAccessibility($el); + } + + /** + * Add accessibility related attributes + * + * @param Zend_Form_Element $element + * + * @return Zend_Form_Element + */ + public function ensureElementAccessibility(Zend_Form_Element $element) + { + if ($element->isRequired() && strpos(strtolower($element->getType()), 'checkbox') === false) { + $element->setAttrib('aria-required', 'true'); // ARIA + $element->setAttrib('required', ''); // HTML5 + } + + return $element; } /** From 437050430f8f3f806516b7e8cfa349dadb821f71 Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Thu, 5 Feb 2015 13:18:21 +0100 Subject: [PATCH 0559/2920] Make sure that the admin wizard-step provides the required-HTML markup refs #8349 --- .../application/forms/AdminAccountPage.php | 44 ++++++++++++++++++- .../scripts/form/setup-admin-account.phtml | 6 +-- 2 files changed, 46 insertions(+), 4 deletions(-) diff --git a/modules/setup/application/forms/AdminAccountPage.php b/modules/setup/application/forms/AdminAccountPage.php index e9334c650..de8650439 100644 --- a/modules/setup/application/forms/AdminAccountPage.php +++ b/modules/setup/application/forms/AdminAccountPage.php @@ -78,7 +78,7 @@ class AdminAccountPage extends Form 'text', 'by_name', array( - 'required' => isset($formData['user_type']) && $formData['user_type'] === 'by_name', + 'required' => !isset($formData['user_type']) || $formData['user_type'] === 'by_name', 'value' => $this->getUsername(), 'label' => $this->translate('Username'), 'description' => $this->translate( @@ -87,6 +87,12 @@ class AdminAccountPage extends Form ) ) ); + if (! $this->request->isXmlHttpRequest()) { + // In case JS is disabled we must not provide client side validation as + // the user is required to input data even he has changed his mind + $this->getElement('by_name')->setAttrib('required', null); + $this->getElement('by_name')->setAttrib('aria-required', null); + } } if ($this->backendConfig['backend'] === 'db' || $this->backendConfig['backend'] === 'ldap') { @@ -111,6 +117,12 @@ class AdminAccountPage extends Form 'multiOptions' => array_combine($users, $users) ) ); + if (! $this->request->isXmlHttpRequest()) { + // In case JS is disabled we must not provide client side validation as + // the user is required to input data even he has changed his mind + $this->getElement('existing_user')->setAttrib('required', null); + $this->getElement('existing_user')->setAttrib('aria-required', null); + } } } @@ -149,6 +161,14 @@ class AdminAccountPage extends Form ) ) ); + if (! $this->request->isXmlHttpRequest()) { + // In case JS is disabled we must not provide client side validation as + // the user is required to input data even he has changed his mind + foreach (array('new_user', 'new_user_password', 'new_user_2ndpass') as $elementName) { + $this->getElement($elementName)->setAttrib('aria-required', null); + $this->getElement($elementName)->setAttrib('required', null); + } + } } if (count($choices) > 1) { @@ -157,6 +177,8 @@ class AdminAccountPage extends Form 'user_type', array( 'required' => true, + 'autosubmit' => true, + 'value' => key($choices), 'multiOptions' => $choices ) ); @@ -218,6 +240,26 @@ class AdminAccountPage extends Form return true; } + /** + * Return whether the given values (possibly incomplete) are valid + * + * Unsets all empty text-inputs so that they are not being validated when auto-submitting the form. + * + * @param array $formData + * + * @return type + */ + public function isValidPartial(array $formData) + { + foreach (array('by_name', 'new_user', 'new_user_password', 'new_user_2ndpass') as $elementName) { + if (isset($formData[$elementName]) && $formData[$elementName] === '') { + unset($formData[$elementName]); + } + } + + return parent::isValidPartial($formData); + } + /** * Return the name of the externally authenticated user * diff --git a/modules/setup/application/views/scripts/form/setup-admin-account.phtml b/modules/setup/application/views/scripts/form/setup-admin-account.phtml index ac060526a..b069bb371 100644 --- a/modules/setup/application/views/scripts/form/setup-admin-account.phtml +++ b/modules/setup/application/views/scripts/form/setup-admin-account.phtml @@ -17,7 +17,7 @@ $showRadioBoxes = strpos(strtolower(get_class($radioElem)), 'radio') !== false;
    @@ -32,7 +32,7 @@ $showRadioBoxes = strpos(strtolower(get_class($radioElem)), 'radio') !== false;
    @@ -49,7 +49,7 @@ $showRadioBoxes = strpos(strtolower(get_class($radioElem)), 'radio') !== false;
    From 423025b3fe2776df7c6d314c567ad8544b50d987 Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Thu, 5 Feb 2015 13:21:03 +0100 Subject: [PATCH 0560/2920] javascript: Do not bind the button click event Catching form submit events is sufficient as catching the button click event is not an option due to circumventing the browser's native form validation logic otherwise. refs #8349 --- public/js/icinga/events.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/public/js/icinga/events.js b/public/js/icinga/events.js index 7bcbc8e3b..16b6fb0f5 100644 --- a/public/js/icinga/events.js +++ b/public/js/icinga/events.js @@ -118,8 +118,6 @@ // Select a table row $(document).on('click', 'table.multiselect tr[href]', { self: this }, this.rowSelected); - $(document).on('click', 'button', { self: this }, this.submitForm); - // We catch all form submit events $(document).on('submit', 'form', { self: this }, this.submitForm); From c49f723f05739cf106c232a00fcedca7ca632793 Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Fri, 6 Feb 2015 16:31:03 +0100 Subject: [PATCH 0561/2920] Let Icinga\Protocol\Ldap\Exception inherit from IcingaException --- library/Icinga/Protocol/Ldap/Connection.php | 72 ++++++++------------- library/Icinga/Protocol/Ldap/Exception.php | 4 +- 2 files changed, 31 insertions(+), 45 deletions(-) diff --git a/library/Icinga/Protocol/Ldap/Connection.php b/library/Icinga/Protocol/Ldap/Connection.php index db55858e9..2d425d12b 100644 --- a/library/Icinga/Protocol/Ldap/Connection.php +++ b/library/Icinga/Protocol/Ldap/Connection.php @@ -171,11 +171,9 @@ class Connection return false; } throw new LdapException( - sprintf( - 'LDAP list for "%s" failed: %s', - $dn, - ldap_error($this->ds) - ) + 'LDAP list for "%s" failed: %s', + $dn, + ldap_error($this->ds) ); } $children = ldap_get_entries($this->ds, $result); @@ -183,7 +181,7 @@ class Connection $result = $this->deleteRecursively($children[$i]['dn']); if (!$result) { //return result code, if delete fails - throw new LdapException(sprintf('Recursively deleting "%s" failed', $dn)); + throw new LdapException('Recursively deleting "%s" failed', $dn); } } return $this->deleteDN($dn); @@ -200,11 +198,9 @@ class Connection return false; } throw new LdapException( - sprintf( - 'LDAP delete for "%s" failed: %s', - $dn, - ldap_error($this->ds) - ) + 'LDAP delete for "%s" failed: %s', + $dn, + ldap_error($this->ds) ); } @@ -225,10 +221,8 @@ class Connection $rows = $this->fetchAll($query, $fields); if (count($rows) !== 1) { throw new LdapException( - sprintf( - 'Cannot fetch single DN for %s', - $query->create() - ) + 'Cannot fetch single DN for %s', + $query->create() ); } return key($rows); @@ -471,18 +465,14 @@ class Connection } else { Logger::debug('LDAP STARTTLS failed: %s', ldap_error($ds)); throw new LdapException( - sprintf( - 'LDAP STARTTLS failed: %s', - ldap_error($ds) - ) + 'LDAP STARTTLS failed: %s', + ldap_error($ds) ); } } elseif ($force_tls) { throw new LdapException( - sprintf( - 'TLS is required but not announced by %s', - $this->hostname - ) + 'TLS is required but not announced by %s', + $this->hostname ); } else { // TODO: Log noticy -> TLS enabled but not announced @@ -708,24 +698,20 @@ class Connection if (! $result) { throw new LdapException( - sprintf( - 'Capability query failed (%s:%d): %s. Check if hostname and port of the ldap resource are correct ' - . ' and if anonymous access is permitted.', - $this->hostname, - $this->port, - ldap_error($ds) - ) + 'Capability query failed (%s:%d): %s. Check if hostname and port of the' + . ' ldap resource are correct and if anonymous access is permitted.', + $this->hostname, + $this->port, + ldap_error($ds) ); } $entry = ldap_first_entry($ds, $result); if ($entry === false) { throw new LdapException( - sprintf( - 'Capabilities not available (%s:%d): %s. Discovery of root DSE probably not permitted.', - $this->hostname, - $this->port, - ldap_error($ds) - ) + 'Capabilities not available (%s:%d): %s. Discovery of root DSE probably not permitted.', + $this->hostname, + $this->port, + ldap_error($ds) ); } @@ -771,14 +757,12 @@ class Connection $r = @ldap_bind($this->ds, $this->bind_dn, $this->bind_pw); if (! $r) { throw new LdapException( - sprintf( - 'LDAP connection to %s:%s (%s / %s) failed: %s', - $this->hostname, - $this->port, - $this->bind_dn, - '***' /* $this->bind_pw */, - ldap_error($this->ds) - ) + 'LDAP connection to %s:%s (%s / %s) failed: %s', + $this->hostname, + $this->port, + $this->bind_dn, + '***' /* $this->bind_pw */, + ldap_error($this->ds) ); } $this->bound = true; diff --git a/library/Icinga/Protocol/Ldap/Exception.php b/library/Icinga/Protocol/Ldap/Exception.php index 784b84a9d..de7a10651 100644 --- a/library/Icinga/Protocol/Ldap/Exception.php +++ b/library/Icinga/Protocol/Ldap/Exception.php @@ -3,10 +3,12 @@ namespace Icinga\Protocol\Ldap; +use Icinga\Exception\IcingaException; + /** * Class Exception * @package Icinga\Protocol\Ldap */ -class Exception extends \Exception +class Exception extends IcingaException { } From 8b94e4c7019a0f7e01d204487bacd079b0815899 Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Fri, 6 Feb 2015 16:32:26 +0100 Subject: [PATCH 0562/2920] Fix documentation and code style in the LdapUserBackend --- .../Backend/LdapUserBackend.php | 57 ++++++++++--------- 1 file changed, 30 insertions(+), 27 deletions(-) diff --git a/library/Icinga/Authentication/Backend/LdapUserBackend.php b/library/Icinga/Authentication/Backend/LdapUserBackend.php index fd7e39f54..7fde1f61b 100644 --- a/library/Icinga/Authentication/Backend/LdapUserBackend.php +++ b/library/Icinga/Authentication/Backend/LdapUserBackend.php @@ -5,6 +5,7 @@ namespace Icinga\Authentication\Backend; use Icinga\User; use Icinga\Authentication\UserBackend; +use Icinga\Protocol\Ldap\Query; use Icinga\Protocol\Ldap\Connection; use Icinga\Exception\AuthenticationException; use Icinga\Protocol\Ldap\Exception as LdapException; @@ -15,7 +16,7 @@ class LdapUserBackend extends UserBackend * Connection to the LDAP server * * @var Connection - **/ + */ protected $conn; protected $baseDn; @@ -36,7 +37,9 @@ class LdapUserBackend extends UserBackend } /** - * @return \Icinga\Protocol\Ldap\Query + * Create a query to select all usernames + * + * @return Query */ protected function selectUsers() { @@ -49,18 +52,18 @@ class LdapUserBackend extends UserBackend } /** - * Create query + * Create a query filtered by the given username * - * @param string $username + * @param string $username * - * @return \Icinga\Protocol\Ldap\Query - **/ + * @return Query + */ protected function selectUser($username) { - return $this->selectUsers()->where( - $this->userNameAttribute, - str_replace('*', '', $username) - ); + return $this->selectUsers()->setUsePagedResults(false)->where( + $this->userNameAttribute, + str_replace('*', '', $username) + ); } /** @@ -68,23 +71,22 @@ class LdapUserBackend extends UserBackend * * Try to bind to the backend and query all available users to check if: *
      - *
    • User connection credentials are correct and the bind is possible
    • + *
    • Connection credentials are correct and the bind is possible
    • *
    • At least one user exists
    • *
    • The specified userClass has the property specified by userNameAttribute
    • *
    * - * @throws AuthenticationException When authentication is not possible + * @throws AuthenticationException When authentication is not possible */ public function assertAuthenticationPossible() { try { - $q = $this->conn->select()->setBase($this->baseDn)->from($this->userClass); - $result = $q->fetchRow(); + $result = $this->selectUsers()->fetchRow(); } catch (LdapException $e) { throw new AuthenticationException('Connection not possible.', $e); } - if (! isset($result)) { + if ($result === null) { throw new AuthenticationException( 'No objects with objectClass="%s" in DN="%s" found.', $this->userClass, @@ -139,17 +141,16 @@ class LdapUserBackend extends UserBackend } /** - * Test whether the given user exists + * Return whether the given user exists * - * @param User $user + * @param User $user * * @return bool - * @throws AuthenticationException */ public function hasUser(User $user) { $username = $user->getUsername(); - $entry = $this->conn->fetchOne($this->selectUser($username)); + $entry = $this->selectUser($username)->fetchOne(); if (is_array($entry)) { return in_array(strtolower($username), array_map('strtolower', $entry)); @@ -159,16 +160,15 @@ class LdapUserBackend extends UserBackend } /** - * Authenticate the given user and return true on success, false on failure and null on error + * Return whether the given user credentials are valid * * @param User $user * @param string $password - * @param boolean $healthCheck Perform additional health checks to generate more useful exceptions in case - * of a configuration or backend error + * @param boolean $healthCheck Assert that authentication is possible at all * - * @return bool True when the authentication was successful, false when the username - * or password was invalid - * @throws AuthenticationException When an error occurred during authentication and authentication is not possible + * @return bool + * + * @throws AuthenticationException In case an error occured or the health check has failed */ public function authenticate(User $user, $password, $healthCheck = true) { @@ -176,7 +176,6 @@ class LdapUserBackend extends UserBackend try { $this->assertAuthenticationPossible(); } catch (AuthenticationException $e) { - // Authentication not possible throw new AuthenticationException( 'Authentication against backend "%s" not possible.', $this->getName(), @@ -184,24 +183,27 @@ class LdapUserBackend extends UserBackend ); } } + if (! $this->hasUser($user)) { return false; } + try { $userDn = $this->conn->fetchDN($this->selectUser($user->getUsername())); $authenticated = $this->conn->testCredentials( $userDn, $password ); + if ($authenticated) { $groups = $this->getGroups($userDn); if ($groups !== null) { $user->setGroups($groups); } } + return $authenticated; } catch (LdapException $e) { - // Error during authentication of this specific user throw new AuthenticationException( 'Failed to authenticate user "%s" against backend "%s". An exception was thrown:', $user->getUsername(), @@ -238,6 +240,7 @@ class LdapUserBackend extends UserBackend $users[] = $row->{$this->userNameAttribute}; } } + return $users; } } From 3852feb069f8e91b60dd0976d4d6187d8d3beb2d Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Fri, 6 Feb 2015 16:32:59 +0100 Subject: [PATCH 0563/2920] Add defaults for limit and offset in Icinga\Protocol\Ldap\Query --- library/Icinga/Protocol/Ldap/Query.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/library/Icinga/Protocol/Ldap/Query.php b/library/Icinga/Protocol/Ldap/Query.php index 8b71fc918..897f12f4e 100644 --- a/library/Icinga/Protocol/Ldap/Query.php +++ b/library/Icinga/Protocol/Ldap/Query.php @@ -27,8 +27,8 @@ class Query protected $connection; protected $filters = array(); protected $fields = array(); - protected $limit_count; - protected $limit_offset; + protected $limit_count = 0; + protected $limit_offset = 0; protected $sort_columns = array(); protected $count; protected $base; @@ -111,7 +111,7 @@ class Query */ public function hasLimit() { - return $this->limit_count !== null; + return $this->limit_count > 0; } /** From b828f8b13adfdbc7084da6ef3eb93bac7e024ce8 Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Fri, 6 Feb 2015 16:37:35 +0100 Subject: [PATCH 0564/2920] Fix ldap authentication when authenticating against ActiveDirectory Unlike OpenLDAP, ActiveDirectory does not seem to react on the size limit passed to ldap_search() in global manner causing it to not to respond with LDAP_SIZELIMIT_EXCEEDED (4) in case a requested page contains more entries than the requested maximum. fixes #7993 --- library/Icinga/Protocol/Ldap/Connection.php | 218 ++++++++++++-------- 1 file changed, 127 insertions(+), 91 deletions(-) diff --git a/library/Icinga/Protocol/Ldap/Connection.php b/library/Icinga/Protocol/Ldap/Connection.php index 2d425d12b..6db88365a 100644 --- a/library/Icinga/Protocol/Ldap/Connection.php +++ b/library/Icinga/Protocol/Ldap/Connection.php @@ -32,6 +32,8 @@ class Connection { const LDAP_NO_SUCH_OBJECT = 32; const LDAP_SIZELIMIT_EXCEEDED = 4; + const LDAP_ADMINLIMIT_EXCEEDED = 11; + const PAGE_SIZE = 1000; protected $ds; protected $hostname; @@ -98,9 +100,6 @@ class Connection protected $namingContexts; protected $discoverySuccess = false; - protected $lastResult; - protected $pageCookie; - /** * Constructor * @@ -238,6 +237,7 @@ class Connection { $query = clone $query; $query->limit(1); + $query->setUsePagedResults(false); $results = $this->fetchAll($query, $fields); return array_shift($results); } @@ -267,35 +267,144 @@ class Connection $this->connect(); $this->bind(); - $offset = $limit = null; - if ($query->hasLimit()) { - $offset = $query->getOffset(); - $limit = $query->getLimit(); + if ($query->getUsePagedResults() && version_compare(PHP_VERSION, '5.4.0') >= 0) { + return $this->runPagedQuery($query, $fields); + } else { + return $this->runQuery($query, $fields); + } + } + + protected function runQuery(Query $query, $fields = array()) + { + $limit = $query->getLimit(); + $offset = $query->hasOffset() ? $query->getOffset() - 1 : 0; + + $results = @ldap_search( + $this->ds, + $query->hasBase() ? $query->getBase() : $this->root_dn, + $query->create(), + empty($fields) ? $query->listFields() : $fields, + 0, // Attributes and values + $limit ? $offset + $limit : 0 + ); + if ($results === false) { + if (ldap_errno($this->ds) === self::LDAP_NO_SUCH_OBJECT) { + return array(); + } + + throw new LdapException( + 'LDAP query "%s" (base %s) failed. Error: %s', + $query->create(), + $query->hasBase() ? $query->getBase() : $this->root_dn, + ldap_error($this->ds) + ); + } elseif (ldap_count_entries($this->ds, $results) === 0) { + return array(); + } + + foreach ($query->getSortColumns() as $col) { + ldap_sort($this->ds, $results, $col[0]); } $count = 0; $entries = array(); - $results = $this->runQuery($query, $fields); - while (! empty($results)) { + $entry = ldap_first_entry($this->ds, $results); + do { + $count += 1; + if ($offset === 0 || $offset < $count) { + $entries[ldap_get_dn($this->ds, $entry)] = $this->cleanupAttributes( + ldap_get_attributes($this->ds, $entry) + ); + } + } while (($limit === 0 || $limit !== count($entries)) && ($entry = ldap_next_entry($this->ds, $entry))); + + ldap_free_result($results); + return $entries; + } + + protected function runPagedQuery(Query $query, $fields = array()) + { + $limit = $query->getLimit(); + $offset = $query->hasOffset() ? $query->getOffset() - 1 : 0; + $queryString = $query->create(); + $base = $query->hasBase() ? $query->getBase() : $this->root_dn; + + if (empty($fields)) { + $fields = $query->listFields(); + } + + $count = 0; + $cookie = ''; + $entries = array(); + do { + ldap_control_paged_result($this->ds, static::PAGE_SIZE, true, $cookie); + $results = @ldap_search($this->ds, $base, $queryString, $fields, 0, $limit ? $offset + $limit : 0); + if ($results === false) { + if (ldap_errno($this->ds) === self::LDAP_NO_SUCH_OBJECT) { + break; + } + + throw new LdapException( + 'LDAP query "%s" (base %s) failed. Error: %s', + $queryString, + $base, + ldap_error($this->ds) + ); + } elseif (ldap_count_entries($this->ds, $results) === 0) { + if (in_array( + ldap_errno($this->ds), + array(static::LDAP_SIZELIMIT_EXCEEDED, static::LDAP_ADMINLIMIT_EXCEEDED) + )) { + Logger::warning( + 'Unable to request more than %u results. Does the server allow paged search requests? (%s)', + $count, + ldap_error($this->ds) + ); + } + + break; + } + $entry = ldap_first_entry($this->ds, $results); - while ($entry) { - $count++; - if ( - ($offset === null || $offset <= $count) - && ($limit === null || $limit > count($entries)) - ) { + do { + $count += 1; + if ($offset === 0 || $offset < $count) { $entries[ldap_get_dn($this->ds, $entry)] = $this->cleanupAttributes( ldap_get_attributes($this->ds, $entry) ); } + } while (($limit === 0 || $limit !== count($entries)) && ($entry = ldap_next_entry($this->ds, $entry))); - $entry = ldap_next_entry($this->ds, $entry); + try { + ldap_control_paged_result_response($this->ds, $results, $cookie); + } catch (Exception $e) { + // If the page size is greater than or equal to the sizeLimit value, the server should ignore the + // control as the request can be satisfied in a single page: https://www.ietf.org/rfc/rfc2696.txt + // This applies no matter whether paged search requests are permitted or not. You're done once you + // got everything you were out for. + if (count($entries) !== $limit) { + Logger::warning( + 'Unable to request paged LDAP results. Does the server allow paged search requests? (%s)', + $e->getMessage() + ); + } } - $results = $this->runQuery($query, $fields); + ldap_free_result($results); + } while ($cookie && ($limit === 0 || count($entries) < $limit)); + + if ($cookie) { + // A sequence of paged search requests is abandoned by the client sending a search request containing a + // pagedResultsControl with the size set to zero (0) and the cookie set to the last cookie returned by + // the server: https://www.ietf.org/rfc/rfc2696.txt + ldap_control_paged_result($this->ds, 0, false, $cookie); + ldap_search($this->ds, $base, $queryString, $fields); // Returns no entries, due to the page size + } else { + // Reset the paged search request so that subsequent requests succeed + ldap_control_paged_result($this->ds, 0); } - return $entries; + return $entries; // TODO(7693): Sort entries post-processed } protected function cleanupAttributes($attrs) @@ -314,79 +423,6 @@ class Connection return $clean; } - protected function runQuery(Query $query, $fields = array()) - { - if ($query->getUsePagedResults() && version_compare(PHP_VERSION, '5.4.0') >= 0) { - if ($this->pageCookie === null) { - $this->pageCookie = ''; - } else { - try { - ldap_control_paged_result_response($this->ds, $this->lastResult, $this->pageCookie); - } catch (Exception $e) { - $this->pageCookie = ''; - if (! $query->hasLimit() || ldap_errno($this->ds) !== static::LDAP_SIZELIMIT_EXCEEDED) { - Logger::error( - 'Unable to request paged LDAP results. Does the server allow paged search requests? (%s)', - $e->getMessage() - ); - } - } - - ldap_free_result($this->lastResult); - if (! $this->pageCookie) { - $this->pageCookie = $this->lastResult = null; - // Abandon the paged search request so that subsequent requests succeed - ldap_control_paged_result($this->ds, 0); - return false; - } - } - - // Does not matter whether we'll use a valid page size here, - // as the server applies its hard limit in case its too high - ldap_control_paged_result( - $this->ds, - $query->hasLimit() ? $query->getLimit() : 500, - true, - $this->pageCookie - ); - } elseif ($this->lastResult !== null) { - ldap_free_result($this->lastResult); - $this->lastResult = null; - return false; - } - - $base = $query->hasBase() ? $query->getBase() : $this->root_dn; - $results = @ldap_search( - $this->ds, - $base, - $query->create(), - empty($fields) ? $query->listFields() : $fields, - 0, // Attributes and values - $query->hasLimit() ? $query->getOffset() + $query->getLimit() : 0 // No limit - at least where possible - ); - - if ($results === false) { - if (ldap_errno($this->ds) === self::LDAP_NO_SUCH_OBJECT) { - return false; - } - throw new LdapException( - sprintf( - 'LDAP query "%s" (root %s) failed: %s', - $query->create(), - $this->root_dn, - ldap_error($this->ds) - ) - ); - } - - foreach ($query->getSortColumns() as $col) { - ldap_sort($this->ds, $results, $col[0]); - } - - $this->lastResult = $results; - return $results; - } - public function testCredentials($username, $password) { $this->connect(); From c8da05d0a78e674df51a36d948f181124be62963 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Fri, 6 Feb 2015 17:17:41 +0100 Subject: [PATCH 0565/2920] lib: Remove NodeInterface I'll create an iterator for nodes and drop that every node is a SplDoublyLinkedList. refs #6630 --- library/Icinga/Data/Tree/NodeInterface.php | 25 ---------------------- 1 file changed, 25 deletions(-) delete mode 100644 library/Icinga/Data/Tree/NodeInterface.php diff --git a/library/Icinga/Data/Tree/NodeInterface.php b/library/Icinga/Data/Tree/NodeInterface.php deleted file mode 100644 index faec9e764..000000000 --- a/library/Icinga/Data/Tree/NodeInterface.php +++ /dev/null @@ -1,25 +0,0 @@ - Date: Fri, 6 Feb 2015 17:20:23 +0100 Subject: [PATCH 0566/2920] lib/tree: Save child nodes into an array instead of using SplDoublyLinkedList refs #6630 --- library/Icinga/Data/Tree/Node.php | 91 ++++++++++++++++++++++--------- 1 file changed, 66 insertions(+), 25 deletions(-) diff --git a/library/Icinga/Data/Tree/Node.php b/library/Icinga/Data/Tree/Node.php index 9402f6265..ad1db9c36 100644 --- a/library/Icinga/Data/Tree/Node.php +++ b/library/Icinga/Data/Tree/Node.php @@ -3,10 +3,18 @@ namespace Icinga\Data\Tree; -use SplDoublyLinkedList; +use Identifiable; +use IteratorAggregate; -class Node extends SplDoublyLinkedList implements NodeInterface +class Node implements Identifiable, IteratorAggregate { + /** + * The node's ID + * + * @type mixed + */ + protected $id; + /** * The node's value * @@ -15,13 +23,45 @@ class Node extends SplDoublyLinkedList implements NodeInterface protected $value; /** - * Create a new node + * The node's children * - * @param mixed $value The node's value + * @type array */ - public function __construct($value = null) + protected $children = array(); + + /** + * Set the node's ID + * + * @param mixed $id ID of the node + * + * @return $this + */ + public function setId($id) + { + $this->id = $id; + return $this; + } + + /** + * (non-PHPDoc) + * @see Identifiable::getId() For the method documentation. + */ + public function getId() + { + return $this->id; + } + + /** + * Set the node's value + * + * @param mixed $value + * + * @return $this + */ + public function setValue($value) { $this->value = $value; + return $this; } /** @@ -35,44 +75,45 @@ class Node extends SplDoublyLinkedList implements NodeInterface } /** - * Create a new node from the given value and insert the node as the last child of this node + * Append a child node as the last child of this node * - * @param mixed $value The node's value + * @param Node $child The child to append * - * @return NodeInterface The appended node + * @return $this */ - public function appendChild($value) + public function appendChild(Node $child) { - $child = new static($value); - $this->push($child); - return $child; + $this->children[] = $child; + return $this; } + /** - * Whether this node has child nodes + * Get whether the node has children * * @return bool */ public function hasChildren() { - $current = $this->current(); - if ($current === null) { - $current = $this; - } - return ! $current->isEmpty(); + return ! empty($this->children); } /** - * Get the node's child nodes + * Get the node's children * - * @return NodeInterface + * @return array */ public function getChildren() { - $current = $this->current(); - if ($current === null) { - $current = $this; - } - return $current; + return $this->children; + } + + /** + * (non-PHPDoc) + * @see IteratorAggregate::getIterator() For the method documentation. + */ + public function getIterator() + { + return new TreeNodeIterator($this); } } From 828cb8d23a906b6be934f82dac11e64f1b21dfba Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Fri, 6 Feb 2015 17:23:07 +0100 Subject: [PATCH 0567/2920] lib: Add iterator over a tree node's children refs #6630 --- library/Icinga/Data/Tree/TreeNodeIterator.php | 93 +++++++++++++++++++ 1 file changed, 93 insertions(+) create mode 100644 library/Icinga/Data/Tree/TreeNodeIterator.php diff --git a/library/Icinga/Data/Tree/TreeNodeIterator.php b/library/Icinga/Data/Tree/TreeNodeIterator.php new file mode 100644 index 000000000..cdcefe8ea --- /dev/null +++ b/library/Icinga/Data/Tree/TreeNodeIterator.php @@ -0,0 +1,93 @@ +children = new ArrayIterator($node->getChildren()); + } + + /** + * (non-PHPDoc) + * @see \RecursiveIterator::current() For the method documentation. + */ + public function current() + { + return $this->children->current(); + } + + /** + * (non-PHPDoc) + * @see \RecursiveIterator::key() For the method documentation. + */ + public function key() + { + return $this->children->key(); + } + + /** + * (non-PHPDoc) + * @see \RecursiveIterator::next() For the method documentation. + */ + public function next() + { + $this->children->next(); + } + + /** + * (non-PHPDoc) + * @see \RecursiveIterator::rewind() For the method documentation. + */ + public function rewind() + { + $this->children->rewind(); + } + + /** + * (non-PHPDoc) + * @see \RecursiveIterator::valid() For the method documentation. + */ + public function valid() + { + return $this->children->valid(); + } + + /** + * (non-PHPDoc) + * @see \RecursiveIterator::hasChildren() For the method documentation. + */ + public function hasChildren() + { + return $this->current()->hasChildren(); + } + + /** + * (non-PHPDoc) + * @see \RecursiveIterator::getChildren() For the method documentation. + */ + public function getChildren() + { + return new static($this->current()); + } +} From 95c937e3fd1c93a58bd21fa45e3b991c419bba4e Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Fri, 6 Feb 2015 17:24:01 +0100 Subject: [PATCH 0568/2920] lib/doc: Fix code style for doc exceptions --- .../doc/library/Doc/Exception/ChapterNotFoundException.php | 4 +++- modules/doc/library/Doc/Exception/DocEmptyException.php | 4 +++- modules/doc/library/Doc/Exception/DocException.php | 4 +++- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/modules/doc/library/Doc/Exception/ChapterNotFoundException.php b/modules/doc/library/Doc/Exception/ChapterNotFoundException.php index a1de9b496..5a5d41936 100644 --- a/modules/doc/library/Doc/Exception/ChapterNotFoundException.php +++ b/modules/doc/library/Doc/Exception/ChapterNotFoundException.php @@ -6,4 +6,6 @@ namespace Icinga\Module\Doc\Exception; /** * Exception thrown if a chapter was not found */ -class ChapterNotFoundException extends DocException {} +class ChapterNotFoundException extends DocException +{ +} diff --git a/modules/doc/library/Doc/Exception/DocEmptyException.php b/modules/doc/library/Doc/Exception/DocEmptyException.php index b4050e3e3..0ce563cf1 100644 --- a/modules/doc/library/Doc/Exception/DocEmptyException.php +++ b/modules/doc/library/Doc/Exception/DocEmptyException.php @@ -6,4 +6,6 @@ namespace Icinga\Module\Doc\Exception; /** * Exception thrown if a documentation directory is empty */ -class DocEmptyException extends DocException {} +class DocEmptyException extends DocException +{ +} diff --git a/modules/doc/library/Doc/Exception/DocException.php b/modules/doc/library/Doc/Exception/DocException.php index 672359591..f749fb7b3 100644 --- a/modules/doc/library/Doc/Exception/DocException.php +++ b/modules/doc/library/Doc/Exception/DocException.php @@ -8,4 +8,6 @@ use RuntimeException; /** * Exception thrown if an error in the documentation module's library occurs */ -class DocException extends RuntimeException {} +class DocException extends RuntimeException +{ +} From 0d63e14baf8184088713c3ce819741d022b45e5b Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Fri, 6 Feb 2015 17:27:14 +0100 Subject: [PATCH 0569/2920] lib: Rename Node to TreeNode refs #6630 --- library/Icinga/Data/Tree/{Node.php => TreeNode.php} | 6 +++--- library/Icinga/Data/Tree/TreeNodeIterator.php | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) rename library/Icinga/Data/Tree/{Node.php => TreeNode.php} (91%) diff --git a/library/Icinga/Data/Tree/Node.php b/library/Icinga/Data/Tree/TreeNode.php similarity index 91% rename from library/Icinga/Data/Tree/Node.php rename to library/Icinga/Data/Tree/TreeNode.php index ad1db9c36..fcf257e55 100644 --- a/library/Icinga/Data/Tree/Node.php +++ b/library/Icinga/Data/Tree/TreeNode.php @@ -6,7 +6,7 @@ namespace Icinga\Data\Tree; use Identifiable; use IteratorAggregate; -class Node implements Identifiable, IteratorAggregate +class TreeNode implements Identifiable, IteratorAggregate { /** * The node's ID @@ -77,11 +77,11 @@ class Node implements Identifiable, IteratorAggregate /** * Append a child node as the last child of this node * - * @param Node $child The child to append + * @param TreeNode $child The child to append * * @return $this */ - public function appendChild(Node $child) + public function appendChild(TreeNode $child) { $this->children[] = $child; return $this; diff --git a/library/Icinga/Data/Tree/TreeNodeIterator.php b/library/Icinga/Data/Tree/TreeNodeIterator.php index cdcefe8ea..b0b0b0f83 100644 --- a/library/Icinga/Data/Tree/TreeNodeIterator.php +++ b/library/Icinga/Data/Tree/TreeNodeIterator.php @@ -21,9 +21,9 @@ class TreeNodeIterator implements RecursiveIterator /** * Create a new iterator over a tree node's children * - * @param Node $node + * @param TreeNode $node */ - public function __construct(Node $node) + public function __construct(TreeNode $node) { $this->children = new ArrayIterator($node->getChildren()); } From ecfda1a6f5077b4b0494fc3af90bdfd894faf8bf Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Fri, 6 Feb 2015 17:29:04 +0100 Subject: [PATCH 0570/2920] lib/doc: Rename Section to DocSection and let it extend TreeNode refs #6630 --- .../Doc/{Section.php => DocSection.php} | 85 ++++++++----------- 1 file changed, 36 insertions(+), 49 deletions(-) rename modules/doc/library/Doc/{Section.php => DocSection.php} (50%) diff --git a/modules/doc/library/Doc/Section.php b/modules/doc/library/Doc/DocSection.php similarity index 50% rename from modules/doc/library/Doc/Section.php rename to modules/doc/library/Doc/DocSection.php index 32f836c33..237b487fc 100644 --- a/modules/doc/library/Doc/Section.php +++ b/modules/doc/library/Doc/DocSection.php @@ -3,81 +3,52 @@ namespace Icinga\Module\Doc; -use Icinga\Data\Identifiable; +use Icinga\Data\Tree\TreeNode; /** * A section of a documentation */ -class Section implements Identifiable +class DocSection extends TreeNode { - /** - * The ID of the section - * - * @var string - */ - protected $id; - /** * The title of the section * - * @var string + * @type string */ protected $title; /** * The header level * - * @var int + * @type int */ protected $level; /** * Whether to instruct search engines to not index the link to the section * - * @var bool + * @type bool */ protected $noFollow; - /** - * The ID of the chapter the section is part of - * - * @var string - */ - protected $chapterId; - /** * The content of the section * - * @var array + * @type array */ protected $content = array(); /** - * Create a new section + * Set the title of the section * - * @param string $id The ID of the section - * @param string $title The title of the section - * @param int $level The header level - * @param bool $noFollow Whether to instruct search engines to not index the link to the section - * @param string $chapterId The ID of the chapter the section is part of - */ - public function __construct($id, $title, $level, $noFollow, $chapterId) - { - $this->id = $id; - $this->title = $title; - $this->level = $level; - $this->noFollow = $noFollow; - $this->chapterId= $chapterId; - } - - /** - * Get the ID of the section + * @param string $title Title of the section * - * @return string + * @return $this */ - public function getId() + public function setTitle($title) { - return $this->id; + $this->title = (string) $title; + return $this; } /** @@ -90,6 +61,19 @@ class Section implements Identifiable return $this->title; } + /** + * Set the header level + * + * @param int $level Header level + * + * @return $this + */ + public function setLevel($level) + { + $this->level = (int) $level; + return $this; + } + /** * Get the header level * @@ -101,23 +85,26 @@ class Section implements Identifiable } /** - * Whether to instruct search engines to not index the link to the section + * Set whether to instruct search engines to not index the link to the section * - * @return bool + * @param bool $noFollow Whether to instruct search engines to not index the link to the section + * + * @return $this */ - public function isNoFollow() + public function setNoFollow($noFollow = true) { - return $this->noFollow; + $this->noFollow = (bool) $noFollow; + return $this; } /** - * The ID of the chapter the section is part of + * Get whether to instruct search engines to not index the link to the section * - * @return string + * @return bool */ - public function getChapterId() + public function getNoFollow() { - return $this->chapterId; + return $this->noFollow; } /** From 3a4c6e45b823f9f8ecee54600c256aa9aad14f73 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Fri, 6 Feb 2015 17:32:51 +0100 Subject: [PATCH 0571/2920] Fix Fatal error: Interface 'Identifiable' not found refs #6630 --- library/Icinga/Data/Tree/TreeNode.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library/Icinga/Data/Tree/TreeNode.php b/library/Icinga/Data/Tree/TreeNode.php index fcf257e55..61008a66d 100644 --- a/library/Icinga/Data/Tree/TreeNode.php +++ b/library/Icinga/Data/Tree/TreeNode.php @@ -3,8 +3,8 @@ namespace Icinga\Data\Tree; -use Identifiable; use IteratorAggregate; +use Icinga\Data\Identifiable; class TreeNode implements Identifiable, IteratorAggregate { From 58d48d9fa048c673b63903291afdc4b10d70825c Mon Sep 17 00:00:00 2001 From: Alexander Klimov Date: Fri, 6 Feb 2015 17:48:21 +0100 Subject: [PATCH 0572/2920] Accessibility: Text cue for required form control labels: Add prototype refs #7934 --- ...-cue-for-required-form-control-labels.html | 36 +++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 doc/accessibility/text-cue-for-required-form-control-labels.html diff --git a/doc/accessibility/text-cue-for-required-form-control-labels.html b/doc/accessibility/text-cue-for-required-form-control-labels.html new file mode 100644 index 000000000..b9e624208 --- /dev/null +++ b/doc/accessibility/text-cue-for-required-form-control-labels.html @@ -0,0 +1,36 @@ + + + + + + Accessibility: Text cue for required form control labels + + + + + +
    + + + +
    + + \ No newline at end of file From 23ce15668197c5217d79cbc227a349f49608595d Mon Sep 17 00:00:00 2001 From: Michael Friedrich Date: Sat, 7 Feb 2015 21:15:26 +0100 Subject: [PATCH 0573/2920] doc/installation: Add a note where to store the webserver's config --- doc/installation.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/doc/installation.md b/doc/installation.md index d9483faef..aa85adb22 100644 --- a/doc/installation.md +++ b/doc/installation.md @@ -55,6 +55,14 @@ nginx: ./bin/icingacli setup config webserver nginx --document-root /usr/share/icingaweb2/public ```` +Save the output as new file in your webserver's configuration directory. + +Example for Apache on RHEL/CentOS: +```` +./bin/icingacli setup config webserver apache --document-root /usr/share/icingaweb2/public > /etc/httpd/conf.d/icingaweb2.conf +```` + + **Step 4: Preparing Web Setup** Because both web and CLI must have access to configuration and logs, permissions will be managed using a special From 4c9374cccafc58408c3d8b8b07f251aabbd0359a Mon Sep 17 00:00:00 2001 From: Michael Friedrich Date: Sun, 8 Feb 2015 16:03:08 +0100 Subject: [PATCH 0574/2920] spec: Install doc and translation module fixes #8392 --- icingaweb2.spec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/icingaweb2.spec b/icingaweb2.spec index 1d97819d9..231b2642e 100644 --- a/icingaweb2.spec +++ b/icingaweb2.spec @@ -189,7 +189,7 @@ rm -rf %{buildroot} mkdir -p %{buildroot}/{%{basedir}/{modules,library,public},%{bindir},%{configdir}/modules/setup,%{logdir},%{phpdir},%{wwwconfigdir},%{_sysconfdir}/bash_completion.d,%{docsdir}} cp -prv application doc %{buildroot}/%{basedir} cp -pv etc/bash_completion.d/icingacli %{buildroot}/%{_sysconfdir}/bash_completion.d/icingacli -cp -prv modules/{monitoring,setup} %{buildroot}/%{basedir}/modules +cp -prv modules/{monitoring,setup,doc,translation} %{buildroot}/%{basedir}/modules cp -prv library/Icinga %{buildroot}/%{phpdir} cp -prv library/vendor %{buildroot}/%{basedir}/library cp -prv public/{css,img,js,error_norewrite.html} %{buildroot}/%{basedir}/public From d10beb7604875f39d96a9a7dd85af1e065b3237e Mon Sep 17 00:00:00 2001 From: Thomas Gelf Date: Mon, 9 Feb 2015 15:26:55 +0100 Subject: [PATCH 0575/2920] js: no console.log. please! --- public/js/icinga/loader.js | 1 - public/js/icinga/utils.js | 2 -- 2 files changed, 3 deletions(-) diff --git a/public/js/icinga/loader.js b/public/js/icinga/loader.js index 6a82a6ee5..92aa1e9d8 100644 --- a/public/js/icinga/loader.js +++ b/public/js/icinga/loader.js @@ -737,7 +737,6 @@ } this.icinga.ui.assignUniqueContainerIds(); - console.log(origFocus); if (origFocus.length == origFocus[0] !== '') { setTimeout(function() { $(self.icinga.utils.getElementByDomPath(origFocus)).focus(); diff --git a/public/js/icinga/utils.js b/public/js/icinga/utils.js index bd64e586e..4b04b3d44 100644 --- a/public/js/icinga/utils.js +++ b/public/js/icinga/utils.js @@ -284,10 +284,8 @@ if (! $element) { $element = $(selector); } else { - console.log(selector); $element = $element.children(selector).first(); if (! $element[0]) { - console.log("element not existing stopping..."); return false; } } From 7b1b5b9b40f54404c1e2d6108e92382120ff4843 Mon Sep 17 00:00:00 2001 From: Thomas Gelf Date: Mon, 9 Feb 2015 15:27:50 +0100 Subject: [PATCH 0576/2920] Authentication\Manager: do not override user groups Needs more care, but this way we are at least able to fetch groups unless we get out improved implementation. --- library/Icinga/Authentication/Manager.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library/Icinga/Authentication/Manager.php b/library/Icinga/Authentication/Manager.php index 81221176e..993475636 100644 --- a/library/Icinga/Authentication/Manager.php +++ b/library/Icinga/Authentication/Manager.php @@ -84,7 +84,7 @@ class Manager $preferences = new Preferences(); } $user->setPreferences($preferences); - $groups = array(); + $groups = $user->getGroups(); foreach (Config::app('groups') as $name => $config) { try { $groupBackend = UserGroupBackend::create($name, $config); From 81f65a7cd4dadab8e31f4aa41092649551a8f20e Mon Sep 17 00:00:00 2001 From: Thomas Gelf Date: Mon, 9 Feb 2015 15:29:52 +0100 Subject: [PATCH 0577/2920] LdapUserBackend: disable "health check" I see no point in checking this at every login. It could however be a nice addition for our config backends and the setup wizard. I'd also opt for completely removing this parameter - who wants to use this method should explicitely call it. --- library/Icinga/Authentication/Backend/LdapUserBackend.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library/Icinga/Authentication/Backend/LdapUserBackend.php b/library/Icinga/Authentication/Backend/LdapUserBackend.php index 7fde1f61b..016512ab4 100644 --- a/library/Icinga/Authentication/Backend/LdapUserBackend.php +++ b/library/Icinga/Authentication/Backend/LdapUserBackend.php @@ -170,7 +170,7 @@ class LdapUserBackend extends UserBackend * * @throws AuthenticationException In case an error occured or the health check has failed */ - public function authenticate(User $user, $password, $healthCheck = true) + public function authenticate(User $user, $password, $healthCheck = false) { if ($healthCheck) { try { From 88315db1ebafc2e9d61711d2a114e44f2fbd7f17 Mon Sep 17 00:00:00 2001 From: Thomas Gelf Date: Mon, 9 Feb 2015 15:31:47 +0100 Subject: [PATCH 0578/2920] UserBackend: reasonable defaults for AD groups I didn't do farther research, but those values seem to work fine. --- library/Icinga/Authentication/UserBackend.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/library/Icinga/Authentication/UserBackend.php b/library/Icinga/Authentication/UserBackend.php index b8bde164d..cb6eb458b 100644 --- a/library/Icinga/Authentication/UserBackend.php +++ b/library/Icinga/Authentication/UserBackend.php @@ -93,10 +93,10 @@ abstract class UserBackend implements Countable break; case 'msldap': $groupOptions = array( - 'group_base_dn' => $backendConfig->group_base_dn, - 'group_attribute' => $backendConfig->group_attribute, - 'group_member_attribute' => $backendConfig->group_member_attribute, - 'group_class' => $backendConfig->group_class + 'group_base_dn' => $backendConfig->get('group_base_dn', $resource->getDN()), + 'group_attribute' => $backendConfig->get('group_attribute', 'sAMAccountName'), + 'group_member_attribute' => $backendConfig->get('group_member_attribute', 'member'), + 'group_class' => $backendConfig->get('group_class', 'group') ); $backend = new LdapUserBackend( $resource, From 5bf89da6d7ed8956c180289bae4bb8b173cf9c58 Mon Sep 17 00:00:00 2001 From: Thomas Gelf Date: Mon, 9 Feb 2015 15:38:43 +0100 Subject: [PATCH 0579/2920] PluginOutput: simplify code, add tab support refs #8366 --- .../views/helpers/PluginOutput.php | 46 +++++++++++-------- 1 file changed, 28 insertions(+), 18 deletions(-) diff --git a/modules/monitoring/application/views/helpers/PluginOutput.php b/modules/monitoring/application/views/helpers/PluginOutput.php index e6c8b2d5a..d494a7810 100644 --- a/modules/monitoring/application/views/helpers/PluginOutput.php +++ b/modules/monitoring/application/views/helpers/PluginOutput.php @@ -5,34 +5,44 @@ class Zend_View_Helper_PluginOutput extends Zend_View_Helper_Abstract { protected static $purifier; + protected static $txtPatterns = array( + '~\\\n~', + '~\\\t~', + '~\\\n\\\n~', + '~(\[|\()OK(\]|\))~', + '~(\[|\()WARNING(\]|\))~', + '~(\[|\()CRITICAL(\]|\))~', + '~(\[|\()UNKNOWN(\]|\))~', + '~\@{6,}~' + ); + + protected static $txtReplacements = array( + "\n", + "\t", + "\n", + '$1OK$2', + '$1WARNING$2', + '$1CRITICAL$2', + '$1UNKNOWN$2', + '@@@@@@', + ); + public function pluginOutput($output) { if (empty($output)) { return ''; } $output = preg_replace('~]+>~', "\n", $output); - if (preg_match('~<\w+[^>]*>~', $output)) { + if (preg_match('~<\w+[^>^\\\]{,60}>~', $output)) { // HTML $output = preg_replace('~getPurifier()->purify($output) ); - } elseif (preg_match('~\\\n~', $output)) { - // Plaintext - $output = '
    '
    -               . preg_replace(
    -              '~\\\n~', "\n", preg_replace(
    -                '~\\\n\\\n~', "\n",
    -                preg_replace('~\[OK\]~', '[OK]',
    -                 preg_replace('~\[WARNING\]~', '[WARNING]',
    -                  preg_replace('~\[CRITICAL\]~', '[CRITICAL]',
    -                   preg_replace('~\@{6,}~', '@@@@@@',
    -                     $this->view->escape($output)
    -                ))))
    -              )
    -            ) . '
    '; } else { - $output = '
    '
    -               . preg_replace('~\@{6,}~', '@@@@@@',
    +            // Plaintext
    +            $output = '
    ' . preg_replace(
    +                self::$txtPatterns,
    +                self::$txtReplacements,
                     $this->view->escape($output)
                 ) . '
    '; } @@ -55,7 +65,7 @@ class Zend_View_Helper_PluginOutput extends Zend_View_Helper_Abstract parse_str($m[1], $params); if (isset($params['host'])) { $tag->setAttribute('href', $this->view->baseUrl( - '/monitoring/detail/show?host=' . urlencode($params['host'] + '/monitoring/host/show?host=' . urlencode($params['host'] ))); } } else { From b2ace4e209ab400a0dc8ccb2d102f18d5109260f Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Tue, 10 Feb 2015 16:58:40 +0100 Subject: [PATCH 0580/2920] doc: Remove DocTree class It will be replaced by a class in our lib refs #6630 --- modules/doc/library/Doc/DocTree.php | 79 ----------------------------- 1 file changed, 79 deletions(-) delete mode 100644 modules/doc/library/Doc/DocTree.php diff --git a/modules/doc/library/Doc/DocTree.php b/modules/doc/library/Doc/DocTree.php deleted file mode 100644 index 66b36f1a4..000000000 --- a/modules/doc/library/Doc/DocTree.php +++ /dev/null @@ -1,79 +0,0 @@ -getId(); - if (isset($this->nodes[$rootId])) { - $rootId = uniqid($rootId); -// throw new LogicException( -// sprintf('Can\'t add root node: a root node with the id \'%s\' already exists', $rootId) -// ); - } - $this->nodes[$rootId] = $this->appendChild($root); - } - - /** - * Append a child node to a parent node - * - * @param Identifiable $child - * @param Identifiable $parent - * - * @throws LogicException If the the tree does not contain the parent node - */ - public function addChild(Identifiable $child, Identifiable $parent) - { - $childId = $child->getId(); - $parentId = $parent->getId(); - if (isset($this->nodes[$childId])) { - $childId = uniqid($childId); -// throw new LogicException( -// sprintf('Can\'t add child node: a child node with the id \'%s\' already exists', $childId) -// ); - } - if (! isset($this->nodes[$parentId])) { - throw new LogicException( - sprintf(mt('doc', 'Can\'t add child node: there\'s no parent node having the id \'%s\''), $parentId) - ); - } - $this->nodes[$childId] = $this->nodes[$parentId]->appendChild($child); - } - - /** - * Get a node - * - * @param mixed $id - * - * @return Node|null - */ - public function getNode($id) - { - if (! isset($this->nodes[$id])) { - return null; - } - return $this->nodes[$id]; - } -} From fd38e5b2e12f5b9b8efe7b2a8fed97cd238e68ae Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Tue, 10 Feb 2015 16:59:43 +0100 Subject: [PATCH 0581/2920] lib: Use @inheritdoc in the TreeNodeIterator refs #6630 --- library/Icinga/Data/Tree/TreeNodeIterator.php | 22 +++++++------------ 1 file changed, 8 insertions(+), 14 deletions(-) diff --git a/library/Icinga/Data/Tree/TreeNodeIterator.php b/library/Icinga/Data/Tree/TreeNodeIterator.php index b0b0b0f83..753b338f6 100644 --- a/library/Icinga/Data/Tree/TreeNodeIterator.php +++ b/library/Icinga/Data/Tree/TreeNodeIterator.php @@ -29,8 +29,7 @@ class TreeNodeIterator implements RecursiveIterator } /** - * (non-PHPDoc) - * @see \RecursiveIterator::current() For the method documentation. + * {@inheritdoc} */ public function current() { @@ -38,8 +37,7 @@ class TreeNodeIterator implements RecursiveIterator } /** - * (non-PHPDoc) - * @see \RecursiveIterator::key() For the method documentation. + * {@inheritdoc} */ public function key() { @@ -47,8 +45,7 @@ class TreeNodeIterator implements RecursiveIterator } /** - * (non-PHPDoc) - * @see \RecursiveIterator::next() For the method documentation. + * {@inheritdoc} */ public function next() { @@ -56,8 +53,7 @@ class TreeNodeIterator implements RecursiveIterator } /** - * (non-PHPDoc) - * @see \RecursiveIterator::rewind() For the method documentation. + * {@inheritdoc} */ public function rewind() { @@ -65,8 +61,7 @@ class TreeNodeIterator implements RecursiveIterator } /** - * (non-PHPDoc) - * @see \RecursiveIterator::valid() For the method documentation. + * {@inheritdoc} */ public function valid() { @@ -74,8 +69,7 @@ class TreeNodeIterator implements RecursiveIterator } /** - * (non-PHPDoc) - * @see \RecursiveIterator::hasChildren() For the method documentation. + * {@inheritdoc} */ public function hasChildren() { @@ -83,8 +77,8 @@ class TreeNodeIterator implements RecursiveIterator } /** - * (non-PHPDoc) - * @see \RecursiveIterator::getChildren() For the method documentation. + * {@inheritdoc} + * @return TreeNodeIterator */ public function getChildren() { From b18405e99f5e0ee25cbd58272f7c678b8a40057e Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Tue, 10 Feb 2015 17:00:47 +0100 Subject: [PATCH 0582/2920] lib: Add SimpleTree Simple tree implementation for TreeNodes. refs #6630 --- library/Icinga/Data/Tree/SimpleTree.php | 90 +++++++++++++++++++++++++ 1 file changed, 90 insertions(+) create mode 100644 library/Icinga/Data/Tree/SimpleTree.php diff --git a/library/Icinga/Data/Tree/SimpleTree.php b/library/Icinga/Data/Tree/SimpleTree.php new file mode 100644 index 000000000..46a91135d --- /dev/null +++ b/library/Icinga/Data/Tree/SimpleTree.php @@ -0,0 +1,90 @@ +sentinel = new TreeNode(); + } + + /** + * Add a child node + * + * @param TreeNode $child + * @param TreeNode $parent + * + * @return $this + */ + public function addChild(TreeNode $child, TreeNode $parent = null) + { + if ($parent === null) { + $parent = $this->sentinel; + } elseif (! isset($this->nodes[$parent->getId()])) { + throw new LogicException(sprintf( + 'Can\'t append child node %s to parent node %s: Parent node does not exist', + $child->getId(), + $parent->getId() + )); + } + if (isset($this->nodes[$child->getId()])) { + throw new LogicException(sprintf( + 'Can\'t append child node %s to parent node %s: Child node does already exist', + $child->getId(), + $parent->getId() + )); + } + $this->nodes[$child->getId()] = $child; + $parent->appendChild($child); + return $this; + } + + /** + * Get a node by its ID + * + * @param mixed $id + * + * @return TreeNode|null + */ + public function getNode($id) + { + if (! isset($this->nodes[$id])) { + return null; + } + return $this->nodes[$id]; + } + + /** + * {@inheritdoc} + * @return TreeNodeIterator + */ + public function getIterator() + { + return new TreeNodeIterator($this->sentinel); + } +} From 760819f239273c46138a48f486dfb98335ab470a Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Tue, 10 Feb 2015 17:01:32 +0100 Subject: [PATCH 0583/2920] lib: Remove TreeNode::getIterator() Its the tree who has the iterator. refs #6630 --- library/Icinga/Data/Tree/TreeNode.php | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/library/Icinga/Data/Tree/TreeNode.php b/library/Icinga/Data/Tree/TreeNode.php index 61008a66d..200b3b9a6 100644 --- a/library/Icinga/Data/Tree/TreeNode.php +++ b/library/Icinga/Data/Tree/TreeNode.php @@ -3,10 +3,9 @@ namespace Icinga\Data\Tree; -use IteratorAggregate; use Icinga\Data\Identifiable; -class TreeNode implements Identifiable, IteratorAggregate +class TreeNode implements Identifiable { /** * The node's ID @@ -107,13 +106,4 @@ class TreeNode implements Identifiable, IteratorAggregate { return $this->children; } - - /** - * (non-PHPDoc) - * @see IteratorAggregate::getIterator() For the method documentation. - */ - public function getIterator() - { - return new TreeNodeIterator($this); - } } From 8ad7a30cd7fe9b313ce91ced450be3cabc835b35 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Tue, 10 Feb 2015 17:02:17 +0100 Subject: [PATCH 0584/2920] doc: Fix link to resources in the authentication doc --- doc/authentication.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/doc/authentication.md b/doc/authentication.md index 175403061..604c85a2e 100644 --- a/doc/authentication.md +++ b/doc/authentication.md @@ -40,7 +40,7 @@ or LDAP configuration method. Directive | Description ------------------------|------------ **backend** | `ldap` -**resource** | The name of the LDAP resource defined in [resources.ini](resources). +**resource** | The name of the LDAP resource defined in [resources.ini](#resources). **user_class** | LDAP user class. **user_name_attribute** | LDAP attribute which contains the username. @@ -63,7 +63,7 @@ with Icinga Web 2 (e.g. an alias) no matter what the primary user id might actua Directive | Description ------------------------|------------ **backend** | `ad` -**resource** | The name of the LDAP resource defined in [resources.ini](resources). +**resource** | The name of the LDAP resource defined in [resources.ini](#resources). **Example:** @@ -82,7 +82,7 @@ authentication method. Directive | Description ------------------------|------------ **backend** | `db` -**resource** | The name of the database resource defined in [resources.ini](resources). +**resource** | The name of the database resource defined in [resources.ini](#resources). **Example:** From 322c6b582d2dd81cf89e4aed2cc81f275493257b Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Tue, 10 Feb 2015 17:02:37 +0100 Subject: [PATCH 0585/2920] lib: Prefer @type over @var in the FileExtensionFilterIterator --- library/Icinga/File/FileExtensionFilterIterator.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library/Icinga/File/FileExtensionFilterIterator.php b/library/Icinga/File/FileExtensionFilterIterator.php index cb26bb214..fd1d657b4 100644 --- a/library/Icinga/File/FileExtensionFilterIterator.php +++ b/library/Icinga/File/FileExtensionFilterIterator.php @@ -58,7 +58,7 @@ class FileExtensionFilterIterator extends FilterIterator public function accept() { $current = $this->current(); - /* @var $current \SplFileInfo */ + /** @type $current \SplFileInfo */ if (! $current->isFile()) { return false; } From 07cfbe23ef8d184cb885972d3b672619562a995b Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Tue, 10 Feb 2015 17:03:15 +0100 Subject: [PATCH 0586/2920] doc/lib: Use @inheritdoc in the DocIterator --- modules/doc/library/Doc/DocIterator.php | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/modules/doc/library/Doc/DocIterator.php b/modules/doc/library/Doc/DocIterator.php index c8be8e808..34358a89e 100644 --- a/modules/doc/library/Doc/DocIterator.php +++ b/modules/doc/library/Doc/DocIterator.php @@ -19,7 +19,7 @@ class DocIterator implements Countable, IteratorAggregate /** * Ordered files * - * @var array + * @type array */ protected $fileInfo; @@ -46,8 +46,7 @@ class DocIterator implements Countable, IteratorAggregate } /** - * (non-PHPDoc) - * @see Countable::count() + * {@inheritdoc} */ public function count() { @@ -55,8 +54,7 @@ class DocIterator implements Countable, IteratorAggregate } /** - * (non-PHPDoc) - * @see IteratorAggregate::getIterator() + * {@inheritdoc} */ public function getIterator() { From 9f3b95316569aae7c350e7bb1af48b2d62fe5f38 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Tue, 10 Feb 2015 17:03:58 +0100 Subject: [PATCH 0587/2920] doc/lib: Support setting the chapter a section belongs to refs #6630 --- modules/doc/library/Doc/DocSection.php | 76 ++++++++++++++++++-------- 1 file changed, 53 insertions(+), 23 deletions(-) diff --git a/modules/doc/library/Doc/DocSection.php b/modules/doc/library/Doc/DocSection.php index 237b487fc..4b97db282 100644 --- a/modules/doc/library/Doc/DocSection.php +++ b/modules/doc/library/Doc/DocSection.php @@ -11,14 +11,21 @@ use Icinga\Data\Tree\TreeNode; class DocSection extends TreeNode { /** - * The title of the section + * Chapter the section belongs to * - * @type string + * @type DocSection */ - protected $title; + protected $chapter; /** - * The header level + * Content of the section + * + * @type array + */ + protected $content = array(); + + /** + * Header level * * @type int */ @@ -32,33 +39,53 @@ class DocSection extends TreeNode protected $noFollow; /** - * The content of the section + * Title of the section * - * @type array + * @type string */ - protected $content = array(); + protected $title; /** - * Set the title of the section + * Set the chapter the section belongs to * - * @param string $title Title of the section + * @param DocSection $section * * @return $this */ - public function setTitle($title) + public function setChapter(DocSection $section) { - $this->title = (string) $title; + $this->chapter = $section; return $this; } /** - * Get the title of the section + * Get the chapter the section belongs to * - * @return string + * @return DocSection */ - public function getTitle() + public function getChapter() { - return $this->title; + return $this->chapter; + } + + /** + * Append content + * + * @param string $content + */ + public function appendContent($content) + { + $this->content[] = $content; + } + + /** + * Get the content of the section + * + * @return array + */ + public function getContent() + { + return $this->content; } /** @@ -108,22 +135,25 @@ class DocSection extends TreeNode } /** - * Append content + * Set the title of the section * - * @param string $content + * @param string $title Title of the section + * + * @return $this */ - public function appendContent($content) + public function setTitle($title) { - $this->content[] = $content; + $this->title = (string) $title; + return $this; } /** - * Get the content of the section + * Get the title of the section * - * @return array + * @return string */ - public function getContent() + public function getTitle() { - return $this->content; + return $this->title; } } From c95838a33d54a44fa53ce1febc7603207cbb476b Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Tue, 10 Feb 2015 17:04:27 +0100 Subject: [PATCH 0588/2920] doc/lib: Use SimpleTree in the DocParser refs #6630 --- modules/doc/library/Doc/DocParser.php | 31 ++++++++++++++++----------- 1 file changed, 19 insertions(+), 12 deletions(-) diff --git a/modules/doc/library/Doc/DocParser.php b/modules/doc/library/Doc/DocParser.php index 4b6ec7de9..b0384a3d4 100644 --- a/modules/doc/library/Doc/DocParser.php +++ b/modules/doc/library/Doc/DocParser.php @@ -3,7 +3,8 @@ namespace Icinga\Module\Doc; -use SplDoublyLinkedList; +use SplStack; +use Icinga\Data\Tree\SimpleTree; use Icinga\Exception\NotReadableError; use Icinga\Module\Doc\Exception\DocEmptyException; use Icinga\Module\Doc\Exception\DocException; @@ -121,16 +122,15 @@ class DocParser /** * Get the documentation tree * - * @return DocTree + * @return SimpleTree */ public function getDocTree() { - $tree = new DocTree(); - $stack = new SplDoublyLinkedList(); + $tree = new SimpleTree(); + $stack = new SplStack(); foreach ($this->docIterator as $fileInfo) { - /* @var $file \SplFileInfo */ + /** @type $fileInfo \SplFileInfo */ $file = $fileInfo->openFile(); - /* @var $file \SplFileObject */ $lastLine = null; foreach ($file as $line) { $header = $this->extractHeader($line, $lastLine); @@ -142,7 +142,7 @@ class DocParser if ($id === null) { $path = array(); foreach ($stack as $section) { - /* @var $section Section */ + /** @type $section DocSection */ $path[] = $section->getTitle(); } $path[] = $title; @@ -151,13 +151,20 @@ class DocParser } else { $noFollow = false; } + if ($tree->getNode($id) !== null) { + $id = uniqid($id); + } + $section = new DocSection(); + $section + ->setId($id) + ->setTitle($title) + ->setLevel($level) + ->setNoFollow($noFollow); if ($stack->isEmpty()) { - $chapterId = $id; - $section = new Section($id, $title, $level, $noFollow, $chapterId); - $tree->addRoot($section); + $section->setChapter($section); + $tree->addChild($section); } else { - $chapterId = $stack->bottom()->getId(); - $section = new Section($id, $title, $level, $noFollow, $chapterId); + $section->setChapter($stack->bottom()); $tree->addChild($section, $stack->top()); } $stack->push($section); From 377685d8024c8cd6e563a0eb4c79515b6f0b9053 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Tue, 10 Feb 2015 17:04:46 +0100 Subject: [PATCH 0589/2920] doc/lib: Let DocException extend IcingaException --- modules/doc/library/Doc/Exception/DocException.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/doc/library/Doc/Exception/DocException.php b/modules/doc/library/Doc/Exception/DocException.php index f749fb7b3..c7d895261 100644 --- a/modules/doc/library/Doc/Exception/DocException.php +++ b/modules/doc/library/Doc/Exception/DocException.php @@ -3,11 +3,11 @@ namespace Icinga\Module\Doc\Exception; -use RuntimeException; +use Icinga\Exception\IcingaException; /** * Exception thrown if an error in the documentation module's library occurs */ -class DocException extends RuntimeException +class DocException extends IcingaException { } From 9093795f646d1b2d34f1b1d2cfb0e5de8ad7e95c Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Tue, 10 Feb 2015 17:05:24 +0100 Subject: [PATCH 0590/2920] doc/lib: Add common used methods to the abstract Renderer refs #6630 --- modules/doc/library/Doc/Renderer.php | 118 +++++++++++++++++++++++++-- 1 file changed, 111 insertions(+), 7 deletions(-) diff --git a/modules/doc/library/Doc/Renderer.php b/modules/doc/library/Doc/Renderer.php index fee74048d..e2329c4dc 100644 --- a/modules/doc/library/Doc/Renderer.php +++ b/modules/doc/library/Doc/Renderer.php @@ -3,8 +3,9 @@ namespace Icinga\Module\Doc; +use Exception; use RecursiveIteratorIterator; -use Zend_View_Helper_Url; +use Icinga\Application\Icinga; use Icinga\Web\View; /** @@ -12,6 +13,99 @@ use Icinga\Web\View; */ abstract class Renderer extends RecursiveIteratorIterator { + /** + * URL to replace links with + * + * @type string + */ + protected $url; + + /** + * Additional URL parameters + * + * @type array + */ + protected $urlParams = array(); + + /** + * View + * + * @type View|null + */ + protected $view; + + /** + * Set the URL to replace links with + * + * @param string $url + * + * @return $this + */ + public function setUrl($url) + { + $this->url = (string) $url; + return $this; + } + + /** + * Get the URL to replace links with + * + * @return string + */ + public function getUrl() + { + return $this->url; + } + + /** + * Set additional URL parameters + * + * @param array $urlParams + * + * @return $this + */ + public function setUrlParams(array $urlParams) + { + $this->urlParams = array_map(array($this, 'encodeUrlParam'), $urlParams); + return $this; + } + + /** + * Get additional URL parameters + * + * @return array + */ + public function getUrlParams() + { + return $this->urlParams; + } + + /** + * Set the view + * + * @param View $view + * + * @return $this + */ + public function setView(View $view) + { + $this->view = $view; + return $this; + } + + /** + * Get the view + * + * @return View + */ + public function getView() + { + if ($this->view === null) { + $this->view = Icinga::app()->getViewRenderer()->view; + } + return $this->view; + } + /** * Encode an anchor identifier * @@ -63,12 +157,22 @@ abstract class Renderer extends RecursiveIteratorIterator /** * Render to HTML * - * Meant to be overwritten by concrete classes. - * - * @param View $view - * @param Zend_View_Helper_Url $zendUrlHelper - * * @return string */ - abstract public function render(View $view, Zend_View_Helper_Url $zendUrlHelper); + abstract public function render(); + + /** + * Render to HTML + * + * @return string + * @see \Icinga\Module\Doc\Renderer::render() For the render method. + */ + public function __toString() + { + try { + return $this->render(); + } catch (Exception $e) { + return $e->getMessage(); + } + } } From 52de56fb65fae85b5944a9165ecfaccc8e80e677 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Tue, 10 Feb 2015 17:06:11 +0100 Subject: [PATCH 0591/2920] doc/lib: Use TreeNodeIterator in the SectionFilterIterator refs #6630 --- .../doc/library/Doc/SectionFilterIterator.php | 50 ++++++++++++------- 1 file changed, 31 insertions(+), 19 deletions(-) diff --git a/modules/doc/library/Doc/SectionFilterIterator.php b/modules/doc/library/Doc/SectionFilterIterator.php index 0db620120..77171a5c8 100644 --- a/modules/doc/library/Doc/SectionFilterIterator.php +++ b/modules/doc/library/Doc/SectionFilterIterator.php @@ -5,30 +5,34 @@ namespace Icinga\Module\Doc; use Countable; use RecursiveFilterIterator; -use Icinga\Data\Tree\NodeInterface; +use Icinga\Data\Tree\TreeNodeIterator; /** - * Recursive iterator over sections that are part of a particular chapter + * Recursive filter iterator over sections that are part of a particular chapter + * + * @method TreeNodeIterator getInnerIterator() { + * {@inheritdoc} + * } */ class SectionFilterIterator extends RecursiveFilterIterator implements Countable { /** - * The chapter ID to filter for + * Chapter to filter for * - * @var string + * @type string */ - protected $chapterId; + protected $chapter; /** - * Create a new SectionFilterIterator + * Create a new recursive filter iterator over sections that are part of a particular chapter * - * @param NodeInterface $node Node - * @param string $chapterId The chapter ID to filter for + * @param TreeNodeIterator $iterator + * @param string $chapter The chapter to filter for */ - public function __construct(NodeInterface $node, $chapterId) + public function __construct(TreeNodeIterator $iterator, $chapter) { - parent::__construct($node); - $this->chapterId = $chapterId; + parent::__construct($iterator); + $this->chapter = $chapter; } /** @@ -39,29 +43,37 @@ class SectionFilterIterator extends RecursiveFilterIterator implements Countable */ public function accept() { - $section = $this->getInnerIterator()->current()->getValue(); - /* @var $section \Icinga\Module\Doc\Section */ - if ($section->getChapterId() === $this->chapterId) { + $section = $this->current(); + /** @type \Icinga\Module\Doc\DocSection $section */ + if ($section->getChapter()->getId() === $this->chapter) { return true; } return false; } /** - * (non-PHPDoc) - * @see RecursiveFilterIterator::getChildren() + * {@inheritdoc} */ public function getChildren() { - return new static($this->getInnerIterator()->getChildren(), $this->chapterId); + return new static($this->getInnerIterator()->getChildren(), $this->chapter); } /** - * (non-PHPDoc) - * @see Countable::count() + * {@inheritdoc} */ public function count() { return iterator_count($this); } + + /** + * Whether the filter swallowed every section + * + * @return bool + */ + public function isEmpty() + { + return $this->count() === 0; + } } From 5965638e2322764258d236e27a93dd11a23e045a Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Tue, 10 Feb 2015 17:07:24 +0100 Subject: [PATCH 0592/2920] doc/lib: Open toc links in the next container refs #6630 --- modules/doc/library/Doc/TocRenderer.php | 74 ++++++++++++------------- 1 file changed, 34 insertions(+), 40 deletions(-) diff --git a/modules/doc/library/Doc/TocRenderer.php b/modules/doc/library/Doc/TocRenderer.php index 69ab7ac02..cfa18fad0 100644 --- a/modules/doc/library/Doc/TocRenderer.php +++ b/modules/doc/library/Doc/TocRenderer.php @@ -3,88 +3,81 @@ namespace Icinga\Module\Doc; -use RecursiveIteratorIterator; -use Zend_View_Helper_Url; use Icinga\Web\View; +use Icinga\Data\Tree\TreeNodeIterator; +use RecursiveIteratorIterator; /** * TOC renderer + * + * @method TreeNodeIterator getInnerIterator() { + * {@inheritdoc} + * } */ class TocRenderer extends Renderer { /** - * The URL to replace links with + * Content to render * - * @var string - */ - protected $url; - - /** - * Additional URL parameters - * - * @var array - */ - protected $urlParams; - - /** - * Content - * - * @var array + * @type array */ protected $content = array(); /** * Create a new toc renderer * - * @param DocTree $docTree The documentation tree - * @param string $url The URL to replace links with - * @param array $urlParams Additional URL parameters + * @param TreeNodeIterator $iterator */ - public function __construct(DocTree $docTree, $url, array $urlParams) + public function __construct(TreeNodeIterator $iterator) { - parent::__construct($docTree, RecursiveIteratorIterator::SELF_FIRST); - $this->url = $url; - $this->urlParams = array_map(array($this, 'encodeUrlParam'), $urlParams); + parent::__construct($iterator, RecursiveIteratorIterator::SELF_FIRST); } + /** + * {@inheritdoc} + */ public function beginIteration() { $this->content[] = ''; } + /** + * {@inheritdoc} + */ public function beginChildren() { $this->content[] = '
      '; } + /** + * {@inheritdoc} + */ public function endChildren() { - $this->content[] = '
    '; + $this->content[] = ''; } /** - * Render the toc - * - * @param View $view - * @param Zend_View_Helper_Url $zendUrlHelper - * - * @return string + * {@inheritdoc} */ - public function render(View $view, Zend_View_Helper_Url $zendUrlHelper) + public function render() { - foreach ($this as $node) { - $section = $node->getValue(); - /* @var $section \Icinga\Module\Doc\Section */ + $view = $this->getView(); + $zendUrlHelper = $view->getHelper('Url'); + foreach ($this as $section) { $path = $zendUrlHelper->url( array_merge( $this->urlParams, array( - 'chapterId' => $this->encodeUrlParam($section->getChapterId()) + 'chapter' => $this->encodeUrlParam($section->getChapter()->getId()) ) ), $this->url, @@ -92,14 +85,15 @@ class TocRenderer extends Renderer false ); $url = $view->url($path); + /** @type \Icinga\Web\Url $url */ $url->setAnchor($this->encodeAnchor($section->getId())); $this->content[] = sprintf( - '
  • %s', - $section->isNoFollow() ? 'rel="nofollow" ' : '', + '
  • %s', + $section->getNoFollow() ? 'rel="nofollow" ' : '', $url->getAbsoluteUrl(), $view->escape($section->getTitle()) ); - if (! $this->getInnerIterator()->current()->hasChildren()) { + if (! $section->hasChildren()) { $this->content[] = '
  • '; } } From 41355fe0e24b417ecb1953aa63f3564d868d3b14 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Tue, 10 Feb 2015 17:08:48 +0100 Subject: [PATCH 0593/2920] doc/lib: Drop navigation added to each section refs #6630 --- modules/doc/library/Doc/SectionRenderer.php | 296 ++++++-------------- 1 file changed, 89 insertions(+), 207 deletions(-) diff --git a/modules/doc/library/Doc/SectionRenderer.php b/modules/doc/library/Doc/SectionRenderer.php index b4d19f9fb..825754ad7 100644 --- a/modules/doc/library/Doc/SectionRenderer.php +++ b/modules/doc/library/Doc/SectionRenderer.php @@ -7,133 +7,54 @@ require_once 'Parsedown/Parsedown.php'; use DOMDocument; use DOMXPath; -use RecursiveIteratorIterator; use Parsedown; -use Zend_View_Helper_Url; +use RecursiveIteratorIterator; +use Icinga\Data\Tree\SimpleTree; use Icinga\Module\Doc\Exception\ChapterNotFoundException; use Icinga\Web\Url; use Icinga\Web\View; -/** - * preg_replace_callback helper to replace links - */ -class Callback -{ - protected $docTree; - - protected $view; - - protected $zendUrlHelper; - - protected $url; - - protected $urlParams; - - public function __construct( - DocTree $docTree, - View $view, - Zend_View_Helper_Url $zendUrlHelper, - $url, - array $urlParams) - { - $this->docTree = $docTree; - $this->view = $view; - $this->zendUrlHelper = $zendUrlHelper; - $this->url = $url; - $this->urlParams = $urlParams; - } - - public function render($match) - { - $node = $this->docTree->getNode(Renderer::decodeAnchor($match['fragment'])); - /* @var $node \Icinga\Data\Tree\Node */ - if ($node === null) { - return $match[0]; - } - $section = $node->getValue(); - /* @var $section \Icinga\Module\Doc\Section */ - $path = $this->zendUrlHelper->url( - array_merge( - $this->urlParams, - array( - 'chapterId' => SectionRenderer::encodeUrlParam($section->getChapterId()) - ) - ), - $this->url, - false, - false - ); - $url = $this->view->url($path); - $url->setAnchor(SectionRenderer::encodeAnchor($section->getId())); - return sprintf( - 'isNoFollow() ? 'rel="nofollow" ' : '', - $url->getAbsoluteUrl() - ); - } -} - /** * Section renderer */ class SectionRenderer extends Renderer { /** - * The documentation tree + * Content to render * - * @var DocTree - */ - protected $docTree; - - protected $tocUrl; - - /** - * The URL to replace links with - * - * @var string - */ - protected $url; - - /** - * Additional URL parameters - * - * @var array - */ - protected $urlParams; - - /** - * Parsedown instance - * - * @var Parsedown - */ - protected $parsedown; - - /** - * Content - * - * @var array + * @type array */ protected $content = array(); + /** + * Parsedown instance + * + * @type Parsedown + */ + protected $parsedown; + + /** + * Documentation tree + * + * @type SimpleTree + */ + protected $tree; + /** * Create a new section renderer * - * @param DocTree $docTree The documentation tree - * @param string|null $chapterId If not null, the chapter ID to filter for - * @param string $tocUrl - * @param string $url The URL to replace links with - * @param array $urlParams Additional URL parameters + * @param SimpleTree $tree The documentation tree + * @param string|null $chapter If not null, the chapter to filter for * * @throws ChapterNotFoundException If the chapter to filter for was not found */ - public function __construct(DocTree $docTree, $chapterId, $tocUrl, $url, array $urlParams) + public function __construct(SimpleTree $tree, $chapter = null) { - if ($chapterId !== null) { - $filter = new SectionFilterIterator($docTree, $chapterId); - if ($filter->count() === 0) { + if ($chapter !== null) { + $filter = new SectionFilterIterator($tree->getIterator(), $chapter); + if ($filter->isEmpty()) { throw new ChapterNotFoundException( - sprintf(mt('doc', 'Chapter \'%s\' not found'), $chapterId) + mt('doc', 'Chapter %s not found'), $chapter ); } parent::__construct( @@ -141,19 +62,16 @@ class SectionRenderer extends Renderer RecursiveIteratorIterator::SELF_FIRST ); } else { - parent::__construct($docTree, RecursiveIteratorIterator::SELF_FIRST); + parent::__construct($tree->getIterator(), RecursiveIteratorIterator::SELF_FIRST); } - $this->docTree = $docTree; - $this->tocUrl = $tocUrl; - $this->url = $url; - $this->urlParams = array_map(array($this, 'encodeUrlParam'), $urlParams); + $this->tree = $tree; $this->parsedown = Parsedown::instance(); } /** * Syntax highlighting for PHP code * - * @param $match + * @param array $match * * @return string */ @@ -162,6 +80,26 @@ class SectionRenderer extends Renderer return '
    ' . highlight_string(htmlspecialchars_decode($match[1]), true) . '
    '; } + /** + * Markup notes + * + * @param array $match + * + * @return string + */ + protected function markupNotes($match) + { + $doc = new DOMDocument(); + $doc->loadHTML($match[0]); + $xpath = new DOMXPath($doc); + $blockquote = $xpath->query('//blockquote[1]')->item(0); + /* @var $blockquote \DOMElement */ + if (strtolower(substr(trim($blockquote->nodeValue), 0, 5)) === 'note:') { + $blockquote->setAttribute('class', 'note'); + } + return $doc->saveXML($blockquote); + } + /** * Replace img src tags * @@ -180,40 +118,52 @@ class SectionRenderer extends Renderer return substr_replace($doc->saveXML($img), '', -2, 1); // Replace '/>' with '>' } - protected function blubb($match) - { - $doc = new DOMDocument(); - $doc->loadHTML($match[0]); - $xpath = new DOMXPath($doc); - $blockquote = $xpath->query('//blockquote[1]')->item(0); - /* @var $blockquote \DOMElement */ - if (strtolower(substr(trim($blockquote->nodeValue), 0, 5)) === 'note:') { - $blockquote->setAttribute('class', 'note'); - } - return $doc->saveXML($blockquote); - } - /** - * Render the section + * Replace link * - * @param View $view - * @param Zend_View_Helper_Url $zendUrlHelper - * @param bool $renderNavigation + * @param array $match * * @return string */ - public function render(View $view, Zend_View_Helper_Url $zendUrlHelper, $renderNavigation = true) + protected function replaceLink($match) { - $callback = new Callback($this->docTree, $view, $zendUrlHelper, $this->url, $this->urlParams); - $content = array(); - foreach ($this as $node) { - $section = $node->getValue(); - /* @var $section \Icinga\Module\Doc\Section */ - $content[] = sprintf( + if (($section = $this->tree->getNode($this->decodeAnchor($match['fragment']))) === null) { + return $match[0]; + } + /** @type $section \Icinga\Module\Doc\DocSection */ + $path = $this->getView()->getHelper('Url')->url( + array_merge( + $this->urlParams, + array( + 'chapter' => $this->encodeUrlParam($section->getChapter()->getId()) + ) + ), + $this->url, + false, + false + ); + $url = $this->getView()->url($path); + /** @type \Icinga\Web\Url $url */ + $url->setAnchor($this->encodeAnchor($section->getId())); + return sprintf( + '
    getNoFollow() ? 'rel="nofollow" ' : '', + $url->getAbsoluteUrl() + ); + } + + /** + * {@inheritdoc} + */ + public function render() + { + foreach ($this as $section) { + $this->content[] = sprintf( '%3$s', Renderer::encodeAnchor($section->getId()), $section->getLevel(), - $view->escape($section->getTitle()) + $this->getView()->escape($section->getTitle()) ); $html = preg_replace_callback( '#
    (.*?)
    #s', @@ -227,83 +177,15 @@ class SectionRenderer extends Renderer ); $html = preg_replace_callback( '#
    .+
    #ms', - array($this, 'blubb'), + array($this, 'markupNotes'), $html ); - $content[] = preg_replace_callback( + $this->content[] = preg_replace_callback( '/[^>]*?\s+)?href="(?:(?!http:\/\/)[^#]*)#(?P[^"]+)"/', - array($callback, 'render'), + array($this, 'replaceLink'), $html ); } - if ($renderNavigation) { - foreach ($this->docTree as $chapter) { - if ($chapter->getValue()->getId() === $section->getChapterId()) { - $navigation = array(''; - $content = array_merge($navigation, $content, $navigation); - break; - } - } - } - return implode("\n", $content); + return implode("\n", $this->content); } } From 005ef8c92f0a00b10cdfb70e4589debf582c0533 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Tue, 10 Feb 2015 17:09:56 +0100 Subject: [PATCH 0594/2920] doc/lib: Update controllers and views according to the recent changes refs #6630 --- .../controllers/IcingawebController.php | 9 ++--- .../controllers/ModuleController.php | 9 ++--- .../application/views/scripts/chapter.phtml | 2 +- .../views/scripts/module/chapter.phtml | 2 +- .../views/scripts/module/toc.phtml | 4 +- .../doc/application/views/scripts/toc.phtml | 4 +- modules/doc/configuration.php | 2 + modules/doc/library/Doc/DocController.php | 37 +++++++++---------- modules/doc/run.php | 4 +- 9 files changed, 36 insertions(+), 37 deletions(-) diff --git a/modules/doc/application/controllers/IcingawebController.php b/modules/doc/application/controllers/IcingawebController.php index 89afc0e59..31819239a 100644 --- a/modules/doc/application/controllers/IcingawebController.php +++ b/modules/doc/application/controllers/IcingawebController.php @@ -46,17 +46,16 @@ class Doc_IcingawebController extends DocController */ public function chapterAction() { - $chapterId = $this->getParam('chapterId'); - if ($chapterId === null) { + $chapter = $this->getParam('chapter'); + if ($chapter === null) { throw new Zend_Controller_Action_Exception( - sprintf($this->translate('Missing parameter \'%s\''), 'chapterId'), + sprintf($this->translate('Missing parameter %s'), 'chapter'), 404 ); } $this->renderChapter( $this->getPath(), - $chapterId, - 'doc/icingaweb/toc', + $chapter, 'doc/icingaweb/chapter' ); } diff --git a/modules/doc/application/controllers/ModuleController.php b/modules/doc/application/controllers/ModuleController.php index d0c760444..3b8e5e201 100644 --- a/modules/doc/application/controllers/ModuleController.php +++ b/modules/doc/application/controllers/ModuleController.php @@ -122,10 +122,10 @@ class Doc_ModuleController extends DocController { $module = $this->getParam('moduleName'); $this->assertModuleEnabled($module); - $chapterId = $this->getParam('chapterId'); - if ($chapterId === null) { + $chapter = $this->getParam('chapter'); + if ($chapter === null) { throw new Zend_Controller_Action_Exception( - sprintf($this->translate('Missing parameter \'%s\''), 'chapterId'), + sprintf($this->translate('Missing parameter %s'), 'chapter'), 404 ); } @@ -133,8 +133,7 @@ class Doc_ModuleController extends DocController try { $this->renderChapter( $this->getPath($module, Icinga::app()->getModuleManager()->getModuleDir($module, '/doc')), - $chapterId, - $this->_helper->url->url(array('moduleName' => $module), 'doc/module/toc'), + $chapter, 'doc/module/chapter', array('moduleName' => $module) ); diff --git a/modules/doc/application/views/scripts/chapter.phtml b/modules/doc/application/views/scripts/chapter.phtml index 7657d69fb..6fe0d8d27 100644 --- a/modules/doc/application/views/scripts/chapter.phtml +++ b/modules/doc/application/views/scripts/chapter.phtml @@ -1,3 +1,3 @@
    - render($this, $this->getHelper('Url')); ?> +
    diff --git a/modules/doc/application/views/scripts/module/chapter.phtml b/modules/doc/application/views/scripts/module/chapter.phtml index 7657d69fb..6fe0d8d27 100644 --- a/modules/doc/application/views/scripts/module/chapter.phtml +++ b/modules/doc/application/views/scripts/module/chapter.phtml @@ -1,3 +1,3 @@
    - render($this, $this->getHelper('Url')); ?> +
    diff --git a/modules/doc/application/views/scripts/module/toc.phtml b/modules/doc/application/views/scripts/module/toc.phtml index ca6283d67..ce1b3da29 100644 --- a/modules/doc/application/views/scripts/module/toc.phtml +++ b/modules/doc/application/views/scripts/module/toc.phtml @@ -1,6 +1,6 @@
    -

    +

    - render($this, $this->getHelper('Url')); ?> +
    diff --git a/modules/doc/application/views/scripts/toc.phtml b/modules/doc/application/views/scripts/toc.phtml index ca6283d67..ce1b3da29 100644 --- a/modules/doc/application/views/scripts/toc.phtml +++ b/modules/doc/application/views/scripts/toc.phtml @@ -1,6 +1,6 @@
    -

    +

    - render($this, $this->getHelper('Url')); ?> +
    diff --git a/modules/doc/configuration.php b/modules/doc/configuration.php index f9bed3887..fdbada7af 100644 --- a/modules/doc/configuration.php +++ b/modules/doc/configuration.php @@ -20,3 +20,5 @@ $section->add($this->translate('Developer - Style'), array( 'url' => 'doc/style/guide', 'priority' => 200, )); + +$this->provideSearchUrl($this->translate('Doc'), 'doc/search'); diff --git a/modules/doc/library/Doc/DocController.php b/modules/doc/library/Doc/DocController.php index 9e29d99c7..70d2639bf 100644 --- a/modules/doc/library/Doc/DocController.php +++ b/modules/doc/library/Doc/DocController.php @@ -10,38 +10,37 @@ class DocController extends ModuleActionController /** * Render a chapter * - * @param string $path Path to the documentation - * @param string $chapterId ID of the chapter - * @param string $tocUrl - * @param string $url - * @param array $urlParams + * @param string $path Path to the documentation + * @param string $chapter ID of the chapter + * @param string $url URL to replace links with + * @param array $urlParams Additional URL parameters */ - protected function renderChapter($path, $chapterId, $tocUrl, $url, array $urlParams = array()) + protected function renderChapter($path, $chapter, $url, array $urlParams = array()) { $parser = new DocParser($path); - $this->view->sectionRenderer = new SectionRenderer( - $parser->getDocTree(), - SectionRenderer::decodeUrlParam($chapterId), - $tocUrl, - $url, - $urlParams - ); - $this->view->title = $chapterId; + $section = new SectionRenderer($parser->getDocTree(), SectionRenderer::decodeUrlParam($chapter)); + $this->view->section = $section + ->setUrl($url) + ->setUrlParams($urlParams); + $this->view->title = $chapter; $this->render('chapter', null, true); } /** * Render a toc * - * @param string $path Path to the documentation - * @param string $name Name of the documentation - * @param string $url - * @param array $urlParams + * @param string $path Path to the documentation + * @param string $name Name of the documentation + * @param string $url URL to replace links with + * @param array $urlParams Additional URL parameters */ protected function renderToc($path, $name, $url, array $urlParams = array()) { $parser = new DocParser($path); - $this->view->tocRenderer = new TocRenderer($parser->getDocTree(), $url, $urlParams); + $toc = new TocRenderer($parser->getDocTree()->getIterator()); + $this->view->toc = $toc + ->setUrl($url) + ->setUrlParams($urlParams); $name = ucfirst($name); $this->view->docName = $name; $this->view->title = sprintf($this->translate('%s Documentation'), $name); diff --git a/modules/doc/run.php b/modules/doc/run.php index cdeb95195..95abbf9df 100644 --- a/modules/doc/run.php +++ b/modules/doc/run.php @@ -9,7 +9,7 @@ if (Icinga::app()->isCli()) { } $docModuleChapter = new Zend_Controller_Router_Route( - 'doc/module/:moduleName/chapter/:chapterId', + 'doc/module/:moduleName/chapter/:chapter', array( 'controller' => 'module', 'action' => 'chapter', @@ -18,7 +18,7 @@ $docModuleChapter = new Zend_Controller_Router_Route( ); $docIcingaWebChapter = new Zend_Controller_Router_Route( - 'doc/icingaweb/chapter/:chapterId', + 'doc/icingaweb/chapter/:chapter', array( 'controller' => 'icingaweb', 'action' => 'chapter', From 312d18d14aea68c93c4bbff31f67f2d80918b7ba Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Tue, 10 Feb 2015 17:11:00 +0100 Subject: [PATCH 0595/2920] doc/lib: Add DocSearch class for creating search criteria refs #6630 --- modules/doc/library/Doc/Search/DocSearch.php | 91 ++++++++++++++++++++ 1 file changed, 91 insertions(+) create mode 100644 modules/doc/library/Doc/Search/DocSearch.php diff --git a/modules/doc/library/Doc/Search/DocSearch.php b/modules/doc/library/Doc/Search/DocSearch.php new file mode 100644 index 000000000..ab3a7cf64 --- /dev/null +++ b/modules/doc/library/Doc/Search/DocSearch.php @@ -0,0 +1,91 @@ +input = $search = (string) $search; + $criteria = array(); + if (preg_match_all('/"(?P[^"]*)"/', $search, $matches, PREG_SET_ORDER | PREG_OFFSET_CAPTURE)) { + $unquoted = ''; + $offset = 0; + foreach ($matches as $match) { + $fullMatch = $match[0]; + $searchMatch = $match['search']; + $unquoted .= substr($search, $offset, $fullMatch[1] - $offset); + $offset += $fullMatch[1] + strlen($fullMatch[0]); + if (strlen($searchMatch[0]) > 0) { + $criteria[] = $searchMatch[0]; + } + } + $search = $unquoted . substr($search, $offset); + } + $this->search = array_unique(array_merge($criteria, array_filter(explode(' ', trim($search))))); + } + + /** + * Get the search criteria + * + * @return array + */ + public function getCriteria() + { + return $this->search; + } + + /** + * Get the search string + * + * @return string + */ + public function getInput() + { + return $this->input; + } + + /** + * Search in the given line + * + * @param string $line + * + * @return DocSearchMatch|null + */ + public function search($line) + { + $match = new DocSearchMatch(); + $match->setLine($line); + foreach ($this->search as $criteria) { + $offset = 0; + while (($position = stripos($line, $criteria, $offset)) !== false) { + $match->appendMatch(substr($line, $position, strlen($criteria)), $position); + $offset = $position + 1; + } + } + return $match->isEmpty() ? null : $match; + } +} From 267c36d8d16d0c7a262b36beb36c85c298ae87af Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Tue, 10 Feb 2015 17:11:48 +0100 Subject: [PATCH 0596/2920] doc/lib: Add class DocSearchMatch represeting a search match refs #6630 --- .../doc/library/Doc/Search/DocSearchMatch.php | 151 ++++++++++++++++++ 1 file changed, 151 insertions(+) create mode 100644 modules/doc/library/Doc/Search/DocSearchMatch.php diff --git a/modules/doc/library/Doc/Search/DocSearchMatch.php b/modules/doc/library/Doc/Search/DocSearchMatch.php new file mode 100644 index 000000000..c5c7b4b7f --- /dev/null +++ b/modules/doc/library/Doc/Search/DocSearchMatch.php @@ -0,0 +1,151 @@ +line = (string) $line; + return $this; + } + + /** + * Get the line + * + * @return string + */ + public function getLine() + { + return $this->line; + } + + /** + * Set the line number + * + * @param int $lineno + * + * @return $this + */ + public function setLineno($lineno) + { + $this->lineno = (int) $lineno; + return $this; + } + + /** + * Set the match type + * + * @param int $matchType + * + * @return $this + */ + public function setMatchType($matchType) + { + $matchType = (int) $matchType; + if ($matchType !== static::MATCH_HEADER && $matchType !== static::MATCH_CONTENT) { + throw new UnexpectedValueException(); + } + $this->matchType = $matchType; + return $this; + } + + /** + * Get the match type + * + * @return int + */ + public function getMatchType() + { + return $this->matchType; + } + + /** + * Append a match + * + * @param string $match + * @param int $position + * + * @return $this + */ + public function appendMatch($match, $position) + { + $this->matches[(int) $position] = (string) $match; + return $this; + } + + /** + * Get the matches + * + * @return array + */ + public function getMatches() + { + return $this->matches; + } + + /** + * Whether the match is empty + * + * @return bool + */ + public function isEmpty() + { + return empty($this->matches); + } +} From e7b0f8d30f5548cb6ea3098938419ad697a5b2e4 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Tue, 10 Feb 2015 17:12:43 +0100 Subject: [PATCH 0597/2920] doc/lib: Add iterator over doc sections that match a given search criteria refs #6630 --- .../library/Doc/Search/DocSearchIterator.php | 122 ++++++++++++++++++ 1 file changed, 122 insertions(+) create mode 100644 modules/doc/library/Doc/Search/DocSearchIterator.php diff --git a/modules/doc/library/Doc/Search/DocSearchIterator.php b/modules/doc/library/Doc/Search/DocSearchIterator.php new file mode 100644 index 000000000..a3a4d8504 --- /dev/null +++ b/modules/doc/library/Doc/Search/DocSearchIterator.php @@ -0,0 +1,122 @@ +search = $search; + parent::__construct($iterator); + } + + /** + * Accept sections that match the search + * + * @return bool Whether the current element of the iterator is acceptable + * through this filter + */ + public function accept() + { + $section = $this->getInnerIterator()->current(); + /** @type $section \Icinga\Module\Doc\DocSection */ + $matches = array(); + if (($match = $this->search->search($section->getTitle())) !== null) { + $matches[] = $match->setMatchType(DocSearchMatch::MATCH_HEADER); + } + foreach ($section->getContent() as $lineno => $line) { + if (($match = $this->search->search($line)) !== null) { + $matches[] = $match + ->setMatchType(DocSearchMatch::MATCH_CONTENT) + ->setLineno($lineno); + } + } + if (! empty($matches)) { + $this->matches = $matches; + return $this; + } + if ($section->hasChildren()) { + $this->matches = null; + return true; + } + return false; + } + + /** + * Get the search criteria + * + * @return DocSearch + */ + public function getSearch() + { + return $this->search; + } + + /** + * {@inheritdoc} + */ + public function getChildren() + { + return new static($this->getInnerIterator()->getChildren(), $this->search); + } + + /** + * {@inheritdoc} + */ + public function count() + { + return iterator_count($this); + } + + /** + * Whether the search did not yield any match + * + * @return bool + */ + public function isEmpty() + { + return $this->count() === 0; + } + + /** + * Get matches + * + * @return DocSearchMatch[]|null + */ + public function getMatches() + { + return $this->matches; + } +} From 3b20e499404d6b451a385522e91341b652197a21 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Tue, 10 Feb 2015 17:13:17 +0100 Subject: [PATCH 0598/2920] doc/lib: Add renderer for doc searches refs #6630 --- .../library/Doc/Search/DocSearchRenderer.php | 147 ++++++++++++++++++ 1 file changed, 147 insertions(+) create mode 100644 modules/doc/library/Doc/Search/DocSearchRenderer.php diff --git a/modules/doc/library/Doc/Search/DocSearchRenderer.php b/modules/doc/library/Doc/Search/DocSearchRenderer.php new file mode 100644 index 000000000..97f830a93 --- /dev/null +++ b/modules/doc/library/Doc/Search/DocSearchRenderer.php @@ -0,0 +1,147 @@ +content[] = ''; + } + + /** + * {@inheritdoc} + */ + public function beginChildren() + { + if ($this->getInnerIterator()->getMatches()) { + $this->content[] = '
      '; + } + } + + /** + * {@inheritdoc} + */ + public function endChildren() + { + if ($this->getInnerIterator()->getMatches()) { + $this->content[] = '
    '; + } + } + + public function highlight($line, array $matches) + { + $highlighted = ''; + $offset = 0; + ksort($matches); + foreach ($matches as $position => $match) { + $highlighted .= $this->getView()->escape(substr($line, $offset, $position - $offset)) + . '' + . $this->getView()->escape($match) + . ''; + $offset = $position + strlen($match); + } + $highlighted .= $this->getView()->escape(substr($line, $offset)); + return $highlighted; + } + + /** + * {@inheritdoc} + */ + public function render() + { + foreach ($this as $section) { + if (($matches = $this->getInnerIterator()->getMatches()) === null) { + continue; + } + $title = $this->getView()->escape($section->getTitle()); + $contentMatches = array(); + foreach ($matches as $match) { + if ($match->getMatchType() === DocSearchMatch::MATCH_HEADER) { + $title = $this->highlight($match->getLine(), $match->getMatches()); + } else { + $contentMatches[] = sprintf( + '

    %s

    ', + $this->highlight($match->getLine(), $match->getMatches()) + ); + } + } + $path = $this->getView()->getHelper('Url')->url( + array_merge( + $this->urlParams, + array( + 'chapter' => $this->encodeUrlParam($section->getChapter()->getId()) + ) + ), + $this->url, + false, + false + ); + $url = $this->getView()->url( + $path, + array('highlight' => $this->getInnerIterator()->getSearch()->getInput()) + ); + /** @type \Icinga\Web\Url $url */ + $url->setAnchor($this->encodeAnchor($section->getId())); + $this->content[] = sprintf( + '
  • %s', + $section->getNoFollow() ? 'rel="nofollow" ' : '', + $url->getAbsoluteUrl(), + $title + ); + if (! empty($contentMatches)) { + $this->content = array_merge($this->content, $contentMatches); + } + if (! $section->hasChildren()) { + $this->content[] = '
  • '; + } + } + return implode("\n", $this->content); + } +} From e2b34023cd4736327a04c74e341e49493e08dacc Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Tue, 10 Feb 2015 17:14:16 +0100 Subject: [PATCH 0599/2920] doc/lib: Add SearchController At the moment only Icinga Web 2's documentation is available for searching. refs #6630 --- .../controllers/SearchController.php | 49 +++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 modules/doc/application/controllers/SearchController.php diff --git a/modules/doc/application/controllers/SearchController.php b/modules/doc/application/controllers/SearchController.php new file mode 100644 index 000000000..5ba223d00 --- /dev/null +++ b/modules/doc/application/controllers/SearchController.php @@ -0,0 +1,49 @@ +getPath()); + $search = new DocSearchRenderer( + new DocSearchIterator( + $parser->getDocTree()->getIterator(), + new DocSearch($this->params->get('q')) + ) + ); + $this->view->search = $search->setUrl('doc/icingaweb/chapter'); + } + + /** + * Get the path to Icinga Web 2's documentation + * + * @return string + * + * @throws Zend_Controller_Action_Exception If Icinga Web 2's documentation is not available + */ + protected function getPath() + { + $path = Icinga::app()->getBaseDir('doc'); + if (is_dir($path)) { + return $path; + } + if (($path = $this->Config()->get('documentation', 'icingaweb2')) !== null) { + if (is_dir($path)) { + return $path; + } + } + throw new Zend_Controller_Action_Exception( + $this->translate('Documentation for Icinga Web 2 is not available'), + 404 + ); + } +} From 278591fbd2e7a704ed0530745e5b96d523337f8c Mon Sep 17 00:00:00 2001 From: Marius Hein Date: Wed, 11 Feb 2015 10:35:12 +0100 Subject: [PATCH 0600/2920] Accessibility: Prototype for skip links --- doc/accessibility/skip-content.html | 177 ++++++++++++++++++++++++++++ 1 file changed, 177 insertions(+) create mode 100644 doc/accessibility/skip-content.html diff --git a/doc/accessibility/skip-content.html b/doc/accessibility/skip-content.html new file mode 100644 index 000000000..c785f6c12 --- /dev/null +++ b/doc/accessibility/skip-content.html @@ -0,0 +1,177 @@ + + + + + + Accessibility: Skip Links + + + + + +
    + + +
    +
    + +
    +

    Content

    + +

    + Organised prehistoric cultures began developing on Bulgarian lands + during the Neolithic period. Its ancient history saw the presence + of the Thracians and later the Greeks and Romans. The emergence of + a unified Bulgarian state dates back to the establishment of the + First Bulgarian Empire + in 681 CE, which dominated most of the + Balkans and functioned as a cultural hub for Slavs during the + Middle Ages. +

    +

    + With the downfall of the Second Bulgarian Empire in 1396, its + territories came under Ottoman + rule for nearly five centuries. + The Russo-Turkish War (1877–78) led to the formation of the Third + Bulgarian State. The following years saw several conflicts with its + neighbours, which prompted Bulgaria to align with Germany in both + world wars. +

    +

    + In 1946 it became a single-party socialist state as part of the + Soviet-led Eastern Bloc. In December 1989 the ruling Communist + Party allowed multi-party elections, which subsequently led to + Bulgaria's transition into a democracy and a market-based economy. +

    + +

    Content2

    +

    + The development of Final Fantasy VIII began in 1997, during the + English localization process of Final Fantasy VII. It was produced + by Shinji Hashimoto, + and directed by Yoshinori Kitase. The music + was scored by regular series composer Nobuo Uematsu, and in a + series first a vocal piece was written as the game's theme, "Eyes + on Me", performed by Faye Wong. +

    +

    + The game was positively received by + critics, + who praised the originality + and scope of the game. It was + voted the 22nd-best game of all time in 2006 by readers of the + Japanese magazine Famitsu. The game was a commercial success; + thirteen weeks after its release, +

    +
    +
    + + \ No newline at end of file From 0b1a9c16596b7b819c34db3014c54812869c1db3 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Wed, 11 Feb 2015 12:58:31 +0100 Subject: [PATCH 0601/2920] doc/lib: Apply role and css class toc to the toc refs #6630 --- modules/doc/library/Doc/TocRenderer.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/doc/library/Doc/TocRenderer.php b/modules/doc/library/Doc/TocRenderer.php index cfa18fad0..019ca2d9f 100644 --- a/modules/doc/library/Doc/TocRenderer.php +++ b/modules/doc/library/Doc/TocRenderer.php @@ -38,7 +38,7 @@ class TocRenderer extends Renderer */ public function beginIteration() { - $this->content[] = '
      - icon('up-open'); ?> + qlink( + $this->icon('up-open'), + Url::fromRequest(), + array( + 'page' => $currentXAxisPage . ',' . $prevYAxisPage + ), + array( + 'data-base-target' => '_self', + 'title' => sprintf( + $showText, + $this->translate('Y-Axis', 'pagination.joystick'), + $this->translate('hosts', 'pagination.joystick'), + ($prevYAxisPage - 1) * $yAxisPages->itemCountPerPage + 1, + $prevYAxisPage * $yAxisPages->itemCountPerPage, + $yAxisPages->totalItemCount + ) + ), + false + ); ?> icon('up-open'); ?> @@ -47,16 +56,25 @@ $nextXAxisPage = $currentXAxisPage < $totalXAxisPages ? $currentXAxisPage + 1 :
    - icon('left-open'); ?> + qlink( + $this->icon('left-open'), + Url::fromRequest(), + array( + 'page' => $prevXAxisPage . ',' . $currentYAxisPage + ), + array( + 'data-base-target' => '_self', + 'title' => sprintf( + $showText, + $this->translate('X-Axis', 'pagination.joystick'), + $this->translate('services', 'pagination.joystick'), + ($prevXAxisPage - 1) * $xAxisPages->itemCountPerPage + 1, + $prevXAxisPage * $xAxisPages->itemCountPerPage, + $xAxisPages->totalItemCount + ) + ), + false + ); ?> icon('left-open'); ?> @@ -64,16 +82,25 @@ $nextXAxisPage = $currentXAxisPage < $totalXAxisPages ? $currentXAxisPage + 1 :   - icon('right-open'); ?> + qlink( + $this->icon('right-open'), + Url::fromRequest(), + array( + 'page' => $nextXAxisPage . ',' . $currentYAxisPage + ), + array( + 'data-base-target' => '_self', + 'title' => sprintf( + $showText, + $this->translate('X-Axis', 'pagination.joystick'), + $this->translate('services', 'pagination.joystick'), + $currentXAxisPage * $xAxisPages->itemCountPerPage + 1, + $nextXAxisPage === $xAxisPages->last ? $xAxisPages->totalItemCount : $nextXAxisPage * $xAxisPages->itemCountPerPage, + $xAxisPages->totalItemCount + ) + ), + false + ); ?> icon('right-open'); ?> @@ -83,16 +110,25 @@ $nextXAxisPage = $currentXAxisPage < $totalXAxisPages ? $currentXAxisPage + 1 :   - icon('down-open'); ?> + qlink( + $this->icon('down-open'), + Url::fromRequest(), + array( + 'page' => $currentXAxisPage . ',' . $nextYAxisPage + ), + array( + 'data-base-target' => '_self', + 'title' => sprintf( + $showText, + $this->translate('Y-Axis', 'pagination.joystick'), + $this->translate('hosts', 'pagination.joystick'), + $currentYAxisPage * $yAxisPages->itemCountPerPage + 1, + $nextYAxisPage === $yAxisPages->last ? $yAxisPages->totalItemCount : $nextYAxisPage * $yAxisPages->itemCountPerPage, + $yAxisPages->totalItemCount + ) + ), + false + ); ?> icon('down-open'); ?> From 371f8951889467e8bbb40b10ff7d5b4ff5774ea2 Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Mon, 23 Feb 2015 17:21:31 +0100 Subject: [PATCH 0764/2920] Add proper titles to the mixed pagination refs #8458 --- application/views/scripts/mixedPagination.phtml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/application/views/scripts/mixedPagination.phtml b/application/views/scripts/mixedPagination.phtml index bac2b202b..4704d8f51 100644 --- a/application/views/scripts/mixedPagination.phtml +++ b/application/views/scripts/mixedPagination.phtml @@ -13,7 +13,7 @@ if ($this->pageCount <= 1) return; - - escape($h->hostgroup_alias) ?> - + qlink( + $h->hostgroup_alias, + 'monitoring/list/hosts', + array('hostgroup' => $h->hostgroup), + array('title' => sprintf($this->translate('List all hosts in the group "%s"'), $h->hostgroup_alias)) + ); ?> - qlink($h->services_total, 'monitoring/list/services', array('hostgroup' => $h->hostgroup)) ?> + qlink( + $h->services_total, + 'monitoring/list/services', + array('hostgroup' => $h->hostgroup), + array('title' => sprintf( + $this->translate('List all services of all hosts in host group "%s"'), + $h->hostgroup_alias + )) + ); ?> services_ok): ?> - - services_ok; ?> - + array( + 'title' => sprintf( + $this->translatePlural( + 'List %u service that is currently in state OK on hosts in the host group "%s"', + 'List %u services which are currently in state OK on hosts in the host group "%s"', + $h->services_ok + ), + $h->services_ok, + $h->hostgroup_alias + ) + ) + ); ?> services_critical_unhandled): ?> - - services_critical_unhandled; ?> - + array( + 'title' => sprintf( + $this->translatePlural( + 'List %u service that is currently in state CRITICAL on hosts in the host group "%s"', + 'List %u services which are currently in state CRITICAL on hosts in the host group "%s"', + $h->services_critical_unhandled + ), + $h->services_critical_unhandled, + $h->hostgroup_alias + ) + ) + ); ?> services_critical_handled): ?> - - services_critical_handled; ?> - + array( + 'title' => sprintf( + $this->translatePlural( + 'List %u service that is currently in state CRITICAL (Acknowledged) on hosts in the host group "%s"', + 'List %u services which are currently in state CRITICAL (Acknowledged) on hosts in the host group "%s"', + $h->services_critical_handled + ), + $h->services_critical_handled, + $h->hostgroup_alias + ) + ) + ); ?> services_critical_unhandled): ?> @@ -161,7 +178,8 @@ services_unknown_unhandled): ?> - - services_unknown_unhandled; ?> - + array( + 'title' => sprintf( + $this->translatePlural( + 'List %u service that is currently in state UNKNOWN on hosts in the host group "%s"', + 'List %u services which are currently in state UNKNOWN on hosts in the host group "%s"', + $h->services_unknown_unhandled + ), + $h->services_unknown_unhandled, + $h->hostgroup_alias + ) + ) + ); ?> services_unknown_handled): ?> - - services_unknown_handled; ?> - + array( + 'title' => sprintf( + $this->translatePlural( + 'List %u service that is currently in state UNKNOWN (Acknowledged) on hosts in the host group "%s"', + 'List %u services which are currently in state UNKNOWN (Acknowledged) on hosts in the host group "%s"', + $h->services_unknown_handled + ), + $h->services_unknown_handled, + $h->hostgroup_alias + ) + ) + ); ?> services_unknown_unhandled): ?> @@ -211,7 +232,8 @@ services_warning_unhandled): ?> - - services_warning_unhandled; ?> - + array( + 'title' => sprintf( + $this->translatePlural( + 'List %u service that is currently in state WARNING on hosts in the host group "%s"', + 'List %u services which are currently in state WARNING on hosts in the host group "%s"', + $h->services_warning_unhandled + ), + $h->services_warning_unhandled, + $h->hostgroup_alias + ) + ) + ); ?> services_warning_handled): ?> - - services_warning_handled; ?> - + array( + 'title' => sprintf( + $this->translatePlural( + 'List %u service that is currently in state WARNING (Acknowledged) on hosts in the host group "%s"', + 'List %u services which are currently in state WARNING (Acknowledged) on hosts in the host group "%s"', + $h->services_warning_handled + ), + $h->services_warning_handled, + $h->hostgroup_alias + ) + ) + ); ?> services_warning_unhandled): ?> @@ -261,24 +286,26 @@ services_pending): ?> - - services_pending; ?> - + array( + 'title' => sprintf( + $this->translatePlural( + 'List %u service that is currently in state PENDING on hosts in the host group "%s"', + 'List %u services which are currently in state PENDING on hosts in the host group "%s"', + $h->services_pending + ), + $h->services_pending, + $h->hostgroup_alias + ) + ) + ); ?>
    - + - - - 18 ? substr($service_description, 0, 18) . '...' : $service_description; ?> - - + ), + array( + 'title' => sprintf($this->translate('List all services with the name "%s" on all reported hosts'), $service_description) + ), + false + ); ?>
    @@ -60,18 +65,40 @@ $hostFilter = '(host_name=' . implode('|host_name=', array_keys($pivotData)) . '
    - + qlink( + $host_name, + 'monitoring/show/services?' . $serviceFilter, + array('host' => $host_name), + array('title' => sprintf($this->translate('List all reported services on host %s'), $host_name)) + ); ?> - + + escape($service->service_output); ?> + + qlink( + '', + 'monitoring/show/service', + array( + 'host' => $service->host_name, + 'service' => $service->service_description + ), + array( + 'aria-describedby' => $service->host_name . '_' . $service->service_description . '_desc', + 'class' => 'state_' . Service::getStateText($service->service_state). ($service->service_handled ? ' handled' : ''), + 'title' => $this->escape($service->service_output), + 'aria-label' => sprintf( + $this->translate('Show detailed information for service %s on host %s'), + $service->service_description, + $service->host_name + ) + ) + ); ?> ·
    - - translate($s->servicegroup_alias) ?> - + qlink( + $s->servicegroup_alias, + 'monitoring/list/services', + array('servicegroup' => $s->servicegroup), + array('title' => sprintf($this->translate('List all services in the group "%s"'), $s->servicegroup_alias)) + ); ?> services_total; ?> @@ -89,29 +92,32 @@ services_ok): ?> - - services_ok; ?> - + array( + 'title' => sprintf( + $this->translatePlural( + 'List %s service that is currently in state OK in service group "%s"', + 'List %s services which are currently in state OK in service group "%s"', + $s->services_ok + ), + $s->services_ok, + $s->servicegroup_alias + ) + ) + ); ?> services_critical_unhandled): ?> - - services_critical_unhandled; ?> - + array( + 'title' => sprintf( + $this->translatePlural( + 'List %s service that is currently in state CRITICAL in service group "%s"', + 'List %s services which are currently in state CRITICAL in service group "%s"', + $s->services_critical_unhandled + ), + $s->services_critical_unhandled, + $s->servicegroup_alias + ) + ) + ); ?> services_critical_handled): ?> - - services_critical_handled; ?> - + array( + 'title' => sprintf( + $this->translatePlural( + 'List %s service that is currently in state CRITICAL (Acknowledged) in service group "%s"', + 'List %s services which are currently in state CRITICAL (Acknowledged) in service group "%s"', + $s->services_critical_handled + ), + $s->services_critical_handled, + $s->servicegroup_alias + ) + ) + ); ?> services_critical_unhandled): ?> @@ -161,7 +170,8 @@ services_unknown_unhandled): ?> - - services_unknown_unhandled; ?> - + array( + 'title' => sprintf( + $this->translatePlural( + 'List %s service that is currently in state UNKNOWN in service group "%s"', + 'List %s services which are currently in state UNKNOWN in service group "%s"', + $s->services_unknown_unhandled + ), + $s->services_unknown_unhandled, + $s->servicegroup_alias + ) + ) + ); ?> services_unknown_handled): ?> - - services_unknown_handled; ?> - + array( + 'title' => sprintf( + $this->translatePlural( + 'List %s service that is currently in state UNKNOWN (Acknowledged) in service group "%s"', + 'List %s services which are currently in state UNKNOWN (Acknowledged) in service group "%s"', + $s->services_unknown_handled + ), + $s->services_unknown_handled, + $s->servicegroup_alias + ) + ) + ); ?> services_unknown_unhandled): ?> @@ -211,7 +224,8 @@ services_warning_unhandled): ?> - - services_warning_unhandled; ?> - + array( + 'title' => sprintf( + $this->translatePlural( + 'List %s service that is currently in state WARNING in service group "%s"', + 'List %s services which are currently in state WARNING in service group "%s"', + $s->services_warning_unhandled + ), + $s->services_warning_unhandled, + $s->servicegroup_alias + ) + ) + ); ?> services_warning_handled): ?> - - services_warning_handled; ?> - + array( + 'title' => sprintf( + $this->translatePlural( + 'List %s service that is currently in state WARNING (Acknowledged) in service group "%s"', + 'List %s services which are currently in state WARNING (Acknowledged) in service group "%s"', + $s->services_warning_handled + ), + $s->services_warning_handled, + $s->servicegroup_alias + ) + ) + ); ?> services_warning_unhandled): ?> @@ -261,24 +278,26 @@ services_pending): ?> - - services_pending; ?> - + array( + 'title' => sprintf( + $this->translatePlural( + 'List %s service that is currenlty in state PENDING in service group "%s"', + 'List %s services which are currently in state PENDING in service group "%s"', + $s->services_pending + ), + $s->services_pending, + $s->servicegroup_alias + ) + ) + ); ?> hasPermission('monitoring/command/schedule-check')) { if ($isService) { - $reschedule = $this->href( + echo $this->qlink( + $this->icon('reschedule') . ' ' . $this->translate('Reschedule'), 'monitoring/service/reschedule-check', - array('host' => $object->getHost()->getName(), 'service' => $object->getName()) + array('host' => $object->getHost()->getName(), 'service' => $object->getName()), + array( + 'data-base-target' => '_self', + 'title' => $this->translate( + 'Schedule the next active check at a different time than the current one' + ) + ), + false ); } else { - $reschedule = $this->href( + echo $this->qlink( + $this->icon('reschedule') . ' ' . $this->translate('Reschedule'), 'monitoring/host/reschedule-check', - array('host' => $object->getName()) + array('host' => $object->getName()), + array( + 'data-base-target' => '_self', + 'title' => $this->translate( + 'Schedule the next active check at a different time than the current one' + ) + ), + false ); } - ?> - - icon('reschedule') ?> - translate('Reschedule') ?> - - - timeUntil($object->next_check) ?> + } ?> timeUntil($object->next_check) ?>
    translate('Command') ?>translate('Command'); ?> - escape($command) ?> - hasPermission('monitoring/command/schedule-check') && $object->passive_checks_enabled): ?> - getType() === $object::TYPE_HOST) { - $processCheckResult = $this->href( + escape($command); ?> + hasPermission('monitoring/command/schedule-check') && $object->passive_checks_enabled) { + $title = sprintf($this->translate('Submit a one time or so called passive result for the %s check'), $command); + if ($object->getType() === $object::TYPE_HOST) { + echo $this->qlink( + $this->icon('reply') . ' ' . $this->translate('Process check result'), 'monitoring/host/process-check-result', - array('host' => $object->getName()) + array('host' => $object->getName()), + array('data-base-target' => '_self', 'title' => $title), + false ); } else { - $processCheckResult = $this->href( + echo $this->qlink( + $this->icon('reply') . ' ' . $this->translate('Process check result'), 'monitoring/service/process-check-result', - array('host' => $object->getHost()->getName(), 'service' => $object->getName()) + array('host' => $object->getHost()->getName(), 'service' => $object->getName()), + array('data-base-target' => '_self', 'title' => $title), + false ); - } ?> - - icon('reply') ?> - translate('Process check result') ?> - - + } + } ?>
    translate('Comments') ?>translate('Comments'); ?> hasPermission('monitoring/command/comment/add')) { /** @type \Icinga\Module\Monitoring\Object\MonitoredObject $object */ if ($object->getType() === $object::TYPE_HOST) { - $addCommentLink = $this->href( + echo $this->qlink( + $this->icon('comment') . ' ' . $this->translate('Add comment'), 'monitoring/host/add-comment', - array('host' => $object->getName()) + array('host' => $object->getName()), + array( + 'data-base-target' => '_self', + 'title' => $this->translate('Add a new comment to this host') + ), + false ); } else { - $addCommentLink = $this->href( + echo $this->qlink( + $this->icon('comment') . ' ' . $this->translate('Add comment'), 'monitoring/service/add-comment', - array('host' => $object->getHost()->getName(), 'service' => $object->getName()) + array('host' => $object->getHost()->getName(), 'service' => $object->getName()), + array( + 'data-base-target' => '_self', + 'title' => $this->translate('Add a new comment to this service') + ), + false ); } - ?> - - icon('comment') ?> - translate('Add comment') ?> - - + } ?>
    translate('Downtimes') ?>translate('Downtimes'); ?> hasPermission('monitoring/command/downtime/schedule')) { /** @type \Icinga\Module\Monitoring\Object\MonitoredObject $object */ if ($object->getType() === $object::TYPE_HOST) { - $scheduleDowntimeLink = $this->href( + echo $this->qlink( + $this->icon('plug') . ' ' . $this->translate('Schedule downtime'), 'monitoring/host/schedule-downtime', - array('host' => $object->getName()) + array('host' => $object->getName()), + array( + 'data-base-target' => '_self', + 'title' => $this->translate( + 'Schedule a downtime to suppress all problem notifications within a specific period of time' + ) + ), + false ); } else { - $scheduleDowntimeLink = $this->href( + echo $this->qlink( + $this->icon('plug') . ' ' . $this->translate('Schedule downtime'), 'monitoring/service/schedule-downtime', - array('host' => $object->getHost()->getName(), 'service' => $object->getName()) + array('host' => $object->getHost()->getName(), 'service' => $object->getName()), + array( + 'data-base-target' => '_self', + 'title' => $this->translate( + 'Schedule a downtime to suppress all problem notifications within a specific period of time' + ) + ), + false ); } - ?> - - icon('plug') ?> - translate('Schedule downtime') ?> - - + } ?>
    %s%s %s
    statusSummary->hosts_active): ?> -
    - - translatePlural('%d Active', '%d Active', $this->statusSummary->hosts_active), $this->statusSummary->hosts_active); ?> - -
    +
    qlink( + sprintf( + $this->translatePlural('%u Active', '%u Active', $this->statusSummary->hosts_active), + $this->statusSummary->hosts_active + ), + 'monitoring/list/hosts', + array('host_active_checks_enabled' => 1), + array('title' => sprintf( + $this->translatePlural( + 'List %u actively checked host', + 'List %u actively checked hosts', + $this->statusSummary->hosts_active + ), + $this->statusSummary->hosts_active + )) + ); ?>
    statusSummary->hosts_passive): ?> -
    - - translatePlural('%d Passive', '%d Passive', $this->statusSummary->hosts_passive), $this->statusSummary->hosts_passive); ?> - -
    +
    qlink( + sprintf( + $this->translatePlural('%d Passive', '%d Passive', $this->statusSummary->hosts_passive), + $this->statusSummary->hosts_passive + ), + 'monitoring/list/hosts', + array('host_active_checks_enabled' => 0, 'host_passive_checks_enabled' => 1), + array('title' => sprintf( + $this->translatePlural( + 'List %u passively checked host', + 'List %u passively checked hosts', + $this->statusSummary->hosts_passive + ), + $this->statusSummary->hosts_passive + )) + ); ?>
    statusSummary->hosts_not_checked): ?> -
    - - translatePlural('%d Disabled', '%d Disabled', $this->statusSummary->hosts_not_checked), $this->statusSummary->hosts_not_checked); ?> - -
    +
    qlink( + sprintf( + $this->translatePlural('%d Disabled', '%d Disabled', $this->statusSummary->hosts_not_checked), + $this->statusSummary->hosts_not_checked + ), + 'monitoring/list/hosts', + array('host_active_checks_enabled' => 0, 'host_passive_checks_enabled' => 0), + array('title' => sprintf( + $this->translatePlural( + 'List %u host that is not being checked at all', + 'List %u hosts which are not being checked at all', + $this->statusSummary->hosts_not_checked + ), + $this->statusSummary->hosts_not_checked + )) + ); ?>
    statusSummary->services_active): ?> -
    - - translatePlural('%d Active', '%d Active', $this->statusSummary->services_active), $this->statusSummary->services_active); ?> - -
    +
    qlink( + sprintf( + $this->translatePlural('%d Active', '%d Active', $this->statusSummary->services_active), + $this->statusSummary->services_active + ), + 'monitoring/list/services', + array('service_active_checks_enabled' => 1), + array('title' => sprintf( + $this->translatePlural( + 'List %u actively checked service', + 'List %u actively checked services', + $this->statusSummary->services_active + ), + $this->statusSummary->services_active + )) + ); ?>
    statusSummary->services_passive): ?> -
    - - translatePlural('%d Passive', '%d Passive', $this->statusSummary->services_passive), $this->statusSummary->services_passive); ?> - -
    +
    qlink( + sprintf( + $this->translatePlural('%d Passive', '%d Passive', $this->statusSummary->services_passive), + $this->statusSummary->services_passive + ), + 'monitoring/list/services', + array('service_active_checks_enabled' => 0, 'service_passive_checks_enabled' => 1), + array('title' => sprintf( + $this->translatePlural( + 'List %u passively checked service', + 'List %u passively checked services', + $this->statusSummary->services_passive + ), + $this->statusSummary->services_passive + )) + ); ?>
    statusSummary->services_not_checked): ?> -
    - - translatePlural('%d Disabled', '%d Disabled', $this->statusSummary->services_not_checked), $this->statusSummary->services_not_checked); ?> - -
    +
    qlink( + sprintf( + $this->translatePlural('%d Disabled', '%d Disabled', $this->statusSummary->services_not_checked), + $this->statusSummary->services_not_checked + ), + 'monitoring/list/services', + array('service_active_checks_enabled' => 0, 'service_passive_checks_enabled' => 0), + array('title' => sprintf( + $this->translatePlural( + 'List %u service that is not being checked at all', + 'List %u services which are not being checked at all', + $this->statusSummary->services_not_checked + ), + $this->statusSummary->services_not_checked + )) + ); ?>
    +
    statusSummary->hosts_without_flap_detection): ?> -
    - - translatePlural('%d Host Disabled', '%d Hosts Disabled', $this->statusSummary->hosts_without_flap_detection), $this->statusSummary->hosts_without_flap_detection); ?> - + array('host_flap_detection_enabled' => 0), + array( + 'class' => 'feature-highlight', + 'title' => sprintf( + $this->translatePlural( + 'List %u host for which flap detection has been disabled', + 'List %u hosts for which flap detection has been disabled', + $this->statusSummary->hosts_without_flap_detection + ), + $this->statusSummary->hosts_without_flap_detection + ) + ) + ); ?> -
    - - translate('All Hosts Enabled'); ?> - + array('host_flap_detection_enabled' => 1), + array('title' => $this->translate( + 'List all hosts, for which flap detection is enabled entirely' + )) + ); ?> statusSummary->hosts_flapping): ?> - - translatePlural('%d Host Flapping', '%d Hosts Flapping', $this->statusSummary->hosts_flapping), $this->statusSummary->hosts_flapping); ?> - + array('host_is_flapping' => 1), + array( + 'class' => 'feature-highlight', + 'title' => sprintf( + $this->translatePlural( + 'List %u host that is currently flapping', + 'List %u hosts which are currently flapping', + $this->statusSummary->hosts_flapping + ), + $this->statusSummary->hosts_flapping + ) + ) + ); ?>
    +
    statusSummary->services_without_flap_detection): ?> -
    - - translatePlural('%d Service Disabled', '%d Services Disabled', $this->statusSummary->services_without_flap_detection), $this->statusSummary->services_without_flap_detection); ?> - + array('service_flap_detection_enabled' => 0), + array( + 'class' => 'feature-highlight', + 'title' => sprintf( + $this->translatePlural( + 'List %u service for which flap detection has been disabled', + 'List %u services for which flap detection has been disabled', + $this->statusSummary->services_without_flap_detection + ), + $this->statusSummary->services_without_flap_detection + ) + ) + ); ?> -
    - - translate('All Services Enabled'); ?> - + array('service_flap_detection_enabled' => 1), + array('title' => $this->translate( + 'List all services, for which flap detection is enabled entirely' + )) + ); ?> statusSummary->services_flapping): ?> - - translatePlural('%d Service Flapping', '%d Services Flapping', $this->statusSummary->services_flapping), $this->statusSummary->services_flapping); ?> - + array('service_is_flapping' => 1), + array( + 'class' => 'feature-highlight', + 'title' => sprintf( + $this->translatePlural( + 'List %u service that is currently flapping', + 'List %u services which are currently flapping', + $this->statusSummary->services_flapping + ), + $this->statusSummary->services_flapping + ) + ) + ); ?>
    +
    statusSummary->hosts_not_triggering_notifications): ?> -
    - - translatePlural('%d Host Disabled', '%d Hosts Disabled', $this->statusSummary->hosts_not_triggering_notifications), $this->statusSummary->hosts_not_triggering_notifications); ?> - + array('host_notifications_enabled' => 0), + array( + 'class' => 'feature-highlight', + 'title' => sprintf( + $this->translatePlural( + 'List %u host for which notifications are suppressed', + 'List %u hosts for which notifications are suppressed', + $this->statusSummary->hosts_not_triggering_notifications + ), + $this->statusSummary->hosts_not_triggering_notifications + ) + ) + ); ?> -
    - - translate('All Hosts Enabled'); ?> - + array('host_notifications_enabled' => 1), + array('title' => $this->translate( + 'List all hosts, for which notifications are enabled entirely' + )) + ); ?>
    +
    statusSummary->services_not_triggering_notifications): ?> -
    - - translatePlural('%d Service Disabled', '%d Services Disabled', $this->statusSummary->services_not_triggering_notifications), $this->statusSummary->services_not_triggering_notifications); ?> - + array('service_notifications_enabled' => 0), + array( + 'class' => 'feature-highlight', + 'title' => sprintf( + $this->translatePlural( + 'List %u service for which notifications are suppressed', + 'List %u services for which notifications are suppressed', + $this->statusSummary->services_not_triggering_notifications + ), + $this->statusSummary->services_not_triggering_notifications + ) + ) + ); ?> -
    - - translate('All Services Enabled'); ?> - + array('service_notifications_enabled' => 1), + array('title' => $this->translate( + 'List all services, for which notifications are enabled entirely' + )) + ); ?>
    +
    statusSummary->hosts_not_processing_event_handlers): ?> -
    - - translatePlural('%d Host Disabled', '%d Hosts Disabled', $this->statusSummary->hosts_not_processing_event_handlers), $this->statusSummary->hosts_not_processing_event_handlers); ?> - + array('host_event_handler_enabled' => 0), + array( + 'class' => 'feature-highlight', + 'title' => sprintf( + $this->translatePlural( + 'List %u host that is not processing any event handlers', + 'List %u hosts which are not processing any event handlers', + $this->statusSummary->hosts_not_processing_event_handlers + ), + $this->statusSummary->hosts_not_processing_event_handlers + ) + ) + ); ?> -
    - - translate('All Hosts Enabled'); ?> - + array('host_event_handler_enabled' => 1), + array('title' => $this->translate( + 'List all hosts, which are processing event handlers entirely' + )) + ); ?>
    +
    statusSummary->services_not_processing_event_handlers): ?> -
    - - translatePlural('%d Service Disabled', '%d Services Disabled', $this->statusSummary->services_not_processing_event_handlers), $this->statusSummary->services_not_processing_event_handlers); ?> - + array('service_event_handler_enabled' => 0), + array( + 'class' => 'feature-highlight', + 'title' => sprintf( + $this->translatePlural( + 'List %u service that is not processing any event handlers', + 'List %u services which are not processing any event handlers', + $this->statusSummary->services_not_processing_event_handlers + ), + $this->statusSummary->services_not_processing_event_handlers + ) + ) + ); ?> -
    - - translate('All Services Enabled'); ?> - + array('service_event_handler_enabled' => 1), + array('title' => $this->translate( + 'List all services, which are processing event handlers entirely' + )) + ); ?>
    %1$s', $this->escape($contact->contact_email)) ?> translate('Email') ?> + + escape($contact->contact_email); ?> + +
    qlink( - $this->icon('edit') . ' ' . $this->escape($name), + $name, 'config/editresource', array('resource' => $name), - array('title' => sprintf($this->translate('Edit resource %s'), $name)), - false + array( + 'icon' => 'edit', + 'title' => sprintf($this->translate('Edit resource %s'), $name) + ) ); ?>
    qlink( - $this->icon('cancel'), + '', 'config/removeresource', array('resource' => $name), - array('title' => sprintf($this->translate('Remove resource %s'), $name)), - false + array( + 'icon' => 'cancel', + 'title' => sprintf($this->translate('Remove resource %s'), $name) + ) ); ?>
    qlink( - $this->icon('cancel'), + '', 'dashboard/remove-pane', array('pane' => $pane->getName()), - array('title' => sprintf($this->translate('Remove pane %s'), $pane->getName())), - false + array( + 'icon' => 'cancel', + 'title' => sprintf($this->translate('Remove pane %s'), $pane->getName()) + ) ); ?>
    qlink( - $this->icon('cancel'), + '', 'dashboard/remove-dashlet', array('pane' => $pane->getName(), 'dashlet' => $dashlet->getTitle()), - array('title' => sprintf($this->translate('Remove dashlet %s from pane %s'), $dashlet->getTitle(), $pane->getName())), - false + array( + 'icon' => 'cancel', + 'title' => sprintf($this->translate('Remove dashlet %s from pane %s'), $dashlet->getTitle(), $pane->getName()) + ) ); ?>
    qlink( - $this->icon('edit') . ' ' . $this->escape($backendNames[$i]), + $backendNames[$i], 'config/editAuthenticationBackend', array('auth_backend' => $backendNames[$i]), - array('title' => sprintf($this->translate('Edit authentication backend %s'), $backendNames[$i])), - false + array( + 'icon' => 'edit', + 'title' => sprintf($this->translate('Edit authentication backend %s'), $backendNames[$i]) + ) ); ?> qlink( - $this->icon('cancel'), + '', 'config/removeAuthenticationBackend', array('auth_backend' => $backendNames[$i]), - array('title' => sprintf($this->translate('Remove authentication backend %s'), $backendNames[$i])), - false + array( + 'icon' => 'cancel', + 'title' => sprintf($this->translate('Remove authentication backend %s'), $backendNames[$i]) + ) ); ?> diff --git a/application/views/scripts/joystickPagination.phtml b/application/views/scripts/joystickPagination.phtml index ef0acdb60..9549fc2b0 100644 --- a/application/views/scripts/joystickPagination.phtml +++ b/application/views/scripts/joystickPagination.phtml @@ -29,12 +29,13 @@ $nextXAxisPage = $currentXAxisPage < $totalXAxisPages ? $currentXAxisPage + 1 : qlink( - $this->icon('up-open'), + '', Url::fromRequest(), array( 'page' => $currentXAxisPage . ',' . $prevYAxisPage ), array( + 'icon' => 'up-open', 'data-base-target' => '_self', 'title' => sprintf( $showText, @@ -44,8 +45,7 @@ $nextXAxisPage = $currentXAxisPage < $totalXAxisPages ? $currentXAxisPage + 1 : $prevYAxisPage * $yAxisPages->itemCountPerPage, $yAxisPages->totalItemCount ) - ), - false + ) ); ?> icon('up-open'); ?> @@ -57,12 +57,13 @@ $nextXAxisPage = $currentXAxisPage < $totalXAxisPages ? $currentXAxisPage + 1 : qlink( - $this->icon('left-open'), + '', Url::fromRequest(), array( 'page' => $prevXAxisPage . ',' . $currentYAxisPage ), array( + 'icon' => 'left-open', 'data-base-target' => '_self', 'title' => sprintf( $showText, @@ -72,8 +73,7 @@ $nextXAxisPage = $currentXAxisPage < $totalXAxisPages ? $currentXAxisPage + 1 : $prevXAxisPage * $xAxisPages->itemCountPerPage, $xAxisPages->totalItemCount ) - ), - false + ) ); ?> icon('left-open'); ?> @@ -83,12 +83,13 @@ $nextXAxisPage = $currentXAxisPage < $totalXAxisPages ? $currentXAxisPage + 1 : qlink( - $this->icon('right-open'), + '', Url::fromRequest(), array( 'page' => $nextXAxisPage . ',' . $currentYAxisPage ), array( + 'icon' => 'right-open', 'data-base-target' => '_self', 'title' => sprintf( $showText, @@ -111,12 +112,13 @@ $nextXAxisPage = $currentXAxisPage < $totalXAxisPages ? $currentXAxisPage + 1 : qlink( - $this->icon('down-open'), + '', Url::fromRequest(), array( 'page' => $currentXAxisPage . ',' . $nextYAxisPage ), array( + 'icon' => 'down-open', 'data-base-target' => '_self', 'title' => sprintf( $showText, @@ -126,8 +128,7 @@ $nextXAxisPage = $currentXAxisPage < $totalXAxisPages ? $currentXAxisPage + 1 : $nextYAxisPage === $yAxisPages->last ? $yAxisPages->totalItemCount : $nextYAxisPage * $yAxisPages->itemCountPerPage, $yAxisPages->totalItemCount ) - ), - false + ) ); ?> icon('down-open'); ?> diff --git a/application/views/scripts/roles/index.phtml b/application/views/scripts/roles/index.phtml index fa1297396..350fb3343 100644 --- a/application/views/scripts/roles/index.phtml +++ b/application/views/scripts/roles/index.phtml @@ -56,11 +56,13 @@ escape($role->groups) ?> qlink( - $this->icon('cancel'), + '', 'roles/remove', array('role' => $name), - array('title' => sprintf($this->translate('Remove role %s'), $name)), - false + array( + 'icon' => 'cancel', + 'title' => sprintf($this->translate('Remove role %s'), $name) + ) ); ?>
    qlink( - $this->icon('edit') . ' ' . $this->escape($backendName), + $backendName, '/monitoring/config/editbackend', array('backend' => $backendName), - array('title' => sprintf($this->translate('Edit monitoring backend %s'), $backendName)), - false + array( + 'icon' => 'edit', + 'title' => sprintf($this->translate('Edit monitoring backend %s'), $backendName) + ) ); ?> (translate('Type: %s'), @@ -32,11 +34,13 @@ qlink( - $this->icon('cancel'), + '', '/monitoring/config/removebackend', array('backend' => $backendName), - array('title' => sprintf($this->translate('Remove monitoring backend %s'), $backendName)), - false + array( + 'icon' => 'cancel', + 'title' => sprintf($this->translate('Remove monitoring backend %s'), $backendName) + ) ); ?>
    qlink( - $this->icon('edit') . ' ' . $this->escape($instanceName), + $instanceName, '/monitoring/config/editinstance', array('instance' => $instanceName), - array('title' => sprintf($this->translate('Edit monitoring instance %s'), $instanceName)), - false + array( + 'icon' => 'edit', + 'title' => sprintf($this->translate('Edit monitoring instance %s'), $instanceName) + ) ); ?> (translate('Type: %s'), @@ -72,11 +78,13 @@ qlink( - $this->icon('cancel'), + '', '/monitoring/config/removeinstance', array('instance' => $instanceName), - array('title' => sprintf($this->translate('Remove monitoring instance %s'), $instanceName)), - false + array( + 'icon' => 'cancel', + 'title' => sprintf($this->translate('Remove monitoring instance %s'), $instanceName) + ) ); ?>

    title; ?>

    getTitle(); ?>

    - description)): ?> + getDescriptions(); ?> + 1): ?>
      - description as $desc): ?> +
    - - description; ?> + +
    message; ?>getStateText(); ?>
    - +

    getTitle(); ?>

    diff --git a/modules/setup/library/Setup/Requirements.php b/modules/setup/library/Setup/Requirements.php index aba96c4bc..69892f236 100644 --- a/modules/setup/library/Setup/Requirements.php +++ b/modules/setup/library/Setup/Requirements.php @@ -3,14 +3,13 @@ namespace Icinga\Module\Setup; -use ArrayIterator; use LogicException; -use IteratorAggregate; +use RecursiveIterator; /** * Container to store and handle requirements */ -class Requirements implements IteratorAggregate +class Requirements implements RecursiveIterator { /** * Mode AND (all requirements must met) @@ -94,7 +93,7 @@ class Requirements implements IteratorAggregate public function add(Requirement $requirement) { $merged = false; - foreach ($this as $knownRequirement) { + foreach ($this->requirements as $knownRequirement) { if ($knownRequirement instanceof Requirement && $requirement->equals($knownRequirement)) { if ($this->getMode() === static::MODE_AND && !$requirement->isOptional()) { $knownRequirement->setOptional(false); @@ -142,16 +141,6 @@ class Requirements implements IteratorAggregate return $this->containsMandatoryRequirements || $this->getMode() === static::MODE_OR; } - /** - * Return an iterator of all registered requirements - * - * @return ArrayIterator - */ - public function getIterator() - { - return new ArrayIterator($this->getAll()); - } - /** * Register the given requirements * @@ -162,7 +151,7 @@ class Requirements implements IteratorAggregate public function merge(Requirements $requirements) { if ($this->getMode() === static::MODE_OR && $requirements->getMode() === static::MODE_OR) { - foreach ($requirements as $requirement) { + foreach ($requirements->getAll() as $requirement) { if ($requirement instanceof static) { $this->merge($requirement); } else { @@ -188,7 +177,7 @@ class Requirements implements IteratorAggregate public function fulfilled() { $state = false; - foreach ($this as $requirement) { + foreach ($this->requirements as $requirement) { if ($requirement instanceof static) { if ($requirement->fulfilled()) { if ($this->getMode() === static::MODE_OR) { @@ -218,4 +207,71 @@ class Requirements implements IteratorAggregate return $state; } + + /** + * Return whether the current element represents a nested set of requirements + * + * @return bool + */ + public function hasChildren() + { + $current = $this->current(); + return $current instanceof static; + } + + /** + * Return a iterator for the current nested set of requirements + * + * @return RecursiveIterator + */ + public function getChildren() + { + return $this->current(); + } + + /** + * Rewind the iterator to its first element + */ + public function rewind() + { + reset($this->requirements); + } + + /** + * Return whether the current iterator position is valid + * + * @return bool + */ + public function valid() + { + return $this->key() !== null; + } + + /** + * Return the current element in the iteration + * + * @return Requirement|Requirements + */ + public function current() + { + return current($this->requirements); + } + + /** + * Return the position of the current element in the iteration + * + * @return int + */ + public function key() + { + return key($this->requirements); + } + + /** + * Advance the iterator to the next element + */ + public function next() + { + next($this->requirements); + } } From 435160324318552e9cfa3333b457d2f471de8338 Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Thu, 26 Feb 2015 14:48:37 +0100 Subject: [PATCH 0821/2920] Fix that editing an auth backend does not open the next column --- application/views/scripts/form/reorder-authbackend.phtml | 4 ++-- public/js/icinga/events.js | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/application/views/scripts/form/reorder-authbackend.phtml b/application/views/scripts/form/reorder-authbackend.phtml index 02f62572d..c31443eb6 100644 --- a/application/views/scripts/form/reorder-authbackend.phtml +++ b/application/views/scripts/form/reorder-authbackend.phtml @@ -1,4 +1,4 @@ -
    + @@ -31,7 +31,7 @@ ) ); ?> - '; + $currentSet = $this->getSubIterator(); + $state = $currentSet->getState() ? 'fulfilled' : ( + $currentSet->isOptional() ? 'not-available' : 'missing' + ); + $colSpanRequired = $this->hasSingleRequirements($this->getSubIterator($this->getDepth() - 1)); + $this->tags[] = ''; + $this->tags[] = ''; + } + + protected function hasSingleRequirements(RequirementSet $requirements) + { + $set = $requirements->getAll(); + foreach ($set as $entry) { + if ($entry instanceof Requirement) { + return true; + } + } + + return false; + } + + public function render() + { + foreach ($this as $requirement) { + $this->tags[] = ''; + $this->tags[] = ''; + $this->tags[] = ''; + $this->tags[] = ''; + $this->tags[] = ''; + } + + return implode("\n", $this->tags); + } + + public function __toString() + { + return $this->render(); + } +} diff --git a/public/css/icinga/setup.less b/public/css/icinga/setup.less index 66b08417e..31ecd205f 100644 --- a/public/css/icinga/setup.less +++ b/public/css/icinga/setup.less @@ -110,7 +110,8 @@ } #setup div.buttons { - margin: 1.5em 0; + margin-top: 1.5em; // Yes, -top and -bottom, keep it like that... + margin-bottom: 1.5em; .double { position: absolute; @@ -166,25 +167,53 @@ } } -#setup table.requirements { +form#setup_requirements { + padding-top: 0.5em; + border-top: 2px solid @colorPetrol; +} + +div.requirements-refresh { + width: 25%; + margin-left: 75%; + text-align: center; +} + +#setup > table.requirements { font-size: 0.9em; - margin: -1em -1em 2em; +} + +#setup table.requirements { + margin: -1em; border-spacing: 1em; border-collapse: separate; - border-bottom: 2px solid @colorPetrol; td { + padding: 0; + h2 { margin: 0 1em 0 0; } + table { + font-size: 102%; // Just a hack for webkit, remove this in case you can't see any difference or make it work without it + } + ul { margin: 0; padding-left: 1em; list-style-type: square; } + &.title { + width: 25%; + } + + &.desc { + width: 50%; + } + &.state { + width: 25%; color: white; padding: 0.4em; From 2d3fec9a42f5362b525912aa5f844f56f5dc7344 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Tue, 10 Mar 2015 09:57:51 +0100 Subject: [PATCH 0912/2920] Do not select host_state_type in the service detail view The column host_state_type is not used in the service detail view. refs #8614 --- modules/monitoring/library/Monitoring/Object/Service.php | 1 - 1 file changed, 1 deletion(-) diff --git a/modules/monitoring/library/Monitoring/Object/Service.php b/modules/monitoring/library/Monitoring/Object/Service.php index 774511ae3..69717a9ea 100644 --- a/modules/monitoring/library/Monitoring/Object/Service.php +++ b/modules/monitoring/library/Monitoring/Object/Service.php @@ -109,7 +109,6 @@ class Service extends MonitoredObject 'host_name', 'host_display_name', 'host_state', - 'host_state_type', 'host_last_state_change', 'host_address', 'host_problem', From 330b575c7cf30c71205814d3de4426c0e12cc37b Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Tue, 10 Mar 2015 09:58:36 +0100 Subject: [PATCH 0913/2920] Remove duplicate service_last_check column from the service detail view select refs #8614 --- modules/monitoring/library/Monitoring/Object/Service.php | 1 - 1 file changed, 1 deletion(-) diff --git a/modules/monitoring/library/Monitoring/Object/Service.php b/modules/monitoring/library/Monitoring/Object/Service.php index 69717a9ea..dff8e7c52 100644 --- a/modules/monitoring/library/Monitoring/Object/Service.php +++ b/modules/monitoring/library/Monitoring/Object/Service.php @@ -132,7 +132,6 @@ class Service extends MonitoredObject 'service_notifications_enabled_changed', 'service_action_url', 'service_notes_url', - 'service_last_check', 'service_next_check', 'service_attempt', 'service_last_notification', From af4bce35575b4ffcfb182c2c4eb3c11009ee0157 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Tue, 10 Mar 2015 10:00:07 +0100 Subject: [PATCH 0914/2920] Do not select icon_image columns in the service detail view The columns host_icon_image and service_icon_image are not used in the service detail view. refs #8665 refs #8614 --- modules/monitoring/library/Monitoring/Object/Service.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/modules/monitoring/library/Monitoring/Object/Service.php b/modules/monitoring/library/Monitoring/Object/Service.php index dff8e7c52..4d043d878 100644 --- a/modules/monitoring/library/Monitoring/Object/Service.php +++ b/modules/monitoring/library/Monitoring/Object/Service.php @@ -122,7 +122,6 @@ class Service extends MonitoredObject 'service_unhandled', 'service_output', 'service_last_state_change', - 'service_icon_image', 'service_long_output', 'service_is_flapping', 'service_state_type', @@ -138,7 +137,6 @@ class Service extends MonitoredObject 'service_check_command', 'service_check_source', 'service_current_notification_number', - 'host_icon_image', 'host_acknowledged', 'host_output', 'host_long_output', From 59f43a0f5eb2007d15843c09fabfce64d1aa06c6 Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Tue, 10 Mar 2015 10:56:05 +0100 Subject: [PATCH 0915/2920] Show module requirements as a separate table refs #8508 --- .../application/forms/RequirementsPage.php | 28 +++++++------- .../scripts/form/setup-requirements.phtml | 37 ++++++++++--------- modules/setup/library/Setup/WebWizard.php | 10 +++-- public/css/icinga/setup.less | 33 +++++------------ 4 files changed, 50 insertions(+), 58 deletions(-) diff --git a/modules/setup/application/forms/RequirementsPage.php b/modules/setup/application/forms/RequirementsPage.php index 086e6e7fc..3ce50b7f1 100644 --- a/modules/setup/application/forms/RequirementsPage.php +++ b/modules/setup/application/forms/RequirementsPage.php @@ -4,7 +4,7 @@ namespace Icinga\Module\Setup\Forms; use Icinga\Web\Form; -use Icinga\Module\Setup\RequirementSet; +use Icinga\Module\Setup\SetupWizard; /** * Wizard page to list setup requirements @@ -12,11 +12,11 @@ use Icinga\Module\Setup\RequirementSet; class RequirementsPage extends Form { /** - * The requirements to list + * The wizard * - * @var RequirementSet + * @var SetupWizard */ - protected $set; + protected $wizard; /** * Initialize this page @@ -28,30 +28,30 @@ class RequirementsPage extends Form } /** - * Set the requirements to list + * Set the wizard * - * @param RequirementSet $set + * @param SetupWizard $wizard * * @return self */ - public function setRequirements(RequirementSet $set) + public function setWizard(SetupWizard $wizard) { - $this->set = $set; + $this->wizard = $wizard; return $this; } /** - * Return the requirements to list + * Return the wizard * - * @return RequirementSet + * @return SetupWizard */ - public function getRequirements() + public function getWizard() { - return $this->set; + return $this->wizard; } /** - * Validate the given form data and check whether the requirements are fulfilled + * Validate the given form data and check whether the wizard's requirements are fulfilled * * @param array $data The data to validate * @@ -63,6 +63,6 @@ class RequirementsPage extends Form return false; } - return $this->set->fulfilled(); + return $this->wizard->getRequirements()->fulfilled(); } } diff --git a/modules/setup/application/views/scripts/form/setup-requirements.phtml b/modules/setup/application/views/scripts/form/setup-requirements.phtml index 571a661b6..fbd2c692a 100644 --- a/modules/setup/application/views/scripts/form/setup-requirements.phtml +++ b/modules/setup/application/views/scripts/form/setup-requirements.phtml @@ -2,23 +2,13 @@ use Icinga\Web\Wizard; -$requirements = $form->getRequirements(); -echo $requirements; - ?> -
    - translate('You may also need to restart the web-server for the changes to take effect!'); ?> - qlink( - $this->translate('Refresh'), - null, - null, - array( - 'class' => 'button-like', - 'title' => $title, - 'aria-label' => sprintf($this->translate('Refresh the page; %s'), $title) - ) - ); ?> -
    +

    Icinga Web 2

    +getWizard()->getRequirements(true); ?> +getWizard()->getPage('setup_modules')->getModuleWizards() as $moduleName => $wizard): ?> +

    translate('Module'); ?>

    +getRequirements(); ?> +
    getElement($form->getTokenElementName()); ?> getElement($form->getUidElementName()); ?> @@ -26,10 +16,23 @@ echo $requirements; getElement(Wizard::BTN_PREV); ?> getElement(Wizard::BTN_NEXT); - if (! $requirements->fulfilled()) { + if (! $form->getWizard()->getRequirements()->fulfilled()) { $btn->setAttrib('disabled', 1); } echo $btn; ?> +
    + translate('You may also need to restart the web-server for the changes to take effect!'); ?> + qlink( + $this->translate('Refresh'), + null, + null, + array( + 'class' => 'button-like', + 'title' => $title, + 'aria-label' => sprintf($this->translate('Refresh the page; %s'), $title) + ) + ); ?> +
    \ No newline at end of file diff --git a/modules/setup/library/Setup/WebWizard.php b/modules/setup/library/Setup/WebWizard.php index e3091bd4d..d16b614f5 100644 --- a/modules/setup/library/Setup/WebWizard.php +++ b/modules/setup/library/Setup/WebWizard.php @@ -115,7 +115,7 @@ class WebWizard extends Wizard implements SetupWizard public function setupPage(Form $page, Request $request) { if ($page->getName() === 'setup_requirements') { - $page->setRequirements($this->getRequirements()); + $page->setWizard($this); } elseif ($page->getName() === 'setup_preferences_type') { $authData = $this->getPageData('setup_authentication_type'); if ($authData['type'] === 'db') { @@ -355,7 +355,7 @@ class WebWizard extends Wizard implements SetupWizard /** * @see SetupWizard::getRequirements() */ - public function getRequirements() + public function getRequirements($skipModules = false) { $set = new RequirementSet(); @@ -502,8 +502,10 @@ class WebWizard extends Wizard implements SetupWizard ) ))); - foreach ($this->getWizards() as $wizard) { - $set->merge($wizard->getRequirements()); + if (! $skipModules) { + foreach ($this->getWizards() as $wizard) { + $set->merge($wizard->getRequirements()); + } } return $set; diff --git a/public/css/icinga/setup.less b/public/css/icinga/setup.less index 31ecd205f..26c4b4e64 100644 --- a/public/css/icinga/setup.less +++ b/public/css/icinga/setup.less @@ -168,14 +168,19 @@ } form#setup_requirements { + margin-top: 2em; padding-top: 0.5em; border-top: 2px solid @colorPetrol; -} -div.requirements-refresh { - width: 25%; - margin-left: 75%; - text-align: center; + div.buttons div.requirements-refresh { + width: 25%; + float: right; + text-align: center; + + a.button-like { + padding: 0.1em 0.4em; + } + } } #setup > table.requirements { @@ -230,24 +235,6 @@ div.requirements-refresh { background-color: @colorCritical; } } - - &.btn-update { - padding-top: 0.3em; - text-align: center; - - div.buttons { - margin: 0; - - a.button-like { - padding: 0.2em 0.5em; - background-color: @colorPetro; - - &:hover, &:focus { - background-color: #666; - } - } - } - } } } From f4446cbaded08c99ab2ba5d6c0bc3c2fcb8817a5 Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Tue, 10 Mar 2015 11:00:51 +0100 Subject: [PATCH 0916/2920] Add todo to the MonitoringWizard related to the livestatus backend type The requirement should be added to the OR-set that has currently both ido requirement sets so that livestatus may the only choice again. refs #8254 --- .../monitoring/library/Monitoring/MonitoringWizard.php | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/modules/monitoring/library/Monitoring/MonitoringWizard.php b/modules/monitoring/library/Monitoring/MonitoringWizard.php index 639986246..496809c33 100644 --- a/modules/monitoring/library/Monitoring/MonitoringWizard.php +++ b/modules/monitoring/library/Monitoring/MonitoringWizard.php @@ -138,6 +138,7 @@ class MonitoringWizard extends Wizard implements SetupWizard { $set = new RequirementSet(); + // TODO(8254): Add this to the $backendSet $set->add(new PhpModuleRequirement(array( 'optional' => true, 'condition' => 'Sockets', @@ -148,7 +149,7 @@ class MonitoringWizard extends Wizard implements SetupWizard ) ))); - $idoSet = new RequirementSet(false, RequirementSet::MODE_OR); + $backendSet = new RequirementSet(false, RequirementSet::MODE_OR); $mysqlSet = new RequirementSet(true); $mysqlSet->add(new PhpModuleRequirement(array( 'optional' => true, @@ -168,7 +169,7 @@ class MonitoringWizard extends Wizard implements SetupWizard 'The Zend database adapter for MySQL is required to access a MySQL database.' ) ))); - $idoSet->merge($mysqlSet); + $backendSet->merge($mysqlSet); $pgsqlSet = new RequirementSet(true); $pgsqlSet->add(new PhpModuleRequirement(array( 'optional' => true, @@ -188,8 +189,8 @@ class MonitoringWizard extends Wizard implements SetupWizard 'The Zend database adapter for PostgreSQL is required to access a PostgreSQL database.' ) ))); - $idoSet->merge($pgsqlSet); - $set->merge($idoSet); + $backendSet->merge($pgsqlSet); + $set->merge($backendSet); return $set; } From d0383a241e0f2bc4d4cd4d4b02d80c43cd3b9448 Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Tue, 10 Mar 2015 12:30:22 +0100 Subject: [PATCH 0917/2920] Use date and mktime instead of cal_days_in_month to count a month's days fixes #8637 --- library/Icinga/Web/Widget/Chart/HistoryColorGrid.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library/Icinga/Web/Widget/Chart/HistoryColorGrid.php b/library/Icinga/Web/Widget/Chart/HistoryColorGrid.php index 96b012db5..d1c9a677f 100644 --- a/library/Icinga/Web/Widget/Chart/HistoryColorGrid.php +++ b/library/Icinga/Web/Widget/Chart/HistoryColorGrid.php @@ -268,7 +268,7 @@ class HistoryColorGrid extends AbstractWidget { } $week++; } - if ($day > cal_days_in_month(CAL_GREGORIAN, $month, $year)) { + if ($day > date('t', mktime(0, 0, 0, $month, 1, $year))) { $month++; if ($month > 12) { $year++; From b2bb5af0a74be5ee1d7720db50a48a9b177094f3 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Tue, 10 Mar 2015 13:01:41 +0100 Subject: [PATCH 0918/2920] Don't select host_problem in the service detail view The column host_problem is not used in the service detail view. refs #8614 --- modules/monitoring/library/Monitoring/Object/Service.php | 1 - 1 file changed, 1 deletion(-) diff --git a/modules/monitoring/library/Monitoring/Object/Service.php b/modules/monitoring/library/Monitoring/Object/Service.php index 4d043d878..f182bd065 100644 --- a/modules/monitoring/library/Monitoring/Object/Service.php +++ b/modules/monitoring/library/Monitoring/Object/Service.php @@ -111,7 +111,6 @@ class Service extends MonitoredObject 'host_state', 'host_last_state_change', 'host_address', - 'host_problem', 'host_handled', 'service_description', 'service_display_name', From 2ba5e8eb0cab01a61608f8e19f0adc5149930418 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Tue, 10 Mar 2015 13:02:57 +0100 Subject: [PATCH 0919/2920] Don't select service_unhandled column in the service detail view The column service_unhandled is not used in the service detail view. refs #8614 --- modules/monitoring/library/Monitoring/Object/Service.php | 1 - 1 file changed, 1 deletion(-) diff --git a/modules/monitoring/library/Monitoring/Object/Service.php b/modules/monitoring/library/Monitoring/Object/Service.php index f182bd065..419ef2f12 100644 --- a/modules/monitoring/library/Monitoring/Object/Service.php +++ b/modules/monitoring/library/Monitoring/Object/Service.php @@ -118,7 +118,6 @@ class Service extends MonitoredObject 'service_in_downtime', 'service_acknowledged', 'service_handled', - 'service_unhandled', 'service_output', 'service_last_state_change', 'service_long_output', From 6d78ab69ef571a1ac032d40562b564d8069946f3 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Tue, 10 Mar 2015 13:03:55 +0100 Subject: [PATCH 0920/2920] Don't select service_severity column in the service detail view The column service_severity is not used in the service detail view. refs #8614 --- modules/monitoring/library/Monitoring/Object/Service.php | 1 - 1 file changed, 1 deletion(-) diff --git a/modules/monitoring/library/Monitoring/Object/Service.php b/modules/monitoring/library/Monitoring/Object/Service.php index 419ef2f12..45278e79e 100644 --- a/modules/monitoring/library/Monitoring/Object/Service.php +++ b/modules/monitoring/library/Monitoring/Object/Service.php @@ -123,7 +123,6 @@ class Service extends MonitoredObject 'service_long_output', 'service_is_flapping', 'service_state_type', - 'service_severity', 'service_last_check', 'service_notifications_enabled', 'service_notifications_enabled_changed', From 9dc6e65e5f1643298ba71ffe4cd1f12d5afa58fa Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Tue, 10 Mar 2015 13:05:39 +0100 Subject: [PATCH 0921/2920] Don't select host_output column in the service detail view The column host_output is not used in the service detail view refs #8614 --- modules/monitoring/library/Monitoring/Object/Service.php | 1 - 1 file changed, 1 deletion(-) diff --git a/modules/monitoring/library/Monitoring/Object/Service.php b/modules/monitoring/library/Monitoring/Object/Service.php index 45278e79e..99867a09f 100644 --- a/modules/monitoring/library/Monitoring/Object/Service.php +++ b/modules/monitoring/library/Monitoring/Object/Service.php @@ -135,7 +135,6 @@ class Service extends MonitoredObject 'service_check_source', 'service_current_notification_number', 'host_acknowledged', - 'host_output', 'host_long_output', 'host_in_downtime', 'host_is_flapping', From da7f959db5c68644f0bfc7e3438692d5bdf42ffb Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Tue, 10 Mar 2015 13:09:59 +0100 Subject: [PATCH 0922/2920] Don't select host_long_output in the service detail view The column host_long_output is not used in the service detail view. refs #8614 --- modules/monitoring/library/Monitoring/Object/Service.php | 1 - 1 file changed, 1 deletion(-) diff --git a/modules/monitoring/library/Monitoring/Object/Service.php b/modules/monitoring/library/Monitoring/Object/Service.php index 99867a09f..25730d448 100644 --- a/modules/monitoring/library/Monitoring/Object/Service.php +++ b/modules/monitoring/library/Monitoring/Object/Service.php @@ -135,7 +135,6 @@ class Service extends MonitoredObject 'service_check_source', 'service_current_notification_number', 'host_acknowledged', - 'host_long_output', 'host_in_downtime', 'host_is_flapping', 'host_last_check', From 151d87f38ca730e6f7776d0418caee27f9ad7fab Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Tue, 10 Mar 2015 13:19:37 +0100 Subject: [PATCH 0923/2920] Don't select host_is_flapping in the service detail view The column host_is_flapping is not used in the service detail view. refs #8614 --- modules/monitoring/library/Monitoring/Object/Service.php | 1 - 1 file changed, 1 deletion(-) diff --git a/modules/monitoring/library/Monitoring/Object/Service.php b/modules/monitoring/library/Monitoring/Object/Service.php index 25730d448..82975de85 100644 --- a/modules/monitoring/library/Monitoring/Object/Service.php +++ b/modules/monitoring/library/Monitoring/Object/Service.php @@ -136,7 +136,6 @@ class Service extends MonitoredObject 'service_current_notification_number', 'host_acknowledged', 'host_in_downtime', - 'host_is_flapping', 'host_last_check', 'host_notifications_enabled', 'host_unhandled_services', From 4102ee290b338d640bf7a2c92e01b14204593bf1 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Tue, 10 Mar 2015 13:22:28 +0100 Subject: [PATCH 0924/2920] Don't select host_last_check in the service detail view The column host_last_check is not used in the service detail view. refs #8614 --- modules/monitoring/library/Monitoring/Object/Service.php | 1 - 1 file changed, 1 deletion(-) diff --git a/modules/monitoring/library/Monitoring/Object/Service.php b/modules/monitoring/library/Monitoring/Object/Service.php index 82975de85..23a89454e 100644 --- a/modules/monitoring/library/Monitoring/Object/Service.php +++ b/modules/monitoring/library/Monitoring/Object/Service.php @@ -136,7 +136,6 @@ class Service extends MonitoredObject 'service_current_notification_number', 'host_acknowledged', 'host_in_downtime', - 'host_last_check', 'host_notifications_enabled', 'host_unhandled_services', 'host_action_url', From f87a43b9d3647efaf9fe67c838490f98508a8529 Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Tue, 10 Mar 2015 13:24:54 +0100 Subject: [PATCH 0925/2920] Catch errors occuring on ldap discoveries fixes #8656 --- modules/setup/application/forms/LdapDiscoveryPage.php | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/modules/setup/application/forms/LdapDiscoveryPage.php b/modules/setup/application/forms/LdapDiscoveryPage.php index 1b8a85c77..588791e2c 100644 --- a/modules/setup/application/forms/LdapDiscoveryPage.php +++ b/modules/setup/application/forms/LdapDiscoveryPage.php @@ -3,6 +3,7 @@ namespace Icinga\Module\Setup\Forms; +use Exception; use Zend_Validate_NotEmpty; use Icinga\Web\Form; use Icinga\Web\Form\ErrorLabeller; @@ -68,9 +69,12 @@ class LdapDiscoveryPage extends Form } if (isset($data['domain']) && $data['domain']) { - $this->discovery = Discovery::discoverDomain($data['domain']); - if ($this->discovery->isSuccess()) { - return true; + try { + $this->discovery = Discovery::discoverDomain($data['domain']); + if ($this->discovery->isSuccess()) { + return true; + } + } catch (Exception $e) { } $this->addError( From b9ec2844f5191f445f974249afe5eef456f876a4 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Tue, 10 Mar 2015 13:25:25 +0100 Subject: [PATCH 0926/2920] Don't select host_unhandled_services in the service detail view The column host_unhandled_services is not used in the service detail view. refs #8614 --- modules/monitoring/library/Monitoring/Object/Service.php | 1 - 1 file changed, 1 deletion(-) diff --git a/modules/monitoring/library/Monitoring/Object/Service.php b/modules/monitoring/library/Monitoring/Object/Service.php index 23a89454e..8be746d88 100644 --- a/modules/monitoring/library/Monitoring/Object/Service.php +++ b/modules/monitoring/library/Monitoring/Object/Service.php @@ -137,7 +137,6 @@ class Service extends MonitoredObject 'host_acknowledged', 'host_in_downtime', 'host_notifications_enabled', - 'host_unhandled_services', 'host_action_url', 'host_notes_url', 'host_display_name', From 0f65f83374481a7d264c84dcddffe81a38c30fe6 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Tue, 10 Mar 2015 13:26:47 +0100 Subject: [PATCH 0927/2920] Don't select host_action_url in the service detail view The column host_action_url is not used in the service detail view. refs #8614 --- modules/monitoring/library/Monitoring/Object/Service.php | 1 - 1 file changed, 1 deletion(-) diff --git a/modules/monitoring/library/Monitoring/Object/Service.php b/modules/monitoring/library/Monitoring/Object/Service.php index 8be746d88..acfddd90f 100644 --- a/modules/monitoring/library/Monitoring/Object/Service.php +++ b/modules/monitoring/library/Monitoring/Object/Service.php @@ -137,7 +137,6 @@ class Service extends MonitoredObject 'host_acknowledged', 'host_in_downtime', 'host_notifications_enabled', - 'host_action_url', 'host_notes_url', 'host_display_name', 'host_alias', From 5f57e290c72ef991637ed7c7ba78383aebb7db59 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Tue, 10 Mar 2015 13:27:07 +0100 Subject: [PATCH 0928/2920] Don't select host_notes_url in the service detail view The column host_notes_url is not used in the service detail view. refs #8614 --- modules/monitoring/library/Monitoring/Object/Service.php | 1 - 1 file changed, 1 deletion(-) diff --git a/modules/monitoring/library/Monitoring/Object/Service.php b/modules/monitoring/library/Monitoring/Object/Service.php index acfddd90f..647ae5ca6 100644 --- a/modules/monitoring/library/Monitoring/Object/Service.php +++ b/modules/monitoring/library/Monitoring/Object/Service.php @@ -137,7 +137,6 @@ class Service extends MonitoredObject 'host_acknowledged', 'host_in_downtime', 'host_notifications_enabled', - 'host_notes_url', 'host_display_name', 'host_alias', 'host_ipv4', From 9146a62573207f7cadec00a2829524df63271fa3 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Tue, 10 Mar 2015 13:28:44 +0100 Subject: [PATCH 0929/2920] Don't select host_ipv4 in the service detail view The column host_ipv4 is not used in the service detail view. refs #8614 --- modules/monitoring/library/Monitoring/Object/Service.php | 1 - 1 file changed, 1 deletion(-) diff --git a/modules/monitoring/library/Monitoring/Object/Service.php b/modules/monitoring/library/Monitoring/Object/Service.php index 647ae5ca6..8fa495648 100644 --- a/modules/monitoring/library/Monitoring/Object/Service.php +++ b/modules/monitoring/library/Monitoring/Object/Service.php @@ -139,7 +139,6 @@ class Service extends MonitoredObject 'host_notifications_enabled', 'host_display_name', 'host_alias', - 'host_ipv4', 'host_severity', 'host_perfdata', 'host_active_checks_enabled', From e1dbe0b9a75ffebce4e4844f43468fca87998d91 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Tue, 10 Mar 2015 13:29:39 +0100 Subject: [PATCH 0930/2920] Don't select host_severity in the service detail view The column host_severity is not used in the service detail view. refs #8614 --- modules/monitoring/library/Monitoring/Object/Service.php | 1 - 1 file changed, 1 deletion(-) diff --git a/modules/monitoring/library/Monitoring/Object/Service.php b/modules/monitoring/library/Monitoring/Object/Service.php index 8fa495648..8412d8542 100644 --- a/modules/monitoring/library/Monitoring/Object/Service.php +++ b/modules/monitoring/library/Monitoring/Object/Service.php @@ -139,7 +139,6 @@ class Service extends MonitoredObject 'host_notifications_enabled', 'host_display_name', 'host_alias', - 'host_severity', 'host_perfdata', 'host_active_checks_enabled', 'host_passive_checks_enabled', From 232b3d3a9f52e6fa5b03b2e11629dce1b7775ae1 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Tue, 10 Mar 2015 13:30:03 +0100 Subject: [PATCH 0931/2920] Don't select host_perfdata in the service detail view The column host_perfdata is not used in the service detail view. refs #8614 --- modules/monitoring/library/Monitoring/Object/Service.php | 1 - 1 file changed, 1 deletion(-) diff --git a/modules/monitoring/library/Monitoring/Object/Service.php b/modules/monitoring/library/Monitoring/Object/Service.php index 8412d8542..e2c3fe801 100644 --- a/modules/monitoring/library/Monitoring/Object/Service.php +++ b/modules/monitoring/library/Monitoring/Object/Service.php @@ -139,7 +139,6 @@ class Service extends MonitoredObject 'host_notifications_enabled', 'host_display_name', 'host_alias', - 'host_perfdata', 'host_active_checks_enabled', 'host_passive_checks_enabled', 'host_last_hard_state', From 2cbeab55daa51c65a5da1a43145fc43620638eeb Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Tue, 10 Mar 2015 13:31:32 +0100 Subject: [PATCH 0932/2920] Don't select host_last_hard_state* in the service detail view The columns host_last_hard_state and host_last_hard_state_change are not used in the service detail view. refs #8614 --- modules/monitoring/library/Monitoring/Object/Service.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/modules/monitoring/library/Monitoring/Object/Service.php b/modules/monitoring/library/Monitoring/Object/Service.php index e2c3fe801..88a62294b 100644 --- a/modules/monitoring/library/Monitoring/Object/Service.php +++ b/modules/monitoring/library/Monitoring/Object/Service.php @@ -141,8 +141,6 @@ class Service extends MonitoredObject 'host_alias', 'host_active_checks_enabled', 'host_passive_checks_enabled', - 'host_last_hard_state', - 'host_last_hard_state_change', 'host_last_time_up', 'host_last_time_down', 'host_last_time_unreachable', From 34ad174f89d4532ce757a3e03ea7a8a93378d392 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Tue, 10 Mar 2015 13:32:28 +0100 Subject: [PATCH 0933/2920] Don't select host_last_time_* in the service detail view The columns host_last_time_ up, down and unreachable are not used in the service detail view. refs #8614 --- modules/monitoring/library/Monitoring/Object/Service.php | 3 --- 1 file changed, 3 deletions(-) diff --git a/modules/monitoring/library/Monitoring/Object/Service.php b/modules/monitoring/library/Monitoring/Object/Service.php index 88a62294b..810b326d9 100644 --- a/modules/monitoring/library/Monitoring/Object/Service.php +++ b/modules/monitoring/library/Monitoring/Object/Service.php @@ -141,9 +141,6 @@ class Service extends MonitoredObject 'host_alias', 'host_active_checks_enabled', 'host_passive_checks_enabled', - 'host_last_time_up', - 'host_last_time_down', - 'host_last_time_unreachable', 'host_modified_host_attributes', 'host', 'service', From d65aa39ebd862673d926ca94f337fa70d8108393 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Tue, 10 Mar 2015 13:33:17 +0100 Subject: [PATCH 0934/2920] Don't select host_modified_host_attributes in the service detail view The column host_modified_host_attributes is not used in the service detail view. refs #8614 --- modules/monitoring/library/Monitoring/Object/Service.php | 1 - 1 file changed, 1 deletion(-) diff --git a/modules/monitoring/library/Monitoring/Object/Service.php b/modules/monitoring/library/Monitoring/Object/Service.php index 810b326d9..16cb64e0c 100644 --- a/modules/monitoring/library/Monitoring/Object/Service.php +++ b/modules/monitoring/library/Monitoring/Object/Service.php @@ -141,7 +141,6 @@ class Service extends MonitoredObject 'host_alias', 'host_active_checks_enabled', 'host_passive_checks_enabled', - 'host_modified_host_attributes', 'host', 'service', 'service_hard_state', From 4e308016bfd48fa3b96e6048c3c79ab228f30537 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Tue, 10 Mar 2015 13:37:40 +0100 Subject: [PATCH 0935/2920] Don't select service_hard_state in the service detail view The column service_hard_state is not used in the service detail view. refs #8614 --- modules/monitoring/library/Monitoring/Object/Service.php | 1 - 1 file changed, 1 deletion(-) diff --git a/modules/monitoring/library/Monitoring/Object/Service.php b/modules/monitoring/library/Monitoring/Object/Service.php index 16cb64e0c..526e367d6 100644 --- a/modules/monitoring/library/Monitoring/Object/Service.php +++ b/modules/monitoring/library/Monitoring/Object/Service.php @@ -143,7 +143,6 @@ class Service extends MonitoredObject 'host_passive_checks_enabled', 'host', 'service', - 'service_hard_state', 'service_problem', 'service_perfdata', 'service_active_checks_enabled', From 3bbd68dc95f0f9403738a203398bf7e47fca86bc Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Tue, 10 Mar 2015 13:38:12 +0100 Subject: [PATCH 0936/2920] Don't select service_problem in the service detail view The column service_problem is not used in the service detail view. refs #8614 --- modules/monitoring/library/Monitoring/Object/Service.php | 1 - 1 file changed, 1 deletion(-) diff --git a/modules/monitoring/library/Monitoring/Object/Service.php b/modules/monitoring/library/Monitoring/Object/Service.php index 526e367d6..ce60d6c69 100644 --- a/modules/monitoring/library/Monitoring/Object/Service.php +++ b/modules/monitoring/library/Monitoring/Object/Service.php @@ -143,7 +143,6 @@ class Service extends MonitoredObject 'host_passive_checks_enabled', 'host', 'service', - 'service_problem', 'service_perfdata', 'service_active_checks_enabled', 'service_active_checks_enabled_changed', From 88dce0c1f4f578779227651ee6278c9d6cc1fc9d Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Tue, 10 Mar 2015 13:38:30 +0100 Subject: [PATCH 0937/2920] Don't select host and service columns in the service detail view The columns host and service are not used in the service detail view. refs #8614 --- modules/monitoring/library/Monitoring/Object/Service.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/modules/monitoring/library/Monitoring/Object/Service.php b/modules/monitoring/library/Monitoring/Object/Service.php index ce60d6c69..7e792c3c1 100644 --- a/modules/monitoring/library/Monitoring/Object/Service.php +++ b/modules/monitoring/library/Monitoring/Object/Service.php @@ -141,8 +141,6 @@ class Service extends MonitoredObject 'host_alias', 'host_active_checks_enabled', 'host_passive_checks_enabled', - 'host', - 'service', 'service_perfdata', 'service_active_checks_enabled', 'service_active_checks_enabled_changed', From 70ef6263b2ab3c63197b13e00c7afb1d41df0572 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Tue, 10 Mar 2015 13:45:20 +0100 Subject: [PATCH 0938/2920] Don't select service_last_hard_state* in the service detail view The columns service_last_hard_state and service_last_hard_state_change are not used in the service detail view. refs #8614 --- modules/monitoring/library/Monitoring/Object/Service.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/modules/monitoring/library/Monitoring/Object/Service.php b/modules/monitoring/library/Monitoring/Object/Service.php index 7e792c3c1..242870231 100644 --- a/modules/monitoring/library/Monitoring/Object/Service.php +++ b/modules/monitoring/library/Monitoring/Object/Service.php @@ -146,8 +146,6 @@ class Service extends MonitoredObject 'service_active_checks_enabled_changed', 'service_passive_checks_enabled', 'service_passive_checks_enabled_changed', - 'service_last_hard_state', - 'service_last_hard_state_change', 'service_last_time_ok', 'service_last_time_warning', 'service_last_time_critical', From 0cc6b5d0c2851e738316a2efd5e5581346b2716d Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Tue, 10 Mar 2015 13:46:09 +0100 Subject: [PATCH 0939/2920] Don't select service_last_time_* in the service detail view The columns service_last_time_ ok, warning, critical and unknown are not used in the service detail view. refs #8614 --- modules/monitoring/library/Monitoring/Object/Service.php | 4 ---- 1 file changed, 4 deletions(-) diff --git a/modules/monitoring/library/Monitoring/Object/Service.php b/modules/monitoring/library/Monitoring/Object/Service.php index 242870231..6ef118973 100644 --- a/modules/monitoring/library/Monitoring/Object/Service.php +++ b/modules/monitoring/library/Monitoring/Object/Service.php @@ -146,10 +146,6 @@ class Service extends MonitoredObject 'service_active_checks_enabled_changed', 'service_passive_checks_enabled', 'service_passive_checks_enabled_changed', - 'service_last_time_ok', - 'service_last_time_warning', - 'service_last_time_critical', - 'service_last_time_unknown', 'service_check_execution_time', 'service_check_latency', 'service_current_check_attempt', From 87e5bdfa4cb0105c8be9f84d8f3d265d370cc083 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Tue, 10 Mar 2015 13:47:20 +0100 Subject: [PATCH 0940/2920] Do not select columns for check attempt twice in the service detail view The column service_attempt is used in favor of service_current_check_attempt and service_max_check_attempts. refs #8614 --- modules/monitoring/library/Monitoring/Object/Service.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/modules/monitoring/library/Monitoring/Object/Service.php b/modules/monitoring/library/Monitoring/Object/Service.php index 6ef118973..ee59ed806 100644 --- a/modules/monitoring/library/Monitoring/Object/Service.php +++ b/modules/monitoring/library/Monitoring/Object/Service.php @@ -148,8 +148,6 @@ class Service extends MonitoredObject 'service_passive_checks_enabled_changed', 'service_check_execution_time', 'service_check_latency', - 'service_current_check_attempt', - 'service_max_check_attempts', 'service_obsessing', 'service_obsessing_changed', 'service_event_handler_enabled', From 62f0f5b6a4d890c8ef9200b34a81ff1096fa500c Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Tue, 10 Mar 2015 14:00:17 +0100 Subject: [PATCH 0941/2920] Don't select service_modified_service_attributes in the service detail view The column service_modified_service_attributes is not used in the service detail view. refs #8614 --- modules/monitoring/library/Monitoring/Object/Service.php | 1 - 1 file changed, 1 deletion(-) diff --git a/modules/monitoring/library/Monitoring/Object/Service.php b/modules/monitoring/library/Monitoring/Object/Service.php index ee59ed806..93328a48c 100644 --- a/modules/monitoring/library/Monitoring/Object/Service.php +++ b/modules/monitoring/library/Monitoring/Object/Service.php @@ -154,7 +154,6 @@ class Service extends MonitoredObject 'service_event_handler_enabled_changed', 'service_flap_detection_enabled', 'service_flap_detection_enabled_changed', - 'service_modified_service_attributes', 'service_process_performance_data', 'process_perfdata' => 'service_process_performance_data', 'service_percent_state_change', From e0acebf474d90e35c6635e86d5a1dd17d579b82b Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Tue, 10 Mar 2015 14:09:53 +0100 Subject: [PATCH 0942/2920] Don't select service_host_name in the service detail view We already select the host_name. refs #8614 --- modules/monitoring/library/Monitoring/Object/Service.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/modules/monitoring/library/Monitoring/Object/Service.php b/modules/monitoring/library/Monitoring/Object/Service.php index 93328a48c..2ffc5a74b 100644 --- a/modules/monitoring/library/Monitoring/Object/Service.php +++ b/modules/monitoring/library/Monitoring/Object/Service.php @@ -156,8 +156,7 @@ class Service extends MonitoredObject 'service_flap_detection_enabled_changed', 'service_process_performance_data', 'process_perfdata' => 'service_process_performance_data', - 'service_percent_state_change', - 'service_host_name' + 'service_percent_state_change' )) ->where('host_name', $this->host->getName()) ->where('service_description', $this->service); From fcb94af93c4a55d8dcab661eb9f5c588ec952cce Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Tue, 10 Mar 2015 14:11:50 +0100 Subject: [PATCH 0943/2920] Don't select service_process_performance_data twice in the service detail view refs #8614 --- modules/monitoring/library/Monitoring/Object/Service.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/modules/monitoring/library/Monitoring/Object/Service.php b/modules/monitoring/library/Monitoring/Object/Service.php index 2ffc5a74b..9599a51cb 100644 --- a/modules/monitoring/library/Monitoring/Object/Service.php +++ b/modules/monitoring/library/Monitoring/Object/Service.php @@ -154,8 +154,7 @@ class Service extends MonitoredObject 'service_event_handler_enabled_changed', 'service_flap_detection_enabled', 'service_flap_detection_enabled_changed', - 'service_process_performance_data', - 'process_perfdata' => 'service_process_performance_data', + 'service_process_perfdata' => 'service_process_performance_data', 'service_percent_state_change' )) ->where('host_name', $this->host->getName()) From e6949eaab4d56e4b770b30ce67e291426ca68fb8 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Tue, 10 Mar 2015 14:17:09 +0100 Subject: [PATCH 0944/2920] Reorder columns to select in the Service object refs #8614 --- .../library/Monitoring/Object/Service.php | 76 +++++++++---------- 1 file changed, 38 insertions(+), 38 deletions(-) diff --git a/modules/monitoring/library/Monitoring/Object/Service.php b/modules/monitoring/library/Monitoring/Object/Service.php index 9599a51cb..fc317fc8d 100644 --- a/modules/monitoring/library/Monitoring/Object/Service.php +++ b/modules/monitoring/library/Monitoring/Object/Service.php @@ -106,56 +106,56 @@ class Service extends MonitoredObject protected function getDataView() { return $this->backend->select()->from('serviceStatus', array( - 'host_name', - 'host_display_name', - 'host_state', - 'host_last_state_change', - 'host_address', - 'host_handled', - 'service_description', - 'service_display_name', - 'service_state', - 'service_in_downtime', - 'service_acknowledged', - 'service_handled', - 'service_output', - 'service_last_state_change', - 'service_long_output', - 'service_is_flapping', - 'service_state_type', - 'service_last_check', - 'service_notifications_enabled', - 'service_notifications_enabled_changed', - 'service_action_url', - 'service_notes_url', - 'service_next_check', - 'service_attempt', - 'service_last_notification', - 'service_check_command', - 'service_check_source', - 'service_current_notification_number', 'host_acknowledged', - 'host_in_downtime', - 'host_notifications_enabled', - 'host_display_name', - 'host_alias', 'host_active_checks_enabled', + 'host_address', + 'host_alias', + 'host_display_name', + 'host_display_name', + 'host_handled', + 'host_in_downtime', + 'host_last_state_change', + 'host_name', + 'host_notifications_enabled', 'host_passive_checks_enabled', - 'service_perfdata', + 'host_state', + 'service_acknowledged', + 'service_action_url', 'service_active_checks_enabled', 'service_active_checks_enabled_changed', - 'service_passive_checks_enabled', - 'service_passive_checks_enabled_changed', + 'service_attempt', + 'service_check_command', 'service_check_execution_time', 'service_check_latency', - 'service_obsessing', - 'service_obsessing_changed', + 'service_check_source', + 'service_current_notification_number', + 'service_description', + 'service_display_name', 'service_event_handler_enabled', 'service_event_handler_enabled_changed', 'service_flap_detection_enabled', 'service_flap_detection_enabled_changed', + 'service_handled', + 'service_in_downtime', + 'service_is_flapping', + 'service_last_check', + 'service_last_notification', + 'service_last_state_change', + 'service_long_output', + 'service_next_check', + 'service_notes_url', + 'service_notifications_enabled', + 'service_notifications_enabled_changed', + 'service_obsessing', + 'service_obsessing_changed', + 'service_output', + 'service_passive_checks_enabled', + 'service_passive_checks_enabled_changed', + 'service_percent_state_change', + 'service_perfdata', 'service_process_perfdata' => 'service_process_performance_data', - 'service_percent_state_change' + 'service_state', + 'service_state_type' )) ->where('host_name', $this->host->getName()) ->where('service_description', $this->service); From 5ed6838f509e5877b301776c20d40e6a70efe1fa Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Tue, 10 Mar 2015 14:18:08 +0100 Subject: [PATCH 0945/2920] Don't select host_display_name twice in the service detail view refs #8614 --- modules/monitoring/library/Monitoring/Object/Service.php | 1 - 1 file changed, 1 deletion(-) diff --git a/modules/monitoring/library/Monitoring/Object/Service.php b/modules/monitoring/library/Monitoring/Object/Service.php index fc317fc8d..4195b0ff4 100644 --- a/modules/monitoring/library/Monitoring/Object/Service.php +++ b/modules/monitoring/library/Monitoring/Object/Service.php @@ -111,7 +111,6 @@ class Service extends MonitoredObject 'host_address', 'host_alias', 'host_display_name', - 'host_display_name', 'host_handled', 'host_in_downtime', 'host_last_state_change', From a34d6026b31a112922508e01f8aad46df47fd162 Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Tue, 10 Mar 2015 15:03:48 +0100 Subject: [PATCH 0946/2920] LdapResourceForm: Validate the host field and do not require a port fixes #7990 --- .../Config/Resource/LdapResourceForm.php | 36 +++++++++++++++---- library/Icinga/Protocol/Ldap/Connection.php | 3 +- library/Icinga/Web/Form/Element/Number.php | 13 ++++--- 3 files changed, 38 insertions(+), 14 deletions(-) diff --git a/application/forms/Config/Resource/LdapResourceForm.php b/application/forms/Config/Resource/LdapResourceForm.php index 499d39941..90cc17939 100644 --- a/application/forms/Config/Resource/LdapResourceForm.php +++ b/application/forms/Config/Resource/LdapResourceForm.php @@ -32,7 +32,7 @@ class LdapResourceForm extends Form array( 'required' => true, 'label' => $this->translate('Resource Name'), - 'description' => $this->translate('The unique name of this resource') + 'description' => $this->translate('The unique name of this resource.') ) ); $this->addElement( @@ -42,18 +42,40 @@ class LdapResourceForm extends Form 'required' => true, 'label' => $this->translate('Host'), 'description' => $this->translate( - 'The hostname or address of the LDAP server to use for authentication' + 'The hostname, address or URL of the LDAP server.' ), - 'value' => 'localhost' + 'value' => 'localhost', + 'validators' => array( + array( + 'Callback', + false, + array( + 'callback' => function ($v) { + return strpos($v, '?') === false; + }, + 'messages' => array( + 'callbackValue' => $this->translate( + 'The URL pointing to the LDAP server must not contain any filter attributes.' + ) + ) + ) + ) + ), + 'requirement' => $this->translate( + 'The LDAP server\'s URL must have the following format: [ldap[s]://]host[:port]' + ) ) ); $this->addElement( 'number', 'port', array( - 'required' => true, + 'allowEmpty' => true, 'label' => $this->translate('Port'), - 'description' => $this->translate('The port of the LDAP server to use for authentication'), + 'description' => $this->translate( + 'The port of the LDAP server. Leave empty if you\'ll set this as part of the URL above.' + . ' If not set the default port (389) is being used.' + ), 'value' => 389 ) ); @@ -74,7 +96,7 @@ class LdapResourceForm extends Form array( 'required' => true, 'label' => $this->translate('Bind DN'), - 'description' => $this->translate('The user dn to use for querying the ldap server') + 'description' => $this->translate('The user dn to use for querying the ldap server.') ) ); $this->addElement( @@ -84,7 +106,7 @@ class LdapResourceForm extends Form 'required' => true, 'renderPassword' => true, 'label' => $this->translate('Bind Password'), - 'description' => $this->translate('The password to use for querying the ldap server') + 'description' => $this->translate('The password to use for querying the ldap server.') ) ); diff --git a/library/Icinga/Protocol/Ldap/Connection.php b/library/Icinga/Protocol/Ldap/Connection.php index 053c6c908..e705c19b8 100644 --- a/library/Icinga/Protocol/Ldap/Connection.php +++ b/library/Icinga/Protocol/Ldap/Connection.php @@ -3,7 +3,6 @@ namespace Icinga\Protocol\Ldap; -use Exception; use Icinga\Exception\ProgrammingError; use Icinga\Protocol\Ldap\Exception as LdapException; use Icinga\Application\Platform; @@ -76,7 +75,7 @@ class Connection $this->bind_dn = $config->bind_dn; $this->bind_pw = $config->bind_pw; $this->root_dn = $config->root_dn; - $this->port = $config->get('port', $this->port); + $this->port = $config->get('port') ?: $this->port; } public function getHostname() diff --git a/library/Icinga/Web/Form/Element/Number.php b/library/Icinga/Web/Form/Element/Number.php index 8a1217363..95640c5ca 100644 --- a/library/Icinga/Web/Form/Element/Number.php +++ b/library/Icinga/Web/Form/Element/Number.php @@ -132,12 +132,15 @@ class Number extends FormElement */ public function isValid($value, $context = null) { - $this->setValue($value); - $value = $this->getValue(); - if (! is_numeric($value)) { - $this->addError(sprintf($this->translate('\'%s\' is not a valid number'), $value)); + if (! parent::isValid($value, $context)) { return false; } - return parent::isValid($value, $context); + + if ((! empty($value) || !$this->getAllowEmpty()) && !is_numeric($value)) { + $this->addError(sprintf(t('\'%s\' is not a valid number'), $value)); + return false; + } + + return true; } } From e72e340faa9db5531ddc71131cf113862d22c72c Mon Sep 17 00:00:00 2001 From: Markus Frosch Date: Tue, 10 Mar 2015 18:21:33 +0100 Subject: [PATCH 0947/2920] Remove Debian packaging from GIT Refs #6402 --- packages/debian/README.1st | 3 - packages/debian/changelog | 5 -- packages/debian/compat | 1 - packages/debian/control | 68 ------------------- packages/debian/icinga-php.install | 1 - packages/debian/icingacli.install | 3 - packages/debian/icingaweb-common.dirs | 1 - packages/debian/icingaweb-common.install | 2 - packages/debian/icingaweb-module-doc.install | 1 - .../icingaweb-module-monitoring.install | 1 - .../debian/icingaweb-module-setup.install | 1 - packages/debian/icingaweb-module-test.install | 1 - .../icingaweb-module-translation.install | 1 - .../icingaweb-vendor-htmlpurifier.install | 1 - .../debian/icingaweb-vendor-jshrink.install | 1 - .../debian/icingaweb-vendor-lessphp.install | 1 - .../debian/icingaweb-vendor-parsedown.install | 1 - packages/debian/icingaweb-vendor-zend.install | 1 - packages/debian/icingaweb.install | 10 --- packages/debian/rules | 35 ---------- packages/debian/source/format | 1 - packages/debian/substvars | 1 - 22 files changed, 141 deletions(-) delete mode 100644 packages/debian/README.1st delete mode 100644 packages/debian/changelog delete mode 100644 packages/debian/compat delete mode 100644 packages/debian/control delete mode 100644 packages/debian/icinga-php.install delete mode 100644 packages/debian/icingacli.install delete mode 100644 packages/debian/icingaweb-common.dirs delete mode 100644 packages/debian/icingaweb-common.install delete mode 100644 packages/debian/icingaweb-module-doc.install delete mode 100644 packages/debian/icingaweb-module-monitoring.install delete mode 100644 packages/debian/icingaweb-module-setup.install delete mode 100644 packages/debian/icingaweb-module-test.install delete mode 100644 packages/debian/icingaweb-module-translation.install delete mode 100644 packages/debian/icingaweb-vendor-htmlpurifier.install delete mode 100644 packages/debian/icingaweb-vendor-jshrink.install delete mode 100644 packages/debian/icingaweb-vendor-lessphp.install delete mode 100644 packages/debian/icingaweb-vendor-parsedown.install delete mode 100644 packages/debian/icingaweb-vendor-zend.install delete mode 100644 packages/debian/icingaweb.install delete mode 100755 packages/debian/rules delete mode 100644 packages/debian/source/format delete mode 100644 packages/debian/substvars diff --git a/packages/debian/README.1st b/packages/debian/README.1st deleted file mode 100644 index 66c58c719..000000000 --- a/packages/debian/README.1st +++ /dev/null @@ -1,3 +0,0 @@ -PLEASE DO NOT BUILD PACKAGES BASES ON THIS - -Packages may still be renamed diff --git a/packages/debian/changelog b/packages/debian/changelog deleted file mode 100644 index ed074d733..000000000 --- a/packages/debian/changelog +++ /dev/null @@ -1,5 +0,0 @@ -icingaweb (2.0.0) stable; urgency=low - - * First stable release (Closes: #0001) - - -- Thomas Gelf Fri, 28 Mar 2014 23:37:31 +0100 diff --git a/packages/debian/compat b/packages/debian/compat deleted file mode 100644 index ec635144f..000000000 --- a/packages/debian/compat +++ /dev/null @@ -1 +0,0 @@ -9 diff --git a/packages/debian/control b/packages/debian/control deleted file mode 100644 index 73d0b57a3..000000000 --- a/packages/debian/control +++ /dev/null @@ -1,68 +0,0 @@ -Source: icingaweb -Section: admin -Maintainer: Icinga Development Team -Priority: optional -Build-Depends: debhelper (>=9) -Standards-Version: 3.9.4 -Homepage: https://www.icinga.org - -Package: php-icinga -Architecture: any -Depends: php5 (>= 5.3.2) -Recommends: php5-ldap, php5-mysql, php5-json -Suggests: php5-pgsql -Description: Icinga PHP libraries - PHP libraries - -Package: icingaweb-common -Architecture: any -Depends: php-icinga -Description: Icinga PHP common libraries - PHP common libraries, application and modules - -Package: icingaweb-module-doc -Architecture: any -Depends: icingaweb-common -Description: Icingaweb documentation module - This module renders documentation for Icingaweb and its modules - -Package: icingaweb-module-monitoring -Architecture: any -Depends: icingaweb-common -Description: Icingaweb monitoring module - Use this module to visualize your monitoring environment in Icingaweb - -Package: icingaweb-module-setup -Architecture: any -Depends: icingaweb-common -Description: Icingaweb setup module - This setup wizard does your initial Icingaweb configuration - -Package: icingaweb-module-test -Architecture: any -Depends: icingacli -Description: Icingaweb test module - Use this module to run unit tests against Icingaweb or any of its modules - -Package: icingaweb-module-translation -Architecture: any -Depends: icingaweb-common -Description: Icingaweb translation module - This module helps translators to get Icingaweb translations done - -Package: icingacli -Architecture: any -Depends: icingaweb-common, php5-cli (>= 5.3.2) -Description: Icinga CLI tool - The Icinga CLI allows one to access its Icinga monitoring - system from a terminal. - . - The CLI is based on the Icinga PHP libraries - -Package: icingaweb -Architecture: any -Depends: icingaweb-common, libapache2-mod-php5, zendframework | icingaweb-vendor-zend, icingaweb-vendor-parsedown, icingaweb-vendor-lessphp, icingaweb-vendor-jshrink, icingaweb-vendor-htmlpurifier, icingaweb-module-setup -Recommends: icingaweb-module-monitoring, icingaweb-module-doc -Suggests: php5-ldap -Description: Icingaweb Frontend - Icingaweb is a modular web frontend diff --git a/packages/debian/icinga-php.install b/packages/debian/icinga-php.install deleted file mode 100644 index 6cbd03f13..000000000 --- a/packages/debian/icinga-php.install +++ /dev/null @@ -1 +0,0 @@ -library/Icinga usr/share/php diff --git a/packages/debian/icingacli.install b/packages/debian/icingacli.install deleted file mode 100644 index be3db5e1c..000000000 --- a/packages/debian/icingacli.install +++ /dev/null @@ -1,3 +0,0 @@ -packages/files/bin/icingacli usr/bin -etc/bash_completion.d etc/bash_completion.d -application/clicommands usr/share/icingaweb/application diff --git a/packages/debian/icingaweb-common.dirs b/packages/debian/icingaweb-common.dirs deleted file mode 100644 index 00ec00632..000000000 --- a/packages/debian/icingaweb-common.dirs +++ /dev/null @@ -1 +0,0 @@ -etc/icingaweb diff --git a/packages/debian/icingaweb-common.install b/packages/debian/icingaweb-common.install deleted file mode 100644 index 91a34bcee..000000000 --- a/packages/debian/icingaweb-common.install +++ /dev/null @@ -1,2 +0,0 @@ -application/locales usr/share/icingaweb/application -modules usr/share/icingaweb diff --git a/packages/debian/icingaweb-module-doc.install b/packages/debian/icingaweb-module-doc.install deleted file mode 100644 index 1482e8c66..000000000 --- a/packages/debian/icingaweb-module-doc.install +++ /dev/null @@ -1 +0,0 @@ -modules/doc usr/share/icingaweb/modules diff --git a/packages/debian/icingaweb-module-monitoring.install b/packages/debian/icingaweb-module-monitoring.install deleted file mode 100644 index 1482e8c66..000000000 --- a/packages/debian/icingaweb-module-monitoring.install +++ /dev/null @@ -1 +0,0 @@ -modules/doc usr/share/icingaweb/modules diff --git a/packages/debian/icingaweb-module-setup.install b/packages/debian/icingaweb-module-setup.install deleted file mode 100644 index 4fdd070d2..000000000 --- a/packages/debian/icingaweb-module-setup.install +++ /dev/null @@ -1 +0,0 @@ -modules/setup usr/share/icingaweb/modules diff --git a/packages/debian/icingaweb-module-test.install b/packages/debian/icingaweb-module-test.install deleted file mode 100644 index e0db79bca..000000000 --- a/packages/debian/icingaweb-module-test.install +++ /dev/null @@ -1 +0,0 @@ -modules/test usr/share/icingaweb/modules diff --git a/packages/debian/icingaweb-module-translation.install b/packages/debian/icingaweb-module-translation.install deleted file mode 100644 index 5a89d3d4d..000000000 --- a/packages/debian/icingaweb-module-translation.install +++ /dev/null @@ -1 +0,0 @@ -modules/translation usr/share/icingaweb/modules diff --git a/packages/debian/icingaweb-vendor-htmlpurifier.install b/packages/debian/icingaweb-vendor-htmlpurifier.install deleted file mode 100644 index 298284f29..000000000 --- a/packages/debian/icingaweb-vendor-htmlpurifier.install +++ /dev/null @@ -1 +0,0 @@ -library/vendor/HTMLPurifier usr/share/icingaweb/library/vendor diff --git a/packages/debian/icingaweb-vendor-jshrink.install b/packages/debian/icingaweb-vendor-jshrink.install deleted file mode 100644 index 0db6b408b..000000000 --- a/packages/debian/icingaweb-vendor-jshrink.install +++ /dev/null @@ -1 +0,0 @@ -library/vendor/JShrink usr/share/icingaweb/library/vendor diff --git a/packages/debian/icingaweb-vendor-lessphp.install b/packages/debian/icingaweb-vendor-lessphp.install deleted file mode 100644 index 1ace5481e..000000000 --- a/packages/debian/icingaweb-vendor-lessphp.install +++ /dev/null @@ -1 +0,0 @@ -library/vendor/Zend usr/share/icingaweb/library/vendor diff --git a/packages/debian/icingaweb-vendor-parsedown.install b/packages/debian/icingaweb-vendor-parsedown.install deleted file mode 100644 index 13954e16b..000000000 --- a/packages/debian/icingaweb-vendor-parsedown.install +++ /dev/null @@ -1 +0,0 @@ -library/vendor/Parsedown usr/share/icingaweb/library/vendor diff --git a/packages/debian/icingaweb-vendor-zend.install b/packages/debian/icingaweb-vendor-zend.install deleted file mode 100644 index 1ace5481e..000000000 --- a/packages/debian/icingaweb-vendor-zend.install +++ /dev/null @@ -1 +0,0 @@ -library/vendor/Zend usr/share/icingaweb/library/vendor diff --git a/packages/debian/icingaweb.install b/packages/debian/icingaweb.install deleted file mode 100644 index 0fdee4dc0..000000000 --- a/packages/debian/icingaweb.install +++ /dev/null @@ -1,10 +0,0 @@ -public/css usr/share/icingaweb/public -public/img usr/share/icingaweb/public -public/js usr/share/icingaweb/public -public/error_norewrite.html usr/share/icingaweb/public -application/controllers usr/share/icingaweb/application -application/fonts usr/share/icingaweb/application -application/layouts usr/share/icingaweb/application -application/views usr/share/icingaweb/application -packages/files/public/index.php usr/share/icingaweb/public -packages/files/apache/icingaweb.conf etc/apache2/conf.d diff --git a/packages/debian/rules b/packages/debian/rules deleted file mode 100755 index fbe100736..000000000 --- a/packages/debian/rules +++ /dev/null @@ -1,35 +0,0 @@ -#!/usr/bin/make -f -#export DH_VERBOSE=1 - -%: - dh $@ - -clean: - dh_testdir - dh_clean - -build: - dh_testdir - -binary: - dh_testroot - dh_prep - dh_installdirs - dh_install - dh_installchangelogs - dh_installexamples - dh_installman - dh_installcron - dh_installdebconf - dh_installinfo - dh_installinit - dpkg-statoverride --force --add root www-data 2770 /etc/icingaweb - dh_compress - dh_fixperms - dh_strip - dh_shlibdeps - dh_installdeb - dh_gencontrol - dh_md5sums - dh_builddeb - diff --git a/packages/debian/source/format b/packages/debian/source/format deleted file mode 100644 index af745b310..000000000 --- a/packages/debian/source/format +++ /dev/null @@ -1 +0,0 @@ -3.0 (git) diff --git a/packages/debian/substvars b/packages/debian/substvars deleted file mode 100644 index abd3ebebc..000000000 --- a/packages/debian/substvars +++ /dev/null @@ -1 +0,0 @@ -misc:Depends= From e4e6c1cb28922320c484767b0112d953484e5caf Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Wed, 11 Mar 2015 07:58:40 +0100 Subject: [PATCH 0948/2920] Wizard: Fix that the wrong form element is used in case a user already exists fixes #8678 --- .../application/views/scripts/form/setup-admin-account.phtml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/setup/application/views/scripts/form/setup-admin-account.phtml b/modules/setup/application/views/scripts/form/setup-admin-account.phtml index 77220017c..99e5692b3 100644 --- a/modules/setup/application/views/scripts/form/setup-admin-account.phtml +++ b/modules/setup/application/views/scripts/form/setup-admin-account.phtml @@ -35,7 +35,7 @@ $showRadioBoxes = strpos(strtolower(get_class($radioElem)), 'radio') !== false; getElement('existing_user')) !== null): ?>
    - setAttrib('data-related-radiobtn', 'existing_user') : $existingUserElem; ?> + setAttrib('data-related-radiobtn', 'existing_user') : $existingUserElem; ?>
    From 2cf09ebc48159b1b85f46444fd83373dff3ef52a Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Wed, 11 Mar 2015 08:00:20 +0100 Subject: [PATCH 0949/2920] Revert "LdapResourceForm: Validate the host field and do not require a port" This reverts commit a34d6026b31a112922508e01f8aad46df47fd162. refs #7990 --- .../Config/Resource/LdapResourceForm.php | 36 ++++--------------- library/Icinga/Protocol/Ldap/Connection.php | 3 +- library/Icinga/Web/Form/Element/Number.php | 13 +++---- 3 files changed, 14 insertions(+), 38 deletions(-) diff --git a/application/forms/Config/Resource/LdapResourceForm.php b/application/forms/Config/Resource/LdapResourceForm.php index 90cc17939..499d39941 100644 --- a/application/forms/Config/Resource/LdapResourceForm.php +++ b/application/forms/Config/Resource/LdapResourceForm.php @@ -32,7 +32,7 @@ class LdapResourceForm extends Form array( 'required' => true, 'label' => $this->translate('Resource Name'), - 'description' => $this->translate('The unique name of this resource.') + 'description' => $this->translate('The unique name of this resource') ) ); $this->addElement( @@ -42,40 +42,18 @@ class LdapResourceForm extends Form 'required' => true, 'label' => $this->translate('Host'), 'description' => $this->translate( - 'The hostname, address or URL of the LDAP server.' + 'The hostname or address of the LDAP server to use for authentication' ), - 'value' => 'localhost', - 'validators' => array( - array( - 'Callback', - false, - array( - 'callback' => function ($v) { - return strpos($v, '?') === false; - }, - 'messages' => array( - 'callbackValue' => $this->translate( - 'The URL pointing to the LDAP server must not contain any filter attributes.' - ) - ) - ) - ) - ), - 'requirement' => $this->translate( - 'The LDAP server\'s URL must have the following format: [ldap[s]://]host[:port]' - ) + 'value' => 'localhost' ) ); $this->addElement( 'number', 'port', array( - 'allowEmpty' => true, + 'required' => true, 'label' => $this->translate('Port'), - 'description' => $this->translate( - 'The port of the LDAP server. Leave empty if you\'ll set this as part of the URL above.' - . ' If not set the default port (389) is being used.' - ), + 'description' => $this->translate('The port of the LDAP server to use for authentication'), 'value' => 389 ) ); @@ -96,7 +74,7 @@ class LdapResourceForm extends Form array( 'required' => true, 'label' => $this->translate('Bind DN'), - 'description' => $this->translate('The user dn to use for querying the ldap server.') + 'description' => $this->translate('The user dn to use for querying the ldap server') ) ); $this->addElement( @@ -106,7 +84,7 @@ class LdapResourceForm extends Form 'required' => true, 'renderPassword' => true, 'label' => $this->translate('Bind Password'), - 'description' => $this->translate('The password to use for querying the ldap server.') + 'description' => $this->translate('The password to use for querying the ldap server') ) ); diff --git a/library/Icinga/Protocol/Ldap/Connection.php b/library/Icinga/Protocol/Ldap/Connection.php index e705c19b8..053c6c908 100644 --- a/library/Icinga/Protocol/Ldap/Connection.php +++ b/library/Icinga/Protocol/Ldap/Connection.php @@ -3,6 +3,7 @@ namespace Icinga\Protocol\Ldap; +use Exception; use Icinga\Exception\ProgrammingError; use Icinga\Protocol\Ldap\Exception as LdapException; use Icinga\Application\Platform; @@ -75,7 +76,7 @@ class Connection $this->bind_dn = $config->bind_dn; $this->bind_pw = $config->bind_pw; $this->root_dn = $config->root_dn; - $this->port = $config->get('port') ?: $this->port; + $this->port = $config->get('port', $this->port); } public function getHostname() diff --git a/library/Icinga/Web/Form/Element/Number.php b/library/Icinga/Web/Form/Element/Number.php index 95640c5ca..8a1217363 100644 --- a/library/Icinga/Web/Form/Element/Number.php +++ b/library/Icinga/Web/Form/Element/Number.php @@ -132,15 +132,12 @@ class Number extends FormElement */ public function isValid($value, $context = null) { - if (! parent::isValid($value, $context)) { + $this->setValue($value); + $value = $this->getValue(); + if (! is_numeric($value)) { + $this->addError(sprintf($this->translate('\'%s\' is not a valid number'), $value)); return false; } - - if ((! empty($value) || !$this->getAllowEmpty()) && !is_numeric($value)) { - $this->addError(sprintf(t('\'%s\' is not a valid number'), $value)); - return false; - } - - return true; + return parent::isValid($value, $context); } } From 0758be4af13e79e9402f032fd67b12730c992b0e Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Wed, 11 Mar 2015 09:50:41 +0100 Subject: [PATCH 0950/2920] Add support for dynamic ldap filter expressions "Dynamic" is a more of a overstatement when describing this commit but the current implementation is just the start. Once our ldap protocol stuff supports our filter implementation this will be vastly improved. refs #8365 --- library/Icinga/Protocol/Ldap/Expression.php | 30 +++++++++++++++++++++ library/Icinga/Protocol/Ldap/Query.php | 27 +++++++++++++++---- 2 files changed, 52 insertions(+), 5 deletions(-) create mode 100644 library/Icinga/Protocol/Ldap/Expression.php diff --git a/library/Icinga/Protocol/Ldap/Expression.php b/library/Icinga/Protocol/Ldap/Expression.php new file mode 100644 index 000000000..403e1fd04 --- /dev/null +++ b/library/Icinga/Protocol/Ldap/Expression.php @@ -0,0 +1,30 @@ +value = $value; + } + + public function setValue($value) + { + $this->value = $value; + return $this; + } + + public function getValue() + { + return $this->value; + } + + public function __toString() + { + return (string) $this->getValue(); + } +} diff --git a/library/Icinga/Protocol/Ldap/Query.php b/library/Icinga/Protocol/Ldap/Query.php index 897f12f4e..4e25fe9d4 100644 --- a/library/Icinga/Protocol/Ldap/Query.php +++ b/library/Icinga/Protocol/Ldap/Query.php @@ -306,6 +306,19 @@ class Query return $paginator; } + /** + * Add a filter expression to this query + * + * @param Expression $expression + * + * @return Query + */ + public function addFilter(Expression $expression) + { + $this->filters[] = $expression; + return $this; + } + /** * Returns the LDAP filter that will be applied * @@ -318,11 +331,15 @@ class Query throw new Exception('Object class is mandatory'); } foreach ($this->filters as $key => $value) { - $parts[] = sprintf( - '%s=%s', - LdapUtils::quoteForSearch($key), - LdapUtils::quoteForSearch($value, true) - ); + if ($value instanceof Expression) { + $parts[] = (string) $value; + } else { + $parts[] = sprintf( + '%s=%s', + LdapUtils::quoteForSearch($key), + LdapUtils::quoteForSearch($value, true) + ); + } } if (count($parts) > 1) { return '(&(' . implode(')(', $parts) . '))'; From 39a74c4f3d3fb7859ced908316b17b13d6ef56ca Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Wed, 11 Mar 2015 09:52:14 +0100 Subject: [PATCH 0951/2920] LDAP-Auth backend config: Add support for custom LDAP filter rules refs #8365 --- .../Config/Authentication/LdapBackendForm.php | 58 +++++++++++++++---- .../Backend/LdapUserBackend.php | 29 ++++++++-- library/Icinga/Authentication/UserBackend.php | 2 + .../application/forms/AdminAccountPage.php | 3 +- .../Setup/Steps/AuthenticationStep.php | 8 ++- 5 files changed, 81 insertions(+), 19 deletions(-) diff --git a/application/forms/Config/Authentication/LdapBackendForm.php b/application/forms/Config/Authentication/LdapBackendForm.php index 4c7a027a7..838be7776 100644 --- a/application/forms/Config/Authentication/LdapBackendForm.php +++ b/application/forms/Config/Authentication/LdapBackendForm.php @@ -55,7 +55,7 @@ class LdapBackendForm extends Form 'required' => true, 'label' => $this->translate('Backend Name'), 'description' => $this->translate( - 'The name of this authentication provider that is used to differentiate it from others' + 'The name of this authentication provider that is used to differentiate it from others.' ) ) ); @@ -64,8 +64,10 @@ class LdapBackendForm extends Form 'resource', array( 'required' => true, - 'label' => $this->translate('LDAP Resource'), - 'description' => $this->translate('The resource to use for authenticating with this provider'), + 'label' => $this->translate('LDAP Connection'), + 'description' => $this->translate( + 'The LDAP connection to use for authenticating with this provider.' + ), 'multiOptions' => false === empty($this->resources) ? array_combine($this->resources, $this->resources) : array() @@ -77,10 +79,40 @@ class LdapBackendForm extends Form array( 'required' => true, 'label' => $this->translate('LDAP User Object Class'), - 'description' => $this->translate('The object class used for storing users on the ldap server'), + 'description' => $this->translate('The object class used for storing users on the LDAP server.'), 'value' => 'inetOrgPerson' ) ); + $this->addElement( + 'text', + 'filter', + array( + 'allowEmpty' => true, + 'label' => $this->translate('LDAP Filter'), + 'description' => $this->translate( + 'An additional filter to use when looking up users using the specified connection. ' + . 'Leave empty to not to use any additional filter rules.' + ), + 'requirement' => $this->translate( + 'The filter needs to be expressed as standard LDAP expression, without' + . ' outer parentheses. (e.g. &(foo=bar)(bar=foo) or foo=bar)' + ), + 'validators' => array( + array( + 'Callback', + false, + array( + 'callback' => function ($v) { + return strpos($v, '(') !== 0; + }, + 'messages' => array( + 'callbackValue' => $this->translate('The filter must not be wrapped in parantheses.') + ) + ) + ) + ) + ) + ); $this->addElement( 'text', 'user_name_attribute', @@ -88,7 +120,7 @@ class LdapBackendForm extends Form 'required' => true, 'label' => $this->translate('LDAP User Name Attribute'), 'description' => $this->translate( - 'The attribute name used for storing the user name on the ldap server' + 'The attribute name used for storing the user name on the LDAP server.' ), 'value' => 'uid' ) @@ -106,10 +138,10 @@ class LdapBackendForm extends Form 'base_dn', array( 'required' => false, - 'label' => $this->translate('Base DN'), + 'label' => $this->translate('LDAP Base DN'), 'description' => $this->translate( - 'The path where users can be found on the ldap server. Leave ' . - 'empty to select all users available on the specified resource.' + 'The path where users can be found on the LDAP server. Leave ' . + 'empty to select all users available using the specified connection.' ) ) ); @@ -142,11 +174,17 @@ class LdapBackendForm extends Form ResourceFactory::createResource($form->getResourceConfig()), $form->getElement('user_class')->getValue(), $form->getElement('user_name_attribute')->getValue(), - $form->getElement('base_dn')->getValue() + $form->getElement('base_dn')->getValue(), + $form->getElement('filter')->getValue() ); $ldapUserBackend->assertAuthenticationPossible(); } catch (AuthenticationException $e) { - $form->addError($e->getMessage()); + if (($previous = $e->getPrevious()) !== null) { + $form->addError($previous->getMessage()); + } else { + $form->addError($e->getMessage()); + } + return false; } catch (Exception $e) { $form->addError(sprintf($form->translate('Unable to validate authentication: %s'), $e->getMessage())); diff --git a/library/Icinga/Authentication/Backend/LdapUserBackend.php b/library/Icinga/Authentication/Backend/LdapUserBackend.php index 016512ab4..211f05711 100644 --- a/library/Icinga/Authentication/Backend/LdapUserBackend.php +++ b/library/Icinga/Authentication/Backend/LdapUserBackend.php @@ -9,6 +9,7 @@ use Icinga\Protocol\Ldap\Query; use Icinga\Protocol\Ldap\Connection; use Icinga\Exception\AuthenticationException; use Icinga\Protocol\Ldap\Exception as LdapException; +use Icinga\Protocol\Ldap\Expression; class LdapUserBackend extends UserBackend { @@ -25,14 +26,23 @@ class LdapUserBackend extends UserBackend protected $userNameAttribute; + protected $customFilter; + protected $groupOptions; - public function __construct(Connection $conn, $userClass, $userNameAttribute, $baseDn, $groupOptions = null) - { + public function __construct( + Connection $conn, + $userClass, + $userNameAttribute, + $baseDn, + $cutomFilter, + $groupOptions = null + ) { $this->conn = $conn; - $this->baseDn = trim($baseDn) !== '' ? $baseDn : $conn->getDN(); + $this->baseDn = trim($baseDn) ?: $conn->getDN(); $this->userClass = $userClass; $this->userNameAttribute = $userNameAttribute; + $this->customFilter = trim($cutomFilter); $this->groupOptions = $groupOptions; } @@ -43,12 +53,18 @@ class LdapUserBackend extends UserBackend */ protected function selectUsers() { - return $this->conn->select()->setBase($this->baseDn)->from( + $query = $this->conn->select()->setBase($this->baseDn)->from( $this->userClass, array( $this->userNameAttribute ) ); + + if ($this->customFilter) { + $query->addFilter(new Expression($this->customFilter)); + } + + return $query; } /** @@ -88,9 +104,10 @@ class LdapUserBackend extends UserBackend if ($result === null) { throw new AuthenticationException( - 'No objects with objectClass="%s" in DN="%s" found.', + 'No objects with objectClass="%s" in DN="%s" found. (Filter: %s)', $this->userClass, - $this->baseDn + $this->baseDn, + $this->customFilter ?: 'None' ); } diff --git a/library/Icinga/Authentication/UserBackend.php b/library/Icinga/Authentication/UserBackend.php index cb6eb458b..e5a090bb5 100644 --- a/library/Icinga/Authentication/UserBackend.php +++ b/library/Icinga/Authentication/UserBackend.php @@ -103,6 +103,7 @@ abstract class UserBackend implements Countable $backendConfig->get('user_class', 'user'), $backendConfig->get('user_name_attribute', 'sAMAccountName'), $backendConfig->get('base_dn', $resource->getDN()), + $backendConfig->get('filter'), $groupOptions ); break; @@ -130,6 +131,7 @@ abstract class UserBackend implements Countable $backendConfig->user_class, $backendConfig->user_name_attribute, $backendConfig->get('base_dn', $resource->getDN()), + $backendConfig->get('filter'), $groupOptions ); break; diff --git a/modules/setup/application/forms/AdminAccountPage.php b/modules/setup/application/forms/AdminAccountPage.php index da9e90a14..d0766ed3c 100644 --- a/modules/setup/application/forms/AdminAccountPage.php +++ b/modules/setup/application/forms/AdminAccountPage.php @@ -272,7 +272,8 @@ class AdminAccountPage extends Form ResourceFactory::createResource(new ConfigObject($this->resourceConfig)), $this->backendConfig['user_class'], $this->backendConfig['user_name_attribute'], - $this->backendConfig['base_dn'] + $this->backendConfig['base_dn'], + $this->backendConfig['filter'] ); } else { throw new LogicException( diff --git a/modules/setup/library/Setup/Steps/AuthenticationStep.php b/modules/setup/library/Setup/Steps/AuthenticationStep.php index 495a42469..9de0c9867 100644 --- a/modules/setup/library/Setup/Steps/AuthenticationStep.php +++ b/modules/setup/library/Setup/Steps/AuthenticationStep.php @@ -126,11 +126,15 @@ class AuthenticationStep extends Step . '' . ($authType === 'ldap' ? ( '
    ' - . '' + . '' . '' . '' . '' - . '' + . '' + . '' + . '' + . '' + . '' . '' . '' ) : ($authType === 'external' ? ( From ba0154ab7957897268143bd45fc45738eb2f4415 Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Wed, 11 Mar 2015 10:21:06 +0100 Subject: [PATCH 0952/2920] Tab: Use the title as caption if there is no label set yet --- library/Icinga/Web/Widget/Tab.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/library/Icinga/Web/Widget/Tab.php b/library/Icinga/Web/Widget/Tab.php index c7fb30ff8..a210a206e 100644 --- a/library/Icinga/Web/Widget/Tab.php +++ b/library/Icinga/Web/Widget/Tab.php @@ -140,6 +140,10 @@ class Tab extends AbstractWidget */ public function getLabel() { + if (! $this->label) { + return $this->title; + } + return $this->label; } @@ -238,7 +242,7 @@ class Tab extends AbstractWidget $classes[] = 'active'; } - $caption = $view->escape($this->label); + $caption = $view->escape($this->getLabel()); $tagParams = $this->tagParams; if ($this->title) { From 132ae9e44c645c04a16a5a8cae5d8cb536068697 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Wed, 11 Mar 2015 10:43:19 +0100 Subject: [PATCH 0953/2920] Use {@inheritdoc} in the Comment data view ... ... instead of duplicating method documentation. refs #8614 --- .../monitoring/library/Monitoring/DataView/Comment.php | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/modules/monitoring/library/Monitoring/DataView/Comment.php b/modules/monitoring/library/Monitoring/DataView/Comment.php index f2d98895c..5172690bb 100644 --- a/modules/monitoring/library/Monitoring/DataView/Comment.php +++ b/modules/monitoring/library/Monitoring/DataView/Comment.php @@ -9,9 +9,7 @@ namespace Icinga\Module\Monitoring\DataView; class Comment extends DataView { /** - * Retrieve columns provided by this view - * - * @return array + * {@inheritdoc} */ public function getColumns() { @@ -34,9 +32,7 @@ class Comment extends DataView } /** - * Retrieve default sorting rules for particular columns. These involve sort order and potential additional to sort - * - * @return array + * {@inheritdoc} */ public function getSortRules() { From c69a46d005959afae483571fc63d415d55bfedfc Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Wed, 11 Mar 2015 11:30:38 +0100 Subject: [PATCH 0954/2920] Add PHPDoc to the Downtime query refs #8614 --- .../Backend/Ido/Query/DowntimeQuery.php | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/modules/monitoring/library/Monitoring/Backend/Ido/Query/DowntimeQuery.php b/modules/monitoring/library/Monitoring/Backend/Ido/Query/DowntimeQuery.php index db4305c0d..f1981ef7f 100644 --- a/modules/monitoring/library/Monitoring/Backend/Ido/Query/DowntimeQuery.php +++ b/modules/monitoring/library/Monitoring/Backend/Ido/Query/DowntimeQuery.php @@ -3,8 +3,14 @@ namespace Icinga\Module\Monitoring\Backend\Ido\Query; +/** + * Query for host and service downtimes + */ class DowntimeQuery extends IdoQuery { + /** + * {@inheritdoc} + */ protected $columnMap = array( 'downtime' => array( 'downtime_author' => 'sd.author_name', @@ -44,6 +50,9 @@ class DowntimeQuery extends IdoQuery ) ); + /** + * {@inheritdoc} + */ protected function joinBaseTables() { $this->select->from( @@ -63,6 +72,11 @@ class DowntimeQuery extends IdoQuery $this->joinedVirtualTables = array('downtime' => true); } + /** + * Join downtimes' hosts + * + * @return $this + */ protected function joinHosts() { $this->select->joinLeft( @@ -73,6 +87,11 @@ class DowntimeQuery extends IdoQuery return $this; } + /** + * Join downtimes' hosts' status + * + * @return $this + */ protected function joinHoststatus() { $this->select->joinLeft( @@ -80,8 +99,14 @@ class DowntimeQuery extends IdoQuery 'ho.object_id = hs.host_object_id', array() ); + return $this; } + /** + * Join downtimes' services + * + * @return $this + */ protected function joinServices() { $this->select->joinLeft( @@ -97,6 +122,11 @@ class DowntimeQuery extends IdoQuery return $this; } + /** + * Join downtimes' services' status + * + * @return $this + */ protected function joinServicestatus() { $this->select->joinLeft( From ea32d3dfb31cd92cfe89a85165be08e13c6d3851 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Wed, 11 Mar 2015 11:54:23 +0100 Subject: [PATCH 0955/2920] Add PHPDoc to the EventHistory query refs #8614 --- .../Backend/Ido/Query/EventHistoryQuery.php | 44 ++++++++++++++++++- 1 file changed, 43 insertions(+), 1 deletion(-) diff --git a/modules/monitoring/library/Monitoring/Backend/Ido/Query/EventHistoryQuery.php b/modules/monitoring/library/Monitoring/Backend/Ido/Query/EventHistoryQuery.php index 12395abca..370fad9af 100644 --- a/modules/monitoring/library/Monitoring/Backend/Ido/Query/EventHistoryQuery.php +++ b/modules/monitoring/library/Monitoring/Backend/Ido/Query/EventHistoryQuery.php @@ -6,10 +6,23 @@ namespace Icinga\Module\Monitoring\Backend\Ido\Query; use Zend_Db_Select; use Icinga\Data\Filter\Filter; +/** + * Query for event history + */ class EventHistoryQuery extends IdoQuery { + /** + * Subqueries used for the event history query + * + * @type IdoQuery[] + * + * @see EventHistoryQuery::joinBaseTables() For the used subqueries. + */ protected $subQueries = array(); + /** + * {@inheritdoc} + */ protected $columnMap = array( 'eventhistory' => array( 'cnt_notification' => "SUM(CASE eh.type WHEN 'notify' THEN 1 ELSE 0 END)", @@ -41,8 +54,14 @@ class EventHistoryQuery extends IdoQuery ) ); + /** + * {@inheritdoc} + */ protected $useSubqueryCount = true; + /** + * {@inheritdoc} + */ protected function joinBaseTables() { $columns = array( @@ -77,15 +96,20 @@ class EventHistoryQuery extends IdoQuery $this->joinedVirtualTables = array('eventhistory' => true); } + /** + * {@inheritdoc} + */ public function order($columnOrAlias, $dir = null) { foreach ($this->subQueries as $sub) { $sub->requireColumn($columnOrAlias); } - return parent::order($columnOrAlias, $dir); } + /** + * {@inheritdoc} + */ public function addFilter(Filter $filter) { foreach ($this->subQueries as $sub) { @@ -94,6 +118,9 @@ class EventHistoryQuery extends IdoQuery return $this; } + /** + * {@inheritdoc} + */ public function where($condition, $value = null) { $this->requireColumn($condition); @@ -103,6 +130,11 @@ class EventHistoryQuery extends IdoQuery return $this; } + /** + * Join host groups + * + * @return $this + */ protected function joinHostgroups() { $this->select->join( @@ -121,6 +153,11 @@ class EventHistoryQuery extends IdoQuery return $this; } + /** + * Join hosts + * + * @return $this + */ protected function joinHosts() { $this->select->joinLeft( @@ -131,6 +168,11 @@ class EventHistoryQuery extends IdoQuery return $this; } + /** + * Join services + * + * @return $this + */ protected function joinServices() { $this->select->joinLeft( From e72670cb753db1f9cb96751a9f42200f93b356e2 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Wed, 11 Mar 2015 12:03:05 +0100 Subject: [PATCH 0956/2920] Use default sorting for an object's event history refs #8614 --- modules/monitoring/library/Monitoring/Object/MonitoredObject.php | 1 - 1 file changed, 1 deletion(-) diff --git a/modules/monitoring/library/Monitoring/Object/MonitoredObject.php b/modules/monitoring/library/Monitoring/Object/MonitoredObject.php index 0f382f214..38053f5a2 100644 --- a/modules/monitoring/library/Monitoring/Object/MonitoredObject.php +++ b/modules/monitoring/library/Monitoring/Object/MonitoredObject.php @@ -459,7 +459,6 @@ abstract class MonitoredObject implements Filterable 'output', 'type' )) - ->order('timestamp', 'DESC') ->where('host_name', $this->host_name); if ($this->type === self::TYPE_SERVICE) { $eventHistory->where('service_description', $this->service_description); From 37d09511c630e6217e9b4ba3e986ac49db401b67 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Wed, 11 Mar 2015 13:07:33 +0100 Subject: [PATCH 0957/2920] Don't select host_modified_host_attributes in the host detail view The column host_modified_host_attributes is not used in the host detail view. refs #8614 --- modules/monitoring/library/Monitoring/Object/Host.php | 1 - 1 file changed, 1 deletion(-) diff --git a/modules/monitoring/library/Monitoring/Object/Host.php b/modules/monitoring/library/Monitoring/Object/Host.php index 273c65eae..93db2b815 100644 --- a/modules/monitoring/library/Monitoring/Object/Host.php +++ b/modules/monitoring/library/Monitoring/Object/Host.php @@ -128,7 +128,6 @@ class Host extends MonitoredObject 'host_is_flapping', 'host_action_url', 'host_notes_url', - 'host_modified_host_attributes', 'host_problem', 'host_process_performance_data', 'process_perfdata' => 'host_process_performance_data' From 84f56f4e5185feabb77680c41e8e5a356dd913ed Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Wed, 11 Mar 2015 13:08:11 +0100 Subject: [PATCH 0958/2920] Don't select host_problem in the host detail view The column host_problem is not used in the host detail view. refs #8614 --- modules/monitoring/library/Monitoring/Object/Host.php | 1 - 1 file changed, 1 deletion(-) diff --git a/modules/monitoring/library/Monitoring/Object/Host.php b/modules/monitoring/library/Monitoring/Object/Host.php index 93db2b815..502be01a1 100644 --- a/modules/monitoring/library/Monitoring/Object/Host.php +++ b/modules/monitoring/library/Monitoring/Object/Host.php @@ -128,7 +128,6 @@ class Host extends MonitoredObject 'host_is_flapping', 'host_action_url', 'host_notes_url', - 'host_problem', 'host_process_performance_data', 'process_perfdata' => 'host_process_performance_data' ); From ef4970c0c13d11280e12fcdd604d83558ead7b33 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Wed, 11 Mar 2015 13:08:53 +0100 Subject: [PATCH 0959/2920] Don't select host_process_performance_data twice in the host detail view refs #8614 --- modules/monitoring/library/Monitoring/Object/Host.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/modules/monitoring/library/Monitoring/Object/Host.php b/modules/monitoring/library/Monitoring/Object/Host.php index 502be01a1..7c132c22b 100644 --- a/modules/monitoring/library/Monitoring/Object/Host.php +++ b/modules/monitoring/library/Monitoring/Object/Host.php @@ -128,8 +128,7 @@ class Host extends MonitoredObject 'host_is_flapping', 'host_action_url', 'host_notes_url', - 'host_process_performance_data', - 'process_perfdata' => 'host_process_performance_data' + 'host_process_perfdata' => 'host_process_performance_data' ); if ($this->backend->getType() === 'livestatus') { $columns[] = 'host_contacts'; From b501fef62b3000453dd4761b4f51b073a5399165 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Wed, 11 Mar 2015 13:10:55 +0100 Subject: [PATCH 0960/2920] Rearrange columns in the Host object refs #8614 --- .../library/Monitoring/Object/Host.php | 60 +++++++++---------- 1 file changed, 30 insertions(+), 30 deletions(-) diff --git a/modules/monitoring/library/Monitoring/Object/Host.php b/modules/monitoring/library/Monitoring/Object/Host.php index 7c132c22b..359065e57 100644 --- a/modules/monitoring/library/Monitoring/Object/Host.php +++ b/modules/monitoring/library/Monitoring/Object/Host.php @@ -89,46 +89,46 @@ class Host extends MonitoredObject protected function getDataView() { $columns = array( - 'host_name', - 'host_display_name', - 'host_alias', - 'host_address', - 'host_state', - 'host_state_type', - 'host_handled', - 'host_in_downtime', 'host_acknowledged', - 'host_last_state_change', - 'host_last_notification', - 'host_last_check', - 'host_next_check', + 'host_action_url', + 'host_active_checks_enabled', + 'host_active_checks_enabled_changed', + 'host_address', + 'host_alias', + 'host_check_command', 'host_check_execution_time', 'host_check_latency', 'host_check_source', - 'host_output', - 'host_long_output', - 'host_check_command', - 'host_perfdata', - 'host_passive_checks_enabled', - 'host_passive_checks_enabled_changed', - 'host_obsessing', - 'host_obsessing_changed', - 'host_notifications_enabled', - 'host_notifications_enabled_changed', + 'host_current_check_attempt', + 'host_current_notification_number', + 'host_display_name', 'host_event_handler_enabled', 'host_event_handler_enabled_changed', 'host_flap_detection_enabled', 'host_flap_detection_enabled_changed', - 'host_active_checks_enabled', - 'host_active_checks_enabled_changed', - 'host_current_check_attempt', - 'host_max_check_attempts', - 'host_current_notification_number', - 'host_percent_state_change', + 'host_handled', + 'host_in_downtime', 'host_is_flapping', - 'host_action_url', + 'host_last_check', + 'host_last_notification', + 'host_last_state_change', + 'host_long_output', + 'host_max_check_attempts', + 'host_name', + 'host_next_check', 'host_notes_url', - 'host_process_perfdata' => 'host_process_performance_data' + 'host_notifications_enabled', + 'host_notifications_enabled_changed', + 'host_obsessing', + 'host_obsessing_changed', + 'host_output', + 'host_passive_checks_enabled', + 'host_passive_checks_enabled_changed', + 'host_percent_state_change', + 'host_perfdata', + 'host_process_perfdata' => 'host_process_performance_data', + 'host_state', + 'host_state_type' ); if ($this->backend->getType() === 'livestatus') { $columns[] = 'host_contacts'; From 0286641369d39c7aa47c6051b38099e178919b66 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Wed, 11 Mar 2015 13:32:54 +0100 Subject: [PATCH 0961/2920] Don't fetch comments and downtimes twice in an object's detail view The controller counts comments and downtimes on the object, which will automatically fetch comments and downtimes. After that came a call to MonitoredObject::populate() which again fetched comments and downtimes. Now the object is populated before counting comments and dowtimes. refs #8614 --- .../Monitoring/Web/Controller/MonitoredObjectController.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/modules/monitoring/library/Monitoring/Web/Controller/MonitoredObjectController.php b/modules/monitoring/library/Monitoring/Web/Controller/MonitoredObjectController.php index f553c12f3..1b8fd2336 100644 --- a/modules/monitoring/library/Monitoring/Web/Controller/MonitoredObjectController.php +++ b/modules/monitoring/library/Monitoring/Web/Controller/MonitoredObjectController.php @@ -73,6 +73,7 @@ abstract class MonitoredObjectController extends Controller } } } + $this->object->populate(); if (count($this->object->comments) > 0 && $auth->hasPermission('monitoring/command/comment/delete')) { $delCommentForm = new DeleteCommentCommandForm(); $delCommentForm @@ -93,7 +94,7 @@ abstract class MonitoredObjectController extends Controller ->setObjects($this->object) ->handleRequest(); $this->view->toggleFeaturesForm = $toggleFeaturesForm; - $this->view->object = $this->object->populate(); + $this->view->object = $this->object; } /** From 361afdcf13fe488c0d42cb63fb2883b7becc2710 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Wed, 11 Mar 2015 14:08:43 +0100 Subject: [PATCH 0962/2920] Use ! empty in favor of count > 0 in the MonitoredObjectController refs #8614 --- .../Controller/MonitoredObjectController.php | 28 +++++++++---------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/modules/monitoring/library/Monitoring/Web/Controller/MonitoredObjectController.php b/modules/monitoring/library/Monitoring/Web/Controller/MonitoredObjectController.php index 1b8fd2336..04102e9d2 100644 --- a/modules/monitoring/library/Monitoring/Web/Controller/MonitoredObjectController.php +++ b/modules/monitoring/library/Monitoring/Web/Controller/MonitoredObjectController.php @@ -74,26 +74,26 @@ abstract class MonitoredObjectController extends Controller } } $this->object->populate(); - if (count($this->object->comments) > 0 && $auth->hasPermission('monitoring/command/comment/delete')) { - $delCommentForm = new DeleteCommentCommandForm(); - $delCommentForm - ->setObjects($this->object) - ->handleRequest(); - $this->view->delCommentForm = $delCommentForm; - } - if (count($this->object->downtimes > 0) && $auth->hasPermission('monitoring/command/downtime/delete')) { - $delDowntimeForm = new DeleteDowntimeCommandForm(); - $delDowntimeForm - ->setObjects($this->object) - ->handleRequest(); - $this->view->delDowntimeForm = $delDowntimeForm; - } $toggleFeaturesForm = new ToggleObjectFeaturesCommandForm(); $toggleFeaturesForm ->load($this->object) ->setObjects($this->object) ->handleRequest(); $this->view->toggleFeaturesForm = $toggleFeaturesForm; + if (! empty($this->object->comments) && $auth->hasPermission('monitoring/command/comment/delete')) { + $delCommentForm = new DeleteCommentCommandForm(); + $delCommentForm + ->setObjects($this->object) + ->handleRequest(); + $this->view->delCommentForm = $delCommentForm; + } + if (! empty($this->object->downtimes) && $auth->hasPermission('monitoring/command/downtime/delete')) { + $delDowntimeForm = new DeleteDowntimeCommandForm(); + $delDowntimeForm + ->setObjects($this->object) + ->handleRequest(); + $this->view->delDowntimeForm = $delDowntimeForm; + } $this->view->object = $this->object; } From 815dc8a5fa3a0963a2c50133dad0e2e62c77f580 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Wed, 11 Mar 2015 14:51:59 +0100 Subject: [PATCH 0963/2920] Replace /** with /* for non PHPDoc in the logout script refs #8626 --- application/views/scripts/authentication/logout.phtml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/application/views/scripts/authentication/logout.phtml b/application/views/scripts/authentication/logout.phtml index 9b03d190f..8fc8a1c87 100644 --- a/application/views/scripts/authentication/logout.phtml +++ b/application/views/scripts/authentication/logout.phtml @@ -22,7 +22,7 @@ From d102a61e2294bb19e156f07ae1612e115254bebc Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Wed, 11 Mar 2015 20:50:05 +0100 Subject: [PATCH 0970/2920] Fix Undefined index: HTTP_ACCEPT_LANGUAGE fixes #8370 --- library/Icinga/Application/Web.php | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/library/Icinga/Application/Web.php b/library/Icinga/Application/Web.php index 45dbc7e87..16f8d5131 100644 --- a/library/Icinga/Application/Web.php +++ b/library/Icinga/Application/Web.php @@ -314,13 +314,15 @@ class Web extends ApplicationBootstrap protected function detectLocale() { $auth = Manager::getInstance(); - if (isset($_SERVER['HTTP_ACCEPT_LANGUAGE']) && !$auth->isAuthenticated() - || ($locale = $auth->getUser()->getPreferences()->getValue('icingaweb', 'language')) === null + if ($auth->isAuthenticated() + && ($locale = $auth->getUser()->getPreferences()->getValue('icingaweb', 'language')) !== null ) { - $locale = Translator::getPreferredLocaleCode($_SERVER['HTTP_ACCEPT_LANGUAGE']); + return $locale; } - - return $locale; + if (isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])) { + return Translator::getPreferredLocaleCode($_SERVER['HTTP_ACCEPT_LANGUAGE']); + } + return Translator::DEFAULT_LOCALE; } /** From 031f9ddc84ffabaae40b2ca17603dfb219df094b Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Wed, 11 Mar 2015 21:24:56 +0100 Subject: [PATCH 0971/2920] Don't always redirect to the current window's URL if the redirect URL is __SELF__ Please see code comments for an explanation. refs #8626 --- public/js/icinga/loader.js | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/public/js/icinga/loader.js b/public/js/icinga/loader.js index 6f5df4ea1..addfe2aa0 100644 --- a/public/js/icinga/loader.js +++ b/public/js/icinga/loader.js @@ -246,13 +246,31 @@ }, processRedirectHeader: function(req) { - var icinga = this.icinga; - var redirect = req.getResponseHeader('X-Icinga-Redirect'); - if (! redirect) return false; + var icinga = this.icinga, + redirect = req.getResponseHeader('X-Icinga-Redirect'); + + if (! redirect) { + return false; + } + redirect = decodeURIComponent(redirect); if (redirect.match(/__SELF__/)) { - redirect = redirect.replace(/__SELF__/, encodeURIComponent(document.location.pathname + document.location.search + document.location.hash)); + if (req.autorefresh) { + // Redirect to the current window's URL in case it's an auto-refresh request. If authenticated + // externally this ensures seamless re-login if the session's expired + redirect = redirect.replace( + /__SELF__/, + encodeURIComponent( + document.location.pathname + document.location.search + document.location.hash + ) + ); + } else { + // Redirect to the URL which required authentication. When clicking a link this ensures that we + // redirect to the link's URL instead of the current window's URL (see above) + redirect = redirect.replace(/__SELF__/, req.url); + } } + icinga.logger.debug( 'Got redirect for ', req.$target, ', URL was ' + redirect ); From 7f94858b8df85e07426927b46778b7b334779279 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Wed, 11 Mar 2015 21:26:44 +0100 Subject: [PATCH 0972/2920] Add JSDoc to Icinga.Loader.prototype.processRedirectHeader() refs #8626 --- public/js/icinga/loader.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/public/js/icinga/loader.js b/public/js/icinga/loader.js index addfe2aa0..07ab3cbc1 100644 --- a/public/js/icinga/loader.js +++ b/public/js/icinga/loader.js @@ -245,6 +245,15 @@ } }, + /** + * Process the X-Icinga-Redirect HTTP Response Header + * + * If the response includes the X-Icinga-Redirect header, redirects to the URL associated with the header. + * + * @param {object} req Current request + * + * @returns {boolean} Whether we're about to redirect + */ processRedirectHeader: function(req) { var icinga = this.icinga, redirect = req.getResponseHeader('X-Icinga-Redirect'); From 4ebfbf83abfe7875f2537b69863d2b3a5a065117 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Wed, 11 Mar 2015 21:40:14 +0100 Subject: [PATCH 0973/2920] Leave note about __SELF__ in our action controller refs #8626 --- library/Icinga/Web/Controller/ActionController.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/library/Icinga/Web/Controller/ActionController.php b/library/Icinga/Web/Controller/ActionController.php index 0a1fe8ae4..d1c320bb2 100644 --- a/library/Icinga/Web/Controller/ActionController.php +++ b/library/Icinga/Web/Controller/ActionController.php @@ -307,6 +307,8 @@ class ActionController extends Zend_Controller_Action $afterLogin = Url::fromPath($afterLogin); } if ($this->isXhr()) { + // __SELF__ instructs JavaScript to redirect to the current window's URL in case it's an auto-refreshing + // request or to redirect to the URL which required login in case it's not an auto-refreshing one $redir = '__SELF__'; } else { // TODO: Ignore /? @@ -319,7 +321,6 @@ class ActionController extends Zend_Controller_Action if ($redir) { $url->setParam('redirect', $redir); } - $this->rerenderLayout()->redirectNow($url); } From bc1336b6f99689570406de701384c78db43e1fac Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Wed, 11 Mar 2015 21:49:20 +0100 Subject: [PATCH 0974/2920] Fix stupid code in ActionController::redirectToLogin() refs #8626 --- .../Web/Controller/ActionController.php | 37 +++++++------------ 1 file changed, 14 insertions(+), 23 deletions(-) diff --git a/library/Icinga/Web/Controller/ActionController.php b/library/Icinga/Web/Controller/ActionController.php index d1c320bb2..0949dbc81 100644 --- a/library/Icinga/Web/Controller/ActionController.php +++ b/library/Icinga/Web/Controller/ActionController.php @@ -293,35 +293,26 @@ class ActionController extends Zend_Controller_Action } /** - * Redirect to the login path + * Redirect to login * - * @param Url $afterLogin The action to call when the login was successful. Defaults to '/index/welcome' + * XHR will always redirect to __SELF__. __SELF__ instructs JavaScript to redirect to the current window's URL + * if it's an auto-refresh request or to redirect to the URL which required login if it's not an auto-refreshing + * one. * - * @throws \Exception + * @param Url|string $redirect URL to redirect to after successful login */ - protected function redirectToLogin($afterLogin = null) + protected function redirectToLogin($redirect = null) { - $redir = null; - if ($afterLogin !== null) { - if (! $afterLogin instanceof Url) { - $afterLogin = Url::fromPath($afterLogin); - } - if ($this->isXhr()) { - // __SELF__ instructs JavaScript to redirect to the current window's URL in case it's an auto-refreshing - // request or to redirect to the URL which required login in case it's not an auto-refreshing one - $redir = '__SELF__'; - } else { - // TODO: Ignore /? - $redir = $afterLogin->getRelativeUrl(); + $login = Url::fromPath('authentication/login'); + if ($this->isXhr()) { + $login->setParam('redirect', '__SELF__'); + } elseif ($redirect !== null) { + if (! $redirect instanceof Url) { + $redirect = Url::fromPath($redirect); } + $login->setParam('redirect', $redirect->getRelativeUrl()); } - - $url = Url::fromPath('authentication/login'); - - if ($redir) { - $url->setParam('redirect', $redir); - } - $this->rerenderLayout()->redirectNow($url); + $this->rerenderLayout()->redirectNow($login); } protected function rerenderLayout() From 29d4ad69b9be3bdaabab11b19491cab7fcaad11a Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Wed, 11 Mar 2015 21:50:41 +0100 Subject: [PATCH 0975/2920] Remove // @codeCoverageIgnoreEnd This is obsolete. --- library/Icinga/Application/Web.php | 1 - 1 file changed, 1 deletion(-) diff --git a/library/Icinga/Application/Web.php b/library/Icinga/Application/Web.php index 45dbc7e87..46f677d94 100644 --- a/library/Icinga/Application/Web.php +++ b/library/Icinga/Application/Web.php @@ -337,4 +337,3 @@ class Web extends ApplicationBootstrap return $this; } } -// @codeCoverageIgnoreEnd From 7fe4b3d7ab007790252a7ca365605209a44b54ab Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Wed, 11 Mar 2015 21:55:04 +0100 Subject: [PATCH 0976/2920] Fix PHPDoc of Web::detectLocale() --- library/Icinga/Application/Web.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/library/Icinga/Application/Web.php b/library/Icinga/Application/Web.php index 16f8d5131..b365252f0 100644 --- a/library/Icinga/Application/Web.php +++ b/library/Icinga/Application/Web.php @@ -307,9 +307,11 @@ class Web extends ApplicationBootstrap /** * Setup internationalization using gettext * - * Uses the preferred user language or the configured default and system default, respectively. + * Uses the preferred user language or the browser suggested language or our default. * - * @return self + * @return string Detected locale code + * + * @see Translator::DEFAULT_LOCALE For the the default locale code. */ protected function detectLocale() { From 32ca28bc46da04ed5ff51e9cab8e8c56a13210de Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Wed, 11 Mar 2015 21:58:41 +0100 Subject: [PATCH 0977/2920] Use @return $this for documenting fluent interfaces --- library/Icinga/Application/Web.php | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/library/Icinga/Application/Web.php b/library/Icinga/Application/Web.php index 6145b7ceb..3710ae7a0 100644 --- a/library/Icinga/Application/Web.php +++ b/library/Icinga/Application/Web.php @@ -84,7 +84,7 @@ class Web extends ApplicationBootstrap /** * Initialize all together * - * @return self + * @return $this */ protected function bootstrap() { @@ -112,7 +112,7 @@ class Web extends ApplicationBootstrap /** * Prepare routing * - * @return self + * @return $this */ private function setupRoute() { @@ -161,7 +161,7 @@ class Web extends ApplicationBootstrap /** * Prepare Zend MVC Base * - * @return self + * @return $this */ private function setupZendMvc() { @@ -182,7 +182,7 @@ class Web extends ApplicationBootstrap /** * Create user object * - * @return self + * @return $this */ private function setupUser() { @@ -198,7 +198,7 @@ class Web extends ApplicationBootstrap /** * Initialize a session provider * - * @return self + * @return $this */ private function setupSession() { @@ -209,7 +209,7 @@ class Web extends ApplicationBootstrap /** * Inject dependencies into request * - * @return self + * @return $this */ private function setupRequest() { @@ -225,7 +225,7 @@ class Web extends ApplicationBootstrap /** * Instantiate front controller * - * @return self + * @return $this */ private function setupFrontController() { @@ -247,7 +247,7 @@ class Web extends ApplicationBootstrap /** * Register helper paths and views for renderer * - * @return self + * @return $this */ private function setupViewRenderer() { @@ -270,7 +270,7 @@ class Web extends ApplicationBootstrap /** * Configure pagination settings * - * @return self + * @return $this */ private function setupPagination() { @@ -330,7 +330,7 @@ class Web extends ApplicationBootstrap /** * Setup an autoloader namespace for Icinga\Forms * - * @return self + * @return $this */ private function setupFormNamespace() { From 9e8137055173e61754f7d68baf39376a26dd2680 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Wed, 11 Mar 2015 22:00:09 +0100 Subject: [PATCH 0978/2920] Removed unused use ... in Web.php --- library/Icinga/Application/Web.php | 5 ----- 1 file changed, 5 deletions(-) diff --git a/library/Icinga/Application/Web.php b/library/Icinga/Application/Web.php index 3710ae7a0..b572c443a 100644 --- a/library/Icinga/Application/Web.php +++ b/library/Icinga/Application/Web.php @@ -7,8 +7,6 @@ require_once __DIR__ . '/ApplicationBootstrap.php'; use Icinga\Authentication\Manager as AuthenticationManager; use Icinga\Authentication\Manager; -use Icinga\Exception\ConfigurationError; -use Icinga\Exception\NotReadableError; use Icinga\Application\Logger; use Icinga\Util\TimezoneDetect; use Icinga\Web\Request; @@ -18,9 +16,6 @@ use Icinga\Web\Session\Session as BaseSession; use Icinga\Web\Session; use Icinga\User; use Icinga\Util\Translator; -use Icinga\Util\DateTimeFactory; -use DateTimeZone; -use Exception; use Zend_Layout; use Zend_Paginator; use Zend_View_Helper_PaginationControl; From dfa7e20b741956472d571c329d2402b70fef438b Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Wed, 11 Mar 2015 22:01:41 +0100 Subject: [PATCH 0979/2920] Don't use Icinga\Authentication\Manager twice --- library/Icinga/Application/Web.php | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/library/Icinga/Application/Web.php b/library/Icinga/Application/Web.php index b572c443a..bd5e09d0f 100644 --- a/library/Icinga/Application/Web.php +++ b/library/Icinga/Application/Web.php @@ -5,7 +5,6 @@ namespace Icinga\Application; require_once __DIR__ . '/ApplicationBootstrap.php'; -use Icinga\Authentication\Manager as AuthenticationManager; use Icinga\Authentication\Manager; use Icinga\Application\Logger; use Icinga\Util\TimezoneDetect; @@ -181,12 +180,10 @@ class Web extends ApplicationBootstrap */ private function setupUser() { - $authenticationManager = AuthenticationManager::getInstance(); - - if ($authenticationManager->isAuthenticated() === true) { - $this->user = $authenticationManager->getUser(); + $auth = Manager::getInstance(); + if ($auth->isAuthenticated() === true) { + $this->user = $auth->getUser(); } - return $this; } From c47164601accab061d9c44ca538c46545276c640 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Wed, 11 Mar 2015 22:03:49 +0100 Subject: [PATCH 0980/2920] Don't alias Zend_Controller_Action_HelperBroker in Web.php --- library/Icinga/Application/Web.php | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/library/Icinga/Application/Web.php b/library/Icinga/Application/Web.php index bd5e09d0f..9d6f226b5 100644 --- a/library/Icinga/Application/Web.php +++ b/library/Icinga/Application/Web.php @@ -18,7 +18,7 @@ use Icinga\Util\Translator; use Zend_Layout; use Zend_Paginator; use Zend_View_Helper_PaginationControl; -use Zend_Controller_Action_HelperBroker as ActionHelperBroker; +use Zend_Controller_Action_HelperBroker; use Zend_Controller_Router_Route; use Zend_Controller_Front; @@ -243,19 +243,14 @@ class Web extends ApplicationBootstrap */ private function setupViewRenderer() { + $view = Zend_Controller_Action_HelperBroker::getStaticHelper('viewRenderer'); /** @var \Zend_Controller_Action_Helper_ViewRenderer $view */ - $view = ActionHelperBroker::getStaticHelper('viewRenderer'); $view->setView(new View()); - $view->view->addHelperPath($this->getApplicationDir('/views/helpers')); - $view->view->setEncoding('UTF-8'); $view->view->headTitle()->prepend($this->config->get('global', 'project', 'Icinga')); - $view->view->headTitle()->setSeparator(' :: '); - $this->viewRenderer = $view; - return $this; } From c54648244e14dec40e20bbb6f6edfb4589e16df7 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Wed, 11 Mar 2015 22:05:23 +0100 Subject: [PATCH 0981/2920] Remove newlines from Web.php --- library/Icinga/Application/Web.php | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/library/Icinga/Application/Web.php b/library/Icinga/Application/Web.php index 9d6f226b5..e4e3583c1 100644 --- a/library/Icinga/Application/Web.php +++ b/library/Icinga/Application/Web.php @@ -166,10 +166,8 @@ class Web extends ApplicationBootstrap 'layoutPath' => $this->getApplicationDir('/layouts/scripts') ) ); - $this->setupFrontController(); $this->setupViewRenderer(); - return $this; } @@ -206,11 +204,9 @@ class Web extends ApplicationBootstrap private function setupRequest() { $this->request = new Request(); - if ($this->user instanceof User) { $this->request->setUser($this->user); } - return $this; } @@ -222,17 +218,13 @@ class Web extends ApplicationBootstrap private function setupFrontController() { $this->frontController = Zend_Controller_Front::getInstance(); - $this->frontController->setRequest($this->request); - $this->frontController->setControllerDirectory($this->getApplicationDir('/controllers')); - $this->frontController->setParams( array( 'displayExceptions' => true ) ); - return $this; } @@ -261,17 +253,14 @@ class Web extends ApplicationBootstrap */ private function setupPagination() { - Zend_Paginator::addScrollingStylePrefixPath( 'Icinga_Web_Paginator_ScrollingStyle', 'Icinga/Web/Paginator/ScrollingStyle' ); - Zend_Paginator::setDefaultScrollingStyle('SlidingWithBorder'); Zend_View_Helper_PaginationControl::setDefaultViewPartial( array('mixedPagination.phtml', 'default') ); - return $this; } From a835cad31f388c0746578baf0b5bcf537f3825a0 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Wed, 11 Mar 2015 22:06:23 +0100 Subject: [PATCH 0982/2920] Remove a nonsense TODO from Web.php TODOs for replacing Zend classes are unnecessary. --- library/Icinga/Application/Web.php | 1 - 1 file changed, 1 deletion(-) diff --git a/library/Icinga/Application/Web.php b/library/Icinga/Application/Web.php index e4e3583c1..909839de7 100644 --- a/library/Icinga/Application/Web.php +++ b/library/Icinga/Application/Web.php @@ -159,7 +159,6 @@ class Web extends ApplicationBootstrap */ private function setupZendMvc() { - // TODO: Replace Zend_Application: Zend_Layout::startMvc( array( 'layout' => 'layout', From 64ad54ebd6c461e6b424933b57aa5ec674d853e5 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Wed, 11 Mar 2015 22:08:28 +0100 Subject: [PATCH 0983/2920] Optimize imports in Web.php --- library/Icinga/Application/Web.php | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/library/Icinga/Application/Web.php b/library/Icinga/Application/Web.php index 909839de7..c07536e89 100644 --- a/library/Icinga/Application/Web.php +++ b/library/Icinga/Application/Web.php @@ -5,22 +5,22 @@ namespace Icinga\Application; require_once __DIR__ . '/ApplicationBootstrap.php'; -use Icinga\Authentication\Manager; -use Icinga\Application\Logger; -use Icinga\Util\TimezoneDetect; -use Icinga\Web\Request; -use Icinga\Web\Response; -use Icinga\Web\View; -use Icinga\Web\Session\Session as BaseSession; -use Icinga\Web\Session; -use Icinga\User; -use Icinga\Util\Translator; +use Zend_Controller_Action_HelperBroker; +use Zend_Controller_Front; +use Zend_Controller_Router_Route; use Zend_Layout; use Zend_Paginator; use Zend_View_Helper_PaginationControl; -use Zend_Controller_Action_HelperBroker; -use Zend_Controller_Router_Route; -use Zend_Controller_Front; +use Icinga\Application\Logger; +use Icinga\Authentication\Manager; +use Icinga\User; +use Icinga\Util\TimezoneDetect; +use Icinga\Util\Translator; +use Icinga\Web\Request; +use Icinga\Web\Response; +use Icinga\Web\Session; +use Icinga\Web\Session\Session as BaseSession; +use Icinga\Web\View; /** * Use this if you want to make use of Icinga functionality in other web projects From 4570151b4b58fe4ff212869135bb1927c05ee0c5 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Wed, 11 Mar 2015 22:11:10 +0100 Subject: [PATCH 0984/2920] Fix indentation for strings spanning multiple lines in our auth controller --- application/controllers/AuthenticationController.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/application/controllers/AuthenticationController.php b/application/controllers/AuthenticationController.php index 933a97357..affeca2f1 100644 --- a/application/controllers/AuthenticationController.php +++ b/application/controllers/AuthenticationController.php @@ -102,21 +102,21 @@ class AuthenticationController extends ActionController $this->view->form->addError( $this->translate( 'No authentication methods available. Did you create' - . ' authentication.ini when setting up Icinga Web 2?' + . ' authentication.ini when setting up Icinga Web 2?' ) ); } else if ($backendsTried === $backendsWithError) { $this->view->form->addError( $this->translate( 'All configured authentication methods failed.' - . ' Please check the system log or Icinga Web 2 log for more information.' + . ' Please check the system log or Icinga Web 2 log for more information.' ) ); } elseif ($backendsWithError) { $this->view->form->addError( $this->translate( 'Please note that not all authentication methods were available.' - . ' Check the system log or Icinga Web 2 log for more information.' + . ' Check the system log or Icinga Web 2 log for more information.' ) ); } From 7288f2e92b41a6868b3e4d91fa2ab69b179d7647 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Wed, 11 Mar 2015 22:25:52 +0100 Subject: [PATCH 0985/2920] Use space after the boolean negotiation operator --- application/controllers/AuthenticationController.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/application/controllers/AuthenticationController.php b/application/controllers/AuthenticationController.php index affeca2f1..7d492f8c1 100644 --- a/application/controllers/AuthenticationController.php +++ b/application/controllers/AuthenticationController.php @@ -144,7 +144,7 @@ class AuthenticationController extends ActionController $this->view->form->addError($e->getMessage()); } - $this->view->requiresExternalAuth = $triedOnlyExternalAuth && !$auth->isAuthenticated(); + $this->view->requiresExternalAuth = $triedOnlyExternalAuth && ! $auth->isAuthenticated(); $this->view->requiresSetup = Icinga::app()->requiresSetup(); } From 0806ab3ec980916bb565b61a83519735f07ad9e1 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Wed, 11 Mar 2015 22:26:03 +0100 Subject: [PATCH 0986/2920] Remove strict equality for $auth->isAuthenticated() --- library/Icinga/Application/Web.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library/Icinga/Application/Web.php b/library/Icinga/Application/Web.php index c07536e89..0c7ea0ad8 100644 --- a/library/Icinga/Application/Web.php +++ b/library/Icinga/Application/Web.php @@ -178,7 +178,7 @@ class Web extends ApplicationBootstrap private function setupUser() { $auth = Manager::getInstance(); - if ($auth->isAuthenticated() === true) { + if ($auth->isAuthenticated()) { $this->user = $auth->getUser(); } return $this; From 2f752ed1ac9bd1c1fb7763c8583df977233b771b Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Wed, 11 Mar 2015 22:32:04 +0100 Subject: [PATCH 0987/2920] Respond with HTTP status code 403 when an XHR requires authentication refs #8626 --- library/Icinga/Web/Controller/ActionController.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/library/Icinga/Web/Controller/ActionController.php b/library/Icinga/Web/Controller/ActionController.php index 0949dbc81..f0db0164f 100644 --- a/library/Icinga/Web/Controller/ActionController.php +++ b/library/Icinga/Web/Controller/ActionController.php @@ -299,6 +299,8 @@ class ActionController extends Zend_Controller_Action * if it's an auto-refresh request or to redirect to the URL which required login if it's not an auto-refreshing * one. * + * XHR will respond with HTTP status code 403 Forbidden. + * * @param Url|string $redirect URL to redirect to after successful login */ protected function redirectToLogin($redirect = null) @@ -306,6 +308,7 @@ class ActionController extends Zend_Controller_Action $login = Url::fromPath('authentication/login'); if ($this->isXhr()) { $login->setParam('redirect', '__SELF__'); + $this->_response->setHttpResponseCode(403); } elseif ($redirect !== null) { if (! $redirect instanceof Url) { $redirect = Url::fromPath($redirect); From 83443a5dc4b48c67fcaae9d3e7fcc3fafc0d00a2 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Thu, 12 Mar 2015 00:52:19 +0100 Subject: [PATCH 0988/2920] Use -1 for last update of the menu We must not rely on the server time minus an offset for the last update of the menu to trigger an immediate update of the menu because the server time may be behind the current time. fixes #8694 --- application/layouts/scripts/parts/navigation.phtml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/application/layouts/scripts/parts/navigation.phtml b/application/layouts/scripts/parts/navigation.phtml index 2136c0fd5..92273e4b4 100644 --- a/application/layouts/scripts/parts/navigation.phtml +++ b/application/layouts/scripts/parts/navigation.phtml @@ -21,7 +21,7 @@ if (! $this->auth()->isAuthenticated()) { -
    Backend + 0): ?> ', + t('Push this button to update the form to reflect the change that was made in the control on the left'), + $this->getView()->icon('cw') . t('Apply') + ); + } + + return $content; + } +} diff --git a/library/Icinga/Web/Form/Decorator/NoScriptApply.php b/library/Icinga/Web/Form/Decorator/NoScriptApply.php deleted file mode 100644 index fbc96756b..000000000 --- a/library/Icinga/Web/Form/Decorator/NoScriptApply.php +++ /dev/null @@ -1,34 +0,0 @@ -'; - } - - return $content; - } -} diff --git a/public/css/icinga/forms.less b/public/css/icinga/forms.less index d455bf654..ae7ebf720 100644 --- a/public/css/icinga/forms.less +++ b/public/css/icinga/forms.less @@ -195,6 +195,18 @@ select.grant-permissions { width: auto; } -label + input, label + select, label + input + input { +label ~ input, label ~ select { margin-left: 1.6em; +} + +label + i ~ input, label + i ~ select { + margin-left: 0; +} + +button.noscript-apply { + margin-left: 0.5em; +} + +html.no-js i.autosubmit-warning { + .sr-only; } \ No newline at end of file From 74dfa6e72af0d8b9f99a439fe75e481f34a3a82a Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Fri, 27 Feb 2015 14:45:47 +0100 Subject: [PATCH 0831/2920] Fix invalid icon names passed to the icon view helper --- application/views/scripts/authentication/login.phtml | 2 +- library/Icinga/Web/Widget/FilterEditor.php | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/application/views/scripts/authentication/login.phtml b/application/views/scripts/authentication/login.phtml index 4b1de3961..1bd7dc562 100644 --- a/application/views/scripts/authentication/login.phtml +++ b/application/views/scripts/authentication/login.phtml @@ -18,7 +18,7 @@ '' ); ?>

    -

    icon('icon-info'); ?>translate( +

    icon('info'); ?>translate( 'You\'re currently not authenticated using any of the web server\'s authentication mechanisms.' . ' Make sure you\'ll configure such, otherwise you\'ll not be able to login.' ); ?>

    diff --git a/library/Icinga/Web/Widget/FilterEditor.php b/library/Icinga/Web/Widget/FilterEditor.php index 0a8de5586..568b02498 100644 --- a/library/Icinga/Web/Widget/FilterEditor.php +++ b/library/Icinga/Web/Widget/FilterEditor.php @@ -323,7 +323,7 @@ class FilterEditor extends AbstractWidget $this->preservedUrl()->with('addFilter', $filter->getId()), null, array( - 'icon' => 'icon-plus', + 'icon' => 'plus', 'title' => t('Add another filter') ) ); @@ -336,7 +336,7 @@ class FilterEditor extends AbstractWidget $this->preservedUrl()->with('stripFilter', $filter->getId()), null, array( - 'icon' => 'icon-minus', + 'icon' => 'minus', 'title' => t('Strip this filter') ) ); @@ -349,7 +349,7 @@ class FilterEditor extends AbstractWidget $this->preservedUrl()->without('addFilter'), null, array( - 'icon' => 'icon-cancel', + 'icon' => 'cancel', 'title' => t('Cancel this operation') ) ); From 7bb78330a903f6e7693df0ff8de98e874de8725c Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Fri, 27 Feb 2015 14:47:46 +0100 Subject: [PATCH 0832/2920] Replace cancel icon with the trash icon... ...where the link's purpose is to remove something --- application/views/scripts/config/resource.phtml | 2 +- application/views/scripts/dashboard/settings.phtml | 4 ++-- application/views/scripts/form/reorder-authbackend.phtml | 2 +- application/views/scripts/roles/index.phtml | 2 +- library/Icinga/Web/Widget/FilterEditor.php | 2 +- .../monitoring/application/views/scripts/config/index.phtml | 4 ++-- 6 files changed, 8 insertions(+), 8 deletions(-) diff --git a/application/views/scripts/config/resource.phtml b/application/views/scripts/config/resource.phtml index 342320ab9..a8275912b 100644 --- a/application/views/scripts/config/resource.phtml +++ b/application/views/scripts/config/resource.phtml @@ -42,7 +42,7 @@ 'config/removeresource', array('resource' => $name), array( - 'icon' => 'cancel', + 'icon' => 'trash', 'title' => sprintf($this->translate('Remove resource %s'), $name) ) ); ?> diff --git a/application/views/scripts/dashboard/settings.phtml b/application/views/scripts/dashboard/settings.phtml index d1ed998d1..2c638c318 100644 --- a/application/views/scripts/dashboard/settings.phtml +++ b/application/views/scripts/dashboard/settings.phtml @@ -28,7 +28,7 @@ 'dashboard/remove-pane', array('pane' => $pane->getName()), array( - 'icon' => 'cancel', + 'icon' => 'trash', 'title' => sprintf($this->translate('Remove pane %s'), $pane->getName()) ) ); ?> @@ -67,7 +67,7 @@ 'dashboard/remove-dashlet', array('pane' => $pane->getName(), 'dashlet' => $dashlet->getTitle()), array( - 'icon' => 'cancel', + 'icon' => 'trash', 'title' => sprintf($this->translate('Remove dashlet %s from pane %s'), $dashlet->getTitle(), $pane->getName()) ) ); ?> diff --git a/application/views/scripts/form/reorder-authbackend.phtml b/application/views/scripts/form/reorder-authbackend.phtml index c31443eb6..f6b432940 100644 --- a/application/views/scripts/form/reorder-authbackend.phtml +++ b/application/views/scripts/form/reorder-authbackend.phtml @@ -26,7 +26,7 @@ 'config/removeAuthenticationBackend', array('auth_backend' => $backendNames[$i]), array( - 'icon' => 'cancel', + 'icon' => 'trash', 'title' => sprintf($this->translate('Remove authentication backend %s'), $backendNames[$i]) ) ); ?> diff --git a/application/views/scripts/roles/index.phtml b/application/views/scripts/roles/index.phtml index 350fb3343..25d3d1cdd 100644 --- a/application/views/scripts/roles/index.phtml +++ b/application/views/scripts/roles/index.phtml @@ -60,7 +60,7 @@ 'roles/remove', array('role' => $name), array( - 'icon' => 'cancel', + 'icon' => 'trash', 'title' => sprintf($this->translate('Remove role %s'), $name) ) ); ?> diff --git a/library/Icinga/Web/Widget/FilterEditor.php b/library/Icinga/Web/Widget/FilterEditor.php index 568b02498..8bcb9aa60 100644 --- a/library/Icinga/Web/Widget/FilterEditor.php +++ b/library/Icinga/Web/Widget/FilterEditor.php @@ -310,7 +310,7 @@ class FilterEditor extends AbstractWidget $this->preservedUrl()->with('removeFilter', $filter->getId()), null, array( - 'icon' => 'icon-cancel', + 'icon' => 'trash', 'title' => t('Remove this part of your filter') ) ); diff --git a/modules/monitoring/application/views/scripts/config/index.phtml b/modules/monitoring/application/views/scripts/config/index.phtml index 634da957c..201a09dae 100644 --- a/modules/monitoring/application/views/scripts/config/index.phtml +++ b/modules/monitoring/application/views/scripts/config/index.phtml @@ -38,7 +38,7 @@ '/monitoring/config/removebackend', array('backend' => $backendName), array( - 'icon' => 'cancel', + 'icon' => 'trash', 'title' => sprintf($this->translate('Remove monitoring backend %s'), $backendName) ) ); ?> @@ -82,7 +82,7 @@ '/monitoring/config/removeinstance', array('instance' => $instanceName), array( - 'icon' => 'cancel', + 'icon' => 'trash', 'title' => sprintf($this->translate('Remove monitoring instance %s'), $instanceName) ) ); ?> From e93a5f16d9ce3d82dbf1628376bb16cb332d5a5f Mon Sep 17 00:00:00 2001 From: Matthias Jentsch Date: Fri, 27 Feb 2015 09:51:44 +0100 Subject: [PATCH 0833/2920] Move capability-related code of the ldap connection into a separate class Achieve a better separation between the different concerns, more readable code and get rid of unused dead code. --- library/Icinga/Protocol/Ldap/Capability.php | 218 +++++++++++++++++++ library/Icinga/Protocol/Ldap/Connection.php | 223 ++------------------ library/Icinga/Protocol/Ldap/Discovery.php | 11 +- 3 files changed, 245 insertions(+), 207 deletions(-) create mode 100644 library/Icinga/Protocol/Ldap/Capability.php diff --git a/library/Icinga/Protocol/Ldap/Capability.php b/library/Icinga/Protocol/Ldap/Capability.php new file mode 100644 index 000000000..a1da67ce2 --- /dev/null +++ b/library/Icinga/Protocol/Ldap/Capability.php @@ -0,0 +1,218 @@ +attributes = $attributes; + + if (isset($attributes->supportedControl)) { + foreach ($attributes->supportedControl as $oid) { + $this->oids[$oid] = true; + } + } + if (isset($attributes->supportedExtension)) { + foreach ($attributes->supportedExtension as $oid) { + $this->oids[$oid] = true; + } + } + if (isset($attributes->supportedFeatures)) { + foreach ($attributes->supportedFeatures as $oid) { + $this->oids[$oid] = true; + } + } + if (isset($attributes->supportedCapabilities)) { + foreach ($attributes->supportedCapabilities as $oid) { + $this->oids[$oid] = true; + } + } + } + + /** + * Return if the capability object contains support for StartTLS + * + * @return bool Whether StartTLS is supported + */ + public function hasStartTLS() + { + return isset($this->oids[self::LDAP_SERVER_START_TLS_OID]); + } + + /** + * Return if the capability object contains support for StartTLS + * + * @return bool Whether StartTLS is supported + */ + public function hasPagedResult() + { + return isset($this->oids[self::LDAP_PAGED_RESULT_OID_STRING]); + } + + /** + * Whether the ldap server is an ActiveDirectory server + * + * @return boolean + */ + public function hasAdOid() + { + return isset($this->oids[self::LDAP_CAP_ACTIVE_DIRECTORY_OID]); + } + + /** + * Return if the capability objects contains support for LdapV3, defaults to true if discovery failed + * + * @return bool + */ + public function hasLdapV3() + { + if (!isset($this->attributes)) { + // Default to true, if unknown + return true; + } + + return (is_string($this->attributes->supportedLDAPVersion) + && (int) $this->attributes->supportedLDAPVersion === 3) + || (is_array($this->attributes->supportedLDAPVersion) + && in_array(3, $this->attributes->supportedLDAPVersion)); + } + + /** + * Whether the capability with the given OID is supported + * + * @param $oid string The OID of the capability + * + * @return bool + */ + public function hasOid($oid) + { + return isset($this->oids[$oid]); + } + + /** + * Get the default naming context + * + * @return string|null the default naming context, or null when no contexts are available + */ + public function getDefaultNamingContext() + { + // defaultNamingContext entry has higher priority + if (isset($this->attributes->defaultNamingContext)) { + return $this->attributes->defaultNamingContext; + } + + // if its missing use namingContext + $namingContexts = $this->namingContexts(); + return empty($namingContexts) ? null : $namingContexts[0]; + } + + /** + * Fetch the namingContexts + * + * @return array the available naming contexts + */ + public function namingContexts() + { + if (!isset($this->attributes->namingContexts)) { + return array(); + } + if (!is_array($this->attributes->namingContexts)) { + return array($this->attributes->namingContexts); + } + return$this->attributes->namingContexts; + } +} diff --git a/library/Icinga/Protocol/Ldap/Connection.php b/library/Icinga/Protocol/Ldap/Connection.php index 65eafffe0..39e447486 100644 --- a/library/Icinga/Protocol/Ldap/Connection.php +++ b/library/Icinga/Protocol/Ldap/Connection.php @@ -44,47 +44,6 @@ class Connection protected $root_dn; protected $count; - protected $ldap_extension = array( - '1.3.6.1.4.1.1466.20037' => 'STARTTLS', - // '1.3.6.1.4.1.4203.1.11.1' => '11.1', // PASSWORD_MODIFY - // '1.3.6.1.4.1.4203.1.11.3' => '11.3', // Whoami - // '1.3.6.1.1.8' => '8', // Cancel Extended Request - ); - - protected $ms_capability = array( - // Prefix LDAP_CAP_ - // Source: http://msdn.microsoft.com/en-us/library/cc223359.aspx - - // Running Active Directory as AD DS: - '1.2.840.113556.1.4.800' => 'ACTIVE_DIRECTORY_OID', - - // Capable of signing and sealing on an NTLM authenticated connection - // and of performing subsequent binds on a signed or sealed connection. - '1.2.840.113556.1.4.1791' => 'ACTIVE_DIRECTORY_LDAP_INTEG_OID', - - // If AD DS: running at least W2K3, if AD LDS running at least W2K8 - '1.2.840.113556.1.4.1670' => 'ACTIVE_DIRECTORY_V51_OID', - - // If AD LDS: accepts DIGEST-MD5 binds for AD LDSsecurity principals - '1.2.840.113556.1.4.1880' => 'ACTIVE_DIRECTORY_ADAM_DIGEST', - - // Running Active Directory as AD LDS - '1.2.840.113556.1.4.1851' => 'ACTIVE_DIRECTORY_ADAM_OID', - - // If AD DS: it's a Read Only DC (RODC) - '1.2.840.113556.1.4.1920' => 'ACTIVE_DIRECTORY_PARTIAL_SECRETS_OID', - - // Running at least W2K8 - '1.2.840.113556.1.4.1935' => 'ACTIVE_DIRECTORY_V60_OID', - - // Running at least W2K8r2 - '1.2.840.113556.1.4.2080' => 'ACTIVE_DIRECTORY_V61_R2_OID', - - // Running at least W2K12 - '1.2.840.113556.1.4.2237' => 'ACTIVE_DIRECTORY_W8_OID', - - ); - /** * Whether the bind on this connection was already performed * @@ -94,11 +53,14 @@ class Connection protected $root; - protected $supports_v3 = false; - protected $supports_tls = false; - + /** + * @var Capability + */ protected $capabilities; - protected $namingContexts; + + /** + * @var bool + */ protected $discoverySuccess = false; /** @@ -374,8 +336,8 @@ class Connection $cookie = ''; $entries = array(); do { - // do not set controlPageResult as a critical extension, since we still want the - // server to return an answer in case the pagination extension is missing. + // do not set controlPageResult as a critical extension, since there is still the possibillity that the + // server returns an answer in case the pagination extension is missing. ldap_control_paged_result($this->ds, $pageSize, false, $cookie); $results = @ldap_search($this->ds, $base, $queryString, $fields, 0, $limit ? $offset + $limit : 0); @@ -516,24 +478,18 @@ class Connection $ds = ldap_connect($this->hostname, $this->port); try { - $capabilities = $this->discoverCapabilities($ds); - list($cap, $namingContexts) = $capabilities; + $this->capabilities = $this->discoverCapabilities($ds); $this->discoverySuccess = true; + } catch (LdapException $e) { - // discovery failed, guess defaults - $cap = (object) array( - 'supports_ldapv3' => true, - 'supports_starttls' => false, - 'msCapabilities' => array() - ); - $namingContexts = null; + // create empty default capabilities + Logger::warning('LADP discovery failed, assuming default LDAP settings.'); + $this->capabilities = new Capability(); } - $this->capabilities = $cap; - $this->namingContexts = $namingContexts; if ($use_tls) { - if ($cap->supports_starttls) { + if ($this->capabilities->hasStartTLS()) { if (@ldap_start_tls($ds)) { Logger::debug('LDAP STARTTLS succeeded'); } else { @@ -549,11 +505,11 @@ class Connection $this->hostname ); } else { - // TODO: Log noticy -> TLS enabled but not announced + Logger::warning('LDAP TLS enabled but not announced'); } } // ldap_rename requires LDAPv3: - if ($cap->supports_ldapv3) { + if ($this->capabilities->hasLdapV3()) { if (! ldap_set_option($ds, LDAP_OPT_PROTOCOL_VERSION, 3)) { throw new LdapException('LDAPv3 is required'); } @@ -591,141 +547,15 @@ class Connection } /** - * Return if the capability object contains support for StartTLS + * Get the capabilities of the connected server * - * @param $cap The object containing the capabilities - * - * @return bool Whether StartTLS is supported - */ - protected function hasCapabilityStartTLS($cap) - { - $cap = $this->getExtensionCapabilities($cap); - return isset($cap['1.3.6.1.4.1.1466.20037']); - } - - /** - * Return if the capability objects contains support for LdapV3 - * - * @param $cap - * - * @return bool - */ - protected function hasCapabilityLdapV3($cap) - { - if ((is_string($cap->supportedLDAPVersion) - && (int) $cap->supportedLDAPVersion === 3) - || (is_array($cap->supportedLDAPVersion) - && in_array(3, $cap->supportedLDAPVersion) - )) { - return true; - } - return false; - } - - /** - * Extract an array of all extension capabilities from the given ldap response - * - * @param $cap object The response returned by a ldap_search discovery query - * - * @return object The extracted capabilities. - */ - protected function getExtensionCapabilities($cap) - { - $extensions = array(); - if (isset($cap->supportedExtension)) { - foreach ($cap->supportedExtension as $oid) { - if (array_key_exists($oid, $this->ldap_extension)) { - if ($this->ldap_extension[$oid] === 'STARTTLS') { - $extensions['1.3.6.1.4.1.1466.20037'] = $this->ldap_extension['1.3.6.1.4.1.1466.20037']; - } - } - } - } - return $extensions; - } - - /** - * Extract an array of all MSAD capabilities from the given ldap response - * - * @param $cap object The response returned by a ldap_search discovery query - * - * @return object The extracted capabilities. - */ - protected function getMsCapabilities($cap) - { - $ms = array(); - foreach ($this->ms_capability as $name) { - $ms[$this->convName($name)] = false; - } - - if (isset($cap->supportedCapabilities)) { - foreach ($cap->supportedCapabilities as $oid) { - if (array_key_exists($oid, $this->ms_capability)) { - $ms[$this->convName($this->ms_capability[$oid])] = true; - } - } - } - return (object)$ms; - } - - /** - * Convert a single capability name entry into camel-case - * - * @param $name string The name to convert - * - * @return string The name in camel-case - */ - private function convName($name) - { - $parts = explode('_', $name); - foreach ($parts as $i => $part) { - $parts[$i] = ucfirst(strtolower($part)); - } - return implode('', $parts); - } - - /** - * Get the capabilities of this ldap server - * - * @return stdClass An object, providing the flags 'ldapv3' and 'starttls' to indicate LdapV3 and StartTLS - * support and an additional property 'msCapabilities', containing all supported active directory capabilities. + * @return Capability The capability object */ public function getCapabilities() { return $this->capabilities; } - /** - * Get the default naming context of this ldap connection - * - * @return string|null the default naming context, or null when no contexts are available - */ - public function getDefaultNamingContext() - { - $cap = $this->capabilities; - if (isset($cap->defaultNamingContext)) { - return $cap->defaultNamingContext; - } - $namingContexts = $this->namingContexts($cap); - return empty($namingContexts) ? null : $namingContexts[0]; - } - - /** - * Fetch the namingContexts for this Ldap-Connection - * - * @return array the available naming contexts - */ - public function namingContexts() - { - if (!isset($this->namingContexts)) { - return array(); - } - if (!is_array($this->namingContexts)) { - return array($this->namingContexts); - } - return $this->namingContexts; - } - /** * Whether service discovery was successful * @@ -742,7 +572,7 @@ class Connection * * @param resource $ds The link identifier of the current ldap connection * - * @return array The capabilities and naming-contexts + * @return Capability The capabilities * @throws LdapException When the capability query fails */ protected function discoverCapabilities($ds) @@ -759,6 +589,7 @@ class Connection 'schemaNamingContext', 'supportedLDAPVersion', // => array(3, 2) 'supportedCapabilities', + 'supportedControl', 'supportedExtension', '+' ) @@ -789,19 +620,9 @@ class Connection ); } - $cap = (object) array( - 'supports_ldapv3' => false, - 'supports_starttls' => false, - 'msCapabilities' => array() - ); - $ldapAttributes = ldap_get_attributes($ds, $entry); $result = $this->cleanupAttributes($ldapAttributes); - $cap->supports_ldapv3 = $this->hasCapabilityLdapV3($result); - $cap->supports_starttls = $this->hasCapabilityStartTLS($result); - $cap->msCapabilities = $this->getMsCapabilities($result); - - return array($cap, $result->namingContexts); + return new Capability($result); } /** diff --git a/library/Icinga/Protocol/Ldap/Discovery.php b/library/Icinga/Protocol/Ldap/Discovery.php index 18ef40307..1d7acbab9 100644 --- a/library/Icinga/Protocol/Ldap/Discovery.php +++ b/library/Icinga/Protocol/Ldap/Discovery.php @@ -54,7 +54,7 @@ class Discovery { return array( 'hostname' => $this->connection->getHostname(), 'port' => $this->connection->getPort(), - 'root_dn' => $this->connection->getDefaultNamingContext() + 'root_dn' => $this->connection->getCapabilities()->getDefaultNamingContext() ); } @@ -69,14 +69,14 @@ class Discovery { $this->execDiscovery(); if ($this->isAd()) { return array( - 'base_dn' => $this->connection->getDefaultNamingContext(), + 'base_dn' => $this->connection->getCapabilities()->getDefaultNamingContext(), 'user_class' => 'user', 'user_name_attribute' => 'sAMAccountName' ); } else { return array( - 'base_dn' => $this->connection->getDefaultNamingContext(), - 'user_class' => 'getDefaultNamingContext', + 'base_dn' => $this->connection->getCapabilities()->getDefaultNamingContext(), + 'user_class' => 'inetOrgPerson', 'user_name_attribute' => 'uid' ); } @@ -90,8 +90,7 @@ class Discovery { public function isAd() { $this->execDiscovery(); - $caps = $this->connection->getCapabilities(); - return isset($caps->msCapabilities->ActiveDirectoryOid) && $caps->msCapabilities->ActiveDirectoryOid; + return $this->connection->getCapabilities()->hasAdOid(); } /** From 65821863faf1f4c9e0f5f370133c16014f6087c8 Mon Sep 17 00:00:00 2001 From: Matthias Jentsch Date: Fri, 27 Feb 2015 16:59:50 +0100 Subject: [PATCH 0834/2920] Don't crash on single ldap capability entries refs #8490 --- library/Icinga/Protocol/Ldap/Capability.php | 30 ++++++++------------- library/Icinga/Protocol/Ldap/Connection.php | 1 - 2 files changed, 11 insertions(+), 20 deletions(-) diff --git a/library/Icinga/Protocol/Ldap/Capability.php b/library/Icinga/Protocol/Ldap/Capability.php index a1da67ce2..76d1f11a0 100644 --- a/library/Icinga/Protocol/Ldap/Capability.php +++ b/library/Icinga/Protocol/Ldap/Capability.php @@ -101,24 +101,16 @@ class Capability { { $this->attributes = $attributes; - if (isset($attributes->supportedControl)) { - foreach ($attributes->supportedControl as $oid) { - $this->oids[$oid] = true; - } - } - if (isset($attributes->supportedExtension)) { - foreach ($attributes->supportedExtension as $oid) { - $this->oids[$oid] = true; - } - } - if (isset($attributes->supportedFeatures)) { - foreach ($attributes->supportedFeatures as $oid) { - $this->oids[$oid] = true; - } - } - if (isset($attributes->supportedCapabilities)) { - foreach ($attributes->supportedCapabilities as $oid) { - $this->oids[$oid] = true; + $keys = array('supportedControl', 'supportedExtension', 'supportedFeatures', 'supportedCapabilities'); + foreach ($keys as $key) { + if (isset($attributes->$key)) { + if (is_array($attributes->$key)) { + foreach ($attributes->$key as $oid) { + $this->oids[$oid] = true; + } + } else { + $this->oids[$attributes->$key] = true; + } } } } @@ -160,7 +152,7 @@ class Capability { */ public function hasLdapV3() { - if (!isset($this->attributes)) { + if (! isset($this->attributes) || ! isset($this->attributes->supportedLDAPVersion)) { // Default to true, if unknown return true; } diff --git a/library/Icinga/Protocol/Ldap/Connection.php b/library/Icinga/Protocol/Ldap/Connection.php index 39e447486..57b1617a5 100644 --- a/library/Icinga/Protocol/Ldap/Connection.php +++ b/library/Icinga/Protocol/Ldap/Connection.php @@ -469,7 +469,6 @@ class Connection protected function prepareNewConnection() { $use_tls = false; - $force_tls = true; $force_tls = false; if ($use_tls) { From 36d2d31035239be0702f527914078f4cef968dc0 Mon Sep 17 00:00:00 2001 From: Matthias Jentsch Date: Fri, 27 Feb 2015 17:08:11 +0100 Subject: [PATCH 0835/2920] Do not use page control unless explicitly announced refs #8490 --- library/Icinga/Protocol/Ldap/Connection.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/library/Icinga/Protocol/Ldap/Connection.php b/library/Icinga/Protocol/Ldap/Connection.php index 57b1617a5..053c6c908 100644 --- a/library/Icinga/Protocol/Ldap/Connection.php +++ b/library/Icinga/Protocol/Ldap/Connection.php @@ -299,7 +299,9 @@ class Connection */ protected function pageControlAvailable(Query $query) { - return $query->getUsePagedResults() && version_compare(PHP_VERSION, '5.4.0') >= 0; + return $this->capabilities->hasPagedResult() && + $query->getUsePagedResults() && + version_compare(PHP_VERSION, '5.4.0') >= 0; } /** @@ -336,8 +338,8 @@ class Connection $cookie = ''; $entries = array(); do { - // do not set controlPageResult as a critical extension, since there is still the possibillity that the - // server returns an answer in case the pagination extension is missing. + // do not set controlPageResult as a critical extension, since we still want the + // possibillity server to return an answer in case the pagination extension is missing. ldap_control_paged_result($this->ds, $pageSize, false, $cookie); $results = @ldap_search($this->ds, $base, $queryString, $fields, 0, $limit ? $offset + $limit : 0); From e4f71eacd6f3aa6775ac233c868ba7022422dd19 Mon Sep 17 00:00:00 2001 From: Matthias Jentsch Date: Fri, 27 Feb 2015 17:11:12 +0100 Subject: [PATCH 0836/2920] Add unit tests for ldap connection behavior It is important that we test handling of protocol extensions properly, to prohibit errors that are difficult to reproduce like this in the future. fixes #7993 --- .../Icinga/Protocol/Ldap/ConnectionTest.php | 258 ++++++++++++++++++ 1 file changed, 258 insertions(+) create mode 100644 test/php/library/Icinga/Protocol/Ldap/ConnectionTest.php diff --git a/test/php/library/Icinga/Protocol/Ldap/ConnectionTest.php b/test/php/library/Icinga/Protocol/Ldap/ConnectionTest.php new file mode 100644 index 000000000..182004703 --- /dev/null +++ b/test/php/library/Icinga/Protocol/Ldap/ConnectionTest.php @@ -0,0 +1,258 @@ +getAttributesMock; + } + + function ldap_start_tls() + { + global $self; + $self->startTlsCalled = true; + } + + function ldap_set_option($ds, $option, $value) + { + global $self; + $self->activatedOptions[$option] = $value; + return true; + } + + function ldap_set($ds, $option) + { + global $self; + $self->activatedOptions[] = $option; + } + + function ldap_control_paged_result() + { + global $self; + $self->pagedResultsCalled = true; + return true; + } + + function ldap_control_paged_result_response() + { + return true; + } + + function ldap_get_dn() + { + return NULL; + } + + function ldap_free_result() + { + return NULL; + } + } + + private function node(&$element, $name) + { + $element['count']++; + $element[$name] = array('count' => 0); + $element[] = $name; + } + + private function addEntry(&$element, $name, $entry) + { + $element[$name]['count']++; + $element[$name][] = $entry; + } + + private function mockQuery() + { + return Mockery::mock('overload:Icinga\Protocol\Ldap\Query') + ->shouldReceive(array( + 'from' => Mockery::self(), + 'create' => array('count' => 1), + 'listFields' => array('count' => 1), + 'getLimit' => 1, + 'hasOffset' => false, + 'hasBase' => false, + 'getSortColumns' => array(), + 'getUsePagedResults' => true + )); + } + + private function connectionFetchAll() + { + $this->mockQuery(); + $this->connection->connect(); + $this->connection->fetchAll(Mockery::self()); + } + + public function setUp() + { + $this->pagedResultsCalled = false; + $this->startTlsCalled = false; + $this->activatedOptions = array(); + + $this->mockLdapFunctions(); + + $config = new ConfigObject( + array( + 'hostname' => 'localhost', + 'root_dn' => 'dc=example,dc=com', + 'bind_dn' => 'cn=user,ou=users,dc=example,dc=com', + 'bind_pw' => '***' + ) + ); + $this->connection = new Connection($config); + + $caps = array('count' => 0); + $this->node($caps, 'defaultNamingContext'); + $this->node($caps, 'namingContexts'); + $this->node($caps, 'supportedCapabilities'); + $this->node($caps, 'supportedControl'); + $this->node($caps, 'supportedLDAPVersion'); + $this->node($caps, 'supportedExtension'); + $this->getAttributesMock = $caps; + } + + public function testUsePageControlWhenAnnounced() + { + if (version_compare(PHP_VERSION, '5.4.0') < 0) { + $this->markTestSkipped('Page control needs at least PHP_VERSION 5.4.0'); + } + + $this->addEntry($this->getAttributesMock, 'supportedControl', Capability::LDAP_PAGED_RESULT_OID_STRING); + $this->connectionFetchAll(); + + // see ticket #7993 + $this->assertEquals(true, $this->pagedResultsCalled, "Use paged result when capability is present."); + } + + public function testDontUsePagecontrolWhenNotAnnounced() + { + if (version_compare(PHP_VERSION, '5.4.0') < 0) { + $this->markTestSkipped('Page control needs at least PHP_VERSION 5.4.0'); + } + $this->connectionFetchAll(); + + // see ticket #8490 + $this->assertEquals(false, $this->pagedResultsCalled, "Don't use paged result when capability is not announced."); + } + + public function testUseLdapV2WhenAnnounced() + { + // TODO: Test turned off, see other TODO in Ldap/Connection. + $this->markTestSkipped('LdapV2 currently turned off.'); + + $this->addEntry($this->getAttributesMock, 'supportedLDAPVersion', 2); + $this->connectionFetchAll(); + + $this->assertArrayHasKey(LDAP_OPT_PROTOCOL_VERSION, $this->activatedOptions, "LDAP version must be set"); + $this->assertEquals($this->activatedOptions[LDAP_OPT_PROTOCOL_VERSION], 2); + } + + public function testUseLdapV3WhenAnnounced() + { + $this->addEntry($this->getAttributesMock, 'supportedLDAPVersion', 3); + $this->connectionFetchAll(); + + $this->assertArrayHasKey(LDAP_OPT_PROTOCOL_VERSION, $this->activatedOptions, "LDAP version must be set"); + $this->assertEquals($this->activatedOptions[LDAP_OPT_PROTOCOL_VERSION], 3, "LDAPv3 must be active"); + } + + public function testDefaultSettings() + { + $this->connectionFetchAll(); + + $this->assertArrayHasKey(LDAP_OPT_PROTOCOL_VERSION, $this->activatedOptions, "LDAP version must be set"); + $this->assertEquals($this->activatedOptions[LDAP_OPT_PROTOCOL_VERSION], 3, "LDAPv3 must be active"); + + $this->assertArrayHasKey(LDAP_OPT_REFERRALS, $this->activatedOptions, "Following referrals must be turned off"); + $this->assertEquals($this->activatedOptions[LDAP_OPT_REFERRALS], 0, "Following referrals must be turned off"); + } + + + public function testActiveDirectoryDiscovery() + { + $this->addEntry($this->getAttributesMock, 'supportedCapabilities', Capability::LDAP_CAP_ACTIVE_DIRECTORY_OID); + $this->connectionFetchAll(); + + $this->assertEquals(true, $this->connection->getCapabilities()->hasAdOid(), + "Server with LDAP_CAP_ACTIVE_DIRECTORY_OID must be recognized as Active Directory."); + } + + public function testDefaultNamingContext() + { + $this->addEntry($this->getAttributesMock, 'defaultNamingContext', 'dn=default,dn=contex'); + $this->connectionFetchAll(); + + $this->assertEquals('dn=default,dn=contex', $this->connection->getCapabilities()->getDefaultNamingContext(), + 'Default naming context must be correctly recognized.'); + } + + public function testDefaultNamingContextFallback() + { + $this->addEntry($this->getAttributesMock, 'namingContexts', 'dn=some,dn=other,dn=context'); + $this->addEntry($this->getAttributesMock, 'namingContexts', 'dn=default,dn=context'); + $this->connectionFetchAll(); + + $this->assertEquals('dn=some,dn=other,dn=context', $this->connection->getCapabilities()->getDefaultNamingContext(), + 'If defaultNamingContext is missing, the connection must fallback to first namingContext.'); + } +} From 0f3c27f8122836ca9fb61597156ff5b622116b33 Mon Sep 17 00:00:00 2001 From: Matthias Jentsch Date: Mon, 2 Mar 2015 12:27:27 +0100 Subject: [PATCH 0837/2920] Fix event grid for dashboard --- modules/monitoring/application/controllers/ListController.php | 1 + 1 file changed, 1 insertion(+) diff --git a/modules/monitoring/application/controllers/ListController.php b/modules/monitoring/application/controllers/ListController.php index 60c669f93..b1b96b477 100644 --- a/modules/monitoring/application/controllers/ListController.php +++ b/modules/monitoring/application/controllers/ListController.php @@ -397,6 +397,7 @@ class Monitoring_ListController extends Controller $form->render(); $this->view->form = $form; + $this->params->remove('view'); $orientation = $this->params->shift('vertical', 0) ? 'vertical' : 'horizontal'; /* $orientationBox = new SelectBox( From 1a334f8d642c1628597411961c4a69e7bdc25543 Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Mon, 2 Mar 2015 13:45:24 +0100 Subject: [PATCH 0838/2920] Add decorator FormDescriptions This decorator displays a list of messages at the top of a form. refs #7947 --- library/Icinga/Web/Form.php | 51 +++++++++++++++++ .../Web/Form/Decorator/FormDescriptions.php | 55 +++++++++++++++++++ public/css/icinga/forms.less | 24 +++++++- public/css/icinga/main-content.less | 2 +- 4 files changed, 128 insertions(+), 4 deletions(-) create mode 100644 library/Icinga/Web/Form/Decorator/FormDescriptions.php diff --git a/library/Icinga/Web/Form.php b/library/Icinga/Web/Form.php index 0dc607412..e97190d66 100644 --- a/library/Icinga/Web/Form.php +++ b/library/Icinga/Web/Form.php @@ -126,6 +126,13 @@ class Form extends Zend_Form */ protected $requiredCue = '*'; + /** + * The descriptions of this form + * + * @var array + */ + protected $descriptions; + /** * Authentication manager * @@ -436,6 +443,49 @@ class Form extends Zend_Form return $this->requiredCue; } + /** + * Set the descriptions for this form + * + * @param array $descriptions + * + * @return Form + */ + public function setDescriptions(array $descriptions) + { + $this->descriptions = $descriptions; + return $this; + } + + /** + * Add a description for this form + * + * If $description is an array the second value should be + * an array as well containing additional HTML properties. + * + * @param string|array $description + * + * @return Form + */ + public function addDescription($description) + { + $this->descriptions[] = $description; + return $this; + } + + /** + * Return the descriptions of this form + * + * @return array + */ + public function getDescriptions() + { + if ($this->descriptions === null) { + return array(); + } + + return $this->descriptions; + } + /** * Create this form * @@ -860,6 +910,7 @@ class Form extends Zend_Form )); } else { $this->addDecorator('FormErrors', array('onlyCustomFormErrors' => true)) + ->addDecorator('FormDescriptions') ->addDecorator('FormElements') //->addDecorator('HtmlTag', array('tag' => 'dl', 'class' => 'zend_form')) ->addDecorator('Form'); diff --git a/library/Icinga/Web/Form/Decorator/FormDescriptions.php b/library/Icinga/Web/Form/Decorator/FormDescriptions.php new file mode 100644 index 000000000..936708e62 --- /dev/null +++ b/library/Icinga/Web/Form/Decorator/FormDescriptions.php @@ -0,0 +1,55 @@ +getElement(); + if (! $form instanceof Form) { + return $content; + } + + $view = $form->getView(); + if ($view === null) { + return $content; + } + + $descriptions = $form->getDescriptions(); + if (empty($descriptions)) { + return $content; + } + + $html = '
      '; + foreach ($descriptions as $description) { + if (is_array($description)) { + list($description, $properties) = $description; + $html .= 'propertiesToString($properties) . '>' . $view->escape($description) . ''; + } else { + $html .= '
    • ' . $view->escape($description) . '
    • '; + } + } + + switch ($this->getPlacement()) { + case self::APPEND: + return $content . $html . '
    '; + case self::PREPEND: + return $html . '' . $content; + } + } +} diff --git a/public/css/icinga/forms.less b/public/css/icinga/forms.less index ae7ebf720..d503ba037 100644 --- a/public/css/icinga/forms.less +++ b/public/css/icinga/forms.less @@ -126,10 +126,10 @@ input.link-like:hover, button.link-like:focus { .non-list-like-list { list-style-type: none; margin: 0; - padding: 0; + padding: 0.5em 0.5em 0; li { - margin: 0.5em; + padding-bottom: 0.5em; } } @@ -146,12 +146,16 @@ form div.element ul.errors { form ul.form-errors { .non-list-like-list; - display: inline-block; margin-bottom: 1em; background-color: @colorCritical; ul.errors { .non-list-like-list; + padding: 0; + + li:last-child { + padding-bottom: 0; + } } li { @@ -209,4 +213,18 @@ button.noscript-apply { html.no-js i.autosubmit-warning { .sr-only; +} + +form ul.descriptions { + .info-box; + padding: 0.5em 0.5em 0 1.8em; + + li { + padding-bottom: 0.5em; + + &:only-child { + margin-left: -1.3em; + list-style-type: none; + } + } } \ No newline at end of file diff --git a/public/css/icinga/main-content.less b/public/css/icinga/main-content.less index 74f9e1a6d..32054e242 100644 --- a/public/css/icinga/main-content.less +++ b/public/css/icinga/main-content.less @@ -206,5 +206,5 @@ table.benchmark { .info-box { padding: 0.5em; border: 1px solid lightgrey; - background-color: infobackground; + background-color: #fbfcc5; } From 1eacaa4c48daad665b1a1e3b44c19cb7d865d2df Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Mon, 2 Mar 2015 13:48:35 +0100 Subject: [PATCH 0839/2920] Improve the display of the text cue on required form elements Shows just a message at the top of the form if all elements are required and a explaining message what the cue is standing for otherwise. refs #7934 --- .../Web/Form/Decorator/FormDescriptions.php | 55 +++++++++++++++++++ 1 file changed, 55 insertions(+) diff --git a/library/Icinga/Web/Form/Decorator/FormDescriptions.php b/library/Icinga/Web/Form/Decorator/FormDescriptions.php index 936708e62..ecf16d578 100644 --- a/library/Icinga/Web/Form/Decorator/FormDescriptions.php +++ b/library/Icinga/Web/Form/Decorator/FormDescriptions.php @@ -8,6 +8,8 @@ use Icinga\Web\Form; /** * Decorator to add a list of descriptions at the top of a form + * + * The description for required form elements is automatically being handled. */ class FormDescriptions extends Zend_Form_Decorator_Abstract { @@ -31,6 +33,10 @@ class FormDescriptions extends Zend_Form_Decorator_Abstract } $descriptions = $form->getDescriptions(); + if (($requiredDesc = $this->getRequiredDescription($form)) !== null) { + $descriptions[] = $requiredDesc; + } + if (empty($descriptions)) { return $content; } @@ -52,4 +58,53 @@ class FormDescriptions extends Zend_Form_Decorator_Abstract return $html . '' . $content; } } + + /** + * Return the description for the given form's required elements + * + * @param Form $form + * + * @return string|null + */ + protected function getRequiredDescription(Form $form) + { + if (($cue = $form->getRequiredCue()) === null) { + return; + } + + $requiredLabels = array(); + $entirelyRequired = true; + $partiallyRequired = false; + $blacklist = array( + 'Zend_Form_Element_Hidden', + 'Zend_Form_Element_Submit', + 'Zend_Form_Element_Button', + 'Icinga\Web\Form\Element\CsrfCounterMeasure' + ); + foreach ($form->getElements() as $element) { + if (! in_array($element->getType(), $blacklist)) { + if (! $element->isRequired()) { + $entirelyRequired = false; + } else { + $partiallyRequired = true; + if (($label = $element->getDecorator('label')) !== false) { + $requiredLabels[] = $label; + } + } + } + } + + if ($entirelyRequired && $partiallyRequired) { + foreach ($requiredLabels as $label) { + $label->setRequiredSuffix(''); + } + + return $form->getView()->translate('All fields are required and must be filled in to complete the form.'); + } elseif ($partiallyRequired) { + return $form->getView()->translate(sprintf( + 'Required fields are marked with %s and must be filled in to complete the form.', + $cue + )); + } + } } From 92a15a6ee43aa24abfbe1a71d94b179a97fa7ce0 Mon Sep 17 00:00:00 2001 From: Matthias Jentsch Date: Mon, 2 Mar 2015 18:16:46 +0100 Subject: [PATCH 0840/2920] Fix badge css Nav element added for accesssibility destroyed the badge CSS. Make badge CSS more robust against inserted elements. --- public/css/icinga/widgets.less | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/public/css/icinga/widgets.less b/public/css/icinga/widgets.less index 1da6b7bfb..45701a697 100644 --- a/public/css/icinga/widgets.less +++ b/public/css/icinga/widgets.less @@ -230,29 +230,29 @@ li li .badge-container { background-color: @colorInvalid; } -#menu > ul > li.active > .badge-container { +#menu nav > ul > li.active > .badge-container { display: none; } -#menu > ul > li.hover > .badge-container { +#menu nav > ul > li.hover > .badge-container { display: none; } -#menu > ul > li.active > ul > li .badge-container { +#menu nav > ul > li.active > ul > li .badge-container { position: relative; top: -0.5em; } -#menu > ul > li.hover > ul > li > a { +#menu nav > ul > li.hover > ul > li > a { width: 12.5em; } -#menu > ul > li.hover > ul > li .badge-container { +#menu nav > ul > li.hover > ul > li .badge-container { position: relative; top: -0.5em; } -#menu > ul > li.hover > ul > li { +#menu nav > ul > li.hover > ul > li { // prevent floating badges from resizing list items in webkit //max-height: 2em; } From 65eafc0e8fadc389fd020d348026d3dcc26f980e Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Mon, 2 Mar 2015 18:15:13 +0100 Subject: [PATCH 0841/2920] LdapDiscoveryForm: Remove waste --- application/forms/LdapDiscoveryForm.php | 39 ------------------------- 1 file changed, 39 deletions(-) diff --git a/application/forms/LdapDiscoveryForm.php b/application/forms/LdapDiscoveryForm.php index e05be6eaa..fc1625385 100644 --- a/application/forms/LdapDiscoveryForm.php +++ b/application/forms/LdapDiscoveryForm.php @@ -30,45 +30,6 @@ class LdapDiscoveryForm extends Form ) ); - if (false) { - $this->addElement( - 'note', - 'additional_description', - array( - 'value' => $this->translate('No Ldap servers found on this domain.' - . ' You can try to specify host and port and try again, or just skip this step and ' - . 'configure the server manually.' - ) - ) - ); - $this->addElement( - 'text', - 'hostname', - array( - 'required' => false, - 'label' => $this->translate('Host'), - 'description' => $this->translate('IP or hostname to search.'), - ) - ); - - $this->addElement( - 'text', - 'port', - array( - 'required' => false, - 'label' => $this->translate('Port'), - 'description' => $this->translate('Port', 389), - ) - ); - } return $this; } - - public function isValid($data) - { - if (false === parent::isValid($data)) { - return false; - } - return true; - } } From e9bae08a6eecaea26e446cc23f393e7408e0924b Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Mon, 2 Mar 2015 18:19:41 +0100 Subject: [PATCH 0842/2920] Fix that one can't advance the wizard when skipping the ldap discovery fixes #8506 --- application/forms/LdapDiscoveryForm.php | 1 - .../application/forms/LdapDiscoveryPage.php | 21 +++++++++++-------- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/application/forms/LdapDiscoveryForm.php b/application/forms/LdapDiscoveryForm.php index fc1625385..3e129934d 100644 --- a/application/forms/LdapDiscoveryForm.php +++ b/application/forms/LdapDiscoveryForm.php @@ -24,7 +24,6 @@ class LdapDiscoveryForm extends Form 'text', 'domain', array( - 'required' => true, 'label' => $this->translate('Search Domain'), 'description' => $this->translate('Search this domain for records of available servers.'), ) diff --git a/modules/setup/application/forms/LdapDiscoveryPage.php b/modules/setup/application/forms/LdapDiscoveryPage.php index addc40545..6dbec66da 100644 --- a/modules/setup/application/forms/LdapDiscoveryPage.php +++ b/modules/setup/application/forms/LdapDiscoveryPage.php @@ -3,7 +3,9 @@ namespace Icinga\Module\Setup\Forms; +use Zend_Validate_NotEmpty; use Icinga\Web\Form; +use Icinga\Web\Form\ErrorLabeller; use Icinga\Forms\LdapDiscoveryForm; use Icinga\Protocol\Ldap\Discovery; use Icinga\Module\Setup\Forms\LdapDiscoveryConfirmPage; @@ -55,15 +57,11 @@ class LdapDiscoveryPage extends Form $discoveryForm = new LdapDiscoveryForm(); $this->addElements($discoveryForm->createElements($formData)->getElements()); - $this->getElement('domain')->setRequired( - isset($formData['skip_validation']) === false || ! $formData['skip_validation'] - ); $this->addElement( 'checkbox', 'skip_validation', array( - 'required' => true, 'label' => $this->translate('Skip'), 'description' => $this->translate('Do not discover LDAP servers and enter all settings manually.') ) @@ -82,19 +80,24 @@ class LdapDiscoveryPage extends Form if (false === parent::isValid($data)) { return false; } - if ($data['skip_validation']) { + if (isset($data['skip_validation']) && $data['skip_validation']) { return true; } - if (isset($data['domain'])) { + if (isset($data['domain']) && $data['domain']) { $this->discovery = Discovery::discoverDomain($data['domain']); if ($this->discovery->isSuccess()) { return true; } + + $this->addError( + sprintf($this->translate('Could not find any LDAP servers on the domain "%s".'), $data['domain']) + ); + } else { + $labeller = new ErrorLabeller(array('element' => $this->getElement('domain'))); + $this->getElement('domain')->addError($labeller->translate(Zend_Validate_NotEmpty::IS_EMPTY)); } - $this->addError( - sprintf($this->translate('Could not find any LDAP servers on the domain "%s".'), $data['domain']) - ); + return false; } From cbd061aa4156b1631f5a08ae0f561247ff1c4aca Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Mon, 2 Mar 2015 18:20:29 +0100 Subject: [PATCH 0843/2920] Fix that the FormDescriptions decorator does not ignore Notes and Buttons --- library/Icinga/Web/Form/Decorator/FormDescriptions.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/library/Icinga/Web/Form/Decorator/FormDescriptions.php b/library/Icinga/Web/Form/Decorator/FormDescriptions.php index ecf16d578..012c934a1 100644 --- a/library/Icinga/Web/Form/Decorator/FormDescriptions.php +++ b/library/Icinga/Web/Form/Decorator/FormDescriptions.php @@ -79,6 +79,8 @@ class FormDescriptions extends Zend_Form_Decorator_Abstract 'Zend_Form_Element_Hidden', 'Zend_Form_Element_Submit', 'Zend_Form_Element_Button', + 'Icinga\Web\Form\Element\Note', + 'Icinga\Web\Form\Element\Button', 'Icinga\Web\Form\Element\CsrfCounterMeasure' ); foreach ($form->getElements() as $element) { From ad288c08ca5bc64b4c8ff7d1684c6f0a10c7b464 Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Mon, 2 Mar 2015 18:24:02 +0100 Subject: [PATCH 0844/2920] Form: Add the Description decorator by default for native title support --- library/Icinga/Web/Form.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/library/Icinga/Web/Form.php b/library/Icinga/Web/Form.php index e97190d66..0ec502aa9 100644 --- a/library/Icinga/Web/Form.php +++ b/library/Icinga/Web/Form.php @@ -913,7 +913,12 @@ class Form extends Zend_Form ->addDecorator('FormDescriptions') ->addDecorator('FormElements') //->addDecorator('HtmlTag', array('tag' => 'dl', 'class' => 'zend_form')) - ->addDecorator('Form'); + ->addDecorator('Form') + ->addDecorator('Description', array( + 'placement' => 'prepend', + 'class' => 'form-title', + 'tag' => 'h1' + )); } } From b1d0c12df3988a7b2a85f8d2d8b36aac2f04f0ae Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Mon, 2 Mar 2015 18:24:41 +0100 Subject: [PATCH 0845/2920] Form: Introduce setTitle() as alias for Zend_Form::setDescription() --- library/Icinga/Web/Form.php | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/library/Icinga/Web/Form.php b/library/Icinga/Web/Form.php index 0ec502aa9..2cce16f76 100644 --- a/library/Icinga/Web/Form.php +++ b/library/Icinga/Web/Form.php @@ -956,6 +956,20 @@ class Form extends Zend_Form return $name; } + /** + * Set form description + * + * Alias for Zend_Form::setDescription(). + * + * @param string $value + * + * @return Form + */ + public function setTitle($value) + { + return $this->setDescription($value); + } + /** * Return the request associated with this form * From 4d2bd75a38374232c75484bb40a9dc76f8cd8a9e Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Mon, 2 Mar 2015 18:25:17 +0100 Subject: [PATCH 0846/2920] Installation: Fix ugly checkbox positioning when selecting modules --- public/css/icinga/setup.less | 1 + 1 file changed, 1 insertion(+) diff --git a/public/css/icinga/setup.less b/public/css/icinga/setup.less index d7217e1af..cf859be96 100644 --- a/public/css/icinga/setup.less +++ b/public/css/icinga/setup.less @@ -440,6 +440,7 @@ input[type=checkbox] { height: 10em; float: right; + margin: 0; } } From d714c4323c41ea8d799b8d15642e9e58d04750d1 Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Mon, 2 Mar 2015 18:26:46 +0100 Subject: [PATCH 0847/2920] Installation: Remove required cue from the token input refs #7934 --- modules/setup/application/forms/WelcomePage.php | 1 + 1 file changed, 1 insertion(+) diff --git a/modules/setup/application/forms/WelcomePage.php b/modules/setup/application/forms/WelcomePage.php index 7f2e00ef2..bc4c40b9f 100644 --- a/modules/setup/application/forms/WelcomePage.php +++ b/modules/setup/application/forms/WelcomePage.php @@ -17,6 +17,7 @@ class WelcomePage extends Form */ public function init() { + $this->setRequiredCue(null); $this->setName('setup_welcome'); $this->setViewScript('form/setup-welcome.phtml'); } From ea7b77eb72264503f822cb41938e8410d2d13f08 Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Mon, 2 Mar 2015 18:28:20 +0100 Subject: [PATCH 0848/2920] Remove the required cue when disabling notifications globally refs #7934 --- .../Command/Instance/DisableNotificationsExpireCommandForm.php | 1 + 1 file changed, 1 insertion(+) diff --git a/modules/monitoring/application/forms/Command/Instance/DisableNotificationsExpireCommandForm.php b/modules/monitoring/application/forms/Command/Instance/DisableNotificationsExpireCommandForm.php index 96f7f80d3..31e3b37aa 100644 --- a/modules/monitoring/application/forms/Command/Instance/DisableNotificationsExpireCommandForm.php +++ b/modules/monitoring/application/forms/Command/Instance/DisableNotificationsExpireCommandForm.php @@ -20,6 +20,7 @@ class DisableNotificationsExpireCommandForm extends CommandForm */ public function init() { + $this->setRequiredCue(null); $this->setSubmitLabel($this->translate('Disable Notifications')); } From d3f9bd633cd5666f1272e136291c9583221acdbd Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Mon, 2 Mar 2015 18:30:52 +0100 Subject: [PATCH 0849/2920] Installation: Hide the required cue when choosing the preference backend refs #7934 --- modules/setup/application/forms/PreferencesPage.php | 1 + 1 file changed, 1 insertion(+) diff --git a/modules/setup/application/forms/PreferencesPage.php b/modules/setup/application/forms/PreferencesPage.php index 3e91fc428..9763db3b3 100644 --- a/modules/setup/application/forms/PreferencesPage.php +++ b/modules/setup/application/forms/PreferencesPage.php @@ -16,6 +16,7 @@ class PreferencesPage extends Form */ public function init() { + $this->setRequiredCue(null); $this->setName('setup_preferences_type'); } From 2af83e7d7262bbb796a23e01912e572d3d0ded30 Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Mon, 2 Mar 2015 18:36:04 +0100 Subject: [PATCH 0850/2920] Installation: Use native form title and description support where appropriate refs #7947 refs #7976 --- .../application/forms/Setup/BackendPage.php | 25 ++------- .../forms/Setup/IdoResourcePage.php | 25 ++------- .../application/forms/Setup/InstancePage.php | 25 ++------- .../forms/Setup/LivestatusResourcePage.php | 26 ++-------- .../application/forms/Setup/SecurityPage.php | 25 ++------- .../application/forms/AdminAccountPage.php | 25 --------- .../application/forms/AuthBackendPage.php | 52 ++++++------------- .../application/forms/AuthenticationPage.php | 52 ++++--------------- .../forms/DatabaseCreationPage.php | 33 +++--------- .../application/forms/DbResourcePage.php | 26 ++-------- .../application/forms/GeneralConfigPage.php | 25 ++------- .../forms/LdapDiscoveryConfirmPage.php | 26 ++-------- .../application/forms/LdapDiscoveryPage.php | 27 ++-------- .../application/forms/LdapResourcePage.php | 26 ++-------- .../application/forms/PreferencesPage.php | 38 +------------- .../scripts/form/setup-admin-account.phtml | 8 +++ modules/setup/library/Setup/WebWizard.php | 6 ++- public/css/icinga/setup.less | 4 -- 18 files changed, 95 insertions(+), 379 deletions(-) diff --git a/modules/monitoring/application/forms/Setup/BackendPage.php b/modules/monitoring/application/forms/Setup/BackendPage.php index f2df42a1f..077ca3594 100644 --- a/modules/monitoring/application/forms/Setup/BackendPage.php +++ b/modules/monitoring/application/forms/Setup/BackendPage.php @@ -11,31 +11,14 @@ class BackendPage extends Form public function init() { $this->setName('setup_monitoring_backend'); + $this->setTitle($this->translate('Monitoring Backend', 'setup.page.title')); + $this->addDescription($this->translate( + 'Please configure below how Icinga Web 2 should retrieve monitoring information.' + )); } public function createElements(array $formData) { - $this->addElement( - 'note', - 'title', - array( - 'value' => $this->translate('Monitoring Backend', 'setup.page.title'), - 'decorators' => array( - 'ViewHelper', - array('HtmlTag', array('tag' => 'h2')) - ) - ) - ); - $this->addElement( - 'note', - 'description', - array( - 'value' => $this->translate( - 'Please configure below how Icinga Web 2 should retrieve monitoring information.' - ) - ) - ); - $this->addElement( 'text', 'name', diff --git a/modules/monitoring/application/forms/Setup/IdoResourcePage.php b/modules/monitoring/application/forms/Setup/IdoResourcePage.php index dac7d041f..f52601359 100644 --- a/modules/monitoring/application/forms/Setup/IdoResourcePage.php +++ b/modules/monitoring/application/forms/Setup/IdoResourcePage.php @@ -11,6 +11,10 @@ class IdoResourcePage extends Form public function init() { $this->setName('setup_monitoring_ido'); + $this->setTitle($this->translate('Monitoring IDO Resource', 'setup.page.title')); + $this->addDescription($this->translate( + 'Please fill out the connection details below to access the IDO database of your monitoring environment.' + )); } public function createElements(array $formData) @@ -23,27 +27,6 @@ class IdoResourcePage extends Form 'value' => 'db' ) ); - $this->addElement( - 'note', - 'title', - array( - 'value' => $this->translate('Monitoring IDO Resource', 'setup.page.title'), - 'decorators' => array( - 'ViewHelper', - array('HtmlTag', array('tag' => 'h2')) - ) - ) - ); - $this->addElement( - 'note', - 'description', - array( - 'value' => $this->translate( - 'Please fill out the connection details below to access' - . ' the IDO database of your monitoring environment.' - ) - ) - ); if (isset($formData['skip_validation']) && $formData['skip_validation']) { $this->addSkipValidationCheckbox(); diff --git a/modules/monitoring/application/forms/Setup/InstancePage.php b/modules/monitoring/application/forms/Setup/InstancePage.php index 54e4bbba6..25525ffaf 100644 --- a/modules/monitoring/application/forms/Setup/InstancePage.php +++ b/modules/monitoring/application/forms/Setup/InstancePage.php @@ -11,31 +11,14 @@ class InstancePage extends Form public function init() { $this->setName('setup_monitoring_instance'); + $this->setTitle($this->translate('Monitoring Instance', 'setup.page.title')); + $this->addDescription($this->translate( + 'Please define the settings specific to your monitoring instance below.' + )); } public function createElements(array $formData) { - $this->addElement( - 'note', - 'title', - array( - 'value' => $this->translate('Monitoring Instance', 'setup.page.title'), - 'decorators' => array( - 'ViewHelper', - array('HtmlTag', array('tag' => 'h2')) - ) - ) - ); - $this->addElement( - 'note', - 'description', - array( - 'value' => $this->translate( - 'Please define the settings specific to your monitoring instance below.' - ) - ) - ); - if (isset($formData['host'])) { $formData['type'] = 'remote'; // This is necessary as the type element gets ignored by Form::getValues() } diff --git a/modules/monitoring/application/forms/Setup/LivestatusResourcePage.php b/modules/monitoring/application/forms/Setup/LivestatusResourcePage.php index ca50980d6..48b688218 100644 --- a/modules/monitoring/application/forms/Setup/LivestatusResourcePage.php +++ b/modules/monitoring/application/forms/Setup/LivestatusResourcePage.php @@ -11,6 +11,11 @@ class LivestatusResourcePage extends Form public function init() { $this->setName('setup_monitoring_livestatus'); + $this->setTitle($this->translate('Monitoring Livestatus Resource', 'setup.page.title')); + $this->addDescription($this->translate( + 'Please fill out the connection details below to access the Livestatus' + . ' socket interface for your monitoring environment.' + )); } public function createElements(array $formData) @@ -23,27 +28,6 @@ class LivestatusResourcePage extends Form 'value' => 'livestatus' ) ); - $this->addElement( - 'note', - 'title', - array( - 'value' => $this->translate('Monitoring Livestatus Resource', 'setup.page.title'), - 'decorators' => array( - 'ViewHelper', - array('HtmlTag', array('tag' => 'h2')) - ) - ) - ); - $this->addElement( - 'note', - 'description', - array( - 'value' => $this->translate( - 'Please fill out the connection details below to access the Livestatus' - . ' socket interface for your monitoring environment.' - ) - ) - ); if (isset($formData['skip_validation']) && $formData['skip_validation']) { $this->addSkipValidationCheckbox(); diff --git a/modules/monitoring/application/forms/Setup/SecurityPage.php b/modules/monitoring/application/forms/Setup/SecurityPage.php index 1921c58f4..30eac67ab 100644 --- a/modules/monitoring/application/forms/Setup/SecurityPage.php +++ b/modules/monitoring/application/forms/Setup/SecurityPage.php @@ -11,31 +11,14 @@ class SecurityPage extends Form public function init() { $this->setName('setup_monitoring_security'); + $this->setTitle($this->translate('Monitoring Security', 'setup.page.title')); + $this->addDescription($this->translate( + 'To protect your monitoring environment against prying eyes please fill out the settings below.' + )); } public function createElements(array $formData) { - $this->addElement( - 'note', - 'title', - array( - 'value' => $this->translate('Monitoring Security', 'setup.page.title'), - 'decorators' => array( - 'ViewHelper', - array('HtmlTag', array('tag' => 'h2')) - ) - ) - ); - $this->addElement( - 'note', - 'description', - array( - 'value' => $this->translate( - 'To protect your monitoring environment against prying eyes please fill out the settings below.' - ) - ) - ); - $securityConfigForm = new SecurityConfigForm(); $securityConfigForm->createElements($formData); $this->addElements($securityConfigForm->getElements()); diff --git a/modules/setup/application/forms/AdminAccountPage.php b/modules/setup/application/forms/AdminAccountPage.php index 485baa64f..da9e90a14 100644 --- a/modules/setup/application/forms/AdminAccountPage.php +++ b/modules/setup/application/forms/AdminAccountPage.php @@ -192,31 +192,6 @@ class AdminAccountPage extends Form ) ); } - - $this->addElement( - 'note', - 'title', - array( - 'value' => $this->translate('Administration', 'setup.page.title'), - 'decorators' => array( - 'ViewHelper', - array('HtmlTag', array('tag' => 'h2')) - ) - ) - ); - $this->addElement( - 'note', - 'description', - array( - 'value' => tp( - 'Now it\'s time to configure your first administrative account for Icinga Web 2.' - . ' Please follow the instructions below:', - 'Now it\'s time to configure your first administrative account for Icinga Web 2.' - . ' Below are several options you can choose from. Select one and follow its instructions:', - count($choices) - ) - ) - ); } /** diff --git a/modules/setup/application/forms/AuthBackendPage.php b/modules/setup/application/forms/AuthBackendPage.php index 0f07d31be..0ec1de30f 100644 --- a/modules/setup/application/forms/AuthBackendPage.php +++ b/modules/setup/application/forms/AuthBackendPage.php @@ -27,6 +27,7 @@ class AuthBackendPage extends Form public function init() { $this->setName('setup_authentication_backend'); + $this->setTitle($this->translate('Authentication Backend', 'setup.page.title')); } /** @@ -57,54 +58,33 @@ class AuthBackendPage extends Form */ public function createElements(array $formData) { - $this->addElement( - 'note', - 'title', - array( - 'value' => $this->translate('Authentication Backend', 'setup.page.title'), - 'decorators' => array( - 'ViewHelper', - array('HtmlTag', array('tag' => 'h2')) - ) - ) - ); - - if ($this->config['type'] === 'db') { - $note = $this->translate( - 'As you\'ve chosen to use a database for authentication all you need ' - . 'to do now is defining a name for your first authentication backend.' - ); - } elseif ($this->config['type'] === 'ldap') { - $note = $this->translate( - 'Before you are able to authenticate using the LDAP connection defined earlier you need to' - . ' provide some more information so that Icinga Web 2 is able to locate account details.' - ); - } else { // if ($this->config['type'] === 'external' - $note = $this->translate( - 'You\'ve chosen to authenticate using a web server\'s mechanism so it may be necessary' - . ' to adjust usernames before any permissions, restrictions, etc. are being applied.' - ); - } - - $this->addElement( - 'note', - 'description', - array('value' => $note) - ); - if (isset($formData['skip_validation']) && $formData['skip_validation']) { $this->addSkipValidationCheckbox(); } if ($this->config['type'] === 'db') { + $this->setRequiredCue(null); $backendForm = new DbBackendForm(); + $backendForm->setRequiredCue(null); $backendForm->createElements($formData)->removeElement('resource'); + $this->addDescription($this->translate( + 'As you\'ve chosen to use a database for authentication all you need ' + . 'to do now is defining a name for your first authentication backend.' + )); } elseif ($this->config['type'] === 'ldap') { $backendForm = new LdapBackendForm(); $backendForm->createElements($formData)->removeElement('resource'); + $this->addDescription($this->translate( + 'Before you are able to authenticate using the LDAP connection defined earlier you need to' + . ' provide some more information so that Icinga Web 2 is able to locate account details.' + )); } else { // $this->config['type'] === 'external' $backendForm = new ExternalBackendForm(); $backendForm->createElements($formData); + $this->addDescription($this->translate( + 'You\'ve chosen to authenticate using a web server\'s mechanism so it may be necessary' + . ' to adjust usernames before any permissions, restrictions, etc. are being applied.' + )); } $this->addElements($backendForm->getElements()); @@ -143,7 +123,7 @@ class AuthBackendPage extends Form 'checkbox', 'skip_validation', array( - 'order' => 2, + 'order' => 0, 'ignore' => true, 'required' => true, 'label' => $this->translate('Skip Validation'), diff --git a/modules/setup/application/forms/AuthenticationPage.php b/modules/setup/application/forms/AuthenticationPage.php index d7c26d460..4f455de1e 100644 --- a/modules/setup/application/forms/AuthenticationPage.php +++ b/modules/setup/application/forms/AuthenticationPage.php @@ -16,7 +16,13 @@ class AuthenticationPage extends Form */ public function init() { + $this->setRequiredCue(null); $this->setName('setup_authentication_type'); + $this->setTitle($this->translate('Authentication', 'setup.page.title')); + $this->addDescription($this->translate( + 'Please choose how you want to authenticate when accessing Icinga Web 2.' + . ' Configuring backend specific details follows in a later step.' + )); } /** @@ -24,50 +30,14 @@ class AuthenticationPage extends Form */ public function createElements(array $formData) { - $this->addElement( - 'note', - 'title', - array( - 'value' => $this->translate('Authentication', 'setup.page.title'), - 'decorators' => array( - 'ViewHelper', - array('HtmlTag', array('tag' => 'h2')) - ) - ) - ); - if (isset($formData['type']) && $formData['type'] === 'external' && !isset($_SERVER['REMOTE_USER'])) { - $this->addElement( - 'note', - 'external_note', - array( - 'value' => '' . $this->translate( - 'You\'re currently not authenticated using any of the web server\'s authentication ' - . 'mechanisms. Make sure you\'ll configure such, otherwise you\'ll not be able to ' - . 'log into Icinga Web 2.' - ), - 'decorators' => array( - 'ViewHelper', - array( - 'HtmlTag', - array('tag' => 'p', 'class' => 'info-box') - ) - ) - ) - ); + $this->addDescription($this->translate( + 'You\'re currently not authenticated using any of the web server\'s authentication ' + . 'mechanisms. Make sure you\'ll configure such, otherwise you\'ll not be able to ' + . 'log into Icinga Web 2.' + )); } - $this->addElement( - 'note', - 'description', - array( - 'value' => $this->translate( - 'Please choose how you want to authenticate when accessing Icinga Web 2.' - . ' Configuring backend specific details follows in a later step.' - ) - ) - ); - $backendTypes = array(); if (Platform::hasMysqlSupport() || Platform::hasPostgresqlSupport()) { $backendTypes['db'] = $this->translate('Database'); diff --git a/modules/setup/application/forms/DatabaseCreationPage.php b/modules/setup/application/forms/DatabaseCreationPage.php index 81e9dcc62..9f4ed35a1 100644 --- a/modules/setup/application/forms/DatabaseCreationPage.php +++ b/modules/setup/application/forms/DatabaseCreationPage.php @@ -39,6 +39,13 @@ class DatabaseCreationPage extends Form public function init() { $this->setName('setup_database_creation'); + $this->setTitle($this->translate('Database Setup', 'setup.page.title')); + $this->addDescription($this->translate( + 'It seems that either the database you defined earlier does not yet exist and cannot be created' + . ' using the provided access credentials, the database does not have the required schema to be' + . ' operated by Icinga Web 2 or the provided access credentials do not have the sufficient ' + . 'permissions to access the database. Please provide appropriate access credentials to solve this.' + )); } /** @@ -85,30 +92,6 @@ class DatabaseCreationPage extends Form */ public function createElements(array $formData) { - $this->addElement( - 'note', - 'title', - array( - 'value' => $this->translate('Database Setup', 'setup.page.title'), - 'decorators' => array( - 'ViewHelper', - array('HtmlTag', array('tag' => 'h2')) - ) - ) - ); - $this->addElement( - 'note', - 'description', - array( - 'value' => $this->translate( - 'It seems that either the database you defined earlier does not yet exist and cannot be created' - . ' using the provided access credentials, the database does not have the required schema to be' - . ' operated by Icinga Web 2 or the provided access credentials do not have the sufficient ' - . 'permissions to access the database. Please provide appropriate access credentials to solve this.' - ) - ) - ); - $skipValidation = isset($formData['skip_validation']) && $formData['skip_validation']; $this->addElement( 'text', @@ -213,7 +196,7 @@ class DatabaseCreationPage extends Form 'checkbox', 'skip_validation', array( - 'order' => 2, + 'order' => 0, 'required' => true, 'label' => $this->translate('Skip Validation'), 'description' => $this->translate( diff --git a/modules/setup/application/forms/DbResourcePage.php b/modules/setup/application/forms/DbResourcePage.php index df5fd9c9a..8844ced4c 100644 --- a/modules/setup/application/forms/DbResourcePage.php +++ b/modules/setup/application/forms/DbResourcePage.php @@ -19,6 +19,11 @@ class DbResourcePage extends Form public function init() { $this->setName('setup_db_resource'); + $this->setTitle($this->translate('Database Resource', 'setup.page.title')); + $this->addDescription($this->translate( + 'Now please configure your database resource. Note that the database itself does not need to' + . ' exist at this time as it is going to be created once the wizard is about to be finished.' + )); } /** @@ -34,27 +39,6 @@ class DbResourcePage extends Form 'value' => 'db' ) ); - $this->addElement( - 'note', - 'title', - array( - 'value' => $this->translate('Database Resource', 'setup.page.title'), - 'decorators' => array( - 'ViewHelper', - array('HtmlTag', array('tag' => 'h2')) - ) - ) - ); - $this->addElement( - 'note', - 'description', - array( - 'value' => $this->translate( - 'Now please configure your database resource. Note that the database itself does not need to' - . ' exist at this time as it is going to be created once the wizard is about to be finished.' - ) - ) - ); if (isset($formData['skip_validation']) && $formData['skip_validation']) { $this->addSkipValidationCheckbox(); diff --git a/modules/setup/application/forms/GeneralConfigPage.php b/modules/setup/application/forms/GeneralConfigPage.php index 3dc4eecf1..c50d77293 100644 --- a/modules/setup/application/forms/GeneralConfigPage.php +++ b/modules/setup/application/forms/GeneralConfigPage.php @@ -17,6 +17,10 @@ class GeneralConfigPage extends Form public function init() { $this->setName('setup_general_config'); + $this->setTitle($this->translate('Application Configuration', 'setup.page.title')); + $this->addDescription($this->translate( + 'Now please adjust all application and logging related configuration options to fit your needs.' + )); } /** @@ -24,27 +28,6 @@ class GeneralConfigPage extends Form */ public function createElements(array $formData) { - $this->addElement( - 'note', - 'title', - array( - 'value' => $this->translate('Application Configuration', 'setup.page.title'), - 'decorators' => array( - 'ViewHelper', - array('HtmlTag', array('tag' => 'h2')) - ) - ) - ); - $this->addElement( - 'note', - 'description', - array( - 'value' => $this->translate( - 'Now please adjust all application and logging related configuration options to fit your needs.' - ) - ) - ); - $loggingForm = new LoggingConfigForm(); $this->addElements($loggingForm->createElements($formData)->getElements()); } diff --git a/modules/setup/application/forms/LdapDiscoveryConfirmPage.php b/modules/setup/application/forms/LdapDiscoveryConfirmPage.php index 6a09d9fee..3635fc358 100644 --- a/modules/setup/application/forms/LdapDiscoveryConfirmPage.php +++ b/modules/setup/application/forms/LdapDiscoveryConfirmPage.php @@ -37,6 +37,7 @@ EOT; public function init() { $this->setName('setup_ldap_discovery_confirm'); + $this->setTitle($this->translate('LDAP Discovery Results', 'setup.page.title')); } /** @@ -77,27 +78,10 @@ EOT; $html = str_replace('{user_attribute}', $backend['user_name_attribute'], $html); $html = str_replace('{user_class}', $backend['user_class'], $html); - $this->addElement( - 'note', - 'title', - array( - 'value' => $this->translate('LDAP Discovery Results', 'setup.page.title'), - 'decorators' => array( - 'ViewHelper', - array('HtmlTag', array('tag' => 'h2')) - ) - ) - ); - $this->addElement( - 'note', - 'description', - array( - 'value' => sprintf( - $this->translate('The following directory service has been found on domain "%s":'), - $this->config['domain'] - ) - ) - ); + $this->addDescription(sprintf( + $this->translate('The following directory service has been found on domain "%s".'), + $this->config['domain'] + )); $this->addElement( 'note', diff --git a/modules/setup/application/forms/LdapDiscoveryPage.php b/modules/setup/application/forms/LdapDiscoveryPage.php index 6dbec66da..1b8a85c77 100644 --- a/modules/setup/application/forms/LdapDiscoveryPage.php +++ b/modules/setup/application/forms/LdapDiscoveryPage.php @@ -26,6 +26,11 @@ class LdapDiscoveryPage extends Form public function init() { $this->setName('setup_ldap_discovery'); + $this->setTitle($this->translate('LDAP Discovery', 'setup.page.title')); + $this->addDescription($this->translate( + 'You can use this page to discover LDAP or ActiveDirectory servers ' . + ' for authentication. If you don\' want to execute a discovery, just skip this step.' + )); } /** @@ -33,28 +38,6 @@ class LdapDiscoveryPage extends Form */ public function createElements(array $formData) { - $this->addElement( - 'note', - 'title', - array( - 'value' => $this->translate('LDAP Discovery', 'setup.page.title'), - 'decorators' => array( - 'ViewHelper', - array('HtmlTag', array('tag' => 'h2')) - ) - ) - ); - $this->addElement( - 'note', - 'description', - array( - 'value' => $this->translate( - 'You can use this page to discover LDAP or ActiveDirectory servers ' . - ' for authentication. If you don\' want to execute a discovery, just skip this step.' - ) - ) - ); - $discoveryForm = new LdapDiscoveryForm(); $this->addElements($discoveryForm->createElements($formData)->getElements()); diff --git a/modules/setup/application/forms/LdapResourcePage.php b/modules/setup/application/forms/LdapResourcePage.php index 8374c8efa..e7342185e 100644 --- a/modules/setup/application/forms/LdapResourcePage.php +++ b/modules/setup/application/forms/LdapResourcePage.php @@ -17,6 +17,11 @@ class LdapResourcePage extends Form public function init() { $this->setName('setup_ldap_resource'); + $this->setTitle($this->translate('LDAP Resource', 'setup.page.title')); + $this->addDescription($this->translate( + 'Now please configure your AD/LDAP resource. This will later ' + . 'be used to authenticate users logging in to Icinga Web 2.' + )); } /** @@ -32,27 +37,6 @@ class LdapResourcePage extends Form 'value' => 'ldap' ) ); - $this->addElement( - 'note', - 'title', - array( - 'value' => $this->translate('LDAP Resource', 'setup.page.title'), - 'decorators' => array( - 'ViewHelper', - array('HtmlTag', array('tag' => 'h2')) - ) - ) - ); - $this->addElement( - 'note', - 'description', - array( - 'value' => $this->translate( - 'Now please configure your AD/LDAP resource. This will later ' - . 'be used to authenticate users logging in to Icinga Web 2.' - ) - ) - ); if (isset($formData['skip_validation']) && $formData['skip_validation']) { $this->addSkipValidationCheckbox(); diff --git a/modules/setup/application/forms/PreferencesPage.php b/modules/setup/application/forms/PreferencesPage.php index 9763db3b3..fdd5844cf 100644 --- a/modules/setup/application/forms/PreferencesPage.php +++ b/modules/setup/application/forms/PreferencesPage.php @@ -18,23 +18,8 @@ class PreferencesPage extends Form { $this->setRequiredCue(null); $this->setName('setup_preferences_type'); - } - - /** - * Pre-select "db" as preference backend and add a hint to the select element - * - * @return self - */ - public function showDatabaseNote() - { - $this->getElement('store') - ->setValue('db') - ->setDescription( - $this->translate( - 'Note that choosing "Database" causes Icinga Web 2 to use the same database as for authentication.' - ) - ); - return $this; + $this->setTitle($this->translate('Preferences', 'setup.page.title')); + $this->addDescription($this->translate('Please choose how Icinga Web 2 should store user preferences.')); } /** @@ -42,25 +27,6 @@ class PreferencesPage extends Form */ public function createElements(array $formData) { - $this->addElement( - 'note', - 'title', - array( - 'value' => $this->translate('Preferences', 'setup.page.title'), - 'decorators' => array( - 'ViewHelper', - array('HtmlTag', array('tag' => 'h2')) - ) - ) - ); - $this->addElement( - 'note', - 'description', - array( - 'value' => $this->translate('Please choose how Icinga Web 2 should store user preferences.') - ) - ); - $storageTypes = array(); $storageTypes['ini'] = $this->translate('File System (INI Files)'); if (Platform::hasMysqlSupport() || Platform::hasPostgresqlSupport()) { diff --git a/modules/setup/application/views/scripts/form/setup-admin-account.phtml b/modules/setup/application/views/scripts/form/setup-admin-account.phtml index b069bb371..83d01d43b 100644 --- a/modules/setup/application/views/scripts/form/setup-admin-account.phtml +++ b/modules/setup/application/views/scripts/form/setup-admin-account.phtml @@ -6,7 +6,15 @@ $radioElem = $form->getElement('user_type'); $showRadioBoxes = strpos(strtolower(get_class($radioElem)), 'radio') !== false; ?> +

    translate('Administration', 'setup.page.title'); ?>

    +
      +
    • translatePlural( + 'Now it\'s time to configure your first administrative account for Icinga Web 2. Please follow the instructions below:', + 'Now it\'s time to configure your first administrative account for Icinga Web 2. Below are several options you can choose from. Select one and follow its instructions:', + $showRadioBoxes ? count($radioElem->getMultiOptions()) : 1 + ); ?>
    • +
    getElement('title'); ?> getElement('description'); ?> getElement('by_name')) !== null): ?> diff --git a/modules/setup/library/Setup/WebWizard.php b/modules/setup/library/Setup/WebWizard.php index 7576adbb8..0bf575033 100644 --- a/modules/setup/library/Setup/WebWizard.php +++ b/modules/setup/library/Setup/WebWizard.php @@ -115,7 +115,11 @@ class WebWizard extends Wizard implements SetupWizard } elseif ($page->getName() === 'setup_preferences_type') { $authData = $this->getPageData('setup_authentication_type'); if ($authData['type'] === 'db') { - $page->create()->showDatabaseNote(); + $page->create()->getElement('store')->setValue('db'); + $page->addDescription(mt( + 'setup', + 'Note that choosing "Database" causes Icinga Web 2 to use the same database as for authentication.' + )); } } elseif ($page->getName() === 'setup_authentication_backend') { $authData = $this->getPageData('setup_authentication_type'); diff --git a/public/css/icinga/setup.less b/public/css/icinga/setup.less index cf859be96..66b08417e 100644 --- a/public/css/icinga/setup.less +++ b/public/css/icinga/setup.less @@ -222,10 +222,6 @@ } } -#setup_authentication_type p.info-box em { - text-decoration: underline; -} - #setup_ldap_discovery_confirm table { margin: 1em 0; border-collapse: separate; From 4ba281e7e8767109cd6f90b5d6734960a0a56341 Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Mon, 2 Mar 2015 18:37:54 +0100 Subject: [PATCH 0851/2920] Config: Use native form title and description support where appropriate refs #7947 refs #7976 --- application/controllers/ConfigController.php | 13 +++++++- .../controllers/DashboardController.php | 4 +++ application/controllers/RolesController.php | 5 +-- .../forms/Config/GeneralConfigForm.php | 1 + application/forms/PreferenceForm.php | 1 + .../views/scripts/config/application.phtml | 3 -- .../config/authentication/create.phtml | 14 ++------- .../config/authentication/modify.phtml | 7 +---- .../config/authentication/remove.phtml | 7 +---- .../scripts/config/resource/create.phtml | 8 +---- .../scripts/config/resource/modify.phtml | 7 +---- .../scripts/config/resource/remove.phtml | 7 +---- .../views/scripts/dashboard/new-dashlet.phtml | 1 - .../scripts/dashboard/remove-dashlet.phtml | 8 ----- .../views/scripts/dashboard/remove-pane.phtml | 8 ----- .../scripts/dashboard/update-dashlet.phtml | 2 -- .../views/scripts/preference/index.phtml | 1 - application/views/scripts/roles/new.phtml | 5 +-- application/views/scripts/roles/remove.phtml | 5 +-- application/views/scripts/roles/update.phtml | 5 +-- .../controllers/ConfigController.php | 31 +++++++++++++++++-- .../views/scripts/config/createbackend.phtml | 5 +-- .../views/scripts/config/createinstance.phtml | 5 +-- .../views/scripts/config/editbackend.phtml | 5 +-- .../views/scripts/config/editinstance.phtml | 5 +-- .../views/scripts/config/removebackend.phtml | 5 +-- .../views/scripts/config/removeinstance.phtml | 7 ++--- 27 files changed, 78 insertions(+), 97 deletions(-) diff --git a/application/controllers/ConfigController.php b/application/controllers/ConfigController.php index e240777dd..5ad822e12 100644 --- a/application/controllers/ConfigController.php +++ b/application/controllers/ConfigController.php @@ -216,6 +216,11 @@ class ConfigController extends ActionController { $this->assertPermission('system/config/authentication'); $form = new AuthenticationBackendConfigForm(); + $form->setTitle($this->translate('Create New Authentication Backend')); + $form->addDescription($this->translate( + 'Create a new backend for authenticating your users. This backend' + . ' will be added at the end of your authentication order.' + )); $form->setIniConfig(Config::app('authentication')); $form->setResourceConfig(ResourceFactory::getResourceConfigs()); $form->setRedirectUrl('config/authentication'); @@ -233,6 +238,7 @@ class ConfigController extends ActionController { $this->assertPermission('system/config/authentication'); $form = new AuthenticationBackendConfigForm(); + $form->setTitle($this->translate('Edit Backend')); $form->setIniConfig(Config::app('authentication')); $form->setResourceConfig(ResourceFactory::getResourceConfigs()); $form->setRedirectUrl('config/authentication'); @@ -272,6 +278,7 @@ class ConfigController extends ActionController } } )); + $form->setTitle($this->translate('Remove Backend')); $form->setRedirectUrl('config/authentication'); $form->handleRequest(); @@ -297,6 +304,8 @@ class ConfigController extends ActionController { $this->assertPermission('system/config/resources'); $form = new ResourceConfigForm(); + $form->setTitle($this->translate('Create A New Resource')); + $form->addDescription($this->translate('Resources are entities that provide data to Icinga Web 2.')); $form->setIniConfig(Config::app('resources')); $form->setRedirectUrl('config/resource'); $form->handleRequest(); @@ -312,6 +321,7 @@ class ConfigController extends ActionController { $this->assertPermission('system/config/resources'); $form = new ResourceConfigForm(); + $form->setTitle($this->translate('Edit Existing Resource')); $form->setIniConfig(Config::app('resources')); $form->setRedirectUrl('config/resource'); $form->handleRequest(); @@ -346,6 +356,7 @@ class ConfigController extends ActionController } } )); + $form->setTitle($this->translate('Remove Existing Resource')); $form->setRedirectUrl('config/resource'); $form->handleRequest(); @@ -354,7 +365,7 @@ class ConfigController extends ActionController $authConfig = Config::app('authentication'); foreach ($authConfig as $backendName => $config) { if ($config->get('resource') === $resource) { - $form->addError(sprintf( + $form->addDescription(sprintf( $this->translate( 'The resource "%s" is currently in use by the authentication backend "%s". ' . 'Removing the resource can result in noone being able to log in any longer.' diff --git a/application/controllers/DashboardController.php b/application/controllers/DashboardController.php index 6df92e892..325556be0 100644 --- a/application/controllers/DashboardController.php +++ b/application/controllers/DashboardController.php @@ -66,6 +66,7 @@ class DashboardController extends ActionController Notification::success(t('Dashlet created')); return true; }); + $form->setTitle($this->translate('Add Dashlet To Dashboard')); $form->setRedirectUrl('dashboard'); $form->handleRequest(); $this->view->form = $form; @@ -128,6 +129,7 @@ class DashboardController extends ActionController Notification::success(t('Dashlet updated')); return true; }); + $form->setTitle($this->translate('Edit Dashlet')); $form->setRedirectUrl('dashboard/settings'); $form->handleRequest(); $pane = $dashboard->getPane($this->getParam('pane')); @@ -176,6 +178,7 @@ class DashboardController extends ActionController } return false; }); + $form->setTitle($this->translate('Remove Dashlet From Dashboard')); $form->setRedirectUrl('dashboard/settings'); $form->handleRequest(); $this->view->pane = $pane; @@ -215,6 +218,7 @@ class DashboardController extends ActionController } return false; }); + $form->setTitle($this->translate('Remove Dashboard')); $form->setRedirectUrl('dashboard/settings'); $form->handleRequest(); $this->view->pane = $pane; diff --git a/application/controllers/RolesController.php b/application/controllers/RolesController.php index 6cbb4f703..2b7b520c5 100644 --- a/application/controllers/RolesController.php +++ b/application/controllers/RolesController.php @@ -86,6 +86,7 @@ class RolesController extends ActionController } )); $role + ->setTitle($this->translate('New Role')) ->setSubmitLabel($this->translate('Create Role')) ->setIniConfig(Config::app('roles', true)) ->setRedirectUrl('roles') @@ -108,6 +109,7 @@ class RolesController extends ActionController ); } $role = new RoleForm(); + $role->setTitle(sprintf($this->translate('Update Role %s'), $name)); $role->setSubmitLabel($this->translate('Update Role')); try { $role @@ -138,7 +140,6 @@ class RolesController extends ActionController }) ->setRedirectUrl('roles') ->handleRequest(); - $this->view->name = $name; $this->view->form = $role; } @@ -183,10 +184,10 @@ class RolesController extends ActionController } )); $confirmation + ->setTitle(sprintf($this->translate('Remove Role %s'), $name)) ->setSubmitLabel($this->translate('Remove Role')) ->setRedirectUrl('roles') ->handleRequest(); - $this->view->name = $name; $this->view->form = $confirmation; } } diff --git a/application/forms/Config/GeneralConfigForm.php b/application/forms/Config/GeneralConfigForm.php index b11b91208..c3c771f97 100644 --- a/application/forms/Config/GeneralConfigForm.php +++ b/application/forms/Config/GeneralConfigForm.php @@ -20,6 +20,7 @@ class GeneralConfigForm extends ConfigForm { $this->setName('form_config_general'); $this->setSubmitLabel($this->translate('Save Changes')); + $this->setTitle($this->translate('General Configuration')); } /** diff --git a/application/forms/PreferenceForm.php b/application/forms/PreferenceForm.php index 3ee1ebb38..09aa6b652 100644 --- a/application/forms/PreferenceForm.php +++ b/application/forms/PreferenceForm.php @@ -40,6 +40,7 @@ class PreferenceForm extends Form public function init() { $this->setName('form_config_preferences'); + $this->setTitle($this->translate('Preferences')); } /** diff --git a/application/views/scripts/config/application.phtml b/application/views/scripts/config/application.phtml index 4255befc4..e9aa039f9 100644 --- a/application/views/scripts/config/application.phtml +++ b/application/views/scripts/config/application.phtml @@ -2,9 +2,6 @@ tabs->render($this); ?>
    -

    - translate('General Configuration'); ?> -

    messageBox)): ?> messageBox->render() ?> diff --git a/application/views/scripts/config/authentication/create.phtml b/application/views/scripts/config/authentication/create.phtml index 48d1f00ed..a53f51721 100644 --- a/application/views/scripts/config/authentication/create.phtml +++ b/application/views/scripts/config/authentication/create.phtml @@ -2,15 +2,5 @@ tabs->showOnlyCloseButton() ?>
    -

    - translate('Create New Authentication Backend'); ?> -

    -

    - translate( - 'Create a new backend for authenticating your users. This backend will be added at the end of your authentication order.' - ); ?> -

    -
    - -
    -
    + + \ No newline at end of file diff --git a/application/views/scripts/config/authentication/modify.phtml b/application/views/scripts/config/authentication/modify.phtml index ebc1937a7..338d6807e 100644 --- a/application/views/scripts/config/authentication/modify.phtml +++ b/application/views/scripts/config/authentication/modify.phtml @@ -2,10 +2,5 @@ tabs->showOnlyCloseButton() ?>
    -

    - translate('Edit Backend'); ?> -

    -
    - -
    +
    diff --git a/application/views/scripts/config/authentication/remove.phtml b/application/views/scripts/config/authentication/remove.phtml index 0a53af30c..a53f51721 100644 --- a/application/views/scripts/config/authentication/remove.phtml +++ b/application/views/scripts/config/authentication/remove.phtml @@ -2,10 +2,5 @@ tabs->showOnlyCloseButton() ?>
    -

    - translate('Remove Backend'); ?> -

    -
    - -
    +
    \ No newline at end of file diff --git a/application/views/scripts/config/resource/create.phtml b/application/views/scripts/config/resource/create.phtml index 71d8c946e..a53f51721 100644 --- a/application/views/scripts/config/resource/create.phtml +++ b/application/views/scripts/config/resource/create.phtml @@ -2,11 +2,5 @@ tabs->showOnlyCloseButton() ?>
    -

    - translate('Create A New Resource'); ?> -

    -

    translate('Resources are entities that provide data to Icinga Web 2.'); ?>

    -
    - -
    +
    \ No newline at end of file diff --git a/application/views/scripts/config/resource/modify.phtml b/application/views/scripts/config/resource/modify.phtml index b7bd0a2f7..a53f51721 100644 --- a/application/views/scripts/config/resource/modify.phtml +++ b/application/views/scripts/config/resource/modify.phtml @@ -2,10 +2,5 @@ tabs->showOnlyCloseButton() ?>
    -

    - translate('Edit Existing Resource'); ?> -

    -
    - -
    +
    \ No newline at end of file diff --git a/application/views/scripts/config/resource/remove.phtml b/application/views/scripts/config/resource/remove.phtml index 010f2d5d2..a53f51721 100644 --- a/application/views/scripts/config/resource/remove.phtml +++ b/application/views/scripts/config/resource/remove.phtml @@ -2,10 +2,5 @@ tabs->showOnlyCloseButton() ?>
    -

    - translate('Remove Existing Resource'); ?> -

    -
    - -
    +
    \ No newline at end of file diff --git a/application/views/scripts/dashboard/new-dashlet.phtml b/application/views/scripts/dashboard/new-dashlet.phtml index 98b055414..b265a253a 100644 --- a/application/views/scripts/dashboard/new-dashlet.phtml +++ b/application/views/scripts/dashboard/new-dashlet.phtml @@ -2,6 +2,5 @@ tabs ?>
    -

    form; ?>
    \ No newline at end of file diff --git a/application/views/scripts/dashboard/remove-dashlet.phtml b/application/views/scripts/dashboard/remove-dashlet.phtml index 4c842cf29..b265a253a 100644 --- a/application/views/scripts/dashboard/remove-dashlet.phtml +++ b/application/views/scripts/dashboard/remove-dashlet.phtml @@ -1,14 +1,6 @@
    tabs ?>
    -
    -

    - -

    - translate('Please confirm the removal'); ?>: - pane; ?>/dashlet; ?> -

    - form; ?>
    \ No newline at end of file diff --git a/application/views/scripts/dashboard/remove-pane.phtml b/application/views/scripts/dashboard/remove-pane.phtml index 45455d37d..b265a253a 100644 --- a/application/views/scripts/dashboard/remove-pane.phtml +++ b/application/views/scripts/dashboard/remove-pane.phtml @@ -1,14 +1,6 @@
    tabs ?>
    -
    -

    - -

    - translate('Please confirm the removal of'); ?>: - pane; ?> -

    - form; ?>
    \ No newline at end of file diff --git a/application/views/scripts/dashboard/update-dashlet.phtml b/application/views/scripts/dashboard/update-dashlet.phtml index e83c8b6c3..b265a253a 100644 --- a/application/views/scripts/dashboard/update-dashlet.phtml +++ b/application/views/scripts/dashboard/update-dashlet.phtml @@ -1,8 +1,6 @@
    tabs ?>
    -
    -

    form; ?>
    \ No newline at end of file diff --git a/application/views/scripts/preference/index.phtml b/application/views/scripts/preference/index.phtml index fc19a1e10..4ca5e6821 100644 --- a/application/views/scripts/preference/index.phtml +++ b/application/views/scripts/preference/index.phtml @@ -2,6 +2,5 @@
    -

    translate('Preferences'); ?>

    \ No newline at end of file diff --git a/application/views/scripts/roles/new.phtml b/application/views/scripts/roles/new.phtml index d18ada1a5..ca1e1559e 100644 --- a/application/views/scripts/roles/new.phtml +++ b/application/views/scripts/roles/new.phtml @@ -2,8 +2,5 @@ showOnlyCloseButton() ?>
    -

    - translate('New Role') ?> -

    -
    + \ No newline at end of file diff --git a/application/views/scripts/roles/remove.phtml b/application/views/scripts/roles/remove.phtml index 432c3602d..ca1e1559e 100644 --- a/application/views/scripts/roles/remove.phtml +++ b/application/views/scripts/roles/remove.phtml @@ -2,8 +2,5 @@ showOnlyCloseButton() ?>
    -

    - translate('Remove Role %s'), $name) ?> -

    -
    + \ No newline at end of file diff --git a/application/views/scripts/roles/update.phtml b/application/views/scripts/roles/update.phtml index 32ab7d018..ca1e1559e 100644 --- a/application/views/scripts/roles/update.phtml +++ b/application/views/scripts/roles/update.phtml @@ -2,8 +2,5 @@ showOnlyCloseButton() ?>
    -

    - translate('Update Role %s'), $name) ?> -

    -
    + \ No newline at end of file diff --git a/modules/monitoring/application/controllers/ConfigController.php b/modules/monitoring/application/controllers/ConfigController.php index 7d4c07de0..2571b071e 100644 --- a/modules/monitoring/application/controllers/ConfigController.php +++ b/modules/monitoring/application/controllers/ConfigController.php @@ -30,6 +30,7 @@ class Monitoring_ConfigController extends ModuleActionController public function editbackendAction() { $form = new BackendConfigForm(); + $form->setTitle($this->translate('Edit Existing Backend')); $form->setIniConfig($this->Config('backends')); $form->setResourceConfig(ResourceFactory::getResourceConfigs()); $form->setRedirectUrl('monitoring/config'); @@ -44,6 +45,7 @@ class Monitoring_ConfigController extends ModuleActionController public function createbackendAction() { $form = new BackendConfigForm(); + $form->setTitle($this->translate('Add New Backend')); $form->setIniConfig($this->Config('backends')); $form->setResourceConfig(ResourceFactory::getResourceConfigs()); $form->setRedirectUrl('monitoring/config'); @@ -72,12 +74,16 @@ class Monitoring_ConfigController extends ModuleActionController } if ($configForm->save()) { - Notification::success(sprintf(mt('monitoring', 'Backend "%s" successfully removed.'), $backendName)); + Notification::success(sprintf( + $this->translate('Backend "%s" successfully removed.'), + $backendName + )); } else { return false; } } )); + $form->setTitle($this->translate('Remove Existing Backend')); $form->setRedirectUrl('monitoring/config'); $form->handleRequest(); @@ -104,12 +110,31 @@ class Monitoring_ConfigController extends ModuleActionController } if ($configForm->save()) { - Notification::success(sprintf(mt('monitoring', 'Instance "%s" successfully removed.'), $instanceName)); + Notification::success(sprintf( + $this->translate('Instance "%s" successfully removed.'), + $instanceName + )); } else { return false; } } )); + $form->setTitle($this->translate('Remove Existing Instance')); + $form->addDescription($this->translate( + 'If you have still any environments or views referring to this instance, ' + . 'you won\'t be able to send commands anymore after deletion.' + )); + $form->addElement( + 'note', + 'question', + array( + 'value' => $this->translate('Are you sure you want to remove this instance?'), + 'decorators' => array( + 'ViewHelper', + array('HtmlTag', array('tag' => 'p')) + ) + ) + ); $form->setRedirectUrl('monitoring/config'); $form->handleRequest(); @@ -122,6 +147,7 @@ class Monitoring_ConfigController extends ModuleActionController public function editinstanceAction() { $form = new InstanceConfigForm(); + $form->setTitle($this->translate('Edit Existing Instance')); $form->setIniConfig($this->Config('instances')); $form->setRedirectUrl('monitoring/config'); $form->handleRequest(); @@ -135,6 +161,7 @@ class Monitoring_ConfigController extends ModuleActionController public function createinstanceAction() { $form = new InstanceConfigForm(); + $form->setTitle($this->translate('Add New Instance')); $form->setIniConfig($this->Config('instances')); $form->setRedirectUrl('monitoring/config'); $form->handleRequest(); diff --git a/modules/monitoring/application/views/scripts/config/createbackend.phtml b/modules/monitoring/application/views/scripts/config/createbackend.phtml index 10ee02541..d2c7b6bdd 100644 --- a/modules/monitoring/application/views/scripts/config/createbackend.phtml +++ b/modules/monitoring/application/views/scripts/config/createbackend.phtml @@ -1,5 +1,6 @@
    showOnlyCloseButton() ?>
    -

    translate('Add New Backend'); ?>

    - +
    + +
    \ No newline at end of file diff --git a/modules/monitoring/application/views/scripts/config/createinstance.phtml b/modules/monitoring/application/views/scripts/config/createinstance.phtml index 3515514df..d2c7b6bdd 100644 --- a/modules/monitoring/application/views/scripts/config/createinstance.phtml +++ b/modules/monitoring/application/views/scripts/config/createinstance.phtml @@ -1,5 +1,6 @@
    showOnlyCloseButton() ?>
    -

    translate('Add New Instance') ?>

    - +
    + +
    \ No newline at end of file diff --git a/modules/monitoring/application/views/scripts/config/editbackend.phtml b/modules/monitoring/application/views/scripts/config/editbackend.phtml index 630cb83f2..d2c7b6bdd 100644 --- a/modules/monitoring/application/views/scripts/config/editbackend.phtml +++ b/modules/monitoring/application/views/scripts/config/editbackend.phtml @@ -1,5 +1,6 @@
    showOnlyCloseButton() ?>
    -

    translate('Edit Existing Backend') ?>

    - +
    + +
    \ No newline at end of file diff --git a/modules/monitoring/application/views/scripts/config/editinstance.phtml b/modules/monitoring/application/views/scripts/config/editinstance.phtml index 2c91ee656..d2c7b6bdd 100644 --- a/modules/monitoring/application/views/scripts/config/editinstance.phtml +++ b/modules/monitoring/application/views/scripts/config/editinstance.phtml @@ -1,5 +1,6 @@
    showOnlyCloseButton() ?>
    -

    translate('Edit Existing Instance'); ?>

    - +
    + +
    \ No newline at end of file diff --git a/modules/monitoring/application/views/scripts/config/removebackend.phtml b/modules/monitoring/application/views/scripts/config/removebackend.phtml index d297f615b..d2c7b6bdd 100644 --- a/modules/monitoring/application/views/scripts/config/removebackend.phtml +++ b/modules/monitoring/application/views/scripts/config/removebackend.phtml @@ -1,5 +1,6 @@
    showOnlyCloseButton() ?>
    -

    translate('Remove Existing Backend') ?>

    - +
    + +
    \ No newline at end of file diff --git a/modules/monitoring/application/views/scripts/config/removeinstance.phtml b/modules/monitoring/application/views/scripts/config/removeinstance.phtml index eee29fb02..d2c7b6bdd 100644 --- a/modules/monitoring/application/views/scripts/config/removeinstance.phtml +++ b/modules/monitoring/application/views/scripts/config/removeinstance.phtml @@ -1,7 +1,6 @@
    showOnlyCloseButton() ?>
    -

    translate('Remove Existing Instance'); ?>

    -

    translate('Are you sure you want to remove this instance?'); ?>

    -

    translate('If you have still any environments or views referring to this instance, you won\'t be able to send commands anymore after deletion.'); ?>

    - +
    + +
    \ No newline at end of file From a2f88dc60f231260f64345f9c8c52d0d6101e437 Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Mon, 2 Mar 2015 18:39:10 +0100 Subject: [PATCH 0852/2920] Commands: Use native form title and description support where appropriate refs #7947 refs #7976 --- .../controllers/HostController.php | 25 +++++++++------ .../controllers/HostsController.php | 20 +++++++----- .../controllers/ServiceController.php | 25 +++++++++------ .../controllers/ServicesController.php | 20 +++++++----- .../DisableNotificationsExpireCommandForm.php | 12 ++----- .../Object/AcknowledgeProblemCommandForm.php | 32 ++++++++----------- .../Command/Object/AddCommentCommandForm.php | 26 ++++++--------- .../Object/ProcessCheckResultCommandForm.php | 28 ++++++++-------- .../Object/ScheduleHostCheckCommandForm.php | 3 +- .../ScheduleHostDowntimeCommandForm.php | 4 +-- .../ScheduleServiceCheckCommandForm.php | 30 ++++++++--------- .../ScheduleServiceDowntimeCommandForm.php | 32 ++++++++----------- .../command/object-command-form.phtml | 5 ++- .../command/objects-command-form.phtml | 5 ++- .../process/disable-notifications.phtml | 4 +-- modules/monitoring/public/css/module.less | 2 +- 16 files changed, 129 insertions(+), 144 deletions(-) diff --git a/modules/monitoring/application/controllers/HostController.php b/modules/monitoring/application/controllers/HostController.php index 9cf3b26ab..4a29750e3 100644 --- a/modules/monitoring/application/controllers/HostController.php +++ b/modules/monitoring/application/controllers/HostController.php @@ -66,8 +66,9 @@ class Monitoring_HostController extends MonitoredObjectController { $this->assertPermission('monitoring/command/acknowledge-problem'); - $this->view->title = $this->translate('Acknowledge Host Problem'); - $this->handleCommandForm(new AcknowledgeProblemCommandForm()); + $form = new AcknowledgeProblemCommandForm(); + $form->setTitle($this->translate('Acknowledge Host Problem')); + $this->handleCommandForm($form); } /** @@ -77,8 +78,9 @@ class Monitoring_HostController extends MonitoredObjectController { $this->assertPermission('monitoring/command/comment/add'); - $this->view->title = $this->translate('Add Host Comment'); - $this->handleCommandForm(new AddCommentCommandForm()); + $form = new AddCommentCommandForm(); + $form->setTitle($this->translate('Add Host Comment')); + $this->handleCommandForm($form); } /** @@ -88,8 +90,9 @@ class Monitoring_HostController extends MonitoredObjectController { $this->assertPermission('monitoring/command/schedule-check'); - $this->view->title = $this->translate('Reschedule Host Check'); - $this->handleCommandForm(new ScheduleHostCheckCommandForm()); + $form = new ScheduleHostCheckCommandForm(); + $form->setTitle($this->translate('Reschedule Host Check')); + $this->handleCommandForm($form); } /** @@ -99,8 +102,9 @@ class Monitoring_HostController extends MonitoredObjectController { $this->assertPermission('monitoring/command/downtime/schedule'); - $this->view->title = $this->translate('Schedule Host Downtime'); - $this->handleCommandForm(new ScheduleHostDowntimeCommandForm()); + $form = new ScheduleHostDowntimeCommandForm(); + $form->setTitle($this->translate('Schedule Host Downtime')); + $this->handleCommandForm($form); } /** @@ -110,7 +114,8 @@ class Monitoring_HostController extends MonitoredObjectController { $this->assertPermission('monitoring/command/process-check-result'); - $this->view->title = $this->translate('Submit Passive Host Check Result'); - $this->handleCommandForm(new ProcessCheckResultCommandForm()); + $form = new ProcessCheckResultCommandForm(); + $form->setTitle($this->translate('Submit Passive Host Check Result')); + $this->handleCommandForm($form); } } diff --git a/modules/monitoring/application/controllers/HostsController.php b/modules/monitoring/application/controllers/HostsController.php index de1f063ac..5dc72eeb0 100644 --- a/modules/monitoring/application/controllers/HostsController.php +++ b/modules/monitoring/application/controllers/HostsController.php @@ -175,8 +175,9 @@ class Monitoring_HostsController extends Controller { $this->assertPermission('monitoring/command/acknowledge-problem'); - $this->view->title = $this->translate('Acknowledge Host Problems'); - $this->handleCommandForm(new AcknowledgeProblemCommandForm()); + $form = new AcknowledgeProblemCommandForm(); + $form->setTitle($this->translate('Acknowledge Host Problems')); + $this->handleCommandForm($form); } /** @@ -186,8 +187,9 @@ class Monitoring_HostsController extends Controller { $this->assertPermission('monitoring/command/schedule-check'); - $this->view->title = $this->translate('Reschedule Host Checks'); - $this->handleCommandForm(new ScheduleHostCheckCommandForm()); + $form = new ScheduleHostCheckCommandForm(); + $form->setTitle($this->translate('Reschedule Host Checks')); + $this->handleCommandForm($form); } /** @@ -197,8 +199,9 @@ class Monitoring_HostsController extends Controller { $this->assertPermission('monitoring/command/downtime/schedule'); - $this->view->title = $this->translate('Schedule Host Downtimes'); - $this->handleCommandForm(new ScheduleHostDowntimeCommandForm()); + $form = new ScheduleHostDowntimeCommandForm(); + $form->setTitle($this->translate('Schedule Host Downtimes')); + $this->handleCommandForm($form); } /** @@ -208,7 +211,8 @@ class Monitoring_HostsController extends Controller { $this->assertPermission('monitoring/command/process-check-result'); - $this->view->title = $this->translate('Submit Passive Host Check Results'); - $this->handleCommandForm(new ProcessCheckResultCommandForm()); + $form = new ProcessCheckResultCommandForm(); + $form->setTitle($this->translate('Submit Passive Host Check Results')); + $this->handleCommandForm($form); } } diff --git a/modules/monitoring/application/controllers/ServiceController.php b/modules/monitoring/application/controllers/ServiceController.php index 19906f5d2..d717a8e1c 100644 --- a/modules/monitoring/application/controllers/ServiceController.php +++ b/modules/monitoring/application/controllers/ServiceController.php @@ -43,8 +43,9 @@ class Monitoring_ServiceController extends MonitoredObjectController { $this->assertPermission('monitoring/command/acknowledge-problem'); - $this->view->title = $this->translate('Acknowledge Service Problem'); - $this->handleCommandForm(new AcknowledgeProblemCommandForm()); + $form = new AcknowledgeProblemCommandForm(); + $form->setTitle($this->translate('Acknowledge Service Problem')); + $this->handleCommandForm($form); } /** @@ -54,8 +55,9 @@ class Monitoring_ServiceController extends MonitoredObjectController { $this->assertPermission('monitoring/command/comment/add'); - $this->view->title = $this->translate('Add Service Comment'); - $this->handleCommandForm(new AddCommentCommandForm()); + $form = new AddCommentCommandForm(); + $form->setTitle($this->translate('Add Service Comment')); + $this->handleCommandForm($form); } /** @@ -65,8 +67,9 @@ class Monitoring_ServiceController extends MonitoredObjectController { $this->assertPermission('monitoring/command/schedule-check'); - $this->view->title = $this->translate('Reschedule Service Check'); - $this->handleCommandForm(new ScheduleServiceCheckCommandForm()); + $form = new ScheduleServiceCheckCommandForm(); + $form->setTitle($this->translate('Reschedule Service Check')); + $this->handleCommandForm($form); } /** @@ -76,8 +79,9 @@ class Monitoring_ServiceController extends MonitoredObjectController { $this->assertPermission('monitoring/command/downtime/schedule'); - $this->view->title = $this->translate('Schedule Service Downtime'); - $this->handleCommandForm(new ScheduleServiceDowntimeCommandForm()); + $form = new ScheduleServiceDowntimeCommandForm(); + $form->setTitle($this->translate('Schedule Service Downtime')); + $this->handleCommandForm($form); } /** @@ -87,7 +91,8 @@ class Monitoring_ServiceController extends MonitoredObjectController { $this->assertPermission('monitoring/command/process-check-result'); - $this->view->title = $this->translate('Submit Passive Service Check Result'); - $this->handleCommandForm(new ProcessCheckResultCommandForm()); + $form = new ProcessCheckResultCommandForm(); + $form->setTitle($this->translate('Submit Passive Service Check Result')); + $this->handleCommandForm($form); } } diff --git a/modules/monitoring/application/controllers/ServicesController.php b/modules/monitoring/application/controllers/ServicesController.php index a74b61074..1e907aab9 100644 --- a/modules/monitoring/application/controllers/ServicesController.php +++ b/modules/monitoring/application/controllers/ServicesController.php @@ -224,8 +224,9 @@ class Monitoring_ServicesController extends Controller { $this->assertPermission('monitoring/command/acknowledge-problem'); - $this->view->title = $this->translate('Acknowledge Service Problems'); - $this->handleCommandForm(new AcknowledgeProblemCommandForm()); + $form = new AcknowledgeProblemCommandForm(); + $form->setTitle($this->translate('Acknowledge Service Problems')); + $this->handleCommandForm($form); } /** @@ -235,8 +236,9 @@ class Monitoring_ServicesController extends Controller { $this->assertPermission('monitoring/command/schedule-check'); - $this->view->title = $this->translate('Reschedule Service Checks'); - $this->handleCommandForm(new ScheduleServiceCheckCommandForm()); + $form = new ScheduleServiceCheckCommandForm(); + $form->setTitle($this->translate('Reschedule Service Checks')); + $this->handleCommandForm($form); } /** @@ -246,8 +248,9 @@ class Monitoring_ServicesController extends Controller { $this->assertPermission('monitoring/command/downtime/schedule'); - $this->view->title = $this->translate('Schedule Service Downtimes'); - $this->handleCommandForm(new ScheduleServiceDowntimeCommandForm()); + $form = new ScheduleServiceDowntimeCommandForm(); + $form->setTitle($this->translate('Schedule Service Downtimes')); + $this->handleCommandForm($form); } /** @@ -257,7 +260,8 @@ class Monitoring_ServicesController extends Controller { $this->assertPermission('monitoring/command/process-check-result'); - $this->view->title = $this->translate('Submit Passive Service Check Results'); - $this->handleCommandForm(new ProcessCheckResultCommandForm()); + $form = new ProcessCheckResultCommandForm(); + $form->setTitle($this->translate('Submit Passive Service Check Results')); + $this->handleCommandForm($form); } } diff --git a/modules/monitoring/application/forms/Command/Instance/DisableNotificationsExpireCommandForm.php b/modules/monitoring/application/forms/Command/Instance/DisableNotificationsExpireCommandForm.php index 31e3b37aa..e69b9ea11 100644 --- a/modules/monitoring/application/forms/Command/Instance/DisableNotificationsExpireCommandForm.php +++ b/modules/monitoring/application/forms/Command/Instance/DisableNotificationsExpireCommandForm.php @@ -22,17 +22,9 @@ class DisableNotificationsExpireCommandForm extends CommandForm { $this->setRequiredCue(null); $this->setSubmitLabel($this->translate('Disable Notifications')); - } - - /** - * (non-PHPDoc) - * @see \Icinga\Module\Monitoring\Forms\Command\CommandForm::getHelp() For the method documentation. - */ - public function getHelp() - { - return $this->translate( + $this->addDescription($this->translate( 'This command is used to disable host and service notifications for a specific time.' - ); + )); } /** diff --git a/modules/monitoring/application/forms/Command/Object/AcknowledgeProblemCommandForm.php b/modules/monitoring/application/forms/Command/Object/AcknowledgeProblemCommandForm.php index 6f1235363..ef6d626b3 100644 --- a/modules/monitoring/application/forms/Command/Object/AcknowledgeProblemCommandForm.php +++ b/modules/monitoring/application/forms/Command/Object/AcknowledgeProblemCommandForm.php @@ -13,28 +13,25 @@ use Icinga\Web\Notification; */ class AcknowledgeProblemCommandForm extends ObjectsCommandForm { + /** + * Initialize this form + */ + public function init() + { + $this->addDescription($this->translate( + 'This command is used to acknowledge host or service problems. When a problem is acknowledged,' + . ' future notifications about problems are temporarily disabled until the host or service' + . ' recovers.' + )); + } + /** * (non-PHPDoc) * @see \Icinga\Web\Form::getSubmitLabel() For the method documentation. */ public function getSubmitLabel() { - return mtp( - 'monitoring', 'Acknowledge problem', 'Acknowledge problems', count($this->objects) - ); - } - - /** - * (non-PHPDoc) - * @see \Icinga\Module\Monitoring\Forms\Command\CommandForm::getHelp() For the method documentation. - */ - public function getHelp() - { - return $this->translate( - 'This command is used to acknowledge host or service problems. When a problem is acknowledged,' - . ' future notifications about problems are temporarily disabled until the host or service' - . ' recovers.' - ); + return $this->translatePlural('Acknowledge problem', 'Acknowledge problems', count($this->objects)); } /** @@ -156,8 +153,7 @@ class AcknowledgeProblemCommandForm extends ObjectsCommandForm } $this->getTransport($this->request)->send($ack); } - Notification::success(mtp( - 'monitoring', + Notification::success($this->translatePlural( 'Acknowledging problem..', 'Acknowledging problems..', count($this->objects) diff --git a/modules/monitoring/application/forms/Command/Object/AddCommentCommandForm.php b/modules/monitoring/application/forms/Command/Object/AddCommentCommandForm.php index eee671397..d167061f9 100644 --- a/modules/monitoring/application/forms/Command/Object/AddCommentCommandForm.php +++ b/modules/monitoring/application/forms/Command/Object/AddCommentCommandForm.php @@ -11,26 +11,21 @@ use Icinga\Web\Notification; */ class AddCommentCommandForm extends ObjectsCommandForm { + /** + * Initialize this form + */ + public function init() + { + $this->addDescription($this->translate('This command is used to add host or service comments.')); + } + /** * (non-PHPDoc) * @see \Icinga\Web\Form::getSubmitLabel() For the method documentation. */ public function getSubmitLabel() { - return mtp( - 'monitoring', 'Add comment', 'Add comments', count($this->objects) - ); - } - - /** - * (non-PHPDoc) - * @see \Icinga\Module\Monitoring\Forms\Command\CommandForm::getHelp() For the method documentation. - */ - public function getHelp() - { - return $this->translate( - 'This command is used to add host or service comments.' - ); + return $this->translatePlural('Add comment', 'Add comments', count($this->objects)); } /** @@ -84,8 +79,7 @@ class AddCommentCommandForm extends ObjectsCommandForm $comment->setPersistent($this->getElement('persistent')->isChecked()); $this->getTransport($this->request)->send($comment); } - Notification::success(mtp( - 'monitoring', + Notification::success($this->translatePlural( 'Adding comment..', 'Adding comments..', count($this->objects) diff --git a/modules/monitoring/application/forms/Command/Object/ProcessCheckResultCommandForm.php b/modules/monitoring/application/forms/Command/Object/ProcessCheckResultCommandForm.php index 1a357bdce..ec80a539f 100644 --- a/modules/monitoring/application/forms/Command/Object/ProcessCheckResultCommandForm.php +++ b/modules/monitoring/application/forms/Command/Object/ProcessCheckResultCommandForm.php @@ -11,25 +11,24 @@ use Icinga\Module\Monitoring\Command\Object\ProcessCheckResultCommand; */ class ProcessCheckResultCommandForm extends ObjectsCommandForm { + /** + * Initialize this form + */ + public function init() + { + $this->addDescription($this->translate( + 'This command is used to submit passive host or service check results.' + )); + } + /** * (non-PHPDoc) * @see \Icinga\Web\Form::getSubmitLabel() For the method documentation. */ public function getSubmitLabel() { - return mtp( - 'monitoring', 'Submit Passive Check Result', 'Submit Passive Check Results', count($this->objects) - ); - } - - /** - * (non-PHPDoc) - * @see \Icinga\Module\Monitoring\Forms\Command\CommandForm::getHelp() For the method documentation. - */ - public function getHelp() - { - return $this->translate( - 'This command is used to submit passive host or service check results.' + return $this->translatePlural( + 'Submit Passive Check Result', 'Submit Passive Check Results', count($this->objects) ); } @@ -108,8 +107,7 @@ class ProcessCheckResultCommandForm extends ObjectsCommandForm $this->getTransport($this->request)->send($command); } - Notification::success(mtp( - 'monitoring', + Notification::success($this->translatePlural( 'Processing check result..', 'Processing check results..', count($this->objects) diff --git a/modules/monitoring/application/forms/Command/Object/ScheduleHostCheckCommandForm.php b/modules/monitoring/application/forms/Command/Object/ScheduleHostCheckCommandForm.php index 7789460e3..0fa748fc4 100644 --- a/modules/monitoring/application/forms/Command/Object/ScheduleHostCheckCommandForm.php +++ b/modules/monitoring/application/forms/Command/Object/ScheduleHostCheckCommandForm.php @@ -47,8 +47,7 @@ class ScheduleHostCheckCommandForm extends ScheduleServiceCheckCommandForm ->setOfAllServices($this->getElement('all_services')->isChecked()); $this->scheduleCheck($check, $this->request); } - Notification::success(mtp( - 'monitoring', + Notification::success($this->translatePlural( 'Scheduling host check..', 'Scheduling host checks..', count($this->objects) diff --git a/modules/monitoring/application/forms/Command/Object/ScheduleHostDowntimeCommandForm.php b/modules/monitoring/application/forms/Command/Object/ScheduleHostDowntimeCommandForm.php index 6c7823dca..c35cb5413 100644 --- a/modules/monitoring/application/forms/Command/Object/ScheduleHostDowntimeCommandForm.php +++ b/modules/monitoring/application/forms/Command/Object/ScheduleHostDowntimeCommandForm.php @@ -7,7 +7,6 @@ use Icinga\Module\Monitoring\Command\Object\PropagateHostDowntimeCommand; use Icinga\Module\Monitoring\Command\Object\ScheduleHostDowntimeCommand; use Icinga\Module\Monitoring\Command\Object\ScheduleServiceDowntimeCommand; use Icinga\Web\Notification; -use Icinga\Web\Request; /** * Form for scheduling host downtimes @@ -83,8 +82,7 @@ class ScheduleHostDowntimeCommandForm extends ScheduleServiceDowntimeCommandForm $hostDowntime->setObject($object); $this->scheduleDowntime($hostDowntime, $this->request); } - Notification::success(mtp( - 'monitoring', + Notification::success($this->translatePlural( 'Scheduling host downtime..', 'Scheduling host downtimes..', count($this->objects) diff --git a/modules/monitoring/application/forms/Command/Object/ScheduleServiceCheckCommandForm.php b/modules/monitoring/application/forms/Command/Object/ScheduleServiceCheckCommandForm.php index e6686a9b8..f0f15559e 100644 --- a/modules/monitoring/application/forms/Command/Object/ScheduleServiceCheckCommandForm.php +++ b/modules/monitoring/application/forms/Command/Object/ScheduleServiceCheckCommandForm.php @@ -14,27 +14,24 @@ use Icinga\Web\Request; */ class ScheduleServiceCheckCommandForm extends ObjectsCommandForm { + /** + * Initialize this form + */ + public function init() + { + $this->addDescription($this->translate( + 'This command is used to schedule the next check of hosts or services. Icinga will re-queue the' + . ' hosts or services to be checked at the time you specify.' + )); + } + /** * (non-PHPDoc) * @see \Icinga\Web\Form::getSubmitLabel() For the method documentation. */ public function getSubmitLabel() { - return mtp( - 'monitoring', 'Schedule check', 'Schedule checks', count($this->objects) - ); - } - - /** - * (non-PHPDoc) - * @see \Icinga\Module\Monitoring\Forms\Command\CommandForm::getHelp() For the method documentation. - */ - public function getHelp() - { - return $this->translate( - 'This command is used to schedule the next check of hosts or services. Icinga will re-queue the' - . ' hosts or services to be checked at the time you specify.' - ); + return $this->translatePlural('Schedule check', 'Schedule checks', count($this->objects)); } /** @@ -99,8 +96,7 @@ class ScheduleServiceCheckCommandForm extends ObjectsCommandForm $check->setObject($object); $this->scheduleCheck($check, $this->request); } - Notification::success(mtp( - 'monitoring', + Notification::success($this->translatePlural( 'Scheduling service check..', 'Scheduling service checks..', count($this->objects) diff --git a/modules/monitoring/application/forms/Command/Object/ScheduleServiceDowntimeCommandForm.php b/modules/monitoring/application/forms/Command/Object/ScheduleServiceDowntimeCommandForm.php index 00487e115..627138a88 100644 --- a/modules/monitoring/application/forms/Command/Object/ScheduleServiceDowntimeCommandForm.php +++ b/modules/monitoring/application/forms/Command/Object/ScheduleServiceDowntimeCommandForm.php @@ -25,29 +25,26 @@ class ScheduleServiceDowntimeCommandForm extends ObjectsCommandForm const FLEXIBLE = 'flexible'; /** - * (non-PHPDoc) - * @see \Icinga\Web\Form::getSubmitLabel() For the method documentation. + * Initialize this form */ - public function getSubmitLabel() + public function init() { - return mtp( - 'monitoring', 'Schedule downtime', 'Schedule downtimes', count($this->objects) - ); - } - - /** - * (non-PHPDoc) - * @see \Icinga\Module\Monitoring\Forms\Command\CommandForm::getHelp() For the method documentation. - */ - public function getHelp() - { - return $this->translate( + $this->addDescription($this->translate( 'This command is used to schedule host and service downtimes. During the specified downtime,' . ' Icinga will not send notifications out about the hosts and services. When the scheduled' . ' downtime expires, Icinga will send out notifications for the hosts and services as it' . ' normally would. Scheduled downtimes are preserved across program shutdowns and' . ' restarts.' - ); + )); + } + + /** + * (non-PHPDoc) + * @see \Icinga\Web\Form::getSubmitLabel() For the method documentation. + */ + public function getSubmitLabel() + { + return $this->translatePlural('Schedule downtime', 'Schedule downtimes', count($this->objects)); } /** @@ -206,8 +203,7 @@ class ScheduleServiceDowntimeCommandForm extends ObjectsCommandForm $downtime->setObject($object); $this->scheduleDowntime($downtime, $this->request); } - Notification::success(mtp( - 'monitoring', + Notification::success($this->translatePlural( 'Scheduling service downtime..', 'Scheduling service downtimes..', count($this->objects) diff --git a/modules/monitoring/application/views/scripts/partials/command/object-command-form.phtml b/modules/monitoring/application/views/scripts/partials/command/object-command-form.phtml index 7f4314cbf..dbcf0bc03 100644 --- a/modules/monitoring/application/views/scripts/partials/command/object-command-form.phtml +++ b/modules/monitoring/application/views/scripts/partials/command/object-command-form.phtml @@ -7,7 +7,6 @@
    -
    -

    icon('help', $form->getHelp()); ?>

    - +
    +
    \ No newline at end of file diff --git a/modules/monitoring/application/views/scripts/partials/command/objects-command-form.phtml b/modules/monitoring/application/views/scripts/partials/command/objects-command-form.phtml index da58fc9cb..d387202c2 100644 --- a/modules/monitoring/application/views/scripts/partials/command/objects-command-form.phtml +++ b/modules/monitoring/application/views/scripts/partials/command/objects-command-form.phtml @@ -5,7 +5,7 @@ render('partials/host/objects-header.phtml'); ?>
    -
    +
    @@ -27,6 +27,5 @@

    -

    icon('help', $form->getHelp()) ?>

    - +
    diff --git a/modules/monitoring/application/views/scripts/process/disable-notifications.phtml b/modules/monitoring/application/views/scripts/process/disable-notifications.phtml index 2fb3c6c6e..9b9a2b133 100644 --- a/modules/monitoring/application/views/scripts/process/disable-notifications.phtml +++ b/modules/monitoring/application/views/scripts/process/disable-notifications.phtml @@ -2,7 +2,7 @@ tabs->showOnlyCloseButton() ?>
    -

    icon('help', $form->getHelp()) ?>

    +

    notifications_enabled === false): ?>
    translate('Host and service notifications are already disabled.') ?> @@ -13,6 +13,6 @@
    - +
    diff --git a/modules/monitoring/public/css/module.less b/modules/monitoring/public/css/module.less index 26cd5bc38..02ef9be6c 100644 --- a/modules/monitoring/public/css/module.less +++ b/modules/monitoring/public/css/module.less @@ -190,7 +190,7 @@ div.selection-info { vertical-align: middle; } -h1.command-title { +.object-command h1.form-title, .objects-command h1.form-title { border: none; } From b9ac42b54d5dcc152c57fdb7abd248a375b24b7e Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Mon, 2 Mar 2015 18:39:40 +0100 Subject: [PATCH 0853/2920] Drop CommandForm::getHelp() as being obsolete --- .../application/forms/Command/CommandForm.php | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/modules/monitoring/application/forms/Command/CommandForm.php b/modules/monitoring/application/forms/Command/CommandForm.php index dae5df963..41a46f110 100644 --- a/modules/monitoring/application/forms/Command/CommandForm.php +++ b/modules/monitoring/application/forms/Command/CommandForm.php @@ -43,16 +43,6 @@ abstract class CommandForm extends Form return $this->backend; } - /** - * Get the command help description - * - * @return string|null - */ - public function getHelp() - { - return null; - } - /** * Get the transport used to send commands * From 53e73161d8ca1b45bf26e6900b355f0dde2a2227 Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Mon, 2 Mar 2015 18:45:38 +0100 Subject: [PATCH 0854/2920] Fix that the AcknowledgeCommandForm is opened in a new column --- .../views/scripts/show/components/acknowledgement.phtml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/modules/monitoring/application/views/scripts/show/components/acknowledgement.phtml b/modules/monitoring/application/views/scripts/show/components/acknowledgement.phtml index 22a372151..7c50a4882 100644 --- a/modules/monitoring/application/views/scripts/show/components/acknowledgement.phtml +++ b/modules/monitoring/application/views/scripts/show/components/acknowledgement.phtml @@ -40,8 +40,9 @@ if ($object->acknowledged): ?> $ackLink, null, array( - 'icon' => 'ok', - 'title' => $this->translate( + 'icon' => 'ok', + 'data-base-target' => '_self', + 'title' => $this->translate( 'Acknowledge this problem, suppress all future notifications for it and tag it as being handled' ) ) From f7785ee04aede15e9c3bb7681fa74a53f0675385 Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Tue, 3 Mar 2015 08:24:23 +0100 Subject: [PATCH 0855/2920] Fix that the DashletForm handles the autosubmit manually --- application/forms/Dashboard/DashletForm.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/application/forms/Dashboard/DashletForm.php b/application/forms/Dashboard/DashletForm.php index 6a33a439b..59ae41582 100644 --- a/application/forms/Dashboard/DashletForm.php +++ b/application/forms/Dashboard/DashletForm.php @@ -116,9 +116,9 @@ class DashletForm extends Form 'checkbox', 'create_new_pane', array( + 'autosubmit' => true, 'required' => false, 'label' => $this->translate('New dashboard'), - 'class' => 'autosubmit', 'description' => $this->translate('Check this box if you want to add the dashlet to a new dashboard') ) ); From 642fa44fce3f38b0398c708d3dd23efdad4ea548 Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Tue, 3 Mar 2015 09:53:25 +0100 Subject: [PATCH 0856/2920] Move a form's title into the markup of its form --- library/Icinga/Web/Form.php | 10 +++------- modules/monitoring/public/css/module.less | 2 +- .../views/scripts/form/setup-admin-account.phtml | 2 +- 3 files changed, 5 insertions(+), 9 deletions(-) diff --git a/library/Icinga/Web/Form.php b/library/Icinga/Web/Form.php index 2cce16f76..f70ab7351 100644 --- a/library/Icinga/Web/Form.php +++ b/library/Icinga/Web/Form.php @@ -909,16 +909,12 @@ class Form extends Zend_Form 'form' => $this )); } else { - $this->addDecorator('FormErrors', array('onlyCustomFormErrors' => true)) + $this->addDecorator('Description', array('tag' => 'h1')) + ->addDecorator('FormErrors', array('onlyCustomFormErrors' => true)) ->addDecorator('FormDescriptions') ->addDecorator('FormElements') //->addDecorator('HtmlTag', array('tag' => 'dl', 'class' => 'zend_form')) - ->addDecorator('Form') - ->addDecorator('Description', array( - 'placement' => 'prepend', - 'class' => 'form-title', - 'tag' => 'h1' - )); + ->addDecorator('Form'); } } diff --git a/modules/monitoring/public/css/module.less b/modules/monitoring/public/css/module.less index 02ef9be6c..cc820f7a1 100644 --- a/modules/monitoring/public/css/module.less +++ b/modules/monitoring/public/css/module.less @@ -190,7 +190,7 @@ div.selection-info { vertical-align: middle; } -.object-command h1.form-title, .objects-command h1.form-title { +.object-command form h1, .objects-command form h1 { border: none; } diff --git a/modules/setup/application/views/scripts/form/setup-admin-account.phtml b/modules/setup/application/views/scripts/form/setup-admin-account.phtml index 83d01d43b..55767e96f 100644 --- a/modules/setup/application/views/scripts/form/setup-admin-account.phtml +++ b/modules/setup/application/views/scripts/form/setup-admin-account.phtml @@ -6,8 +6,8 @@ $radioElem = $form->getElement('user_type'); $showRadioBoxes = strpos(strtolower(get_class($radioElem)), 'radio') !== false; ?> -

    translate('Administration', 'setup.page.title'); ?>

    +

    translate('Administration', 'setup.page.title'); ?>

    • translatePlural( 'Now it\'s time to configure your first administrative account for Icinga Web 2. Please follow the instructions below:', From dcf38cbf737d1c02658b9528494cc7686dd1e041 Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Tue, 3 Mar 2015 09:54:12 +0100 Subject: [PATCH 0857/2920] Fix form id of the authentication configuration --- application/views/scripts/form/reorder-authbackend.phtml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/application/views/scripts/form/reorder-authbackend.phtml b/application/views/scripts/form/reorder-authbackend.phtml index f6b432940..cd8001436 100644 --- a/application/views/scripts/form/reorder-authbackend.phtml +++ b/application/views/scripts/form/reorder-authbackend.phtml @@ -1,4 +1,4 @@ - + From 747e51553e2599215c9969a1b56a1f498331050a Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Tue, 3 Mar 2015 13:33:26 +0100 Subject: [PATCH 0858/2920] Allow the Autosubmit decorator being used on forms as well refs #7935 --- library/Icinga/Web/Form.php | 70 ++++++++++++++++--- .../Icinga/Web/Form/Decorator/Autosubmit.php | 42 ++++++++--- public/css/icinga/forms.less | 6 ++ 3 files changed, 100 insertions(+), 18 deletions(-) diff --git a/library/Icinga/Web/Form.php b/library/Icinga/Web/Form.php index f70ab7351..fad1a9d5e 100644 --- a/library/Icinga/Web/Form.php +++ b/library/Icinga/Web/Form.php @@ -133,6 +133,15 @@ class Form extends Zend_Form */ protected $descriptions; + /** + * Whether the Autosubmit decorator should be applied to this form + * + * If this is true, the Autosubmit decorator is being applied to this form instead of to each of its elements. + * + * @var bool + */ + protected $useFormAutosubmit = false; + /** * Authentication manager * @@ -486,6 +495,31 @@ class Form extends Zend_Form return $this->descriptions; } + /** + * Set whether the Autosubmit decorator should be applied to this form + * + * If true, the Autosubmit decorator is being applied to this form instead of to each of its elements. + * + * @param bool $state + * + * @return Form + */ + public function setUseFormAutosubmit($state = true) + { + $this->useFormAutosubmit = (bool) $state; + return $this; + } + + /** + * Return whether the Autosubmit decorator is being applied to this form + * + * @return bool + */ + public function getUseFormAutosubmit() + { + return $this->useFormAutosubmit; + } + /** * Create this form * @@ -647,20 +681,35 @@ class Form extends Zend_Form } if ($el->getAttrib('autosubmit')) { - $autosubmitDecorator = new Autosubmit(); - $autosubmitDecorator->setAccessible(); + if ($this->getUseFormAutosubmit()) { + $warningId = 'autosubmit_warning_' . $el->getId(); + $warningText = $this->getView()->escape($this->translate( + 'Upon its value has changed, this control issues an automatic update of this page.' + )); + $autosubmitDecorator = $this->_getDecorator('Callback', array( + 'placement' => 'PREPEND', + 'callback' => function ($content) use ($warningId, $warningText) { + return '' . $warningText . ''; + } + )); + } else { + $autosubmitDecorator = new Autosubmit(); + $autosubmitDecorator->setAccessible(); + $warningId = $autosubmitDecorator->getWarningId($el); + } + $decorators = $el->getDecorators(); $pos = array_search('Zend_Form_Decorator_ViewHelper', array_keys($decorators)) + 1; $el->setDecorators( array_slice($decorators, 0, $pos, true) - + array(get_class($autosubmitDecorator) => $autosubmitDecorator) + + array('autosubmit' => $autosubmitDecorator) + array_slice($decorators, $pos, count($decorators) - $pos, true) ); if (($describedBy = $el->getAttrib('aria-describedby')) !== null) { - $el->setAttrib('aria-describedby', $describedBy . ' ' . $autosubmitDecorator->getWarningId($el)); + $el->setAttrib('aria-describedby', $describedBy . ' ' . $warningId); } else { - $el->setAttrib('aria-describedby', $autosubmitDecorator->getWarningId($el)); + $el->setAttrib('aria-describedby', $warningId); } $class = $el->getAttrib('class'); @@ -702,7 +751,7 @@ class Form extends Zend_Form if (($describedBy = $element->getAttrib('aria-describedby')) !== null) { // Assume that it's because of the element being of type autosubmit or // that one who did set the property manually removes the help decorator - // in case it has already an aria-requiredby property set + // in case it has already an aria-describedby property set $element->setAttrib( 'aria-describedby', $help->setAccessible()->getDescriptionId($element) . ' ' . $describedBy @@ -909,8 +958,13 @@ class Form extends Zend_Form 'form' => $this )); } else { - $this->addDecorator('Description', array('tag' => 'h1')) - ->addDecorator('FormErrors', array('onlyCustomFormErrors' => true)) + $this->addDecorator('Description', array('tag' => 'h1')); + if ($this->getUseFormAutosubmit()) { + $this->addDecorator('Autosubmit', array('accessible' => true)) + ->addDecorator('HtmlTag', array('tag' => 'div', 'class' => 'header')); + } + + $this->addDecorator('FormErrors', array('onlyCustomFormErrors' => true)) ->addDecorator('FormDescriptions') ->addDecorator('FormElements') //->addDecorator('HtmlTag', array('tag' => 'dl', 'class' => 'zend_form')) diff --git a/library/Icinga/Web/Form/Decorator/Autosubmit.php b/library/Icinga/Web/Form/Decorator/Autosubmit.php index 928325919..53fcaa5a0 100644 --- a/library/Icinga/Web/Form/Decorator/Autosubmit.php +++ b/library/Icinga/Web/Form/Decorator/Autosubmit.php @@ -3,15 +3,15 @@ namespace Icinga\Web\Form\Decorator; -use Zend_Form_Element; use Zend_Form_Decorator_Abstract; use Icinga\Application\Icinga; use Icinga\Web\View; +use Icinga\Web\Form; /** * Decorator to add an icon and a submit button encapsulated in noscript-tags * - * The icon is shown in JS environments to indicate that a specific form control does automatically request an update + * The icon is shown in JS environments to indicate that a specific form field does automatically request an update * of its form upon it has changed. The button allows users in non-JS environments to trigger the update manually. */ class Autosubmit extends Zend_Form_Decorator_Abstract @@ -21,7 +21,7 @@ class Autosubmit extends Zend_Form_Decorator_Abstract * * @var bool */ - protected $accessible = false; + protected $accessible; /** * The id used to identify the auto-submit warning associated with the decorated form element @@ -43,14 +43,28 @@ class Autosubmit extends Zend_Form_Decorator_Abstract return $this; } + /** + * Return whether a hidden is being created with the same warning as in the icon label + * + * @return bool + */ + public function getAccessible() + { + if ($this->accessible === null) { + $this->accessible = $this->getOption('accessible') ?: false; + } + + return $this->accessible; + } + /** * Return the id used to identify the auto-submit warning associated with the decorated element * - * @param Zend_Form_Element $element The element for which to generate a id + * @param mixed $element The element for which to generate a id * * @return string */ - public function getWarningId(Zend_Form_Element $element = null) + public function getWarningId($element = null) { if ($this->warningId === null) { $element = $element ?: $this->getElement(); @@ -80,13 +94,18 @@ class Autosubmit extends Zend_Form_Decorator_Abstract public function render($content = '') { if ($content) { - $warning = t('Upon its value has changed, this control issues an automatic update of this page.'); + $isForm = $this->getElement() instanceof Form; + $warning = $isForm + ? t('Upon any of this form\'s fields were changed, this page is being updated automatically.') + : t('Upon its value has changed, this field issues an automatic update of this page.'); $content .= $this->getView()->icon('cw', $warning, array( 'aria-hidden' => 'true', 'class' => 'autosubmit-warning' )); - if ($this->accessible) { - $content = '' . $warning . '' . $content; + if ($this->getAccessible()) { + $content = $isForm + ? $content . '' . $warning . '' + : '' . $warning . '' . $content; } $content .= sprintf( @@ -95,10 +114,13 @@ class Autosubmit extends Zend_Form_Decorator_Abstract . ' class="noscript-apply"' . ' type="submit"' . ' value="1"' - . ($this->accessible ? ' aria-label="%1$s"' : '') + . ($this->getAccessible() ? ' aria-label="%1$s"' : '') . ' title="%1$s"' . '>%2$s', - t('Push this button to update the form to reflect the change that was made in the control on the left'), + $isForm + ? t('Push this button to update the form to reflect the changes that were made below') + : t('Push this button to update the form to reflect the change' + . ' that was made in the field on the left'), $this->getView()->icon('cw') . t('Apply') ); } diff --git a/public/css/icinga/forms.less b/public/css/icinga/forms.less index d503ba037..0f9c67170 100644 --- a/public/css/icinga/forms.less +++ b/public/css/icinga/forms.less @@ -227,4 +227,10 @@ form ul.descriptions { list-style-type: none; } } +} + +form > div.header { + h1 { + display: inline-block; + } } \ No newline at end of file From d9fdcf036b5d28fcba7fc8c80a05d1c773a4b7b2 Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Tue, 3 Mar 2015 14:34:08 +0100 Subject: [PATCH 0859/2920] Show a form based autosubmit warning when toggling instance features refs #7935 --- .../Instance/ToggleInstanceFeaturesCommandForm.php | 3 +++ .../application/views/scripts/process/info.phtml | 5 +---- modules/monitoring/public/css/module.less | 12 +++++++++++- public/css/icinga/forms.less | 2 +- 4 files changed, 16 insertions(+), 6 deletions(-) diff --git a/modules/monitoring/application/forms/Command/Instance/ToggleInstanceFeaturesCommandForm.php b/modules/monitoring/application/forms/Command/Instance/ToggleInstanceFeaturesCommandForm.php index 692ed6094..ec58bb4b6 100644 --- a/modules/monitoring/application/forms/Command/Instance/ToggleInstanceFeaturesCommandForm.php +++ b/modules/monitoring/application/forms/Command/Instance/ToggleInstanceFeaturesCommandForm.php @@ -25,7 +25,10 @@ class ToggleInstanceFeaturesCommandForm extends CommandForm */ public function init() { + $this->setUseFormAutosubmit(); + $this->setTitle($this->translate('Feature Commands')); $this->setAttrib('class', 'inline instance-features'); + $this->loadDefaultDecorators()->getDecorator('description')->setTag('h2'); } /** diff --git a/modules/monitoring/application/views/scripts/process/info.phtml b/modules/monitoring/application/views/scripts/process/info.phtml index 639b5ebc0..b881641e6 100644 --- a/modules/monitoring/application/views/scripts/process/info.phtml +++ b/modules/monitoring/application/views/scripts/process/info.phtml @@ -16,10 +16,7 @@ $cp = $this->checkPerformance()->create($this->checkperformance);
      -

      - translate('Feature Commands') ?> -

      - toggleFeaturesForm ?> + toggleFeaturesForm; ?>
      diff --git a/modules/monitoring/public/css/module.less b/modules/monitoring/public/css/module.less index cc820f7a1..936c6c5de 100644 --- a/modules/monitoring/public/css/module.less +++ b/modules/monitoring/public/css/module.less @@ -160,6 +160,16 @@ form.instance-features span.description, form.object-features span.description { display: inline; } +.boxview div.box form.instance-features div.header { + border-bottom: 1px solid #d9d9d9; + margin-bottom: 0.5em; + + h2 { + border: 0; + padding-bottom: 0; + } +} + table.avp .customvar ul { list-style-type: none; margin: 0; @@ -202,4 +212,4 @@ hr.command-separator { .sort-box { float: right; margin-right: 1em; -} \ No newline at end of file +} diff --git a/public/css/icinga/forms.less b/public/css/icinga/forms.less index 0f9c67170..41525a4c7 100644 --- a/public/css/icinga/forms.less +++ b/public/css/icinga/forms.less @@ -230,7 +230,7 @@ form ul.descriptions { } form > div.header { - h1 { + h1, h2, h3, h4, h5, h6 { display: inline-block; } } \ No newline at end of file From c2339d156bc591b09bb9dad7e42c6d664c53f207 Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Tue, 3 Mar 2015 14:35:41 +0100 Subject: [PATCH 0860/2920] Improve aria-hidden handling in the icon and img view helper --- library/Icinga/Web/View/helpers/url.php | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/library/Icinga/Web/View/helpers/url.php b/library/Icinga/Web/View/helpers/url.php index f58afef35..39e8de951 100644 --- a/library/Icinga/Web/View/helpers/url.php +++ b/library/Icinga/Web/View/helpers/url.php @@ -53,11 +53,12 @@ $this->addHelperFunction('img', function ($url, $params = null, array $propertie $properties['alt'] = ''; } + $ariaHidden = array_key_exists('aria-hidden', $properties) ? $properties['aria-hidden'] : null; if (array_key_exists('title', $properties)) { - if (! array_key_exists('aria-label', $properties) && !array_key_exists('aria-hidden', $properties)) { + if (! array_key_exists('aria-label', $properties) && $ariaHidden !== 'true') { $properties['aria-label'] = $properties['title']; } - } elseif (! array_key_exists('aria-hidden', $properties)) { + } elseif ($ariaHidden === null) { $properties['aria-hidden'] = 'true'; } @@ -79,14 +80,15 @@ $this->addHelperFunction('icon', function ($img, $title = null, array $propertie return $view->img('img/icons/' . $img, $properties); } + $ariaHidden = array_key_exists('aria-hidden', $properties) ? $properties['aria-hidden'] : null; if ($title !== null) { $properties['role'] = 'img'; $properties['title'] = $title; - if (! array_key_exists('aria-label', $properties) && !array_key_exists('aria-hidden', $properties)) { + if (! array_key_exists('aria-label', $properties) && $ariaHidden !== 'true') { $properties['aria-label'] = $title; } - } elseif (! array_key_exists('aria-hidden', $properties)) { + } elseif ($ariaHidden === null) { $properties['aria-hidden'] = 'true'; } From 8510835fba2a7adb8241a4fea42f757660e2ce47 Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Tue, 3 Mar 2015 14:35:46 +0100 Subject: [PATCH 0861/2920] Fix accessibility of the Autosubmit decorator when applied to a form refs #7935 --- library/Icinga/Web/Form/Decorator/Autosubmit.php | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/library/Icinga/Web/Form/Decorator/Autosubmit.php b/library/Icinga/Web/Form/Decorator/Autosubmit.php index 53fcaa5a0..6893c161e 100644 --- a/library/Icinga/Web/Form/Decorator/Autosubmit.php +++ b/library/Icinga/Web/Form/Decorator/Autosubmit.php @@ -99,13 +99,11 @@ class Autosubmit extends Zend_Form_Decorator_Abstract ? t('Upon any of this form\'s fields were changed, this page is being updated automatically.') : t('Upon its value has changed, this field issues an automatic update of this page.'); $content .= $this->getView()->icon('cw', $warning, array( - 'aria-hidden' => 'true', + 'aria-hidden' => $isForm ? 'false' : 'true', 'class' => 'autosubmit-warning' )); - if ($this->getAccessible()) { - $content = $isForm - ? $content . '' . $warning . '' - : '' . $warning . '' . $content; + if (! $isForm && $this->getAccessible()) { + $content = '' . $warning . '' . $content; } $content .= sprintf( From 507e5b43cc2f639d17e19dd21e009828400ded2a Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Tue, 3 Mar 2015 14:52:45 +0100 Subject: [PATCH 0862/2920] Show a form based autosubmit warning when toggling object features refs #7935 --- .../forms/Command/Object/ToggleObjectFeaturesCommandForm.php | 3 +++ modules/monitoring/public/css/module.less | 4 ++++ 2 files changed, 7 insertions(+) diff --git a/modules/monitoring/application/forms/Command/Object/ToggleObjectFeaturesCommandForm.php b/modules/monitoring/application/forms/Command/Object/ToggleObjectFeaturesCommandForm.php index 5caacb5f8..a6c20f630 100644 --- a/modules/monitoring/application/forms/Command/Object/ToggleObjectFeaturesCommandForm.php +++ b/modules/monitoring/application/forms/Command/Object/ToggleObjectFeaturesCommandForm.php @@ -18,7 +18,10 @@ class ToggleObjectFeaturesCommandForm extends ObjectsCommandForm */ public function init() { + $this->setUseFormAutosubmit(); + $this->setTitle('Feature Commands'); $this->setAttrib('class', 'inline object-features'); + $this->loadDefaultDecorators()->getDecorator('description')->setTag('h4'); } /** diff --git a/modules/monitoring/public/css/module.less b/modules/monitoring/public/css/module.less index 936c6c5de..6c205cd04 100644 --- a/modules/monitoring/public/css/module.less +++ b/modules/monitoring/public/css/module.less @@ -170,6 +170,10 @@ form.instance-features span.description, form.object-features span.description { } } +table.avp form.object-features div.header h4 { + margin: 0; +} + table.avp .customvar ul { list-style-type: none; margin: 0; From e2887df03e78e1ebffb3b7aecaae6051f37c3ccd Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Tue, 3 Mar 2015 15:01:09 +0100 Subject: [PATCH 0863/2920] Form: It's a field, not a control --- library/Icinga/Web/Form.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library/Icinga/Web/Form.php b/library/Icinga/Web/Form.php index fad1a9d5e..c229f8311 100644 --- a/library/Icinga/Web/Form.php +++ b/library/Icinga/Web/Form.php @@ -684,7 +684,7 @@ class Form extends Zend_Form if ($this->getUseFormAutosubmit()) { $warningId = 'autosubmit_warning_' . $el->getId(); $warningText = $this->getView()->escape($this->translate( - 'Upon its value has changed, this control issues an automatic update of this page.' + 'Upon its value has changed, this field issues an automatic update of this page.' )); $autosubmitDecorator = $this->_getDecorator('Callback', array( 'placement' => 'PREPEND', From 6e61980dd2c0f5344c9469669c83b5f1af42c7e0 Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Wed, 4 Mar 2015 08:28:30 +0100 Subject: [PATCH 0864/2920] Fix operator precedence when detecting the default locale fixes #8370 --- library/Icinga/Application/Web.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/library/Icinga/Application/Web.php b/library/Icinga/Application/Web.php index 72e91ca92..45dbc7e87 100644 --- a/library/Icinga/Application/Web.php +++ b/library/Icinga/Application/Web.php @@ -314,12 +314,12 @@ class Web extends ApplicationBootstrap protected function detectLocale() { $auth = Manager::getInstance(); - if (! $auth->isAuthenticated() + if (isset($_SERVER['HTTP_ACCEPT_LANGUAGE']) && !$auth->isAuthenticated() || ($locale = $auth->getUser()->getPreferences()->getValue('icingaweb', 'language')) === null - && isset($_SERVER['HTTP_ACCEPT_LANGUAGE']) ) { $locale = Translator::getPreferredLocaleCode($_SERVER['HTTP_ACCEPT_LANGUAGE']); } + return $locale; } From ff263946c87f0a0f35e54e538e0f2264d8460261 Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Wed, 4 Mar 2015 09:38:00 +0100 Subject: [PATCH 0865/2920] Form: Fix translation domain detection while running unit tests --- library/Icinga/Web/Form.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/library/Icinga/Web/Form.php b/library/Icinga/Web/Form.php index c229f8311..3ebfdaf04 100644 --- a/library/Icinga/Web/Form.php +++ b/library/Icinga/Web/Form.php @@ -1071,10 +1071,11 @@ class Form extends Zend_Form protected function getTranslationDomain() { $parts = explode('\\', get_called_class()); - if ($parts[1] === 'Module') { + if (count($parts) > 1 && $parts[1] === 'Module') { // Assume format Icinga\Module\ModuleName\Forms\... return strtolower($parts[2]); } + return 'icinga'; } From 5c371a6d0b3a2bfcf6d0e0d0971afb2503d18297 Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Wed, 4 Mar 2015 09:43:37 +0100 Subject: [PATCH 0866/2920] Fix form tests --- .../forms/Config/Authentication/DbBackendFormTest.php | 10 ++++++++-- .../Config/Authentication/LdapBackendFormTest.php | 10 ++++++++-- .../forms/Config/Resource/LdapResourceFormTest.php | 10 ++++++++-- 3 files changed, 24 insertions(+), 6 deletions(-) diff --git a/test/php/application/forms/Config/Authentication/DbBackendFormTest.php b/test/php/application/forms/Config/Authentication/DbBackendFormTest.php index 2dc7fb5a0..b7d1ea3c1 100644 --- a/test/php/application/forms/Config/Authentication/DbBackendFormTest.php +++ b/test/php/application/forms/Config/Authentication/DbBackendFormTest.php @@ -31,7 +31,10 @@ class DbBackendFormTest extends BaseTestCase ->shouldReceive('count') ->andReturn(2); - $form = new DbBackendForm(); + $form = Mockery::mock('Icinga\Forms\Config\Authentication\DbBackendForm[getView]'); + $form->shouldReceive('getView->escape') + ->with(Mockery::type('string')) + ->andReturnUsing(function ($s) { return $s; }); $form->setTokenDisabled(); $form->setResources(array('test_db_backend')); $form->populate(array('resource' => 'test_db_backend')); @@ -53,7 +56,10 @@ class DbBackendFormTest extends BaseTestCase ->shouldReceive('count') ->andReturn(0); - $form = new DbBackendForm(); + $form = Mockery::mock('Icinga\Forms\Config\Authentication\DbBackendForm[getView]'); + $form->shouldReceive('getView->escape') + ->with(Mockery::type('string')) + ->andReturnUsing(function ($s) { return $s; }); $form->setTokenDisabled(); $form->setResources(array('test_db_backend')); $form->populate(array('resource' => 'test_db_backend')); diff --git a/test/php/application/forms/Config/Authentication/LdapBackendFormTest.php b/test/php/application/forms/Config/Authentication/LdapBackendFormTest.php index 561d61b1c..d31033ba9 100644 --- a/test/php/application/forms/Config/Authentication/LdapBackendFormTest.php +++ b/test/php/application/forms/Config/Authentication/LdapBackendFormTest.php @@ -31,7 +31,10 @@ class LdapBackendFormTest extends BaseTestCase Mockery::mock('overload:Icinga\Authentication\Backend\LdapUserBackend') ->shouldReceive('assertAuthenticationPossible')->andReturnNull(); - $form = new LdapBackendForm(); + $form = Mockery::mock('Icinga\Forms\Config\Authentication\LdapBackendForm[getView]'); + $form->shouldReceive('getView->escape') + ->with(Mockery::type('string')) + ->andReturnUsing(function ($s) { return $s; }); $form->setTokenDisabled(); $form->setResources(array('test_ldap_backend')); $form->populate(array('resource' => 'test_ldap_backend')); @@ -52,7 +55,10 @@ class LdapBackendFormTest extends BaseTestCase Mockery::mock('overload:Icinga\Authentication\Backend\LdapUserBackend') ->shouldReceive('assertAuthenticationPossible')->andThrow(new AuthenticationException); - $form = new LdapBackendForm(); + $form = Mockery::mock('Icinga\Forms\Config\Authentication\LdapBackendForm[getView]'); + $form->shouldReceive('getView->escape') + ->with(Mockery::type('string')) + ->andReturnUsing(function ($s) { return $s; }); $form->setTokenDisabled(); $form->setResources(array('test_ldap_backend')); $form->populate(array('resource' => 'test_ldap_backend')); diff --git a/test/php/application/forms/Config/Resource/LdapResourceFormTest.php b/test/php/application/forms/Config/Resource/LdapResourceFormTest.php index f6d823046..d074f1b3b 100644 --- a/test/php/application/forms/Config/Resource/LdapResourceFormTest.php +++ b/test/php/application/forms/Config/Resource/LdapResourceFormTest.php @@ -29,7 +29,10 @@ class LdapResourceFormTest extends BaseTestCase Mockery::mock()->shouldReceive('testCredentials')->once()->andReturn(true)->getMock() ); - $form = new LdapResourceForm(); + $form = Mockery::mock('Icinga\Forms\Config\Resource\LdapResourceForm[getView]'); + $form->shouldReceive('getView->escape') + ->with(Mockery::type('string')) + ->andReturnUsing(function ($s) { return $s; }); $form->setTokenDisabled(); $this->assertTrue( @@ -48,7 +51,10 @@ class LdapResourceFormTest extends BaseTestCase Mockery::mock()->shouldReceive('testCredentials')->once()->andThrow('\Exception')->getMock() ); - $form = new LdapResourceForm(); + $form = Mockery::mock('Icinga\Forms\Config\Resource\LdapResourceForm[getView]'); + $form->shouldReceive('getView->escape') + ->with(Mockery::type('string')) + ->andReturnUsing(function ($s) { return $s; }); $form->setTokenDisabled(); $this->assertFalse( From 31560c9249dddd5863839aa448a700b01b5ca8bc Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Thu, 5 Mar 2015 10:30:06 +0100 Subject: [PATCH 0867/2920] Wizard: Explain that the webserver user must be in the group "icingaweb2" resolves #8491 --- .../views/scripts/form/setup-welcome.phtml | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/modules/setup/application/views/scripts/form/setup-welcome.phtml b/modules/setup/application/views/scripts/form/setup-welcome.phtml index d4bc1c3d7..1b37f60f0 100644 --- a/modules/setup/application/views/scripts/form/setup-welcome.phtml +++ b/modules/setup/application/views/scripts/form/setup-welcome.phtml @@ -5,6 +5,7 @@ use Icinga\Application\Config; use Icinga\Application\Platform; use Icinga\Web\Wizard; +$phpUser = Platform::getPhpUser(); $configDir = Icinga::app()->getConfigDir(); $setupTokenPath = rtrim($configDir, '/') . '/setup.token'; $cliPath = realpath(Icinga::app()->getApplicationDir() . '/../bin/icingacli'); @@ -41,10 +42,15 @@ $cliPath = realpath(Icinga::app()->getApplicationDir() . '/../bin/icingacli'); 'To run this wizard a user needs to authenticate using a token which is usually' . ' provided to him by an administrator who\'d followed the instructions below.' ); ?>

      -

      translate('In any case, make sure that a group called "icingaweb2" exists:'); ?>

      -
      - groupadd icingaweb2; -
      +

      translate('In any case, make sure that all of the following applies to your environment:'); ?>

      +
        +
      • translate('A system group called "icingaweb2" exists'); ?>
      • + +
      • translate('The user "%s" is a member of the system group "icingaweb2"'), $phpUser); ?>
      • + +
      • translate('Your webserver\'s user is a member of the system group "icingaweb2"'); ?>
      • + +

      translate('If you\'ve got the IcingaCLI installed you can do the following:'); ?>

      setup config directory --group icingaweb2; @@ -52,7 +58,7 @@ $cliPath = realpath(Icinga::app()->getApplicationDir() . '/../bin/icingacli');

      translate('In case the IcingaCLI is missing you can create the token manually:'); ?>

      - su -c "mkdir -m 2770 ; chgrp icingaweb2 ; head -c 12 /dev/urandom | base64 | tee ; chmod 0660 ;"; + su translate(''); ?> -c "mkdir -m 2770 ; chgrp icingaweb2 ; head -c 12 /dev/urandom | base64 | tee ; chmod 0660 ;";

      translate('Please see the %s for an extensive description on how to access and use this wizard.'), From 764f125778c409c045e6ce63d2be6d82ed688142 Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Thu, 5 Mar 2015 15:08:30 +0100 Subject: [PATCH 0868/2920] Make the FormDescriptions decorator able to handle sub forms refs #7947 --- .../Web/Form/Decorator/FormDescriptions.php | 108 ++++++++++++------ 1 file changed, 71 insertions(+), 37 deletions(-) diff --git a/library/Icinga/Web/Form/Decorator/FormDescriptions.php b/library/Icinga/Web/Form/Decorator/FormDescriptions.php index 012c934a1..c8ba16ead 100644 --- a/library/Icinga/Web/Form/Decorator/FormDescriptions.php +++ b/library/Icinga/Web/Form/Decorator/FormDescriptions.php @@ -13,6 +13,29 @@ use Icinga\Web\Form; */ class FormDescriptions extends Zend_Form_Decorator_Abstract { + /** + * A list of element class names to be ignored when detecting which message to use to describe required elements + * + * @var array + */ + protected $blacklist; + + /** + * {@inheritdoc} + */ + public function __construct($options = null) + { + parent::__construct($options); + $this->blacklist = array( + 'Zend_Form_Element_Hidden', + 'Zend_Form_Element_Submit', + 'Zend_Form_Element_Button', + 'Icinga\Web\Form\Element\Note', + 'Icinga\Web\Form\Element\Button', + 'Icinga\Web\Form\Element\CsrfCounterMeasure' + ); + } + /** * Render form descriptions * @@ -32,9 +55,16 @@ class FormDescriptions extends Zend_Form_Decorator_Abstract return $content; } - $descriptions = $form->getDescriptions(); - if (($requiredDesc = $this->getRequiredDescription($form)) !== null) { - $descriptions[] = $requiredDesc; + $descriptions = $this->recurseForm($form, $entirelyRequired); + if ($entirelyRequired) { + $descriptions[] = $form->getView()->translate( + 'All fields are required and must be filled in to complete the form.' + ); + } elseif ($entirelyRequired === false) { + $descriptions[] = $form->getView()->translate(sprintf( + 'Required fields are marked with %s and must be filled in to complete the form.', + $form->getRequiredCue() + )); } if (empty($descriptions)) { @@ -60,53 +90,57 @@ class FormDescriptions extends Zend_Form_Decorator_Abstract } /** - * Return the description for the given form's required elements + * Recurse the given form and return the descriptions for it and all of its subforms * - * @param Form $form + * @param Form $form The form to recurse + * @param mixed $entirelyRequired Set by reference, true means all elements in the hierarchy are + * required, false only a partial subset and null none at all + * @param bool $elementsPassed Whether there were any elements passed during the recursion until now * - * @return string|null + * @return array */ - protected function getRequiredDescription(Form $form) + protected function recurseForm(Form $form, & $entirelyRequired = null, $elementsPassed = false) { - if (($cue = $form->getRequiredCue()) === null) { - return; - } - $requiredLabels = array(); - $entirelyRequired = true; - $partiallyRequired = false; - $blacklist = array( - 'Zend_Form_Element_Hidden', - 'Zend_Form_Element_Submit', - 'Zend_Form_Element_Button', - 'Icinga\Web\Form\Element\Note', - 'Icinga\Web\Form\Element\Button', - 'Icinga\Web\Form\Element\CsrfCounterMeasure' - ); - foreach ($form->getElements() as $element) { - if (! in_array($element->getType(), $blacklist)) { - if (! $element->isRequired()) { - $entirelyRequired = false; - } else { - $partiallyRequired = true; - if (($label = $element->getDecorator('label')) !== false) { - $requiredLabels[] = $label; + if ($form->getRequiredCue() !== null) { + $partiallyRequired = $partiallyOptional = false; + foreach ($form->getElements() as $element) { + if (! in_array($element->getType(), $this->blacklist)) { + if (! $element->isRequired()) { + $partiallyOptional = true; + if ($entirelyRequired) { + $entirelyRequired = false; + } + } else { + $partiallyRequired = true; + if (($label = $element->getDecorator('label')) !== false) { + $requiredLabels[] = $label; + } } } } + + if (! $elementsPassed) { + $elementsPassed = $partiallyRequired || $partiallyOptional; + if ($entirelyRequired === null && $partiallyRequired) { + $entirelyRequired = ! $partiallyOptional; + } + } elseif ($entirelyRequired === null && $partiallyRequired) { + $entirelyRequired = false; + } } - if ($entirelyRequired && $partiallyRequired) { + $descriptions = array($form->getDescriptions()); + foreach ($form->getSubForms() as $subForm) { + $descriptions[] = $this->recurseForm($subForm, $entirelyRequired, $elementsPassed); + } + + if ($entirelyRequired) { foreach ($requiredLabels as $label) { $label->setRequiredSuffix(''); } - - return $form->getView()->translate('All fields are required and must be filled in to complete the form.'); - } elseif ($partiallyRequired) { - return $form->getView()->translate(sprintf( - 'Required fields are marked with %s and must be filled in to complete the form.', - $cue - )); } + + return call_user_func_array('array_merge', $descriptions); } } From b8eedc21bbebb660ecdb32cfbb0abbbfb9ce428b Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Thu, 5 Mar 2015 15:12:02 +0100 Subject: [PATCH 0869/2920] Form: Explicitly set subform decorators refs #7947 --- library/Icinga/Web/Form.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library/Icinga/Web/Form.php b/library/Icinga/Web/Form.php index 3ebfdaf04..795fac1e9 100644 --- a/library/Icinga/Web/Form.php +++ b/library/Icinga/Web/Form.php @@ -622,7 +622,7 @@ class Form extends Zend_Form public function addSubForm(Zend_Form $form, $name = null, $order = null) { if ($form instanceof self) { - $form->removeDecorator('Form'); + $form->setDecorators(array('FormElements')); // TODO: Makes it difficult to customise subform decorators.. $form->setSubmitLabel(''); $form->setTokenDisabled(); $form->setUidDisabled(); From b9811f8590ad7bc8cce91a3bc881e73667fed01e Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Thu, 5 Mar 2015 15:13:38 +0100 Subject: [PATCH 0870/2920] Form: Do not set the requiredSuffix as option but use its virtual setter This removes the invalid attribute on each

      + + compact): ?> + + + +

      translate('%d Services Selected'), count($objects)) ?>

      render('partials/service/objects-header.phtml'); ?> +

      translate('%d Hosts Selected'), count($objects)) ?>

      render('partials/host/objects-header.phtml'); ?>
      +
      -
      Backend
      - - - - - - - - getObjects() as $object): /** @var \Icinga\Module\Monitoring\Object\MonitoredObject $object */ ?> - - getType() === $object::TYPE_HOST): ?> - - - - - - - - -
      icon('host'); ?> translate('Host'); ?>icon('conf'); ?> translate('Service'); ?>
      escape($object->getName()); ?>escape($object->getHost()->getName()); ?>escape($object->getName()); ?>

      diff --git a/modules/monitoring/application/views/scripts/partials/host/objects-header.phtml b/modules/monitoring/application/views/scripts/partials/host/objects-header.phtml index f892df6f4..448be4c02 100644 --- a/modules/monitoring/application/views/scripts/partials/host/objects-header.phtml +++ b/modules/monitoring/application/views/scripts/partials/host/objects-header.phtml @@ -1,6 +1,7 @@ compact): ?> + 0): ?>

      @@ -15,4 +16,4 @@ translate(strtoupper($text)), $count); ?>

      - \ No newline at end of file + diff --git a/modules/monitoring/application/views/scripts/partials/host/servicesummary.phtml b/modules/monitoring/application/views/scripts/partials/host/servicesummary.phtml index c0acdead4..bdd4d9af7 100644 --- a/modules/monitoring/application/views/scripts/partials/host/servicesummary.phtml +++ b/modules/monitoring/application/views/scripts/partials/host/servicesummary.phtml @@ -31,6 +31,7 @@ $currentUrl = Url::fromRequest()->without('limit')->getRelativeUrl(); translate('No services configured on this host'); ?> + stats->services_ok): ?> diff --git a/modules/monitoring/application/views/scripts/partials/service/objects-header.phtml b/modules/monitoring/application/views/scripts/partials/service/objects-header.phtml index 6389d992f..113e7c0a0 100644 --- a/modules/monitoring/application/views/scripts/partials/service/objects-header.phtml +++ b/modules/monitoring/application/views/scripts/partials/service/objects-header.phtml @@ -1,34 +1,85 @@ -compact): ?> - - + + + 0): ?> -
      -
      -

      - translatePlural('Service (%u)', 'Services (%u)', $serviceCount), $serviceCount); ?> -

      -
      -
      -   -
      -
      - $count): ?> - translate(strtoupper($text)), $count); ?>
      - -
      -
      -
      -
      - - translatePlural('Host (%u)', 'Hosts (%u)', $hostCount), $hostCount); ?> -
      -
      -   -
      -
      - $count): ?> - translate(strtoupper($text)), $count); ?>
      - -
      -
      - \ No newline at end of file +

      + + + + + + + + + + + + + + 5) { + $desc = $service->getHost()->getName() . ' on ' . $service->getName(); + $hidden[] = $desc; + $hiddenRich[] = sprintf("
      %s", $service->getStateText($service->service_state) ,$desc); + continue; + } + ?> + + + + + + + + + + + + + + + + + +
      icon('service'); ?> translate('Service'); ?>icon('host'); ?> translate('Host'); ?>translate('Output'); ?>
      service_state, true); ?>
      + service_handled && $service->service_state > 0): ?> + icon('attention-alt', $this->translate('Unhandled')) ?> + + + service_acknowledged && !$service->service_in_downtime): ?> + icon('ok', $this->translate('Acknowledged') . ( + $service->service_last_ack ? ': ' . $service->service_last_ack : '' + )) ?> + + + service_is_flapping): ?> + icon('flapping', $this->translate('Flapping')) ?> + + + service_notifications_enabled): ?> + icon('bell-off-empty', $this->translate('Notifications Disabled')) ?> + + + service_in_downtime): ?> + icon('plug', $this->translate('In Downtime')) ?> + + + service_last_comment) && $service->service_last_comment !== null): ?> + icon('comment', $this->translate('Last Comment: ') . $service->service_last_comment) ?> + + escape($service->getName()); ?>escape($service->getHost()->getName()); ?>

      escape($service->service_output) ?>

      +
      + +
      +
      +

      + diff --git a/modules/monitoring/application/views/scripts/partials/service/objects-tinysummary.phtml b/modules/monitoring/application/views/scripts/partials/service/objects-tinysummary.phtml new file mode 100644 index 000000000..7707651d2 --- /dev/null +++ b/modules/monitoring/application/views/scripts/partials/service/objects-tinysummary.phtml @@ -0,0 +1,42 @@ + + +

      + qlink( + sprintf($this->translate('%d Services Selected:'), count($objects)), + $listAllLink + ); ?> + + + services_ok): ?> + + + services_ok ?> + + + + 'critical', + 3 => 'unknown', + 1 => 'warning', + 4 => 'pending' + ) as $stateId => $state) { + + $stateName = 'services_' . $state; + $unhandledStateName = $stateName . '_unhandled'; + if ($serviceStates->$unhandledStateName) { + echo '' . $serviceStates->$unhandledStateName . ''; + } + if ($serviceStates->$stateName) { + echo '' . $serviceStates->$stateName . ''; + } + if ($serviceStates->$unhandledStateName) { + echo ''; + } + $stateName .= '_unhandled'; + }?> + +

      \ No newline at end of file diff --git a/modules/monitoring/application/views/scripts/services/show.phtml b/modules/monitoring/application/views/scripts/services/show.phtml index 015fecb95..9dc865010 100644 --- a/modules/monitoring/application/views/scripts/services/show.phtml +++ b/modules/monitoring/application/views/scripts/services/show.phtml @@ -1,47 +1,66 @@ + +
      + + compact): ?> + + + + render('partials/service/objects-tinysummary.phtml') ?> render('partials/service/objects-header.phtml'); ?> +
      - translate('No services matching the filter'); ?> + translate('No services matching the filter'); ?> -

      translatePlural('%u Service', '%u Services', $serviceCount), $serviceCount); ?>

      -
      qlink( - sprintf($this->translate('List all %u services'), $serviceCount), - $listAllLink - ); ?>
      + + +

      qlink( - sprintf($this->translate('Reschedule the next check for all %u services'), $serviceCount), - $rescheduleAllLink, - null, - array('icon' => 'reschedule') - ); ?>
      + $this->translate('Reschedule the next check'), + $rescheduleAllLink, + null, + array('icon' => 'reschedule') + ); ?>
      qlink( - sprintf($this->translate('Schedule a downtime for all %u services'), $serviceCount), - $downtimeAllLink, - null, - array('icon' => 'plug') - ); ?>
      + $this->translate('Schedule a downtime'), + $downtimeAllLink, + null, + array('icon' => 'plug') + ); ?>
      qlink( - sprintf($this->translate('Submit a passive check result for all %u services'), $serviceCount), - $processCheckResultAllLink, - null, - array('icon' => 'reply') - ); ?>
      - 0): ?> -
      -

      translatePlural( - '%u Unhandled Service Problem', - '%u Unhandled Service Problems', - $unhandledCount - ), - $unhandledCount - ); ?>

      -
      qlink( + $this->translate('Submit a passive check result'), + $processCheckResultAllLink, + null, + array('icon' => 'reply') + ); ?>
      +

      + + 0): ?> +
      +

      + icon('attention-alt') ?> + translatePlural( + 'Unhandled Problem', + 'Unhandled Problems', + $unhandledCount + ) ?> +

      + +

      ' . $unhandledCount . '') ?> + + +

      + qlink( sprintf( $this->translatePlural( 'Schedule a downtime for %u unhandled service problem', @@ -53,7 +72,9 @@ $downtimeUnhandledLink, null, array('icon' => 'plug') - ); ?>
      + ); ?> +
      +
      qlink( sprintf( $this->translatePlural( @@ -67,50 +88,101 @@ null, array('icon' => 'ok') ); ?>
      -
      - - 0): ?> -
      -

      translatePlural( - '%u Acknowledged Service Problem', - '%u Acknowledged Service Problems', - $acknowledgedCount - ), +

      + + +

      + + + 0): ?> + +

      icon('ok', $this->translate('Acknowledgements')) ?> translate('Acknowledgements') ?>

      +

      + translatePlural( + '%u Acknowledged Service Problem', + '%u Acknowledged Service Problems', $acknowledgedCount - ); ?> - - - - 0): ?> -

      qlink( - sprintf( - $this->translatePlural( - 'List %u service currently in downtime', - 'List %u services currently in downtime', - $inDowntimeCount - ), - $inDowntimeCount ), + $acknowledgedCount + ); ?> +

      + + + + 0): ?> + +

      icon('plug', $this->translate('Downtimes')) ?> translate('Downtimes') ?>

      +

      translatePlural( + '%u service currently in downtime', + '%u services currently in downtime', + $inDowntimeCount + ), $inDowntimeCount) ?> + +

      + qlink( + $this->translate('List all'), $inDowntimeLink, null, array('icon' => 'plug') - ); ?> - - getComments())) > 0): ?> -

      qlink( - sprintf( - $this->translatePlural( - 'List %u service comment', - 'List %u service comments', - $commentCount - ), + );?> +

      + +
      + Delete All +
      +

      + + + +getComments()) ?> + 0): ?> +

      icon('comment') ?>

      +

      translatePlural( + 'There are no comments.', + 'There are %d comments', $commentCount - ), - $commentsLink, - null, - array('icon' => 'comment') - ); ?> - + ), $commentCount); + ?> + qlink( + $this->translate('List all'), + $commentsLink, + null, + array('icon' => 'comment') + ); ?>

      + + + + fetchComments(); ?> + + comments as $comment): ?> + + + + + + + +
      + populate( + array('comment_id' => $comment->id, 'redirect' => html_entity_decode($this->url)) + ); + $delCommentForm->setAction( + $this->url( + 'monitoring/service/delete-comment', + array('host' => $service->getHost()->getName(), 'service' => $service->getName()) + ) + ); + echo $delCommentForm; + ?> + (type) ?>): + + comment) ?> +
      + + \ No newline at end of file diff --git a/modules/monitoring/public/css/module.less b/modules/monitoring/public/css/module.less index 6c205cd04..eb598bb5d 100644 --- a/modules/monitoring/public/css/module.less +++ b/modules/monitoring/public/css/module.less @@ -91,15 +91,16 @@ div.contacts div.notification-periods { margin-top: 0.5em; } -div.tinystatesummary { +.tinystatesummary { .page-header(); font-size: 1em; .badges { display: inline-block; margin-bottom: 4px; margin-left: 1em; + height: auto; } - .state > a { + .state > * { color: white; font-size: 0.8em; padding: 2px 5px; @@ -196,7 +197,7 @@ div.selection-info { .optionbox label { max-width: 6.5em; text-align: left; - vertical-align: middle; + vertgical-align: middle; margin-right: 0em; } diff --git a/public/css/icinga/monitoring-colors.less b/public/css/icinga/monitoring-colors.less index 5c19bfe35..62d5a68cd 100644 --- a/public/css/icinga/monitoring-colors.less +++ b/public/css/icinga/monitoring-colors.less @@ -922,3 +922,50 @@ table.groupview { } /* End of monitoring groupsummary styles */ + +/* compact table */ +table.statesummary { + text-align: left; + width: auto; + border-collapse: separate; + + tbody { + white-space: nowrap; + } + + td { + padding: 0em 0.4em 0em 0.4em; + line-height: 1.2em; + } + + tr.state td.state { + width: auto; + font-weight: bold; + } + + td .pluginoutput { + font-size: 0.8em; + line-height: 1.2em; + padding-left: 0; + margin: 0; + } + + td.state { + min-width: 70px; + font-size: 0.7em; + text-align: center; + } + + td a { + color: inherit; + text-decoration: none; + } +} + +/* Up to 576px for 1em=16px, should fit 320px devices */ +@media screen and (max-width: 97em) { + + table.statesummary .collapse { + display: none; + } +} diff --git a/public/css/icinga/widgets.less b/public/css/icinga/widgets.less index 45701a697..de33d6685 100644 --- a/public/css/icinga/widgets.less +++ b/public/css/icinga/widgets.less @@ -203,23 +203,13 @@ li li .badge-container { margin-right: 0.75em; } -/* -#layout.hoveredmenu .active > .badge-container { - display: none; -} - -#layout.hoveredmenu .hover > .badge-container { - //margin-right: 14.15em; - display: none; -} -*/ - .badge { position: relative; - top: 0.3em; + top: -0.15em; display: inline-block; min-width: 1em; padding: 3px 7px; + margin: 0 0.2em 0 0.2em; font-size: 0.8em; font-weight: 700; line-height: 1.1em; @@ -230,6 +220,11 @@ li li .badge-container { background-color: @colorInvalid; } +#menu nav ul .badge { + margin-right: 0em; + top: 0.3em; +} + #menu nav > ul > li.active > .badge-container { display: none; } @@ -277,7 +272,7 @@ li li .badge { background-color: @colorPending; } -.badge-pending { +.badge-unknown { background-color: @colorUnknown; } @@ -303,3 +298,24 @@ li li .badge { margin: 0em 0em 0em 0.1em; } + +.tipsy .tipsy-inner { + // overwrite tooltip max width, we need them to grow bigger + max-width: 300px; + text-align: left; +} + +.color-box { + position: relative; + top: 2px; + margin: 0px 3px 0px 3px; + display: inline-block; + width: 12px; + height: 12px; +} + +.oneline { + overflow: hidden; + white-space: nowrap; + text-overflow: ellipsis; +} diff --git a/public/js/icinga/behavior/tooltip.js b/public/js/icinga/behavior/tooltip.js index c9a64257f..c0abcbd45 100644 --- a/public/js/icinga/behavior/tooltip.js +++ b/public/js/icinga/behavior/tooltip.js @@ -30,7 +30,7 @@ $('svg .chart-data', el).tipsy({ gravity: 'se', html: true }); $('.historycolorgrid a[title]', el).tipsy({ gravity: 's', offset: 2 }); $('img.icon[title]', el).tipsy({ gravity: $.fn.tipsy.autoNS, offset: 2 }); - $('[title]', el).tipsy({ gravity: $.fn.tipsy.autoNS, delayIn: 500 }); + $('[title]', el).tipsy({ gravity: $.fn.tipsy.autoNS, delayIn: 500, html: true }); // migrate or remove all orphaned tooltips $('.tipsy').each(function () { From 6cfa958bb848a34e04d943700d18c84f8ffd40ec Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Fri, 6 Mar 2015 08:53:34 +0100 Subject: [PATCH 0874/2920] Allow setting `requirement' on form elements It's supposed to be used as description what kind of value an element will accept. refs #7947 --- library/Icinga/Web/Form.php | 2 +- library/Icinga/Web/Form/Decorator/Help.php | 27 ++++++++++++++++++---- 2 files changed, 23 insertions(+), 6 deletions(-) diff --git a/library/Icinga/Web/Form.php b/library/Icinga/Web/Form.php index c7e613e7b..265da8420 100644 --- a/library/Icinga/Web/Form.php +++ b/library/Icinga/Web/Form.php @@ -157,7 +157,7 @@ class Form extends Zend_Form public static $defaultElementDecorators = array( array('ViewHelper', array('separator' => '')), array('Errors', array('separator' => '')), - array('Help'), + array('Help', array('placement' => 'PREPEND')), array('Label', array('separator' => '')), array('HtmlTag', array('tag' => 'div', 'class' => 'element')) ); diff --git a/library/Icinga/Web/Form/Decorator/Help.php b/library/Icinga/Web/Form/Decorator/Help.php index a02443994..152d548af 100644 --- a/library/Icinga/Web/Form/Decorator/Help.php +++ b/library/Icinga/Web/Form/Decorator/Help.php @@ -76,18 +76,35 @@ class Help extends Zend_Form_Decorator_Abstract */ public function render($content = '') { - if ($content && ($description = $this->getElement()->getDescription()) !== null) { + $element = $this->getElement(); + $description = $element->getDescription(); + $requirement = $element->getAttrib('requirement'); + unset($element->requirement); + + $helpContent = ''; + if ($description || $requirement) { if ($this->accessible) { - $content = 'getDescriptionId() . '" class="sr-only">' . $description - . '' . $content; + . ($description && $requirement ? ' ' : '') + . $requirement + . '
      '; } - $content = $this->getView()->icon('help', $description, array('aria-hidden' => 'true')) . $content; + $helpContent = $this->getView()->icon( + 'help', + $description . ($description && $requirement ? ' ' : '') . $requirement, + array('aria-hidden' => $this->accessible ? 'true' : 'false') + ) . $helpContent; } - return $content; + switch ($this->getPlacement()) { + case self::APPEND: + return $content . $helpContent; + case self::PREPEND: + return $helpContent . $content; + } } } From ef16ba5f48543447ca81b5a7afc2a445eae9c52b Mon Sep 17 00:00:00 2001 From: Matthias Jentsch Date: Fri, 6 Mar 2015 09:23:11 +0100 Subject: [PATCH 0875/2920] Add commands for adding comments to services refs #8348 --- .../controllers/ServicesController.php | 40 +++++++- .../views/scripts/services/show.phtml | 95 ++++++++++++------- 2 files changed, 96 insertions(+), 39 deletions(-) diff --git a/modules/monitoring/application/controllers/ServicesController.php b/modules/monitoring/application/controllers/ServicesController.php index ceabd643e..a20572d0d 100644 --- a/modules/monitoring/application/controllers/ServicesController.php +++ b/modules/monitoring/application/controllers/ServicesController.php @@ -10,7 +10,8 @@ use Icinga\Module\Monitoring\Forms\Command\Object\ProcessCheckResultCommandForm; use Icinga\Module\Monitoring\Forms\Command\Object\RemoveAcknowledgementCommandForm; use Icinga\Module\Monitoring\Forms\Command\Object\ScheduleServiceCheckCommandForm; use Icinga\Module\Monitoring\Forms\Command\Object\ScheduleServiceDowntimeCommandForm; -use Icinga\Module\Monitoring\Forms\Command\Object\DeleteDowntimeCommandForm; +use Icinga\Module\Monitoring\Forms\Command\Object\AddCommentCommandForm; +use Icinga\Module\Monitoring\Forms\Command\Object\DeleteCommentCommandForm; use Icinga\Module\Monitoring\Object\Host; use Icinga\Module\Monitoring\Object\Service; use Icinga\Module\Monitoring\Object\ServiceList; @@ -58,7 +59,8 @@ class Monitoring_ServicesController extends Controller 'service_is_flapping', 'service_notifications_enabled', 'service_output', - 'service_last_ack' + 'service_last_ack', + 'service_last_comment' )); $form @@ -200,18 +202,23 @@ class Monitoring_ServicesController extends Controller ->handleRequest(); $this->view->removeAckForm = $removeAckForm; } + /* if (! empty($objectsInDowntime)) { $removeDowntimeForm = new DeleteDowntimeCommandForm(); - $removeDowntimeForm->setObjects($objectsInDowntime) + $removeDowntimeForm + ->setObjects($objectsInDowntime) ->handleRequest(); $this->view->removeDowntimeForm = $removeDowntimeForm; } + */ $this->setAutorefreshInterval(15); $this->view->rescheduleAllLink = Url::fromRequest()->setPath('monitoring/services/reschedule-check'); $this->view->downtimeAllLink = Url::fromRequest()->setPath('monitoring/services/schedule-downtime'); $this->view->processCheckResultAllLink = Url::fromRequest()->setPath( 'monitoring/services/process-check-result' ); + $this->view->addCommentLink = Url::fromRequest()->setPath('monitoring/services/add-comment'); + $this->view->deleteCommentLink = Url::fromRequest()->setPath('monitoring/services/delete-comment'); $this->view->hostStates = (object)$hostStates; $this->view->serviceStates = (object)$serviceStates; $this->view->objects = $this->serviceList; @@ -250,6 +257,33 @@ class Monitoring_ServicesController extends Controller ->setSparklineClass('sparkline-multi'); } + + /** + * Add a service comment + */ + public function addCommentAction() + { + $this->assertPermission('monitoring/command/comment/add'); + + $form = new AddCommentCommandForm(); + $form->setTitle($this->translate('Add Service Comments')); + $this->handleCommandForm($form); + } + + + /** + * Delete a comment + */ + public function deleteCommentAction() + { + $this->assertPermission('monitoring/command/comment/delete'); + + $form = new DeleteCommentCommandForm(); + $form->setTitle($this->translate('Delete Service Comments')); + $this->handleCommandForm($form); + } + + /** * Acknowledge service problems */ diff --git a/modules/monitoring/application/views/scripts/services/show.phtml b/modules/monitoring/application/views/scripts/services/show.phtml index 9dc865010..cd941df4d 100644 --- a/modules/monitoring/application/views/scripts/services/show.phtml +++ b/modules/monitoring/application/views/scripts/services/show.phtml @@ -14,6 +14,11 @@ use Icinga\Web\Url;
      +

      + icon('reschedule') ?> + translate('Commands') ?> +

      + translate('No services matching the filter'); ?> @@ -41,6 +46,12 @@ use Icinga\Web\Url; null, array('icon' => 'reply') ); ?>
      +
      qlink( + $this->translate('Add a comment'), + $addCommentLink, + null, + array('icon' => 'comment') + ); ?>

      0): ?> @@ -127,10 +138,6 @@ use Icinga\Web\Url; array('icon' => 'plug') );?> - -
      - Delete All -

      @@ -145,44 +152,60 @@ use Icinga\Web\Url; $commentCount ), $commentCount); ?> +

      + + + fetchComments(); ?> + comments as $comment): ?> + + + + + + +
      + populate( + array('comment_id' => $comment->id, 'redirect' => html_entity_decode($this->url)) + ); + $delCommentForm->setAction( + $this->url( + 'monitoring/service/delete-comment', + array('host' => $service->getHost()->getName(), 'service' => $service->getName()) + ) + ); + echo $delCommentForm; + ?> + (type) ?>): + + comment) ?> +
      +

      + +
      qlink( $this->translate('List all'), $commentsLink, null, array('icon' => 'comment') - ); ?>

      + ); ?> +
      - - - fetchComments(); ?> + - comments as $comment): ?> - - - - - - - -
      - populate( - array('comment_id' => $comment->id, 'redirect' => html_entity_decode($this->url)) - ); - $delCommentForm->setAction( - $this->url( - 'monitoring/service/delete-comment', - array('host' => $service->getHost()->getName(), 'service' => $service->getName()) - ) - ); - echo $delCommentForm; - ?> - (type) ?>): - - comment) ?> -
      - - \ No newline at end of file + + + From cb0ca6d6acb20c3c6040c79a148cd80487813dc5 Mon Sep 17 00:00:00 2001 From: Matthias Jentsch Date: Fri, 6 Mar 2015 09:24:11 +0100 Subject: [PATCH 0876/2920] Remove unused piechart code --- .../Backend/LdapUserBackend.php | 1 - .../controllers/HostsController.php | 20 ----------- .../controllers/ServicesController.php | 33 ------------------- .../partials/host/objects-header.phtml | 3 -- .../views/scripts/services/show.phtml | 1 - 5 files changed, 58 deletions(-) diff --git a/library/Icinga/Authentication/Backend/LdapUserBackend.php b/library/Icinga/Authentication/Backend/LdapUserBackend.php index 016512ab4..62834211d 100644 --- a/library/Icinga/Authentication/Backend/LdapUserBackend.php +++ b/library/Icinga/Authentication/Backend/LdapUserBackend.php @@ -240,7 +240,6 @@ class LdapUserBackend extends UserBackend $users[] = $row->{$this->userNameAttribute}; } } - return $users; } } diff --git a/modules/monitoring/application/controllers/HostsController.php b/modules/monitoring/application/controllers/HostsController.php index 1586ad723..19b501a88 100644 --- a/modules/monitoring/application/controllers/HostsController.php +++ b/modules/monitoring/application/controllers/HostsController.php @@ -13,7 +13,6 @@ use Icinga\Module\Monitoring\Forms\Command\Object\ScheduleHostDowntimeCommandFor use Icinga\Module\Monitoring\Object\Host; use Icinga\Module\Monitoring\Object\HostList; use Icinga\Web\Url; -use Icinga\Web\Widget\Chart\InlinePie; class Monitoring_HostsController extends Controller { @@ -58,11 +57,6 @@ class Monitoring_HostsController extends Controller $this->view->form = $form; $this->view->objects = $this->hostList; $this->view->hostStates = $hostStates; - $this->view->hostStatesPieChart = $this->createPieChart( - $hostStates, - $this->translate('Host State'), - array('#44bb77', '#FF5566', '#E066FF', '#77AAFF') - ); $this->_helper->viewRenderer('partials/command/objects-command-form', null, true); return $form; } @@ -153,20 +147,6 @@ class Monitoring_HostsController extends Controller ->setQueryString(Filter::matchAny($downtimeFilterExpressions)->toQueryString()); $this->view->commentsLink = Url::fromRequest() ->setPath('monitoring/list/comments'); - $this->view->hostStatesPieChart = $this->createPieChart( - $hostStates, - $this->translate('Host State'), - array('#44bb77', '#FF5566', '#E066FF', '#77AAFF') - ); - } - - protected function createPieChart(array $states, $title, array $colors) - { - $chart = new InlinePie(array_values($states), $title, $colors); - return $chart - ->setSize(75) - ->setTitle('') - ->setSparklineClass('sparkline-multi'); } /** diff --git a/modules/monitoring/application/controllers/ServicesController.php b/modules/monitoring/application/controllers/ServicesController.php index a20572d0d..1514a0ea0 100644 --- a/modules/monitoring/application/controllers/ServicesController.php +++ b/modules/monitoring/application/controllers/ServicesController.php @@ -16,7 +16,6 @@ use Icinga\Module\Monitoring\Object\Host; use Icinga\Module\Monitoring\Object\Service; use Icinga\Module\Monitoring\Object\ServiceList; use Icinga\Web\Url; -use Icinga\Web\Widget\Chart\InlinePie; class Monitoring_ServicesController extends Controller { @@ -94,16 +93,6 @@ class Monitoring_ServicesController extends Controller $this->view->objects = $this->serviceList; $this->view->serviceStates = $serviceStates; $this->view->hostStates = $hostStates; - $this->view->serviceStatesPieChart = $this->createPieChart( - $serviceStates, - $this->translate('Service State'), - array('#44bb77', '#FFCC66', '#FF5566', '#E066FF', '#77AAFF') - ); - $this->view->hostStatesPieChart = $this->createPieChart( - $hostStates, - $this->translate('Host State'), - array('#44bb77', '#FF5566', '#E066FF', '#77AAFF') - ); $this->_helper->viewRenderer('partials/command/objects-command-form', null, true); return $form; } @@ -234,30 +223,8 @@ class Monitoring_ServicesController extends Controller ->setQueryString(Filter::matchAny($downtimeFilterExpressions)->toQueryString()); $this->view->commentsLink = Url::fromRequest() ->setPath('monitoring/list/comments'); - /* - $this->view->serviceStatesPieChart = $this->createPieChart( - $serviceStates, - $this->translate('Service State'), - array('#44bb77', '#FFCC66', '#FF5566', '#E066FF', '#77AAFF') - ); - $this->view->hostStatesPieChart = $this->createPieChart( - $hostStates, - $this->translate('Host State'), - array('#44bb77', '#FF5566', '#E066FF', '#77AAFF') - ); - */ } - protected function createPieChart(array $states, $title, array $colors) - { - $chart = new InlinePie(array_values($states), $title, $colors); - return $chart - ->setSize(75) - ->setTitle('') - ->setSparklineClass('sparkline-multi'); - } - - /** * Add a service comment */ diff --git a/modules/monitoring/application/views/scripts/partials/host/objects-header.phtml b/modules/monitoring/application/views/scripts/partials/host/objects-header.phtml index 448be4c02..cd79bce5b 100644 --- a/modules/monitoring/application/views/scripts/partials/host/objects-header.phtml +++ b/modules/monitoring/application/views/scripts/partials/host/objects-header.phtml @@ -8,9 +8,6 @@ translatePlural('Host (%u)', 'Hosts (%u)', $hostCount), $hostCount); ?> -
      -   -
      $count): ?> translate(strtoupper($text)), $count); ?>
      diff --git a/modules/monitoring/application/views/scripts/services/show.phtml b/modules/monitoring/application/views/scripts/services/show.phtml index cd941df4d..5cd3af1b6 100644 --- a/modules/monitoring/application/views/scripts/services/show.phtml +++ b/modules/monitoring/application/views/scripts/services/show.phtml @@ -69,7 +69,6 @@ use Icinga\Web\Url; 'Issue commands to the problematic services.'), '' . $unhandledCount . '') ?> -
      qlink( sprintf( From fc403e693b8f43394ca01b56374a5ed99aa15abc Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Fri, 6 Mar 2015 09:46:47 +0100 Subject: [PATCH 0877/2920] Fix array indentation in the ContactQuery refs #8614 --- .../Backend/Ido/Query/ContactQuery.php | 52 +++++++++---------- 1 file changed, 26 insertions(+), 26 deletions(-) diff --git a/modules/monitoring/library/Monitoring/Backend/Ido/Query/ContactQuery.php b/modules/monitoring/library/Monitoring/Backend/Ido/Query/ContactQuery.php index ac549e00a..a55f582ee 100644 --- a/modules/monitoring/library/Monitoring/Backend/Ido/Query/ContactQuery.php +++ b/modules/monitoring/library/Monitoring/Backend/Ido/Query/ContactQuery.php @@ -7,39 +7,39 @@ class ContactQuery extends IdoQuery { protected $columnMap = array( 'contacts' => array( - 'contact_id' => 'c.contact_id', - 'contact_name' => 'co.name1 COLLATE latin1_general_ci', - 'contact_alias' => 'c.alias COLLATE latin1_general_ci', - 'contact_email' => 'c.email_address COLLATE latin1_general_ci', - 'contact_pager' => 'c.pager_address', - 'contact_object_id' => 'c.contact_object_id', - 'contact_has_host_notfications' => 'c.host_notifications_enabled', - 'contact_has_service_notfications' => 'c.service_notifications_enabled', - 'contact_can_submit_commands' => 'c.can_submit_commands', - 'contact_notify_service_recovery' => 'c.notify_service_recovery', - 'contact_notify_service_warning' => 'c.notify_service_warning', - 'contact_notify_service_critical' => 'c.notify_service_critical', - 'contact_notify_service_unknown' => 'c.notify_service_unknown', - 'contact_notify_service_flapping' => 'c.notify_service_flapping', - 'contact_notify_service_downtime' => 'c.notify_service_recovery', - 'contact_notify_host_recovery' => 'c.notify_host_recovery', - 'contact_notify_host_down' => 'c.notify_host_down', - 'contact_notify_host_unreachable' => 'c.notify_host_unreachable', - 'contact_notify_host_flapping' => 'c.notify_host_flapping', - 'contact_notify_host_downtime' => 'c.notify_host_downtime', + 'contact_id' => 'c.contact_id', + 'contact_name' => 'co.name1 COLLATE latin1_general_ci', + 'contact_alias' => 'c.alias COLLATE latin1_general_ci', + 'contact_email' => 'c.email_address COLLATE latin1_general_ci', + 'contact_pager' => 'c.pager_address', + 'contact_object_id' => 'c.contact_object_id', + 'contact_has_host_notfications' => 'c.host_notifications_enabled', + 'contact_has_service_notfications' => 'c.service_notifications_enabled', + 'contact_can_submit_commands' => 'c.can_submit_commands', + 'contact_notify_service_recovery' => 'c.notify_service_recovery', + 'contact_notify_service_warning' => 'c.notify_service_warning', + 'contact_notify_service_critical' => 'c.notify_service_critical', + 'contact_notify_service_unknown' => 'c.notify_service_unknown', + 'contact_notify_service_flapping' => 'c.notify_service_flapping', + 'contact_notify_service_downtime' => 'c.notify_service_recovery', + 'contact_notify_host_recovery' => 'c.notify_host_recovery', + 'contact_notify_host_down' => 'c.notify_host_down', + 'contact_notify_host_unreachable' => 'c.notify_host_unreachable', + 'contact_notify_host_flapping' => 'c.notify_host_flapping', + 'contact_notify_host_downtime' => 'c.notify_host_downtime' ), 'timeperiods' => array( - 'contact_notify_host_timeperiod' => 'ht.alias COLLATE latin1_general_ci', + 'contact_notify_host_timeperiod' => 'ht.alias COLLATE latin1_general_ci', 'contact_notify_service_timeperiod' => 'st.alias COLLATE latin1_general_ci' ), 'hosts' => array( - 'host_name' => 'ho.name1 COLLATE latin1_general_ci', - 'host' => 'ho.name1 COLLATE latin1_general_ci', + 'host' => 'ho.name1 COLLATE latin1_general_ci', + 'host_name' => 'ho.name1 COLLATE latin1_general_ci', ), 'services' => array( - 'service_host_name' => 'so.name1 COLLATE latin1_general_ci', - 'service' => 'so.name1 COLLATE latin1_general_ci', - 'service_description' => 'so.name2 COLLATE latin1_general_ci', + 'service' => 'so.name1 COLLATE latin1_general_ci', + 'service_description' => 'so.name2 COLLATE latin1_general_ci', + 'service_host_name' => 'so.name1 COLLATE latin1_general_ci', ) ); From f4257043050c64c5d28e4286131fd275a75e61ca Mon Sep 17 00:00:00 2001 From: Matthias Jentsch Date: Fri, 6 Mar 2015 09:48:42 +0100 Subject: [PATCH 0878/2920] Fix service tooltip title refs #8565 --- .../views/scripts/partials/service/objects-header.phtml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/monitoring/application/views/scripts/partials/service/objects-header.phtml b/modules/monitoring/application/views/scripts/partials/service/objects-header.phtml index 113e7c0a0..11127ddf3 100644 --- a/modules/monitoring/application/views/scripts/partials/service/objects-header.phtml +++ b/modules/monitoring/application/views/scripts/partials/service/objects-header.phtml @@ -26,7 +26,7 @@ use Icinga\Web\Url; 5) { - $desc = $service->getHost()->getName() . ' on ' . $service->getName(); + $desc = $service->getName() . ' on ' . $service->getHost()->getName(); $hidden[] = $desc; $hiddenRich[] = sprintf("
      %s", $service->getStateText($service->service_state) ,$desc); continue; From 886cc863f00a8b33699b0007ecbb62f7ef93654e Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Fri, 6 Mar 2015 09:49:15 +0100 Subject: [PATCH 0879/2920] Add form element value expectation descriptions where required I did not adjust the DateTimePicker element as the sent format is controlled by the useragent due to either the datetime-local input type or a javascript datetimepicker. (which does not exist yet, though) Mentioning the RFC 3339 format such a picker expects is very likely going to lead to confusion on an end user's side otherwise. refs #7947 --- .../Config/Authentication/ExternalBackendForm.php | 7 ++++--- .../forms/Config/General/LoggingConfigForm.php | 1 + .../forms/Config/Resource/FileResourceForm.php | 12 +++++++++++- 3 files changed, 16 insertions(+), 4 deletions(-) diff --git a/application/forms/Config/Authentication/ExternalBackendForm.php b/application/forms/Config/Authentication/ExternalBackendForm.php index e25661596..86087eb66 100644 --- a/application/forms/Config/Authentication/ExternalBackendForm.php +++ b/application/forms/Config/Authentication/ExternalBackendForm.php @@ -53,7 +53,7 @@ class ExternalBackendForm extends Form return @preg_match($value, '') !== false; }); $callbackValidator->setMessage( - $this->translate('"%value%" is not a valid regular expression'), + $this->translate('"%value%" is not a valid regular expression.'), Zend_Validate_Callback::INVALID_VALUE ); $this->addElement( @@ -62,9 +62,10 @@ class ExternalBackendForm extends Form array( 'label' => $this->translate('Filter Pattern'), 'description' => $this->translate( - 'The regular expression to use to strip specific parts off from usernames.' - . ' Leave empty if you do not want to strip off anything' + 'The filter to use to strip specific parts off from usernames.' + . ' Leave empty if you do not want to strip off anything.' ), + 'requirement' => $this->translate('The filter pattern must be a valid regular expression.'), 'validators' => array($callbackValidator) ) ); diff --git a/application/forms/Config/General/LoggingConfigForm.php b/application/forms/Config/General/LoggingConfigForm.php index 1c4e090c4..bd62f4490 100644 --- a/application/forms/Config/General/LoggingConfigForm.php +++ b/application/forms/Config/General/LoggingConfigForm.php @@ -66,6 +66,7 @@ class LoggingConfigForm extends Form 'description' => $this->translate( 'The name of the application by which to prefix syslog messages.' ), + 'requirement' => $this->translate('The application prefix must not contain whitespace.'), 'value' => 'icingaweb2', 'validators' => array( array( diff --git a/application/forms/Config/Resource/FileResourceForm.php b/application/forms/Config/Resource/FileResourceForm.php index b1bb0c6ae..184a5c18a 100644 --- a/application/forms/Config/Resource/FileResourceForm.php +++ b/application/forms/Config/Resource/FileResourceForm.php @@ -3,6 +3,7 @@ namespace Icinga\Forms\Config\Resource; +use Zend_Validate_Callback; use Icinga\Web\Form; /** @@ -42,13 +43,22 @@ class FileResourceForm extends Form 'validators' => array('ReadablePathValidator') ) ); + $callbackValidator = new Zend_Validate_Callback(function ($value) { + return @preg_match($value, '') !== false; + }); + $callbackValidator->setMessage( + $this->translate('"%value%" is not a valid regular expression.'), + Zend_Validate_Callback::INVALID_VALUE + ); $this->addElement( 'text', 'fields', array( 'required' => true, 'label' => $this->translate('Pattern'), - 'description' => $this->translate('The regular expression by which to identify columns') + 'description' => $this->translate('The pattern by which to identify columns.'), + 'requirement' => $this->translate('The column pattern must be a valid regular expression.'), + 'validators' => array($callbackValidator) ) ); From 2b91ec7f2c90c12ae7b8e5f52c2cca6904694f79 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Fri, 6 Mar 2015 09:54:12 +0100 Subject: [PATCH 0880/2920] Comment out unused query in the ContactgroupQuery refs #8614 --- .../Monitoring/Backend/Ido/Query/ContactgroupQuery.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/modules/monitoring/library/Monitoring/Backend/Ido/Query/ContactgroupQuery.php b/modules/monitoring/library/Monitoring/Backend/Ido/Query/ContactgroupQuery.php index d975da05e..c19670e8d 100644 --- a/modules/monitoring/library/Monitoring/Backend/Ido/Query/ContactgroupQuery.php +++ b/modules/monitoring/library/Monitoring/Backend/Ido/Query/ContactgroupQuery.php @@ -95,10 +95,10 @@ class ContactgroupQuery extends IdoQuery protected function joinServices() { - $scgSub = $this->db->select()->distinct()->from( - $this->prefix . 'service_contactgroups', - array('contactgroup_object_id', 'service_id') - ); +// $scgSub = $this->db->select()->distinct()->from( +// $this->prefix . 'service_contactgroups', +// array('contactgroup_object_id', 'service_id') +// ); /* This subselect is a workaround for a fucking stupid bug. Other tables From 64d1d12c7347a7027f8547079325f9ba107289d8 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Fri, 6 Mar 2015 10:02:20 +0100 Subject: [PATCH 0881/2920] Do not join icinga_hosts when fetching a service's contact groups refs #8614 --- .../library/Monitoring/Object/MonitoredObject.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/modules/monitoring/library/Monitoring/Object/MonitoredObject.php b/modules/monitoring/library/Monitoring/Object/MonitoredObject.php index 4baa7aa9b..bf417c4f4 100644 --- a/modules/monitoring/library/Monitoring/Object/MonitoredObject.php +++ b/modules/monitoring/library/Monitoring/Object/MonitoredObject.php @@ -426,10 +426,12 @@ abstract class MonitoredObject implements Filterable $contactsGroups = $this->backend->select()->from('contactgroup', array( 'contactgroup_name', 'contactgroup_alias' - )) - ->where('host_name', $this->host_name); + )); if ($this->type === self::TYPE_SERVICE) { + $contactsGroups->where('service_host_name', $this->host_name); $contactsGroups->where('service_description', $this->service_description); + } else { + $contactsGroups->where('host_name', $this->host_name); } $this->contactgroups = $contactsGroups->getQuery()->fetchAll(); return $this; From f3fa74302222a142165450a12fd69595960464de Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Fri, 6 Mar 2015 11:03:45 +0100 Subject: [PATCH 0882/2920] Fix login when using a PostgreSQL database as authentication backend fixes #8524 --- library/Icinga/Authentication/Backend/DbUserBackend.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/library/Icinga/Authentication/Backend/DbUserBackend.php b/library/Icinga/Authentication/Backend/DbUserBackend.php index 42322a575..12fa0392f 100644 --- a/library/Icinga/Authentication/Backend/DbUserBackend.php +++ b/library/Icinga/Authentication/Backend/DbUserBackend.php @@ -96,10 +96,15 @@ class DbUserBackend extends UserBackend 'SELECT password_hash FROM icingaweb_user WHERE name = :name AND active = 1' ); } + $stmt->execute(array(':name' => $username)); $stmt->bindColumn(1, $lob, PDO::PARAM_LOB); $stmt->fetch(PDO::FETCH_BOUND); - return is_resource($lob) ? stream_get_contents($lob) : $lob; + if (is_resource($lob)) { + $lob = stream_get_contents($lob); + } + + return $this->conn->getDbType() === 'pgsql' ? pg_unescape_bytea($lob) : $lob; } /** From 71534369efd3b2a1f0794536d597d58494f9c65c Mon Sep 17 00:00:00 2001 From: Matthias Jentsch Date: Fri, 6 Mar 2015 12:31:34 +0100 Subject: [PATCH 0883/2920] Implement new layout for host multi-view refs #8543 --- .../controllers/HostsController.php | 30 +- .../views/scripts/hosts/show.phtml | 256 +++++++++++++----- .../partials/host/objects-header.phtml | 101 ++++++- 3 files changed, 297 insertions(+), 90 deletions(-) diff --git a/modules/monitoring/application/controllers/HostsController.php b/modules/monitoring/application/controllers/HostsController.php index 19b501a88..2c9ebc20e 100644 --- a/modules/monitoring/application/controllers/HostsController.php +++ b/modules/monitoring/application/controllers/HostsController.php @@ -10,6 +10,7 @@ use Icinga\Module\Monitoring\Forms\Command\Object\ProcessCheckResultCommandForm; use Icinga\Module\Monitoring\Forms\Command\Object\RemoveAcknowledgementCommandForm; use Icinga\Module\Monitoring\Forms\Command\Object\ScheduleHostCheckCommandForm; use Icinga\Module\Monitoring\Forms\Command\Object\ScheduleHostDowntimeCommandForm; +use Icinga\Module\Monitoring\Forms\Command\Object\AddCommentCommandForm; use Icinga\Module\Monitoring\Object\Host; use Icinga\Module\Monitoring\Object\HostList; use Icinga\Web\Url; @@ -36,7 +37,12 @@ class Monitoring_HostsController extends Controller 'host_problem', 'host_handled', 'host_acknowledged', - 'host_in_downtime' + 'host_in_downtime', + 'host_last_ack', + 'host_is_flapping', + 'host_last_comment', + 'host_output', + 'host_notifications_enabled' )); $form @@ -87,9 +93,13 @@ class Monitoring_HostsController extends Controller 'host_problem', 'host_handled', 'host_acknowledged', - 'host_in_downtime'/*, + 'host_in_downtime', + 'host_last_ack', + 'host_is_flapping', + 'host_last_comment', + 'host_output', + 'host_notifications_enabled',/*, 'host_passive_checks_enabled', - 'host_notifications_enabled', 'host_event_handler_enabled', 'host_flap_detection_enabled', 'host_active_checks_enabled', @@ -133,6 +143,8 @@ class Monitoring_HostsController extends Controller $this->view->rescheduleAllLink = Url::fromRequest()->setPath('monitoring/hosts/reschedule-check'); $this->view->downtimeAllLink = Url::fromRequest()->setPath('monitoring/hosts/schedule-downtime'); $this->view->processCheckResultAllLink = Url::fromRequest()->setPath('monitoring/hosts/process-check-result'); + $this->view->addCommentLink = Url::fromRequest()->setPath('monitoring/hosts/add-comment'); + $this->view->deleteCommentLink = Url::fromRequest()->setPath('monitoring/hosts/delete-comment'); $this->view->hostStates = $hostStates; $this->view->objects = $this->hostList; $this->view->unhandledObjects = $unhandledObjects; @@ -149,6 +161,18 @@ class Monitoring_HostsController extends Controller ->setPath('monitoring/list/comments'); } + /** + * Add a host comments + */ + public function addCommentAction() + { + $this->assertPermission('monitoring/command/comment/add'); + + $form = new AddCommentCommandForm(); + $form->setTitle($this->translate('Add Host Comments')); + $this->handleCommandForm($form); + } + /** * Acknowledge host problems */ diff --git a/modules/monitoring/application/views/scripts/hosts/show.phtml b/modules/monitoring/application/views/scripts/hosts/show.phtml index 8655a31b1..b6cb454bf 100644 --- a/modules/monitoring/application/views/scripts/hosts/show.phtml +++ b/modules/monitoring/application/views/scripts/hosts/show.phtml @@ -1,116 +1,224 @@ + +
      + + compact): ?> + + + +

      + qlink( + sprintf($this->translate('%d Hosts Selected'), count($objects)), + $listAllLink + ); ?> +

      + render('partials/host/objects-header.phtml'); ?>
      +
      +

      + icon('reschedule') ?> + translate('Commands') ?> +

      + + translate('No hosts matching the filter'); ?> -

      translatePlural('%u Host', '%u Hosts', $hostCount), $hostCount); ?>

      -
      qlink( - sprintf($this->translate('List all %u hosts'), $hostCount), - $listAllLink - ); ?>
      + +

      -
      qlink( - sprintf($this->translate('Reschedule the next check for all %u hosts'), $hostCount), - $rescheduleAllLink, - null, - array('icon' => 'reschedule') - ); ?>
      -
      qlink( - sprintf($this->translate('Schedule a downtime for all %u hosts'), $hostCount), - $downtimeAllLink, - null, - array('icon' => 'plug') - ); ?>
      -
      qlink( - sprintf($this->translate('Submit a passive check result for all %u hosts'), $hostCount), - $processCheckResultAllLink, - null, - array('icon' => 'reply') - ); ?>
      - 0): ?> +
      -

      translatePlural( - '%u Unhandled Host Problem', - '%u Unhandled Host Problems', - $unhandledCount - ), - $unhandledCount - ); ?>

      -
      qlink( - sprintf( - $this->translatePlural( - 'Schedule a downtime for %u unhandled host problem', - 'Schedule a downtime for %u unhandled host problems', - $unhandledCount - ), - $unhandledCount - ), - $downtimeUnhandledLink, + qlink( + $this->translate('Reschedule the next check'), + $rescheduleAllLink, + null, + array('icon' => 'reschedule') + ); ?> +
      + +
      + qlink( + $this->translate('Schedule a downtime'), + $downtimeAllLink, null, array('icon' => 'plug') - ); ?>
      -
      qlink( - sprintf( - $this->translatePlural( - 'Acknowledge %u unhandled host problem', - 'Acknowledge %u unhandled host problems', + ); ?> +
      + +
      + qlink( + $this->translate('Submit a passive check result'), + $processCheckResultAllLink, + null, + array('icon' => 'reply') + ); ?> +
      + +
      + qlink( + $this->translate('Add a comment'), + $addCommentLink, + null, + array('icon' => 'comment') + ); ?> +
      +

      + + 0): ?> +
      +

      + icon('attention-alt') ?> + translatePlural( + 'Unhandled Problem', + 'Unhandled Problems', + $unhandledCount + ) ?> +

      + + +

      + ' . $unhandledCount . '' + ) ?> + +

      qlink( + sprintf( + $this->translatePlural( + 'Schedule a downtime for %u host', + 'Schedule a downtime for %u hosts', + $unhandledCount + ), + $unhandledCount + ), + $downtimeUnhandledLink, + null, + array('icon' => 'plug') + ); ?>
      + + +
      qlink( + sprintf( + $this->translatePlural( + 'Acknowledge %u unhandled host', + 'Acknowledge %u unhandled hosts', + $unhandledCount + ), $unhandledCount ), - $unhandledCount - ), - $acknowledgeUnhandledLink, - null, - array('icon' => 'ok') - ); ?>
      + $acknowledgeUnhandledLink, + null, + array('icon' => 'ok') + ); ?>
      + +

      +
      + 0): ?>
      -

      icon('ok', $this->translate('Acknowledgements')) ?> translate('Acknowledgements') ?>

      + +

      translatePlural( '%u Acknowledged Host Problem', '%u Acknowledged Host Problems', $acknowledgedCount ), $acknowledgedCount - ); ?> + ); ?>

      +
      + 0): ?> -

      qlink( - sprintf( + +

      translate('Downtimes') ?>

      +

      translatePlural( - 'List %u host currently in downtime', - 'List %u hosts currently in downtime', + '%u Host currently in downtime.', + '%u Hosts currently in downtime.', $inDowntimeCount ), $inDowntimeCount - ), - $inDowntimeLink, - null, - array('icon' => 'plug') - ); ?> + ) ?> qlink( + $this->translate('Alle anzeigen'), + $inDowntimeLink, + null + ); ?> + +

      + getComments())) > 0): ?> -

      qlink( - sprintf( +

      translate('Comments') ?>

      +

      + translatePlural( - 'List %u host comment', - 'List %u host comments', + 'There is %u host comment.', + 'There are %u host comments.', $commentCount ), $commentCount - ), - $commentsLink, - null, - array('icon' => 'comment') - ); ?> + ) ?> + + qlink( + $this->translate('List all'), + $commentsLink, + null + ); ?> + +

      + + + + fetchComments(); ?> + comments as $comment): ?> + + + + + + +
      + populate( + array('comment_id' => $comment->id, 'redirect' => html_entity_decode($this->url)) + ); + $delCommentForm->setAction( + $this->url( + 'monitoring/service/delete-comment', + array('host' => $service->getName()) + ) + ); + echo $delCommentForm; + ?> + (type) ?>): + + comment) ?> +
      + + +
      \ No newline at end of file diff --git a/modules/monitoring/application/views/scripts/partials/host/objects-header.phtml b/modules/monitoring/application/views/scripts/partials/host/objects-header.phtml index cd79bce5b..6c910d46a 100644 --- a/modules/monitoring/application/views/scripts/partials/host/objects-header.phtml +++ b/modules/monitoring/application/views/scripts/partials/host/objects-header.phtml @@ -1,16 +1,91 @@ -compact): ?> - - + + + + + 0): ?> -
      -

      - translatePlural('Host (%u)', 'Hosts (%u)', $hostCount), $hostCount); ?> -

      -
      -
      - $count): ?> - translate(strtoupper($text)), $count); ?>
      - -
      + +

      + + + + + + + + + + + + + 5) { + $desc = $host->getName(); + $hidden[] = $desc; + $hiddenRich[] = sprintf("
      %s", $host->getStateText($host->host_state) ,$desc); + continue; + } + ?> + + + + + + + + + + + + + + + + +
      icon('host'); ?> translate('Host'); ?>translate('Output'); ?>
      host_state, true); ?>
      + host_handled && $host->host_state > 0): ?> + icon('attention-alt', $this->translate('Unhandled')) ?> + + + host_acknowledged && !$host->host_in_downtime): ?> + icon('ok', $this->translate('Acknowledged') . ( + $host->host_last_ack ? ': ' . $host->host_last_ack : '' + )) ?> + + + host_is_flapping): ?> + icon('flapping', $this->translate('Flapping')) ?> + + + host_notifications_enabled): ?> + icon('bell-off-empty', $this->translate('Notifications Disabled')) ?> + + + host_in_downtime): ?> + icon('plug', $this->translate('In Downtime')) ?> + + + host_last_comment) && $host->host_last_comment !== null): ?> + icon('comment', $this->translate('Last Comment: ') . $host->host_last_comment) ?> + + escape($host->getName()); ?>

      escape($host->host_output) ?>

      +
      + +
      +
      +

      + + + + + From 9fc80ec34fb9a4d57ef4d390375e2a82f89d7d0d Mon Sep 17 00:00:00 2001 From: Matthias Jentsch Date: Fri, 6 Mar 2015 12:45:29 +0100 Subject: [PATCH 0884/2920] Use more readable coding style in service multi-view refs #8565 --- .../views/scripts/services/show.phtml | 218 +++++++++--------- 1 file changed, 109 insertions(+), 109 deletions(-) diff --git a/modules/monitoring/application/views/scripts/services/show.phtml b/modules/monitoring/application/views/scripts/services/show.phtml index 5cd3af1b6..d9aed1581 100644 --- a/modules/monitoring/application/views/scripts/services/show.phtml +++ b/modules/monitoring/application/views/scripts/services/show.phtml @@ -20,124 +20,130 @@ use Icinga\Web\Url; - translate('No services matching the filter'); ?> + translate('No services matching the filter'); ?> - + -

      +

      -
      qlink( + +
      + qlink( $this->translate('Reschedule the next check'), $rescheduleAllLink, null, array('icon' => 'reschedule') - ); ?>
      -
      qlink( + ); ?> +
      + +
      + qlink( $this->translate('Schedule a downtime'), $downtimeAllLink, null, array('icon' => 'plug') - ); ?>
      -
      qlink( + ); ?> +
      + +
      + qlink( $this->translate('Submit a passive check result'), $processCheckResultAllLink, null, array('icon' => 'reply') - ); ?>
      -
      qlink( + ); ?> +
      + +
      + qlink( $this->translate('Add a comment'), $addCommentLink, null, array('icon' => 'comment') - ); ?>
      -

      - - 0): ?> -
      -

      - icon('attention-alt') ?> - translatePlural( - 'Unhandled Problem', - 'Unhandled Problems', - $unhandledCount - ) ?> -

      - -

      ' . $unhandledCount . '') ?> - -

      - qlink( - sprintf( - $this->translatePlural( - 'Schedule a downtime for %u unhandled service problem', - 'Schedule a downtime for %u unhandled service problems', - $unhandledCount - ), - $unhandledCount - ), - $downtimeUnhandledLink, - null, - array('icon' => 'plug') ); ?> -
      - -
      qlink( - sprintf( - $this->translatePlural( - 'Acknowledge %u unhandled service problem', - 'Acknowledge %u unhandled service problems', - $unhandledCount - ), - $unhandledCount - ), - $acknowledgeUnhandledLink, - null, - array('icon' => 'ok') - ); ?>
      +

      - -
      - - - 0): ?> - -

      icon('ok', $this->translate('Acknowledgements')) ?> translate('Acknowledgements') ?>

      -

      - translatePlural( - '%u Acknowledged Service Problem', - '%u Acknowledged Service Problems', - $acknowledgedCount - ), - $acknowledgedCount - ); ?> -

      - - - - 0): ?> - -

      icon('plug', $this->translate('Downtimes')) ?> translate('Downtimes') ?>

      -

      translatePlural( - '%u service currently in downtime', - '%u services currently in downtime', - $inDowntimeCount - ), $inDowntimeCount) ?> - + 0): ?>

      - qlink( - $this->translate('List all'), - $inDowntimeLink, - null, - array('icon' => 'plug') - );?> +

      + icon('attention-alt') ?> + translatePlural( + 'Unhandled Problem', + 'Unhandled Problems', + $unhandledCount + ) ?> +

      + +

      ' . $unhandledCount . '') ?> + +

      + qlink( + sprintf( + $this->translatePlural( + 'Schedule a downtime for %u unhandled service problem', + 'Schedule a downtime for %u unhandled service problems', + $unhandledCount + ), + $unhandledCount + ), + $downtimeUnhandledLink, + null, + array('icon' => 'plug') + ); ?> +
      + +
      qlink( + sprintf( + $this->translatePlural( + 'Acknowledge %u unhandled service problem', + 'Acknowledge %u unhandled service problems', + $unhandledCount + ), + $unhandledCount + ), + $acknowledgeUnhandledLink, + null, + array('icon' => 'ok') + ); ?>
      +

      +
      -

      + + + 0): ?> +

      icon('ok', $this->translate('Acknowledgements')) ?> translate('Acknowledgements') ?>

      +

      + translatePlural( + '%u Acknowledged Service Problem.', + '%u Acknowledged Service Problems.', + $acknowledgedCount + ), + $acknowledgedCount + ); ?> +

      + + + + 0 /*&& $auth->hasPermission('monitoring/command/comment/delete')*/): ?> +

      icon('plug', $this->translate('Downtimes')) ?> translate('Downtimes') ?>

      +

      translatePlural( + '%u service currently in downtime.', + '%u services currently in downtime.', + $inDowntimeCount + ), $inDowntimeCount) ?> + + qlink( + $this->translate('List all'), + $inDowntimeLink, + null + );?> +

      @@ -146,12 +152,18 @@ use Icinga\Web\Url;

      icon('comment') ?>

      translatePlural( - 'There are no comments.', - 'There are %d comments', + 'There is %d comment.', + 'There are %d comments.', $commentCount ), $commentCount); ?> + qlink( + $this->translate('List all'), + $commentsLink, + null + ); ?>

      + fetchComments(); ?> @@ -180,20 +192,9 @@ use Icinga\Web\Url;
      + + - + --> From 0623404963818b033d857a655de59bbb45b5567c Mon Sep 17 00:00:00 2001 From: Matthias Jentsch Date: Fri, 6 Mar 2015 12:46:49 +0100 Subject: [PATCH 0885/2920] Add missing layout color for "down" badge refs #8565 --- public/css/icinga/monitoring-colors.less | 2 +- public/css/icinga/widgets.less | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/public/css/icinga/monitoring-colors.less b/public/css/icinga/monitoring-colors.less index 62d5a68cd..609b3451c 100644 --- a/public/css/icinga/monitoring-colors.less +++ b/public/css/icinga/monitoring-colors.less @@ -951,7 +951,7 @@ table.statesummary { } td.state { - min-width: 70px; + min-width: 75px; font-size: 0.7em; text-align: center; } diff --git a/public/css/icinga/widgets.less b/public/css/icinga/widgets.less index de33d6685..b6a41c234 100644 --- a/public/css/icinga/widgets.less +++ b/public/css/icinga/widgets.less @@ -260,6 +260,10 @@ li li .badge { background-color: @colorCritical; } +.badge-down { + background-color: @colorCritical; +} + .badge-warning { background-color: @colorWarning; } From a077472226fe5a2c6472ac70243ebb76b0afd19d Mon Sep 17 00:00:00 2001 From: Matthias Jentsch Date: Fri, 6 Mar 2015 12:53:58 +0100 Subject: [PATCH 0886/2920] Make tabs available in all host controller actions refs #8565 --- .../controllers/HostsController.php | 24 +++++++++---------- .../views/scripts/services/show.phtml | 1 - 2 files changed, 12 insertions(+), 13 deletions(-) diff --git a/modules/monitoring/application/controllers/HostsController.php b/modules/monitoring/application/controllers/HostsController.php index 2c9ebc20e..aa119c161 100644 --- a/modules/monitoring/application/controllers/HostsController.php +++ b/modules/monitoring/application/controllers/HostsController.php @@ -27,6 +27,18 @@ class Monitoring_HostsController extends Controller $hostList = new HostList($this->backend); $hostList->setFilter(Filter::fromQueryString((string) $this->params)); $this->hostList = $hostList; + $this->getTabs()->add( + 'show', + array( + 'title' => sprintf( + $this->translate('Show summarized information for %u hosts'), + count($this->hostList) + ), + 'label' => $this->translate('Hosts'), + 'url' => Url::fromRequest(), + 'icon' => 'host' + ) + )->activate('show'); } protected function handleCommandForm(ObjectsCommandForm $form) @@ -69,18 +81,6 @@ class Monitoring_HostsController extends Controller public function showAction() { - $this->getTabs()->add( - 'show', - array( - 'title' => sprintf( - $this->translate('Show summarized information for %u hosts'), - count($this->hostList) - ), - 'label' => $this->translate('Hosts'), - 'url' => Url::fromRequest(), - 'icon' => 'host' - ) - )->activate('show'); $this->setAutorefreshInterval(15); $checkNowForm = new CheckNowCommandForm(); $checkNowForm diff --git a/modules/monitoring/application/views/scripts/services/show.phtml b/modules/monitoring/application/views/scripts/services/show.phtml index d9aed1581..2933e6623 100644 --- a/modules/monitoring/application/views/scripts/services/show.phtml +++ b/modules/monitoring/application/views/scripts/services/show.phtml @@ -1,6 +1,5 @@

      From 6d436737540132b34099f2c5b2c7402aa14614b5 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Fri, 6 Mar 2015 13:13:02 +0100 Subject: [PATCH 0887/2920] Do not always join host and service status in the DowntimeQuery Now the hoststatus and servicestatus tables are only joined if necessary. refs #8614 --- .../Backend/Ido/Query/DowntimeQuery.php | 44 +++++++++++++------ 1 file changed, 30 insertions(+), 14 deletions(-) diff --git a/modules/monitoring/library/Monitoring/Backend/Ido/Query/DowntimeQuery.php b/modules/monitoring/library/Monitoring/Backend/Ido/Query/DowntimeQuery.php index 96b0dd5d7..db4305c0d 100644 --- a/modules/monitoring/library/Monitoring/Backend/Ido/Query/DowntimeQuery.php +++ b/modules/monitoring/library/Monitoring/Backend/Ido/Query/DowntimeQuery.php @@ -21,19 +21,26 @@ class DowntimeQuery extends IdoQuery 'downtime_duration' => 'sd.duration', 'downtime_is_in_effect' => 'sd.is_in_effect', 'downtime_internal_id' => 'sd.internal_downtime_id', + 'downtime_objecttype' => "CASE WHEN ho.object_id IS NULL THEN 'service' ELSE 'host' END", 'downtime_host' => 'CASE WHEN ho.name1 IS NULL THEN so.name1 ELSE ho.name1 END COLLATE latin1_general_ci', // #7278, #7279 'host' => 'CASE WHEN ho.name1 IS NULL THEN so.name1 ELSE ho.name1 END COLLATE latin1_general_ci', + 'host_name' => 'CASE WHEN ho.name1 IS NULL THEN so.name1 ELSE ho.name1 END', 'downtime_service' => 'so.name2 COLLATE latin1_general_ci', 'service' => 'so.name2 COLLATE latin1_general_ci', // #7278, #7279 - 'downtime_objecttype' => "CASE WHEN ho.object_id IS NOT NULL THEN 'host' ELSE CASE WHEN so.object_id IS NOT NULL THEN 'service' ELSE NULL END END", - 'downtime_host_state' => 'CASE WHEN hs.has_been_checked = 0 OR hs.has_been_checked IS NULL THEN 99 ELSE hs.current_state END', - 'downtime_service_state' => 'CASE WHEN ss.has_been_checked = 0 OR ss.has_been_checked IS NULL THEN 99 ELSE ss.current_state END' + 'service_description' => 'so.name2', + 'service_host_name' => 'so.name1' ), 'hosts' => array( - 'host_display_name' => 'CASE WHEN sh.display_name IS NOT NULL THEN sh.display_name ELSE h.display_name END' + 'host_display_name' => 'CASE WHEN h.display_name IS NULL THEN sh.display_name ELSE h.display_name END' + ), + 'hoststatus' => array( + 'downtime_host_state' => 'CASE WHEN hs.has_been_checked = 0 OR hs.has_been_checked IS NULL THEN 99 ELSE hs.current_state END' ), 'services' => array( 'service_display_name' => 's.display_name' + ), + 'servicestatus' => array( + 'downtime_service_state' => 'CASE WHEN ss.has_been_checked = 0 OR ss.has_been_checked IS NULL THEN 99 ELSE ss.current_state END' ) ); @@ -53,16 +60,6 @@ class DowntimeQuery extends IdoQuery 'sd.object_id = so.object_id AND so.is_active = 1 AND so.objecttype_id = 2', array() ); - $this->select->joinLeft( - array('hs' => $this->prefix . 'hoststatus'), - 'ho.object_id = hs.host_object_id', - array() - ); - $this->select->joinLeft( - array('ss' => $this->prefix . 'servicestatus'), - 'so.object_id = ss.service_object_id', - array() - ); $this->joinedVirtualTables = array('downtime' => true); } @@ -76,6 +73,15 @@ class DowntimeQuery extends IdoQuery return $this; } + protected function joinHoststatus() + { + $this->select->joinLeft( + array('hs' => $this->prefix . 'hoststatus'), + 'ho.object_id = hs.host_object_id', + array() + ); + } + protected function joinServices() { $this->select->joinLeft( @@ -90,4 +96,14 @@ class DowntimeQuery extends IdoQuery ); return $this; } + + protected function joinServicestatus() + { + $this->select->joinLeft( + array('ss' => $this->prefix . 'servicestatus'), + 'so.object_id = ss.service_object_id', + array() + ); + return $this; + } } From db99c323cc85357efa3bcaabe7ad34a99f20bde1 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Fri, 6 Mar 2015 13:13:48 +0100 Subject: [PATCH 0888/2920] Add host and service name columns to the Downtime data view refs #8614 --- modules/monitoring/library/Monitoring/DataView/Downtime.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/modules/monitoring/library/Monitoring/DataView/Downtime.php b/modules/monitoring/library/Monitoring/DataView/Downtime.php index 54a47e6b4..07123dd4f 100644 --- a/modules/monitoring/library/Monitoring/DataView/Downtime.php +++ b/modules/monitoring/library/Monitoring/DataView/Downtime.php @@ -33,7 +33,10 @@ class Downtime extends DataView 'downtime_host_state', 'downtime_service_state', 'host_display_name', - 'service_display_name' + 'service_display_name', + 'host_name', + 'service_host_name', + 'service_description' ); } From 7317aa7158198716399a2cd923278b73d0fd63fe Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Fri, 6 Mar 2015 13:14:20 +0100 Subject: [PATCH 0889/2920] Do not join hosts when fetching a service's downtimes refs #8614 --- .../library/Monitoring/Object/MonitoredObject.php | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/modules/monitoring/library/Monitoring/Object/MonitoredObject.php b/modules/monitoring/library/Monitoring/Object/MonitoredObject.php index bf417c4f4..0f382f214 100644 --- a/modules/monitoring/library/Monitoring/Object/MonitoredObject.php +++ b/modules/monitoring/library/Monitoring/Object/MonitoredObject.php @@ -281,16 +281,18 @@ abstract class MonitoredObject implements Filterable 'is_flexible' => 'downtime_is_flexible', 'is_fixed' => 'downtime_is_fixed', 'is_in_effect' => 'downtime_is_in_effect', - 'entry_time' => 'downtime_entry_time', - 'host' => 'downtime_host', - 'service' => 'downtime_service' + 'entry_time' => 'downtime_entry_time' )) ->where('downtime_objecttype', $this->type) - ->where('downtime_host', $this->host_name) ->order('downtime_is_in_effect', 'DESC') ->order('downtime_scheduled_start', 'ASC'); if ($this->type === self::TYPE_SERVICE) { - $downtimes->where('downtime_service', $this->service_description); + $downtimes + ->where('service_host_name', $this->host_name) + ->where('service_description', $this->service_description); + } else { + $downtimes + ->where('host_name', $this->host_name); } $this->downtimes = $downtimes->getQuery()->fetchAll(); return $this; From cbf39a2d99bb3b55d3757267c1c2b41816aca72c Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Fri, 6 Mar 2015 13:14:56 +0100 Subject: [PATCH 0890/2920] Use host_name and service_description columns in the downtime overview refs #8614 --- modules/monitoring/application/controllers/ListController.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/monitoring/application/controllers/ListController.php b/modules/monitoring/application/controllers/ListController.php index b1b96b477..6ac7e16ed 100644 --- a/modules/monitoring/application/controllers/ListController.php +++ b/modules/monitoring/application/controllers/ListController.php @@ -282,8 +282,8 @@ class Monitoring_ListController extends Controller 'is_fixed' => 'downtime_is_fixed', 'is_in_effect' => 'downtime_is_in_effect', 'entry_time' => 'downtime_entry_time', - 'host' => 'downtime_host', - 'service' => 'downtime_service', + 'host' => 'host_name', + 'service' => 'service_description', 'host_state' => 'downtime_host_state', 'service_state' => 'downtime_service_state', 'host_display_name', From 4324385010e1d58dd6fc0182cc9e527f8e7f3138 Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Fri, 6 Mar 2015 13:22:51 +0100 Subject: [PATCH 0891/2920] Do not load a module twice while enabling it --- application/controllers/ConfigController.php | 1 - 1 file changed, 1 deletion(-) diff --git a/application/controllers/ConfigController.php b/application/controllers/ConfigController.php index 5ad822e12..33e845f8c 100644 --- a/application/controllers/ConfigController.php +++ b/application/controllers/ConfigController.php @@ -163,7 +163,6 @@ class ConfigController extends ActionController $manager = Icinga::app()->getModuleManager(); try { $manager->enableModule($module); - $manager->loadModule($module); Notification::success(sprintf($this->translate('Module "%s" enabled'), $module)); $this->rerenderLayout()->reloadCss()->redirectNow('config/modules'); } catch (Exception $e) { From d7dcbb48a2a9f2d4cb0536fd0040ef7268982008 Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Fri, 6 Mar 2015 13:23:22 +0100 Subject: [PATCH 0892/2920] Do not try to access a module's title if there is none --- application/views/scripts/config/module.phtml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/application/views/scripts/config/module.phtml b/application/views/scripts/config/module.phtml index 28fbeb39e..9130bcc90 100644 --- a/application/views/scripts/config/module.phtml +++ b/application/views/scripts/config/module.phtml @@ -2,9 +2,6 @@ tabs ?>
      -

      - escape($module->getTitle()) ?> -

      translate('There is no such module installed.') ?> @@ -14,6 +11,9 @@ $permissions = $module->getProvidedPermissions(); $state = $moduleData->enabled ? ($moduleData->loaded ? 'enabled' : 'failed') : 'disabled' ?> +

      + escape($module->getTitle()) ?> +

      From f45f00b022a611c94365fbd0dfe6fdac58377ac5 Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Fri, 6 Mar 2015 13:25:04 +0100 Subject: [PATCH 0893/2920] Run a module's configuration script only in case it has been registered fixes #8601 --- application/controllers/ConfigController.php | 19 +++++++------- library/Icinga/Application/Modules/Module.php | 25 ++++++++++++++++++- 2 files changed, 34 insertions(+), 10 deletions(-) diff --git a/application/controllers/ConfigController.php b/application/controllers/ConfigController.php index 33e845f8c..f7543cc03 100644 --- a/application/controllers/ConfigController.php +++ b/application/controllers/ConfigController.php @@ -135,22 +135,23 @@ class ConfigController extends ActionController public function moduleAction() { - $name = $this->getParam('name'); $app = Icinga::app(); $manager = $app->getModuleManager(); + $name = $this->getParam('name'); if ($manager->hasInstalled($name)) { - $this->view->moduleData = Icinga::app() - ->getModuleManager() - ->select() - ->from('modules') - ->where('name', $name) - ->fetchRow(); - $module = new Module($app, $name, $manager->getModuleDir($name)); + $this->view->moduleData = $manager->select()->from('modules')->where('name', $name)->fetchRow(); + if ($manager->hasLoaded($name)) { + $module = $manager->getModule($name); + } else { + $module = new Module($app, $name, $manager->getModuleDir($name)); + } + $this->view->module = $module; + $this->view->tabs = $module->getConfigTabs()->activate('info'); } else { $this->view->module = false; + $this->view->tabs = null; } - $this->view->tabs = $module->getConfigTabs()->activate('info'); } /** diff --git a/library/Icinga/Application/Modules/Module.php b/library/Icinga/Application/Modules/Module.php index b59154020..8c0bc2266 100644 --- a/library/Icinga/Application/Modules/Module.php +++ b/library/Icinga/Application/Modules/Module.php @@ -113,6 +113,13 @@ class Module */ private $triedToLaunchConfigScript = false; + /** + * Whether this module has been registered + * + * @var bool + */ + private $registered = false; + /** * Provided permissions * @@ -279,6 +286,10 @@ class Module */ public function register() { + if ($this->registered) { + return true; + } + $this->registerAutoloader(); try { $this->launchRunScript(); @@ -291,10 +302,22 @@ class Module ); return false; } + $this->registerWebIntegration(); + $this->registered = true; return true; } + /** + * Return whether this module has been registered + * + * @return bool + */ + public function isRegistered() + { + return $this->registered; + } + /** * Test for an enabled module by name * @@ -913,7 +936,7 @@ class Module */ protected function launchConfigScript() { - if ($this->triedToLaunchConfigScript) { + if ($this->triedToLaunchConfigScript || !$this->registered) { return; } $this->triedToLaunchConfigScript = true; From f91ce0cfa1af1e7d5525c34938ae8777764b006f Mon Sep 17 00:00:00 2001 From: Matthias Jentsch Date: Fri, 6 Mar 2015 13:27:48 +0100 Subject: [PATCH 0894/2920] Fix delete comment command in host multi-view refs #8565 --- .../application/controllers/HostsController.php | 12 ++++++++++++ .../application/views/scripts/hosts/show.phtml | 6 +++--- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/modules/monitoring/application/controllers/HostsController.php b/modules/monitoring/application/controllers/HostsController.php index aa119c161..eaa3d03a4 100644 --- a/modules/monitoring/application/controllers/HostsController.php +++ b/modules/monitoring/application/controllers/HostsController.php @@ -173,6 +173,18 @@ class Monitoring_HostsController extends Controller $this->handleCommandForm($form); } + /** + * Delete a comment + */ + public function deleteCommentAction() + { + $this->assertPermission('monitoring/command/comment/delete'); + + $form = new DeleteCommentCommandForm(); + $form->setTitle($this->translate('Delete Host Comments')); + $this->handleCommandForm($form); + } + /** * Acknowledge host problems */ diff --git a/modules/monitoring/application/views/scripts/hosts/show.phtml b/modules/monitoring/application/views/scripts/hosts/show.phtml index b6cb454bf..ffba365b1 100644 --- a/modules/monitoring/application/views/scripts/hosts/show.phtml +++ b/modules/monitoring/application/views/scripts/hosts/show.phtml @@ -14,8 +14,8 @@ use Icinga\Module\Monitoring\Forms\Command\Object\DeleteCommentCommandForm; $listAllLink ); ?> - render('partials/host/objects-header.phtml'); ?> +
      @@ -23,7 +23,7 @@ use Icinga\Module\Monitoring\Forms\Command\Object\DeleteCommentCommandForm; icon('reschedule') ?> translate('Commands') ?> - + translate('No hosts matching the filter'); ?> @@ -192,7 +192,7 @@ use Icinga\Module\Monitoring\Forms\Command\Object\DeleteCommentCommandForm; ); $delCommentForm->setAction( $this->url( - 'monitoring/service/delete-comment', + 'monitoring/host/delete-comment', array('host' => $service->getName()) ) ); From c0deeefe00b71ac6f4e51c507c7fdc89ad1226bd Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Fri, 6 Mar 2015 13:44:14 +0100 Subject: [PATCH 0895/2920] Re-add dashboard link to the upper left logo fixes #8592 --- application/layouts/scripts/body.phtml | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/application/layouts/scripts/body.phtml b/application/layouts/scripts/body.phtml index 03c0f5905..78bb4f91d 100644 --- a/application/layouts/scripts/body.phtml +++ b/application/layouts/scripts/body.phtml @@ -29,7 +29,16 @@ if ($notifications->hasMessages()) { } ?>
      From 4724eb907fc53d072c8675e33443eb3c56899df4 Mon Sep 17 00:00:00 2001 From: Matthias Jentsch Date: Fri, 6 Mar 2015 14:49:33 +0100 Subject: [PATCH 0896/2920] Fix site layout of multi-views Fix responsiveness and add icons for plugin output section. refs 8565 --- .../views/scripts/hosts/show.phtml | 2 +- .../partials/host/objects-header.phtml | 8 +++---- .../partials/service/objects-header.phtml | 17 +++++++------ .../views/scripts/services/show.phtml | 2 +- public/css/icinga/layout-structure.less | 4 ++++ public/css/icinga/monitoring-colors.less | 24 +++++++------------ public/css/icinga/widgets.less | 5 ++++ 7 files changed, 32 insertions(+), 30 deletions(-) diff --git a/modules/monitoring/application/views/scripts/hosts/show.phtml b/modules/monitoring/application/views/scripts/hosts/show.phtml index ffba365b1..20338b08e 100644 --- a/modules/monitoring/application/views/scripts/hosts/show.phtml +++ b/modules/monitoring/application/views/scripts/hosts/show.phtml @@ -18,7 +18,7 @@ use Icinga\Module\Monitoring\Forms\Command\Object\DeleteCommentCommandForm; -
      +

      icon('reschedule') ?> translate('Commands') ?> diff --git a/modules/monitoring/application/views/scripts/partials/host/objects-header.phtml b/modules/monitoring/application/views/scripts/partials/host/objects-header.phtml index 6c910d46a..39445e277 100644 --- a/modules/monitoring/application/views/scripts/partials/host/objects-header.phtml +++ b/modules/monitoring/application/views/scripts/partials/host/objects-header.phtml @@ -18,8 +18,8 @@ $hiddenRich = array();

      - - + + @@ -64,8 +64,8 @@ $hiddenRich = array(); icon('comment', $this->translate('Last Comment: ') . $host->host_last_comment) ?> - - + + diff --git a/modules/monitoring/application/views/scripts/partials/service/objects-header.phtml b/modules/monitoring/application/views/scripts/partials/service/objects-header.phtml index 11127ddf3..fe23cde2c 100644 --- a/modules/monitoring/application/views/scripts/partials/service/objects-header.phtml +++ b/modules/monitoring/application/views/scripts/partials/service/objects-header.phtml @@ -15,12 +15,11 @@ use Icinga\Web\Url; - - - + + + - icon('comment', $this->translate('Last Comment: ') . $service->service_last_comment) ?> - - - + + + - diff --git a/modules/monitoring/application/views/scripts/partials/service/objects-header.phtml b/modules/monitoring/application/views/scripts/partials/service/objects-header.phtml index fe23cde2c..4501f0e7e 100644 --- a/modules/monitoring/application/views/scripts/partials/service/objects-header.phtml +++ b/modules/monitoring/application/views/scripts/partials/service/objects-header.phtml @@ -34,7 +34,9 @@ use Icinga\Web\Url; + @@ -72,7 +75,7 @@ use Icinga\Web\Url; diff --git a/modules/monitoring/application/views/scripts/services/show.phtml b/modules/monitoring/application/views/scripts/services/show.phtml index d35125254..08e1737f3 100644 --- a/modules/monitoring/application/views/scripts/services/show.phtml +++ b/modules/monitoring/application/views/scripts/services/show.phtml @@ -21,7 +21,7 @@ use Icinga\Module\Monitoring\Forms\Command\Object\DeleteCommentCommandForm; translate('No services matching the filter'); ?> - + translate('Issue commands to all %d selected services:'), count($objects)) ?>

      @@ -30,7 +30,7 @@ use Icinga\Module\Monitoring\Forms\Command\Object\DeleteCommentCommandForm;
      qlink( - $this->translate('Reschedule the next check'), + $this->translate('Reschedule next checks'), $rescheduleAllLink, null, array('icon' => 'reschedule') @@ -39,7 +39,7 @@ use Icinga\Module\Monitoring\Forms\Command\Object\DeleteCommentCommandForm;
      qlink( - $this->translate('Schedule a downtime'), + $this->translate('Schedule downtimes'), $downtimeAllLink, null, array('icon' => 'plug') @@ -48,7 +48,7 @@ use Icinga\Module\Monitoring\Forms\Command\Object\DeleteCommentCommandForm;
      qlink( - $this->translate('Submit a passive check result'), + $this->translate('Submit passive check results'), $processCheckResultAllLink, null, array('icon' => 'reply') @@ -57,7 +57,7 @@ use Icinga\Module\Monitoring\Forms\Command\Object\DeleteCommentCommandForm;
      qlink( - $this->translate('Add a comment'), + $this->translate('Add comments'), $addCommentLink, null, array('icon' => 'comment') @@ -76,7 +76,7 @@ use Icinga\Module\Monitoring\Forms\Command\Object\DeleteCommentCommandForm; ) ?> -

      translate('There are %s unhandled problems. ' . 'Issue commands to the problematic services:'), '' . $unhandledCount . '') ?> @@ -149,7 +149,7 @@ use Icinga\Module\Monitoring\Forms\Command\Object\DeleteCommentCommandForm; getComments()) ?> 0): ?> -

      icon('comment') ?>

      +

      icon('comment') ?> translate('Comments') ?>

      translatePlural( 'There is %d comment.', From cddcde9494f548d0b1f193017f91e1e657ef1507 Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Fri, 6 Mar 2015 15:41:25 +0100 Subject: [PATCH 0900/2920] Setup: Automatically check the respective admin account type selection resolves #8603 --- .../views/scripts/form/setup-admin-account.phtml | 12 ++++++------ public/js/icinga/events.js | 15 +++++++++++++++ 2 files changed, 21 insertions(+), 6 deletions(-) diff --git a/modules/setup/application/views/scripts/form/setup-admin-account.phtml b/modules/setup/application/views/scripts/form/setup-admin-account.phtml index 55767e96f..77220017c 100644 --- a/modules/setup/application/views/scripts/form/setup-admin-account.phtml +++ b/modules/setup/application/views/scripts/form/setup-admin-account.phtml @@ -20,12 +20,12 @@ $showRadioBoxes = strpos(strtolower(get_class($radioElem)), 'radio') !== false; getElement('by_name')) !== null): ?>

      - + setAttrib('data-related-radiobtn', 'by_name') : $byNameElem; ?>
      @@ -35,12 +35,12 @@ $showRadioBoxes = strpos(strtolower(get_class($radioElem)), 'radio') !== false; getElement('existing_user')) !== null): ?>
      - + setAttrib('data-related-radiobtn', 'existing_user') : $existingUserElem; ?>
      @@ -50,14 +50,14 @@ $showRadioBoxes = strpos(strtolower(get_class($radioElem)), 'radio') !== false; getElement('new_user')) !== null): ?>
      - + setAttrib('data-related-radiobtn', 'new_user') : $newUserElem; ?> getElement('new_user_password'); ?> getElement('new_user_2ndpass'); ?>
      diff --git a/public/js/icinga/events.js b/public/js/icinga/events.js index e4c1e54a0..c7674a63d 100644 --- a/public/js/icinga/events.js +++ b/public/js/icinga/events.js @@ -125,6 +125,10 @@ $(document).on('change', 'form select.autosubmit', { self: this }, this.autoSubmitForm); $(document).on('change', 'form input.autosubmit', { self: this }, this.autoSubmitForm); + // Automatically check a radio button once a specific input is focused + $(document).on('focus', 'form select[data-related-radiobtn]', { self: this }, this.autoCheckRadioButton); + $(document).on('focus', 'form input[data-related-radiobtn]', { self: this }, this.autoCheckRadioButton); + $(document).on('keyup', '#menu input.search', {self: this}, this.autoSubmitSearch); $(document).on('click', '.tree .handle', { self: this }, this.treeNodeToggle); @@ -163,6 +167,15 @@ icinga.ui.fixControls(); }, + autoCheckRadioButton: function (event) { + var $input = $(event.currentTarget); + var $radio = $('#' + $input.attr('data-related-radiobtn')); + if ($radio.length) { + $radio.prop('checked', true); + } + return true; + }, + autoSubmitSearch: function(event) { var self = event.data.self; if ($('#menu input.search').val() === self.searchValue) { @@ -560,6 +573,8 @@ $(document).off('submit', 'form', this.submitForm); $(document).off('change', 'form select.autosubmit', this.submitForm); $(document).off('change', 'form input.autosubmit', this.submitForm); + $(document).off('focus', 'form select[data-related-radiobtn]', this.autoCheckRadioButton); + $(document).off('focus', 'form input[data-related-radiobtn]', this.autoCheckRadioButton); }, destroy: function() { From 9c45e99b5731b7b8336f066ce6e0f2b3c64ad4f4 Mon Sep 17 00:00:00 2001 From: Matthias Jentsch Date: Fri, 6 Mar 2015 16:13:00 +0100 Subject: [PATCH 0901/2920] Add tiny statesummary to service multi-view refs #8565 --- .../controllers/HostsController.php | 19 +++++--- .../views/scripts/hosts/show.phtml | 7 +-- .../partials/host/objects-header.phtml | 6 +-- .../partials/host/objects-tinysummary.phtml | 44 +++++++++++++++++++ .../partials/service/objects-header.phtml | 1 - modules/monitoring/public/css/module.less | 12 +++++ 6 files changed, 71 insertions(+), 18 deletions(-) create mode 100644 modules/monitoring/application/views/scripts/partials/host/objects-tinysummary.phtml diff --git a/modules/monitoring/application/controllers/HostsController.php b/modules/monitoring/application/controllers/HostsController.php index eaa3d03a4..ec4e470a2 100644 --- a/modules/monitoring/application/controllers/HostsController.php +++ b/modules/monitoring/application/controllers/HostsController.php @@ -111,14 +111,19 @@ class Monitoring_HostsController extends Controller $objectsInDowntime = array(); $downtimeFilterExpressions = array(); $hostStates = array( - Host::getStateText(Host::STATE_UP) => 0, - Host::getStateText(Host::STATE_DOWN) => 0, - Host::getStateText(Host::STATE_UNREACHABLE) => 0, - Host::getStateText(Host::STATE_PENDING) => 0, + 'hosts_' . Host::getStateText(Host::STATE_UP) => 0, + 'hosts_' . Host::getStateText(Host::STATE_UP) . '_unhandled' => 0, + 'hosts_' . Host::getStateText(Host::STATE_DOWN) => 0, + 'hosts_' . Host::getStateText(Host::STATE_DOWN) . '_unhandled' => 0, + 'hosts_' . Host::getStateText(Host::STATE_UNREACHABLE) => 0, + 'hosts_' . Host::getStateText(Host::STATE_UNREACHABLE) . '_unhandled' => 0, + 'hosts_' . Host::getStateText(Host::STATE_PENDING) => 0, + 'hosts_' . Host::getStateText(Host::STATE_PENDING) . '_unhandled' => 0, ); foreach ($this->hostList as $host) { /** @var Host $host */ - if ((bool) $host->problem === true && (bool) $host->handled === false) { + $unhandled = (bool) $host->problem === true && (bool) $host->handled === false; + if ($unhandled) { $unhandledObjects[] = $host; $unhandledFilterExpressions[] = Filter::where('host', $host->getName()); } @@ -129,7 +134,7 @@ class Monitoring_HostsController extends Controller $objectsInDowntime[] = $host; $downtimeFilterExpressions[] = Filter::where('downtime_host', $host->getName()); } - ++$hostStates[$host::getStateText($host->state)]; + ++$hostStates['hosts_' . $host::getStateText($host->state) . ($unhandled ? '_unhandled' : '')]; } if (! empty($acknowledgedObjects)) { $removeAckForm = new RemoveAcknowledgementCommandForm(); @@ -145,7 +150,7 @@ class Monitoring_HostsController extends Controller $this->view->processCheckResultAllLink = Url::fromRequest()->setPath('monitoring/hosts/process-check-result'); $this->view->addCommentLink = Url::fromRequest()->setPath('monitoring/hosts/add-comment'); $this->view->deleteCommentLink = Url::fromRequest()->setPath('monitoring/hosts/delete-comment'); - $this->view->hostStates = $hostStates; + $this->view->hostStates = (object)$hostStates; $this->view->objects = $this->hostList; $this->view->unhandledObjects = $unhandledObjects; $unhandledFilterQueryString = Filter::matchAny($unhandledFilterExpressions)->toQueryString(); diff --git a/modules/monitoring/application/views/scripts/hosts/show.phtml b/modules/monitoring/application/views/scripts/hosts/show.phtml index c8a4f9484..f4ac40904 100644 --- a/modules/monitoring/application/views/scripts/hosts/show.phtml +++ b/modules/monitoring/application/views/scripts/hosts/show.phtml @@ -8,12 +8,7 @@ use Icinga\Module\Monitoring\Forms\Command\Object\DeleteCommentCommandForm; -

      - qlink( - sprintf($this->translate('%d Hosts Selected'), count($objects)), - $listAllLink - ); ?> -

      + render('partials/host/objects-tinysummary.phtml') ?> render('partials/host/objects-header.phtml'); ?>
      diff --git a/modules/monitoring/application/views/scripts/partials/host/objects-header.phtml b/modules/monitoring/application/views/scripts/partials/host/objects-header.phtml index c2f016ceb..d535f367e 100644 --- a/modules/monitoring/application/views/scripts/partials/host/objects-header.phtml +++ b/modules/monitoring/application/views/scripts/partials/host/objects-header.phtml @@ -2,14 +2,12 @@ use Icinga\Module\Monitoring\Object\Host; ?> - - 0): ?>

      @@ -71,8 +69,8 @@ $hiddenRich = array();

      - diff --git a/modules/monitoring/application/views/scripts/partials/service/objects-header.phtml b/modules/monitoring/application/views/scripts/partials/service/objects-header.phtml index dd206a646..5580446a1 100644 --- a/modules/monitoring/application/views/scripts/partials/service/objects-header.phtml +++ b/modules/monitoring/application/views/scripts/partials/service/objects-header.phtml @@ -74,7 +74,12 @@ use Icinga\Module\Monitoring\Object\Service; From d414d7e3950b9e2983eb12c339f335d1c3c80879 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Sun, 8 Mar 2015 10:19:17 +0100 Subject: [PATCH 0905/2920] Fix that preferences can't be stored in a database The mtime column is a column to update, not a column for the where condition. fixes #8629 --- library/Icinga/User/Preferences/Store/DbStore.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/library/Icinga/User/Preferences/Store/DbStore.php b/library/Icinga/User/Preferences/Store/DbStore.php index 9e012fd01..347fc81df 100644 --- a/library/Icinga/User/Preferences/Store/DbStore.php +++ b/library/Icinga/User/Preferences/Store/DbStore.php @@ -203,12 +203,14 @@ class DbStore extends PreferencesStore foreach ($preferences as $key => $value) { $db->update( $this->table, - array(self::COLUMN_VALUE => $value), + array( + self::COLUMN_VALUE => $value, + self::COLUMN_MODIFIED_TIME => new Zend_Db_Expr('NOW()') + ), array( self::COLUMN_USERNAME . '=?' => $this->getUser()->getUsername(), $db->quoteIdentifier(self::COLUMN_SECTION) . '=?' => $section, - $db->quoteIdentifier(self::COLUMN_PREFERENCE) . '=?' => $key, - self::COLUMN_MODIFIED_TIME => new Zend_Db_Expr('NOW()') + $db->quoteIdentifier(self::COLUMN_PREFERENCE) . '=?' => $key ) ); } From 083c1a9e6bc6a60dc14d716e63327a6b6d220782 Mon Sep 17 00:00:00 2001 From: Louis Sautier Date: Sun, 8 Mar 2015 14:39:53 +0100 Subject: [PATCH 0906/2920] Fix some spelling errors in comments and messages fixes #8633 Signed-off-by: Gunnar Beutner --- library/Icinga/Application/Modules/Manager.php | 2 +- library/Icinga/Chart/Axis.php | 2 +- library/Icinga/Web/Controller/BasePreferenceController.php | 2 +- library/Icinga/Web/Widget/AbstractWidget.php | 2 +- library/Icinga/Web/Widget/Dashboard.php | 4 ++-- library/Icinga/Web/Widget/Tabs.php | 6 +++--- modules/doc/module.info | 2 +- modules/test/module.info | 2 +- .../translation/application/clicommands/CompileCommand.php | 2 +- modules/translation/doc/translation.md | 4 ++-- modules/translation/module.info | 2 +- packages/debian/control | 6 +++--- test/php/library/Icinga/File/Ini/IniWriterTest.php | 2 +- 13 files changed, 19 insertions(+), 19 deletions(-) diff --git a/library/Icinga/Application/Modules/Manager.php b/library/Icinga/Application/Modules/Manager.php index ec2193af9..3d50df109 100644 --- a/library/Icinga/Application/Modules/Manager.php +++ b/library/Icinga/Application/Modules/Manager.php @@ -252,7 +252,7 @@ class Manager } /** - * Disable the given module and remove it's enabled state + * Disable the given module and remove its enabled state * * @param string $name The name of the module to disable * diff --git a/library/Icinga/Chart/Axis.php b/library/Icinga/Chart/Axis.php index 8a0ad5532..a7f8d6d5f 100644 --- a/library/Icinga/Chart/Axis.php +++ b/library/Icinga/Chart/Axis.php @@ -16,7 +16,7 @@ use Icinga\Chart\Unit\LinearUnit; /** * Axis class for the GridChart class. * - * Implements drawing functions for the axis and it's labels but delegates tick and label calculations + * Implements drawing functions for the axis and its labels but delegates tick and label calculations * to the AxisUnit implementations * * @see GridChart diff --git a/library/Icinga/Web/Controller/BasePreferenceController.php b/library/Icinga/Web/Controller/BasePreferenceController.php index af8229262..84e2b045b 100644 --- a/library/Icinga/Web/Controller/BasePreferenceController.php +++ b/library/Icinga/Web/Controller/BasePreferenceController.php @@ -27,7 +27,7 @@ class BasePreferenceController extends ActionController } /** - * Initialize the controller and collect all tabs for it from the application and it's modules + * Initialize the controller and collect all tabs for it from the application and its modules * * @see ActionController::init() */ diff --git a/library/Icinga/Web/Widget/AbstractWidget.php b/library/Icinga/Web/Widget/AbstractWidget.php index a1c1a244e..e047d7512 100644 --- a/library/Icinga/Web/Widget/AbstractWidget.php +++ b/library/Icinga/Web/Widget/AbstractWidget.php @@ -26,7 +26,7 @@ abstract class AbstractWidget { /** * If you are going to access the current view with the view() function, - * it's instance is stored here for performance reasons. + * its instance is stored here for performance reasons. * * @var Zend_View_Abstract */ diff --git a/library/Icinga/Web/Widget/Dashboard.php b/library/Icinga/Web/Widget/Dashboard.php index 00d39cd71..258c9cf2e 100644 --- a/library/Icinga/Web/Widget/Dashboard.php +++ b/library/Icinga/Web/Widget/Dashboard.php @@ -18,7 +18,7 @@ use Icinga\Web\Url; * * The terminology is as follows: * - Dashlet: A single view showing a specific url - * - Pane: Aggregates one or more dashlets on one page, displays it's title as a tab + * - Pane: Aggregates one or more dashlets on one page, displays its title as a tab * - Dashboard: Shows all panes * */ @@ -347,7 +347,7 @@ class Dashboard extends AbstractWidget } /** - * Activates the default pane of this dashboard and returns it's name + * Activates the default pane of this dashboard and returns its name * * @return mixed */ diff --git a/library/Icinga/Web/Widget/Tabs.php b/library/Icinga/Web/Widget/Tabs.php index e83d10783..4952d29b1 100644 --- a/library/Icinga/Web/Widget/Tabs.php +++ b/library/Icinga/Web/Widget/Tabs.php @@ -207,7 +207,7 @@ EOT; * with tab properties or an instance of an existing Tab * * @param string $name The new tab name - * @param array|Tab $tab The tab itself of it's properties + * @param array|Tab $tab The tab itself of its properties * * @return self * @@ -232,7 +232,7 @@ EOT; * of an existing Tab * * @param string $name The new tab name - * @param array|Tab $tab The tab itself of it's properties + * @param array|Tab $tab The tab itself of its properties * * @return self */ @@ -279,7 +279,7 @@ EOT; } /** - * Render the dropdown area with it's tabs and return the resulting HTML + * Render the dropdown area with its tabs and return the resulting HTML * * @return mixed|string */ diff --git a/modules/doc/module.info b/modules/doc/module.info index 1689fd940..2c6f48ac9 100644 --- a/modules/doc/module.info +++ b/modules/doc/module.info @@ -1,4 +1,4 @@ Module: doc Version: 2.0.0 Description: Documentation module - Extracts, shows and exports documentation for Icinga Web 2 and it's modules. + Extracts, shows and exports documentation for Icinga Web 2 and its modules. diff --git a/modules/test/module.info b/modules/test/module.info index 646315156..ed6adc1f2 100644 --- a/modules/test/module.info +++ b/modules/test/module.info @@ -2,4 +2,4 @@ Module: test Version: 2.0.0~alpha4 Description: Translation module This module allows developers to run (unit) tests against Icinga Web 2 and - any of it's modules. Usually you do not need to enable this. + any of its modules. Usually you do not need to enable this. diff --git a/modules/translation/application/clicommands/CompileCommand.php b/modules/translation/application/clicommands/CompileCommand.php index 4f08b2844..036769175 100644 --- a/modules/translation/application/clicommands/CompileCommand.php +++ b/modules/translation/application/clicommands/CompileCommand.php @@ -15,7 +15,7 @@ use Icinga\Module\Translation\Util\GettextTranslationHelper; * Domains are the global one 'icinga' and all available and enabled modules * identified by their name. * - * Once a PO-file is compiled it's content is used by Icinga Web 2 to display + * Once a PO-file is compiled its content is used by Icinga Web 2 to display * messages in the configured language. */ class CompileCommand extends TranslationCommand diff --git a/modules/translation/doc/translation.md b/modules/translation/doc/translation.md index 55dc415ad..308eae6a8 100644 --- a/modules/translation/doc/translation.md +++ b/modules/translation/doc/translation.md @@ -109,7 +109,7 @@ When you are done, just save your new settings. To work with Icinga Web 2 .po files, you can open for e.g. the german icinga.po file which is located under `application/locale/de_DE/LC_MESSAGES/icinga.po`, as shown below, you will get then a full list of all available -translation strings for the core application. Each module names it's translation files `%module_name%.po`. For a +translation strings for the core application. Each module names its translation files `%module_name%.po`. For a module called __yourmodule__ the .po translation file will be named `yourmodule.po`. @@ -196,4 +196,4 @@ The last step is to compile the __yourmodule.po__ to the __yourmodule.mo__: icingacli translation compile module development ll_CC At this moment, everywhere in the module where the `Dummy` should be translated, it would returns the translated -string `Attrappe`. \ No newline at end of file +string `Attrappe`. diff --git a/modules/translation/module.info b/modules/translation/module.info index 9934ec931..ebe121ebc 100644 --- a/modules/translation/module.info +++ b/modules/translation/module.info @@ -2,6 +2,6 @@ Module: translation Version: 2.0.0~alpha4 Description: Translation module This module allows developers and translators to translate Icinga Web 2 and - it's modules for multiple languages. You do not need this module to run an + its modules for multiple languages. You do not need this module to run an internationalized web frontend. This is only for people who want to contribute translations or translate just their own moduls. diff --git a/packages/debian/control b/packages/debian/control index 560b2ef65..73d0b57a3 100644 --- a/packages/debian/control +++ b/packages/debian/control @@ -24,7 +24,7 @@ Package: icingaweb-module-doc Architecture: any Depends: icingaweb-common Description: Icingaweb documentation module - This module renders documentation for Icingaweb and it's modules + This module renders documentation for Icingaweb and its modules Package: icingaweb-module-monitoring Architecture: any @@ -42,7 +42,7 @@ Package: icingaweb-module-test Architecture: any Depends: icingacli Description: Icingaweb test module - Use this module to run unit tests against Icingaweb or any of it's modules + Use this module to run unit tests against Icingaweb or any of its modules Package: icingaweb-module-translation Architecture: any @@ -54,7 +54,7 @@ Package: icingacli Architecture: any Depends: icingaweb-common, php5-cli (>= 5.3.2) Description: Icinga CLI tool - The Icinga CLI allows one to access it's Icinga monitoring + The Icinga CLI allows one to access its Icinga monitoring system from a terminal. . The CLI is based on the Icinga PHP libraries diff --git a/test/php/library/Icinga/File/Ini/IniWriterTest.php b/test/php/library/Icinga/File/Ini/IniWriterTest.php index 56f7fbf3f..4dc94a63a 100644 --- a/test/php/library/Icinga/File/Ini/IniWriterTest.php +++ b/test/php/library/Icinga/File/Ini/IniWriterTest.php @@ -726,7 +726,7 @@ EOD; } /** - * Write a INI-configuration string to a temporary file and return it's path + * Write a INI-configuration string to a temporary file and return its path * * @param string $config The config string to write * From 003a9be43d7b2e3f93e7adad75a6bde32f42ff92 Mon Sep 17 00:00:00 2001 From: Louis Sautier Date: Sun, 8 Mar 2015 15:22:29 +0100 Subject: [PATCH 0907/2920] Fix external authentication with nginx fixes #8634 Signed-off-by: Gunnar Beutner --- modules/setup/library/Setup/Webserver/Nginx.php | 1 + 1 file changed, 1 insertion(+) diff --git a/modules/setup/library/Setup/Webserver/Nginx.php b/modules/setup/library/Setup/Webserver/Nginx.php index 780a3184e..524b90ebf 100644 --- a/modules/setup/library/Setup/Webserver/Nginx.php +++ b/modules/setup/library/Setup/Webserver/Nginx.php @@ -25,6 +25,7 @@ location ~ ^{urlPath}/index\.php(.*)$ { include fastcgi_params; fastcgi_param SCRIPT_FILENAME {documentRoot}/index.php; fastcgi_param ICINGAWEB_CONFIGDIR {configDir}; + fastcgi_param REMOTE_USER $remote_user; } location ~ ^{urlPath}(.+)? { From 8ef119dd39b5ec51676189dfb15a9554bfc224df Mon Sep 17 00:00:00 2001 From: Gunnar Beutner Date: Sun, 8 Mar 2015 15:31:52 +0100 Subject: [PATCH 0908/2920] Update AUTHORS --- AUTHORS | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/AUTHORS b/AUTHORS index 30365cbd0..8a0bc91d0 100644 --- a/AUTHORS +++ b/AUTHORS @@ -1,5 +1,6 @@ Alexander Fuhr Alexander Klimov +ayoubabid baufrecht Bernd Erk Boden Garman @@ -11,8 +12,9 @@ Goran Rakic Gunnar Beutner Jannis Moßhammer Johannes Meyer -Marius Hein +Louis Sautier Marcus Cobden +Marius Hein Markus Frosch Matthias Jentsch Michael Friedrich @@ -22,4 +24,3 @@ Sylph Lin Thomas Gelf Tom Ford Ulf Lange -ayoubabid From e80786d63dc77e9f506c11754829b3d1d3343034 Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Mon, 9 Mar 2015 09:05:56 +0100 Subject: [PATCH 0909/2920] Rename Requirements to RequirementSet refs #8508 --- .../library/Monitoring/MonitoringWizard.php | 28 ++++++------ .../application/forms/RequirementsPage.php | 18 ++++---- .../{Requirements.php => RequirementSet.php} | 22 +++++----- modules/setup/library/Setup/SetupWizard.php | 2 +- modules/setup/library/Setup/WebWizard.php | 44 +++++++++---------- 5 files changed, 57 insertions(+), 57 deletions(-) rename modules/setup/library/Setup/{Requirements.php => RequirementSet.php} (91%) diff --git a/modules/monitoring/library/Monitoring/MonitoringWizard.php b/modules/monitoring/library/Monitoring/MonitoringWizard.php index 82ee90e62..e746db033 100644 --- a/modules/monitoring/library/Monitoring/MonitoringWizard.php +++ b/modules/monitoring/library/Monitoring/MonitoringWizard.php @@ -8,7 +8,7 @@ use Icinga\Web\Wizard; use Icinga\Web\Request; use Icinga\Module\Setup\Setup; use Icinga\Module\Setup\SetupWizard; -use Icinga\Module\Setup\Requirements; +use Icinga\Module\Setup\RequirementSet; use Icinga\Module\Setup\Forms\SummaryPage; use Icinga\Module\Monitoring\Forms\Setup\WelcomePage; use Icinga\Module\Monitoring\Forms\Setup\BackendPage; @@ -136,9 +136,9 @@ class MonitoringWizard extends Wizard implements SetupWizard */ public function getRequirements() { - $requirements = new Requirements(); + $set = new RequirementSet(); - $requirements->add(new PhpModuleRequirement(array( + $set->add(new PhpModuleRequirement(array( 'optional' => true, 'condition' => 'Sockets', 'description' => mt( @@ -148,9 +148,9 @@ class MonitoringWizard extends Wizard implements SetupWizard ) ))); - $idoRequirements = new Requirements(Requirements::MODE_OR); - $mysqlRequirements = new Requirements(); - $mysqlRequirements->add(new PhpModuleRequirement(array( + $idoSet = new RequirementSet(RequirementSet::MODE_OR); + $mysqlSet = new RequirementSet(); + $mysqlSet->add(new PhpModuleRequirement(array( 'condition' => 'mysql', 'alias' => 'PDO-MySQL', 'description' => mt( @@ -158,7 +158,7 @@ class MonitoringWizard extends Wizard implements SetupWizard 'To access the IDO stored in a MySQL database the PDO-MySQL module for PHP is required.' ) ))); - $mysqlRequirements->add(new ClassRequirement(array( + $mysqlSet->add(new ClassRequirement(array( 'condition' => 'Zend_Db_Adapter_Pdo_Mysql', 'alias' => mt('monitoring', 'Zend database adapter for MySQL'), 'description' => mt( @@ -166,9 +166,9 @@ class MonitoringWizard extends Wizard implements SetupWizard 'The Zend database adapter for MySQL is required to access a MySQL database.' ) ))); - $idoRequirements->merge($mysqlRequirements); - $pgsqlRequirements = new Requirements(); - $pgsqlRequirements->add(new PhpModuleRequirement(array( + $idoSet->merge($mysqlSet); + $pgsqlSet = new RequirementSet(); + $pgsqlSet->add(new PhpModuleRequirement(array( 'condition' => 'pgsql', 'alias' => 'PDO-PostgreSQL', 'description' => mt( @@ -176,7 +176,7 @@ class MonitoringWizard extends Wizard implements SetupWizard 'To access the IDO stored in a PostgreSQL database the PDO-PostgreSQL module for PHP is required.' ) ))); - $pgsqlRequirements->add(new ClassRequirement(array( + $pgsqlSet->add(new ClassRequirement(array( 'condition' => 'Zend_Db_Adapter_Pdo_Pgsql', 'alias' => mt('monitoring', 'Zend database adapter for PostgreSQL'), 'description' => mt( @@ -184,9 +184,9 @@ class MonitoringWizard extends Wizard implements SetupWizard 'The Zend database adapter for PostgreSQL is required to access a PostgreSQL database.' ) ))); - $idoRequirements->merge($pgsqlRequirements); - $requirements->merge($idoRequirements); + $idoSet->merge($pgsqlSet); + $set->merge($idoSet); - return $requirements; + return $set; } } diff --git a/modules/setup/application/forms/RequirementsPage.php b/modules/setup/application/forms/RequirementsPage.php index f4b8ee648..086e6e7fc 100644 --- a/modules/setup/application/forms/RequirementsPage.php +++ b/modules/setup/application/forms/RequirementsPage.php @@ -4,7 +4,7 @@ namespace Icinga\Module\Setup\Forms; use Icinga\Web\Form; -use Icinga\Module\Setup\Requirements; +use Icinga\Module\Setup\RequirementSet; /** * Wizard page to list setup requirements @@ -14,9 +14,9 @@ class RequirementsPage extends Form /** * The requirements to list * - * @var Requirements + * @var RequirementSet */ - protected $requirements; + protected $set; /** * Initialize this page @@ -30,24 +30,24 @@ class RequirementsPage extends Form /** * Set the requirements to list * - * @param Requirements $requirements + * @param RequirementSet $set * * @return self */ - public function setRequirements(Requirements $requirements) + public function setRequirements(RequirementSet $set) { - $this->requirements = $requirements; + $this->set = $set; return $this; } /** * Return the requirements to list * - * @return Requirements + * @return RequirementSet */ public function getRequirements() { - return $this->requirements; + return $this->set; } /** @@ -63,6 +63,6 @@ class RequirementsPage extends Form return false; } - return $this->requirements->fulfilled(); + return $this->set->fulfilled(); } } diff --git a/modules/setup/library/Setup/Requirements.php b/modules/setup/library/Setup/RequirementSet.php similarity index 91% rename from modules/setup/library/Setup/Requirements.php rename to modules/setup/library/Setup/RequirementSet.php index 69892f236..6ffce61fb 100644 --- a/modules/setup/library/Setup/Requirements.php +++ b/modules/setup/library/Setup/RequirementSet.php @@ -9,7 +9,7 @@ use RecursiveIterator; /** * Container to store and handle requirements */ -class Requirements implements RecursiveIterator +class RequirementSet implements RecursiveIterator { /** * Mode AND (all requirements must met) @@ -59,7 +59,7 @@ class Requirements implements RecursiveIterator * * @param int $mode * - * @return Requirements + * @return RequirementSet * * @throws LogicException In case the given mode is invalid */ @@ -88,7 +88,7 @@ class Requirements implements RecursiveIterator * * @param Requirement $requirement The requirement to add * - * @return Requirements + * @return RequirementSet */ public function add(Requirement $requirement) { @@ -144,14 +144,14 @@ class Requirements implements RecursiveIterator /** * Register the given requirements * - * @param Requirements $requirements The requirements to register + * @param RequirementSet $set The requirements to register * - * @return Requirements + * @return RequirementSet */ - public function merge(Requirements $requirements) + public function merge(RequirementSet $set) { - if ($this->getMode() === static::MODE_OR && $requirements->getMode() === static::MODE_OR) { - foreach ($requirements->getAll() as $requirement) { + if ($this->getMode() === static::MODE_OR && $set->getMode() === static::MODE_OR) { + foreach ($set->getAll() as $requirement) { if ($requirement instanceof static) { $this->merge($requirement); } else { @@ -159,11 +159,11 @@ class Requirements implements RecursiveIterator } } } else { - if ($requirements->getMode() === static::MODE_OR) { + if ($set->getMode() === static::MODE_OR) { $this->containsMandatoryRequirements = true; } - $this->requirements[] = $requirements; + $this->requirements[] = $set; } return $this; @@ -250,7 +250,7 @@ class Requirements implements RecursiveIterator /** * Return the current element in the iteration * - * @return Requirement|Requirements + * @return Requirement|RequirementSet */ public function current() { diff --git a/modules/setup/library/Setup/SetupWizard.php b/modules/setup/library/Setup/SetupWizard.php index 9e7b45174..1ce948dc1 100644 --- a/modules/setup/library/Setup/SetupWizard.php +++ b/modules/setup/library/Setup/SetupWizard.php @@ -18,7 +18,7 @@ interface SetupWizard /** * Return the requirements of this wizard * - * @return Requirements + * @return RequirementSet */ public function getRequirements(); } diff --git a/modules/setup/library/Setup/WebWizard.php b/modules/setup/library/Setup/WebWizard.php index 59404efd6..d3bb71bfa 100644 --- a/modules/setup/library/Setup/WebWizard.php +++ b/modules/setup/library/Setup/WebWizard.php @@ -357,9 +357,9 @@ class WebWizard extends Wizard implements SetupWizard */ public function getRequirements() { - $requirements = new Requirements(); + $set = new RequirementSet(); - $requirements->add(new PhpVersionRequirement(array( + $set->add(new PhpVersionRequirement(array( 'condition' => array('>=', '5.3.2'), 'description' => mt( 'setup', @@ -368,7 +368,7 @@ class WebWizard extends Wizard implements SetupWizard ) ))); - $requirements->add(new PhpConfigRequirement(array( + $set->add(new PhpConfigRequirement(array( 'condition' => array('date.timezone', true), 'title' => mt('setup', 'Default Timezone'), 'description' => sprintf( @@ -377,7 +377,7 @@ class WebWizard extends Wizard implements SetupWizard ), ))); - $requirements->add(new OSRequirement(array( + $set->add(new OSRequirement(array( 'optional' => true, 'condition' => 'linux', 'description' => mt( @@ -387,7 +387,7 @@ class WebWizard extends Wizard implements SetupWizard ) ))); - $requirements->add(new PhpModuleRequirement(array( + $set->add(new PhpModuleRequirement(array( 'condition' => 'OpenSSL', 'description' => mt( 'setup', @@ -395,7 +395,7 @@ class WebWizard extends Wizard implements SetupWizard ) ))); - $requirements->add(new PhpModuleRequirement(array( + $set->add(new PhpModuleRequirement(array( 'optional' => true, 'condition' => 'JSON', 'description' => mt( @@ -404,7 +404,7 @@ class WebWizard extends Wizard implements SetupWizard ) ))); - $requirements->add(new PhpModuleRequirement(array( + $set->add(new PhpModuleRequirement(array( 'optional' => true, 'condition' => 'LDAP', 'description' => mt( @@ -413,7 +413,7 @@ class WebWizard extends Wizard implements SetupWizard ) ))); - $requirements->add(new PhpModuleRequirement(array( + $set->add(new PhpModuleRequirement(array( 'optional' => true, 'condition' => 'INTL', 'description' => mt( @@ -424,7 +424,7 @@ class WebWizard extends Wizard implements SetupWizard ))); // TODO(6172): Remove this requirement once we do not ship dompdf with Icinga Web 2 anymore - $requirements->add(new PhpModuleRequirement(array( + $set->add(new PhpModuleRequirement(array( 'optional' => true, 'condition' => 'DOM', 'description' => mt( @@ -433,7 +433,7 @@ class WebWizard extends Wizard implements SetupWizard ) ))); - $requirements->add(new PhpModuleRequirement(array( + $set->add(new PhpModuleRequirement(array( 'optional' => true, 'condition' => 'GD', 'description' => mt( @@ -442,7 +442,7 @@ class WebWizard extends Wizard implements SetupWizard ) ))); - $requirements->add(new PhpModuleRequirement(array( + $set->add(new PhpModuleRequirement(array( 'optional' => true, 'condition' => 'Imagick', 'description' => mt( @@ -451,8 +451,8 @@ class WebWizard extends Wizard implements SetupWizard ) ))); - $mysqlRequirements = new Requirements(); - $mysqlRequirements->add(new PhpModuleRequirement(array( + $mysqlSet = new RequirementSet(); + $mysqlSet->add(new PhpModuleRequirement(array( 'optional' => true, 'condition' => 'mysql', 'alias' => 'PDO-MySQL', @@ -461,7 +461,7 @@ class WebWizard extends Wizard implements SetupWizard 'To store users or preferences in a MySQL database the PDO-MySQL module for PHP is required.' ) ))); - $mysqlRequirements->add(new ClassRequirement(array( + $mysqlSet->add(new ClassRequirement(array( 'optional' => true, 'condition' => 'Zend_Db_Adapter_Pdo_Mysql', 'alias' => mt('setup', 'Zend database adapter for MySQL'), @@ -470,10 +470,10 @@ class WebWizard extends Wizard implements SetupWizard 'The Zend database adapter for MySQL is required to access a MySQL database.' ) ))); - $requirements->merge($mysqlRequirements); + $set->merge($mysqlSet); - $pgsqlRequirements = new Requirements(); - $pgsqlRequirements->add(new PhpModuleRequirement(array( + $pgsqlSet = new RequirementSet(); + $pgsqlSet->add(new PhpModuleRequirement(array( 'optional' => true, 'condition' => 'pgsql', 'alias' => 'PDO-PostgreSQL', @@ -482,7 +482,7 @@ class WebWizard extends Wizard implements SetupWizard 'To store users or preferences in a PostgreSQL database the PDO-PostgreSQL module for PHP is required.' ) ))); - $pgsqlRequirements->add(new ClassRequirement(array( + $pgsqlSet->add(new ClassRequirement(array( 'optional' => true, 'condition' => 'Zend_Db_Adapter_Pdo_Pgsql', 'alias' => mt('setup', 'Zend database adapter for PostgreSQL'), @@ -491,9 +491,9 @@ class WebWizard extends Wizard implements SetupWizard 'The Zend database adapter for PostgreSQL is required to access a PostgreSQL database.' ) ))); - $requirements->merge($pgsqlRequirements); + $set->merge($pgsqlSet); - $requirements->add(new ConfigDirectoryRequirement(array( + $set->add(new ConfigDirectoryRequirement(array( 'condition' => Icinga::app()->getConfigDir(), 'description' => mt( 'setup', @@ -503,9 +503,9 @@ class WebWizard extends Wizard implements SetupWizard ))); foreach ($this->getWizards() as $wizard) { - $requirements->merge($wizard->getRequirements()); + $set->merge($wizard->getRequirements()); } - return $requirements; + return $set; } } From bc450c573db1446e8f4bdd9cd322c8452e766080 Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Tue, 10 Mar 2015 09:12:06 +0100 Subject: [PATCH 0910/2920] Refactor and fix requirement evaluation refs #8508 --- .../library/Monitoring/MonitoringWizard.php | 10 +- .../setup/library/Setup/RequirementSet.php | 171 +++--- modules/setup/library/Setup/WebWizard.php | 4 +- .../php/library/Setup/RequirementSetTest.php | 496 ++++++++++++++++++ 4 files changed, 613 insertions(+), 68 deletions(-) create mode 100644 modules/setup/test/php/library/Setup/RequirementSetTest.php diff --git a/modules/monitoring/library/Monitoring/MonitoringWizard.php b/modules/monitoring/library/Monitoring/MonitoringWizard.php index e746db033..639986246 100644 --- a/modules/monitoring/library/Monitoring/MonitoringWizard.php +++ b/modules/monitoring/library/Monitoring/MonitoringWizard.php @@ -148,9 +148,10 @@ class MonitoringWizard extends Wizard implements SetupWizard ) ))); - $idoSet = new RequirementSet(RequirementSet::MODE_OR); - $mysqlSet = new RequirementSet(); + $idoSet = new RequirementSet(false, RequirementSet::MODE_OR); + $mysqlSet = new RequirementSet(true); $mysqlSet->add(new PhpModuleRequirement(array( + 'optional' => true, 'condition' => 'mysql', 'alias' => 'PDO-MySQL', 'description' => mt( @@ -159,6 +160,7 @@ class MonitoringWizard extends Wizard implements SetupWizard ) ))); $mysqlSet->add(new ClassRequirement(array( + 'optional' => true, 'condition' => 'Zend_Db_Adapter_Pdo_Mysql', 'alias' => mt('monitoring', 'Zend database adapter for MySQL'), 'description' => mt( @@ -167,8 +169,9 @@ class MonitoringWizard extends Wizard implements SetupWizard ) ))); $idoSet->merge($mysqlSet); - $pgsqlSet = new RequirementSet(); + $pgsqlSet = new RequirementSet(true); $pgsqlSet->add(new PhpModuleRequirement(array( + 'optional' => true, 'condition' => 'pgsql', 'alias' => 'PDO-PostgreSQL', 'description' => mt( @@ -177,6 +180,7 @@ class MonitoringWizard extends Wizard implements SetupWizard ) ))); $pgsqlSet->add(new ClassRequirement(array( + 'optional' => true, 'condition' => 'Zend_Db_Adapter_Pdo_Pgsql', 'alias' => mt('monitoring', 'Zend database adapter for PostgreSQL'), 'description' => mt( diff --git a/modules/setup/library/Setup/RequirementSet.php b/modules/setup/library/Setup/RequirementSet.php index 6ffce61fb..966cf98cc 100644 --- a/modules/setup/library/Setup/RequirementSet.php +++ b/modules/setup/library/Setup/RequirementSet.php @@ -12,17 +12,31 @@ use RecursiveIterator; class RequirementSet implements RecursiveIterator { /** - * Mode AND (all requirements must met) + * Mode AND (all requirements must be met) */ const MODE_AND = 0; /** - * Mode OR (at least one requirement must met) + * Mode OR (at least one requirement must be met) */ const MODE_OR = 1; /** - * The mode by with the requirements are evaluated + * Whether all requirements meet their condition + * + * @var bool + */ + protected $state; + + /** + * Whether this set is optional + * + * @var bool + */ + protected $optional; + + /** + * The mode by which the requirements are evaluated * * @var string */ @@ -36,26 +50,75 @@ class RequirementSet implements RecursiveIterator protected $requirements; /** - * Whether there is any mandatory requirement part of this set + * The raw state of this set's requirements * * @var bool */ - protected $containsMandatoryRequirements; + private $forcedState; /** - * Create a new set of requirements + * Initialize a new set of requirements * - * @param int $mode The mode by with to evaluate the requirements + * @param bool $optional Whether this set is optional + * @param int $mode The mode by which to evaluate this set */ - public function __construct($mode = null) + public function __construct($optional = false, $mode = null) { + $this->optional = $optional; $this->requirements = array(); - $this->containsMandatoryRequirements = false; $this->setMode($mode ?: static::MODE_AND); } /** - * Set the mode by with to evaluate the requirements + * Set the state of this set + * + * @param bool $state + * + * @return RequirementSet + */ + public function setState($state) + { + $this->state = (bool) $state; + return $this; + } + + /** + * Return the state of this set + * + * Alias for RequirementSet::fulfilled(true). + * + * @return bool + */ + public function getState() + { + return $this->fulfilled(true); + } + + /** + * Set whether this set of requirements should be optional + * + * @param bool $state + * + * @return RequirementSet + */ + public function setOptional($state = true) + { + $this->optional = (bool) $state; + return $this; + } + + /** + * Return whether this set of requirements is optional + * + * @return bool + */ + public function isOptional() + { + return $this->optional; + } + + /** + * Set the mode by which to evaluate the requirements * * @param int $mode * @@ -74,7 +137,7 @@ class RequirementSet implements RecursiveIterator } /** - * Return the mode by with the requirements are evaluated + * Return the mode by which the requirements are evaluated * * @return int */ @@ -95,10 +158,7 @@ class RequirementSet implements RecursiveIterator $merged = false; foreach ($this->requirements as $knownRequirement) { if ($knownRequirement instanceof Requirement && $requirement->equals($knownRequirement)) { - if ($this->getMode() === static::MODE_AND && !$requirement->isOptional()) { - $knownRequirement->setOptional(false); - } - + $knownRequirement->setOptional($requirement->isOptional()); foreach ($requirement->getDescriptions() as $description) { $knownRequirement->addDescription($description); } @@ -109,12 +169,6 @@ class RequirementSet implements RecursiveIterator } if (! $merged) { - if ($this->getMode() === static::MODE_OR) { - $requirement->setOptional(); - } elseif (! $requirement->isOptional()) { - $this->containsMandatoryRequirements = true; - } - $this->requirements[] = $requirement; } @@ -132,25 +186,15 @@ class RequirementSet implements RecursiveIterator } /** - * Return whether there is any mandatory requirement part of this set + * Register the given set of requirements * - * @return bool - */ - public function hasAnyMandatoryRequirement() - { - return $this->containsMandatoryRequirements || $this->getMode() === static::MODE_OR; - } - - /** - * Register the given requirements - * - * @param RequirementSet $set The requirements to register + * @param RequirementSet $set The set to register * * @return RequirementSet */ public function merge(RequirementSet $set) { - if ($this->getMode() === static::MODE_OR && $set->getMode() === static::MODE_OR) { + if ($this->getMode() === $set->getMode() && $this->isOptional() === $set->isOptional()) { foreach ($set->getAll() as $requirement) { if ($requirement instanceof static) { $this->merge($requirement); @@ -159,10 +203,6 @@ class RequirementSet implements RecursiveIterator } } } else { - if ($set->getMode() === static::MODE_OR) { - $this->containsMandatoryRequirements = true; - } - $this->requirements[] = $set; } @@ -172,40 +212,45 @@ class RequirementSet implements RecursiveIterator /** * Return whether all requirements can successfully be evaluated based on the current mode * + * In case this is a optional set of requirements (and $force is false), true is returned immediately. + * + * @param bool $force Whether to ignore the optionality of a set or single requirement + * * @return bool */ - public function fulfilled() + public function fulfilled($force = false) { - $state = false; - foreach ($this->requirements as $requirement) { - if ($requirement instanceof static) { - if ($requirement->fulfilled()) { - if ($this->getMode() === static::MODE_OR) { - return true; - } + $state = $this->isOptional(); + if (! $force && $state) { + return true; + } - $state = true; - } elseif ($this->getMode() === static::MODE_AND && $requirement->hasAnyMandatoryRequirement()) { - return false; + if (! $force && $this->state !== null) { + return $this->state; + } elseif ($force && $this->forcedState !== null) { + return $this->forcedState; + } + + $self = $this->requirements; + foreach ($self as $requirement) { + if ($requirement->getState()) { + $state = true; + if ($this->getMode() === static::MODE_OR) { + break; } - } else { - if ($requirement->getState()) { - if ($this->getMode() === static::MODE_OR) { - return true; - } - - $state = true; - } elseif ($this->getMode() === static::MODE_AND) { - if (! $requirement->isOptional()) { - return false; - } - - $state = true; // There may only be optional requirements... + } elseif ($force || !$requirement->isOptional()) { + $state = false; + if ($this->getMode() === static::MODE_AND) { + break; } } } - return $state; + if ($force) { + return $this->forcedState = $state; + } + + return $this->state = $state; } /** diff --git a/modules/setup/library/Setup/WebWizard.php b/modules/setup/library/Setup/WebWizard.php index d3bb71bfa..e3091bd4d 100644 --- a/modules/setup/library/Setup/WebWizard.php +++ b/modules/setup/library/Setup/WebWizard.php @@ -451,7 +451,7 @@ class WebWizard extends Wizard implements SetupWizard ) ))); - $mysqlSet = new RequirementSet(); + $mysqlSet = new RequirementSet(true); $mysqlSet->add(new PhpModuleRequirement(array( 'optional' => true, 'condition' => 'mysql', @@ -472,7 +472,7 @@ class WebWizard extends Wizard implements SetupWizard ))); $set->merge($mysqlSet); - $pgsqlSet = new RequirementSet(); + $pgsqlSet = new RequirementSet(true); $pgsqlSet->add(new PhpModuleRequirement(array( 'optional' => true, 'condition' => 'pgsql', diff --git a/modules/setup/test/php/library/Setup/RequirementSetTest.php b/modules/setup/test/php/library/Setup/RequirementSetTest.php new file mode 100644 index 000000000..d2c4d2029 --- /dev/null +++ b/modules/setup/test/php/library/Setup/RequirementSetTest.php @@ -0,0 +1,496 @@ +assertFalse($emptySet->fulfilled(), 'A empty mandatory set of type and is fulfilled'); + + $singleTrueSet = new RequirementSet(); + $singleTrueSet->add(new TrueRequirement()); + $this->assertTrue( + $singleTrueSet->fulfilled(), + 'A mandatory set of type and with a single TrueRequirement is not fulfilled' + ); + + $singleFalseSet = new RequirementSet(); + $singleFalseSet->add(new FalseRequirement()); + $this->assertFalse( + $singleFalseSet->fulfilled(), + 'A mandatory set of type and with a single FalseRequirement is fulfilled' + ); + + $mixedSet = new RequirementSet(); + $mixedSet->add(new TrueRequirement()); + $mixedSet->add(new FalseRequirement()); + $this->assertFalse( + $mixedSet->fulfilled(), + 'A mandatory set of type and with one True- and one FalseRequirement is fulfilled' + ); + } + + public function testFlatOptionalRequirementsOfTypeAnd() + { + $emptySet = new RequirementSet(true); + $this->assertTrue($emptySet->fulfilled(), 'A empty optional set of type and is not fulfilled'); + + $singleTrueSet = new RequirementSet(true); + $singleTrueSet->add(new TrueRequirement()); + $this->assertTrue( + $singleTrueSet->fulfilled(), + 'A optional set of type and with a single TrueRequirement is not fulfilled' + ); + + $singleFalseSet = new RequirementSet(true); + $singleFalseSet->add(new FalseRequirement()); + $this->assertTrue( + $singleFalseSet->fulfilled(), + 'A optional set of type and with a single FalseRequirement is not fulfilled' + ); + + $mixedSet = new RequirementSet(true); + $mixedSet->add(new TrueRequirement()); + $mixedSet->add(new FalseRequirement()); + $this->assertTrue( + $mixedSet->fulfilled(), + 'A optional set of type and with one True- and one FalseRequirement is not fulfilled' + ); + } + + public function testFlatMixedRequirementsOfTypeAnd() + { + $mandatoryOptionalTrueSet = new RequirementSet(); + $mandatoryOptionalTrueSet->add(new TrueRequirement(array('optional' => true))); + $mandatoryOptionalTrueSet->add(new FalseRequirement()); + $this->assertFalse( + $mandatoryOptionalTrueSet->fulfilled(), + 'A mandatory set of type and with one optional True- and one mandatory FalseRequirement is fulfilled' + ); + + $mandatoryOptionalFalseSet = new RequirementSet(); + $mandatoryOptionalFalseSet->add(new TrueRequirement()); + $mandatoryOptionalFalseSet->add(new FalseRequirement(array('optional' => true))); + $this->assertTrue( + $mandatoryOptionalFalseSet->fulfilled(), + 'A mandatory set of type and with one mandatory True- and one optional FalseRequirement is not fulfilled' + ); + + $optionalOptionalTrueSet = new RequirementSet(true); + $optionalOptionalTrueSet->add(new TrueRequirement(array('optional' => true))); + $optionalOptionalTrueSet->add(new FalseRequirement()); + $this->assertTrue( + $optionalOptionalTrueSet->fulfilled(), + 'A optional set of type and with one optional True- and one mandatory FalseRequirement is not fulfilled' + ); + + $optionalOptionalFalseSet = new RequirementSet(true); + $optionalOptionalFalseSet->add(new TrueRequirement()); + $optionalOptionalFalseSet->add(new FalseRequirement(array('optional' => true))); + $this->assertTrue( + $optionalOptionalFalseSet->fulfilled(), + 'A optional set of type and with one mandatory True- and one optional FalseRequirement is not fulfilled' + ); + } + + public function testFlatMandatoryRequirementsOfTypeOr() + { + $emptySet = new RequirementSet(false, RequirementSet::MODE_OR); + $this->assertFalse($emptySet->fulfilled(), 'A empty mandatory set of type or is fulfilled'); + + $singleTrueSet = new RequirementSet(false, RequirementSet::MODE_OR); + $singleTrueSet->add(new TrueRequirement()); + $this->assertTrue( + $singleTrueSet->fulfilled(), + 'A mandatory set of type or with a single TrueRequirement is not fulfilled' + ); + + $singleFalseSet = new RequirementSet(false, RequirementSet::MODE_OR); + $singleFalseSet->add(new FalseRequirement()); + $this->assertFalse( + $singleFalseSet->fulfilled(), + 'A mandatory set of type or with a single FalseRequirement is fulfilled' + ); + + $mixedSet = new RequirementSet(false, RequirementSet::MODE_OR); + $mixedSet->add(new TrueRequirement()); + $mixedSet->add(new FalseRequirement()); + $this->assertTrue( + $mixedSet->fulfilled(), + 'A mandatory set of type or with one True- and one FalseRequirement is not fulfilled' + ); + } + + public function testFlatOptionalRequirementsOfTypeOr() + { + $emptySet = new RequirementSet(true, RequirementSet::MODE_OR); + $this->assertTrue($emptySet->fulfilled(), 'A empty optional set of type or is not fulfilled'); + + $singleTrueSet = new RequirementSet(true, RequirementSet::MODE_OR); + $singleTrueSet->add(new TrueRequirement()); + $this->assertTrue( + $singleTrueSet->fulfilled(), + 'A optional set of type or with a single TrueRequirement is not fulfilled' + ); + + $singleFalseSet = new RequirementSet(true, RequirementSet::MODE_OR); + $singleFalseSet->add(new FalseRequirement()); + $this->assertTrue( + $singleFalseSet->fulfilled(), + 'A optional set of type or with a single FalseRequirement is not fulfilled' + ); + + $mixedSet = new RequirementSet(true, RequirementSet::MODE_OR); + $mixedSet->add(new TrueRequirement()); + $mixedSet->add(new FalseRequirement()); + $this->assertTrue( + $mixedSet->fulfilled(), + 'A optional set of type or with one True- and one FalseRequirement is not fulfilled' + ); + } + + public function testFlatMixedRequirementsOfTypeOr() + { + $mandatoryOptionalTrueSet = new RequirementSet(false, RequirementSet::MODE_OR); + $mandatoryOptionalTrueSet->add(new TrueRequirement(array('optional' => true))); + $mandatoryOptionalTrueSet->add(new FalseRequirement()); + $this->assertTrue( + $mandatoryOptionalTrueSet->fulfilled(), + 'A mandatory set of type or with one optional True- and one mandatory FalseRequirement is not fulfilled' + ); + + $mandatoryOptionalFalseSet = new RequirementSet(false, RequirementSet::MODE_OR); + $mandatoryOptionalFalseSet->add(new TrueRequirement()); + $mandatoryOptionalFalseSet->add(new FalseRequirement(array('optional' => true))); + $this->assertTrue( + $mandatoryOptionalFalseSet->fulfilled(), + 'A mandatory set of type or with one mandatory True- and one optional FalseRequirement is not fulfilled' + ); + + $optionalOptionalTrueSet = new RequirementSet(true, RequirementSet::MODE_OR); + $optionalOptionalTrueSet->add(new TrueRequirement(array('optional' => true))); + $optionalOptionalTrueSet->add(new FalseRequirement()); + $this->assertTrue( + $optionalOptionalTrueSet->fulfilled(), + 'A optional set of type or with one optional True- and one mandatory FalseRequirement is not fulfilled' + ); + + $optionalOptionalFalseSet = new RequirementSet(true, RequirementSet::MODE_OR); + $optionalOptionalFalseSet->add(new TrueRequirement()); + $optionalOptionalFalseSet->add(new FalseRequirement(array('optional' => true))); + $this->assertTrue( + $optionalOptionalFalseSet->fulfilled(), + 'A optional set of type or with one mandatory True- and one optional FalseRequirement is not fulfilled' + ); + } + + public function testNestedMandatoryRequirementsOfTypeAnd() + { + $trueSet = new RequirementSet(); + $trueSet->add(new TrueRequirement()); + $falseSet = new RequirementSet(); + $falseSet->add(new FalseRequirement()); + + $nestedTrueSet = new RequirementSet(); + $nestedTrueSet->merge($trueSet); + $this->assertTrue( + $nestedTrueSet->fulfilled(), + 'A nested mandatory set of type and with one mandatory TrueRequirement is not fulfilled' + ); + + $nestedFalseSet = new RequirementSet(); + $nestedFalseSet->merge($falseSet); + $this->assertFalse( + $nestedFalseSet->fulfilled(), + 'A nested mandatory set of type and with one mandatory FalseRequirement is fulfilled' + ); + + $nestedMixedSet = new RequirementSet(); + $nestedMixedSet->merge($trueSet); + $nestedMixedSet->merge($falseSet); + $this->assertFalse( + $nestedMixedSet->fulfilled(), + 'Two nested mandatory sets of type and with one mandatory True- and' + . ' one mandatory FalseRequirement respectively are fulfilled' + ); + } + + public function testNestedOptionalRequirementsOfTypeAnd() + { + $trueSet = new RequirementSet(true); + $trueSet->add(new TrueRequirement()); + $falseSet = new RequirementSet(true); + $falseSet->add(new FalseRequirement()); + + $nestedTrueSet = new RequirementSet(true); + $nestedTrueSet->merge($trueSet); + $this->assertTrue( + $nestedTrueSet->fulfilled(), + 'A nested optional set of type and with one mandatory TrueRequirement is not fulfilled' + ); + + $nestedFalseSet = new RequirementSet(true); + $nestedFalseSet->merge($falseSet); + $this->assertTrue( + $nestedFalseSet->fulfilled(), + 'A nested optional set of type and with one mandatory FalseRequirement is not fulfilled' + ); + + $nestedMixedSet = new RequirementSet(true); + $nestedMixedSet->merge($trueSet); + $nestedMixedSet->merge($falseSet); + $this->assertTrue( + $nestedMixedSet->fulfilled(), + 'Two nested optional sets of type and with one mandatory True- and' + . ' one mandatory FalseRequirement respectively are not fulfilled' + ); + } + + public function testNestedMixedRequirementsOfTypeAnd() + { + $mandatoryMandatoryTrueSet = new RequirementSet(); + $mandatoryMandatoryTrueSet->add(new TrueRequirement()); + $mandatoryOptionalTrueSet = new RequirementSet(); + $mandatoryOptionalTrueSet->add(new TrueRequirement(array('optional' => true))); + $mandatoryMandatoryFalseSet = new RequirementSet(); + $mandatoryMandatoryFalseSet->add(new FalseRequirement()); + $mandatoryOptionalFalseSet = new RequirementSet(); + $mandatoryOptionalFalseSet->add(new FalseRequirement(array('optional' => true))); + $optionalMandatoryTrueSet = new RequirementSet(true); + $optionalMandatoryTrueSet->add(new TrueRequirement()); + $optionalOptionalTrueSet = new RequirementSet(true); + $optionalOptionalTrueSet->add(new TrueRequirement(array('optional' => true))); + $optionalMandatoryFalseSet = new RequirementSet(true); + $optionalMandatoryFalseSet->add(new FalseRequirement()); + $optionalOptionalFalseSet = new RequirementSet(true); + $optionalOptionalFalseSet->add(new FalseRequirement(array('optional' => true))); + + $mandatoryMandatoryOptionalTrueSet = new RequirementSet(); + $mandatoryMandatoryOptionalTrueSet->merge($mandatoryOptionalTrueSet); + $mandatoryMandatoryOptionalTrueSet->merge($mandatoryMandatoryFalseSet); + $this->assertFalse( + $mandatoryMandatoryOptionalTrueSet->fulfilled(), + 'A mandatory set of type and with two nested mandatory sets of type and where one has a optional' + . ' TrueRequirement and the other one has a mandatory FalseRequirement is fulfilled' + ); + + $mandatoryMandatoryOptionalFalseSet = new RequirementSet(); + $mandatoryMandatoryOptionalFalseSet->merge($mandatoryOptionalFalseSet); + $mandatoryMandatoryOptionalFalseSet->merge($mandatoryMandatoryTrueSet); + $this->assertTrue( + $mandatoryMandatoryOptionalFalseSet->fulfilled(), + 'A mandatory set of type and with two nested mandatory sets of type and where one has a mandatory' + . ' TrueRequirement and the other one has a optional FalseRequirement is not fulfilled' + ); + + $optionalOptionalOptionalTrueSet = new RequirementSet(true); + $optionalOptionalOptionalTrueSet->merge($optionalOptionalTrueSet); + $optionalOptionalOptionalTrueSet->merge($optionalMandatoryFalseSet); + $this->assertTrue( + $optionalOptionalOptionalTrueSet->fulfilled(), + 'A optional set of type and with two nested optional sets of type and where one has a optional' + . ' TrueRequirement and the other one has a mandatory FalseRequirement is not fulfilled' + ); + + $optionalOptionalOptionalFalseSet = new RequirementSet(true); + $optionalOptionalOptionalFalseSet->merge($optionalOptionalFalseSet); + $optionalOptionalOptionalFalseSet->merge($optionalMandatoryTrueSet); + $this->assertTrue( + $optionalOptionalOptionalFalseSet->fulfilled(), + 'A optional set of type and with two nested optional sets of type and where one has a mandatory' + . ' TrueRequirement and the other one has a optional FalseRequirement is not fulfilled' + ); + } + + public function testNestedMandatoryRequirementsOfTypeOr() + { + $trueSet = new RequirementSet(false, RequirementSet::MODE_OR); + $trueSet->add(new TrueRequirement()); + $falseSet = new RequirementSet(false, RequirementSet::MODE_OR); + $falseSet->add(new FalseRequirement()); + + $nestedTrueSet = new RequirementSet(false, RequirementSet::MODE_OR); + $nestedTrueSet->merge($trueSet); + $this->assertTrue( + $nestedTrueSet->fulfilled(), + 'A nested mandatory set of type or with one mandatory TrueRequirement is not fulfilled' + ); + + $nestedFalseSet = new RequirementSet(false, RequirementSet::MODE_OR); + $nestedFalseSet->merge($falseSet); + $this->assertFalse( + $nestedFalseSet->fulfilled(), + 'A nested mandatory set of type or with one mandatory FalseRequirement is fulfilled' + ); + + $nestedMixedSet = new RequirementSet(false, RequirementSet::MODE_OR); + $nestedMixedSet->merge($trueSet); + $nestedMixedSet->merge($falseSet); + $this->assertTrue( + $nestedMixedSet->fulfilled(), + 'Two nested mandatory sets of type or with one mandatory True- and' + . ' one mandatory FalseRequirement respectively are not fulfilled' + ); + } + + public function testNestedOptionalRequirementsOfTypeOr() + { + $trueSet = new RequirementSet(true, RequirementSet::MODE_OR); + $trueSet->add(new TrueRequirement()); + $falseSet = new RequirementSet(true, RequirementSet::MODE_OR); + $falseSet->add(new FalseRequirement()); + + $nestedTrueSet = new RequirementSet(true, RequirementSet::MODE_OR); + $nestedTrueSet->merge($trueSet); + $this->assertTrue( + $nestedTrueSet->fulfilled(), + 'A nested optional set of type or with one mandatory TrueRequirement is not fulfilled' + ); + + $nestedFalseSet = new RequirementSet(true, RequirementSet::MODE_OR); + $nestedFalseSet->merge($falseSet); + $this->assertTrue( + $nestedFalseSet->fulfilled(), + 'A nested optional set of type or with one mandatory FalseRequirement is not fulfilled' + ); + + $nestedMixedSet = new RequirementSet(true, RequirementSet::MODE_OR); + $nestedMixedSet->merge($trueSet); + $nestedMixedSet->merge($falseSet); + $this->assertTrue( + $nestedMixedSet->fulfilled(), + 'Two nested optional sets of type or with one mandatory True- and' + . ' one mandatory FalseRequirement respectively are not fulfilled' + ); + } + + public function testNestedMixedRequirementsOfTypeOr() + { + $mandatoryMandatoryTrueSet = new RequirementSet(false, RequirementSet::MODE_OR); + $mandatoryMandatoryTrueSet->add(new TrueRequirement()); + $mandatoryOptionalTrueSet = new RequirementSet(false, RequirementSet::MODE_OR); + $mandatoryOptionalTrueSet->add(new TrueRequirement(array('optional' => true))); + $mandatoryMandatoryFalseSet = new RequirementSet(false, RequirementSet::MODE_OR); + $mandatoryMandatoryFalseSet->add(new FalseRequirement()); + $mandatoryOptionalFalseSet = new RequirementSet(false, RequirementSet::MODE_OR); + $mandatoryOptionalFalseSet->add(new FalseRequirement(array('optional' => true))); + $optionalMandatoryTrueSet = new RequirementSet(true, RequirementSet::MODE_OR); + $optionalMandatoryTrueSet->add(new TrueRequirement()); + $optionalOptionalTrueSet = new RequirementSet(true, RequirementSet::MODE_OR); + $optionalOptionalTrueSet->add(new TrueRequirement(array('optional' => true))); + $optionalMandatoryFalseSet = new RequirementSet(true, RequirementSet::MODE_OR); + $optionalMandatoryFalseSet->add(new FalseRequirement()); + $optionalOptionalFalseSet = new RequirementSet(true, RequirementSet::MODE_OR); + $optionalOptionalFalseSet->add(new FalseRequirement(array('optional' => true))); + + $mandatoryMandatoryOptionalTrueSet = new RequirementSet(false, RequirementSet::MODE_OR); + $mandatoryMandatoryOptionalTrueSet->merge($mandatoryOptionalTrueSet); + $mandatoryMandatoryOptionalTrueSet->merge($mandatoryMandatoryFalseSet); + $this->assertTrue($mandatoryMandatoryOptionalTrueSet->fulfilled()); + + $mandatoryMandatoryOptionalFalseSet = new RequirementSet(false, RequirementSet::MODE_OR); + $mandatoryMandatoryOptionalFalseSet->merge($mandatoryOptionalFalseSet); + $mandatoryMandatoryOptionalFalseSet->merge($mandatoryMandatoryTrueSet); + $this->assertTrue($mandatoryMandatoryOptionalFalseSet->fulfilled()); + + $optionalOptionalOptionalTrueSet = new RequirementSet(true, RequirementSet::MODE_OR); + $optionalOptionalOptionalTrueSet->merge($optionalOptionalTrueSet); + $optionalOptionalOptionalTrueSet->merge($optionalMandatoryFalseSet); + $this->assertTrue($optionalOptionalOptionalTrueSet->fulfilled()); + + $optionalOptionalOptionalFalseSet = new RequirementSet(true, RequirementSet::MODE_OR); + $optionalOptionalOptionalFalseSet->merge($optionalOptionalFalseSet); + $optionalOptionalOptionalFalseSet->merge($optionalMandatoryTrueSet); + $this->assertTrue($optionalOptionalOptionalFalseSet->fulfilled()); + } + + public function testNestedMandatoryRequirementsOfDifferentTypes() + { + $true = new TrueRequirement(); + $false = new FalseRequirement(); + + $level1And = new RequirementSet(); + $level2FirstOr = new RequirementSet(false, RequirementSet::MODE_OR); + $level2SecondOr = new RequirementSet(false, RequirementSet::MODE_OR); + $level1And->merge($level2FirstOr)->merge($level2SecondOr); + $level3FirstAnd = new RequirementSet(); + $level3SecondAnd = new RequirementSet(); + $level2FirstOr->merge($level3FirstAnd)->merge($level3SecondAnd); + $level2SecondOr->merge($level3FirstAnd)->merge($level3SecondAnd); + $level3FirstAnd->add($true)->add($true); + $level3SecondAnd->add($false)->add($true); + $this->assertTrue($level1And->fulfilled()); + + $level1Or = new RequirementSet(false, RequirementSet::MODE_OR); + $level2FirstAnd = new RequirementSet(); + $level2SecondAnd = new RequirementSet(); + $level1Or->merge($level2FirstAnd)->merge($level2SecondAnd); + $level3FirstOr = new RequirementSet(false, RequirementSet::MODE_OR); + $level3SecondOr = new RequirementSet(false, RequirementSet::MODE_OR); + $level2FirstAnd->merge($level3FirstOr)->merge($level3SecondOr); + $level2SecondAnd->merge($level3FirstOr)->merge($level3SecondOr); + $level3FirstOr->add($false); + $level3SecondOr->add($true); + $this->assertFalse($level1Or->fulfilled()); + } + + public function testNestedOptionalRequirementsOfDifferentTypes() + { + $true = new TrueRequirement(); + $false = new FalseRequirement(); + + $level1And = new RequirementSet(); + $level2FirstAnd = new RequirementSet(true); + $level2SecondAnd = new RequirementSet(true); + $level1And->merge($level2FirstAnd)->merge($level2SecondAnd); + $level3FirstOr = new RequirementSet(true, RequirementSet::MODE_OR); + $level3SecondOr = new RequirementSet(true, RequirementSet::MODE_OR); + $level2FirstAnd->merge($level3FirstOr)->merge($level3SecondOr); + $level2SecondAnd->merge($level3FirstOr)->merge($level3SecondOr); + $level3FirstOr->add($false); + $level3SecondOr->add($false); + $this->assertFalse($level1And->fulfilled()); + $this->assertTrue($level2FirstAnd->fulfilled()); + $this->assertTrue($level2SecondAnd->fulfilled()); + + $level1Or = new RequirementSet(false, RequirementSet::MODE_OR); + $level2FirstOr = new RequirementSet(true, RequirementSet::MODE_OR); + $level2SecondOr = new RequirementSet(true, RequirementSet::MODE_OR); + $level1Or->merge($level2FirstOr)->merge($level2SecondOr); + $level3FirstAnd = new RequirementSet(true); + $level3SecondAnd = new RequirementSet(true); + $level2FirstOr->merge($level3FirstAnd)->merge($level3SecondAnd); + $level2SecondOr->merge($level3FirstAnd)->merge($level3SecondAnd); + $level3FirstAnd->add($true)->add($true); + $level3SecondAnd->add($false)->add($true); + $this->assertTrue($level1Or->fulfilled()); + } + + public function testNestedMixedRequirementsOfDifferentTypes() + { + $this->markTestIncomplete(); + } +} From c44d5d2a735700e441fe9c9fcb3ade7d57991135 Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Tue, 10 Mar 2015 09:31:57 +0100 Subject: [PATCH 0911/2920] Use a custom RecursiveIteratorIterator to render a RequirementSet refs #8508 --- .../scripts/form/setup-requirements.phtml | 65 ++++----------- .../setup/library/Setup/RequirementSet.php | 11 +++ .../library/Setup/RequirementsRenderer.php | 83 +++++++++++++++++++ public/css/icinga/setup.less | 37 ++++++++- 4 files changed, 144 insertions(+), 52 deletions(-) create mode 100644 modules/setup/library/Setup/RequirementsRenderer.php diff --git a/modules/setup/application/views/scripts/form/setup-requirements.phtml b/modules/setup/application/views/scripts/form/setup-requirements.phtml index 9918df008..571a661b6 100644 --- a/modules/setup/application/views/scripts/form/setup-requirements.phtml +++ b/modules/setup/application/views/scripts/form/setup-requirements.phtml @@ -1,66 +1,35 @@ getRequirements(); -$iterator = new RecursiveIteratorIterator($requirements); +echo $requirements; ?> -
      escape($this->translate('Name')) ?>
      icon('host'); ?> translate('Host'); ?>translate('Output'); ?>icon('host'); ?> translate('Host'); ?>icon('paste'); ?> translate('Plugin Output'); ?>
      escape($host->getName()); ?>

      escape($host->host_output) ?>

      escape($host->getName()); ?>escape($host->host_output) ?>
      icon('service'); ?> translate('Service'); ?>icon('host'); ?> translate('Host'); ?>translate('Output'); ?>icon('service'); ?> translate('Service'); ?>icon('host'); ?> translate('Host'); ?>icon('paste'); ?> translate('Plugin Output'); ?>
      escape($service->getName()); ?>escape($service->getHost()->getName()); ?>

      escape($service->service_output) ?>

      escape($service->getName()); ?>escape($service->getHost()->getName()); ?>escape($service->service_output) ?>
      -
      +
      diff --git a/modules/monitoring/application/views/scripts/services/show.phtml b/modules/monitoring/application/views/scripts/services/show.phtml index 2933e6623..8ee61859a 100644 --- a/modules/monitoring/application/views/scripts/services/show.phtml +++ b/modules/monitoring/application/views/scripts/services/show.phtml @@ -12,7 +12,7 @@ use Icinga\Module\Monitoring\Forms\Command\Object\DeleteCommentCommandForm; render('partials/service/objects-header.phtml'); ?>
      -
      +

      icon('reschedule') ?> translate('Commands') ?> diff --git a/public/css/icinga/layout-structure.less b/public/css/icinga/layout-structure.less index a8f135712..3aa7da077 100644 --- a/public/css/icinga/layout-structure.less +++ b/public/css/icinga/layout-structure.less @@ -370,3 +370,7 @@ html { position: absolute; width: 1px; } + +.no-padding-top { + padding-top: 0em; +} diff --git a/public/css/icinga/monitoring-colors.less b/public/css/icinga/monitoring-colors.less index 609b3451c..ad80fbb45 100644 --- a/public/css/icinga/monitoring-colors.less +++ b/public/css/icinga/monitoring-colors.less @@ -929,10 +929,6 @@ table.statesummary { width: auto; border-collapse: separate; - tbody { - white-space: nowrap; - } - td { padding: 0em 0.4em 0em 0.4em; line-height: 1.2em; @@ -943,29 +939,27 @@ table.statesummary { font-weight: bold; } - td .pluginoutput { - font-size: 0.8em; + td { + font-size: 0.85em; line-height: 1.2em; - padding-left: 0; + padding-left: 0.2em; margin: 0; } td.state { + padding: 0.2em; min-width: 75px; - font-size: 0.7em; + font-size: 0.75em; text-align: center; } + td.name { + font-weight: bold; + } + td a { color: inherit; text-decoration: none; } } -/* Up to 576px for 1em=16px, should fit 320px devices */ -@media screen and (max-width: 97em) { - - table.statesummary .collapse { - display: none; - } -} diff --git a/public/css/icinga/widgets.less b/public/css/icinga/widgets.less index b6a41c234..7aaf8385e 100644 --- a/public/css/icinga/widgets.less +++ b/public/css/icinga/widgets.less @@ -272,6 +272,10 @@ li li .badge { background-color: @colorOk; } +.badge-up { + background-color: @colorOk; +} + .badge-pending { background-color: @colorPending; } @@ -323,3 +327,4 @@ li li .badge { white-space: nowrap; text-overflow: ellipsis; } + From c2c9e49df4a853afa7783439810ebb464a91281b Mon Sep 17 00:00:00 2001 From: Matthias Jentsch Date: Fri, 6 Mar 2015 15:01:52 +0100 Subject: [PATCH 0897/2920] Fix inconsistencies in text messages refs #8565 --- modules/monitoring/application/views/scripts/hosts/show.phtml | 4 ++-- .../monitoring/application/views/scripts/services/show.phtml | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/modules/monitoring/application/views/scripts/hosts/show.phtml b/modules/monitoring/application/views/scripts/hosts/show.phtml index 20338b08e..e5b3cd181 100644 --- a/modules/monitoring/application/views/scripts/hosts/show.phtml +++ b/modules/monitoring/application/views/scripts/hosts/show.phtml @@ -23,7 +23,7 @@ use Icinga\Module\Monitoring\Forms\Command\Object\DeleteCommentCommandForm; icon('reschedule') ?> translate('Commands') ?>

      - + translate('No hosts matching the filter'); ?> @@ -85,7 +85,7 @@ use Icinga\Module\Monitoring\Forms\Command\Object\DeleteCommentCommandForm;

      ' . $unhandledCount . '' ) ?> diff --git a/modules/monitoring/application/views/scripts/services/show.phtml b/modules/monitoring/application/views/scripts/services/show.phtml index 8ee61859a..bbd22df1a 100644 --- a/modules/monitoring/application/views/scripts/services/show.phtml +++ b/modules/monitoring/application/views/scripts/services/show.phtml @@ -21,7 +21,7 @@ use Icinga\Module\Monitoring\Forms\Command\Object\DeleteCommentCommandForm; translate('No services matching the filter'); ?> - +

      @@ -77,7 +77,7 @@ use Icinga\Module\Monitoring\Forms\Command\Object\DeleteCommentCommandForm;

      ' . $unhandledCount . '') ?>

      From 5c71f5a8ef0c16611042f4de96a7d3ae8c037ade Mon Sep 17 00:00:00 2001 From: Matthias Jentsch Date: Fri, 6 Mar 2015 15:13:08 +0100 Subject: [PATCH 0898/2920] Open list all links to the next container refs #8565 --- .../monitoring/application/views/scripts/hosts/show.phtml | 8 +++++--- .../application/views/scripts/services/show.phtml | 6 ++++-- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/modules/monitoring/application/views/scripts/hosts/show.phtml b/modules/monitoring/application/views/scripts/hosts/show.phtml index e5b3cd181..4c1d70ff6 100644 --- a/modules/monitoring/application/views/scripts/hosts/show.phtml +++ b/modules/monitoring/application/views/scripts/hosts/show.phtml @@ -151,9 +151,10 @@ use Icinga\Module\Monitoring\Forms\Command\Object\DeleteCommentCommandForm; ), $inDowntimeCount ) ?> qlink( - $this->translate('Alle anzeigen'), + $this->translate('List all'), $inDowntimeLink, - null + null, + array('data-base-target' => '_next') ); ?>

      @@ -174,7 +175,8 @@ use Icinga\Module\Monitoring\Forms\Command\Object\DeleteCommentCommandForm; qlink( $this->translate('List all'), $commentsLink, - null + null, + array('data-base-target' => '_next') ); ?>

      diff --git a/modules/monitoring/application/views/scripts/services/show.phtml b/modules/monitoring/application/views/scripts/services/show.phtml index bbd22df1a..d35125254 100644 --- a/modules/monitoring/application/views/scripts/services/show.phtml +++ b/modules/monitoring/application/views/scripts/services/show.phtml @@ -140,7 +140,8 @@ use Icinga\Module\Monitoring\Forms\Command\Object\DeleteCommentCommandForm; qlink( $this->translate('List all'), $inDowntimeLink, - null + null, + array('data-base-target' => '_next') );?>

      @@ -159,7 +160,8 @@ use Icinga\Module\Monitoring\Forms\Command\Object\DeleteCommentCommandForm; qlink( $this->translate('List all'), $commentsLink, - null + null, + array('data-base-target' => '_next') ); ?>

      From 2591f055d80df93fdc31a1888cc1ec09fdb60c7e Mon Sep 17 00:00:00 2001 From: Matthias Jentsch Date: Fri, 6 Mar 2015 15:22:14 +0100 Subject: [PATCH 0899/2920] Fix translation Remove calls to deprecated translation function. Always use plural forms for commands in multi-view to indicate that this will cause multiple commands to be issued. refs #8565 --- .../application/views/scripts/hosts/show.phtml | 16 ++++++++-------- .../scripts/partials/host/objects-header.phtml | 2 +- .../partials/service/objects-header.phtml | 5 ++++- .../views/scripts/services/show.phtml | 14 +++++++------- 4 files changed, 20 insertions(+), 17 deletions(-) diff --git a/modules/monitoring/application/views/scripts/hosts/show.phtml b/modules/monitoring/application/views/scripts/hosts/show.phtml index 4c1d70ff6..c8a4f9484 100644 --- a/modules/monitoring/application/views/scripts/hosts/show.phtml +++ b/modules/monitoring/application/views/scripts/hosts/show.phtml @@ -23,7 +23,7 @@ use Icinga\Module\Monitoring\Forms\Command\Object\DeleteCommentCommandForm; icon('reschedule') ?> translate('Commands') ?> - + translate('Issue commands to all %d selected hosts:'), count($objects)) ?> translate('No hosts matching the filter'); ?> @@ -36,7 +36,7 @@ use Icinga\Module\Monitoring\Forms\Command\Object\DeleteCommentCommandForm;

      qlink( - $this->translate('Reschedule the next check'), + $this->translate('Reschedule next checks'), $rescheduleAllLink, null, array('icon' => 'reschedule') @@ -45,7 +45,7 @@ use Icinga\Module\Monitoring\Forms\Command\Object\DeleteCommentCommandForm;
      qlink( - $this->translate('Schedule a downtime'), + $this->translate('Schedule downtimes'), $downtimeAllLink, null, array('icon' => 'plug') @@ -54,7 +54,7 @@ use Icinga\Module\Monitoring\Forms\Command\Object\DeleteCommentCommandForm;
      qlink( - $this->translate('Submit a passive check result'), + $this->translate('Submit passive check results'), $processCheckResultAllLink, null, array('icon' => 'reply') @@ -63,7 +63,7 @@ use Icinga\Module\Monitoring\Forms\Command\Object\DeleteCommentCommandForm;
      qlink( - $this->translate('Add a comment'), + $this->translate('Add comments'), $addCommentLink, null, array('icon' => 'comment') @@ -85,7 +85,7 @@ use Icinga\Module\Monitoring\Forms\Command\Object\DeleteCommentCommandForm;

      translate('There are %s unhandled problems. Issue commands to the problematic hosts:'), '' . $unhandledCount . '' ) ?> @@ -142,7 +142,7 @@ use Icinga\Module\Monitoring\Forms\Command\Object\DeleteCommentCommandForm; 0): ?> -

      translate('Downtimes') ?>

      +

      icon('plug', $this->translate('Downtimes'))?> translate('Downtimes')?>

      translatePlural( '%u Host currently in downtime.', @@ -161,7 +161,7 @@ use Icinga\Module\Monitoring\Forms\Command\Object\DeleteCommentCommandForm; getComments())) > 0): ?> -

      translate('Comments') ?>

      +

      icon('comment', $this->translate('Comments'))?> translate('Comments') ?>

      translatePlural( diff --git a/modules/monitoring/application/views/scripts/partials/host/objects-header.phtml b/modules/monitoring/application/views/scripts/partials/host/objects-header.phtml index 39445e277..c2f016ceb 100644 --- a/modules/monitoring/application/views/scripts/partials/host/objects-header.phtml +++ b/modules/monitoring/application/views/scripts/partials/host/objects-header.phtml @@ -74,7 +74,7 @@ $hiddenRich = array();

      - + translate('%d more ...'), count($hidden)) ?>
      service_state, true); ?>
      + service_handled && $service->service_state > 0): ?> icon('attention-alt', $this->translate('Unhandled')) ?> @@ -60,6 +62,7 @@ use Icinga\Web\Url; service_last_comment) && $service->service_last_comment !== null): ?> icon('comment', $this->translate('Last Comment: ') . $service->service_last_comment) ?> + escape($service->getName()); ?> escape($service->getHost()->getName()); ?>
      - + translate('%d more ...'), count($hidden)) ?>
      -
      +
      translate('%d more ...'), count($hidden)) ?>
      diff --git a/modules/monitoring/application/views/scripts/partials/host/objects-tinysummary.phtml b/modules/monitoring/application/views/scripts/partials/host/objects-tinysummary.phtml new file mode 100644 index 000000000..fa841c633 --- /dev/null +++ b/modules/monitoring/application/views/scripts/partials/host/objects-tinysummary.phtml @@ -0,0 +1,44 @@ + + +

      + qlink( + sprintf($this->translate('%d Hosts Selected:'), count($objects)), + $listAllLink + ); ?> + + + hosts_up): ?> + + + + hosts_up ?> + + + + + 'down', + 2 => 'unreachable', + 99 => 'pending' + ) as $stateId => $state) { + + $stateName = 'hosts_' . $state; + $unhandledStateName = $stateName . '_unhandled'; + if ($hostStates->$unhandledStateName) { + echo '' . $hostStates->$unhandledStateName . ''; + } + if ($hostStates->$stateName) { + echo '' . $hostStates->$stateName . ''; + } + if ($hostStates->$unhandledStateName) { + echo ''; + } + $stateName .= '_unhandled'; + }?> + + +

      \ No newline at end of file diff --git a/modules/monitoring/application/views/scripts/partials/service/objects-header.phtml b/modules/monitoring/application/views/scripts/partials/service/objects-header.phtml index 4501f0e7e..dd206a646 100644 --- a/modules/monitoring/application/views/scripts/partials/service/objects-header.phtml +++ b/modules/monitoring/application/views/scripts/partials/service/objects-header.phtml @@ -1,6 +1,5 @@ Date: Fri, 6 Mar 2015 17:30:59 +0100 Subject: [PATCH 0902/2920] Deduplicate state summary Use existing partials for rendering the state summary instead of a new one. refs #8565 --- .../controllers/HostsController.php | 14 +----- .../controllers/ServicesController.php | 36 +-------------- .../views/scripts/hosts/show.phtml | 2 +- .../partials/host/objects-tinysummary.phtml | 44 ------------------- .../service/objects-tinysummary.phtml | 42 ------------------ .../views/scripts/services/show.phtml | 2 +- .../library/Monitoring/Object/HostList.php | 27 ++++++++++++ .../library/Monitoring/Object/ObjectList.php | 11 +++++ .../library/Monitoring/Object/ServiceList.php | 42 ++++++++++++++++++ 9 files changed, 86 insertions(+), 134 deletions(-) delete mode 100644 modules/monitoring/application/views/scripts/partials/host/objects-tinysummary.phtml delete mode 100644 modules/monitoring/application/views/scripts/partials/service/objects-tinysummary.phtml diff --git a/modules/monitoring/application/controllers/HostsController.php b/modules/monitoring/application/controllers/HostsController.php index ec4e470a2..55f8a6e60 100644 --- a/modules/monitoring/application/controllers/HostsController.php +++ b/modules/monitoring/application/controllers/HostsController.php @@ -110,16 +110,7 @@ class Monitoring_HostsController extends Controller $acknowledgedObjects = array(); $objectsInDowntime = array(); $downtimeFilterExpressions = array(); - $hostStates = array( - 'hosts_' . Host::getStateText(Host::STATE_UP) => 0, - 'hosts_' . Host::getStateText(Host::STATE_UP) . '_unhandled' => 0, - 'hosts_' . Host::getStateText(Host::STATE_DOWN) => 0, - 'hosts_' . Host::getStateText(Host::STATE_DOWN) . '_unhandled' => 0, - 'hosts_' . Host::getStateText(Host::STATE_UNREACHABLE) => 0, - 'hosts_' . Host::getStateText(Host::STATE_UNREACHABLE) . '_unhandled' => 0, - 'hosts_' . Host::getStateText(Host::STATE_PENDING) => 0, - 'hosts_' . Host::getStateText(Host::STATE_PENDING) . '_unhandled' => 0, - ); + foreach ($this->hostList as $host) { /** @var Host $host */ $unhandled = (bool) $host->problem === true && (bool) $host->handled === false; @@ -134,7 +125,6 @@ class Monitoring_HostsController extends Controller $objectsInDowntime[] = $host; $downtimeFilterExpressions[] = Filter::where('downtime_host', $host->getName()); } - ++$hostStates['hosts_' . $host::getStateText($host->state) . ($unhandled ? '_unhandled' : '')]; } if (! empty($acknowledgedObjects)) { $removeAckForm = new RemoveAcknowledgementCommandForm(); @@ -150,7 +140,7 @@ class Monitoring_HostsController extends Controller $this->view->processCheckResultAllLink = Url::fromRequest()->setPath('monitoring/hosts/process-check-result'); $this->view->addCommentLink = Url::fromRequest()->setPath('monitoring/hosts/add-comment'); $this->view->deleteCommentLink = Url::fromRequest()->setPath('monitoring/hosts/delete-comment'); - $this->view->hostStates = (object)$hostStates; + $this->view->stats = (object)$this->hostList->getStateSummary(); $this->view->objects = $this->hostList; $this->view->unhandledObjects = $unhandledObjects; $unhandledFilterQueryString = Filter::matchAny($unhandledFilterExpressions)->toQueryString(); diff --git a/modules/monitoring/application/controllers/ServicesController.php b/modules/monitoring/application/controllers/ServicesController.php index 1514a0ea0..dcd95184c 100644 --- a/modules/monitoring/application/controllers/ServicesController.php +++ b/modules/monitoring/application/controllers/ServicesController.php @@ -132,35 +132,10 @@ class Monitoring_ServicesController extends Controller $acknowledgedObjects = array(); $objectsInDowntime = array(); $downtimeFilterExpressions = array(); - $serviceStates = array( - 'services_' . Service::getStateText(Service::STATE_OK) => 0, - 'services_' . Service::getStateText(Service::STATE_OK) . '_unhandled' => 0, - 'services_' . Service::getStateText(Service::STATE_WARNING) => 0, - 'services_' . Service::getStateText(Service::STATE_WARNING) . '_unhandled' => 0, - 'services_' . Service::getStateText(Service::STATE_CRITICAL) => 0, - 'services_' . Service::getStateText(Service::STATE_CRITICAL) . '_unhandled' => 0, - 'services_' . Service::getStateText(Service::STATE_UNKNOWN) => 0, - 'services_' . Service::getStateText(Service::STATE_UNKNOWN) . '_unhandled' => 0, - 'services_' . Service::getStateText(Service::STATE_PENDING) => 0, - 'services_' . Service::getStateText(Service::STATE_PENDING) . '_unhandled' => 0 - ); - $knownHostStates = array(); - $hostStates = array( - 'hosts_' . Host::getStateText(Host::STATE_UP) => 0, - 'hosts_' . Host::getStateText(Host::STATE_UP) . '_unhandled' => 0, - 'hosts_' . Host::getStateText(Host::STATE_DOWN) => 0, - 'hosts_' . Host::getStateText(Host::STATE_DOWN) . '_unhandled' => 0, - 'hosts_' . Host::getStateText(Host::STATE_UNREACHABLE) => 0, - 'hosts_' . Host::getStateText(Host::STATE_UNREACHABLE) . '_unhandled' => 0, - 'hosts_' . Host::getStateText(Host::STATE_PENDING) => 0, - 'hosts_' . Host::getStateText(Host::STATE_PENDING) . '_unhandled' => 0 - ); - foreach ($this->serviceList as $service) { - $unhandled = false; + foreach ($this->serviceList as $service) { /** @var Service $service */ if ((bool) $service->problem === true && (bool) $service->handled === false) { - $unhandled = true; $unhandledObjects[] = $service; $unhandledFilterExpressions[] = Filter::matchAll( Filter::where('host', $service->getHost()->getName()), @@ -177,12 +152,6 @@ class Monitoring_ServicesController extends Controller Filter::where('downtime_service', $service->getName()) ); } - - ++$serviceStates['services_' . $service::getStateText($service->state) . ($unhandled ? '_unhandled' : '')]; - if (! isset($knownHostStates[$service->getHost()->getName()])) { - $knownHostStates[$service->getHost()->getName()] = true; - ++$hostStates['hosts_' . $service->getHost()->getStateText($service->host_state)]; - } } if (! empty($acknowledgedObjects)) { $removeAckForm = new RemoveAcknowledgementCommandForm(); @@ -208,8 +177,7 @@ class Monitoring_ServicesController extends Controller ); $this->view->addCommentLink = Url::fromRequest()->setPath('monitoring/services/add-comment'); $this->view->deleteCommentLink = Url::fromRequest()->setPath('monitoring/services/delete-comment'); - $this->view->hostStates = (object)$hostStates; - $this->view->serviceStates = (object)$serviceStates; + $this->view->stats = $this->serviceList->getStateSummary(); $this->view->objects = $this->serviceList; $this->view->unhandledObjects = $unhandledObjects; $unhandledFilterQueryString = Filter::matchAny($unhandledFilterExpressions)->toQueryString(); diff --git a/modules/monitoring/application/views/scripts/hosts/show.phtml b/modules/monitoring/application/views/scripts/hosts/show.phtml index f4ac40904..d56f92af4 100644 --- a/modules/monitoring/application/views/scripts/hosts/show.phtml +++ b/modules/monitoring/application/views/scripts/hosts/show.phtml @@ -8,7 +8,7 @@ use Icinga\Module\Monitoring\Forms\Command\Object\DeleteCommentCommandForm; - render('partials/host/objects-tinysummary.phtml') ?> + render('list/components/hostssummary.phtml') ?> render('partials/host/objects-header.phtml'); ?>
      diff --git a/modules/monitoring/application/views/scripts/partials/host/objects-tinysummary.phtml b/modules/monitoring/application/views/scripts/partials/host/objects-tinysummary.phtml deleted file mode 100644 index fa841c633..000000000 --- a/modules/monitoring/application/views/scripts/partials/host/objects-tinysummary.phtml +++ /dev/null @@ -1,44 +0,0 @@ - - -

      - qlink( - sprintf($this->translate('%d Hosts Selected:'), count($objects)), - $listAllLink - ); ?> - - - hosts_up): ?> - - - - hosts_up ?> - - - - - 'down', - 2 => 'unreachable', - 99 => 'pending' - ) as $stateId => $state) { - - $stateName = 'hosts_' . $state; - $unhandledStateName = $stateName . '_unhandled'; - if ($hostStates->$unhandledStateName) { - echo '' . $hostStates->$unhandledStateName . ''; - } - if ($hostStates->$stateName) { - echo '' . $hostStates->$stateName . ''; - } - if ($hostStates->$unhandledStateName) { - echo ''; - } - $stateName .= '_unhandled'; - }?> - - -

      \ No newline at end of file diff --git a/modules/monitoring/application/views/scripts/partials/service/objects-tinysummary.phtml b/modules/monitoring/application/views/scripts/partials/service/objects-tinysummary.phtml deleted file mode 100644 index 7707651d2..000000000 --- a/modules/monitoring/application/views/scripts/partials/service/objects-tinysummary.phtml +++ /dev/null @@ -1,42 +0,0 @@ - - -

      - qlink( - sprintf($this->translate('%d Services Selected:'), count($objects)), - $listAllLink - ); ?> - - - services_ok): ?> - - - services_ok ?> - - - - 'critical', - 3 => 'unknown', - 1 => 'warning', - 4 => 'pending' - ) as $stateId => $state) { - - $stateName = 'services_' . $state; - $unhandledStateName = $stateName . '_unhandled'; - if ($serviceStates->$unhandledStateName) { - echo '' . $serviceStates->$unhandledStateName . ''; - } - if ($serviceStates->$stateName) { - echo '' . $serviceStates->$stateName . ''; - } - if ($serviceStates->$unhandledStateName) { - echo ''; - } - $stateName .= '_unhandled'; - }?> - -

      \ No newline at end of file diff --git a/modules/monitoring/application/views/scripts/services/show.phtml b/modules/monitoring/application/views/scripts/services/show.phtml index 08e1737f3..1daa1a956 100644 --- a/modules/monitoring/application/views/scripts/services/show.phtml +++ b/modules/monitoring/application/views/scripts/services/show.phtml @@ -8,7 +8,7 @@ use Icinga\Module\Monitoring\Forms\Command\Object\DeleteCommentCommandForm; - render('partials/service/objects-tinysummary.phtml') ?> + render('list/components/servicesummary.phtml') ?> render('partials/service/objects-header.phtml'); ?> diff --git a/modules/monitoring/library/Monitoring/Object/HostList.php b/modules/monitoring/library/Monitoring/Object/HostList.php index f0adced24..94157b6fc 100644 --- a/modules/monitoring/library/Monitoring/Object/HostList.php +++ b/modules/monitoring/library/Monitoring/Object/HostList.php @@ -25,4 +25,31 @@ class HostList extends ObjectList } return $hosts; } + + /** + * Create a state summary of all hosts that can be consumed by hostssummary.phtml + * + * @return object The summary + */ + public function getStateSummary() + { + $hostStates = $this->prepareStateNames('hosts_', array( + Host::getStateText(Host::STATE_UP), + Host::getStateText(Host::STATE_DOWN), + Host::getStateText(Host::STATE_UNREACHABLE), + Host::getStateText(Host::STATE_PENDING) + )); + + foreach ($this as $host) { + $unhandled = (bool) $host->problem === true && (bool) $host->handled === false; + + $stateName = 'hosts_' . $host::getStateText($host->state); + ++$hostStates[$stateName]; + ++$hostStates[$stateName. ($unhandled ? '_unhandled' : '_handled')]; + } + + $hostStates['hosts_total'] = count($this); + + return (object)$hostStates; + } } diff --git a/modules/monitoring/library/Monitoring/Object/ObjectList.php b/modules/monitoring/library/Monitoring/Object/ObjectList.php index 146499805..234ccb9bb 100644 --- a/modules/monitoring/library/Monitoring/Object/ObjectList.php +++ b/modules/monitoring/library/Monitoring/Object/ObjectList.php @@ -85,4 +85,15 @@ abstract class ObjectList implements Countable, IteratorAggregate { return $this->backend->select()->from('comment')->applyFilter($this->filter); } + + protected function prepareStateNames($prefix, array $names) { + $new = array(); + foreach ($names as $name) { + $new[$prefix . $name] = 0; + $new[$prefix . $name . '_handled'] = 0; + $new[$prefix . $name . '_unhandled'] = 0; + } + $new[$prefix . 'total'] = 0; + return $new; + } } diff --git a/modules/monitoring/library/Monitoring/Object/ServiceList.php b/modules/monitoring/library/Monitoring/Object/ServiceList.php index d9ffa0d8e..0625ae0f8 100644 --- a/modules/monitoring/library/Monitoring/Object/ServiceList.php +++ b/modules/monitoring/library/Monitoring/Object/ServiceList.php @@ -25,4 +25,46 @@ class ServiceList extends ObjectList } return $services; } + + /** + * Create a state summary of all services that can be consumed by servicesummary.phtml + * + * @return object The summary + */ + public function getStateSummary() + { + $serviceStates = $this->prepareStateNames('services_', array( + Service::getStateText(Service::STATE_OK), + Service::getStateText(Service::STATE_WARNING), + Service::getStateText(Service::STATE_CRITICAL), + Service::getStateText(Service::STATE_UNKNOWN), + Service::getStateText(Service::STATE_PENDING), + )); + + $hostStates = $this->prepareStateNames('hosts_', array( + Host::getStateText(Host::STATE_UP), + Host::getStateText(Host::STATE_DOWN), + Host::getStateText(Host::STATE_UNREACHABLE), + Host::getStateText(Host::STATE_PENDING), + )); + + foreach ($this as $service) { + $unhandled = false; + if ((bool) $service->problem === true && (bool) $service->handled === false) { + $unhandled = true; + } + + $stateName = 'services_' . $service::getStateText($service->state); + ++$serviceStates[$stateName]; + ++$serviceStates[$stateName . ($unhandled ? '_unhandled' : '_handled')]; + if (! isset($knownHostStates[$service->getHost()->getName()])) { + $knownHostStates[$service->getHost()->getName()] = true; + ++$hostStates['hosts_' . $service->getHost()->getStateText($service->host_state)]; + } + } + + $serviceStates['services_total'] = count($this); + + return (object)$serviceStates; + } } From 266e781a93d77473a0bc3c02a7cdcafb9df63d4b Mon Sep 17 00:00:00 2001 From: Matthias Jentsch Date: Fri, 6 Mar 2015 17:52:06 +0100 Subject: [PATCH 0903/2920] Deduplicate Hosts and Services-Controller Create functions in abstract class for filtering hosts and services, instead of reimplementing it in the controller. --- .../controllers/HostsController.php | 30 +++++--------- .../controllers/ServicesController.php | 41 ++++++++----------- .../library/Monitoring/Object/ObjectList.php | 33 +++++++++++++++ 3 files changed, 61 insertions(+), 43 deletions(-) diff --git a/modules/monitoring/application/controllers/HostsController.php b/modules/monitoring/application/controllers/HostsController.php index 55f8a6e60..ecbf6cf71 100644 --- a/modules/monitoring/application/controllers/HostsController.php +++ b/modules/monitoring/application/controllers/HostsController.php @@ -105,27 +105,19 @@ class Monitoring_HostsController extends Controller 'host_active_checks_enabled', 'host_obsessing'*/ )); - $unhandledObjects = array(); + $unhandledObjects = $this->hostList->getUnhandledObjects(); $unhandledFilterExpressions = array(); - $acknowledgedObjects = array(); - $objectsInDowntime = array(); - $downtimeFilterExpressions = array(); - - foreach ($this->hostList as $host) { - /** @var Host $host */ - $unhandled = (bool) $host->problem === true && (bool) $host->handled === false; - if ($unhandled) { - $unhandledObjects[] = $host; - $unhandledFilterExpressions[] = Filter::where('host', $host->getName()); - } - if ((bool) $host->acknowledged === true) { - $acknowledgedObjects[] = $host; - } - if ((bool) $host->in_downtime === true) { - $objectsInDowntime[] = $host; - $downtimeFilterExpressions[] = Filter::where('downtime_host', $host->getName()); - } + foreach ($unhandledObjects as $object) { + $unhandledFilterExpressions[] = Filter::where('host', $object->getName()); } + + $objectsInDowntime = $this->hostList->getObjectsInDowntime(); + $downtimeFilterExpressions = array(); + foreach ($objectsInDowntime as $object) { + $downtimeFilterExpressions[] = Filter::where('downtime_host', $object->getName()); + } + + $acknowledgedObjects = $this->hostList->getAcknowledgedObjects(); if (! empty($acknowledgedObjects)) { $removeAckForm = new RemoveAcknowledgementCommandForm(); $removeAckForm diff --git a/modules/monitoring/application/controllers/ServicesController.php b/modules/monitoring/application/controllers/ServicesController.php index dcd95184c..691897a57 100644 --- a/modules/monitoring/application/controllers/ServicesController.php +++ b/modules/monitoring/application/controllers/ServicesController.php @@ -127,32 +127,25 @@ class Monitoring_ServicesController extends Controller 'service_active_checks_enabled', 'service_obsessing'*/ )); - $unhandledObjects = array(); + $unhandledObjects = $this->serviceList->getUnhandledObjects(); $unhandledFilterExpressions = array(); - $acknowledgedObjects = array(); - $objectsInDowntime = array(); - $downtimeFilterExpressions = array(); - - foreach ($this->serviceList as $service) { - /** @var Service $service */ - if ((bool) $service->problem === true && (bool) $service->handled === false) { - $unhandledObjects[] = $service; - $unhandledFilterExpressions[] = Filter::matchAll( - Filter::where('host', $service->getHost()->getName()), - Filter::where('service', $service->getName()) - ); - } - if ((bool) $service->acknowledged === true) { - $acknowledgedObjects[] = $service; - } - if ((bool) $service->in_downtime === true) { - $objectsInDowntime[] = $service; - $downtimeFilterExpressions[] = Filter::matchAll( - Filter::where('downtime_host', $service->getHost()->getName()), - Filter::where('downtime_service', $service->getName()) - ); - } + foreach ($unhandledObjects as $service) { + $unhandledFilterExpressions[] = Filter::matchAll( + Filter::where('host', $service->getHost()->getName()), + Filter::where('service', $service->getName()) + ); } + + $objectsInDowntime = $this->serviceList->getObjectsInDowntime(); + $downtimeFilterExpressions = array(); + foreach ($objectsInDowntime as $service) { + $downtimeFilterExpressions[] = Filter::matchAll( + Filter::where('downtime_host', $service->getHost()->getName()), + Filter::where('downtime_service', $service->getName()) + ); + } + + $acknowledgedObjects = $this->serviceList->getAcknowledgedObjects(); if (! empty($acknowledgedObjects)) { $removeAckForm = new RemoveAcknowledgementCommandForm(); $removeAckForm diff --git a/modules/monitoring/library/Monitoring/Object/ObjectList.php b/modules/monitoring/library/Monitoring/Object/ObjectList.php index 234ccb9bb..f28dded91 100644 --- a/modules/monitoring/library/Monitoring/Object/ObjectList.php +++ b/modules/monitoring/library/Monitoring/Object/ObjectList.php @@ -86,6 +86,39 @@ abstract class ObjectList implements Countable, IteratorAggregate return $this->backend->select()->from('comment')->applyFilter($this->filter); } + public function getAcknowledgedObjects() + { + $acknowledgedObjects = array(); + foreach ($this as $object) { + if ((bool) $object->acknowledged === true) { + $acknowledgedObjects[] = $object; + } + } + return $acknowledgedObjects; + } + + public function getObjectsInDowntime() + { + $objectsInDowntime = array(); + foreach ($this as $object) { + if ((bool) $object->in_downtime === true) { + $objectsInDowntime[] = $object; + } + } + return $objectsInDowntime; + } + + public function getUnhandledObjects() + { + $unhandledObjects = array(); + foreach ($this as $object) { + if ((bool) $object->problem === true && (bool) $object->handled === false) { + $unhandledObjects[] = $object; + } + } + return $unhandledObjects; + } + protected function prepareStateNames($prefix, array $names) { $new = array(); foreach ($names as $name) { From 95a83a41bd80a1b41aa94cb4b8b200f0eadb38ba Mon Sep 17 00:00:00 2001 From: Matthias Jentsch Date: Fri, 6 Mar 2015 18:03:56 +0100 Subject: [PATCH 0904/2920] Provide a link back to all selected objects in multi-views refs #8565 --- .../monitoring/application/controllers/HostsController.php | 3 ++- .../views/scripts/partials/host/objects-header.phtml | 7 ++++++- .../views/scripts/partials/service/objects-header.phtml | 7 ++++++- 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/modules/monitoring/application/controllers/HostsController.php b/modules/monitoring/application/controllers/HostsController.php index ecbf6cf71..b8e36e2b0 100644 --- a/modules/monitoring/application/controllers/HostsController.php +++ b/modules/monitoring/application/controllers/HostsController.php @@ -39,6 +39,7 @@ class Monitoring_HostsController extends Controller 'icon' => 'host' ) )->activate('show'); + $this->view->listAllLink = Url::fromRequest()->setPath('monitoring/list/hosts'); } protected function handleCommandForm(ObjectsCommandForm $form) @@ -125,8 +126,8 @@ class Monitoring_HostsController extends Controller ->handleRequest(); $this->view->removeAckForm = $removeAckForm; } + $this->setAutorefreshInterval(15); - $this->view->listAllLink = Url::fromRequest()->setPath('monitoring/list/hosts'); $this->view->rescheduleAllLink = Url::fromRequest()->setPath('monitoring/hosts/reschedule-check'); $this->view->downtimeAllLink = Url::fromRequest()->setPath('monitoring/hosts/schedule-downtime'); $this->view->processCheckResultAllLink = Url::fromRequest()->setPath('monitoring/hosts/process-check-result'); diff --git a/modules/monitoring/application/views/scripts/partials/host/objects-header.phtml b/modules/monitoring/application/views/scripts/partials/host/objects-header.phtml index d535f367e..322243be1 100644 --- a/modules/monitoring/application/views/scripts/partials/host/objects-header.phtml +++ b/modules/monitoring/application/views/scripts/partials/host/objects-header.phtml @@ -72,7 +72,12 @@ $hiddenRich = array();
      - translate('%d more ...'), count($hidden)) ?> + + qlink( + sprintf($this->translate('%d more ...'), count($hidden)), + $listAllLink, + null + ) ?>
      - translate('%d more ...'), count($hidden)) ?> + + qlink( + sprintf($this->translate('%d more ...'), count($hidden)), + $listAllLink, + null + ) ?>
      - - - - - - - - - - - - - - -

      getTitle(); ?>

      - getDescriptions(); ?> - 1): ?> -
        - -
      • - -
      - - - -
      getStateText(); ?>
      -
      - translate('You may also need to restart the web-server for the changes to take effect!'); ?> - qlink( - $this->translate('Refresh'), - null, - null, - array( - 'class' => 'button-like', - 'title' => $title, - 'aria-label' => sprintf($this->translate('Refresh the page; %s'), $title) - ) - ); ?> -
      -
      +
      + translate('You may also need to restart the web-server for the changes to take effect!'); ?> + qlink( + $this->translate('Refresh'), + null, + null, + array( + 'class' => 'button-like', + 'title' => $title, + 'aria-label' => sprintf($this->translate('Refresh the page; %s'), $title) + ) + ); ?> +
      getElement($form->getTokenElementName()); ?> getElement($form->getUidElementName()); ?> -
      +
      getElement(Wizard::BTN_PREV); ?> getElement(Wizard::BTN_NEXT); - if (false === $requirements->fulfilled()) { + if (! $requirements->fulfilled()) { $btn->setAttrib('disabled', 1); } echo $btn; ?>
      - + \ No newline at end of file diff --git a/modules/setup/library/Setup/RequirementSet.php b/modules/setup/library/Setup/RequirementSet.php index 966cf98cc..8bb018d7b 100644 --- a/modules/setup/library/Setup/RequirementSet.php +++ b/modules/setup/library/Setup/RequirementSet.php @@ -319,4 +319,15 @@ class RequirementSet implements RecursiveIterator { next($this->requirements); } + + /** + * Return this set of requirements rendered as HTML + * + * @return string + */ + public function __toString() + { + $renderer = new RequirementsRenderer($this); + return (string) $renderer; + } } diff --git a/modules/setup/library/Setup/RequirementsRenderer.php b/modules/setup/library/Setup/RequirementsRenderer.php new file mode 100644 index 000000000..b768a1e86 --- /dev/null +++ b/modules/setup/library/Setup/RequirementsRenderer.php @@ -0,0 +1,83 @@ +tags[] = ''; + $this->tags[] = ''; + } + + public function endIteration() + { + $this->tags[] = ''; + $this->tags[] = '
      '; + } + + public function beginChildren() + { + $this->tags[] = '
    '; + $this->beginIteration(); + } + + public function endChildren() + { + $this->endIteration(); + $this->tags[] = '

    ' . $requirement->getTitle() . '

    '; + $descriptions = $requirement->getDescriptions(); + if (count($descriptions) > 1) { + $this->tags[] = '
      '; + foreach ($descriptions as $d) { + $this->tags[] = '
    • ' . $d . '
    • '; + } + $this->tags[] = '
    '; + } elseif (! empty($descriptions)) { + $this->tags[] = $descriptions[0]; + } + $this->tags[] = '
    ' . $requirement->getStateText() . '
    ' . t('User Object Class') . '' . mt('setup', 'User Object Class') . '' . $this->data['backendConfig']['user_class'] . '
    ' . t('User Name Attribute') . '' . mt('setup', 'Custom Filter') . '' . trim($this->data['backendConfig']['filter']) ?: t('None', 'auth.ldap.filter') . '
    ' . mt('setup', 'User Name Attribute') . '' . $this->data['backendConfig']['user_name_attribute'] . '