mirror of https://github.com/MISP/MISP
chg: [clusterBlocklist] Added forms and endpoints to interract with the
modelpull/6120/head
parent
cd1712761a
commit
19d17ad12a
|
@ -78,7 +78,7 @@ class BlackListComponent extends Component
|
|||
$this->set('message', $message);
|
||||
$this->set('_serialize', array('message', 'result'));
|
||||
} else {
|
||||
$this->controller->Session->setFlash($message);
|
||||
$this->controller->Flash->success($message);
|
||||
$this->controller->redirect(array('action' => 'index'));
|
||||
}
|
||||
}
|
||||
|
@ -92,7 +92,7 @@ class BlackListComponent extends Component
|
|||
$blockEntry = $this->controller->{$this->controller->defaultModel}->find('first', array('conditions' => array('id' => $id)));
|
||||
}
|
||||
if (empty($blockEntry)) {
|
||||
throw new NotFoundException('Blacklist item not found.');
|
||||
throw new NotFoundException(__('Blacklist item not found.'));
|
||||
}
|
||||
$this->controller->set('blockEntry', $blockEntry);
|
||||
if ($this->controller->request->is('post')) {
|
||||
|
@ -123,14 +123,14 @@ class BlackListComponent extends Component
|
|||
$this->controller->set('message', array('Blacklist item added.'));
|
||||
$this->controller->set('_serialize', array('message'));
|
||||
} else {
|
||||
$this->controller->Session->setFlash(__('Blacklist item added.'));
|
||||
$this->controller->Flash->success(__('Blacklist item added.'));
|
||||
$this->controller->redirect(array('action' => 'index'));
|
||||
}
|
||||
} else {
|
||||
if ($rest) {
|
||||
throw new MethodNotAllowedException('Could not save the blacklist item.');
|
||||
} else {
|
||||
$this->controller->Session->setFlash(__('Could not save the blacklist item'));
|
||||
$this->controller->Flash->error(__('Could not save the blacklist item'));
|
||||
$this->controller->redirect(array('action' => 'index'));
|
||||
}
|
||||
}
|
||||
|
@ -156,9 +156,9 @@ class BlackListComponent extends Component
|
|||
}
|
||||
|
||||
if ($this->controller->{$this->controller->defaultModel}->delete()) {
|
||||
$this->controller->Session->setFlash(__('Blacklist entry removed'));
|
||||
$this->controller->Flash->success(__('Blacklist entry removed'));
|
||||
} else {
|
||||
$this->controller->Session->setFlash(__('Could not remove the blacklist entry'));
|
||||
$this->controller->Flash->error(__('Could not remove the blacklist entry'));
|
||||
}
|
||||
$this->controller->redirect(array('action' => 'index'));
|
||||
}
|
||||
|
|
|
@ -40,11 +40,14 @@ class GalaxyClusterBlocklistsController extends AppController
|
|||
public function add()
|
||||
{
|
||||
$this->BlackList->add($this->_isRest());
|
||||
$this->set('action', 'add');
|
||||
}
|
||||
|
||||
public function edit($id)
|
||||
{
|
||||
$this->BlackList->edit($this->_isRest(), $id);
|
||||
$this->set('action', 'edit');
|
||||
$this->render('add');
|
||||
}
|
||||
|
||||
public function delete($id)
|
||||
|
|
|
@ -697,7 +697,11 @@ class GalaxyClustersController extends AppController
|
|||
$result = $this->GalaxyCluster->deleteCluster($cluster['GalaxyCluster']['id'], $hard=$hard);
|
||||
$galaxyId = $cluster['GalaxyCluster']['galaxy_id'];
|
||||
if ($result) {
|
||||
$message = __('Galaxy cluster successfuly %s deleted.', $hard ? __('hard') : __('soft'));
|
||||
$message = __(
|
||||
'Galaxy cluster successfuly %s deleted%s.',
|
||||
$hard ? __('hard') : __('soft'),
|
||||
$hard ? __(' and added to the block list') : ''
|
||||
);
|
||||
if ($this->_isRest()) {
|
||||
return $this->RestResponse->saveSuccessResponse('GalaxyCluster', 'delete', $cluster['GalaxyCluster']['id'], $this->response->type());
|
||||
} else {
|
||||
|
|
|
@ -14,7 +14,7 @@ class GalaxyClusterBlocklist extends AppModel
|
|||
'Containable',
|
||||
);
|
||||
|
||||
public $blocklistFields = array('cluster_uuid', 'comment', 'cluster_info', 'cluster_orgc');
|
||||
public $blacklistFields = array('cluster_uuid', 'comment', 'cluster_info', 'cluster_orgc');
|
||||
|
||||
public $validate = array(
|
||||
'cluster_uuid' => array(
|
||||
|
|
|
@ -0,0 +1,47 @@
|
|||
<?php
|
||||
echo $this->element('genericElements/Form/genericForm', array(
|
||||
'form' => $this->Form,
|
||||
'data' => array(
|
||||
'model' => 'GalaxyClusterBlocklist',
|
||||
'title' => $action == 'add' ? __('Add block entry for Galaxy Cluster') : __('Edit block entry for Galaxy Cluster'),
|
||||
'fields' => array(
|
||||
array(
|
||||
'field' => 'cluster_uuid',
|
||||
'label' => __('Cluster UUID'),
|
||||
'type' => 'textarea',
|
||||
'help' => _('Enter a single or a list of UUIDs'),
|
||||
'default' => isset($blockEntry['GalaxyClusterBlocklist']['cluster_uuid']) ? $blockEntry['GalaxyClusterBlocklist']['cluster_uuid'] : ''
|
||||
),
|
||||
array(
|
||||
'field' => 'cluster_orgc',
|
||||
'label' => __('Creating organisation'),
|
||||
'type' => 'text',
|
||||
'help' => _('(Optional) The organisation that the event is associated with'),
|
||||
'default' => isset($blockEntry['GalaxyClusterBlocklist']['cluster_orgc']) ? $blockEntry['GalaxyClusterBlocklist']['cluster_orgc'] : ''
|
||||
),
|
||||
array(
|
||||
'field' => 'cluster_info',
|
||||
'label' => __('Cluster value'),
|
||||
'type' => 'text',
|
||||
'help' => _('(Optional) The cluster value that you would like to block'),
|
||||
'default' => isset($blockEntry['GalaxyClusterBlocklist']['cluster_info']) ? $blockEntry['GalaxyClusterBlocklist']['cluster_info'] : ''
|
||||
),
|
||||
array(
|
||||
'field' => 'comment',
|
||||
'label' => __('Comment'),
|
||||
'type' => 'text',
|
||||
'help' => _('(Optional) Any comments you would like to add regarding this (or these) entries'),
|
||||
'default' => isset($blockEntry['GalaxyClusterBlocklist']['comment']) ? $blockEntry['GalaxyClusterBlocklist']['comment'] : ''
|
||||
),
|
||||
),
|
||||
'submit' => array(
|
||||
'ajaxSubmit' => ''
|
||||
)
|
||||
)
|
||||
));
|
||||
echo $this->element('/genericElements/SideMenu/side_menu', array('menuList' => 'galaxies', 'menuItem' => 'index_blocklist'));
|
||||
?>
|
||||
|
||||
<script type="text/javascript">
|
||||
</script>
|
||||
<?php echo $this->Js->writeBuffer(); // Write cached scripts
|
Loading…
Reference in New Issue