fix: [acl] Add event to template when adding shadow attribute

pull/8702/head
Jakub Onderka 2022-10-25 12:03:14 +02:00
parent 014035b475
commit c8cd908c9c
2 changed files with 8 additions and 9 deletions

View File

@ -598,9 +598,9 @@ class ShadowAttributesController extends AppController
public function edit($id = null) public function edit($id = null)
{ {
$existingAttribute = $this->ShadowAttribute->Event->Attribute->fetchAttributes($this->Auth->user(), array( $existingAttribute = $this->ShadowAttribute->Event->Attribute->fetchAttributes($this->Auth->user(), array(
'contain' => array('Event' => array('fields' => array('Event.id', 'Event.orgc_id', 'Event.org_id', 'Event.distribution', 'Event.uuid'))), 'contain' => array('Event' => array('fields' => array('Event.id', 'Event.orgc_id', 'Event.org_id', 'Event.distribution', 'Event.uuid'))),
'conditions' => $this->__attributeIdToConditions($id), 'conditions' => $this->__attributeIdToConditions($id),
'flatten' => 1 'flatten' => 1
)); ));
if (empty($existingAttribute)) { if (empty($existingAttribute)) {
throw new NotFoundException(__('Invalid Attribute.')); throw new NotFoundException(__('Invalid Attribute.'));
@ -632,13 +632,13 @@ class ShadowAttributesController extends AppController
} }
if ($attachment) { if ($attachment) {
$fields = array( $fields = array(
'static' => array('old_id' => 'Attribute.id', 'uuid' => 'Attribute.uuid', 'event_id' => 'Attribute.event_id', 'event_uuid' => 'Event.uuid', 'event_org_id' => 'Event.orgc_id', 'category' => 'Attribute.category', 'type' => 'Attribute.type'), 'static' => array('old_id' => 'Attribute.id', 'uuid' => 'Attribute.uuid', 'event_id' => 'Attribute.event_id', 'event_uuid' => 'Event.uuid', 'event_org_id' => 'Event.orgc_id', 'category' => 'Attribute.category', 'type' => 'Attribute.type'),
'optional' => array('value', 'to_ids', 'comment', 'first_seen', 'last_seen') 'optional' => array('value', 'to_ids', 'comment', 'first_seen', 'last_seen')
); );
} else { } else {
$fields = array( $fields = array(
'static' => array('old_id' => 'Attribute.id', 'uuid' => 'Attribute.uuid', 'event_id' => 'Attribute.event_id', 'event_uuid' => 'Event.uuid', 'event_org_id' => 'Event.orgc_id'), 'static' => array('old_id' => 'Attribute.id', 'uuid' => 'Attribute.uuid', 'event_id' => 'Attribute.event_id', 'event_uuid' => 'Event.uuid', 'event_org_id' => 'Event.orgc_id'),
'optional' => array('category', 'type', 'value', 'to_ids', 'comment', 'first_seen', 'last_seen') 'optional' => array('category', 'type', 'value', 'to_ids', 'comment', 'first_seen', 'last_seen')
); );
if ($existingAttribute['Attribute']['object_id']) { if ($existingAttribute['Attribute']['object_id']) {
unset($fields['optional']['type']); unset($fields['optional']['type']);
@ -728,6 +728,7 @@ class ShadowAttributesController extends AppController
} }
} }
} }
$this->set('event', ['Event' => $existingAttribute['Event']]);
$this->set('categories', $categories); $this->set('categories', $categories);
$this->__common(); $this->__common();
$this->set('attrDescriptions', $this->ShadowAttribute->fieldDescriptions); $this->set('attrDescriptions', $this->ShadowAttribute->fieldDescriptions);

View File

@ -92,9 +92,7 @@
?> ?>
</div> </div>
<?php <?php
$event['Event']['id'] = $this->request->data['ShadowAttribute']['event_id'];
echo $this->element('/genericElements/SideMenu/side_menu', array('menuList' => 'event', 'menuItem' => 'proposeAttribute', 'event' => $event)); echo $this->element('/genericElements/SideMenu/side_menu', array('menuList' => 'event', 'menuItem' => 'proposeAttribute', 'event' => $event));
echo $this->element('form_seen_input'); echo $this->element('form_seen_input');
?> ?>