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

50 lines
1.4 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\IcingaDbObject;
use Icinga\Module\Icingadb\Model\Host;
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()
{
$icingadb = $this->params->shift('icingadb');
if ($icingadb) {
$hostName = $this->params->shift('host');
$query = Host::on($this->getDb());
IcingaDbObject::applyIcingaDbRestrictions($query);
$query->getSelectBase()
->where(['host.name = ?' => $hostName]);
2017-12-04 12:05:07 -05:00
$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);
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
}
}