diff --git a/app/Controller/GalaxiesController.php b/app/Controller/GalaxiesController.php
index 3ce4540b7..e967886b9 100644
--- a/app/Controller/GalaxiesController.php
+++ b/app/Controller/GalaxiesController.php
@@ -86,4 +86,75 @@ class GalaxiesController extends AppController {
$this->set('galaxy', $galaxy);
}
}
+
+ public function selectGalaxy($event_id) {
+ $galaxies = $this->Galaxy->find('all', array('recursive' => -1));
+ $this->set('galaxies', $galaxies);
+ $this->set('event_id', $event_id);
+ $this->render('ajax/galaxy_choice');
+ }
+
+ public function selectCluster($event_id) {
+ $selectGalaxy = isset($this->request->data['Galaxy']['id']) ? $this->request->data['Galaxy']['id'] : false;
+ $conditions = array();
+ if ($selectGalaxy) {
+ $conditions = array('GalaxyCluster.galaxy_id' => $selectGalaxy);
+ }
+ $data = $this->Galaxy->GalaxyCluster->find('all', array(
+ 'conditions' => $conditions,
+ 'fields' => array('value', 'description', 'source'),
+ 'contain' => array('GalaxyElement' => array('conditions' => array('GalaxyElement.key' => 'synonyms'))),
+ 'recursive' => -1
+ ));
+ $clusters = array();
+ $lookup_table = array();
+ foreach ($data as $k => $cluster) {
+ $cluster['GalaxyCluster']['synonyms_string'] = array();
+ foreach ($cluster['GalaxyElement'] as $element) {
+ $cluster['GalaxyCluster']['synonyms_string'][] = $element['value'];
+ if (isset($lookup_table[$element['value']])) {
+ $lookup_table[$element['value']][] = $cluster['GalaxyCluster']['id'];
+ } else {
+ $lookup_table[$element['value']] = array($cluster['GalaxyCluster']['id']);
+ }
+ }
+ $cluster['GalaxyCluster']['synonyms_string'] = implode(', ', $cluster['GalaxyCluster']['synonyms_string']);
+ unset($cluster['GalaxyElement']);
+ $clusters[$cluster['GalaxyCluster']['value']] = $cluster['GalaxyCluster'];
+ ksort($clusters);
+ if (isset($lookup_table[$cluster['GalaxyCluster']['value']])) {
+ $lookup_table[$cluster['GalaxyCluster']['value']][] = $cluster['GalaxyCluster']['id'];
+ } else {
+ $lookup_table[$cluster['GalaxyCluster']['value']] = array($cluster['GalaxyCluster']['id']);
+ }
+ }
+ $this->set('clusters', $clusters);
+ $this->set('event_id', $event_id);
+ $this->set('lookup_table', $lookup_table);
+ $this->render('ajax/cluster_choice');
+ }
+
+ public function attachClusterToEvent($event_id) {
+ $cluster_id = $this->request->data['Galaxy']['target_id'];
+ $cluster = $this->Galaxy->GalaxyCluster->find('first', array('recursive' => -1, 'conditions' => array('id' => $cluster_id), 'fields' => array('tag_name')));
+ $this->loadModel('Tag');
+ $tag_id = $this->Tag->captureTag(array('name' => $cluster['GalaxyCluster']['tag_name'], 'colour' => '#0088cc'), $this->Auth->user());
+ if ($tag_id === false) {
+ throw new MethodNotAllowedException('Could not attach cluster.');
+ }
+ $this->Tag->EventTag->create();
+ $existingTag = $this->Tag->EventTag->find('first', array('conditions' => array('event_id' => $event_id, 'tag_id' => $tag_id)));
+ if (!empty($existingTag)) {
+ $this->Session->setFlash('Cluster already attached.');
+ $this->redirect($this->referer());
+ }
+ $result = $this->Tag->EventTag->save(array('event_id' => $event_id, 'tag_id' => $tag_id));
+ if ($result) {
+ $this->Session->setFlash('Cluster attached');
+ $this->redirect($this->referer());
+ } else {
+ $this->Session->setFlash('Cluster could not be attached');
+ $this->redirect($this->referer());
+ }
+ }
}
diff --git a/app/Controller/TagsController.php b/app/Controller/TagsController.php
index 224a0dca5..24ed9d95b 100644
--- a/app/Controller/TagsController.php
+++ b/app/Controller/TagsController.php
@@ -352,6 +352,11 @@ class TagsController extends AppController {
unset($expanded[$banned_tag]);
}
}
+ foreach ($options as $k => $v) {
+ if (substr($v, 0, strlen('misp-galaxy:')) === 'misp-galaxy:') {
+ unset($options[$k]);
+ }
+ }
$this->set('event_id', $event_id);
$this->set('options', $options);
$this->set('expanded', $expanded);
diff --git a/app/Model/Tag.php b/app/Model/Tag.php
index 8c79132d1..d0d095d7f 100644
--- a/app/Model/Tag.php
+++ b/app/Model/Tag.php
@@ -113,7 +113,7 @@ class Tag extends AppModel {
$tag = array(
'name' => $tag['name'],
'colour' => $tag['colour'],
- 'exportable' => $tag['exportable'],
+ 'exportable' => isset($tag['exportable']) ? $tag['exportable'] : 0,
'org_id' => 0
);
$this->save($tag);
@@ -151,7 +151,7 @@ class Tag extends AppModel {
return $colour;
}
- public function quickAdd($name, $colour = false) {
+ public function quickAdd($name, $colour = false, $returnId = false) {
$this->create();
if ($colour === false) $colour = $this->random_color();
$data = array(
diff --git a/app/View/Elements/galaxyQuickView.ctp b/app/View/Elements/galaxyQuickView.ctp
index 612c1a0f6..db16a9310 100644
--- a/app/View/Elements/galaxyQuickView.ctp
+++ b/app/View/Elements/galaxyQuickView.ctp
@@ -2,7 +2,7 @@
$fixed_fields = array('decription', 'source', 'authors');
foreach ($event['Galaxy'] as $galaxy):
?>
-
+
@@ -69,8 +69,7 @@ $(document).ready(function () {
});
$('.delete-cluster').click(function() {
var tagName = $(this).data('tag-name');
- alert(tagName);
- removeTag($id = false, $tag_id = false, $galaxy = false)
+ removeTag($id = false, $tag_id = false, $galaxy = false);
});
});
\ No newline at end of file
diff --git a/app/View/Events/view.ctp b/app/View/Events/view.ctp
index c1fcb3107..ffdb1a315 100644
--- a/app/View/Events/view.ctp
+++ b/app/View/Events/view.ctp
@@ -225,16 +225,16 @@
-
@@ -244,7 +244,9 @@
1) echo $this->element('pivot'); ?>
-
Galaxies
+ Galaxies
+ +
+
element('galaxyQuickView', array()); ?>
@@ -259,27 +261,13 @@
var showContext = false;
$(document).ready(function () {
popoverStartup();
+
$("th, td, dt, div, span, li").tooltip({
'placement': 'top',
'container' : 'body',
delay: { show: 500, hide: 100 }
- });
- var toggles = ['discussions', 'attributes', 'pivots', 'galaxies'];
- $('.toggle-button').click(function() {
- var element = $(this).data('toggle-type');
- if ($(this).children('span').hasClass('icon-minus')) {
- $(this).children('span').addClass('icon-plus');
- $(this).children('span').removeClass('icon-minus');
- $('#' + element + '_div').hide();
- } else {
- $(this).children('span').removeClass('icon-plus');
- $(this).children('span').addClass('icon-minus');
- $('#' + element + '_div').show();
- }
});
-// $.get("/events/viewEventAttributes/", function(data) {
-// $("#attributes_div").html(data);
-// });
+
$.get("/threads/view//true", function(data) {
$("#discussions_div").html(data);
});
diff --git a/app/View/Galaxies/ajax/cluster_choice.ctp b/app/View/Galaxies/ajax/cluster_choice.ctp
new file mode 100644
index 000000000..d4e09408a
--- /dev/null
+++ b/app/View/Galaxies/ajax/cluster_choice.ctp
@@ -0,0 +1,61 @@
+
+
+
+ Form->create('Galaxy', array('url' => '/galaxies/attachClusterToEvent/' . $event_id, 'style' => 'margin:0px;'));
+ echo $this->Form->input('target_id', array('type' => 'text'));
+ echo $this->Form->end();
+ ?>
+
+
+
+
+
+
+ $cluster):
+ $title = isset($cluster['description']) ? $cluster['description'] : $cluster['value'];
+ ?>
+
+ |
+
+
+
+ Back to Galaxy Selection |
+
+
+
+
Cancel
+
+
diff --git a/app/View/Galaxies/ajax/galaxy_choice.ctp b/app/View/Galaxies/ajax/galaxy_choice.ctp
new file mode 100644
index 000000000..d6dc39151
--- /dev/null
+++ b/app/View/Galaxies/ajax/galaxy_choice.ctp
@@ -0,0 +1,25 @@
+
+
+
+
+
+ All Galaxies |
+
+
+
+ Galaxy: |
+
+
+
+
+
Cancel
+
+
diff --git a/app/webroot/js/misp2.4.52.js b/app/webroot/js/misp2.4.52.js
index e680bd317..fdcf83b55 100644
--- a/app/webroot/js/misp2.4.52.js
+++ b/app/webroot/js/misp2.4.52.js
@@ -2688,3 +2688,26 @@ function selectAllInbetween(last, current) {
}
});
}
+
+$('.galaxy-toggle-button').click(function() {
+ var element = $(this).data('toggle-type');
+ if ($(this).children('span').hasClass('icon-minus')) {
+ $(this).children('span').addClass('icon-plus');
+ $(this).children('span').removeClass('icon-minus');
+ $('#' + element + '_div').hide();
+ } else {
+ $(this).children('span').removeClass('icon-plus');
+ $(this).children('span').addClass('icon-minus');
+ $('#' + element + '_div').show();
+ }
+});
+
+$('#addGalaxy').click(function() {
+ getPopup($(this).data('event-id'), 'galaxies', 'selectGalaxy');
+});
+
+function quickSubmitGalaxyForm(event_id, cluster_id) {
+ $('#GalaxyTargetId').val(cluster_id);
+ $('#GalaxySelectClusterForm').submit();
+ return false;
+}