fix: [internal] Sharing group capturing fixed, fixes #3573

- As reported by @eCrimeLabs
pull/3778/head
iglocska 2018-10-18 20:12:24 +02:00
parent 6f9551e202
commit e419c80e9e
3 changed files with 23 additions and 10 deletions

View File

@ -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');

View File

@ -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;
}
}

View File

@ -158,7 +158,8 @@ class SharingGroup extends AppModel
'SharingGroup.id',
'SharingGroup.name',
'SharingGroup.releasability',
'SharingGroup.description'
'SharingGroup.description',
'SharingGroup.org_id'
),
'contain' => array()
),