Source
xxxxxxxxxx
<?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/>.
**/
/**
* @var CView $this
* @var array $data
*/
// Create form.
$form = (new CForm())
->addItem((new CVar(CSRF_TOKEN_NAME, CCsrfTokenHelper::get('template')))->removeId())
->setId('massupdate-form')
->addVar('action', 'template.massupdate')
->addVar('update', '1')
->addVar('ids', $data['ids'])
->addVar('location_url', $data['location_url'])
->disablePasswordAutofill();
/*
* Template tab
*/
$template_tab = new CFormList('template-form-list');
$template_tab->addRow(
(new CVisibilityBox('visible[linked_templates]', 'linked-templates-field', _('Original')))
->setLabel(_('Link templates'))
->setAttribute('autofocus', 'autofocus'),
(new CDiv([
(new CRadioButtonList('mass_action_tpls', ZBX_ACTION_ADD))
->addValue(_('Link'), ZBX_ACTION_ADD)
->addValue(_('Replace'), ZBX_ACTION_REPLACE)
->addValue(_('Unlink'), ZBX_ACTION_REMOVE)
->setModern(true)
->addStyle('margin-bottom: 5px;'),
(new CMultiSelect([
'name' => 'linked_templates[]',
'object_name' => 'templates',
'data' => [],
'popup' => [
'parameters' => [
'srctbl' => 'templates',
'srcfld1' => 'hostid',
'srcfld2' => 'host',
'dstfrm' => $form->getName(),
'dstfld1' => 'linked_templates_'
]
]
]))
->setWidth(ZBX_TEXTAREA_STANDARD_WIDTH)
->addStyle('margin-bottom: 5px;'),
(new CList())
->addClass(ZBX_STYLE_LIST_CHECK_RADIO)
->addItem(
(new CCheckBox('mass_clear_tpls'))->setLabel(_('Clear when unlinking'))
)
]))->setId('linked-templates-field')
);
$template_tab
->addRow(
(new CVisibilityBox('visible[groups]', 'groups-field', _('Original')))->setLabel(_('Template groups')),
(new CDiv([
(new CRadioButtonList('mass_update_groups', ZBX_ACTION_ADD))
->addValue(_('Add'), ZBX_ACTION_ADD)
->addValue(_('Replace'), ZBX_ACTION_REPLACE)
->addValue(_('Remove'), ZBX_ACTION_REMOVE)
->setModern(true)
->addStyle('margin-bottom: 5px;'),
(new CMultiSelect([
'name' => 'groups[]',
'object_name' => 'templateGroup',
'add_new' => (CWebUser::getType() == USER_TYPE_SUPER_ADMIN),
'data' => [],
'popup' => [
'parameters' => [
'srctbl' => 'template_groups',
'srcfld1' => 'groupid',
'dstfrm' => $form->getName(),