From ccd0709fbaa9d49548e2da8ea006d291de50bd7e Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Wed, 6 Nov 2019 15:43:17 +0100 Subject: [PATCH] Controller: Add method `applyMonitoringRestriction` --- library/Icingadb/Web/Controller.php | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/library/Icingadb/Web/Controller.php b/library/Icingadb/Web/Controller.php index f3c22a16..3c04268c 100644 --- a/library/Icingadb/Web/Controller.php +++ b/library/Icingadb/Web/Controller.php @@ -6,6 +6,8 @@ use Generator; use Icinga\Application\Icinga; use Icinga\Data\Filter\Filter; use Icinga\Data\ResourceFactory; +use Icinga\Module\Icingadb\Compat\MonitoringRestrictions; +use Icinga\Module\Icingadb\Compat\UrlMigrator; use Icinga\Module\Icingadb\Widget\FilterControl; use Icinga\Module\Icingadb\Widget\ViewModeSwitcher; use ipl\Html\Html; @@ -208,6 +210,21 @@ class Controller extends CompatController return $this; } + public function applyMonitoringRestriction(Query $query, $queryTransformer = null) + { + if ($queryTransformer === null || UrlMigrator::hasQueryTransformer($queryTransformer)) { + $restriction = UrlMigrator::transformFilter( + MonitoringRestrictions::getRestriction('monitoring/filter/objects'), + $queryTransformer + ); + if ($restriction) { + FilterProcessor::apply($restriction, $query); + } + } + + return $this; + } + public function preDispatch() { $this->format = $this->params->shift('format');