-
data-icinga-module="" data-icinga-url="" style="display: block"> +
data-icinga-module="" data-icinga-url="without('renderLayout') ?>" style="display: block"> render('inline.phtml') ?>
From 17b64f9dd5098c1f7d73b1134970d4e8bb813104 Mon Sep 17 00:00:00 2001 From: Thomas Gelf Date: Tue, 19 Aug 2014 10:13:19 +0200 Subject: [PATCH 111/159] layout: add favicon fixes #6956 --- application/layouts/scripts/layout.phtml | 1 + public/img/favicon.png | Bin 0 -> 451 bytes 2 files changed, 1 insertion(+) create mode 100644 public/img/favicon.png diff --git a/application/layouts/scripts/layout.phtml b/application/layouts/scripts/layout.phtml index b4fd504ed..765873c02 100644 --- a/application/layouts/scripts/layout.phtml +++ b/application/layouts/scripts/layout.phtml @@ -44,6 +44,7 @@ $iframeClass = $isIframe ? ' iframe' : ''; + diff --git a/public/img/favicon.png b/public/img/favicon.png new file mode 100644 index 0000000000000000000000000000000000000000..6d6f713986903f1ab05631fdeba40bd5aa433d27 GIT binary patch literal 451 zcmeAS@N?(olHy`uVBq!ia0vp^3LwnE3?yBabR7dyk|nMYCBgY=CFO}lsSJ)O`AMk? zp1FzXsX?iUDV2pMQ*D5XECYN(Tvg;1{{R1Pq^mcne}b>4*T;_^qr)SvUA<~=Z8NdI zzooJ1#PQ=#9zV`VP20V5XIXK{+SRM)&z%d@a^;b83(yeZk|4ieAQufVY^uG(!N9=C z=;`7ZQgN$iGAG|*1s;}-XL)!2`hWb|l*JtmQQjVmY@2g(KK>GHYIio|Es>mXc-OVJ z!DBE1_kBYs!znukC5cxl;Rk|kQyjlnFh)dbXs3$^ zD`*~`^x%h7lC*-dM)QmBwl%^V6ryVx#|1*4HKL{#+L2&`L>w3hB3ij zIa_Tn>mj)XTuaW*4CJ*?Kkri*azLM9V(UYK&9 zwcsv;%}&1TsVdFx3Mz%mbaGqF6;4mzeD4M0UIvSY$CXTT*WIx&3jJi#sJ*s5%Kvxp gzw3L>e-uk#C{W~+XO_F201PVzPgg&ebxsLQ0Ka>@YXATM literal 0 HcmV?d00001 From f67d273bbdca6a77fc2ee66e936a6b90869b3a66 Mon Sep 17 00:00:00 2001 From: Thomas Gelf Date: Tue, 19 Aug 2014 10:14:46 +0200 Subject: [PATCH 112/159] AuthenticationController: handle redirect parameter This is a form field instead of a get parameter right now. fixes #6584 --- .../controllers/AuthenticationController.php | 29 ++++++++++++++----- 1 file changed, 21 insertions(+), 8 deletions(-) diff --git a/application/controllers/AuthenticationController.php b/application/controllers/AuthenticationController.php index 7d4864d5a..a6a5345ed 100644 --- a/application/controllers/AuthenticationController.php +++ b/application/controllers/AuthenticationController.php @@ -35,12 +35,17 @@ class AuthenticationController extends ActionController public function loginAction() { $auth = $this->Auth(); - $this->view->form = new LoginForm(); - $this->view->form->setRequest($this->_request); + $this->view->form = $form = new LoginForm(); + $form->setRequest($this->_request); $this->view->title = $this->translate('Icingaweb Login'); try { - $redirectUrl = Url::fromPath($this->params->get('redirect', 'dashboard')); + $redirectUrl = $this->view->form->getValue('redirect'); + if ($redirectUrl) { + $redirectUrl = Url::fromPath($redirectUrl); + } else { + $redirectUrl = Url::fromPath('dashboard'); + } if ($auth->isAuthenticated()) { $this->rerenderLayout()->redirectNow($redirectUrl); @@ -72,12 +77,20 @@ class AuthenticationController extends ActionController } } } - } elseif ($this->view->form->isSubmittedAndValid()) { - $user = new User($this->view->form->getValue('username')); - $password = $this->view->form->getValue('password'); + } elseif ($form->isSubmittedAndValid()) { + $user = new User($form->getValue('username')); + $password = $form->getValue('password'); $backendsTried = 0; $backendsWithError = 0; + $redirectUrl = $form->getValue('redirect'); + + if ($redirectUrl) { + $redirectUrl = Url::fromPath($redirectUrl); + } else { + $redirectUrl = Url::fromPath('dashboard'); + } + foreach ($chain as $backend) { if ($backend instanceof AutoLoginBackend) { continue; @@ -112,14 +125,14 @@ class AuthenticationController extends ActionController ); } if ($backendsWithError) { - $this->view->form->addNote( + $form->addNote( $this->translate( 'Note that not all authentication backends are available for authentication because they' . ' have errors. Please check the system log or Icinga Web 2 log for more information' ) ); } - $this->view->form->getElement('password')->addError($this->translate('Incorrect username or password')); + $form->getElement('password')->addError($this->translate('Incorrect username or password')); } } catch (Exception $e) { $this->view->errorInfo = $e->getMessage(); From 5c52e447f5d01df93c8e101848193384a9373e2f Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Tue, 19 Aug 2014 10:26:38 +0200 Subject: [PATCH 113/159] doc: upper case first character of a documentation's title refs #4820 --- modules/doc/application/views/scripts/toc.phtml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/doc/application/views/scripts/toc.phtml b/modules/doc/application/views/scripts/toc.phtml index 8ffe2820d..7e92a6b26 100644 --- a/modules/doc/application/views/scripts/toc.phtml +++ b/modules/doc/application/views/scripts/toc.phtml @@ -1,5 +1,5 @@
-

translate('Documentation'); ?>

+

translate(sprintf('%s Documentation', ucfirst($docName))); ?>

render($this, $this->getHelper('Url')); ?> From a38d71f17c652720f5887fc8cfe843edd7e305c3 Mon Sep 17 00:00:00 2001 From: Thomas Gelf Date: Tue, 19 Aug 2014 10:27:26 +0200 Subject: [PATCH 114/159] Cli\Command: provide Config() This makes it feel more like action controllers fixes #6954 --- library/Icinga/Cli/Command.php | 50 ++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) diff --git a/library/Icinga/Cli/Command.php b/library/Icinga/Cli/Command.php index 081be318c..acb2462e4 100644 --- a/library/Icinga/Cli/Command.php +++ b/library/Icinga/Cli/Command.php @@ -7,6 +7,7 @@ namespace Icinga\Cli; use Icinga\Cli\Screen; use Icinga\Util\Translator; use Icinga\Cli\Params; +use Icinga\Application\Config; use Icinga\Application\ApplicationBootstrap as App; use Exception; @@ -23,6 +24,10 @@ abstract class Command protected $commandName; protected $actionName; + private $config; + + private $configs; + protected $defaultActionName = 'default'; public function __construct(App $app, $moduleName, $commandName, $actionName, $initialize = true) @@ -41,6 +46,51 @@ abstract class Command } } + public function Config($file = null) + { + if ($this->isModule()) { + return $this->getModuleConfig($file); + } else { + return $this->getMainConfig($file); + } + } + + private function getModuleConfig($file = null) + { + if ($file === null) { + if ($this->config === null) { + $this->config = Config::module($this->moduleName); + } + return $this->config; + } else { + if (! array_key_exists($file, $this->configs)) { + $this->configs[$file] = Config::module($this->moduleName, $file); + } + return $this->configs[$file]; + } + } + + private function getMainConfig($file = null) + { + if ($file === null) { + if ($this->config === null) { + $this->config = Config::app(); + } + return $this->config; + } else { + if (! array_key_exists($file, $this->configs)) { + $this->configs[$file] = Config::module($module, $file); + } + return $this->configs[$file]; + } + return $this->config; + } + + public function isModule() + { + return substr(get_class($this), 0, 14) === 'Icinga\\Module\\'; + } + public function setParams(Params $params) { $this->params = $params; From c69af6c5d2f72e6c3d93bc94703935ce7426dbf1 Mon Sep 17 00:00:00 2001 From: Alexander Fuhr Date: Tue, 19 Aug 2014 11:10:01 +0200 Subject: [PATCH 115/159] Move "modules" to "System" menu resolves #6934 --- .vagrant-puppet/files/etc/icingaweb/menu.ini | 7 ++++++- application/controllers/ConfigController.php | 3 --- config/menu.ini | 7 ++++++- 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/.vagrant-puppet/files/etc/icingaweb/menu.ini b/.vagrant-puppet/files/etc/icingaweb/menu.ini index f01ebaecc..d6f342655 100644 --- a/.vagrant-puppet/files/etc/icingaweb/menu.ini +++ b/.vagrant-puppet/files/etc/icingaweb/menu.ini @@ -18,10 +18,15 @@ title = "Configuration" url = "config" priority = 300 +[System.Modules] +title = "Modules" +url = "config/modules" +priority = 400 + [System.ApplicationLog] title = "Application log" url = "list/applicationlog" -priority = 400 +priority = 500 [Logout] url = "authentication/logout" diff --git a/application/controllers/ConfigController.php b/application/controllers/ConfigController.php index 31739c30e..df189f47f 100644 --- a/application/controllers/ConfigController.php +++ b/application/controllers/ConfigController.php @@ -48,9 +48,6 @@ class ConfigController extends BaseConfigController ))->add('logging', array( 'title' => 'Logging', 'url' => 'config/logging' - ))->add('modules', array( - 'title' => 'Modules', - 'url' => 'config/modules' )); } diff --git a/config/menu.ini b/config/menu.ini index 65959c93a..075f4230e 100644 --- a/config/menu.ini +++ b/config/menu.ini @@ -18,10 +18,15 @@ title = "Configuration" url = "config" priority = 300 +[System.Modules] +title = "Modules" +url = "config/modules" +priority = 400 + [System.ApplicationLog] title = "Application log" url = "list/applicationlog" -priority = 400 +priority = 500 [Logout] url = "authentication/logout" From 046409976458753a322a9527fef8e7c7499a6942 Mon Sep 17 00:00:00 2001 From: Alexander Klimov Date: Tue, 19 Aug 2014 11:19:30 +0200 Subject: [PATCH 116/159] Monitoring: implement "Security" config tab --- .../monitoring/application/controllers/ConfigController.php | 5 +++++ .../application/views/scripts/config/security.phtml | 3 +++ modules/monitoring/configuration.php | 5 ++++- 3 files changed, 12 insertions(+), 1 deletion(-) create mode 100644 modules/monitoring/application/views/scripts/config/security.phtml diff --git a/modules/monitoring/application/controllers/ConfigController.php b/modules/monitoring/application/controllers/ConfigController.php index c06ded57f..d777390a8 100644 --- a/modules/monitoring/application/controllers/ConfigController.php +++ b/modules/monitoring/application/controllers/ConfigController.php @@ -258,4 +258,9 @@ class Monitoring_ConfigController extends ModuleActionController $instanceCfg = $this->Config('instances'); return $instanceCfg && $instanceCfg->get($instance); } + + public function securityAction() + { + $this->view->tabs = $this->Module()->getConfigTabs()->activate('security'); + } } diff --git a/modules/monitoring/application/views/scripts/config/security.phtml b/modules/monitoring/application/views/scripts/config/security.phtml new file mode 100644 index 000000000..87b22b9ac --- /dev/null +++ b/modules/monitoring/application/views/scripts/config/security.phtml @@ -0,0 +1,3 @@ +
+ tabs ?> +
diff --git a/modules/monitoring/configuration.php b/modules/monitoring/configuration.php index ffd769482..479ee525f 100644 --- a/modules/monitoring/configuration.php +++ b/modules/monitoring/configuration.php @@ -12,4 +12,7 @@ $this->provideConfigTab('backends', array( 'title' => 'Backends', 'url' => 'config' )); - +$this->provideConfigTab('security', array( + 'title' => 'Security', + 'url' => 'config/security' +)); From 127e4f444f7536f1bba601c46e2a097bfa03f42c Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Tue, 19 Aug 2014 11:30:56 +0200 Subject: [PATCH 117/159] doc: show prev chapter, index and next chapter links refs #4820 --- .../controllers/IcingawebController.php | 7 +- .../controllers/ModuleController.php | 1 + .../doc/application/views/scripts/toc.phtml | 2 +- modules/doc/library/Doc/DocController.php | 5 +- modules/doc/library/Doc/SectionRenderer.php | 79 ++++++++++++++++++- modules/doc/library/Doc/TocRenderer.php | 2 +- modules/doc/public/css/module.less | 19 +++++ 7 files changed, 108 insertions(+), 7 deletions(-) diff --git a/modules/doc/application/controllers/IcingawebController.php b/modules/doc/application/controllers/IcingawebController.php index 117d6eb0e..967a2b768 100644 --- a/modules/doc/application/controllers/IcingawebController.php +++ b/modules/doc/application/controllers/IcingawebController.php @@ -30,7 +30,12 @@ class Doc_IcingawebController extends DocController 404 ); } - $this->renderChapter(Icinga::app()->getApplicationDir('/../doc'), $chapterId, 'doc/icingaweb/chapter'); + $this->renderChapter( + Icinga::app()->getApplicationDir('/../doc'), + $chapterId, + 'doc/icingaweb/toc', + 'doc/icingaweb/chapter' + ); } /** diff --git a/modules/doc/application/controllers/ModuleController.php b/modules/doc/application/controllers/ModuleController.php index 7429dbdf2..19418a800 100644 --- a/modules/doc/application/controllers/ModuleController.php +++ b/modules/doc/application/controllers/ModuleController.php @@ -102,6 +102,7 @@ class Doc_ModuleController extends DocController $this->renderChapter( $moduleManager->getModuleDir($moduleName, '/doc'), $chapterId, + $this->_helper->url->url(array('moduleName' => $moduleName), 'doc/module/toc'), 'doc/module/chapter', array('moduleName' => $moduleName) ); diff --git a/modules/doc/application/views/scripts/toc.phtml b/modules/doc/application/views/scripts/toc.phtml index 7e92a6b26..3f6c6b37c 100644 --- a/modules/doc/application/views/scripts/toc.phtml +++ b/modules/doc/application/views/scripts/toc.phtml @@ -1,6 +1,6 @@

