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 22class CControllerWidgetTrigOverView extends CControllerWidget { 23 24 public function __construct() { 25 parent::__construct(); 26 27 $this->setType(WIDGET_TRIG_OVER); 28 $this->setValidationRules([ 29 'name' => 'string', 30 'fields' => 'json', 31 'initial_load' => 'in 0,1' 32 ]); 33 } 34 35 protected function doAction() { 36 $fields = $this->getForm()->getFieldsData(); 37 38 $data = [ 39 'name' => $this->getInput('name', $this->getDefaultHeader()), 40 'initial_load' => (bool) $this->getInput('initial_load', 0), 41 'style' => $fields['style'], 42 'user' => [ 43 'debug_mode' => $this->getDebugMode() 44 ] 45 ]; 46 47 $trigger_options = [ 48 'skipDependent' => ($fields['show'] == TRIGGERS_OPTION_ALL) ? null : true, 49 'only_true' => ($fields['show'] == TRIGGERS_OPTION_RECENT_PROBLEM) ? true : null, 50 'filter' => [ 51 'value' => ($fields['show'] == TRIGGERS_OPTION_IN_PROBLEM) ? TRIGGER_VALUE_TRUE : null 52 ] 53 ]; 54 55 $problem_options = [ 56 'show_suppressed' => $fields['show_suppressed'], 57 'show_recent' => ($fields['show'] == TRIGGERS_OPTION_RECENT_PROBLEM) ? true : null 58 ]; 59 60 $host_options = [ 61 'hostids' => $fields['hostids'] ? $fields['hostids'] : null 62 ]; 63 64 [$data['db_hosts'], $data['db_triggers'], $data['dependencies'], $data['triggers_by_name'], 65 $data['hosts_by_name'], $data['exceeded_limit'] 66 ] = getTriggersOverviewData(getSubGroups($fields['groupids']), $fields['application'], $host_options, 67 $trigger_options, $problem_options 68 ); 69 70 $this->setResponse(new CControllerResponseData($data)); 71 } 72} 73