mirror of https://github.com/MISP/MISP
fix: [UI] Cleanup for reference bulk add
parent
cf25698a5f
commit
d09455f640
|
@ -217,11 +217,6 @@ class ObjectReferencesController extends AppController
|
|||
}
|
||||
|
||||
$selectedAttributeIDs = $this->_jsonDecode($selectedAttributes);
|
||||
$event = $this->ObjectReference->Object->Event->find('first', array(
|
||||
'recursive' => -1,
|
||||
'fields' => array('Event.id', 'Event.uuid', 'Event.orgc_id', 'Event.user_id', 'Event.publish_timestamp'),
|
||||
'conditions' => array('Event.id' => $eventId)
|
||||
));
|
||||
$event = $this->ObjectReference->Object->Event->fetchEvent($this->Auth->user(), [
|
||||
'eventid' => $eventId,
|
||||
]);
|
||||
|
@ -233,33 +228,28 @@ class ObjectReferencesController extends AppController
|
|||
throw new ForbiddenException(__('You do not have permission to do that.'));
|
||||
}
|
||||
|
||||
$eventObjects = [];
|
||||
$validSourceUuid = [];
|
||||
foreach ($event['Object'] as $object) {
|
||||
$validSourceUuid[$object['uuid']] = sprintf('[%s] %s ', $object['id'], $object['name']);
|
||||
$eventObjects[$object['uuid']] = $object;
|
||||
}
|
||||
$selectedAttributes = [];
|
||||
foreach ($event['Attribute'] as $attribute) {
|
||||
if (in_array($attribute['id'], $selectedAttributeIDs)) {
|
||||
$selectedAttributes[$attribute['id']] = $attribute;
|
||||
}
|
||||
}
|
||||
|
||||
if (empty($selectedAttributes)) {
|
||||
throw new BadRequestException(__('No attribute selected.'));
|
||||
}
|
||||
|
||||
if ($this->request->is('post')) {
|
||||
$conditions = [
|
||||
'Object.deleted' => 0,
|
||||
'Object.event_id' => $eventId,
|
||||
'Object.uuid' => $this->data['ObjectReference']['source_uuid'],
|
||||
];
|
||||
$object = $this->ObjectReference->Object->find('first', array(
|
||||
'conditions' => $conditions,
|
||||
'recursive' => -1,
|
||||
'contain' => array(
|
||||
'Event' => array(
|
||||
'fields' => array('Event.id', 'Event.orgc_id', 'Event.user_id', 'Event.extends_uuid')
|
||||
)
|
||||
)
|
||||
));
|
||||
if (empty($object) || !$this->__canModifyEvent($object)) {
|
||||
if (empty($object)) {
|
||||
throw new NotFoundException('Invalid object.');
|
||||
}
|
||||
|
||||
|
@ -310,6 +300,12 @@ class ObjectReferencesController extends AppController
|
|||
}
|
||||
}
|
||||
|
||||
$eventObjects = [];
|
||||
$validSourceUuid = [];
|
||||
foreach ($event['Object'] as $object) {
|
||||
$validSourceUuid[$object['uuid']] = sprintf('[%s] %s ', $object['id'], $object['name']);
|
||||
$eventObjects[$object['uuid']] = $object;
|
||||
}
|
||||
|
||||
$this->loadModel('ObjectRelationship');
|
||||
$relationships = $this->ObjectRelationship->find('column', array(
|
||||
|
|
|
@ -13,6 +13,7 @@ $fields = [
|
|||
[
|
||||
'field' => 'relationship_type_select',
|
||||
'type' => 'dropdown',
|
||||
'title' => __('Relationship type'),
|
||||
'class' => 'span6',
|
||||
'options' => $relationships,
|
||||
'picker' => true,
|
||||
|
@ -41,9 +42,9 @@ $fields = [
|
|||
[
|
||||
'field' => 'comment',
|
||||
'type' => 'textarea',
|
||||
'class' => 'input span6'
|
||||
'class' => 'input span6',
|
||||
'rows' => 3,
|
||||
],
|
||||
|
||||
];
|
||||
echo $this->element('genericElements/Form/genericForm', [
|
||||
'data' => [
|
||||
|
@ -57,16 +58,10 @@ echo $this->element('genericElements/Form/genericForm', [
|
|||
]
|
||||
]
|
||||
]);
|
||||
|
||||
if (!$ajax) {
|
||||
echo $this->element('/genericElements/SideMenu/side_menu', $menuData);
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
<script>
|
||||
var validSourceUuid = <?= JsonTool::encode($eventObjects) ?>;
|
||||
$(document).ready(function() {
|
||||
$(function() {
|
||||
$("#ObjectReferenceRelationshipTypeSelect").change(function() {
|
||||
objectReferenceCheckForCustomRelationship()
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue