<commit_before><?php
$mayModify = (($isAclModify && $event['Event']['user_id'] == $me['id'] && $event['Event']['orgc_id'] == $me['org_id']) || ($isAclModifyOrg && $event['Event']['orgc_id'] == $me['org_id']));
$mayPublish = ($isAclPublish && $event['Event']['orgc_id'] == $me['org_id']);
?>
<div class="events form">
<?php echo $this->Form->create('Event');?>
    <fieldset>
        <legend><?php echo __('Edit Event');?></legend>
<?php
    echo $this->Form->input('id');
    echo $this->Form->input('date', array(
            'type' => 'text',
            'class' => 'datepicker'
    ));
    echo $this->Form->input('distribution', array(
        'options' => array($distributionLevels),
        'label' => 'Distribution ' . $this->element('formInfo', array('type' => 'distribution')),
        'default' => $event['Event']['distribution'],
    ));
?>
    <div id="SGContainer" style="display:none;">
        <?php
        if (!empty($sharingGroups)) {
            echo $this->Form->input('sharing_group_id', array(
                'options' => array($sharingGroups),
                'label' => __('Sharing Group'),
                'default' => $event['Event']['sharing_group_id'],
            ));
        }
        ?>
    </div>
<?php
    echo '<div class="input clear"></div>';
    if (empty(Configure::read('MISP.disable_threat_level'))) {
        echo $this->Form->input('threat_level_id', array(
            'label' => __('Threat Level ') . $this->element('formInfo', array('type' => 'threat_level'))
        ));
    }
    echo $this->Form->input('analysis', array(
            'label' => __('Analysis ') . $this->element('formInfo', array('type' => 'analysis')),
            'options' => array($analysisLevels)
    ));
    echo $this->Form->input('info', array(
            'div' => 'clear',
            'label' => __('Event Info'),
            'div' => 'clear',
            'type' => 'text',
            'class' => 'form-control span6',
            'placeholder' => __('Quick Event Description or Tracking Info')
    ));
    echo $this->Form->input('extends_uuid', array(
            'label' => __('Extends event'),
            'div' => 'clear',
            'class' => 'form-control span6',
            'placeholder' => __('Event UUID or ID. Leave blank if not applicable.')
    ));
?>
        <div id="extended_event_preview" style="width:446px;"></div>
    </fieldset>
<?php
echo $this->Form->button(__('Submit'), array('class' => 'btn btn-primary'));
echo $this->Form->end();
?>
</div>
<?php
    echo $this->element('/genericElements/SideMenu/side_menu', array('menuList' => 'event', 'menuItem' => 'editEvent', 'mayModify' => $mayModify, 'mayPublish' => $mayPublish));
?>

<script type="text/javascript">
    <?php
        $formInfoTypes = array('distribution' => 'Distribution', 'analysis' => 'Analysis', 'threat_level' => 'ThreatLevelId');
        echo 'var formInfoFields = ' . json_encode($formInfoTypes) . PHP_EOL;
        foreach ($formInfoTypes as $formInfoType => $humanisedName) {
            echo 'var ' . $formInfoType . 'FormInfoValues = {' . PHP_EOL;
            foreach ($info[$formInfoType] as $key => $formInfoData) {
                echo '"' . $key . '": "<span class=\"blue bold\">' . h($formInfoData['key']) . '</span>: ' . h($formInfoData['desc']) . '<br />",' . PHP_EOL;
            }
            echo '}' . PHP_EOL;
        }
    ?>
    $(document).ready(function() {
        if ($('#EventDistribution').val() == 4) $('#SGContainer').show();
        else $('#SGContainer').hide();

        $('#EventDistribution').change(function() {
            if ($('#EventDistribution').val() == 4) $('#SGContainer').show();
            else $('#SGContainer').hide();
        });

        $("#EventDistribution, #EventAnalysis, #EventThreatLevelId").change(function() {
            initPopoverContent('Event');
        });

        $("#EventExtendsUuid").keyup(function() {
            previewEventBasedOnUuids();
        });

        $(document).ready(function() {
            if ($('#EventDistribution').val() == 4) $('#SGContainer').show();
            else $('#SGContainer').hide();
            initPopoverContent('Event');
            previewEventBasedOnUuids();
        });
    });
</script>
<?php echo $this->Js->writeBuffer();<commit_msg>chg: [UI] Using generic form in the edit event view<commit_after><?php
    $mayModify = (($isAclModify && $event['Event']['user_id'] == $me['id'] && $event['Event']['orgc_id'] == $me['org_id']) || ($isAclModifyOrg && $event['Event']['orgc_id'] == $me['org_id']));
    $mayPublish = ($isAclPublish && $event['Event']['orgc_id'] == $me['org_id']);
    $modelForForm = 'Event';
    echo $this->element('genericElements/Form/genericForm', array(
        'form' => $this->Form,
        'data' => array(
            'title' => __('Edit Event'),
            'model' => $modelForForm,
            'fields' => array(
                array(
                    'field' => 'event_id',
                    'type' => 'text',
                    'hidden' => true
                ),
                array(
                    'field' => 'date',
                    'class' => 'datepicker',
                    'type' => 'text'
                ),
                array(
                    'field' => 'distribution',
                    'class' => 'input',
                    'options' => $distributionLevels,
                    'default' => $event['Event']['distribution']
                ),
                array(
                    'field' => 'sharing_group_id',
                    'class' => 'input',
                    'options' => $sharingGroups,
                    'default' => $event['Event']['sharing_group_id'],
                    'label' => __("Sharing Group")
                ),
                array(
                    'field' => 'threat_level_id',
                    'class' => 'input',
                    'options' => $threatLevels,
                    'default' => $event['Event']['threat_level_id'],
                    'label' => __("Threat Level")
                ),
                array(
                    'field' => 'analysis',
                    'class' => 'input',
                    'options' => $analysisLevels,
                    'default' => $event['Event']['analysis']
                ),
                array(
                    'field' => 'info',
                    'label' => __('Event Info'),
                    'class' => 'input-xxlarge',
                    'type' => 'text',
                    'placeholder' => __('Quick Event Description or Tracking Info')
                ),
                array(
                    'field' => 'extends_uuid',
                    'class' => 'input-xxlarge',
                    'placeholder' => __('Event UUID or ID. Leave blank if not applicable.'),
                    'label' => __("Extends Event")
                )
            ),
            'submit' => array(
                'action' => $this->request->params['action']
            )
        )
    ));
    echo $this->element('/genericElements/SideMenu/side_menu', array('menuList' => 'event', 'menuItem' => 'editEvent', 'mayModify' => $mayModify, 'mayPublish' => $mayPublish));
?>

<script type="text/javascript">
    $('#EventDistribution').change(function() {
        checkSharingGroup('Event');
    });

    $("#EventExtendsUuid").keyup(function() {
        previewEventBasedOnUuids();
    });

    $(document).ready(function() {
        checkSharingGroup('Event');
        previewEventBasedOnUuids();
    });
</script>
<?php echo $this->Js->writeBuffer();
{'fraction_non_alphanumeric': 0.20029104378886095, 'fraction_numerical': 0.0010583410504034925, 'mean_word_length': 2.032490974729242, 'pattern_counts': {'":': 1, '<': 34, '<?xml version=': 0, '>': 145, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2231359', 'n_tokens_mistral': 2209, 'n_tokens_neox': 2116, 'n_words': 388}