Add missing fetch routine for customvars in AbstractObject

refs #4490
This commit is contained in:
Johannes Meyer 2014-01-30 16:34:23 +01:00
parent e56056e950
commit de546858c2
5 changed files with 30 additions and 17 deletions

View File

@ -33,10 +33,7 @@ $viewHelper = $this->getHelper('MonitoringState');
<table class="table table-condensed pull-left">
<tbody>
<?php $i = 1; ?>
<?php foreach($hosts as $host): ?>
<?php ($i == 1) ? $host->action_url = 'http://$HOSTNAME$/$HOSTADDRESS$/BANA/$HOSTNAME$/$_HOSTMACADDRESS$' : $host->action_url = "test"; ($i == 1) ? $i++ : $i = $i + 1;?>
<?php $hostStateName = strtolower($this->util()->getHostStateName($host->host_state)); ?>
<?php $hostLink = $this->href('monitoring/show/host', array('host' => $host->host_name)); ?>
<tr>
@ -122,7 +119,6 @@ $viewHelper = $this->getHelper('MonitoringState');
<!-- Host / Status / Output -->
<td>
<?= $this->makroResolver($host->action_url, $host, false); ?>
<?php if ($host->host_icon_image) : ?>
<div class="pull-left" style="margin-right: 2px;">
<i class="inline-image" style="background-image: url(<?= $host->host_icon_image; ?>);"></i>

View File

@ -4,8 +4,6 @@ namespace Icinga\Module\Monitoring\Backend\Ido\Query;
class CustomvarQuery extends IdoQuery
{
protected $object_id = 'object_id';
protected $columnMap = array(
'customvars' => array(
'varname' => 'cvs.varname',
@ -24,12 +22,11 @@ class CustomvarQuery extends IdoQuery
protected function joinBaseTables()
{
$this->baseQuery = $this->db->select()->from(
array('cvs' => $this->prefix . 'customvariablestatus'),
array('cvs' => $this->prefix . 'customvariables'),
array()
)->join(
array('cvo' => $this->prefix . 'objects'),
'cvs.object_id = cvo.' . $this->object_id
. ' AND cvo.is_active = 1',
'cvs.object_id = cvo.object_id AND cvo.is_active = 1',
array()
);

View File

@ -2,17 +2,14 @@
namespace Icinga\Module\Monitoring\Object;
use Icinga\Data\BaseQuery as Query;
use \Icinga\Module\Monitoring\Backend;
use Icinga\Module\Monitoring\DataView\Contact;
use Icinga\Module\Monitoring\DataView\Contactgroup;
use Icinga\Module\Monitoring\DataView\Downtime;
use Icinga\Module\Monitoring\DataView\EventHistory;
use Icinga\Module\Monitoring\DataView\Hostgroup;
use Icinga\Module\Monitoring\DataView\HostStatus;
use Icinga\Module\Monitoring\DataView\Comment;
use Icinga\Module\Monitoring\DataView\Servicegroup;
use Icinga\Module\Monitoring\DataView\ServiceStatus;
use Icinga\Module\Monitoring\DataView\Customvar;
use Icinga\Web\Request;
abstract class AbstractObject
@ -81,6 +78,29 @@ abstract class AbstractObject
return $this;
}
public function fetchCustomvars()
{
$query = Customvar::fromRequest(
$this->request,
array(
'varname',
'varvalue'
)
)->getQuery();
if ($this->type === self::TYPE_HOST) {
$query->where('host_name', $this->host_name)
->where('object_type', 'host');
} else {
$query->where('host_name', $this->host_name)
->where('object_type', 'service')
->where('service_description', $this->service_description);
}
$this->customvars = $query->fetchPairs();
return $this;
}
public function fetchContacts()
{
$this->contacts = Contact::fromRequest(

View File

@ -2,7 +2,6 @@
namespace Icinga\Module\Monitoring\Object;
use Icinga\Data\BaseQuery as Query;
use Icinga\Module\Monitoring\DataView\HostStatus;
class Host extends AbstractObject
@ -19,7 +18,8 @@ class Host extends AbstractObject
->fetchDowntimes()
->fetchHostgroups()
->fetchContacts()
->fetchContactGroups();
->fetchContactGroups()
->fetchCustomvars();
}
protected function getProperties()

View File

@ -2,7 +2,6 @@
namespace Icinga\Module\Monitoring\Object;
use Icinga\Data\BaseQuery as Query;
use Icinga\Module\Monitoring\DataView\ServiceStatus;
class Service extends AbstractObject
@ -19,7 +18,8 @@ class Service extends AbstractObject
->fetchHostgroups()
->fetchServicegroups()
->fetchContacts()
->fetchContactGroups();
->fetchContactGroups()
->fetchCustomvars();
}
protected function getProperties()