mirror of https://github.com/MISP/MISP
chg: [addTag] functions changed to also work with uuids, rather than just local IDs
- as reported by @0x3c7pull/9454/head
parent
9fe416bb63
commit
8b4bb3b34a
|
@ -2671,12 +2671,15 @@ class AttributesController extends AppController
|
|||
$fails = 0;
|
||||
$this->Taxonomy = ClassRegistry::init('Taxonomy');
|
||||
foreach ($idList as $id) {
|
||||
$conditions = $this->__idToConditions($id);
|
||||
$conditions['Attribute.deleted'] = 0;
|
||||
$attribute = $this->Attribute->fetchAttributeSimple($this->Auth->user(), [
|
||||
'conditions' => array('Attribute.id' => $id, 'Attribute.deleted' => 0),
|
||||
'conditions' => $conditions,
|
||||
]);
|
||||
if (empty($attribute)) {
|
||||
throw new NotFoundException(__('Invalid attribute'));
|
||||
}
|
||||
$id = $attribute['Attribute']['id'];
|
||||
if (!$this->__canModifyTag($attribute, $local)) {
|
||||
$fails++;
|
||||
continue;
|
||||
|
|
|
@ -3792,11 +3792,21 @@ class EventsController extends AppController
|
|||
if ($id === false) {
|
||||
$id = $this->request->data['event'];
|
||||
}
|
||||
$this->Event->recursive = -1;
|
||||
$event = $this->Event->read(array(), $id);
|
||||
$conditions = ['Event.id' => $id];
|
||||
if (Validation::uuid($id)) {
|
||||
$conditions = ['Event.uuid' => $id];
|
||||
}
|
||||
$event = $this->Event->find(
|
||||
'first',
|
||||
[
|
||||
'recursive' => -1,
|
||||
'conditions' => $conditions
|
||||
]
|
||||
);
|
||||
if (empty($event)) {
|
||||
return new CakeResponse(array('body'=> json_encode(array('saved' => false, 'errors' => 'Invalid event.')), 'status'=>200, 'type' => 'json'));
|
||||
}
|
||||
$id = $event['Event']['id'];
|
||||
$local = !empty($this->params['named']['local']);
|
||||
if (!$this->request->is('post')) {
|
||||
$this->set('local', $local);
|
||||
|
|
Loading…
Reference in New Issue