mirror of https://github.com/MISP/MISP
new: [Galaxy] Delete individual clusters
- added an API and UI option to delete individual clusterspull/3725/head
parent
e4e38825b1
commit
bae469257a
|
@ -271,4 +271,44 @@ class GalaxyClustersController extends AppController
|
|||
}
|
||||
$this->redirect($this->referer());
|
||||
}
|
||||
|
||||
public function delete($id) {
|
||||
{
|
||||
if ($this->request->is('post')) {
|
||||
$result = false;
|
||||
$galaxy_cluster = $this->GalaxyCluster->find('first', array(
|
||||
'recursive' => -1,
|
||||
'conditions' => array('GalaxyCluster.id' => $id)
|
||||
));
|
||||
if (!empty($galaxy_cluster)) {
|
||||
$result = $this->GalaxyCluster->delete($id, true);
|
||||
$galaxy_id = $galaxy_cluster['GalaxyCluster']['galaxy_id'];
|
||||
}
|
||||
if ($result) {
|
||||
$message = 'Galaxy cluster successfuly deleted.';
|
||||
if ($this->_isRest()) {
|
||||
return $this->RestResponse->saveSuccessResponse('GalaxyCluster', 'delete', $id, $this->response->type());
|
||||
} else {
|
||||
$this->Flash->success($message);
|
||||
$this->redirect(array('controller' => 'galaxies', 'action' => 'view', $galaxy_id));
|
||||
}
|
||||
} else {
|
||||
$message = 'Galaxy cluster could not be deleted.';
|
||||
if ($this->_isRest()) {
|
||||
return $this->RestResponse->saveFailResponse('GalaxyCluster', 'delete', $id, $message, $this->response->type());
|
||||
} else {
|
||||
$this->Flash->error($message);
|
||||
$this->redirect(array('controller' => 'taxonomies', 'action' => 'index'));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if ($this->request->is('ajax')) {
|
||||
$this->set('id', $id);
|
||||
$this->render('ajax/galaxy_cluster_delete_confirmation');
|
||||
} else {
|
||||
throw new MethodNotAllowedException('This function can only be reached via AJAX.');
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -79,6 +79,7 @@
|
|||
<td class="short action-links">
|
||||
<?php echo $this->Html->link('', array('controller' => 'galaxies', 'action' => 'viewGraph', $item['GalaxyCluster']['id']), array('class' => 'fa fa-share-alt', 'title' => 'View graph'));?>
|
||||
<?php echo $this->Html->link('', array('action' => 'view', $item['GalaxyCluster']['id']), array('class' => 'icon-list-alt', 'title' => 'View'));?>
|
||||
<span class="icon-trash useCursorPointer" title="<?php echo __('Delete galaxy cluster');?>" role="button" tabindex="0" aria-label="<?php echo __('Delete galaxy cluster');?>" onClick="deleteObject('galaxy_clusters', 'delete', '<?php echo h($item['GalaxyCluster']['id']); ?>', '<?php echo h($item['GalaxyCluster']['id']); ?>');"></span>
|
||||
</td>
|
||||
</tr>
|
||||
<?php
|
||||
|
|
|
@ -4,7 +4,7 @@ String.prototype.ucfirst = function() {
|
|||
|
||||
function deleteObject(type, action, id, event) {
|
||||
var destination = 'attributes';
|
||||
var alternateDestinations = ['shadow_attributes', 'template_elements', 'taxonomies', 'objects', 'object_references'];
|
||||
var alternateDestinations = ['shadow_attributes', 'template_elements', 'taxonomies', 'galaxy_clusters', 'objects', 'object_references'];
|
||||
if (alternateDestinations.indexOf(type) > -1) destination = type;
|
||||
else destination = type;
|
||||
url = "/" + destination + "/" + action + "/" + id;
|
||||
|
|
Loading…
Reference in New Issue