From b188b9c18d2665f9ead2013e24fff3c8e411c267 Mon Sep 17 00:00:00 2001 From: Thomas Gelf Date: Wed, 16 Mar 2016 21:46:00 +0100 Subject: [PATCH] IcingaObject: a couple of small fixes --- library/Director/Objects/IcingaObject.php | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/library/Director/Objects/IcingaObject.php b/library/Director/Objects/IcingaObject.php index 4e6061a6..3c8476a7 100644 --- a/library/Director/Objects/IcingaObject.php +++ b/library/Director/Objects/IcingaObject.php @@ -676,7 +676,13 @@ abstract class IcingaObject extends DbObject implements IcingaConfigRenderer { $db = $this->getDb(); $table = $this->getTableName(); + $type = strtolower($this->getType()); + + if ($type === 'checkcommand') { + $type = 'command'; + } + $query = $db->select()->from( array('oi' => $table . '_inheritance'), array('cnt' => 'COUNT(*)') @@ -1350,6 +1356,8 @@ abstract class IcingaObject extends DbObject implements IcingaConfigRenderer $type = 'hostGroup'; } elseif ($type === 'usergroup') { $type = 'userGroup'; + } elseif ($type === 'timeperiod') { + $type = 'timePeriod'; } elseif ($type === 'servicegroup') { $type = 'serviceGroup'; } elseif ($type === 'apiuser') { @@ -1472,7 +1480,7 @@ abstract class IcingaObject extends DbObject implements IcingaConfigRenderer // TODO: Do not ship null properties based on flag? if (!$skipDefaults || $this->differsFromDefaultValue($k, $v)) { - if ($k === 'disabled' || $this->propertyIsBoolean($k)) { + if ($k === 'disabled' || $this->propertyIsBoolean($k)) { if ($v === 'y') { $props[$k] = true; } elseif ($v === 'n') { @@ -1579,11 +1587,11 @@ abstract class IcingaObject extends DbObject implements IcingaConfigRenderer } else { $params = array('name' => $this->object_name); - if ($this->hasProperty('host_id')) { + if ($this->hasProperty('host_id') && $this->host_id) { $params['host'] = $this->host; } - if ($this->hasProperty('service_id')) { + if ($this->hasProperty('service_id') && $this->service_id) { $params['service'] = $this->service; } } @@ -1654,6 +1662,12 @@ abstract class IcingaObject extends DbObject implements IcingaConfigRenderer $props[$property] = $set->getPlainUnmodifiedObject(); } + foreach ($this->loadAllMultiRelations() as $key => $rel) { + if (count($rel)) { + $props[$key] = $rel->listOriginalNames(); + } + } + return (object) $props; }