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/>.
**/
require_once __DIR__ .'/../../include/forms.inc.php';
class CControllerTriggerEdit extends CController {
/**
* @var array
*/
private $trigger;
protected function init(): void {
$this->disableCsrfValidation();
}
protected function checkInput(): bool {
$fields = [
'context' => 'in '.implode(',', ['host', 'template']),
'correlation_mode' => 'db triggers.correlation_mode|in '.implode(',', [ZBX_TRIGGER_CORRELATION_NONE, ZBX_TRIGGER_CORRELATION_TAG]),
'correlation_tag' => 'db triggers.correlation_tag',
'dependencies' => 'array',
'description' => 'db triggers.comments',
'event_name' => 'db triggers.event_name',
'expression' => 'string',
'hostid' => 'db hosts.hostid',
'manual_close' => 'db triggers.manual_close|in '.implode(',',[ZBX_TRIGGER_MANUAL_CLOSE_NOT_ALLOWED, ZBX_TRIGGER_MANUAL_CLOSE_ALLOWED]),
'name' => 'string',
'opdata' => 'db triggers.opdata',
'priority' => 'db triggers.priority|in 0,1,2,3,4,5',
'recovery_expression' => 'string',
'recovery_mode' => 'db triggers.recovery_mode|in '.implode(',', [ZBX_RECOVERY_MODE_EXPRESSION, ZBX_RECOVERY_MODE_RECOVERY_EXPRESSION, ZBX_RECOVERY_MODE_NONE]),
'status' => 'db triggers.status|in '.implode(',', [TRIGGER_STATUS_ENABLED, TRIGGER_STATUS_DISABLED]),
'show_inherited_tags' => 'in 0,1',
'form_refresh' => 'in 0,1',
'tags' => 'array',
'triggerid' => 'db triggers.triggerid',
'type' => 'db triggers.type|in 0,1',
'url' => 'db triggers.url',
'url_name' => 'db triggers.url_name'
];
$ret = $this->validateInput($fields);
if (!$ret) {
$this->setResponse(
(new CControllerResponseData(['main_block' => json_encode([
'error' => [
'messages' => array_column(get_and_clear_messages(), 'message')
]
])]))->disableView()