mirror of https://github.com/MISP/MISP
fix: Fixed the detaching of galaxies
parent
f232fe4fb6
commit
9d6f380957
|
@ -74,7 +74,7 @@ class GalaxyClustersController extends AppController {
|
|||
$this->loadModel('Event');
|
||||
$this->Event->id = $event_id;
|
||||
$this->Event->recursive = -1;
|
||||
$event = $this->Event->read(array('id', 'org_id', 'orgc_id', 'distribution', 'sharing_group_id'), $id);
|
||||
$event = $this->Event->read(array('id', 'org_id', 'orgc_id', 'distribution', 'sharing_group_id'), $event_id);
|
||||
if (empty($event)) {
|
||||
throw new MethodNotAllowedException('Invalid Event.');
|
||||
}
|
||||
|
@ -83,18 +83,18 @@ class GalaxyClustersController extends AppController {
|
|||
throw new MethodNotAllowedException('Invalid Event.');
|
||||
}
|
||||
}
|
||||
$tag = $this->EventTag->Tag->find('first', array('conditions' => array('Tag.name' => $tag_name), 'recursive' => -1));
|
||||
$tag = $this->Event->EventTag->Tag->find('first', array('conditions' => array('Tag.name' => $tag_name), 'recursive' => -1));
|
||||
if (empty($tag)) {
|
||||
$this->EventTag->Tag->create();
|
||||
$this->EventTag->Tag->save(array('name' => $tag_name, 'colour' => '#0088cc', 'exportable' => 1));
|
||||
$tag_id = $this->EventTag->Tag->id;
|
||||
$this->Event->EventTag->Tag->create();
|
||||
$this->Event->EventTag->Tag->save(array('name' => $tag_name, 'colour' => '#0088cc', 'exportable' => 1));
|
||||
$tag_id = $this->Event->EventTag->Tag->id;
|
||||
} else {
|
||||
$tag_id = $tag['Tag']['id'];
|
||||
}
|
||||
$existingEventTag = $this->EventTag->find('first', array('conditions' => array('EventTag.tag_id' => $tag_id, 'EventTag.event_id' => $event_id), 'recursive' => -1));
|
||||
$existingEventTag = $this->Event->EventTag->find('first', array('conditions' => array('EventTag.tag_id' => $tag_id, 'EventTag.event_id' => $event_id), 'recursive' => -1));
|
||||
if (empty($existingEventTag)) {
|
||||
$this->EventTag->create();
|
||||
$this->EventTag->save(array('EventTag.tag_id' => $tag_id, 'EventTag.event_id' => $event_id));
|
||||
$this->Event->EventTag->create();
|
||||
$this->Event->EventTag->save(array('EventTag.tag_id' => $tag_id, 'EventTag.event_id' => $event_id));
|
||||
$this->Session->setFlash('Galaxy attached.');
|
||||
} else {
|
||||
$this->Session->setFlash('Galaxy already attached.');
|
||||
|
@ -102,11 +102,11 @@ class GalaxyClustersController extends AppController {
|
|||
$this->redirect($this->referer());
|
||||
}
|
||||
|
||||
public function detachFromEvent($event_id, $tag_name) {
|
||||
public function detachFromEvent($event_id, $tag_id) {
|
||||
$this->loadModel('Event');
|
||||
$this->Event->id = $event_id;
|
||||
$this->Event->recursive = -1;
|
||||
$event = $this->Event->read(array('id', 'org_id', 'orgc_id', 'distribution', 'sharing_group_id'), $id);
|
||||
$event = $this->Event->read(array('id', 'org_id', 'orgc_id', 'distribution', 'sharing_group_id'), $event_id);
|
||||
if (empty($event)) {
|
||||
throw new MethodNotAllowedException('Invalid Event.');
|
||||
}
|
||||
|
@ -115,17 +115,12 @@ class GalaxyClustersController extends AppController {
|
|||
throw new MethodNotAllowedException('Invalid Event.');
|
||||
}
|
||||
}
|
||||
$tag = $this->EventTag->Tag->find('first', array('conditions' => array('Tag.name' => $tag_name), 'recursive' => -1));
|
||||
if (empty($tag)) {
|
||||
$existingEventTag = $this->Event->EventTag->find('first', array('conditions' => array('EventTag.tag_id' => $tag_id, 'EventTag.event_id' => $event_id), 'recursive' => -1));
|
||||
if (empty($existingEventTag)) {
|
||||
$this->Session->setFlash('Galaxy not attached.');
|
||||
} else {
|
||||
$existingEventTag = $this->EventTag->find('first', array('conditions' => array('EventTag.tag_id' => $tag['Tag']['id'], 'EventTag.event_id' => $event_id), 'recursive' => -1));
|
||||
if (empty($existingEventTag)) {
|
||||
$this->Session->setFlash('Galaxy not attached.');
|
||||
} else {
|
||||
$this->EventTag->delete($eexistingEventTag['EventTag']['id']);
|
||||
$this->Session->setFlash('Galaxy successfully detached.');
|
||||
}
|
||||
$this->Event->EventTag->delete($existingEventTag['EventTag']['id']);
|
||||
$this->Session->setFlash('Galaxy successfully detached.');
|
||||
}
|
||||
$this->redirect($this->referer());
|
||||
}
|
||||
|
|
|
@ -3,17 +3,17 @@
|
|||
foreach ($event['Galaxy'] as $galaxy):
|
||||
?>
|
||||
<div class="useCursorPointer">
|
||||
<span title="<?php echo isset($galaxy['description']) ? h($galaxy['description']) : h($galaxy['name']);?>" class="expandable bold blue" style="font-size:14px;">
|
||||
<span title="<?php echo isset($galaxy['description']) ? h($galaxy['description']) : h($galaxy['name']);?>" class="bold blue" style="font-size:14px;">
|
||||
<?php echo h($galaxy['name']); ?>
|
||||
</span>
|
||||
<?php
|
||||
foreach ($galaxy['GalaxyCluster'] as $cluster):
|
||||
?>
|
||||
<div style="margin-left:20px;" class="hidden useCursorPointer">
|
||||
<div style="margin-left:20px;" class="useCursorPointer">
|
||||
<span class="bold blue expandable"><?php echo h($cluster['value']); ?></span>
|
||||
<?php
|
||||
echo $this->Form->postLink('',
|
||||
$baseurl . '/events/removeTag/' . $event['Event']['id'] . '/' . $cluster['tag_id'],
|
||||
$baseurl . '/galaxy_clusters/detachFromEvent/' . $event['Event']['id'] . '/' . $cluster['tag_id'],
|
||||
array('class' => 'icon-trash', 'title' => 'Delete'),
|
||||
__('Are you sure you want to detach %s from this event?', h($cluster['value']))
|
||||
);
|
||||
|
|
Loading…
Reference in New Issue