mirror of https://github.com/MISP/MISP
Merge branch '2.4' of github.com:MISP/MISP into 2.4
commit
e1716ac738
|
@ -1590,7 +1590,8 @@ class AttributesController extends AppController
|
|||
$tagItemsRemove = array();
|
||||
foreach ($tags as $k => $tag) {
|
||||
$tagName = $tag['name'];
|
||||
$tagItemsRemove[h($tagName)] = array(
|
||||
$tagItemsRemove[] = array(
|
||||
'name' => h($tagName),
|
||||
'value' => h($tag['id']),
|
||||
'template' => $tagTemplate,
|
||||
'templateData' => array(
|
||||
|
@ -1622,7 +1623,8 @@ class AttributesController extends AppController
|
|||
$optionName = h($cluster['value']);
|
||||
$optionName .= $cluster['synonyms_string'] !== '' ? ' (' . h($cluster['synonyms_string']) . ')' : '';
|
||||
|
||||
$clusterItemsRemove[$optionName] = array(
|
||||
$clusterItemsRemove[] = array(
|
||||
'name' => $optionName,
|
||||
'value' => h($cluster['id']),
|
||||
'additionalData' => array(
|
||||
'event_id' => h($id),
|
||||
|
@ -1651,7 +1653,8 @@ class AttributesController extends AppController
|
|||
$tagItemsAdd = array();
|
||||
foreach ($tags as $k => $tag) {
|
||||
$tagName = $tag['name'];
|
||||
$tagItemsAdd[h($tagName)] = array(
|
||||
$tagItemsAdd[] = array(
|
||||
'name' => h($tagName),
|
||||
'value' => h($tag['id']),
|
||||
'template' => $tagTemplate,
|
||||
'templateData' => array(
|
||||
|
@ -1671,7 +1674,10 @@ class AttributesController extends AppController
|
|||
));
|
||||
$clusterItemsAdd = array();
|
||||
foreach ($clusters as $k => $cluster) {
|
||||
$clusterItemsAdd[$cluster['GalaxyCluster']['value']] = $cluster['GalaxyCluster']['id'];
|
||||
$clusterItemsAdd[] = array(
|
||||
'name' => $cluster['GalaxyCluster']['value'],
|
||||
'value' => $cluster['GalaxyCluster']['id']
|
||||
);
|
||||
}
|
||||
unset($clusters);
|
||||
|
||||
|
|
|
@ -107,7 +107,10 @@ class GalaxiesController extends AppController
|
|||
}
|
||||
|
||||
$items = array();
|
||||
$items[__('All clusters')] = "/galaxies/selectCluster/" . h($target_id) . '/' . h($target_type) . '/0';
|
||||
$items[] = array(
|
||||
'name' => __('All clusters'),
|
||||
'value' => "/galaxies/selectCluster/" . h($target_id) . '/' . h($target_type) . '/0'
|
||||
);
|
||||
foreach ($galaxies as $galaxy) {
|
||||
if ($galaxy['Galaxy']['id'] != -1) {
|
||||
// construct option template
|
||||
|
@ -119,7 +122,8 @@ class GalaxiesController extends AppController
|
|||
$galaxyTemplate .= '<it class="fa fa-info-circle" style="float:right;" title="{{=it.description}}"></it>';
|
||||
}
|
||||
|
||||
$items[$galaxy['Galaxy']['name']] = array(
|
||||
$items[] = array(
|
||||
'name' => h($galaxy['Galaxy']['name']),
|
||||
'value' => "/galaxies/selectCluster/" . h($target_id) . '/' . h($target_type) . '/' . h($galaxy['Galaxy']['id']),
|
||||
'template' => $galaxyTemplate,
|
||||
'templateData' => array(
|
||||
|
@ -129,7 +133,8 @@ class GalaxiesController extends AppController
|
|||
)
|
||||
);
|
||||
} else { // attackMatrix
|
||||
$items[$galaxy['Galaxy']['name']] = array(
|
||||
$items[] = array(
|
||||
'name' => $galaxy['Galaxy']['name'],
|
||||
'functionName' => "getMitreMatrixPopup('" . h($target_type) . "', '" . h($target_id) . "')",
|
||||
'isPill' => true,
|
||||
'img' => "/img/mitre-attack-icon.ico",
|
||||
|
@ -150,9 +155,15 @@ class GalaxiesController extends AppController
|
|||
));
|
||||
|
||||
$items = array();
|
||||
$items[__('All namespaces')] = "/galaxies/selectGalaxy/" . h($target_id) . '/' . h($target_type) . '/0';
|
||||
$items[] = array(
|
||||
'name' => __('All namespaces'),
|
||||
'value' => "/galaxies/selectGalaxy/" . h($target_id) . '/' . h($target_type) . '/0'
|
||||
);
|
||||
foreach ($namespaces as $namespace) {
|
||||
$items[h($namespace)] = "/galaxies/selectGalaxy/" . h($target_id) . '/' . h($target_type) . '/' . h($namespace);
|
||||
$items[] = array(
|
||||
'name' => h($namespace),
|
||||
'value' => "/galaxies/selectGalaxy/" . h($target_id) . '/' . h($target_type) . '/' . h($namespace)
|
||||
);
|
||||
}
|
||||
|
||||
$this->set('items', $items);
|
||||
|
@ -212,7 +223,8 @@ class GalaxiesController extends AppController
|
|||
$name = h($cluster['value']);
|
||||
$optionName = h($cluster['value']);
|
||||
$optionName .= $cluster['synonyms_string'] !== '' ? ' (' . h($cluster['synonyms_string']) . ')' : '';
|
||||
$items[$optionName] = array(
|
||||
$items[] = array(
|
||||
'name' => $optionName,
|
||||
'value' => h($cluster_id),
|
||||
'title' => $title,
|
||||
'additionalData' => array(
|
||||
|
|
|
@ -17,12 +17,44 @@ class ObjectTemplatesController extends AppController
|
|||
'recursive' => -1
|
||||
);
|
||||
|
||||
public function objectMetaChoice($event_id) {
|
||||
$metas = $this->ObjectTemplate->find('list', array(
|
||||
'recursive' => -1,
|
||||
'conditions' => array('ObjectTemplate.active' => 1),
|
||||
'fields' => array('meta-category'),
|
||||
'group' => array('ObjectTemplate.meta-category'),
|
||||
'order' => array('ObjectTemplate.meta-category asc')
|
||||
));
|
||||
|
||||
$items = array();
|
||||
$items[] = array(
|
||||
'name' => __('All Objects'),
|
||||
'value' => "/ObjectTemplates/objectChoice/" . h($event_id) . "/" . "0"
|
||||
);
|
||||
foreach($metas as $meta) {
|
||||
$items[] = array(
|
||||
'name' => $meta,
|
||||
'value' => "/ObjectTemplates/objectChoice/" . h($event_id) . "/" . h($meta)
|
||||
);
|
||||
}
|
||||
|
||||
$this->set('items', $items);
|
||||
$this->set('options', array(
|
||||
'multiple' => 0,
|
||||
));
|
||||
$this->render('/Elements/generic_picker');
|
||||
}
|
||||
|
||||
public function objectChoice($event_id, $category=false)
|
||||
{
|
||||
$this->ObjectTemplate->populateIfEmpty($this->Auth->user());
|
||||
$conditions = array('ObjectTemplate.active' => 1);
|
||||
if ($category !== false && $category !== "0") {
|
||||
$conditions['meta-category'] = $category;
|
||||
}
|
||||
$templates_raw = $this->ObjectTemplate->find('all', array(
|
||||
'recursive' => -1,
|
||||
'conditions' => array('ObjectTemplate.active' => 1),
|
||||
'conditions' => $conditions,
|
||||
'fields' => array('id', 'meta-category', 'name', 'description', 'org_id'),
|
||||
'contain' => array('Organisation.name'),
|
||||
'order' => array('ObjectTemplate.name asc')
|
||||
|
@ -39,7 +71,8 @@ class ObjectTemplatesController extends AppController
|
|||
}
|
||||
$chosenTemplate .= '<div class="apply_css_arrow" style="padding-left: 5px; margin-top: 5px; font-size: smaller;"><i>{{=it.metacateg}}</i></div>';
|
||||
|
||||
$items[$template['name']] = array(
|
||||
$items[] = array(
|
||||
'name' => $template['name'],
|
||||
'value' => $template['id'],
|
||||
'additionalData' => array('event_id' => h($event_id)),
|
||||
'template' => $chosenTemplate,
|
||||
|
|
|
@ -576,19 +576,31 @@ class TagsController extends AppController
|
|||
$items = array();
|
||||
$favourites = $this->Tag->FavouriteTag->find('count', array('conditions' => array('FavouriteTag.user_id' => $this->Auth->user('id'))));
|
||||
if ($favourites) {
|
||||
$items[__('Favourite Tags')] = "/tags/selectTag/" . h($id) . "/favourites/" . h($scope);
|
||||
$items[] = array(
|
||||
'name' => __('Favourite Tags'),
|
||||
'value' => "/tags/selectTag/" . h($id) . "/favourites/" . h($scope)
|
||||
);
|
||||
}
|
||||
if ($scope !== 'tag_collection') {
|
||||
$items[__('Tag Collections')] = "/tags/selectTag/" . h($id) . "/collections/" . h($scope);
|
||||
$items[] = array(
|
||||
'name' => __('Tag Collections'),
|
||||
'value' => "/tags/selectTag/" . h($id) . "/collections/" . h($scope)
|
||||
);
|
||||
}
|
||||
$items[__('All Tags')] = "/tags/selectTag/" . h($id) . "/all/" . h($scope);
|
||||
$items[] = array(
|
||||
'name' => __('All Tags'),
|
||||
'value' => "/tags/selectTag/" . h($id) . "/all/" . h($scope)
|
||||
);
|
||||
|
||||
$this->loadModel('Taxonomy');
|
||||
$options = $this->Taxonomy->find('list', array('conditions' => array('enabled' => true), 'fields' => array('namespace'), 'order' => array('Taxonomy.namespace ASC')));
|
||||
foreach ($options as $k => $option) {
|
||||
$tags = $this->Taxonomy->getTaxonomyTags($k, false, true);
|
||||
if (!empty($tags)) {
|
||||
$items[__('Taxonomy Library') . ":" . h($option)] = "/tags/selectTag/" . h($id) . "/" . h($k) . "/" . h($scope);
|
||||
$items[] = array(
|
||||
'name' => __('Taxonomy Library') . ":" . h($option),
|
||||
'value' => "/tags/selectTag/" . h($id) . "/" . h($k) . "/" . h($scope)
|
||||
);
|
||||
}
|
||||
}
|
||||
$this->set('items', $items);
|
||||
|
@ -668,10 +680,14 @@ class TagsController extends AppController
|
|||
$conditions = array('Tag.user_id' => array(0, $this->Auth->user('id')));
|
||||
$conditions['Tag.hide_tag'] = 0;
|
||||
$allTags = $this->Tag->find('all', array('conditions' => $conditions, 'recursive' => -1));
|
||||
$allTags = $this->Tag->EventTag->Event->massageTags(array('EventTag' => $allTags), 'Event', false);
|
||||
$allTags = $allTags['EventTag'];
|
||||
$tags = array();
|
||||
foreach ($allTags as $i => $tag) {
|
||||
if (!empty($tag['Tag'])) {
|
||||
$tags[$tag['Tag']['id']] = $tag['Tag'];
|
||||
}
|
||||
}
|
||||
unset($allTags);
|
||||
$expanded = $tags;
|
||||
} else {
|
||||
|
@ -737,7 +753,8 @@ class TagsController extends AppController
|
|||
$tagTemplate .= '<div class="apply_css_arrow" style="padding-left: 5px; margin-top: 5px; font-size: smaller;"><i>{{=it.includes}}</i></div>';
|
||||
}
|
||||
|
||||
$items[h($tagName)] = array(
|
||||
$itemParam = array(
|
||||
'name' => h($tagName),
|
||||
'value' => h($choice_id),
|
||||
'additionalData' => array(
|
||||
'id' => h($id)
|
||||
|
@ -752,8 +769,9 @@ class TagsController extends AppController
|
|||
);
|
||||
if ($taxonomy_id === 'collections') {
|
||||
$TagCollectionTag = __('Includes: ') . h($inludedTagListString[$tag['id']]);
|
||||
$items[h($tagName)]['templateData']['includes'] = $TagCollectionTag;
|
||||
$itemParam['templateData']['includes'] = $TagCollectionTag;
|
||||
}
|
||||
$items[] = $itemParam;
|
||||
}
|
||||
$this->set('items', $items);
|
||||
$this->set('options', array( // set chosen (select picker) options
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
* Generic select picker
|
||||
*/
|
||||
/** Config **/
|
||||
$select_threshold = 6; // threshold above which pills will be replace by a select (unused if multiple is > 1)
|
||||
$select_threshold = 7; // threshold above which pills will be replace by a select (unused if multiple is > 1)
|
||||
$defaults_options = array(
|
||||
'select_options' => array(
|
||||
// 'multiple' => '', // set to add possibility to pick multiple options in the select
|
||||
|
@ -65,9 +65,14 @@ function setupChosen(id, redrawChosen) {
|
|||
} else { // for obscure reasons, `selected` variable is not set in some cases
|
||||
endpoint = $(event.target).val();
|
||||
}
|
||||
if (endpoint === '') {
|
||||
$wrapper = $select.closest('div').find('div.generic-picker-wrapper');
|
||||
$wrapper.hide(0);
|
||||
} else {
|
||||
$select.data('endpoint', endpoint);
|
||||
fetchRequestedData($select);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -180,12 +185,12 @@ function submitFunction(clicked, callback) {
|
|||
<select id="<?php echo $select_id; ?>" style="height: 100px; margin-bottom: 0px;" <?php echo h($this->GenericPicker->add_select_params($defaults)); ?>>
|
||||
<option></option>
|
||||
<?php
|
||||
foreach ($items as $name => $param) {
|
||||
foreach ($items as $k => $param) {
|
||||
if (isset($param['isPill']) && $param['isPill']) {
|
||||
$flag_addPills = true;
|
||||
continue;
|
||||
} else {
|
||||
echo $this->GenericPicker->add_option($name, $param, $defaults);
|
||||
echo $this->GenericPicker->add_option($param, $defaults);
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
@ -196,9 +201,9 @@ function submitFunction(clicked, callback) {
|
|||
|
||||
<?php if ($flag_addPills): // add forced pills ?>
|
||||
<ul class="nav nav-pills">
|
||||
<?php foreach ($items as $name => $param): ?>
|
||||
<?php foreach ($items as $k => $param): ?>
|
||||
<?php if (isset($param['isPill']) && $param['isPill']): ?>
|
||||
<?php echo $this->GenericPicker->add_pill($name, $param, $defaults); ?>
|
||||
<?php echo $this->GenericPicker->add_pill($param, $defaults); ?>
|
||||
<?php endif; ?>
|
||||
<?php endforeach; ?>
|
||||
</ul>
|
||||
|
@ -212,8 +217,8 @@ function submitFunction(clicked, callback) {
|
|||
|
||||
<?php elseif (count($items) > 0): ?>
|
||||
<ul class="nav nav-pills">
|
||||
<?php foreach ($items as $name => $param): ?>
|
||||
<?php echo $this->GenericPicker->add_pill($name, $param, $defaults); ?>
|
||||
<?php foreach ($items as $k => $param): ?>
|
||||
<?php echo $this->GenericPicker->add_pill($param, $defaults); ?>
|
||||
<?php endforeach; ?>
|
||||
</ul>
|
||||
<?php else: ?>
|
||||
|
|
|
@ -54,7 +54,7 @@
|
|||
'text' => __('Add Attribute')
|
||||
));
|
||||
echo '<li>';
|
||||
echo '<a href="#" onclick="popoverPopup(this, ' . h($event['Event']['id']) . ', \'objectTemplates\', \'objectChoice\')"> ' . __('Add Object') . '</a>';
|
||||
echo '<a href="#" onclick="popoverPopup(this, ' . h($event['Event']['id']) . ', \'objectTemplates\', \'objectMetaChoice\')"> ' . __('Add Object') . '</a>';
|
||||
echo '</li>';
|
||||
echo $this->element('/side_menu_link', array(
|
||||
'element_id' => 'addAttachment',
|
||||
|
|
|
@ -16,13 +16,13 @@ class GenericPickerHelper extends AppHelper {
|
|||
return $select_html;
|
||||
}
|
||||
|
||||
function add_option($name, $param, $defaults) {
|
||||
function add_option($param, $defaults) {
|
||||
$option_html = '<option';
|
||||
if (is_array($param)) {
|
||||
|
||||
if (isset($param['value'])) {
|
||||
$option_html .= ' value=' . h($param['value']);
|
||||
} else {
|
||||
$option_html .= ' value=' . h($name);
|
||||
$option_html .= ' value=' . h($param['name']);
|
||||
}
|
||||
if (isset($param['additionalData'])) {
|
||||
$additionalData = json_encode($param['additionalData']);
|
||||
|
@ -43,19 +43,16 @@ class GenericPickerHelper extends AppHelper {
|
|||
} else if (isset($param['selected']) && $param['selected']) { // nonsense to pre-select if disabled
|
||||
$option_html .= ' selected';
|
||||
}
|
||||
} else {
|
||||
$option_html .= ' value=' . h($param);
|
||||
}
|
||||
|
||||
$option_html .= '>';
|
||||
|
||||
$option_html .= h($name);
|
||||
$option_html .= h($param['name']);
|
||||
$option_html .= '</option>';
|
||||
return $option_html;
|
||||
}
|
||||
|
||||
function add_link_params($name, $param, $defaults=array()) {
|
||||
function add_link_params($param, $defaults=array()) {
|
||||
$param_html = ' ';
|
||||
if (is_array($param)) { // add data as param
|
||||
if (isset($param['functionName'])) {
|
||||
$param_html .= 'onclick="execAndClose(this, ' . $param['functionName'] . ')" ';
|
||||
} else { // fallback to default submit function
|
||||
|
@ -80,17 +77,13 @@ class GenericPickerHelper extends AppHelper {
|
|||
}
|
||||
}
|
||||
$param_html .= ' data-additionaldata=' . $additionalData;
|
||||
} else { // param is a simple endpoint from which fetch data
|
||||
$param_html .= 'data-endpoint="' . h($param) . '" ';
|
||||
$param_html .= 'onclick="fetchRequestedData(this)" ';
|
||||
}
|
||||
return $param_html;
|
||||
}
|
||||
|
||||
function add_pill($name, $param, $defaults=array()) {
|
||||
function add_pill($param, $defaults=array()) {
|
||||
$pill_html = '<li>';
|
||||
$pill_html .= '<a href="#" data-toggle="pill" class="pill-pre-picker"';
|
||||
$pill_html .= ' ' . $this->add_link_params($name, $param, $defaults);
|
||||
$pill_html .= ' ' . $this->add_link_params($param, $defaults);
|
||||
$pill_html .= '>';
|
||||
if (isset($param['img'])) {
|
||||
$pill_html .= '<img src="' . $param['img'] . '" style="margin-right: 5px; height: 14px;">';
|
||||
|
@ -98,7 +91,7 @@ class GenericPickerHelper extends AppHelper {
|
|||
$icon = isset($param['icon']) ? $param['icon'] : $param['templateData']['icon'];
|
||||
$pill_html .= '<span class="fa fa-' . $icon . '" style="margin-right: 5px;"></span>';
|
||||
}
|
||||
$pill_html .= h($name) . '</a>';
|
||||
$pill_html .= h($param['name']) . '</a>';
|
||||
$pill_html .= '</li>';
|
||||
return $pill_html;
|
||||
}
|
||||
|
|
|
@ -275,6 +275,7 @@
|
|||
|
||||
function pickCell(cell, clusterId, recurseChosen) {
|
||||
recurseChosen = recurseChosen === undefined ? true : recurseChosen;
|
||||
clusterId = parseInt(clusterId);
|
||||
|
||||
var $cells = $('td[data-cluster-id="' + clusterId + '"]');
|
||||
if (!cell.hasClass('cell-picked')) {
|
||||
|
|
Loading…
Reference in New Issue