icingaweb2-module-businessp.../application/controllers/HostController.php
raviks789 df72ff65be Move enumHostListByFilter and enumServiceListByFilter to EnumList trait.
Move enumHostListByFilter and enumServiceListByFilter to EnumList trait from AddNodeForm and change fetchServices and fetchHosts
method to work with filters in IcingaDbBackEnd class.
Also, applyMonitoringRestriction is changed to applyIcingaDbRestrictions in IcingaDbBackend.
2022-02-03 16:55:02 +01:00

49 lines
1.4 KiB
PHP

<?php
namespace Icinga\Module\Businessprocess\Controllers;
use Icinga\Module\Businessprocess\Common\IcingadbDatabase;
use Icinga\Module\Businessprocess\IcingaDbBackend;
use Icinga\Module\Icingadb\Model\Host;
use Icinga\Module\Monitoring\Controller;
use Icinga\Web\Url;
class HostController extends Controller
{
use IcingadbDatabase;
public function showAction()
{
$icingadb = $this->params->shift('icingadb');
if ($icingadb) {
$hostName = $this->params->shift('host');
$query = Host::on($this->getDb());
IcingaDbBackend::applyIcingaDbRestrictions($query);
$query->getSelectBase()
->where(['host.name = ?' => $hostName]);
$host = $query->first();
$this->params->add('name', $hostName);
if ($host !== false) {
$this->redirectNow(Url::fromPath('icingadb/host')->setParams($this->params));
}
} else {
$hostName = $this->params->get('host');
$query = $this->backend->select()
->from('hoststatus', array('host_name'))
->where('host_name', $hostName);
if ($this->applyRestriction('monitoring/filter/objects', $query)->fetchRow() !== false) {
$this->redirectNow(Url::fromPath('monitoring/host/show')->setParams($this->params));
}
}
$this->view->host = $hostName;
}
}