Source
<?php declare(strict_types = 0);
/*
** 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 Affero General Public License as published by the Free Software Foundation, version 3.
**
** 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 Affero General Public License for more details.
**
** You should have received a copy of the GNU Affero General Public License along with this program.
** If not, see <https://www.gnu.org/licenses/>.
**/
class CControllerMenuPopup extends CController {
protected function init() {
$this->disableCsrfValidation();
}
protected function checkInput() {
$fields = [
'type' => 'required|in history,host,item,item_prototype,map_element,trigger,trigger_macro,drule',
'data' => 'array'
];
$ret = $this->validateInput($fields) && $this->validateInputData();
if (!$ret) {
$this->setResponse(
new CControllerResponseData(['main_block' => json_encode([
'error' => [
'messages' => array_column(get_and_clear_messages(), 'message')
]
])])
);
}
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':
$rules = [
'itemid' => 'required|db items.itemid'
];
break;
case 'item':
case 'item_prototype':
$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',
'backurl' => 'required|string',
'eventid' => 'db events.eventid',
'show_update_problem' => 'in 0,1',
'show_rank_change_cause' => 'in 0,1',
'show_rank_change_symptom' => 'in 0,1',
'ids' => 'array_db events.eventid'
];
break;
case 'trigger_macro':