fix: [object:edit] Updating an object to a new template acutally save

the template version
Fix #6083
pull/6161/head
mokaddem 2020-07-29 15:46:20 +02:00
parent dcd372bd93
commit 8420663ae1
No known key found for this signature in database
GPG Key ID: 164C473F627A06FA
3 changed files with 14 additions and 3 deletions

View File

@ -403,7 +403,7 @@ class ObjectsController extends AppController
$object = $revisedData['object'];
}
if (!empty($templateData['template'])) {
$template = $this->MispObject->prepareTemplate($templateData['template'], $object);
$template = $this->MispObject->prepareTemplate($templateData['template'], $object);
}
if ($this->request->is('post') || $this->request->is('put')) {
if (isset($this->request->data['request'])) {

View File

@ -792,6 +792,9 @@ class MispObject extends AppModel
if (isset($objectToSave['Object']['comment'])) {
$object['Object']['comment'] = $objectToSave['Object']['comment'];
}
if (isset($objectToSave['Object']['template_version'])) {
$object['Object']['template_version'] = $objectToSave['Object']['template_version'];
}
if (isset($objectToSave['Object']['distribution'])) {
$object['Object']['distribution'] = $objectToSave['Object']['distribution'];
if ($object['Object']['distribution'] == 4) {

View File

@ -14,7 +14,7 @@
if ($action == 'edit' && !$update_template_available && $newer_template_version !== false): ?>
<a class="btn btn-mini btn-primary useCursorPointer" title="<?php echo __('Update the template of this object to the newer version: ') . h($newer_template_version) ?>" href="<?php echo $baseurl . '/objects/edit/' . h($object['Object']['id']) . '/1'; ?>">
<span class="fa fa-arrow-circle-up"></span>
<?php echo __('Update template') ?>
<?php echo __('Update template to v%s', h($newer_template_version)) ?>
</a>
<?php endif; ?>
&nbsp;
@ -88,6 +88,14 @@
'div' => 'input hidden',
'required' => false,
));
if ($update_template_available && $newer_template_version !== false) {
echo $this->Form->input('template_version', array(
'type' => 'text',
'div' => 'input hidden',
'required' => false,
'value' => $newer_template_version
));
}
?>
<div id="bothSeenSliderContainer"></div>
</dl>
@ -193,7 +201,7 @@
<?php if ($update_template_available): ?>
<div class="fixedRightPanelHeader useCursorPointer" style="box-shadow: 0px 0px 6px #B2B2B2;margin-bottom: 2px;width: 100%;overflow: hidden; padding: 5px;">
<i class="fas fa-chevron-circle-down"></i>
<span style="margin-left: 5px; display: inline-block; font-size: large;"><?php echo __('Pre-update object\'s template'); ?></span>
<span style="margin-left: 5px; display: inline-block; font-size: large;"><?php echo __('Current Object state on older template version'); ?></span>
</div>
<div class="row" style="max-height: 800px; max-width: 800px; overflow: auto; padding: 15px;">
<div style="border: 1px solid #3465a4 ; border-radius: 5px; overflow: hidden;" class="span5">