diff --git a/application/layouts/scripts/body.phtml b/application/layouts/scripts/body.phtml index 18fc18872..325b1026b 100644 --- a/application/layouts/scripts/body.phtml +++ b/application/layouts/scripts/body.phtml @@ -5,7 +5,7 @@ use Icinga\Web\Notification; use Icinga\Authentication\Auth; $moduleName = $this->layout()->moduleName; -if ($moduleName) { +if ($moduleName !== 'default') { $moduleClass = ' icinga-module module-' . $moduleName; } else { $moduleClass = ''; diff --git a/application/layouts/scripts/pdf.phtml b/application/layouts/scripts/pdf.phtml index c5b28ecbf..ed8e12780 100644 --- a/application/layouts/scripts/pdf.phtml +++ b/application/layouts/scripts/pdf.phtml @@ -4,7 +4,7 @@ use Icinga\Web\StyleSheet; $moduleName = $this->layout()->moduleName; -if ($moduleName) { +if ($moduleName !== 'default') { $moduleClass = ' icinga-module module-' . $moduleName; } else { $moduleClass = ''; diff --git a/doc/authentication.md b/doc/authentication.md index 39e0caf3c..2b4452042 100644 --- a/doc/authentication.md +++ b/doc/authentication.md @@ -62,14 +62,14 @@ with Icinga Web 2 (e.g. an alias) no matter what the primary user id might actua Directive | Description ------------------------|------------ -**backend** | `ad` +**backend** | `msldap` **resource** | The name of the LDAP resource defined in [resources.ini](resources.md#resources). **Example:** ``` [auth_ad] -backend = ad +backend = msldap resource = my_ad ``` diff --git a/library/Icinga/Util/String.php b/library/Icinga/Util/String.php index d67035b3f..712114ee2 100644 --- a/library/Icinga/Util/String.php +++ b/library/Icinga/Util/String.php @@ -4,7 +4,7 @@ namespace Icinga\Util; /** - * Common string helper + * Common string functions */ class String { @@ -103,8 +103,8 @@ class String /** * Check if a string ends with a different string * - * @param $haystack The string to search for matches - * @param $needle The string to match at the start of the haystack + * @param $haystack string The string to search for matches + * @param $needle string The string to match at the start of the haystack * * @return bool Whether or not needle is at the beginning of haystack */ diff --git a/library/Icinga/Web/Controller/ActionController.php b/library/Icinga/Web/Controller/ActionController.php index 2787f961e..ecb0564f9 100644 --- a/library/Icinga/Web/Controller/ActionController.php +++ b/library/Icinga/Web/Controller/ActionController.php @@ -38,6 +38,13 @@ class ActionController extends Zend_Controller_Action */ protected $requiresAuthentication = true; + /** + * The current module's name + * + * @var string + */ + private $moduleName; + private $autorefreshInterval; private $reloadCss = false; @@ -90,11 +97,11 @@ class ActionController extends Zend_Controller_Action $this->_helper = new ActionHelperBroker($this); $this->handlerBrowserWindows(); - $this->view->tabs = new Tabs(); - $this->view->translationDomain = 'icinga'; + $moduleName = $this->getModuleName(); + $this->view->translationDomain = $moduleName !== 'default' ? $moduleName : 'icinga'; $this->_helper->layout()->isIframe = $request->getUrl()->shift('isIframe'); $this->_helper->layout()->showFullscreen = $request->getUrl()->shift('showFullscreen'); - $this->_helper->layout()->moduleName = false; + $this->_helper->layout()->moduleName = $moduleName; $this->view->compact = $request->getParam('view') === 'compact'; if ($request->getUrl()->shift('showCompact')) { @@ -107,12 +114,12 @@ class ActionController extends Zend_Controller_Action $this->_helper->layout()->disableLayout(); } - $this->prepareInit(); - if ($this->requiresLogin()) { $this->redirectToLogin(Url::fromRequest()); } + $this->view->tabs = new Tabs(); + $this->prepareInit(); $this->init(); } @@ -167,6 +174,20 @@ class ActionController extends Zend_Controller_Action } } + /** + * Return the current module's name + * + * @return string + */ + public function getModuleName() + { + if ($this->moduleName === null) { + $this->moduleName = $this->getRequest()->getModuleName(); + } + + return $this->moduleName; + } + public function Config($file = null) { if ($file === null) { diff --git a/library/Icinga/Web/Controller/ModuleActionController.php b/library/Icinga/Web/Controller/ModuleActionController.php index 60990d5d8..cf39a4908 100644 --- a/library/Icinga/Web/Controller/ModuleActionController.php +++ b/library/Icinga/Web/Controller/ModuleActionController.php @@ -6,6 +6,7 @@ namespace Icinga\Web\Controller; use Icinga\Application\Config; use Icinga\Application\Icinga; use Icinga\Application\Modules\Manager; +use Icinga\Application\Modules\Module; /** * Base class for module action controllers @@ -18,25 +19,15 @@ class ModuleActionController extends ActionController private $module; - /** - * Module name - * - * @var string - */ - protected $moduleName; - /** * (non-PHPDoc) * @see \Icinga\Web\Controller\ActionController For the method documentation. */ protected function prepareInit() { - $this->moduleName = $this->_request->getModuleName(); - $this->_helper->layout()->moduleName = $this->moduleName; - $this->view->translationDomain = $this->moduleName; $this->moduleInit(); - if ($this->getFrontController()->getDefaultModule() !== $this->moduleName) { - $this->assertPermission(Manager::MODULE_PERMISSION_NS . $this->moduleName); + if ($this->getFrontController()->getDefaultModule() !== $this->getModuleName()) { + $this->assertPermission(Manager::MODULE_PERMISSION_NS . $this->getModuleName()); } } @@ -51,22 +42,28 @@ class ModuleActionController extends ActionController { if ($file === null) { if ($this->config === null) { - $this->config = Config::module($this->moduleName); + $this->config = Config::module($this->getModuleName()); } return $this->config; } else { if (! array_key_exists($file, $this->configs)) { - $this->configs[$file] = Config::module($this->moduleName, $file); + $this->configs[$file] = Config::module($this->getModuleName(), $file); } return $this->configs[$file]; } } + /** + * Return this controller's module + * + * @return Module + */ public function Module() { if ($this->module === null) { - $this->module = Icinga::app()->getModuleManager()->getModule($this->moduleName); + $this->module = Icinga::app()->getModuleManager()->getModule($this->getModuleName()); } + return $this->module; } @@ -77,6 +74,6 @@ class ModuleActionController extends ActionController public function postDispatchXhr() { parent::postDispatchXhr(); - $this->getResponse()->setHeader('X-Icinga-Module', $this->moduleName, true); + $this->getResponse()->setHeader('X-Icinga-Module', $this->getModuleName(), true); } } diff --git a/modules/monitoring/application/views/scripts/list/notifications.phtml b/modules/monitoring/application/views/scripts/list/notifications.phtml index 30b3c5875..06028c993 100644 --- a/modules/monitoring/application/views/scripts/list/notifications.phtml +++ b/modules/monitoring/application/views/scripts/list/notifications.phtml @@ -36,7 +36,8 @@ if (! $this->compact): ?> $notification->service_description, $notification->service_display_name, $notification->host_name, - $notification->host_display_name + $notification->host_display_name, + 'rowaction' ) ?> icon('host', $this->translate('Host')); ?> diff --git a/modules/monitoring/library/Monitoring/Backend/Ido/Query/EventhistoryQuery.php b/modules/monitoring/library/Monitoring/Backend/Ido/Query/EventhistoryQuery.php index e14fc6e86..c9acd16fc 100644 --- a/modules/monitoring/library/Monitoring/Backend/Ido/Query/EventhistoryQuery.php +++ b/modules/monitoring/library/Monitoring/Backend/Ido/Query/EventhistoryQuery.php @@ -9,7 +9,7 @@ use Icinga\Data\Filter\Filter; /** * Query for event history records */ -class EventHistoryQuery extends IdoQuery +class EventhistoryQuery extends IdoQuery { /** * {@inheritdoc} diff --git a/modules/monitoring/library/Monitoring/Backend/Ido/Query/GroupsummaryQuery.php b/modules/monitoring/library/Monitoring/Backend/Ido/Query/GroupsummaryQuery.php index da33c2bc6..9ed526d79 100644 --- a/modules/monitoring/library/Monitoring/Backend/Ido/Query/GroupsummaryQuery.php +++ b/modules/monitoring/library/Monitoring/Backend/Ido/Query/GroupsummaryQuery.php @@ -8,7 +8,7 @@ use Zend_Db_Select; /** * Query for host and service group summaries */ -class GroupSummaryQuery extends IdoQuery +class GroupsummaryQuery extends IdoQuery { /** * {@inheritdoc} diff --git a/modules/monitoring/library/Monitoring/Backend/Ido/Query/StatussummaryQuery.php b/modules/monitoring/library/Monitoring/Backend/Ido/Query/StatussummaryQuery.php index 9d94e8149..e138a3f5e 100644 --- a/modules/monitoring/library/Monitoring/Backend/Ido/Query/StatussummaryQuery.php +++ b/modules/monitoring/library/Monitoring/Backend/Ido/Query/StatussummaryQuery.php @@ -10,7 +10,7 @@ use Icinga\Data\Filter\Filter; /** * Query for host and service status summary */ -class StatusSummaryQuery extends IdoQuery +class StatussummaryQuery extends IdoQuery { /** * {@inheritdoc} diff --git a/modules/monitoring/library/Monitoring/DataView/DataView.php b/modules/monitoring/library/Monitoring/DataView/DataView.php index 513e419fb..69adb5839 100644 --- a/modules/monitoring/library/Monitoring/DataView/DataView.php +++ b/modules/monitoring/library/Monitoring/DataView/DataView.php @@ -29,8 +29,6 @@ abstract class DataView implements QueryInterface, SortRules, FilterColumns, Ite */ protected $query; - protected $filter; - protected $connection; protected $isSorted = false; @@ -52,7 +50,6 @@ abstract class DataView implements QueryInterface, SortRules, FilterColumns, Ite { $this->connection = $connection; $this->query = $connection->query($this->getQueryName(), $columns); - $this->filter = Filter::matchAll(); } /** @@ -91,7 +88,6 @@ abstract class DataView implements QueryInterface, SortRules, FilterColumns, Ite public function where($condition, $value = null) { - $this->filter->addFilter(Filter::where($condition, $value)); $this->query->where($condition, $value); return $this; } @@ -268,9 +264,14 @@ abstract class DataView implements QueryInterface, SortRules, FilterColumns, Ite return $columns; } + /** + * Return the current filter + * + * @return Filter + */ public function getFilter() { - return $this->filter; + return $this->query->getFilter(); } /** @@ -471,8 +472,7 @@ abstract class DataView implements QueryInterface, SortRules, FilterColumns, Ite */ public function addFilter(Filter $filter) { - $this->query->addFilter(clone($filter)); - $this->filter = $filter; // TODO: Hmmmm.... and? + $this->query->addFilter($filter); return $this; } @@ -496,7 +496,8 @@ abstract class DataView implements QueryInterface, SortRules, FilterColumns, Ite */ public function peekAhead($state = true) { - return $this->query->peekAhead($state); + $this->query->peekAhead($state); + return $this; } /** diff --git a/modules/monitoring/library/Monitoring/Object/MonitoredObject.php b/modules/monitoring/library/Monitoring/Object/MonitoredObject.php index 5f278c92e..502a1a2d1 100644 --- a/modules/monitoring/library/Monitoring/Object/MonitoredObject.php +++ b/modules/monitoring/library/Monitoring/Object/MonitoredObject.php @@ -450,21 +450,29 @@ abstract class MonitoredObject implements Filterable */ public function fetchEventhistory() { - $eventHistory = $this->backend->select()->from('eventhistory', array( - 'object_type', - 'host_name', - 'host_display_name', - 'service_description', - 'service_display_name', - 'timestamp', - 'state', - 'output', - 'type' - )) + $eventHistory = $this->backend + ->select() + ->from( + 'eventhistory', + array( + 'object_type', + 'host_name', + 'host_display_name', + 'service_description', + 'service_display_name', + 'timestamp', + 'state', + 'output', + 'type' + ) + ) + ->where('object_type', $this->type) ->where('host_name', $this->host_name); + if ($this->type === self::TYPE_SERVICE) { $eventHistory->where('service_description', $this->service_description); } + $this->eventhistory = $eventHistory->applyFilter($this->getFilter()); return $this; } diff --git a/public/js/icinga/loader.js b/public/js/icinga/loader.js index 758f21656..ff63f808a 100644 --- a/public/js/icinga/loader.js +++ b/public/js/icinga/loader.js @@ -424,7 +424,9 @@ this.icinga.ui.reloadCss(); } - if (req.getResponseHeader('X-Icinga-Redirect')) return; + if (req.getResponseHeader('X-Icinga-Redirect')) { + return; + } // div helps getting an XML tree var $resp = $('
' + req.responseText + '
'); @@ -515,8 +517,6 @@ var $el = $(el); if ($el.hasClass('dashboard')) { return; - } else { - } var url = $el.data('icingaUrl'); targets[i].data('icingaUrl', url); @@ -533,28 +533,9 @@ this.icinga.ui.initializeTriStates($resp); - /* Should we try to fiddle with responses containing full HTML? */ - /* - if ($('body', $resp).length) { - req.responseText = $('script', $('body', $resp).html()).remove(); + if (rendered) { + return; } - */ - /* - - var containers = []; - - $('.dashboard .container').each(function(idx, el) { - urls.push($(el).data('icingaUrl')); - }); - console.log(urls); - $('.container[data-icinga-refresh]').each(function(idx, el) { - var $el = $(el); - self.loadUrl($el.data('icingaUrl'), $el).autorefresh = true; - el = null; - }); - */ - - if (rendered) return; // .html() removes outer div we added above this.renderContentToContainer($resp.html(), req.$target, req.action, req.autorefresh); @@ -652,8 +633,7 @@ /* * Test if a manual actions comes in and autorefresh is active: Stop refreshing */ - if (req.addToHistory && ! req.autorefresh && req.$target.data('icingaRefresh') > 0 - && req.$target.data('icingaUrl') !== url) { + if (req.addToHistory && ! req.autorefresh && req.$target.data('icingaRefresh') > 0) { req.$target.data('icingaRefresh', 0); req.$target.data('icingaUrl', url); }