1<?php 2/* 3** Zabbix 4** Copyright (C) 2001-2021 Zabbix SIA 5** 6** This program is free software; you can redistribute it and/or modify 7** it under the terms of the GNU General Public License as published by 8** the Free Software Foundation; either version 2 of the License, or 9** (at your option) any later version. 10** 11** This program is distributed in the hope that it will be useful, 12** but WITHOUT ANY WARRANTY; without even the implied warranty of 13** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14** GNU General Public License for more details. 15** 16** You should have received a copy of the GNU General Public License 17** along with this program; if not, write to the Free Software 18** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 19**/ 20 21 22/** 23 * @var CView $this 24 */ 25$this->addJsFile('flickerfreescreen.js'); 26$this->addJsFile('gtlc.js'); 27$this->addJsFile('class.calendar.js'); 28$this->addJsFile('multiselect.js'); 29 30$this->includeJsFile('reports.auditlog.list.js.php'); 31 32$filter = (new CFilter((new CUrl('zabbix.php'))->setArgument('action', $data['action']))); 33 34$select_filter_resourcetype = (new CSelect('filter_resourcetype')) 35 ->setId('resourcetype-select') 36 ->setValue($data['resourcetype']) 37 ->setFocusableElementId('filter-resourcetype') 38 ->addOptions(CSelect::createOptionsFromArray($data['resources'])); 39 40$select_filter_action = (new CSelect('filter_action')) 41 ->setId('action-select') 42 ->setValue($data['auditlog_action']) 43 ->setFocusableElementId('filter-action') 44 ->addOptions(CSelect::createOptionsFromArray($data['actions'])); 45 46$filter_form = (new CFormList()) 47 ->addRow(new CLabel(_('Users'), 'filter_userids__ms'), [ 48 (new CMultiSelect([ 49 'name' => 'filter_userids[]', 50 'object_name' => 'users', 51 'data' => $data['userids'], 52 'placeholder' => '', 53 'popup' => [ 54 'parameters' => [ 55 'srctbl' => 'users', 56 'srcfld1' => 'userid', 57 'srcfld2' => 'fullname', 58 'dstfrm' => $filter->getName(), 59 'dstfld1' => 'filter_userids_' 60 ] 61 ] 62 ]))->setWidth(ZBX_TEXTAREA_FILTER_STANDARD_WIDTH) 63 ]) 64 ->addRow(new CLabel(_('Resource'), $select_filter_resourcetype->getFocusableElementId()), 65 $select_filter_resourcetype 66 ) 67 ->addRow(_('Resource ID'), (new CTextBox('filter_resourceid', $data['resourceid'])) 68 ->setWidth(ZBX_TEXTAREA_FILTER_STANDARD_WIDTH) 69 ) 70 ->addRow(new CLabel(_('Action'), $select_filter_action->getFocusableElementId()), 71 $select_filter_action 72 ); 73 74$widget = (new CWidget()) 75 ->setTitle(_('Audit log')) 76 ->addItem($filter 77 ->addVar('action', $data['action']) 78 ->setProfile($data['timeline']['profileIdx']) 79 ->setActiveTab($data['active_tab']) 80 ->addTimeSelector($data['timeline']['from'], $data['timeline']['to']) 81 ->addFilterTab(_('Filter'), [$filter_form]) 82); 83 84$table = (new CTableInfo()) 85 ->setHeader([ 86 _('Time'), 87 _('User'), 88 _('IP'), 89 _('Resource'), 90 _('Action'), 91 _('ID'), 92 _('Description'), 93 _('Details') 94 ]); 95 96foreach ($data['auditlogs'] as $auditlog) { 97 $details = []; 98 99 foreach ($auditlog['details'] as $detail) { 100 $details[] = [$detail['table_name'].'.'.$detail['field_name'].': '.$detail['oldvalue']. 101 ' => '.$detail['newvalue'], BR() 102 ]; 103 } 104 105 $table->addRow([ 106 zbx_date2str(DATE_TIME_FORMAT_SECONDS, $auditlog['clock']), 107 $data['users'][$auditlog['userid']], 108 $auditlog['ip'], 109 array_key_exists($auditlog['resourcetype'], $data['resources']) 110 ? $data['resources'][$auditlog['resourcetype']] 111 : _('Unknown resource'), 112 array_key_exists($auditlog['action'], $data['actions']) 113 ? $data['actions'][$auditlog['action']] 114 : _('Unknown action'), 115 $auditlog['resourceid'], 116 $auditlog['resourcename'], 117 $details ? $details : $auditlog['note'] 118 ]); 119} 120 121$obj = [ 122 'id' => 'timeline_1', 123 'domid' => 'auditlog', 124 'loadSBox' => 0, 125 'loadImage' => 0, 126 'dynamic' => 0 127]; 128 129(new CScriptTag('timeControl.addObject("auditlog", '.json_encode($data['timeline']).', '.json_encode($obj).');'. 130 'timeControl.processObjects();') 131)->show(); 132 133$widget->addItem((new CForm('get')) 134 ->setName('auditForm') 135 ->addItem([$table, $data['paging']]) 136)->show(); 137