2015-02-03 17:06:05 +01:00
<div class="attributes <?php if (!isset($ajax) || !$ajax) echo 'form';?>">
2016-06-04 01:10:45 +02:00
<?php
2014-04-14 15:13:01 +02:00
echo $this->Form->create('Attribute', array('id'));
?>
2013-05-30 11:14:00 +02:00
<fieldset>
2014-07-10 17:02:19 +02:00
<legend><?php echo __('Add Attribute'); ?></legend>
2014-03-25 13:56:00 +01:00
<div id="formWarning" class="message ajaxMessage"></div>
2014-03-24 16:33:40 +01:00
<div class="add_attribute_fields">
<?php
echo $this->Form->hidden('event_id');
echo $this->Form->input('category', array(
2016-10-02 12:46:30 +02:00
'empty' => '(choose one)',
'label' => 'Category ' . $this->element('formInfo', array('type' => 'category')),
));
2014-03-24 16:33:40 +01:00
echo $this->Form->input('type', array(
2016-10-02 12:46:30 +02:00
'empty' => '(first choose category)',
'label' => 'Type ' . $this->element('formInfo', array('type' => 'type')),
));
2015-04-14 18:11:51 +02:00
$initialDistribution = 5;
2014-09-10 09:43:22 +02:00
if (Configure::read('MISP.default_attribute_distribution') != null) {
if (Configure::read('MISP.default_attribute_distribution') === 'event') {
2016-06-04 01:10:45 +02:00
$initialDistribution = 5;
2014-09-10 09:43:22 +02:00
} else {
$initialDistribution = Configure::read('MISP.default_attribute_distribution');
2013-08-08 12:16:03 +02:00
}
2013-08-06 11:53:12 +02:00
}
2016-06-04 01:08:16 +02:00
2015-04-14 18:11:51 +02:00
?>
<div class="input clear"></div>
<?php
2016-06-04 01:08:16 +02:00
2014-09-10 09:43:22 +02:00
echo $this->Form->input('distribution', array(
'options' => array($distributionLevels),
2016-10-02 12:46:30 +02:00
'label' => 'Distribution ' . $this->element('formInfo', array('type' => 'distribution')),
2014-09-10 09:43:22 +02:00
'selected' => $initialDistribution,
));
2015-04-14 18:11:51 +02:00
?>
<div id="SGContainer" style="display:none;">
<?php
2015-08-03 15:46:58 +02:00
if (!empty($sharingGroups)) {
2015-04-14 18:11:51 +02:00
echo $this->Form->input('sharing_group_id', array(
'options' => array($sharingGroups),
'label' => 'Sharing Group',
));
2015-08-03 15:46:58 +02:00
}
2015-04-14 18:11:51 +02:00
?>
</div>
2016-06-04 01:10:45 +02:00
<?php
2014-03-24 16:33:40 +01:00
echo $this->Form->input('value', array(
'type' => 'textarea',
'error' => array('escape' => false),
'div' => 'input clear',
'class' => 'input-xxlarge'
2013-06-03 10:48:38 +02:00
));
2015-04-14 18:11:51 +02:00
?>
<div class="input clear"></div>
<?php
2014-03-24 16:33:40 +01:00
echo $this->Form->input('comment', array(
'type' => 'text',
'label' => 'Contextual Comment',
'error' => array('escape' => false),
'div' => 'input clear',
'class' => 'input-xxlarge'
));
?>
<div class="input clear"></div>
<?php
echo $this->Form->input('to_ids', array(
'checked' => false,
'label' => 'for Intrusion Detection System',
));
echo $this->Form->input('batch_import', array(
2016-10-02 12:46:30 +02:00
'type' => 'checkbox'
2014-03-24 16:33:40 +01:00
));
2013-06-03 10:48:38 +02:00
?>
2014-03-24 16:33:40 +01:00
</div>
2013-05-30 11:14:00 +02:00
</fieldset>
2016-06-04 15:45:39 +02:00
<p style="color:red;font-weight:bold;display:none;<?php if (isset($ajax) && $ajax) echo "text-align:center;"?>" id="warning-message">Warning: You are about to share data that is of a sensitive nature (Attribution / targeting data). Make sure that you are authorised to share this.</p>
2014-03-24 16:33:40 +01:00
<?php if ($ajax): ?>
<div class="overlay_spacing">
<table>
<tr>
<td style="vertical-align:top">
2014-04-24 15:10:08 +02:00
<span id="submitButton" class="btn btn-primary" onClick="submitPopoverForm('<?php echo $event_id;?>', 'add')">Submit</span>
2014-03-24 16:33:40 +01:00
</td>
<td style="width:540px;">
<p style="color:red;font-weight:bold;display:none;text-align:center" id="warning-message">Warning: You are about to share data that is of a classified nature (Attribution / targeting data). Make sure that you are authorised to share this.</p>
</td>
<td style="vertical-align:top;">
<span class="btn btn-inverse" id="cancel_attribute_add">Cancel</span>
</td>
</tr>
</table>
</div>
2016-06-04 01:10:45 +02:00
<?php
else:
2014-03-24 16:33:40 +01:00
echo $this->Form->button('Submit', array('class' => 'btn btn-primary'));
endif;
echo $this->Form->end();
?>
2014-08-21 13:52:36 +02:00
<div id="confirmation_box" class="confirmation_box"></div>
2013-05-30 11:14:00 +02:00
</div>
2016-06-04 01:10:45 +02:00
<?php
2016-06-04 15:45:39 +02:00
if (!$ajax) {
2014-03-24 16:33:40 +01:00
$event['Event']['id'] = $this->request->data['Attribute']['event_id'];
$event['Event']['published'] = $published;
echo $this->element('side_menu', array('menuList' => 'event', 'menuItem' => 'addAttribute', 'event' => $event));
}
2013-10-24 10:33:34 +02:00
?>
2013-05-30 11:14:00 +02:00
<script type="text/javascript">
2016-10-02 12:46:30 +02:00
<?php
$formInfoTypes = array('distribution' => 'Distribution', 'category' => 'Category', 'type' => 'Type');
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;
}
?>
2013-05-30 11:14:00 +02:00
//
//Generate Category / Type filtering array
//
var category_type_mapping = new Array();
<?php
2016-10-02 12:46:30 +02:00
foreach ($categoryDefinitions as $category => $def) {
echo "category_type_mapping['" . addslashes($category) . "'] = {";
$first = true;
foreach ($def['types'] as $type) {
if ($first) $first = false;
else echo ', ';
echo "'" . addslashes($type) . "' : '" . addslashes($type) . "'";
}
echo "}; \n";
2013-05-30 11:14:00 +02:00
}
?>
2013-06-06 16:36:28 +02:00
$(document).ready(function() {
2016-10-02 12:46:30 +02:00
initPopoverContent('Attribute');
2015-04-14 18:11:51 +02:00
$('#AttributeDistribution').change(function() {
if ($('#AttributeDistribution').val() == 4) $('#SGContainer').show();
else $('#SGContainer').hide();
});
2016-10-02 12:46:30 +02:00
$("#AttributeCategory").on('change', function(e) {
formCategoryChanged('Attribute');
if ($(this).val() === 'Attribution' || $(this).val() === 'Targeting data') {
$("#warning-message").show();
} else {
$("#warning-message").hide();
2014-02-05 13:45:18 +01:00
}
2016-10-02 12:46:30 +02:00
if ($(this).val() === 'Internal reference') {
$("#AttributeDistribution").val('0');
$('#SGContainer').hide();
}
});
$("#AttributeCategory, #AttributeType, #AttributeDistribution").change(function() {
initPopoverContent('Attribute');
2013-06-10 10:41:29 +02:00
});
2014-03-24 16:33:40 +01:00
<?php if ($ajax): ?>
$('#cancel_attribute_add').click(function() {
2014-06-12 13:59:54 +02:00
cancelPopoverForm();
2016-06-04 01:10:45 +02:00
});
2014-03-24 16:33:40 +01:00
<?php endif; ?>
2013-06-06 16:36:28 +02:00
});
2013-05-30 11:14:00 +02:00
</script>
2016-06-06 10:09:55 +02:00
<?php echo $this->Js->writeBuffer(); // Write cached scripts