chg: [attribute] Added tag handling when saving attributes and objects

pull/6143/head
mokaddem 2020-07-24 13:55:34 +02:00
parent 5b4cef3e6c
commit 6c1bbf0fde
No known key found for this signature in database
GPG Key ID: 164C473F627A06FA
2 changed files with 14 additions and 2 deletions

View File

@ -3732,7 +3732,12 @@ class Attribute extends AppModel
}
unset($attribute['Attachment']);
$this->create();
$saveResult = $saveResult && $this->save($attribute);
$currentSave = $this->save($attribute);
$saveResult = $saveResult && $currentSave;
if ($currentSave) {
$attribute['id'] = $this->id;
$this->Attribute->AttributeTag->handleAttributeTags($attribute, $attribute['event_id']);
}
}
return $saveResult;
}

View File

@ -850,6 +850,9 @@ class MispObject extends AppModel
$newAttribute['object_id'] = $object['Object']['id'];
$newAttribute['timestamp'] = $date->getTimestamp();
$result = $this->Event->Attribute->save(array('Attribute' => $newAttribute), array('fieldList' => $this->Attribute->editableFieds));
if ($result) {
$this->Event->Attribute->AttributeTag->handleAttributeTags($newAttribute, $newAttribute['event_id']);
}
}
unset($object['Attribute'][$origKey]);
continue 2;
@ -878,7 +881,11 @@ class MispObject extends AppModel
$newAttribute['distribution'] = 5;
}
}
$this->Event->Attribute->save($newAttribute);
$saveResult = $this->Event->Attribute->save($newAttribute);
if ($saveResult) {
$newAttribute['id'] = $this->Event->Attribute->id;
$this->Event->Attribute->AttributeTag->handleAttributeTags($newAttribute, $newAttribute['event_id']);
}
$attributeArrays['add'][] = $newAttribute;
unset($objectToSave['Attribute'][$newKey]);
}