2013-05-30 11:14:00 +02:00
|
|
|
<div class="attributes form">
|
|
|
|
<?php echo $this->Form->create('Attribute');?>
|
|
|
|
<fieldset>
|
|
|
|
<legend><?php echo __('Add Attribute'); ?></legend>
|
2013-06-03 10:48:38 +02:00
|
|
|
<?php
|
|
|
|
echo $this->Form->hidden('event_id');
|
|
|
|
echo $this->Form->input('category', array(
|
|
|
|
'empty' => '(choose one)'
|
|
|
|
));
|
|
|
|
echo $this->Form->input('type', array(
|
|
|
|
'empty' => '(first choose category)'
|
|
|
|
));
|
|
|
|
if ('true' == Configure::read('CyDefSIG.sync')) {
|
|
|
|
echo $this->Form->input('distribution', array(
|
2013-06-10 20:49:31 +02:00
|
|
|
'options' => array($distributionLevels),
|
2013-06-03 10:48:38 +02:00
|
|
|
'label' => 'Distribution',
|
|
|
|
'selected' => $maxDist,
|
|
|
|
));
|
|
|
|
}
|
|
|
|
echo $this->Form->input('value', array(
|
|
|
|
'type' => 'textarea',
|
|
|
|
'error' => array('escape' => false),
|
|
|
|
'div' => 'input clear',
|
|
|
|
'class' => 'input-xxlarge'
|
|
|
|
));
|
|
|
|
?>
|
|
|
|
<div class="input clear"></div>
|
|
|
|
<?php
|
|
|
|
echo $this->Form->input('to_ids', array(
|
|
|
|
'checked' => true,
|
2013-06-06 16:36:28 +02:00
|
|
|
'data-content' => isset($attrDescriptions['signature']['formdesc']) ? $attrDescriptions['signature']['formdesc'] : $attrDescriptions['signature']['desc'],
|
2013-06-03 10:48:38 +02:00
|
|
|
'label' => 'IDS Signature?',
|
2013-05-30 11:14:00 +02:00
|
|
|
));
|
2013-06-03 10:48:38 +02:00
|
|
|
echo $this->Form->input('batch_import', array(
|
|
|
|
'type' => 'checkbox',
|
2013-06-06 16:36:28 +02:00
|
|
|
'data-content' => 'Create multiple attributes one per line',
|
2013-05-30 11:14:00 +02:00
|
|
|
));
|
|
|
|
|
2013-06-03 10:48:38 +02:00
|
|
|
// link an onchange event to the form elements
|
|
|
|
$this->Js->get('#AttributeCategory')->event('change', 'formCategoryChanged("#AttributeCategory")');
|
|
|
|
?>
|
2013-05-30 11:14:00 +02:00
|
|
|
</fieldset>
|
2013-06-03 10:48:38 +02:00
|
|
|
<?php
|
|
|
|
echo $this->Form->button('Submit', array('class' => 'btn btn-primary'));
|
|
|
|
echo $this->Form->end();
|
|
|
|
?>
|
2013-05-30 11:14:00 +02:00
|
|
|
</div>
|
|
|
|
<div class="actions">
|
2013-06-03 10:48:38 +02:00
|
|
|
<ul class="nav nav-list">
|
2013-06-10 11:31:46 +02:00
|
|
|
<li><a href="/events/view/<?php echo $this->request->data['Attribute']['event_id']; ?>">View Event</a></li>
|
|
|
|
<li><a href="/events/edit/<?php echo $this->request->data['Attribute']['event_id']; ?>">Edit Event</a></li>
|
2013-06-03 10:48:38 +02:00
|
|
|
<li><?php echo $this->Form->postLink('Delete Event', array('controller' => 'events', 'action' => 'delete', $this->request->data['Attribute']['event_id']), null, __('Are you sure you want to delete # %s?', $this->request->data['Attribute']['event_id'])); ?></li>
|
|
|
|
<li class="divider"></li>
|
2013-06-10 11:31:46 +02:00
|
|
|
<li class="active"><a href="/attributes/add/<?php echo $this->request->data['Attribute']['event_id']; ?>">Add Attribute</a></li>
|
|
|
|
<li><a href="/attributes/add_attachment/<?php echo $this->request->data['Attribute']['event_id']; ?>">Add Attachment</a></li>
|
|
|
|
<li><a href="/events/addIOC/<?php echo $this->request->data['Attribute']['event_id']; ?>">Populate from IOC</a></li>
|
2013-06-03 10:48:38 +02:00
|
|
|
<li class="divider"></li>
|
2013-06-10 11:31:46 +02:00
|
|
|
<li><a href="/events/contact/<?php echo $this->request->data['Attribute']['event_id']; ?>">Contact Reporter</a></li>
|
|
|
|
<li><a href="/events/xml/download/<?php echo $this->request->data['Attribute']['event_id']; ?>">Download as XML</a></li>
|
|
|
|
<li><a href="/events/downloadOpenIOCEvent/<?php echo $this->request->data['Attribute']['event_id']; ?>">Download as IOC</a></li>
|
2013-06-03 10:48:38 +02:00
|
|
|
<li class="divider"></li>
|
2013-06-10 11:31:46 +02:00
|
|
|
<li><a href="/events/index">List Events</a></li>
|
2013-06-03 10:48:38 +02:00
|
|
|
<?php if ($isAclAdd): ?>
|
2013-06-10 11:31:46 +02:00
|
|
|
<li><a href="/events/add">Add Event</a></li>
|
2013-06-03 10:48:38 +02:00
|
|
|
<?php endif; ?>
|
|
|
|
</ul>
|
|
|
|
</div>
|
2013-06-03 15:59:22 +02:00
|
|
|
|
2013-05-30 11:14:00 +02:00
|
|
|
<script type="text/javascript">
|
|
|
|
//
|
|
|
|
//Generate Category / Type filtering array
|
|
|
|
//
|
|
|
|
var category_type_mapping = new Array();
|
|
|
|
<?php
|
|
|
|
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";
|
|
|
|
}
|
|
|
|
?>
|
|
|
|
|
|
|
|
function formCategoryChanged(id) {
|
|
|
|
// fill in the types
|
|
|
|
var options = $('#AttributeType').prop('options');
|
|
|
|
$('option', $('#AttributeType')).remove();
|
|
|
|
$.each(category_type_mapping[$('#AttributeCategory').val()], function(val, text) {
|
|
|
|
options[options.length] = new Option(text, val);
|
|
|
|
});
|
|
|
|
// enable the form element
|
|
|
|
$('#AttributeType').prop('disabled', false);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
// Generate tooltip information
|
|
|
|
//
|
|
|
|
var formInfoValues = new Array();
|
|
|
|
<?php
|
|
|
|
foreach ($typeDefinitions as $type => $def) {
|
|
|
|
$info = isset($def['formdesc']) ? $def['formdesc'] : $def['desc'];
|
|
|
|
echo "formInfoValues['" . addslashes($type) . "'] = \"" . addslashes($info) . "\";\n"; // as we output JS code we need to add slashes
|
|
|
|
}
|
|
|
|
foreach ($categoryDefinitions as $category => $def) {
|
|
|
|
$info = isset($def['formdesc']) ? $def['formdesc'] : $def['desc'];
|
|
|
|
echo "formInfoValues['" . addslashes($category) . "'] = \"" . addslashes($info) . "\";\n"; // as we output JS code we need to add slashes
|
|
|
|
}
|
|
|
|
foreach ($distributionDescriptions as $type => $def) {
|
|
|
|
$info = isset($def['formdesc']) ? $def['formdesc'] : $def['desc'];
|
|
|
|
echo "formInfoValues['" . addslashes($type) . "'] = \"" . addslashes($info) . "\";\n"; // as we output JS code we need to add slashes
|
|
|
|
}
|
|
|
|
?>
|
|
|
|
|
2013-06-06 16:36:28 +02:00
|
|
|
$(document).ready(function() {
|
2013-05-30 11:14:00 +02:00
|
|
|
|
2013-06-06 16:36:28 +02:00
|
|
|
$("#AttributeType, #AttributeCategory, #Attribute, #AttributeDistribution").on('mouseleave', function(e) {
|
|
|
|
$('#'+e.currentTarget.id).popover('destroy');
|
|
|
|
});
|
|
|
|
|
|
|
|
$("#AttributeType, #AttributeCategory, #Attribute, #AttributeDistribution").on('mouseover', function(e) {
|
|
|
|
var $e = $(e.target);
|
|
|
|
if ($e.is('option')) {
|
|
|
|
$('#'+e.currentTarget.id).popover('destroy');
|
|
|
|
$('#'+e.currentTarget.id).popover({
|
|
|
|
trigger: 'manual',
|
|
|
|
placement: 'right',
|
|
|
|
content: formInfoValues[$e.val()],
|
|
|
|
}).popover('show');
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
$("input, label").on('mouseleave', function(e) {
|
|
|
|
$('#'+e.currentTarget.id).popover('destroy');
|
|
|
|
});
|
|
|
|
|
|
|
|
$("input, label").on('mouseover', function(e) {
|
|
|
|
var $e = $(e.target);
|
|
|
|
$('#'+e.currentTarget.id).popover('destroy');
|
|
|
|
$('#'+e.currentTarget.id).popover({
|
|
|
|
trigger: 'manual',
|
|
|
|
placement: 'right',
|
|
|
|
}).popover('show');
|
|
|
|
});
|
|
|
|
|
2013-06-10 10:41:29 +02:00
|
|
|
// workaround for browsers like IE and Chrome that do now have an onmouseover on the 'options' of a select.
|
|
|
|
// disadvangate is that user needs to click on the item to see the tooltip.
|
|
|
|
// no solutions exist, except to generate the select completely using html.
|
|
|
|
$("#AttributeType, #AttributeCategory, #Attribute, #AttributeDistribution").on('change', function(e) {
|
|
|
|
var $e = $(e.target);
|
2013-06-10 10:46:03 +02:00
|
|
|
$('#'+e.currentTarget.id).popover('destroy');
|
|
|
|
$('#'+e.currentTarget.id).popover({
|
|
|
|
trigger: 'manual',
|
|
|
|
placement: 'right',
|
|
|
|
content: formInfoValues[$e.val()],
|
|
|
|
}).popover('show');
|
2013-06-10 10:41:29 +02:00
|
|
|
});
|
|
|
|
|
2013-06-06 16:36:28 +02:00
|
|
|
});
|
2013-05-30 11:14:00 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</script>
|
2012-09-18 15:30:32 +02:00
|
|
|
<?php echo $this->Js->writeBuffer(); // Write cached scripts
|