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 22function get_last_event_by_triggerid($triggerId) { 23 $dbEvents = DBfetch(DBselect( 24 'SELECT e.*'. 25 ' FROM events e'. 26 ' WHERE e.objectid='.zbx_dbstr($triggerId). 27 ' AND e.source='.EVENT_SOURCE_TRIGGERS. 28 ' AND e.object='.EVENT_OBJECT_TRIGGER. 29 ' ORDER BY e.objectid DESC,e.object DESC,e.eventid DESC', 30 1 31 )); 32 33 return $dbEvents ? $dbEvents : false; 34} 35 36/** 37 * Get acknowledgement table. 38 * 39 * @param array $acknowledges 40 * @param array $acknowledges['clock'] 41 * @param array $acknowledges['alias'] 42 * @param array $acknowledges['name'] 43 * @param array $acknowledges['surname'] 44 * @param array $acknowledges['message'] 45 * 46 * @return CTableInfo 47 */ 48function makeAckTab($acknowledges) { 49 $table = (new CTableInfo())->setHeader([_('Time'), _('User'), _('Message')]); 50 51 foreach ($acknowledges as $acknowledge) { 52 $table->addRow([ 53 zbx_date2str(DATE_TIME_FORMAT_SECONDS, $acknowledge['clock']), 54 array_key_exists('alias', $acknowledge) 55 ? getUserFullname($acknowledge) 56 : _('Inaccessible user'), 57 zbx_nl2br($acknowledge['message']) 58 ]); 59 } 60 61 return $table; 62} 63