mirror of https://github.com/MISP/MISP
chg: [decayingModels:enable/disable] Return a better API response
parent
fb2fb83682
commit
f3bd901f4e
|
@ -377,13 +377,15 @@ class DecayingModelController extends AppController
|
|||
|
||||
$decaying_model['DecayingModel']['enabled'] = 1;
|
||||
if ($this->DecayingModel->save($decaying_model)) {
|
||||
$model = $this->DecayingModel->fetchModel($this->Auth->user(), $id, true, array(), true);
|
||||
if (empty($model)) {
|
||||
throw new NotFoundException(__('No Decaying Model with the provided ID exists'));
|
||||
}
|
||||
$response = array('data' => $model, 'action' => 'enable');
|
||||
if ($this->request->is('ajax')) {
|
||||
$model = $this->DecayingModel->fetchModel($this->Auth->user(), $id, true, array(), true);
|
||||
if (empty($model)) {
|
||||
throw new NotFoundException(__('No Decaying Model with the provided ID exists'));
|
||||
}
|
||||
$response = array('data' => $model, 'action' => 'enable');
|
||||
return $this->RestResponse->viewData($response, $this->response->type());
|
||||
} else if ($this->_isRest()) {
|
||||
return $this->RestResponse->successResponse($id, __('Decaying model enabled'), $model);
|
||||
}
|
||||
$this->Flash->success(__('Decaying Model enabled.'));
|
||||
} else {
|
||||
|
@ -400,7 +402,7 @@ class DecayingModelController extends AppController
|
|||
}
|
||||
$this->Flash->error(__('Error while enabling decaying model'));
|
||||
}
|
||||
$this->redirect($this->referer());
|
||||
$this->redirect(array('action' => 'index'));
|
||||
} else {
|
||||
$this->set('model', $decaying_model['DecayingModel']);
|
||||
$this->render('ajax/enable_form');
|
||||
|
@ -420,13 +422,15 @@ class DecayingModelController extends AppController
|
|||
|
||||
$decaying_model['DecayingModel']['enabled'] = 0;
|
||||
if ($this->DecayingModel->save($decaying_model)) {
|
||||
$model = $this->DecayingModel->fetchModel($this->Auth->user(), $id, true, array(), true);
|
||||
if (empty($model)) {
|
||||
throw new NotFoundException(__('No Decaying Model with the provided ID exists'));
|
||||
}
|
||||
$response = array('data' => $model, 'action' => 'disable');
|
||||
if ($this->request->is('ajax')) {
|
||||
$model = $this->DecayingModel->fetchModel($this->Auth->user(), $id, true, array(), true);
|
||||
if (empty($model)) {
|
||||
throw new NotFoundException(__('No Decaying Model with the provided ID exists'));
|
||||
}
|
||||
$response = array('data' => $model, 'action' => 'disable');
|
||||
return $this->RestResponse->viewData($response, $this->response->type());
|
||||
} else if ($this->_isRest()) {
|
||||
return $this->RestResponse->successResponse($id, __('Decaying model disabled'), $model);
|
||||
}
|
||||
$this->Flash->success(__('Decaying Model disabled.'));
|
||||
} else {
|
||||
|
|
Loading…
Reference in New Issue