Sync: fix datalist entry sync

This commit is contained in:
Thomas Gelf 2016-02-09 19:21:36 +01:00
parent ef1079e600
commit ad39da9a13

View File

@ -277,9 +277,28 @@ class Sync
$objects = IcingaObject::loadAllByType($rule->object_type, $db); $objects = IcingaObject::loadAllByType($rule->object_type, $db);
if ($rule->object_type === 'datalistEntry') { if ($rule->object_type === 'datalistEntry') {
$listId = null;
foreach ($properties as $prop) {
if ($prop->destination_field === 'list_id') {
$listId = (int) $prop->source_expression;
}
}
if ($listId === null) {
throw new IcingaException(
'Cannot sync datalist entry without list_ist'
);
}
$no = array(); $no = array();
foreach ($objects as $o) { foreach ($objects as $k => $o) {
// if ($o->list_id !== $source-> if ($o->list_id !== $listId) {
$no[] = $k;
}
}
foreach ($no as $k) {
unset($objects[$k]);
} }
} }
$objectKey = $rule->object_type === 'datalistEntry' ? 'entry_name' : 'object_name'; $objectKey = $rule->object_type === 'datalistEntry' ? 'entry_name' : 'object_name';
@ -447,7 +466,9 @@ class Sync
} }
continue; continue;
} }
if ($object->shouldBeRemoved()) {
// TODO: introduce DirectorObject with shouldBeRemoved
if ($object instanceof IcingaObject && $object->shouldBeRemoved()) {
$object->delete($db); $object->delete($db);
continue; continue;
} }