translate(sprintf('%s Documentation', ucfirst($docName))); ?>

-
+
render($this, $this->getHelper('Url')); ?>
diff --git a/modules/doc/library/Doc/DocController.php b/modules/doc/library/Doc/DocController.php index 16824ce0c..88beeee96 100644 --- a/modules/doc/library/Doc/DocController.php +++ b/modules/doc/library/Doc/DocController.php @@ -13,15 +13,17 @@ class DocController extends ModuleActionController * * @param string $path Path to the documentation * @param string $chapterId ID of the chapter + * @param string $tocUrl * @param string $url * @param array $urlParams */ - protected function renderChapter($path, $chapterId, $url, array $urlParams = array()) + protected function renderChapter($path, $chapterId, $tocUrl, $url, array $urlParams = array()) { $parser = new DocParser($path); $this->view->sectionRenderer = new SectionRenderer( $parser->getDocTree(), SectionRenderer::decodeUrlParam($chapterId), + $tocUrl, $url, $urlParams ); @@ -60,6 +62,7 @@ class DocController extends ModuleActionController $this->view->sectionRenderer = new SectionRenderer( $docTree, null, + null, $url, $urlParams ); diff --git a/modules/doc/library/Doc/SectionRenderer.php b/modules/doc/library/Doc/SectionRenderer.php index bc7bfb742..0f925bafb 100644 --- a/modules/doc/library/Doc/SectionRenderer.php +++ b/modules/doc/library/Doc/SectionRenderer.php @@ -87,6 +87,8 @@ class SectionRenderer extends Renderer */ protected $docTree; + protected $tocUrl; + /** * The URL to replace links with * @@ -120,12 +122,13 @@ class SectionRenderer extends 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 * * @throws ChapterNotFoundException If the chapter to filter for was not found */ - public function __construct(DocTree $docTree, $chapterId, $url, array $urlParams) + public function __construct(DocTree $docTree, $chapterId, $tocUrl, $url, array $urlParams) { if ($chapterId !== null) { $filter = new SectionFilterIterator($docTree, $chapterId); @@ -142,6 +145,7 @@ class SectionRenderer extends Renderer parent::__construct($docTree, RecursiveIteratorIterator::SELF_FIRST); } $this->docTree = $docTree; + $this->tocUrl = $tocUrl; $this->url = $url; $this->urlParams = array_map(array($this, 'encodeUrlParam'), $urlParams); $this->parsedown = Parsedown::instance(); @@ -182,9 +186,11 @@ class SectionRenderer extends Renderer * * @param View $view * @param Zend_View_Helper_Url $zendUrlHelper + * @param bool $renderNavigation + * * @return string */ - public function render(View $view, Zend_View_Helper_Url $zendUrlHelper) + public function render(View $view, Zend_View_Helper_Url $zendUrlHelper, $renderNavigation = true) { $callback = new Callback($this->docTree, $view, $zendUrlHelper, $this->url, $this->urlParams); $content = array(); @@ -192,7 +198,7 @@ class SectionRenderer extends Renderer $section = $node->getValue(); /* @var $section \Icinga\Module\Doc\Section */ $content[] = sprintf( - ' %3$s', + '%3$s', Renderer::encodeAnchor($section->getId()), $section->getLevel(), $view->escape($section->getTitle()) @@ -213,6 +219,73 @@ class SectionRenderer extends Renderer $html ); } + if ($renderNavigation) { + foreach ($this->docTree as $chapter) { + if ($chapter->getValue()->getId() === $section->getChapterId()) { + $content[] = ''; + break; + } + } + } return implode("\n", $content); } } diff --git a/modules/doc/library/Doc/TocRenderer.php b/modules/doc/library/Doc/TocRenderer.php index b4ad4228c..4061e80e3 100644 --- a/modules/doc/library/Doc/TocRenderer.php +++ b/modules/doc/library/Doc/TocRenderer.php @@ -9,7 +9,7 @@ use Zend_View_Helper_Url; use Icinga\Web\View; /** - * toc renderer + * TOC renderer */ class TocRenderer extends Renderer { diff --git a/modules/doc/public/css/module.less b/modules/doc/public/css/module.less index 52fff5c32..2676d0f24 100644 --- a/modules/doc/public/css/module.less +++ b/modules/doc/public/css/module.less @@ -31,3 +31,22 @@ code { pre > code { display: inline-block; } + +div.chapter > ul.navigation { + margin: 0; + padding: 0.4em; + text-align: center; + background-color: #888; + + li { + list-style: none; + display: inline; + margin: 0.2em; + padding: 0; + + a { + color: #fff; + text-decoration: none; + } + } +} From 0d3fb9e7a55e66a4cd381acae0004592237f60e4 Mon Sep 17 00:00:00 2001 From: Thomas Gelf Date: Tue, 19 Aug 2014 11:35:51 +0200 Subject: [PATCH 118/159] LoginForm: explicitely remove renderLayout Should prevent against rare race conditions. refs #6584 --- application/forms/Authentication/LoginForm.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/application/forms/Authentication/LoginForm.php b/application/forms/Authentication/LoginForm.php index f7fc9f22e..0eff8006c 100644 --- a/application/forms/Authentication/LoginForm.php +++ b/application/forms/Authentication/LoginForm.php @@ -17,7 +17,7 @@ class LoginForm extends Form */ protected function create() { - $url = Url::fromRequest(); + $url = Url::fromRequest()->without('renderLayout'); $this->setName('form_login'); $this->addElement('text', 'username', array( From 9ce99bf2800fc54c3cef55678e91bf0c73689829 Mon Sep 17 00:00:00 2001 From: Thomas Gelf Date: Tue, 19 Aug 2014 12:22:36 +0200 Subject: [PATCH 119/159] js/helpers: add $.hasAttr Need this for another fix and there is no such jQuery function. As this seems to also be inconsistant across browsers I thought this would definitively be worth a custom jQuery plugin. --- public/js/helpers.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/public/js/helpers.js b/public/js/helpers.js index 082689e40..416bf1185 100644 --- a/public/js/helpers.js +++ b/public/js/helpers.js @@ -95,6 +95,13 @@ if (!Function.prototype.bind) { 'use strict'; + /* Whether a HTML tag has a specific attribute */ + $.fn.hasAttr = function(name) { + // We have inconsistent behaviour across browsers (false VS undef) + var val = this.attr(name); + return typeof val !== 'undefined' && val !== false; + }; + /* Get class list */ $.fn.classes = function (callback) { From f40ada6c81ef25e1179e899eea1281fe6b132eba Mon Sep 17 00:00:00 2001 From: Thomas Gelf Date: Tue, 19 Aug 2014 12:23:51 +0200 Subject: [PATCH 120/159] js/ui: check whether a link tag has a type The new favicon didn't have such, resulting in JS error when reloading CSS at runtime. --- public/js/icinga/ui.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/public/js/icinga/ui.js b/public/js/icinga/ui.js index e9f3d741c..8ff3733f0 100644 --- a/public/js/icinga/ui.js +++ b/public/js/icinga/ui.js @@ -100,7 +100,7 @@ icinga.logger.info('Reloading CSS'); $('link').each(function() { var $oldLink = $(this); - if ($oldLink.attr('type').indexOf('css') > -1) { + if ($oldLink.hasAttr('type') && $oldLink.attr('type').indexOf('css') > -1) { var $newLink = $oldLink.clone().attr( 'href', icinga.utils.addUrlParams( From 7334716d156b21047e824a806a1cf84a657c06fb Mon Sep 17 00:00:00 2001 From: Thomas Gelf Date: Tue, 19 Aug 2014 12:25:14 +0200 Subject: [PATCH 121/159] favicon: add link type The favicon link tag was missing a type attribute. --- application/layouts/scripts/layout.phtml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/application/layouts/scripts/layout.phtml b/application/layouts/scripts/layout.phtml index 765873c02..32c4879b4 100644 --- a/application/layouts/scripts/layout.phtml +++ b/application/layouts/scripts/layout.phtml @@ -44,7 +44,7 @@ $iframeClass = $isIframe ? ' iframe' : ''; - + From db3ef8fbd0c598032e3422ff302007c36e60c42a Mon Sep 17 00:00:00 2001 From: Thomas Gelf Date: Tue, 19 Aug 2014 12:28:24 +0200 Subject: [PATCH 122/159] ActionController: remove redirectToLogin default The redirectOnLogin function now doesn't have any predefined default. This also leads to the behaviour that "Logout" will not redirect you anywhere on a new login while "forcibly being logged out" (e.g. by logging out in another browser tab) will bring you back to where you came from. --- .../Web/Controller/ActionController.php | 23 +++++++++++-------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/library/Icinga/Web/Controller/ActionController.php b/library/Icinga/Web/Controller/ActionController.php index d8e340907..13809e83d 100644 --- a/library/Icinga/Web/Controller/ActionController.php +++ b/library/Icinga/Web/Controller/ActionController.php @@ -254,18 +254,23 @@ class ActionController extends Zend_Controller_Action * * @throws \Exception */ - protected function redirectToLogin($afterLogin = '/dashboard') + protected function redirectToLogin($afterLogin = null) { - if (! $afterLogin instanceof Url) { - $afterLogin = Url::fromPath($afterLogin); - } - if ($this->isXhr()) { - $redir = '__SELF__'; - } else { - // TODO: Ignore /? - $redir = $afterLogin->getRelativeUrl(); + $redir = null; + if ($afterLogin !== null) { + if (! $afterLogin instanceof Url) { + $afterLogin = Url::fromPath($afterLogin); + } + if ($this->isXhr()) { + $redir = '__SELF__'; + } else { + // TODO: Ignore /? + $redir = $afterLogin->getRelativeUrl(); + } } + $url = Url::fromPath('authentication/login'); + if ($redir) { $url->setParam('redirect', $redir); } From 3f65f3447d1255284ffb34f7e91dc961389b42e8 Mon Sep 17 00:00:00 2001 From: Thomas Gelf Date: Tue, 19 Aug 2014 12:39:53 +0200 Subject: [PATCH 123/159] Web\UrlTest: test should use %20 instead of + We MUST use rawurlencode everywhere to avoid potential conflicts with URLs created on JS side. refs #6604 --- test/php/library/Icinga/Web/UrlTest.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/php/library/Icinga/Web/UrlTest.php b/test/php/library/Icinga/Web/UrlTest.php index 0eff54e5c..183f33369 100644 --- a/test/php/library/Icinga/Web/UrlTest.php +++ b/test/php/library/Icinga/Web/UrlTest.php @@ -21,7 +21,7 @@ class UrlTest extends BaseTestCase $url = Url::fromRequest(); $this->assertEquals( '/path/to/my/test/url.html?param1=value1&param2=value2', - $url->getAbsoluteUrl(), + $url->getAbsoluteUrl('&'), 'Url::fromRequest does not reassemble the correct url from the global request' ); } @@ -119,7 +119,7 @@ class UrlTest extends BaseTestCase */ public function testWhetherFromPathProperlyRecognizesAndDecodesQueryParameters() { - $url = Url::fromPath('/my/test/url.html?param1=%25arg1¶m2=arg+2' + $url = Url::fromPath('/my/test/url.html?param1=%25arg1¶m2=arg%202' . '¶m3[]=1¶m3[]=2¶m3[]=3¶m4[key1]=val1¶m4[key2]=val2'); $this->assertEquals( From cd825a4e6b5e2c13cc76f038f22ade6c12f30be7 Mon Sep 17 00:00:00 2001 From: Thomas Gelf Date: Tue, 19 Aug 2014 12:45:42 +0200 Subject: [PATCH 124/159] tests/ScrollingStyle: adjust, pagination shortened Pagination has been "shortened" some time ago to waste less space, tests now fit the current implementation. fixes #6594 fixes #6595 --- .../Paginator/ScrollingStyle/SlidingWithBorderTest.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/test/php/library/Icinga/Web/Paginator/ScrollingStyle/SlidingWithBorderTest.php b/test/php/library/Icinga/Web/Paginator/ScrollingStyle/SlidingWithBorderTest.php index d9eb0b25b..a77dcb553 100644 --- a/test/php/library/Icinga/Web/Paginator/ScrollingStyle/SlidingWithBorderTest.php +++ b/test/php/library/Icinga/Web/Paginator/ScrollingStyle/SlidingWithBorderTest.php @@ -19,8 +19,8 @@ class SlidingwithborderTest extends BaseTestCase $pages = $scrollingStyle->getPages($paginator); $this->assertInternalType('array', $pages); - $this->assertCount(13, $pages); - $this->assertEquals('...', $pages[11]); + $this->assertCount(10, $pages); + $this->assertEquals('...', $pages[8]); } public function testGetPages3() @@ -31,9 +31,9 @@ class SlidingwithborderTest extends BaseTestCase $pages = $scrollingStyle->getPages($paginator); $this->assertInternalType('array', $pages); - $this->assertCount(16, $pages); + $this->assertCount(10, $pages); $this->assertEquals('...', $pages[3]); - $this->assertEquals('...', $pages[14]); + $this->assertEquals('...', $pages[12]); } protected function getPaginatorAdapter() From 2f54ff4797cc321261288e28658c3ef993f44710 Mon Sep 17 00:00:00 2001 From: Alexander Fuhr Date: Tue, 19 Aug 2014 13:17:31 +0200 Subject: [PATCH 125/159] Fix the unrelated tabs resolves #6934 --- application/controllers/ConfigController.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/application/controllers/ConfigController.php b/application/controllers/ConfigController.php index df189f47f..45be1d3fd 100644 --- a/application/controllers/ConfigController.php +++ b/application/controllers/ConfigController.php @@ -67,7 +67,7 @@ class ConfigController extends BaseConfigController $form->setConfiguration(IcingaConfig::app()); $form->setRequest($this->_request); if ($form->isSubmittedAndValid()) { - if (!$this->writeConfigFile($form->getConfig(), 'config')) { + if (!$this->writeConfigFile($form->getConfig(), 'config')) { return; } Notification::success('New configuration has successfully been stored'); @@ -104,6 +104,11 @@ class ConfigController extends BaseConfigController */ public function modulesAction() { + $this->view->tabs = Widget::create('tabs')->add('modules', array( + 'title' => 'Modules', + 'url' => 'config/modules' + )); + $this->view->tabs->activate('modules'); $this->view->modules = Icinga::app()->getModuleManager()->select() ->from('modules') From d35e0816c96619f6292bce4e8dd8d36220d970d8 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Tue, 19 Aug 2014 13:20:46 +0200 Subject: [PATCH 126/159] doc: use `sprintf' in exceptions refs #4820 --- .../application/controllers/ModuleController.php | 4 ++-- modules/doc/library/Doc/DocParser.php | 13 +++++++++---- modules/doc/library/Doc/DocTree.php | 2 +- modules/doc/library/Doc/SectionRenderer.php | 2 +- 4 files changed, 13 insertions(+), 8 deletions(-) diff --git a/modules/doc/application/controllers/ModuleController.php b/modules/doc/application/controllers/ModuleController.php index 19418a800..26dac8626 100644 --- a/modules/doc/application/controllers/ModuleController.php +++ b/modules/doc/application/controllers/ModuleController.php @@ -44,13 +44,13 @@ class Doc_ModuleController extends DocController $moduleManager = Icinga::app()->getModuleManager(); if (! $moduleManager->hasInstalled($moduleName)) { throw new Zend_Controller_Action_Exception( - $this->translate('Module') . ' \'' . $moduleName . '\' ' . $this->translate('is not installed'), + $this->translate(sprintf('Module \'%s\' is not installed', $moduleName)), 404 ); } if (! $moduleManager->hasEnabled($moduleName)) { throw new Zend_Controller_Action_Exception( - $this->translate('Module') . ' \'' . $moduleName . '\' ' . $this->translate('is not enabled'), + $this->translate(sprintf('Module \'%s\' is not enabled', $moduleName)), 404 ); } diff --git a/modules/doc/library/Doc/DocParser.php b/modules/doc/library/Doc/DocParser.php index 8fa34ba77..e0311e6ba 100644 --- a/modules/doc/library/Doc/DocParser.php +++ b/modules/doc/library/Doc/DocParser.php @@ -41,19 +41,24 @@ class DocParser { if (! is_dir($path)) { throw new DocException( - mt('doc', 'Documentation directory') . ' \'' . $path . '\' ' . mt('doc', 'does not exist') + mt('doc', sprintf('Documentation directory \'%s\' does not exist', $path)) ); } if (! is_readable($path)) { throw new DocException( - mt('doc', 'Documentation directory') . ' \'' . $path . '\' ' . mt('doc', 'is not readable') + mt('doc', sprintf('Documentation directory \'%s\' is not readable', $path)) ); } $docIterator = new DocIterator($path); if ($docIterator->count() === 0) { throw new DocEmptyException( - mt('doc', 'Documentation directory') . ' \'' . $path . '\' ' - . mt('doc', 'does not contain any non-empty Markdown file (\'.md\' suffix') + mt( + 'doc', + sprintf( + 'Documentation directory \'%s\' does not contain any non-empty Markdown file (\'.md\' suffix)', + $path + ) + ) ); } $this->path = $path; diff --git a/modules/doc/library/Doc/DocTree.php b/modules/doc/library/Doc/DocTree.php index 07a0c5279..4223d8e99 100644 --- a/modules/doc/library/Doc/DocTree.php +++ b/modules/doc/library/Doc/DocTree.php @@ -57,7 +57,7 @@ class DocTree extends Node } if (! isset($this->nodes[$parentId])) { throw new LogicException( - sprintf('Can\'t add child node: there\'s no parent node having the id \'%s\'', $parentId) + mt('doc', sprintf('Can\'t add child node: there\'s no parent node having the id \'%s\'', $parentId)) ); } $this->nodes[$childId] = $this->nodes[$parentId]->appendChild($child); diff --git a/modules/doc/library/Doc/SectionRenderer.php b/modules/doc/library/Doc/SectionRenderer.php index 0f925bafb..fab6d66c4 100644 --- a/modules/doc/library/Doc/SectionRenderer.php +++ b/modules/doc/library/Doc/SectionRenderer.php @@ -134,7 +134,7 @@ class SectionRenderer extends Renderer $filter = new SectionFilterIterator($docTree, $chapterId); if ($filter->count() === 0) { throw new ChapterNotFoundException( - mt('doc', 'Chapter') . ' \'' . $chapterId . '\' ' . mt('doc', 'not found') + mt('doc', sprintf('Chapter \'%s\' not found', $chapterId)) ); } parent::__construct( From 55b3a5384a5e2ed89a974eadc6b454ac14ea5ab8 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Tue, 19 Aug 2014 13:38:18 +0200 Subject: [PATCH 127/159] doc: set page title refs #4820 --- modules/doc/application/views/scripts/toc.phtml | 2 +- modules/doc/library/Doc/DocController.php | 3 +++ modules/doc/library/Doc/SectionRenderer.php | 15 ++++++++------- modules/doc/public/css/module.less | 10 ++++++++++ 4 files changed, 22 insertions(+), 8 deletions(-) diff --git a/modules/doc/application/views/scripts/toc.phtml b/modules/doc/application/views/scripts/toc.phtml index 3f6c6b37c..ca6283d67 100644 --- a/modules/doc/application/views/scripts/toc.phtml +++ b/modules/doc/application/views/scripts/toc.phtml @@ -1,5 +1,5 @@
-

translate(sprintf('%s Documentation', ucfirst($docName))); ?>

+

render($this, $this->getHelper('Url')); ?> diff --git a/modules/doc/library/Doc/DocController.php b/modules/doc/library/Doc/DocController.php index 88beeee96..66895bfb4 100644 --- a/modules/doc/library/Doc/DocController.php +++ b/modules/doc/library/Doc/DocController.php @@ -27,6 +27,7 @@ class DocController extends ModuleActionController $url, $urlParams ); + $this->view->title = $chapterId; $this->_helper->viewRenderer('chapter', null, true); } @@ -42,7 +43,9 @@ class DocController extends ModuleActionController { $parser = new DocParser($path); $this->view->tocRenderer = new TocRenderer($parser->getDocTree(), $url, $urlParams); + $name = ucfirst($name); $this->view->docName = $name; + $this->view->title = $this->translate(sprintf('%s Documentation', $name)); $this->_helper->viewRenderer('toc', null, true); } diff --git a/modules/doc/library/Doc/SectionRenderer.php b/modules/doc/library/Doc/SectionRenderer.php index fab6d66c4..6281b6d76 100644 --- a/modules/doc/library/Doc/SectionRenderer.php +++ b/modules/doc/library/Doc/SectionRenderer.php @@ -222,7 +222,7 @@ class SectionRenderer extends Renderer if ($renderNavigation) { foreach ($this->docTree as $chapter) { if ($chapter->getValue()->getId() === $section->getChapterId()) { - $content[] = ''; + $content = array_merge($navigation, $content, $navigation); break; } } diff --git a/modules/doc/public/css/module.less b/modules/doc/public/css/module.less index 2676d0f24..d6d0d2a94 100644 --- a/modules/doc/public/css/module.less +++ b/modules/doc/public/css/module.less @@ -48,5 +48,15 @@ div.chapter > ul.navigation { color: #fff; text-decoration: none; } + + &.prev { + padding-right: 0.6em; + border-right: 2px solid #fff; + } + + &.next { + padding-left: 0.6em; + border-left: 2px solid #fff; + } } } From f52b3f7b8c5757c961db958aad9d361e18b40957 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Tue, 19 Aug 2014 13:38:34 +0200 Subject: [PATCH 128/159] doc/config: add menu.ini refs #4820 --- config/modules/doc/menu.ini | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 config/modules/doc/menu.ini diff --git a/config/modules/doc/menu.ini b/config/modules/doc/menu.ini new file mode 100644 index 000000000..86889b239 --- /dev/null +++ b/config/modules/doc/menu.ini @@ -0,0 +1,5 @@ +[Documentation] +title = "Documentation" +icon = "img/icons/comment.png" +url = "doc" +priority = 80 From 6b468b7f9bd5cfddac82b94ad8d10a0321dc3343 Mon Sep 17 00:00:00 2001 From: Alexander Klimov Date: Tue, 19 Aug 2014 13:51:10 +0200 Subject: [PATCH 129/159] Monitoring_ConfigController: make writeConfiguration's parameter `file' non-required refs #6641 --- modules/monitoring/application/controllers/ConfigController.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/monitoring/application/controllers/ConfigController.php b/modules/monitoring/application/controllers/ConfigController.php index d777390a8..d110a32e2 100644 --- a/modules/monitoring/application/controllers/ConfigController.php +++ b/modules/monitoring/application/controllers/ConfigController.php @@ -216,7 +216,7 @@ class Monitoring_ConfigController extends ModuleActionController /** * Display a form to remove the instance identified by the 'instance' parameter */ - private function writeConfiguration($config, $file) + private function writeConfiguration($config, $file = null) { $target = $this->Config($file)->getConfigFile(); $writer = new PreservingIniWriter(array('filename' => $target, 'config' => $config)); From 1ba3954b95a30f1ca6554a0e09dd11ece40c82d9 Mon Sep 17 00:00:00 2001 From: Alexander Klimov Date: Tue, 19 Aug 2014 14:02:26 +0200 Subject: [PATCH 130/159] Monitoring config: implement SecurityForm refs #6641 --- .../application/forms/Config/SecurityForm.php | 56 +++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 modules/monitoring/application/forms/Config/SecurityForm.php diff --git a/modules/monitoring/application/forms/Config/SecurityForm.php b/modules/monitoring/application/forms/Config/SecurityForm.php new file mode 100644 index 000000000..51b64dea0 --- /dev/null +++ b/modules/monitoring/application/forms/Config/SecurityForm.php @@ -0,0 +1,56 @@ +addElement( + 'text', + 'customvars', + array( + 'label' => 'Protected Custom Variables', + 'required' => true, + 'value' => $this->config->customvars + ) + ); + $this->setSubmitLabel('{{SAVE_ICON}} Save'); + } + + /** + * Set the configuration to be used for initial population of the form + */ + public function setConfiguration($config) + { + $this->config = $config; + } + + /** + * Return the configuration set by this form + * + * @return Zend_Config The configuration set in this form + */ + public function getConfig() + { + $values = $this->getValues(); + return new Zend_Config(array( + 'customvars' => $values['customvars'] + )); + } +} From 65473ac8eec9474793c691aae84abe852ab7b2d5 Mon Sep 17 00:00:00 2001 From: Alexander Klimov Date: Tue, 19 Aug 2014 14:04:00 +0200 Subject: [PATCH 131/159] Monitoring config: use SecurityForm refs #6641 --- .../controllers/ConfigController.php | 17 +++++++++++++++++ .../views/scripts/config/security.phtml | 1 + 2 files changed, 18 insertions(+) diff --git a/modules/monitoring/application/controllers/ConfigController.php b/modules/monitoring/application/controllers/ConfigController.php index d110a32e2..f0982c29a 100644 --- a/modules/monitoring/application/controllers/ConfigController.php +++ b/modules/monitoring/application/controllers/ConfigController.php @@ -14,6 +14,7 @@ use Icinga\Module\Monitoring\Form\Config\Backend\EditBackendForm; use Icinga\Module\Monitoring\Form\Config\Backend\CreateBackendForm; use Icinga\Module\Monitoring\Form\Config\Instance\EditInstanceForm; use Icinga\Module\Monitoring\Form\Config\Instance\CreateInstanceForm; +use Icinga\Module\Monitoring\Form\Config\SecurityForm; use Icinga\Exception\NotReadableError; @@ -262,5 +263,21 @@ class Monitoring_ConfigController extends ModuleActionController public function securityAction() { $this->view->tabs = $this->Module()->getConfigTabs()->activate('security'); + + $form = new SecurityForm(); + $form->setConfiguration($this->Config()->get('security')); + $form->setRequest($this->getRequest()); + if ($form->isSubmittedAndValid()) { + $config = $this->Config()->toArray(); + $config['security'] = $form->getConfig(); + if ($this->writeConfiguration(new Zend_Config($config))) { + Notification::success('Configuration modified successfully'); + $this->redirectNow('monitoring/config/security'); + } else { + $this->render('show-configuration'); + return; + } + } + $this->view->form = $form; } } diff --git a/modules/monitoring/application/views/scripts/config/security.phtml b/modules/monitoring/application/views/scripts/config/security.phtml index 87b22b9ac..b4619b4fe 100644 --- a/modules/monitoring/application/views/scripts/config/security.phtml +++ b/modules/monitoring/application/views/scripts/config/security.phtml @@ -1,3 +1,4 @@
tabs ?>
+form ?> From 703509946886e76c5916bfbdc5bee551bbacad75 Mon Sep 17 00:00:00 2001 From: Alexander Fuhr Date: Tue, 19 Aug 2014 14:42:28 +0200 Subject: [PATCH 132/159] Fix the host_unhandled_service_count error fixes #6833 --- modules/monitoring/application/controllers/ListController.php | 1 - modules/monitoring/application/controllers/MultiController.php | 1 - 2 files changed, 2 deletions(-) diff --git a/modules/monitoring/application/controllers/ListController.php b/modules/monitoring/application/controllers/ListController.php index f0cdb2767..7e96ef459 100644 --- a/modules/monitoring/application/controllers/ListController.php +++ b/modules/monitoring/application/controllers/ListController.php @@ -94,7 +94,6 @@ class Monitoring_ListController extends Controller 'host_last_check', 'host_last_state_change' => $stateChangeColumn, 'host_notifications_enabled', - // 'host_unhandled_service_count', 'host_unhandled_services', 'host_action_url', 'host_notes_url', diff --git a/modules/monitoring/application/controllers/MultiController.php b/modules/monitoring/application/controllers/MultiController.php index a623dd88b..6459edd59 100644 --- a/modules/monitoring/application/controllers/MultiController.php +++ b/modules/monitoring/application/controllers/MultiController.php @@ -24,7 +24,6 @@ class Monitoring_MultiController extends Controller array( 'host_name', 'host_in_downtime', - 'host_unhandled_service_count', 'host_passive_checks_enabled', 'host_obsessing', 'host_state', From 3e079efe2a6ce582371a541910cbf2cd6825394d Mon Sep 17 00:00:00 2001 From: Alexander Klimov Date: Tue, 19 Aug 2014 14:51:30 +0200 Subject: [PATCH 133/159] SecurityForm: replace `customvars' with `protected_customvars' refs #6641 --- .../monitoring/application/forms/Config/SecurityForm.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/modules/monitoring/application/forms/Config/SecurityForm.php b/modules/monitoring/application/forms/Config/SecurityForm.php index 51b64dea0..288c00b9c 100644 --- a/modules/monitoring/application/forms/Config/SecurityForm.php +++ b/modules/monitoring/application/forms/Config/SecurityForm.php @@ -23,11 +23,11 @@ class SecurityForm extends Form { $this->addElement( 'text', - 'customvars', + 'protected_customvars', array( 'label' => 'Protected Custom Variables', 'required' => true, - 'value' => $this->config->customvars + 'value' => $this->config->protected_customvars ) ); $this->setSubmitLabel('{{SAVE_ICON}} Save'); @@ -50,7 +50,7 @@ class SecurityForm extends Form { $values = $this->getValues(); return new Zend_Config(array( - 'customvars' => $values['customvars'] + 'protected_customvars' => $values['protected_customvars'] )); } } From f49a34625e17a189fe528eb7e963d51defd655a2 Mon Sep 17 00:00:00 2001 From: Thomas Gelf Date: Tue, 19 Aug 2014 14:53:56 +0200 Subject: [PATCH 134/159] Url\Params: check for QUERY_STRING before using it fixes #6957 --- library/Icinga/Web/UrlParams.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library/Icinga/Web/UrlParams.php b/library/Icinga/Web/UrlParams.php index fa1b2a7f3..bdf776401 100644 --- a/library/Icinga/Web/UrlParams.php +++ b/library/Icinga/Web/UrlParams.php @@ -352,7 +352,7 @@ class UrlParams public static function fromQueryString($queryString = null) { if ($queryString === null) { - $queryString = $_SERVER['QUERY_STRING']; + $queryString = isset($_SERVER['QUERY_STRING']) ? $_SERVER['QUERY_STRING'] : ''; } $params = new static(); $params->parseQueryString($queryString); From c6d4ab4c443c9d2d55c004d8fb81c5014aafbbe7 Mon Sep 17 00:00:00 2001 From: Alexander Klimov Date: Tue, 19 Aug 2014 15:04:43 +0200 Subject: [PATCH 135/159] Vagrant/Puppet: add file '/etc/icingaweb/modules/monitoring/config.ini' refs #6641 --- .../files/etc/icingaweb/modules/monitoring/config.ini | 2 ++ .vagrant-puppet/manifests/default.pp | 6 ++++++ config/modules/monitoring/config.ini | 2 ++ 3 files changed, 10 insertions(+) create mode 100644 .vagrant-puppet/files/etc/icingaweb/modules/monitoring/config.ini create mode 100644 config/modules/monitoring/config.ini diff --git a/.vagrant-puppet/files/etc/icingaweb/modules/monitoring/config.ini b/.vagrant-puppet/files/etc/icingaweb/modules/monitoring/config.ini new file mode 100644 index 000000000..9b69fe86f --- /dev/null +++ b/.vagrant-puppet/files/etc/icingaweb/modules/monitoring/config.ini @@ -0,0 +1,2 @@ +[security] +protected_customvars = "*pw*,*pass*,community" diff --git a/.vagrant-puppet/manifests/default.pp b/.vagrant-puppet/manifests/default.pp index 5caf10452..db7b1baba 100644 --- a/.vagrant-puppet/manifests/default.pp +++ b/.vagrant-puppet/manifests/default.pp @@ -735,6 +735,12 @@ file { '/etc/icingaweb/modules/monitoring/backends.ini': group => 'apache', } +file { '/etc/icingaweb/modules/monitoring/config.ini': + source => 'puppet:////vagrant/.vagrant-puppet/files/etc/icingaweb/modules/monitoring/config.ini', + owner => 'apache', + group => 'apache', +} + file { '/etc/icingaweb/modules/monitoring/instances.ini': source => 'puppet:////vagrant/.vagrant-puppet/files/etc/icingaweb/modules/monitoring/instances.ini', owner => 'apache', diff --git a/config/modules/monitoring/config.ini b/config/modules/monitoring/config.ini new file mode 100644 index 000000000..9b69fe86f --- /dev/null +++ b/config/modules/monitoring/config.ini @@ -0,0 +1,2 @@ +[security] +protected_customvars = "*pw*,*pass*,community" From 8c02f140c3937bba60cc0d6fff2a2270de68a995 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Tue, 19 Aug 2014 16:22:22 +0200 Subject: [PATCH 136/159] doc: fix translate calls w/ sprintf --- .../application/controllers/ModuleController.php | 4 ++-- modules/doc/library/Doc/DocController.php | 2 +- modules/doc/library/Doc/DocParser.php | 16 ++++++++-------- modules/doc/library/Doc/DocTree.php | 2 +- modules/doc/library/Doc/SectionRenderer.php | 2 +- 5 files changed, 13 insertions(+), 13 deletions(-) diff --git a/modules/doc/application/controllers/ModuleController.php b/modules/doc/application/controllers/ModuleController.php index 26dac8626..40913368c 100644 --- a/modules/doc/application/controllers/ModuleController.php +++ b/modules/doc/application/controllers/ModuleController.php @@ -44,13 +44,13 @@ class Doc_ModuleController extends DocController $moduleManager = Icinga::app()->getModuleManager(); if (! $moduleManager->hasInstalled($moduleName)) { throw new Zend_Controller_Action_Exception( - $this->translate(sprintf('Module \'%s\' is not installed', $moduleName)), + sprintf($this->translate('Module \'%s\' is not installed'), $moduleName), 404 ); } if (! $moduleManager->hasEnabled($moduleName)) { throw new Zend_Controller_Action_Exception( - $this->translate(sprintf('Module \'%s\' is not enabled', $moduleName)), + sprintf($this->translate('Module \'%s\' is not enabled'), $moduleName), 404 ); } diff --git a/modules/doc/library/Doc/DocController.php b/modules/doc/library/Doc/DocController.php index 66895bfb4..42f8dce9b 100644 --- a/modules/doc/library/Doc/DocController.php +++ b/modules/doc/library/Doc/DocController.php @@ -45,7 +45,7 @@ class DocController extends ModuleActionController $this->view->tocRenderer = new TocRenderer($parser->getDocTree(), $url, $urlParams); $name = ucfirst($name); $this->view->docName = $name; - $this->view->title = $this->translate(sprintf('%s Documentation', $name)); + $this->view->title = sprintf($this->translate('%s Documentation'), $name); $this->_helper->viewRenderer('toc', null, true); } diff --git a/modules/doc/library/Doc/DocParser.php b/modules/doc/library/Doc/DocParser.php index e0311e6ba..c63532dc1 100644 --- a/modules/doc/library/Doc/DocParser.php +++ b/modules/doc/library/Doc/DocParser.php @@ -41,23 +41,23 @@ class DocParser { if (! is_dir($path)) { throw new DocException( - mt('doc', sprintf('Documentation directory \'%s\' does not exist', $path)) + sprintf(mt('doc', 'Documentation directory \'%s\' does not exist'), $path) ); } if (! is_readable($path)) { throw new DocException( - mt('doc', sprintf('Documentation directory \'%s\' is not readable', $path)) + sprintf(mt('doc', 'Documentation directory \'%s\' is not readable'), $path) ); } $docIterator = new DocIterator($path); if ($docIterator->count() === 0) { throw new DocEmptyException( - mt( - 'doc', - sprintf( - 'Documentation directory \'%s\' does not contain any non-empty Markdown file (\'.md\' suffix)', - $path - ) + sprintf( + mt( + 'doc', + 'Documentation directory \'%s\' does not contain any non-empty Markdown file (\'.md\' suffix)' + ), + $path ) ); } diff --git a/modules/doc/library/Doc/DocTree.php b/modules/doc/library/Doc/DocTree.php index 4223d8e99..1b112649c 100644 --- a/modules/doc/library/Doc/DocTree.php +++ b/modules/doc/library/Doc/DocTree.php @@ -57,7 +57,7 @@ class DocTree extends Node } if (! isset($this->nodes[$parentId])) { throw new LogicException( - mt('doc', sprintf('Can\'t add child node: there\'s no parent node having the id \'%s\'', $parentId)) + 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); diff --git a/modules/doc/library/Doc/SectionRenderer.php b/modules/doc/library/Doc/SectionRenderer.php index 6281b6d76..938e5ed7b 100644 --- a/modules/doc/library/Doc/SectionRenderer.php +++ b/modules/doc/library/Doc/SectionRenderer.php @@ -134,7 +134,7 @@ class SectionRenderer extends Renderer $filter = new SectionFilterIterator($docTree, $chapterId); if ($filter->count() === 0) { throw new ChapterNotFoundException( - mt('doc', sprintf('Chapter \'%s\' not found', $chapterId)) + sprintf(mt('doc', 'Chapter \'%s\' not found'), $chapterId) ); } parent::__construct( From 995355ec30f0879b26bebf82b88636369dfc2685 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Tue, 19 Aug 2014 16:29:11 +0200 Subject: [PATCH 137/159] lib/Limiter: fix translate w/ sprintf --- library/Icinga/Web/Widget/Limiter.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library/Icinga/Web/Widget/Limiter.php b/library/Icinga/Web/Widget/Limiter.php index 9c6a726ba..5afa7e4b8 100644 --- a/library/Icinga/Web/Widget/Limiter.php +++ b/library/Icinga/Web/Widget/Limiter.php @@ -81,7 +81,7 @@ class Limiter extends AbstractWidget $this->url->setParam('limit', $limit), null, array( - 'title' => t(sprintf('Show %s rows on one page', $caption)) + 'title' => sprintf(t('Show %s rows on one page'), $caption) ) ); } From 3573908071898eee6c54d6a3f7a46de85349bb5b Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Tue, 19 Aug 2014 17:03:35 +0200 Subject: [PATCH 138/159] Let downtime view look more list-like and fix downtime end calculation refs #6637 --- .../controllers/ListController.php | 5 +- .../views/scripts/list/downtimes.phtml | 181 +++++++++++------- .../Backend/Ido/Query/DowntimeQuery.php | 14 +- .../library/Monitoring/DataView/Downtime.php | 2 + 4 files changed, 135 insertions(+), 67 deletions(-) diff --git a/modules/monitoring/application/controllers/ListController.php b/modules/monitoring/application/controllers/ListController.php index f0cdb2767..6c4cc0101 100644 --- a/modules/monitoring/application/controllers/ListController.php +++ b/modules/monitoring/application/controllers/ListController.php @@ -222,6 +222,7 @@ class Monitoring_ListController extends Controller 'author' => 'downtime_author', 'start' => 'downtime_start', 'scheduled_start' => 'downtime_scheduled_start', + 'scheduled_end' => 'downtime_scheduled_end', 'end' => 'downtime_end', 'duration' => 'downtime_duration', 'is_flexible' => 'downtime_is_flexible', @@ -229,7 +230,9 @@ class Monitoring_ListController extends Controller 'is_in_effect' => 'downtime_is_in_effect', 'entry_time' => 'downtime_entry_time', 'host' => 'downtime_host', - 'service' => 'downtime_service' + 'service' => 'downtime_service', + 'host_state' => 'downtime_host_state', + 'service_state' => 'downtime_service_state' ))->order('downtime_is_in_effect', 'DESC') ->order('downtime_scheduled_start', 'DESC'); diff --git a/modules/monitoring/application/views/scripts/list/downtimes.phtml b/modules/monitoring/application/views/scripts/list/downtimes.phtml index 995a66001..babb76074 100644 --- a/modules/monitoring/application/views/scripts/list/downtimes.phtml +++ b/modules/monitoring/application/views/scripts/list/downtimes.phtml @@ -1,70 +1,121 @@ getHelper('CommandForm'); ?> -
-tabs ?> -
-sortControl->render($this); ?> -
-paginationControl($downtimes, null, null, array('preserve' => $this->preserve)); ?> -
-
- - -downtimes as $downtime): ?> - - - - - - -
- dateFormat()->formatDateTime($downtime->start); ?> - - dateFormat()->formatDateTime($downtime->end); ?> -
- Duration: util()->showHourMin($downtime->duration); ?> -
- The is_flexible): ?>flexiblefixed downtime is is_in_effect): ?>not in effect -
- service)): ?> - service ?> - on host ?> - - host ?> - -
- author ?>: comment ?> -
- Entry Time: entry_time) ? $this->dateFormat()->formatDateTime((int) $downtime->entry_time) : ''; ?> - -
- $downtime->id, - 'host' => $downtime->host - ); - if (isset($downtime->service)) { - $data['service'] = $downtime->service; - } - // echo $helper->iconSubmitForm( - // 'img/icons/remove.png', - echo $helper->labelSubmitForm( - 'X', - 'Remove Downtime', - 'link-like', - 'removedowntime', - $data - ); - ?> -
+compact): ?> +
+ tabs->render($this); ?> +
+ translate('Sort by'); ?> sortControl->render($this); ?> +
+ widget('limiter', array('url' => $this->url, 'max' => $downtimes->count())); ?> + paginationControl($downtimes, null, null, array('preserve' => $this->preserve)); ?> +
+ + +
+ + translate('No downtimes matching the filter'); ?> +
+ + + + + + service)) { + $stateName = strtolower($this->util()->getServiceStateName($downtime->service_state)); + } else { + $stateName = strtolower($this->util()->getHostStateName($downtime->host_state)); + } + ?> + + + + $downtime->id, + 'host' => $downtime->host + ); + if (isset($downtime->service)) { + $data['service'] = $downtime->service; + } + ?> + + + + +
+ is_in_effect ? $this->translate('Expires') : $this->translate('Starts'); ?> +
+ prefixedTimeUntil($downtime->is_in_effect ? $downtime->end : $downtime->start); ?> +
+ service)): ?> + + service; ?> + + + translate('on'); ?> host; ?> + + + + host; ?> + + +
+ icon('comment.png'); ?> [author; ?>] comment; ?> +
+ + is_flexible): ?> + is_in_effect): ?> + translate('This flexible 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), + date('d.m.y', $downtime->end), + date('H:i', $downtime->end) + ); ?> + + translate('This flexible 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) + ); ?> + + + is_in_effect): ?> + translate('This fixed 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), + date('H:i', $downtime->end) + ); ?> + + translate('This fixed 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), + date('H:i', $downtime->scheduled_end) + ); ?> + + + +
+ labelSubmitForm( + 'X', + 'Remove Downtime', + 'link-like', + 'removedowntime', + $data + ); ?> +
diff --git a/modules/monitoring/library/Monitoring/Backend/Ido/Query/DowntimeQuery.php b/modules/monitoring/library/Monitoring/Backend/Ido/Query/DowntimeQuery.php index 324d72c4c..1f5e17c6c 100644 --- a/modules/monitoring/library/Monitoring/Backend/Ido/Query/DowntimeQuery.php +++ b/modules/monitoring/library/Monitoring/Backend/Ido/Query/DowntimeQuery.php @@ -24,13 +24,15 @@ class DowntimeQuery extends IdoQuery 'downtime_scheduled_start' => 'UNIX_TIMESTAMP(sd.scheduled_start_time)', 'downtime_scheduled_end' => 'UNIX_TIMESTAMP(sd.scheduled_end_time)', 'downtime_start' => "UNIX_TIMESTAMP(CASE WHEN sd.trigger_time != '0000-00-00 00:00:00' then sd.trigger_time ELSE sd.scheduled_start_time END)", - 'downtime_end' => 'UNIX_TIMESTAMP(sd.scheduled_end_time)', + 'downtime_end' => 'CASE WHEN sd.is_fixed 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', 'downtime_service' => 'so.name2 COLLATE latin1_general_ci', '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' ), ); @@ -53,6 +55,16 @@ 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); } } diff --git a/modules/monitoring/library/Monitoring/DataView/Downtime.php b/modules/monitoring/library/Monitoring/DataView/Downtime.php index 8bd97673a..214e1afb5 100644 --- a/modules/monitoring/library/Monitoring/DataView/Downtime.php +++ b/modules/monitoring/library/Monitoring/DataView/Downtime.php @@ -30,6 +30,8 @@ class Downtime extends DataView 'downtime_internal_id', 'downtime_host', 'downtime_service', + 'downtime_host_state', + 'downtiem_service_state' ); } From 6fe47bf5b0bae7b6654c08e3c74be73adf32f9d8 Mon Sep 17 00:00:00 2001 From: Alexander Fuhr Date: Tue, 19 Aug 2014 17:30:56 +0200 Subject: [PATCH 139/159] Fix rows highlighting after refresh fixes #6705 --- modules/monitoring/application/views/scripts/list/hosts.phtml | 2 +- .../monitoring/application/views/scripts/list/services.phtml | 2 +- public/js/icinga/events.js | 3 ++- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/modules/monitoring/application/views/scripts/list/hosts.phtml b/modules/monitoring/application/views/scripts/list/hosts.phtml index a6056e149..6af1181e4 100644 --- a/modules/monitoring/application/views/scripts/list/hosts.phtml +++ b/modules/monitoring/application/views/scripts/list/hosts.phtml @@ -109,7 +109,7 @@ if ($hosts->count() === 0) { - host_name ?> diff --git a/modules/monitoring/application/views/scripts/list/services.phtml b/modules/monitoring/application/views/scripts/list/services.phtml index f2da63dca..9e9e8d725 100644 --- a/modules/monitoring/application/views/scripts/list/services.phtml +++ b/modules/monitoring/application/views/scripts/list/services.phtml @@ -99,7 +99,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_name; ?> host_state != 0): ?> (monitoringState($service, 'host')); ?>) diff --git a/public/js/icinga/events.js b/public/js/icinga/events.js index 6c6978577..5328d20aa 100644 --- a/public/js/icinga/events.js +++ b/public/js/icinga/events.js @@ -134,6 +134,7 @@ // Select a table row $(document).on('click', 'table.multiselect tr[href]', { self: this }, this.rowSelected); + $(document).on('click', 'table.multiselect .select-click', { self: this }, this.rowSelected); $(document).on('click', 'button', { self: this }, this.submitForm); @@ -400,7 +401,7 @@ rowSelected: function(event) { var self = event.data.self; var icinga = self.icinga; - var $tr = $(this); + var $tr = $(this).closest('tr'); var $table = $tr.closest('table.multiselect'); var data = self.icinga.ui.getSelectionKeys($table); var url = $table.data('icinga-multiselect-url'); From ea0248ecf4032d55cd855f9383af39390a7cc41e Mon Sep 17 00:00:00 2001 From: Alexander Klimov Date: Tue, 19 Aug 2014 17:54:22 +0200 Subject: [PATCH 140/159] Remove '{{SAVE_ICON}}', tiny design fixes refs #6641 --- modules/monitoring/application/forms/Config/SecurityForm.php | 2 +- .../application/views/scripts/config/security.phtml | 4 +++- .../views/scripts/show/components/customvars.phtml | 1 - 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/modules/monitoring/application/forms/Config/SecurityForm.php b/modules/monitoring/application/forms/Config/SecurityForm.php index 288c00b9c..ace1594f2 100644 --- a/modules/monitoring/application/forms/Config/SecurityForm.php +++ b/modules/monitoring/application/forms/Config/SecurityForm.php @@ -30,7 +30,7 @@ class SecurityForm extends Form 'value' => $this->config->protected_customvars ) ); - $this->setSubmitLabel('{{SAVE_ICON}} Save'); + $this->setSubmitLabel('Save'); } /** diff --git a/modules/monitoring/application/views/scripts/config/security.phtml b/modules/monitoring/application/views/scripts/config/security.phtml index b4619b4fe..71f2a341a 100644 --- a/modules/monitoring/application/views/scripts/config/security.phtml +++ b/modules/monitoring/application/views/scripts/config/security.phtml @@ -1,4 +1,6 @@
tabs ?>
-form ?> +
+ form ?> +
diff --git a/modules/monitoring/application/views/scripts/show/components/customvars.phtml b/modules/monitoring/application/views/scripts/show/components/customvars.phtml index 9eeb4a0ac..ef79d0e70 100644 --- a/modules/monitoring/application/views/scripts/show/components/customvars.phtml +++ b/modules/monitoring/application/views/scripts/show/components/customvars.phtml @@ -13,4 +13,3 @@ foreach ($object->customvars as $name => $value) { $this->escape($value) ); } - From ba748cbc4af084c02ffd719930b9b91f103db58e Mon Sep 17 00:00:00 2001 From: Alexander Fuhr Date: Tue, 19 Aug 2014 18:33:28 +0200 Subject: [PATCH 141/159] Refactor multiSelect and highlight refs #6705 --- .../views/scripts/list/hosts.phtml | 2 +- .../views/scripts/list/services.phtml | 2 +- public/js/icinga/events.js | 26 ++++++++++++++----- 3 files changed, 21 insertions(+), 9 deletions(-) diff --git a/modules/monitoring/application/views/scripts/list/hosts.phtml b/modules/monitoring/application/views/scripts/list/hosts.phtml index 6af1181e4..a6056e149 100644 --- a/modules/monitoring/application/views/scripts/list/hosts.phtml +++ b/modules/monitoring/application/views/scripts/list/hosts.phtml @@ -109,7 +109,7 @@ if ($hosts->count() === 0) { -
compact ? $hostLink : $this->href( 'monitoring/show/host', array('host' => $host->host_name) ) ?>">host_name ?> diff --git a/modules/monitoring/application/views/scripts/list/services.phtml b/modules/monitoring/application/views/scripts/list/services.phtml index 9e9e8d725..f2da63dca 100644 --- a/modules/monitoring/application/views/scripts/list/services.phtml +++ b/modules/monitoring/application/views/scripts/list/services.phtml @@ -99,7 +99,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_name; ?> host_state != 0): ?> (monitoringState($service, 'host')); ?>) diff --git a/public/js/icinga/events.js b/public/js/icinga/events.js index 5328d20aa..790d245c3 100644 --- a/public/js/icinga/events.js +++ b/public/js/icinga/events.js @@ -134,7 +134,6 @@ // Select a table row $(document).on('click', 'table.multiselect tr[href]', { self: this }, this.rowSelected); - $(document).on('click', 'table.multiselect .select-click', { self: this }, this.rowSelected); $(document).on('click', 'button', { self: this }, this.submitForm); @@ -475,12 +474,20 @@ return true; } - // Ignore clicks on multiselect table inner links while key pressed - if ((event.ctrlKey || event.metaKey || event.shiftKey) && - ! $a.is('tr[href]') && $a.closest('table.multiselect').length > 0 && - $a.closest('tr[href]').length > 0) - { - return self.rowSelected.call($a.closest('tr[href]'), event); + // Special checks for link clicks in multiselect rows + if (! $a.is('tr[href]') && $a.closest('tr[href]').length > 0 && $a.closest('table.multiselect').length > 0) { + + // Forward clicks to ANY link with special key pressed to rowSelected + if (event.ctrlKey || event.metaKey || event.shiftKey) + { + return self.rowSelected.call($a.closest('tr[href]'), event); + } + + // Forward inner links matching the row URL to rowSelected + if ($a.attr('href') === $a.closest('tr[href]').attr('href')) + { + return self.rowSelected.call($a.closest('tr[href]'), event); + } } // Let remote links pass through @@ -494,6 +501,11 @@ return false; } + // ignore multiselect table row clicks + if ($a.closest('tr[href]').length > 0 && $a.closest('table.action').length > 0) { + return; + } + // ignore multiselect table row clicks if ($a.is('tr') && $a.closest('table.multiselect').length > 0) { return; From 071937910b4b4fc29e74edfe9754547694f4d968 Mon Sep 17 00:00:00 2001 From: Alexander Klimov Date: Tue, 19 Aug 2014 18:46:37 +0200 Subject: [PATCH 142/159] Monitoring/Object: filter protected customvars Move the responsibility from the viewscript to Monitoring/Object refs #6641 --- .../scripts/show/components/customvars.phtml | 7 ------- .../Monitoring/Object/AbstractObject.php | 18 ++++++++++++++++++ 2 files changed, 18 insertions(+), 7 deletions(-) diff --git a/modules/monitoring/application/views/scripts/show/components/customvars.phtml b/modules/monitoring/application/views/scripts/show/components/customvars.phtml index ef79d0e70..d89260e95 100644 --- a/modules/monitoring/application/views/scripts/show/components/customvars.phtml +++ b/modules/monitoring/application/views/scripts/show/components/customvars.phtml @@ -1,12 +1,5 @@ customvars) { return; } - foreach ($object->customvars as $name => $value) { - $name = ucwords(str_replace('_', ' ', strtolower($name))); - if (preg_match('~(?:pw|pass|community)~', strtolower($name))) { - $value = '***'; - } printf( "%s%s\n", $this->escape($name), diff --git a/modules/monitoring/library/Monitoring/Object/AbstractObject.php b/modules/monitoring/library/Monitoring/Object/AbstractObject.php index 73314fbc9..483516f9c 100644 --- a/modules/monitoring/library/Monitoring/Object/AbstractObject.php +++ b/modules/monitoring/library/Monitoring/Object/AbstractObject.php @@ -20,6 +20,7 @@ use Icinga\Module\Monitoring\DataView\Comment; use Icinga\Module\Monitoring\DataView\Servicegroup; use Icinga\Module\Monitoring\DataView\Customvar; use Icinga\Web\UrlParams; +use Icinga\Application\Config; abstract class AbstractObject @@ -120,6 +121,17 @@ abstract class AbstractObject public function fetchCustomvars() { + $monitoringSecurity = Config::module('monitoring')->get('security')->toArray(); + $customvars = array(); + foreach (explode(',', $monitoringSecurity['protected_customvars']) as $customvar) { + $nonWildcards = array(); + foreach (explode('*', $customvar) as $nonWildcard) { + $nonWildcards[] = preg_quote($nonWildcard, '/'); + } + $customvars[] = implode('.*', $nonWildcards); + } + $customvars = '/^(' . implode('|', $customvars) . ')$/i'; + $query = Customvar::fromParams(array('backend' => null), array( 'varname', 'varvalue' @@ -136,6 +148,12 @@ abstract class AbstractObject } $this->customvars = $query->getQuery()->fetchPairs(); + foreach ($this->customvars as $name => &$value) { + if (preg_match($customvars, ucwords(str_replace('_', ' ', strtolower($name))))) { + $value = '***'; + } + } + return $this; } From 736113c80cb78aabd16a05eecb9a6f1a92a805fd Mon Sep 17 00:00:00 2001 From: Thomas Gelf Date: Tue, 19 Aug 2014 18:55:58 +0200 Subject: [PATCH 143/159] AuthenticationController: show friendlier hints... ...while not disclosing sensitive information. More to come once we have our setup wizard. fixes #6534 --- .../controllers/AuthenticationController.php | 24 ++++++++----------- 1 file changed, 10 insertions(+), 14 deletions(-) diff --git a/application/controllers/AuthenticationController.php b/application/controllers/AuthenticationController.php index a6a5345ed..4b43ed71b 100644 --- a/application/controllers/AuthenticationController.php +++ b/application/controllers/AuthenticationController.php @@ -54,13 +54,9 @@ class AuthenticationController extends ActionController try { $config = Config::app('authentication'); } catch (NotReadableError $e) { - Logger::error( - new Exception('Cannot load authentication configuration. An exception was thrown:', 0, $e) - ); throw new ConfigurationError( - t( - 'No authentication methods available. Authentication configuration could not be loaded.' - . ' Please check the system log or Icinga Web 2 log for more information' + $this->translate( + 'Could not read your authentiction.ini, no authentication methods are available.' ) ); } @@ -110,25 +106,25 @@ class AuthenticationController extends ActionController } if ($backendsTried === 0) { throw new ConfigurationError( - t( - 'No authentication methods available. It seems that no authentication method has been set' - . ' up. Please check the system log or Icinga Web 2 log for more information' - ) + $this->translate( + 'No authentication methods available. Did you create' + . ' authentication.ini when installing Icinga Web 2?' + ) ); } if ($backendsTried === $backendsWithError) { throw new ConfigurationError( $this->translate( - 'No authentication methods available. It seems that all set up authentication methods have' - . ' errors. Please check the system log or Icinga Web 2 log for more information' + 'All configured authentication methods failed.' + . ' Please check the system log or Icinga Web 2 log for more information.' ) ); } if ($backendsWithError) { $form->addNote( $this->translate( - 'Note that not all authentication backends are available for authentication because they' - . ' have errors. Please check the system log or Icinga Web 2 log for more information' + 'Please note that not all authentication methods where available.' + . ' Check the system log or Icinga Web 2 log for more information.' ) ); } From 686152abf305bd7e4845abfb9edfb9240327ebd1 Mon Sep 17 00:00:00 2001 From: Thomas Gelf Date: Tue, 19 Aug 2014 19:04:29 +0200 Subject: [PATCH 144/159] js/events: fix a small bug introduced right now Links on non-multiselect action tables stopped working. refs #6705 --- public/js/icinga/events.js | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/public/js/icinga/events.js b/public/js/icinga/events.js index 790d245c3..eefca7f47 100644 --- a/public/js/icinga/events.js +++ b/public/js/icinga/events.js @@ -400,7 +400,7 @@ rowSelected: function(event) { var self = event.data.self; var icinga = self.icinga; - var $tr = $(this).closest('tr'); + var $tr = $(this); var $table = $tr.closest('table.multiselect'); var data = self.icinga.ui.getSelectionKeys($table); var url = $table.data('icinga-multiselect-url'); @@ -501,11 +501,6 @@ return false; } - // ignore multiselect table row clicks - if ($a.closest('tr[href]').length > 0 && $a.closest('table.action').length > 0) { - return; - } - // ignore multiselect table row clicks if ($a.is('tr') && $a.closest('table.multiselect').length > 0) { return; From 538c6cf90bad5f471963fca41b8d4d12a233b284 Mon Sep 17 00:00:00 2001 From: Thomas Gelf Date: Wed, 20 Aug 2014 09:26:16 +0200 Subject: [PATCH 145/159] js/events: ignore button/submit clicks In case you clicked a (submit) button in an action row this also also triggered that row's click handler. As the event is going to be stopped there, this leads to "unsubmittable forms". Fixed. fixes #6963 --- public/js/icinga/events.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/public/js/icinga/events.js b/public/js/icinga/events.js index eefca7f47..d04912d0f 100644 --- a/public/js/icinga/events.js +++ b/public/js/icinga/events.js @@ -501,6 +501,12 @@ return false; } + // Ignore form elements in action rows + if ($(event.target).is('input') || $(event.target).is('button')) { + return; + } + + // ignore multiselect table row clicks if ($a.is('tr') && $a.closest('table.multiselect').length > 0) { return; From 4eaf94cdf15cf17bcdb40288de8e912db53eb5fd Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Wed, 20 Aug 2014 11:33:22 +0200 Subject: [PATCH 146/159] Show only acknowledgement and user comments by default --- .vagrant-puppet/files/etc/icingaweb/modules/monitoring/menu.ini | 2 +- config/modules/monitoring/menu.ini | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.vagrant-puppet/files/etc/icingaweb/modules/monitoring/menu.ini b/.vagrant-puppet/files/etc/icingaweb/modules/monitoring/menu.ini index c66a611a9..c185fb87d 100644 --- a/.vagrant-puppet/files/etc/icingaweb/modules/monitoring/menu.ini +++ b/.vagrant-puppet/files/etc/icingaweb/modules/monitoring/menu.ini @@ -68,7 +68,7 @@ priority = 70 [Overview.Comments] title = "Comments" -url = "monitoring/list/comments" +url = "monitoring/list/comments?comment_type=(comment|ack)" priority = 70 [Overview.Contacts] diff --git a/config/modules/monitoring/menu.ini b/config/modules/monitoring/menu.ini index c66a611a9..c185fb87d 100644 --- a/config/modules/monitoring/menu.ini +++ b/config/modules/monitoring/menu.ini @@ -68,7 +68,7 @@ priority = 70 [Overview.Comments] title = "Comments" -url = "monitoring/list/comments" +url = "monitoring/list/comments?comment_type=(comment|ack)" priority = 70 [Overview.Contacts] From 4ceecf1146545c93789d9126e0272a87cf2811ed Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Wed, 20 Aug 2014 11:34:24 +0200 Subject: [PATCH 147/159] Let comment view look more standardized and add limit control refs #6637 --- .../views/scripts/list/comments.phtml | 182 ++++++++++-------- 1 file changed, 99 insertions(+), 83 deletions(-) diff --git a/modules/monitoring/application/views/scripts/list/comments.phtml b/modules/monitoring/application/views/scripts/list/comments.phtml index 3ed671fbe..645c35fb6 100644 --- a/modules/monitoring/application/views/scripts/list/comments.phtml +++ b/modules/monitoring/application/views/scripts/list/comments.phtml @@ -1,98 +1,114 @@ +getHelper('CommandForm'); + +?> + +compact): ?>
-tabs ?> -
-sortControl->render($this); ?> -
-paginationControl($comments, null, null, array('preserve' => $this->preserve)); ?> + tabs->render($this); ?> +
+ translate('Sort by'); ?> sortControl->render($this); ?> +
+ widget('limiter', array('url' => $this->url, 'max' => $comments->count())); ?> + paginationControl($comments, null, null, array('preserve' => $this->preserve)); ?>
+
- - - + translate('No comments matching the filter') ?> + + -$cf = $this->getHelper('CommandForm'); - -if (count($comments) === 0) { - echo t('No comments matching the filter'); -} - -foreach ($comments as $comment): - -?> - - + + + +
+ + + type) { + switch ($comment->type) { case 'flapping': - $icon = 'flapping'; - $tooltip = 'Comment was caused by a flapping host or service.'; - break; + $icon = 'flapping'; + $title = $this->translate('Flapping'); + $tooltip = $this->translate('Comment was caused by a flapping host or service.'); + break; case 'comment': - $icon = 'user'; - $tooltip = 'Comment was created by an user.'; - break; + $icon = 'user'; + $title = $this->translate('User Comment'); + $tooltip = $this->translate('Comment was created by an user.'); + break; case 'downtime': - $icon = 'down'; - $tooltip = 'Comment was caused by a downtime.'; + $icon = 'down'; + $title = $this->translate('Downtime'); + $tooltip = $this->translate('Comment was caused by a downtime.'); case 'ack': - $icon = 'acknowledgement'; - $tooltip = 'Comment was caused by an acknowledgement.'; - } + $icon = 'acknowledgement'; + $title = $this->translate('Acknowledgement'); + $tooltip = $this->translate('Comment was caused by an acknowledgement.'); + } ?> - icon($icon . '.png', $tooltip) ?>
- timeSince($comment->timestamp) ?> - - + + + $comment->id, + 'host' => $comment->host + ); + if ($comment->objecttype === 'service') { + $data['service'] = $comment->service; + } ?> - - - - - -
- objecttype === 'service'): ?>icon('service.png', 'Service comment') ?> qlink( - $comment->service, - 'monitoring/show/service', - array( +
+ icon($icon . '.png', $tooltip) ?> +
+ escape($title); ?> +
+ prefixedTimeSince($comment->timestamp); ?> +
+ objecttype === 'service'): ?> + icon('service.png'); ?> + service; ?> + + + translate('on') . ' ' . $comment->host; ?> + + + icon('host.png'); ?> + host; ?> + + +
+ icon('comment.png'); ?> author) + ? '[' . $comment->author . '] ' + : ''; + ?>escape($comment->comment); ?> +
+ persistent + ? $this->translate('This comment is persistent.') + : $this->translate('This comment is not persistent.'); + ?> +
+ expiration ? sprintf( + $this->translate('This comment expires on %s at %s.'), + date('d.m.y', $comment-expiration), + date('H:i', $comment->expiration) + ) : $this->translate('This comment does not expire.'); ?> +
- $comment->id, - 'host' => $comment->host - ); - - if ($comment->objecttype === 'service') { - $data['service'] = $comment->service; - } - - // echo $cf->iconSubmitForm( - // 'img/icons/remove.png', - echo $cf->labelSubmitForm( - 'X', - 'Remove comment', - 'link-like', - 'removecomment', - $data - ); - -?> -
- - +
+ labelSubmitForm( + 'X', + $this->translate('Remove Comment'), + 'link-like', + 'removecomment', + $data + ); ?> +
+
\ No newline at end of file From 78b98a7d67fc6c20dd164b5c65091028aa0931c8 Mon Sep 17 00:00:00 2001 From: Alexander Klimov Date: Wed, 20 Aug 2014 12:19:53 +0200 Subject: [PATCH 148/159] SecurityForm: Add helptext refs #6641 --- modules/monitoring/application/forms/Config/SecurityForm.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/modules/monitoring/application/forms/Config/SecurityForm.php b/modules/monitoring/application/forms/Config/SecurityForm.php index ace1594f2..74577c0d5 100644 --- a/modules/monitoring/application/forms/Config/SecurityForm.php +++ b/modules/monitoring/application/forms/Config/SecurityForm.php @@ -27,7 +27,10 @@ class SecurityForm extends Form array( 'label' => 'Protected Custom Variables', 'required' => true, - 'value' => $this->config->protected_customvars + 'value' => $this->config->protected_customvars, + 'helptext' => '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.' ) ); $this->setSubmitLabel('Save'); From a8d33d90e2db3f44dcb4102778e7e682cf818514 Mon Sep 17 00:00:00 2001 From: Thomas Gelf Date: Wed, 20 Aug 2014 13:36:03 +0200 Subject: [PATCH 149/159] Monitoring\Object: fix a couple of cv-related issues * Don't throw exceptions with no config * Provide a secure default if not configured * Improve code readability --- .../Monitoring/Object/AbstractObject.php | 30 ++++++++++++------- 1 file changed, 19 insertions(+), 11 deletions(-) diff --git a/modules/monitoring/library/Monitoring/Object/AbstractObject.php b/modules/monitoring/library/Monitoring/Object/AbstractObject.php index 483516f9c..703d05780 100644 --- a/modules/monitoring/library/Monitoring/Object/AbstractObject.php +++ b/modules/monitoring/library/Monitoring/Object/AbstractObject.php @@ -121,16 +121,22 @@ abstract class AbstractObject public function fetchCustomvars() { - $monitoringSecurity = Config::module('monitoring')->get('security')->toArray(); - $customvars = array(); - foreach (explode(',', $monitoringSecurity['protected_customvars']) as $customvar) { - $nonWildcards = array(); - foreach (explode('*', $customvar) as $nonWildcard) { - $nonWildcards[] = preg_quote($nonWildcard, '/'); + $blacklist = array(); + $blacklistPattern = '/^(.*pw.*|.*pass.*|community)$/'; + + if ($security = Config::module('monitoring')->get('security')) { + + $blacklistConfig = $security->get('protected_customvars', ''); + + foreach (explode(',', $blacklistConfig) as $customvar) { + $nonWildcards = array(); + foreach (explode('*', $customvar) as $nonWildcard) { + $nonWildcards[] = preg_quote($nonWildcard, '/'); + } + $blacklist[] = implode('.*', $nonWildcards); } - $customvars[] = implode('.*', $nonWildcards); + $blacklistPattern = '/^(' . implode('|', $blacklist) . ')$/i'; } - $customvars = '/^(' . implode('|', $customvars) . ')$/i'; $query = Customvar::fromParams(array('backend' => null), array( 'varname', @@ -147,11 +153,13 @@ abstract class AbstractObject ->where('service_description', $this->service_description); } - $this->customvars = $query->getQuery()->fetchPairs(); - foreach ($this->customvars as $name => &$value) { - if (preg_match($customvars, ucwords(str_replace('_', ' ', strtolower($name))))) { + $customvars = $query->getQuery()->fetchPairs(); + foreach ($customvars as $name => &$value) { + $name = ucwords(str_replace('_', ' ', strtolower($name))); + if ($blacklistPattern && preg_match($blacklistPattern, $name)) { $value = '***'; } + $this->customvars[$name] = $value; } return $this; From bef639ecb8b2ba4393aa94138daebea282f9023b Mon Sep 17 00:00:00 2001 From: Alexander Fuhr Date: Wed, 20 Aug 2014 15:16:42 +0200 Subject: [PATCH 150/159] Update deprecated output variable in puppet files --- .vagrant-puppet/modules/casperjs/manifests/init.pp | 2 +- .vagrant-puppet/modules/cmmi/manifests/init.pp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.vagrant-puppet/modules/casperjs/manifests/init.pp b/.vagrant-puppet/modules/casperjs/manifests/init.pp index 2b9bac3ca..fd54e37f9 100644 --- a/.vagrant-puppet/modules/casperjs/manifests/init.pp +++ b/.vagrant-puppet/modules/casperjs/manifests/init.pp @@ -40,7 +40,7 @@ class casperjs( require => Class['wget'] } - $tld = inline_template('<%= File.basename(output, ".tar.bz2") %>') + $tld = inline_template('<%= File.basename(@output, ".tar.bz2") %>') $src = "${cwd}/casperjs" exec { 'extract-casperjs': diff --git a/.vagrant-puppet/modules/cmmi/manifests/init.pp b/.vagrant-puppet/modules/cmmi/manifests/init.pp index 64e42eb12..e0116fbc9 100644 --- a/.vagrant-puppet/modules/cmmi/manifests/init.pp +++ b/.vagrant-puppet/modules/cmmi/manifests/init.pp @@ -51,7 +51,7 @@ define cmmi( require => Class['wget'] } - $tld = inline_template('<%= File.basename(output, ".tar.gz") %>') + $tld = inline_template('<%= File.basename(@output, ".tar.gz") %>') $src = "${cwd}/${name}/${tld}" exec { "extract-${name}": From 00ac224ec1479a53cb02562fb06e4e8299069298 Mon Sep 17 00:00:00 2001 From: Alexander Fuhr Date: Wed, 20 Aug 2014 15:39:48 +0200 Subject: [PATCH 151/159] Delete deprecated menu.ini.in refs #5749 --- config/modules/monitoring/menu.ini.in | 69 --------------------------- 1 file changed, 69 deletions(-) delete mode 100644 config/modules/monitoring/menu.ini.in diff --git a/config/modules/monitoring/menu.ini.in b/config/modules/monitoring/menu.ini.in deleted file mode 100644 index ef874f6a7..000000000 --- a/config/modules/monitoring/menu.ini.in +++ /dev/null @@ -1,69 +0,0 @@ -[menu] -;Remove component as of #4583 since it's not working -;Issues.title = "Issues" ; Extended version -;Issues.route = "/monitoring/list/services?problems=1&sort=severity" ; Explicit route -;Issues.key = "issues" ; When this key is set in the controller, the item is active - -;Remove component as of #4583 since it's not working -;Changes.title = "Recent Changes" -;Changes.route = "/monitoring/list/services?sort=service_last_state_change" -;_1 = 1 ;Spacer after this section - -Hosts.title = "Hosts" -Hosts.route = "/monitoring/list/hosts" -Hosts.iconClass = "icinga-icon-host-petrol" - -Services.title = "Services" -Services.route = "/monitoring/list/services" -Services.iconClass = "icinga-icon-service-petrol" - -Downtimes.title = "Downtimes" -Downtimes.route = "/monitoring/list/downtimes" -Downtimes.iconClass = "icinga-icon-down-petrol" - -Notifications.title = "Notifications" -Notifications.route = "/monitoring/list/notifications" -Notifications.iconClass = "icinga-icon-notification-petrol" - -Comments.title = "Comments" -Comments.route = "/monitoring/list/comments" -Comments.iconClass = "icinga-icon-comment-petrol" - -;Contacts = "/monitoring/list/contacts" - -;Contact Groups = "/monitoring/list/contactgroups" - -Servicegroups.title = "Servicegroups" -Servicegroups.route = "/monitoring/list/servicegroups" -Servicegroups.iconClass = "icinga-icon-servicegroup-petrol" - -Hostgroups.title = "Hostgroups" -Hostgroups.route = "/monitoring/list/hostgroups" -Hostgroups.iconClass = "icinga-icon-hostgroup-petrol" - -History.title = "History" -History.route = "/monitoring/list/eventhistory" -History.iconClass = "icinga-icon-history-petrol" - -Performance.title = "Performance" -Performance.route ="/monitoring/process/performance" - - -[Hosts] -; New section -; Title property unset means title is "Hosts" -url="#" -iconClass="icon-hosts" -priority=1 - -[Hosts.Problems] -; New section beneath section hosts -title="Problem Hosts" -url="/monitoring/list/hosts?problem=1" -priority=2 - -[Hosts.A Link] -title="Wiki" -url="https://wiki.somewhere.com" -priority=1 -icon="https://wiki.somewhere.com/icon.png" \ No newline at end of file From e0b9730f17746e932e7cb0a3597272dd60c1cc49 Mon Sep 17 00:00:00 2001 From: Alexander Fuhr Date: Wed, 20 Aug 2014 16:01:08 +0200 Subject: [PATCH 152/159] Update configurations source paths in puppet default.pp refs #5749 --- .vagrant-puppet/manifests/default.pp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.vagrant-puppet/manifests/default.pp b/.vagrant-puppet/manifests/default.pp index 1e1607d29..72cb2b237 100644 --- a/.vagrant-puppet/manifests/default.pp +++ b/.vagrant-puppet/manifests/default.pp @@ -710,7 +710,7 @@ file { '/etc/icingaweb/config.ini': } file { '/etc/icingaweb/menu.ini': - source => 'puppet:////vagrant/.vagrant-puppet/files/etc/icingaweb/menu.ini', + source => 'puppet:////vagrant/config/menu.ini', owner => 'apache', group => 'apache', # replace => false, @@ -736,7 +736,7 @@ file { '/etc/icingaweb/modules/monitoring/backends.ini': } file { '/etc/icingaweb/modules/monitoring/config.ini': - source => 'puppet:////vagrant/.vagrant-puppet/files/etc/icingaweb/modules/monitoring/config.ini', + source => 'puppet:////vagrant/config/modules/monitoring/config.ini', owner => 'apache', group => 'apache', } @@ -748,7 +748,7 @@ file { '/etc/icingaweb/modules/monitoring/instances.ini': } file { '/etc/icingaweb/modules/monitoring/menu.ini': - source => 'puppet:////vagrant/.vagrant-puppet/files/etc/icingaweb/modules/monitoring/menu.ini', + source => 'puppet:////vagrant/config/modules/monitoring/menu.ini', owner => 'apache', group => 'apache', } @@ -760,7 +760,7 @@ file { '/etc/icingaweb/dashboard': } file { '/etc/icingaweb/dashboard/dashboard.ini': - source => 'puppet:////vagrant/.vagrant-puppet/files/etc/icingaweb/dashboard/dashboard.ini', + source => 'puppet:////vagrant/config/dashboard/dashboard.ini', owner => 'apache', group => 'apache', } @@ -799,7 +799,7 @@ file { '/etc/icingaweb/modules/doc/': } file { '/etc/icingaweb/modules/doc/menu.ini': - source => 'puppet:////vagrant/.vagrant-puppet/files/etc/icingaweb/modules/doc/menu.ini', + source => 'puppet:////vagrant/config/modules/doc/menu.ini', owner => 'apache', group => 'apache', } From 36a275371f06845b737986e4deca3ca68a450d60 Mon Sep 17 00:00:00 2001 From: Alexander Fuhr Date: Wed, 20 Aug 2014 16:26:52 +0200 Subject: [PATCH 153/159] Delete unnecessary configurations files from .vagrant-puppet fixes #5749 --- .../etc/icingaweb/dashboard/dashboard.ini | 35 ------ .vagrant-puppet/files/etc/icingaweb/menu.ini | 35 ------ .../files/etc/icingaweb/modules/doc/menu.ini | 5 - .../icingaweb/modules/monitoring/config.ini | 2 - .../etc/icingaweb/modules/monitoring/menu.ini | 109 ------------------ 5 files changed, 186 deletions(-) delete mode 100644 .vagrant-puppet/files/etc/icingaweb/dashboard/dashboard.ini delete mode 100644 .vagrant-puppet/files/etc/icingaweb/menu.ini delete mode 100644 .vagrant-puppet/files/etc/icingaweb/modules/doc/menu.ini delete mode 100644 .vagrant-puppet/files/etc/icingaweb/modules/monitoring/config.ini delete mode 100644 .vagrant-puppet/files/etc/icingaweb/modules/monitoring/menu.ini diff --git a/.vagrant-puppet/files/etc/icingaweb/dashboard/dashboard.ini b/.vagrant-puppet/files/etc/icingaweb/dashboard/dashboard.ini deleted file mode 100644 index 50e5a6373..000000000 --- a/.vagrant-puppet/files/etc/icingaweb/dashboard/dashboard.ini +++ /dev/null @@ -1,35 +0,0 @@ -[Incidents] -title = "Current incidents" - -[Incidents.Service Problems] -url = "monitoring/list/services" -service_problem = 1 -limit = 10 -sort = service_severity - -[Incidents.Recently Recovered Services] -url = "monitoring/list/services" -sort = "service_last_state_change" -service_state = 0 -limit = 10 -dir = "desc" - -[Incidents.Host Problems] -url = "monitoring/list/hosts" -host_problem = 1 -sort = host_severity - -[Landing] -title = "Landing page" - -[Landing.Hostgroups] -url = "monitoring/chart/hostgroup?height=400&width=500" - -[Landing.Servicegroups] -url = "monitoring/chart/servicegroup?height=360&width=450" - -[Landing.Unhandled Problem Services] -url = "monitoring/list/services?service_handled=0&service_problem=1" - -[Landing.Unhandled Problem Hosts] -url = "monitoring/list/hosts?host_handled=0&host_problem=1" diff --git a/.vagrant-puppet/files/etc/icingaweb/menu.ini b/.vagrant-puppet/files/etc/icingaweb/menu.ini deleted file mode 100644 index d6f342655..000000000 --- a/.vagrant-puppet/files/etc/icingaweb/menu.ini +++ /dev/null @@ -1,35 +0,0 @@ -[Dashboard] -title = "Dashboard" -url = "dashboard" -icon = "img/icons/dashboard.png" -priority = 10 - -[System] -icon = img/icons/configuration.png -priority = 200 - -[System.Preferences] -title = "Preferences" -url = "preference" -priority = 200 - -[System.Configuration] -title = "Configuration" -url = "config" -priority = 300 - -[System.Modules] -title = "Modules" -url = "config/modules" -priority = 400 - -[System.ApplicationLog] -title = "Application log" -url = "list/applicationlog" -priority = 500 - -[Logout] -url = "authentication/logout" -icon = img/icons/logout.png -priority = 300 - diff --git a/.vagrant-puppet/files/etc/icingaweb/modules/doc/menu.ini b/.vagrant-puppet/files/etc/icingaweb/modules/doc/menu.ini deleted file mode 100644 index 86889b239..000000000 --- a/.vagrant-puppet/files/etc/icingaweb/modules/doc/menu.ini +++ /dev/null @@ -1,5 +0,0 @@ -[Documentation] -title = "Documentation" -icon = "img/icons/comment.png" -url = "doc" -priority = 80 diff --git a/.vagrant-puppet/files/etc/icingaweb/modules/monitoring/config.ini b/.vagrant-puppet/files/etc/icingaweb/modules/monitoring/config.ini deleted file mode 100644 index 9b69fe86f..000000000 --- a/.vagrant-puppet/files/etc/icingaweb/modules/monitoring/config.ini +++ /dev/null @@ -1,2 +0,0 @@ -[security] -protected_customvars = "*pw*,*pass*,community" diff --git a/.vagrant-puppet/files/etc/icingaweb/modules/monitoring/menu.ini b/.vagrant-puppet/files/etc/icingaweb/modules/monitoring/menu.ini deleted file mode 100644 index c185fb87d..000000000 --- a/.vagrant-puppet/files/etc/icingaweb/modules/monitoring/menu.ini +++ /dev/null @@ -1,109 +0,0 @@ - -[Problems] -priority = 20 -icon = "img/icons/error.png" - -[Problems.Unhandled Hosts] -priority = 40 -url = "monitoring/list/hosts?host_problem=1&host_handled=0" - -[Problems.Unhandled Services] -priority = 40 -url = "monitoring/list/services?service_problem=1&service_handled=0&sort=service_severity" - -[Problems.Host Problems] -priority = 50 -url = "monitoring/list/hosts?host_problem=1&sort=host_severity" - -[Problems.Service Problems] -priority = 50 -url = "monitoring/list/services?service_problem=1&sort=service_severity&dir=desc" - -[Problems.Current Downtimes] -url = "monitoring/list/downtimes?downtime_is_in_effect=1" - -[Overview] -priority = 30 -icon = "img/icons/hostgroup.png" - -[Overview.Tactical Overview] -title = "Tactical Overview" -url = "monitoring/tactical" -priority = 40 - -[Overview.Hosts] -title = "Hosts" -url = "monitoring/list/hosts" -priority = 50 - -[Overview.Services] -title = "Services" -url = "monitoring/list/services" -priority = 50 - -[Overview.Servicematrix] -title = "Servicematrix" -url = "monitoring/list/servicematrix?service_problem=1" -priority = 51 - -[Overview.Servicegroups] -title = "Servicegroups" -url = "monitoring/list/servicegroups" -priority = 60 - -[Overview.Hostgroups] -title = "Hostgroups" -url = "monitoring/list/hostgroups" -priority = 60 - -[Overview.Contactgroups] -title = "Contactgroups" -url = "monitoring/list/contactgroups" -priority = 61 - -[Overview.Downtimes] -title = "Downtimes" -url = "monitoring/list/downtimes" -priority = 70 - -[Overview.Comments] -title = "Comments" -url = "monitoring/list/comments?comment_type=(comment|ack)" -priority = 70 - -[Overview.Contacts] -title = "Contacts" -url = "monitoring/list/contacts" -priority = 70 - -[History] -icon = "img/icons/history.png" - -[History.Critical Events] -title = "Critical Events" -url = "monitoring/list/statehistorysummary" -priority = 50 - -[History.Notifications] -title = "Notifications" -url = "monitoring/list/notifications" - -[History.Events] -title = "All Events" -url = "monitoring/list/eventhistory?timestamp>=-7%20days" - -[History.Timeline] -title = "Timeline" -url = "monitoring/timeline" - -[System.Process Info] -title = "Process Info" -url = "monitoring/process/info" -priority = 120 - -[System.Performance Info] -title = "Performance Info" -url = "monitoring/process/performance" -priority = 130 - - From b36fe5d5643da818562b6bb972c673f746d66e6d Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Thu, 21 Aug 2014 10:06:03 +0200 Subject: [PATCH 154/159] Fix version access while refreshing translations --- .../Util/GettextTranslationHelper.php | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/modules/translation/library/Translation/Util/GettextTranslationHelper.php b/modules/translation/library/Translation/Util/GettextTranslationHelper.php index 895e01fa5..a19353f33 100644 --- a/modules/translation/library/Translation/Util/GettextTranslationHelper.php +++ b/modules/translation/library/Translation/Util/GettextTranslationHelper.php @@ -37,12 +37,19 @@ class GettextTranslationHelper private $moduleMgr; /** - * The current version of IcingaWeb2 + * The current version of Icingaweb 2 or of the module the catalog is being created for * * @var string */ private $version; + /** + * The name of the module if any + * + * @var string + */ + private $moduleName; + /** * The locale used by this helper * @@ -93,8 +100,7 @@ class GettextTranslationHelper */ public function __construct(ApplicationBootstrap $bootstrap, $locale) { - $this->version = $bootstrap->getConfig()->app()->global->get('version', '0.1'); - $this->moduleMgr = $bootstrap->getModuleManager(); + $this->moduleMgr = $bootstrap->getModuleManager()->loadEnabledModules(); $this->appDir = $bootstrap->getApplicationDir(); $this->locale = $locale; } @@ -106,6 +112,7 @@ class GettextTranslationHelper { $this->catalogPath = tempnam(sys_get_temp_dir(), 'IcingaTranslation_'); $this->templatePath = tempnam(sys_get_temp_dir(), 'IcingaPot_'); + $this->version = 'None'; // TODO: Access icinga version from a file or property $this->moduleDir = null; $this->tablePath = implode( @@ -133,6 +140,8 @@ class GettextTranslationHelper { $this->catalogPath = tempnam(sys_get_temp_dir(), 'IcingaTranslation_'); $this->templatePath = tempnam(sys_get_temp_dir(), 'IcingaPot_'); + $this->version = $this->moduleMgr->getModule($module)->getVersion(); + $this->moduleName = $this->moduleMgr->getModule($module)->getName(); $this->moduleDir = $this->moduleMgr->getModuleDir($module); $this->tablePath = implode( @@ -251,7 +260,7 @@ class GettextTranslationHelper 'author_name' => 'FIRST AUTHOR', 'author_mail' => 'EMAIL@ADDRESS', 'author_year' => 'YEAR', - 'project_name' => 'Icinga Web 2', + 'project_name' => $this->moduleName ? ucfirst($this->moduleName) . ' Module' : 'Icinga Web 2', 'project_version' => $this->version, 'project_bug_mail' => 'dev@icinga.org', 'pot_creation_date' => date('Y-m-d H:iO'), From b146a8c311b0694f0fa0a8a92e064939fbf30484 Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Thu, 21 Aug 2014 10:06:53 +0200 Subject: [PATCH 155/159] Relax locale code validation to just a format check fixes #6930 --- .../library/Translation/Cli/TranslationCommand.php | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/modules/translation/library/Translation/Cli/TranslationCommand.php b/modules/translation/library/Translation/Cli/TranslationCommand.php index 2cdc875ec..417d9d6ed 100644 --- a/modules/translation/library/Translation/Cli/TranslationCommand.php +++ b/modules/translation/library/Translation/Cli/TranslationCommand.php @@ -23,12 +23,8 @@ class TranslationCommand extends Command */ public function validateLocaleCode($code) { - $current = setlocale(LC_ALL, '0'); - $result = setlocale(LC_ALL, $code); - setlocale(LC_ALL, $current); - - if ($result === false) { - throw new Exception("Locale code '$code' is not valid"); + if (! preg_match('@[a-z]{2}_[A-Z]{2}@', $code)) { + throw new Exception("Locale code '$code' is not valid. Expected format is: ll_CC"); } return $code; From 30d0ebcdfdbaa3a7bbb14be5f83b2104c538f813 Mon Sep 17 00:00:00 2001 From: Alexander Klimov Date: Wed, 20 Aug 2014 18:15:38 +0200 Subject: [PATCH 156/159] Make 'modules/monitoring/config.ini' doesn't have to exist --- modules/monitoring/application/forms/Config/SecurityForm.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/modules/monitoring/application/forms/Config/SecurityForm.php b/modules/monitoring/application/forms/Config/SecurityForm.php index 74577c0d5..b0749868d 100644 --- a/modules/monitoring/application/forms/Config/SecurityForm.php +++ b/modules/monitoring/application/forms/Config/SecurityForm.php @@ -21,13 +21,14 @@ class SecurityForm extends Form */ public function create() { + $default = '*pw*,*pass*,community'; $this->addElement( 'text', 'protected_customvars', array( 'label' => 'Protected Custom Variables', 'required' => true, - 'value' => $this->config->protected_customvars, + 'value' => $this->config ? $this->config->get('protected_customvars', $default) : $default, 'helptext' => '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.' From 8733238a6e222926d5ac8683bff01c546f29bfb3 Mon Sep 17 00:00:00 2001 From: Alexander Klimov Date: Thu, 21 Aug 2014 12:40:41 +0200 Subject: [PATCH 157/159] Loader::registerNamespace(): correct exception message --- library/Icinga/Application/Loader.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/library/Icinga/Application/Loader.php b/library/Icinga/Application/Loader.php index bc31cfbb1..56e59f4b2 100644 --- a/library/Icinga/Application/Loader.php +++ b/library/Icinga/Application/Loader.php @@ -40,9 +40,9 @@ class Loader { if (!is_dir($directory)) { throw new ProgrammingError(sprintf( - 'Namespace directory "%s" for "%s" does not exist', - $namespace, - $directory + 'Directory "%s" for namespace "%s" does not exist', + $directory, + $namespace )); } From af97db31d7a28f48a9911914a96f77f54dc87f78 Mon Sep 17 00:00:00 2001 From: Thomas Gelf Date: Thu, 21 Aug 2014 18:42:01 +0200 Subject: [PATCH 158/159] StaticController: fix gravatar sample img header --- application/controllers/StaticController.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/application/controllers/StaticController.php b/application/controllers/StaticController.php index df930c3d7..3a15b1b1e 100644 --- a/application/controllers/StaticController.php +++ b/application/controllers/StaticController.php @@ -30,8 +30,8 @@ class StaticController extends ActionController public function gravatarAction() { + header('Content-Type: image/jpg'); $img = file_get_contents('http://www.gravatar.com/avatar/' . md5(strtolower(trim($this->_request->getParam('email')))) . '?s=200&d=mm'); - header('image/jpeg'); echo $img; } From 09412d03b62acd041bc82869bb6a3dec695385a5 Mon Sep 17 00:00:00 2001 From: Thomas Gelf Date: Fri, 22 Aug 2014 09:34:43 +0200 Subject: [PATCH 159/159] Benchmark: hide timestamp on HTML output Wastes space and is mostly useless, absolut and relative expired time gives more than enough information. --- library/Icinga/Application/Benchmark.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/library/Icinga/Application/Benchmark.php b/library/Icinga/Application/Benchmark.php index c510c61bf..fd69dd510 100644 --- a/library/Icinga/Application/Benchmark.php +++ b/library/Icinga/Application/Benchmark.php @@ -142,6 +142,7 @@ class Benchmark // TODO: Move formatting to CSS file $html = '' . "\n" . ''; foreach ($data->columns as & $col) { + if ($col->title === 'Time') continue; $html .= sprintf( '', $col->align, @@ -153,6 +154,7 @@ class Benchmark foreach ($data->rows as & $row) { $html .= ''; foreach ($data->columns as $key => & $col) { + if ($col->title === 'Time') continue; $html .= sprintf( '', $col->align,
%s
%s