Source
'output' => ['triggerid', 'expression', 'description', 'url_name', 'url', 'status', 'priority', 'comments',
<?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 CTriggerHelper extends CTriggerGeneralHelper {
/**
* @param string $src_templateid
* @param string $dst_templateid
*
* @return bool
*/
public static function cloneTemplateTriggers(string $src_templateid, string $dst_templateid): bool {
$src_options = [
'hostids' => $src_templateid,
'inherited' => false
];
$dst_options = ['templateids' => [$dst_templateid]];
return self::copy($src_options, $dst_options);
}
/**
* @param string $src_hostid
* @param string $dst_hostid
*
* @return bool
*/
public static function cloneHostTriggers(string $src_hostid, string $dst_hostid): bool {
$src_options = [
'hostids' => $src_hostid,
'inherited' => false,
'filter' => ['flags' => ZBX_FLAG_DISCOVERY_NORMAL]
];
$dst_options = ['hostids' => [$dst_hostid]];
return self::copy($src_options, $dst_options);
}
/**
* @param array $src_options
* @param array $dst_options
*
* @return bool
*/
public static function copy(array $src_options, array $dst_options): bool {
$src_triggers = self::getSourceTriggers($src_options);
if (!$src_triggers) {