From 3985f67fe7aeba9dba965263310656169be0c786 Mon Sep 17 00:00:00 2001 From: "Alexander A. Klimov" Date: Mon, 4 Dec 2017 18:05:07 +0100 Subject: [PATCH] Fix "Host not found" error refs #147 --- application/controllers/HostController.php | 24 +++++++++++++++++ application/controllers/ServiceController.php | 27 +++++++++++++++++++ application/views/scripts/host/show.phtml | 12 +++++++++ application/views/scripts/service/show.phtml | 17 ++++++++++++ library/Businessprocess/HostNode.php | 2 +- library/Businessprocess/ServiceNode.php | 2 +- 6 files changed, 82 insertions(+), 2 deletions(-) create mode 100644 application/controllers/HostController.php create mode 100644 application/controllers/ServiceController.php create mode 100644 application/views/scripts/host/show.phtml create mode 100644 application/views/scripts/service/show.phtml diff --git a/application/controllers/HostController.php b/application/controllers/HostController.php new file mode 100644 index 0000000..134ab5b --- /dev/null +++ b/application/controllers/HostController.php @@ -0,0 +1,24 @@ +params->getRequired('host'); + + $query = $this->backend->select() + ->from('hoststatus', array('host_name')) + ->where('host_name', $host); + + if ($this->applyRestriction('monitoring/filter/objects', $query)->fetchRow() !== false) { + $this->redirectNow(Url::fromPath('monitoring/host/show')->setParams($this->params)); + } + + $this->view->host = $host; + } +} diff --git a/application/controllers/ServiceController.php b/application/controllers/ServiceController.php new file mode 100644 index 0000000..17bb474 --- /dev/null +++ b/application/controllers/ServiceController.php @@ -0,0 +1,27 @@ +params->getRequired('host'); + $service = $this->params->getRequired('service'); + + $query = $this->backend->select() + ->from('servicestatus', array('service_description')) + ->where('host_name', $host) + ->where('service_description', $service); + + if ($this->applyRestriction('monitoring/filter/objects', $query)->fetchRow() !== false) { + $this->redirectNow(Url::fromPath('monitoring/service/show')->setParams($this->params)); + } + + $this->view->host = $host; + $this->view->service = $service; + } +} diff --git a/application/views/scripts/host/show.phtml b/application/views/scripts/host/show.phtml new file mode 100644 index 0000000..1455c80 --- /dev/null +++ b/application/views/scripts/host/show.phtml @@ -0,0 +1,12 @@ + +
+ showOnlyCloseButton() ?> +
+
+

escape($this->translate('Access denied')) ?>

+

escape($this->translate('Access to host "%s" denied')), $host) ?>

+
diff --git a/application/views/scripts/service/show.phtml b/application/views/scripts/service/show.phtml new file mode 100644 index 0000000..5b0aee6 --- /dev/null +++ b/application/views/scripts/service/show.phtml @@ -0,0 +1,17 @@ + +
+ showOnlyCloseButton() ?> +
+
+

escape($this->translate('Access denied')) ?>

+

escape($this->translate('Access to service "%s" of host "%s" denied')), + $service, + $host + ) ?>

+
diff --git a/library/Businessprocess/HostNode.php b/library/Businessprocess/HostNode.php index d700a5b..130cebe 100644 --- a/library/Businessprocess/HostNode.php +++ b/library/Businessprocess/HostNode.php @@ -64,7 +64,7 @@ class HostNode extends MonitoredNode $params['backend'] = $this->bp->getBackendName(); } - return Url::fromPath('monitoring/host/show', $params); + return Url::fromPath('businessprocess/host/show', $params); } public function getLink() diff --git a/library/Businessprocess/ServiceNode.php b/library/Businessprocess/ServiceNode.php index b827835..517b059 100644 --- a/library/Businessprocess/ServiceNode.php +++ b/library/Businessprocess/ServiceNode.php @@ -51,6 +51,6 @@ class ServiceNode extends MonitoredNode $params['backend'] = $this->bp->getBackendName(); } - return Url::fromPath('monitoring/service/show', $params); + return Url::fromPath('businessprocess/service/show', $params); } }