Display and Search for model ID in the audit logs, fixes #889

pull/903/head
Iglocska 2016-01-29 15:48:23 +01:00
parent 0357ec2558
commit 9c8719bf58
3 changed files with 15 additions and 1 deletions

View File

@ -150,6 +150,7 @@ class LogsController extends AppController {
}
$action = $this->request->data['Log']['action'];
$model = $this->request->data['Log']['model'];
$model_id = $this->request->data['Log']['model_id'];
$title = $this->request->data['Log']['title'];
$change = $this->request->data['Log']['change'];
if (Configure::read('MISP.log_client_ip')) $ip = $this->request->data['Log']['ip'];
@ -159,6 +160,7 @@ class LogsController extends AppController {
$this->set('orgSearch', $org);
$this->set('actionSearch', $action);
$this->set('modelSearch', $model);
$this->set('model_idSearch', $model_id);
$this->set('titleSearch', $title);
$this->set('changeSearch', $change);
if (Configure::read('MISP.log_client_ip')) $this->set('ipSearch', $ip);
@ -178,6 +180,9 @@ class LogsController extends AppController {
if ($model != '') {
$conditions['Log.model'] = $model;
}
if ($model_id != '') {
$conditions['Log.model_id'] = $model_id;
}
if (isset($title) && !empty($title)) {
$conditions['LOWER(Log.title) LIKE'] = '%' . strtolower($title) . '%';
}
@ -200,7 +205,8 @@ class LogsController extends AppController {
$this->Session->write('paginate_conditions_log_email', $email);
$this->Session->write('paginate_conditions_log_org', $org);
$this->Session->write('paginate_conditions_log_action', $action);
$this->Session->write('paginate_conditions_log_action', $model);
$this->Session->write('paginate_conditions_log_model', $model);
$this->Session->write('paginate_conditions_log_model_id', $model_id);
$this->Session->write('paginate_conditions_log_title', $title);
$this->Session->write('paginate_conditions_log_change', $change);
if (Configure::read('MISP.log_client_ip')) $this->Session->write('paginate_conditions_log_ip', $ip);
@ -213,6 +219,7 @@ class LogsController extends AppController {
$org = $this->Session->read('paginate_conditions_log_org');
$action = $this->Session->read('paginate_conditions_log_action');
$model = $this->Session->read('paginate_conditions_log_model');
$model_id = $this->Session->read('paginate_conditions_log_model_id');
$title = $this->Session->read('paginate_conditions_log_title');
$change = $this->Session->read('paginate_conditions_log_change');
if (Configure::read('MISP.log_client_ip')) $ip = $this->Session->read('paginate_conditions_log_ip');
@ -222,6 +229,7 @@ class LogsController extends AppController {
$this->set('orgSearch', $org);
$this->set('actionSearch', $action);
$this->set('modelSearch', $model);
$this->set('model_idSearch', $model_id);
$this->set('titleSearch', $title);
$this->set('changeSearch', $change);
if (Configure::read('MISP.log_client_ip')) $this->set('ipSearch', $ip);

View File

@ -7,6 +7,7 @@
'email' => array('text' => 'for user', 'default' => null),
'org' => array('text' => 'of organisation', 'default' => null),
'model' => array('text' => 'for model', 'default' => ''),
'model_id' => array('text' => 'for model ID', 'default' => ''),
'action' => array('text' => 'of type', 'default' => 'ALL'),
'title' => array('text' => 'with the title', 'default' => null),
'change' => array('text' => 'including the change', 'default' => null),
@ -46,6 +47,7 @@
<th><?php echo $this->Paginator->sort('org');?></th>
<th><?php echo $this->Paginator->sort('created');?></th>
<th><?php echo $this->Paginator->sort('model');?></th>
<th><?php echo $this->Paginator->sort('model_id', 'Model_ID');?></th>
<th><?php echo $this->Paginator->sort('action');?></th>
<th><?php echo $this->Paginator->sort('title');?></th>
<th><?php echo $this->Paginator->sort('change');?></th>
@ -71,6 +73,9 @@
<td class="short"><?php
if (isset($modelSearch) && $modelSearch != null) echo nl2br($this->Highlight->highlighter(h($item['Log']['model']), $modelSearchReplacePairs));
else echo (h($item['Log']['model'])); ?>&nbsp;</td>
<td style="width:100px;"><?php
if (isset($model_idSearch) && $model_idSearch != null) echo nl2br($this->Highlight->highlighter(h($item['Log']['model_id']), $model_idSearchReplacePairs));
else echo (h($item['Log']['model_id'])); ?>&nbsp;</td>
<td class="short"><?php
if (isset($actionSearch) && $actionSearch != "ALL") echo nl2br($this->Highlight->highlighter(h($item['Log']['action']), $actionSearchReplacePairs));
else echo (h($item['Log']['action'])); ?>&nbsp;</td>

View File

@ -11,6 +11,7 @@
echo $this->Form->input('model', array(
'between' => $this->Html->div('forminfo', '', array('id' => 'LogModelDiv')),
'div' => 'input clear'));
echo $this->Form->input('model_id', array('between' => $this->Html->div('forminfo', '', array('id' => 'LogModelIdDiv')),'type' => 'text', 'label' => 'Model ID'));
echo $this->Form->input('action', array(
'between' => $this->Html->div('forminfo', '', array('id' => 'LogActionDiv')),
));