Fix "Host not found" error

refs #147
This commit is contained in:
Alexander A. Klimov 2017-12-04 18:05:07 +01:00 committed by Johannes Meyer
parent 56e37d2876
commit 3985f67fe7
6 changed files with 82 additions and 2 deletions

View file

@ -0,0 +1,24 @@
<?php
namespace Icinga\Module\Businessprocess\Controllers;
use Icinga\Module\Monitoring\Controller;
use Icinga\Web\Url;
class HostController extends Controller
{
public function showAction()
{
$host = $this->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;
}
}

View file

@ -0,0 +1,27 @@
<?php
namespace Icinga\Module\Businessprocess\Controllers;
use Icinga\Module\Monitoring\Controller;
use Icinga\Web\Url;
class ServiceController extends Controller
{
public function showAction()
{
$host = $this->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;
}
}

View file

@ -0,0 +1,12 @@
<?php
/** @var \Icinga\Web\View $this */
/** @var \Icinga\Web\Widget\Tabs $tabs */
/** @var string $host */
?>
<div class="controls">
<?= $tabs->showOnlyCloseButton() ?>
</div>
<div class="content">
<h1><?= $this->escape($this->translate('Access denied')) ?></h1>
<p><?php printf($this->escape($this->translate('Access to host "%s" denied')), $host) ?></p>
</div>

View file

@ -0,0 +1,17 @@
<?php
/** @var \Icinga\Web\View $this */
/** @var \Icinga\Web\Widget\Tabs $tabs */
/** @var string $host */
/** @var string $service */
?>
<div class="controls">
<?= $tabs->showOnlyCloseButton() ?>
</div>
<div class="content">
<h1><?= $this->escape($this->translate('Access denied')) ?></h1>
<p><?php printf(
$this->escape($this->translate('Access to service "%s" of host "%s" denied')),
$service,
$host
) ?></p>
</div>

View file

@ -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()

View file

@ -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);
}
}