mirror of https://github.com/MISP/MISP
new: batch delete should hard delete if event hasn't been published yet, fixes #3311
parent
98066f09a2
commit
e3c8f80421
|
@ -46,7 +46,7 @@ class AppController extends Controller {
|
|||
|
||||
public $helpers = array('Utility', 'OrgImg');
|
||||
|
||||
private $__queryVersion = '37';
|
||||
private $__queryVersion = '38';
|
||||
public $pyMispVersion = '2.4.90';
|
||||
public $phpmin = '5.6.5';
|
||||
public $phprec = '7.0.16';
|
||||
|
|
|
@ -1213,7 +1213,7 @@ class AttributesController extends AppController {
|
|||
}
|
||||
}
|
||||
|
||||
public function deleteSelected($id = false) {
|
||||
public function deleteSelected($id = false, $hard = false) {
|
||||
if (!$this->request->is('post')) {
|
||||
if ($this->request->is('get')) {
|
||||
return $this->RestResponse->describe('Attributes', 'deleteSelected', false, $this->response->type());
|
||||
|
@ -1250,7 +1250,7 @@ class AttributesController extends AppController {
|
|||
if (empty($ids)) $ids = -1;
|
||||
$conditions = array('id' => $ids, 'event_id' => $id);
|
||||
if ($ids == 'all') unset($conditions['id']);
|
||||
if ($this->_isRest() && empty($this->request->data['Attribute']['allow_hard_delete'])) {
|
||||
if ($hard || ($this->_isRest() && empty($this->request->data['Attribute']['allow_hard_delete']))) {
|
||||
$conditions['deleted'] = 0;
|
||||
}
|
||||
// find all attributes from the ID list that also match the provided event ID.
|
||||
|
@ -1270,7 +1270,12 @@ class AttributesController extends AppController {
|
|||
}
|
||||
$successes = array();
|
||||
foreach ($attributes as $a) {
|
||||
if ($this->__delete($a['Attribute']['id'], $a['Attribute']['deleted'] == 1 ? true : false)) $successes[] = $a['Attribute']['id'];
|
||||
if ($hard) {
|
||||
if ($this->__delete($a['Attribute']['id'], true)) $successes[] = $a['Attribute']['id'];
|
||||
} else {
|
||||
if ($this->__delete($a['Attribute']['id'], $a['Attribute']['deleted'] == 1 ? true : false)) $successes[] = $a['Attribute']['id'];
|
||||
}
|
||||
|
||||
}
|
||||
$fails = array_diff($ids, $successes);
|
||||
$this->autoRender = false;
|
||||
|
|
|
@ -77,7 +77,11 @@
|
|||
<br />
|
||||
<div id="edit_object_div">
|
||||
<?php
|
||||
echo $this->Form->create('Attribute', array('id' => 'delete_selected', 'url' => '/attributes/deleteSelected/' . $event['Event']['id']));
|
||||
$deleteSelectedUrl = '/attributes/deleteSelected/' . $event['Event']['id'];
|
||||
if (empty($event['Event']['publish_timestamp'])) {
|
||||
$deleteSelectedUrl .= '/1';
|
||||
}
|
||||
echo $this->Form->create('Attribute', array('id' => 'delete_selected', 'url' => $deleteSelectedUrl));
|
||||
echo $this->Form->input('ids_delete', array(
|
||||
'type' => 'text',
|
||||
'value' => 'test',
|
||||
|
|
|
@ -668,21 +668,21 @@ function multiSelectAction(event, context) {
|
|||
controller: "attributes",
|
||||
camelCase: "Attribute",
|
||||
alias: "attribute",
|
||||
action: "delete",
|
||||
action: "delete"
|
||||
},
|
||||
acceptProposals: {
|
||||
confirmation: "Are you sure you want to accept all selected proposals?",
|
||||
controller: "shadow_attributes",
|
||||
camelCase: "ShadowAttribute",
|
||||
alias: "proposal",
|
||||
action: "accept",
|
||||
action: "accept"
|
||||
},
|
||||
discardProposals: {
|
||||
confirmation: "Are you sure you want to discard all selected proposals?",
|
||||
controller: "shadow_attributes",
|
||||
camelCase: "ShadowAttribute",
|
||||
alias: "proposal",
|
||||
action: "discard",
|
||||
action: "discard"
|
||||
},
|
||||
};
|
||||
var answer = confirm("Are you sure you want to " + settings[context]["action"] + " all selected " + settings[context]["alias"] + "s?");
|
||||
|
@ -696,11 +696,17 @@ function multiSelectAction(event, context) {
|
|||
});
|
||||
$('#' + settings[context]["camelCase"] + 'Ids' + settings[context]["action"].ucfirst()).attr('value', JSON.stringify(selected));
|
||||
var formData = $('#' + settings[context]["action"] + '_selected').serialize();
|
||||
if (context == 'deleteAttributes') {
|
||||
var url = $('#delete_selected').attr('action');
|
||||
console.log(url);
|
||||
} else {
|
||||
var url = "/" + settings[context]["controller"] + "/" + settings[context]["action"] + "Selected/" + event;
|
||||
}
|
||||
$.ajax({
|
||||
data: formData,
|
||||
cache: false,
|
||||
type:"POST",
|
||||
url:"/" + settings[context]["controller"] + "/" + settings[context]["action"] + "Selected/" + event,
|
||||
url: url,
|
||||
success:function (data, textStatus) {
|
||||
updateIndex(event, 'event');
|
||||
var result = handleGenericAjaxResponse(data);
|
||||
|
|
Loading…
Reference in New Issue