fix: Flatten events for the correlation graph

pull/2515/head
iglocska 2017-09-26 10:18:04 +02:00
parent d8a6712832
commit b658c20b75
2 changed files with 7 additions and 7 deletions

View File

@ -3877,7 +3877,7 @@ class EventsController extends AppController {
}
private function __buildGraphJson($id, $json = array()) {
$event = $this->Event->fetchEvent($this->Auth->user(), array('eventid' => $id));
$event = $this->Event->fetchEvent($this->Auth->user(), array('eventid' => $id, 'flatten' => 1));
if (empty($event)) return $json;
$json = $this->__cleanLinks($json);
$old_event = $this->__graphJsonContains('event', $event[0]['Event'], $json);

View File

@ -1331,7 +1331,7 @@ class Event extends AppModel {
// includeAttachments: true will attach the attachments to the attributes in the data field
public function fetchEvent($user, $options = array(), $useCache = false) {
if (isset($options['Event.id'])) $options['eventid'] = $options['Event.id'];
$possibleOptions = array('eventid', 'idList', 'tags', 'from', 'to', 'last', 'to_ids', 'includeAllTags', 'includeAttachments', 'event_uuid', 'distribution', 'sharing_group_id', 'disableSiteAdmin', 'metadata', 'includeGalaxy', 'enforceWarninglist', 'sgReferenceOnly');
$possibleOptions = array('eventid', 'idList', 'tags', 'from', 'to', 'last', 'to_ids', 'includeAllTags', 'includeAttachments', 'event_uuid', 'distribution', 'sharing_group_id', 'disableSiteAdmin', 'metadata', 'includeGalaxy', 'enforceWarninglist', 'sgReferenceOnly', 'flatten');
if (!isset($options['excludeGalaxy']) || !$options['excludeGalaxy']) {
$this->GalaxyCluster = ClassRegistry::init('GalaxyCluster');
}
@ -1350,10 +1350,10 @@ class Event extends AppModel {
$conditionsObjects = array();
$conditionsObjectReferences = array();
if (isset($options['flattenObjects']) && $options['flattenObjects']) {
$flattenObjects = true;
if (isset($options['flatten']) && $options['flatten']) {
$flatten = true;
} else {
$flattenObjects = false;
$flatten = false;
}
$sgids = $this->cacheSgids($user, $useCache);
// restricting to non-private or same org if the user is not a site-admin.
@ -1507,7 +1507,7 @@ class Event extends AppModel {
)
)
);
if ($flattenObjects) {
if ($flatten) {
unset($params['contain']['Object']);
}
if ($options['metadata']) {
@ -1680,7 +1680,7 @@ class Event extends AppModel {
}
}
if ($event['Attribute'][$key]['object_id'] != 0) {
if (!$flatten && $event['Attribute'][$key]['object_id'] != 0) {
if (!empty($event['Object'])) {
foreach ($event['Object'] as $objectKey => $objectValue) {
if ($event['Attribute'][$key]['object_id'] == $objectValue['id']) {