diff --git a/app/Model/Event.php b/app/Model/Event.php index d4b225a24..5b655641f 100755 --- a/app/Model/Event.php +++ b/app/Model/Event.php @@ -902,6 +902,8 @@ class Event extends AppModel } $updated = null; $newLocation = $newTextBody = ''; + debug($event); + throw new Exception(); $result = $this->__executeRestfulEventToServer($event, $server, null, $newLocation, $newTextBody, $HttpSocket); if ($result !== true) { return $result; @@ -3202,6 +3204,7 @@ class Event extends AppModel } $data['Event']['Attribute'] = array_values($data['Event']['Attribute']); } + $referencesToCapture = array(); if (!empty($data['Event']['Object'])) { foreach ($data['Event']['Object'] as $object) { $result = $this->Object->captureObject($object, $this->id, $user, $this->Log); @@ -3209,11 +3212,20 @@ class Event extends AppModel foreach ($data['Event']['Object'] as $object) { if (isset($object['ObjectReference'])) { foreach ($object['ObjectReference'] as $objectRef) { - $result = $this->Object->ObjectReference->captureReference($objectRef, $this->id, $user, $this->Log); + $objectRef['source_uuid'] = $object['uuid']; + $referencesToCapture[] = $objectRef; } } } } + foreach ($referencesToCapture as $referenceToCapture) { + $result = $this->Object->ObjectReference->captureReference( + $referenceToCapture, + $this->id, + $user, + $this->Log + ); + } // zeroq: check if sightings are attached and add to event if (isset($data['Sighting']) && !empty($data['Sighting'])) { $this->Sighting = ClassRegistry::init('Sighting'); diff --git a/app/Model/ObjectReference.php b/app/Model/ObjectReference.php index 43a701b6f..13a616a52 100644 --- a/app/Model/ObjectReference.php +++ b/app/Model/ObjectReference.php @@ -191,8 +191,8 @@ class ObjectReference extends AppModel } } } - if (isset($reference['object_uuid'])) { - $conditions = array('Object.uuid' => $reference['object_uuid']); + if (isset($reference['source_uuid'])) { + $conditions = array('Object.uuid' => $reference['source_uuid']); } elseif (isset($reference['object_id'])) { $conditions = array('Object.id' => $reference['object_id']); } else { @@ -229,26 +229,26 @@ class ObjectReference extends AppModel if (empty($referencedObject)) { return true; } - $referenced_type = 0; + $referenced_type = 'Attribute'; } else { - $referenced_type = 1; + $referenced_type = 'Object'; } $objectTypes = array('Attribute', 'Object'); if (!isset($sourceObject['Object']) || $sourceObject['Object']['event_id'] != $eventId) { return true; } - if ($referencedObject[$objectTypes[$referenced_type]]['event_id'] != $eventId) { + if ($referencedObject[$referenced_type]['event_id'] != $eventId) { return true; } $this->create(); unset($reference['id']); $reference['referenced_type'] = $referenced_type; $reference['object_id'] = $sourceObject['Object']['id']; - $reference['referenced_id'] = $referencedObject[$objectTypes[$referenced_type]]['id']; - $reference['referenced_uuid'] = $referencedObject[$objectTypes[$referenced_type]]['uuid']; + $reference['referenced_id'] = $referencedObject[$referenced_type]['id']; + $reference['referenced_uuid'] = $referencedObject[$referenced_type]['uuid']; $reference['object_uuid'] = $sourceObject['Object']['uuid']; $reference['event_id'] = $eventId; - $this->save(array('ObjectReference' => $reference)); + $result = $this->save(array('ObjectReference' => $reference)); return true; } } diff --git a/app/Model/SharingGroup.php b/app/Model/SharingGroup.php index 1aafb1e45..c6dd26a55 100644 --- a/app/Model/SharingGroup.php +++ b/app/Model/SharingGroup.php @@ -158,7 +158,8 @@ class SharingGroup extends AppModel 'SharingGroup.id', 'SharingGroup.name', 'SharingGroup.releasability', - 'SharingGroup.description' + 'SharingGroup.description', + 'SharingGroup.org_id' ), 'contain' => array() ),