icingaweb2-module-businessp.../application/controllers/HostController.php

48 lines
1.5 KiB
PHP
Raw Normal View History

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