mirror of https://github.com/MISP/MISP
Shadow attribute change
- fixed incorrect link to edit shadow attributes and the distribution checkspull/217/head
parent
be950da012
commit
fd077e7bd4
|
@ -48,15 +48,11 @@ class ShadowAttributesController extends AppController {
|
|||
array(
|
||||
'Event.org =' => $this->Auth->user('org'),
|
||||
'AND' => array(
|
||||
array('OR' => array(
|
||||
array('ShadowAttribute.private !=' => 1),
|
||||
array('ShadowAttribute.cluster =' => 1),
|
||||
)),
|
||||
array('OR' => array(
|
||||
array('Event.private !=' => 1),
|
||||
array('Event.cluster =' => 1),
|
||||
)),
|
||||
)))));
|
||||
'ShadowAttribute.org =' => $this->Auth->user('org'),
|
||||
'Event.distribution >' => 0,
|
||||
),
|
||||
)
|
||||
)));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -120,9 +116,7 @@ class ShadowAttributesController extends AppController {
|
|||
$attribute = $shadow;
|
||||
|
||||
// set the distribution equal to that of the event
|
||||
$attribute['private'] = $event['private'];
|
||||
$attribute['cluster'] = $event['cluster'];
|
||||
$attribute['communitie'] = $event['communitie'];
|
||||
$attribute['distribution'] = $event['distribution'];
|
||||
$this->Attribute->create();
|
||||
$this->Attribute->save($attribute);
|
||||
if ($this->ShadowAttribute->typeIsAttachment($shadow['type'])) {
|
||||
|
@ -486,7 +480,7 @@ class ShadowAttributesController extends AppController {
|
|||
$uuid = $this->Attribute->data['Attribute']['uuid'];
|
||||
if (!$this->_IsSiteAdmin()) {
|
||||
// check for non-private and re-read CHANGE THIS TO NON-PRIVATE AND OTHER ORG
|
||||
if (($this->Attribute->data['Attribute']['private'] == 1 && $this->Attribute->data['Attribute']['Cluster'] == 0) || ($this->Attribute->data['Event']['org'] == $this->Auth->user('org'))) {
|
||||
if (($this->Attribute->data['Attribute']['distribution'] == 0) || ($this->Attribute->data['Event']['org'] == $this->Auth->user('org'))) {
|
||||
$this->Session->setFlash(__('Invalid Attribute.'));
|
||||
$this->redirect(array('controller' => 'events', 'action' => 'index'));
|
||||
}
|
||||
|
|
|
@ -221,7 +221,7 @@ if (!empty($event['Attribute'])):?>
|
|||
echo $this->Html->link('', array('controller' => 'attributes', 'action' => 'edit', $attribute['id']), array('class' => 'icon-edit', 'title' => 'Edit'));
|
||||
echo $this->Form->postLink('', array('controller' => 'attributes', 'action' => 'delete', $attribute['id']), array('class' => 'icon-trash', 'title' => 'Delete'), __('Are you sure you want to delete this attribute? Keep in mind that this will also delete this attribute on remote MISP instances.'));
|
||||
} else {
|
||||
echo $this->Html->link('', array('controller' => 'shadow_attributes', 'action' => 'edit', $attribute['id']), array('class' => 'icon-edit', 'title' => 'Propose Edit'));
|
||||
echo $this->Html->link('', array('controller' => 'shadow_attributes', 'action' => 'add', $attribute['id']), array('class' => 'icon-edit', 'title' => 'Propose Edit'));
|
||||
}
|
||||
?>
|
||||
</td>
|
||||
|
|
|
@ -1,96 +0,0 @@
|
|||
<div class="shadowAttributes form">
|
||||
<?php echo $this->Form->create('ShadowAttribute');?>
|
||||
<fieldset>
|
||||
<legend><?php echo __('Edit Attribute'); ?></legend>
|
||||
<?php
|
||||
echo $this->Form->input('id');
|
||||
echo $this->Form->input('category', array('between' => $this->Html->div('forminfo', '', array('id' => 'ShadowAttributeCategoryDiv'))));
|
||||
if (!$attachment) {
|
||||
echo $this->Form->input('type', array('between' => $this->Html->div('forminfo', '', array('id' => 'ShadowAttributeTypeDiv'))));
|
||||
}
|
||||
echo $this->Form->input('to_ids', array(
|
||||
'before' => $this->Html->div('forminfo', isset($attrDescriptions['signature']['formdesc']) ? $attrDescriptions['signature']['formdesc'] : $attrDescriptions['signature']['desc']),
|
||||
'label' => 'IDS Signature?'
|
||||
));
|
||||
if (!$attachment) {
|
||||
echo $this->Form->input('value', array(
|
||||
'type' => 'textarea',
|
||||
'error' => array('escape' => false),
|
||||
));
|
||||
}
|
||||
|
||||
$this->Js->get('#ShadowAttributeCategory')->event('change', 'formCategoryChanged("#ShadowAttributeCategory")');
|
||||
$this->Js->get('#ShadowAttributeType')->event('change', 'showFormInfo("#ShadowAttributeType")');
|
||||
?>
|
||||
</fieldset>
|
||||
<?php echo $this->Form->end(__('Submit'));?>
|
||||
</div>
|
||||
|
||||
<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) {
|
||||
showFormInfo(id); // display the tooltip
|
||||
// fill in the types
|
||||
var options = $('#ShadowAttributeType').prop('options');
|
||||
$('option', $('#ShadowAttributeType')).remove();
|
||||
$.each(category_type_mapping[$('#ShadowAttributeCategory').val()], function(val, text) {
|
||||
options[options.length] = new Option(text, val);
|
||||
});
|
||||
// enable the form element
|
||||
$('#ShadowAttributeType').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
|
||||
}
|
||||
?>
|
||||
|
||||
function showFormInfo(id) {
|
||||
idDiv = id+'Div';
|
||||
// LATER use nice animations
|
||||
//$(idDiv).hide('fast');
|
||||
// change the content
|
||||
var value = $(id).val(); // get the selected value
|
||||
$(idDiv).html(formInfoValues[value]); // search in a lookup table
|
||||
|
||||
// show it again
|
||||
$(idDiv).fadeIn('slow');
|
||||
}
|
||||
|
||||
//hide the formInfo things
|
||||
$('#ShadowAttributeTypeDiv').hide();
|
||||
$('#ShadowAttributeCategoryDiv').hide();
|
||||
// fix the select box based on what was selected
|
||||
var type_value = $('#ShadowAttributeType').val();
|
||||
formCategoryChanged("#ShadowAttributeCategory");
|
||||
$('#ShadowAttributeType').val(type_value);
|
||||
|
||||
</script>
|
||||
<?php echo $this->Js->writeBuffer(); // Write cached scripts
|
Loading…
Reference in New Issue