mirror of https://github.com/MISP/MISP
fix: Added functionality to remove taxonomies, fixes #1365
parent
efee48557c
commit
d6e1283c43
|
@ -204,4 +204,24 @@ class TaxonomiesController extends AppController {
|
|||
$this->set('id', $id);
|
||||
$this->render('ajax/taxonomy_mass_confirmation');
|
||||
}
|
||||
|
||||
public function delete($id) {
|
||||
if ($this->request->is('post')) {
|
||||
$result = $this->Taxonomy->delete($id, true);
|
||||
if ($result) {
|
||||
$this->Session->setFlash('Taxonomy successfuly deleted.');
|
||||
$this->redirect(array('controller' => 'taxonomies', 'action' => 'index'));
|
||||
} else {
|
||||
$this->Session->setFlash('Taxonomy could not be deleted.');
|
||||
$this->redirect(array('controller' => 'taxonomies', 'action' => 'index'));
|
||||
}
|
||||
} else {
|
||||
if ($this->request->is('ajax')) {
|
||||
$this->set('id', $id);
|
||||
$this->render('ajax/taxonomy_delete_confirmation');
|
||||
} else {
|
||||
throw new MethodNotAllowedException('This function can only be reached via AJAX.');
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -282,12 +282,13 @@
|
|||
case 'taxonomies': ?>
|
||||
<li id='liindex'><a href="<?php echo $baseurl;?>/taxonomies/index">List Taxonomies</a></li>
|
||||
<?php if ($menuItem === 'view'): ?>
|
||||
<li id='liview'><a href="">View Taxonomy</a></li>
|
||||
<li id='liview'><a href="">View Taxonomy</a></li>
|
||||
<li id='lidelete'><a class="useCursorPointer" onClick="deleteObject('taxonomies', 'delete', '<?php echo h($id); ?>', '<?php echo h($id); ?>');">Delete Taxonomy</a></li>
|
||||
<?php
|
||||
endif;
|
||||
if ($isSiteAdmin):
|
||||
?>
|
||||
<li id='liupdate'><?php echo $this->Form->postLink('Update Taxonomies', array('controller' => 'taxonomies', 'action' => 'update'));?></li>
|
||||
<li id='liupdate'><?php echo $this->Form->postLink('Update Taxonomies', array('controller' => 'taxonomies', 'action' => 'update'));?></li>
|
||||
<?php
|
||||
endif;
|
||||
break;
|
||||
|
|
|
@ -0,0 +1,33 @@
|
|||
<div class="confirmation">
|
||||
<?php
|
||||
echo $this->Form->create('Taxonomy', array(
|
||||
'style' => 'margin:0px;',
|
||||
'id' => 'PromptForm',
|
||||
'url' => array('controller' => 'taxonomies', 'action' => 'delete', $id)
|
||||
));
|
||||
?>
|
||||
<legend>Taxonomy Deletion</legend>
|
||||
<div style="padding-left:5px;padding-right:5px;padding-bottom:5px;">
|
||||
<p>Are you sure you want to delete Taxonomy #<?php echo h($id); ?>?<br /> Associated tags will not be removed. You can reload the taxonomy at any time by updating your taxonomies.</p>
|
||||
<table>
|
||||
<tr>
|
||||
<td style="vertical-align:top">
|
||||
<?php
|
||||
echo $this->Form->button('Yes', array(
|
||||
'type' => 'submit',
|
||||
'class' => 'btn btn-primary'
|
||||
));
|
||||
?>
|
||||
</td>
|
||||
<td style="width:540px;">
|
||||
</td>
|
||||
<td style="vertical-align:top;">
|
||||
<span class="btn btn-inverse" id="PromptNoButton" onClick="cancelPrompt();">No</span>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
<?php
|
||||
echo $this->Form->end();
|
||||
?>
|
||||
</div>
|
|
@ -45,6 +45,7 @@ foreach ($taxonomies as $item): ?>
|
|||
}
|
||||
?>
|
||||
<a href='<?php echo $baseurl."/taxonomies/view/". h($item['Taxonomy']['id']);?>' class = "icon-list-alt" title = "View"></a>
|
||||
<span class="icon-trash useCursorPointer" onClick="deleteObject('taxonomies', 'delete', '<?php echo h($item['Taxonomy']['id']); ?>', '<?php echo h($item['Taxonomy']['id']); ?>');"></span>
|
||||
</td>
|
||||
</tr><?php
|
||||
endforeach; ?>
|
||||
|
|
|
@ -4,8 +4,8 @@ String.prototype.ucfirst = function() {
|
|||
|
||||
function deleteObject(type, action, id, event) {
|
||||
var destination = 'attributes';
|
||||
if (type == 'shadow_attributes') destination = 'shadow_attributes';
|
||||
else if (type == 'template_elements') destination = 'template_elements';
|
||||
var alternateDestinations = ['shadow_attributes', 'template_elements', 'taxonomies'];
|
||||
if (alternateDestinations.indexOf(type) > -1) destination = type;
|
||||
url = "/" + destination + "/" + action + "/" + id;
|
||||
$.get(url, function(data) {
|
||||
$("#confirmation_box").fadeIn();
|
||||
|
|
Loading…
Reference in New Issue