Source
xxxxxxxxxx
<?php
/*
** Zabbix
** Copyright (C) 2001-2025 Zabbix SIA
**
** This program is free software; you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation; either version 2 of the License, or
** (at your option) any later version.
**
** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program; if not, write to the Free Software
** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
**/
class CControllerMenuPopup extends CController {
protected function checkInput() {
$fields = [
'type' => 'required|in history,host,item,item_configuration,item_prototype_configuration,map_element,trigger,trigger_macro',
'data' => 'array'
];
$ret = $this->validateInput($fields) && $this->validateInputData();
if (!$ret) {
$output = [];
if (($messages = getMessages()) !== null) {
$output['errors'] = $messages->toString();
}
$this->setResponse(new CControllerResponseData(['main_block' => json_encode($output)]));
}
return $ret;
}
protected function validateInputData(): bool {
$type = $this->getInput('type');
switch ($type) {
case 'host':
$rules = [
'hostid' => 'required|db hosts.hostid',
'has_goto' => 'in 0'
];
break;
case 'history':
case 'item':
$rules = [
'itemid' => 'required|db items.itemid'
];
break;
case 'item_configuration':
case 'item_prototype_configuration':
$rules = [
'itemid' => 'required|db items.itemid',
'backurl' => 'required|string'
];
break;
case 'map_element':
$rules = [
'sysmapid' => 'required|db sysmaps.sysmapid',
'selementid' => 'required|db sysmaps_elements.selementid',
'unique_id' => 'string',
'severity_min' => 'in '.implode(',', [TRIGGER_SEVERITY_NOT_CLASSIFIED, TRIGGER_SEVERITY_INFORMATION, TRIGGER_SEVERITY_WARNING, TRIGGER_SEVERITY_AVERAGE, TRIGGER_SEVERITY_HIGH, TRIGGER_SEVERITY_DISASTER]),
'hostid' => 'db hosts.hostid'
];
break;
case 'trigger':
$rules = [
'triggerid' => 'required|db triggers.triggerid',
'eventid' => 'db events.eventid',
'acknowledge' => 'in 0,1'
];
break;
case 'trigger_macro':
$rules = [];
break;
}