diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-14 13:17:48 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-14 13:17:48 +0000 |
commit | e6d4dfc040bbe3cb80a2ce65b82493b557f751fc (patch) | |
tree | 40bd6366b01b06f4d96fc8638f23a772263cb5e9 /library/Director/ProvidedHook/Monitoring | |
parent | Releasing progress-linux version 1.10.2-2~progress7.99u1. (diff) | |
download | icingaweb2-module-director-e6d4dfc040bbe3cb80a2ce65b82493b557f751fc.tar.xz icingaweb2-module-director-e6d4dfc040bbe3cb80a2ce65b82493b557f751fc.zip |
Merging upstream version 1.11.1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'library/Director/ProvidedHook/Monitoring')
-rw-r--r-- | library/Director/ProvidedHook/Monitoring/HostActions.php | 18 | ||||
-rw-r--r-- | library/Director/ProvidedHook/Monitoring/ServiceActions.php | 16 |
2 files changed, 14 insertions, 20 deletions
diff --git a/library/Director/ProvidedHook/Monitoring/HostActions.php b/library/Director/ProvidedHook/Monitoring/HostActions.php index 2e3fba0..2d0469d 100644 --- a/library/Director/ProvidedHook/Monitoring/HostActions.php +++ b/library/Director/ProvidedHook/Monitoring/HostActions.php @@ -5,8 +5,9 @@ namespace Icinga\Module\Director\ProvidedHook\Monitoring; use Exception; use Icinga\Application\Config; use Icinga\Authentication\Auth; +use Icinga\Module\Director\Auth\Permission; use Icinga\Module\Director\Db; -use Icinga\Module\Director\Monitoring; +use Icinga\Module\Director\Integration\MonitoringModule\Monitoring; use Icinga\Module\Director\Objects\IcingaHost; use Icinga\Module\Director\Util; use Icinga\Module\Monitoring\Hook\HostActionsHook; @@ -32,7 +33,7 @@ class HostActions extends HostActionsHook return $actions; } $hostname = $host->host_name; - if (Util::hasPermission('director/inspect')) { + if (Util::hasPermission(Permission::INSPECT)) { $actions[mt('director', 'Inspect')] = Url::fromPath( 'director/inspect/object', array('type' => 'host', 'plural' => 'hosts', 'name' => $hostname) @@ -40,22 +41,17 @@ class HostActions extends HostActionsHook } $allowEdit = false; - if (Util::hasPermission('director/hosts') && IcingaHost::exists($hostname, $db)) { + if (Util::hasPermission(Permission::HOSTS) && IcingaHost::exists($hostname, $db)) { $allowEdit = true; } - $auth = Auth::getInstance(); - if (Util::hasPermission('director/monitoring/hosts')) { - $monitoring = new Monitoring(); - if ($monitoring->isAvailable() && $monitoring->authCanEditHost($auth, $hostname)) { + if (Util::hasPermission(Permission::MONITORING_HOSTS)) { + if ((new Monitoring(Auth::getInstance()))->canModifyHost($hostname)) { $allowEdit = IcingaHost::exists($hostname, $db); } } if ($allowEdit) { - $actions[mt('director', 'Modify')] = Url::fromPath( - 'director/host/edit', - array('name' => $hostname) - ); + $actions[mt('director', 'Modify')] = Url::fromPath('director/host/edit', ['name' => $hostname]); } return $actions; diff --git a/library/Director/ProvidedHook/Monitoring/ServiceActions.php b/library/Director/ProvidedHook/Monitoring/ServiceActions.php index b2e303a..834b166 100644 --- a/library/Director/ProvidedHook/Monitoring/ServiceActions.php +++ b/library/Director/ProvidedHook/Monitoring/ServiceActions.php @@ -5,8 +5,9 @@ namespace Icinga\Module\Director\ProvidedHook\Monitoring; use Exception; use Icinga\Application\Config; use Icinga\Authentication\Auth; +use Icinga\Module\Director\Auth\Permission; use Icinga\Module\Director\Db; -use Icinga\Module\Director\Monitoring; +use Icinga\Module\Director\Integration\MonitoringModule\Monitoring; use Icinga\Module\Director\Objects\IcingaHost; use Icinga\Module\Director\Util; use Icinga\Module\Monitoring\Hook\ServiceActionsHook; @@ -39,7 +40,7 @@ class ServiceActions extends ServiceActionsHook $hostname = $service->host_name; $serviceName = $service->service_description; - if (Util::hasPermission('director/inspect')) { + if (Util::hasPermission(Permission::INSPECT)) { $actions[mt('director', 'Inspect')] = Url::fromPath('director/inspect/object', [ 'type' => 'service', 'plural' => 'services', @@ -52,16 +53,13 @@ class ServiceActions extends ServiceActionsHook } $title = null; - if (Util::hasPermission('director/hosts')) { + if (Util::hasPermission(Permission::HOSTS)) { $title = mt('director', 'Modify'); - } elseif (Util::hasPermission('director/monitoring/services')) { - $monitoring = new Monitoring(); - if ($monitoring->isAvailable() - && $monitoring->authCanEditService(Auth::getInstance(), $hostname, $serviceName) - ) { + } elseif (Util::hasPermission(Permission::MONITORING_SERVICES)) { + if ((new Monitoring(Auth::getInstance()))->canModifyService($hostname, $serviceName)) { $title = mt('director', 'Modify'); } - } elseif (Util::hasPermission('director/monitoring/services-ro')) { + } elseif (Util::hasPermission(Permission::MONITORING_SERVICES_RO)) { $title = mt('director', 'Configuration'); } |