Source
? makeWarningIcon(_('Global script execution on Zabbix server is disabled by server configuration.'))
<?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
*/
$form = (new CForm())
->addItem((new CVar(CSRF_TOKEN_NAME, CCsrfTokenHelper::get('script')))->removeId())
->setId('script-form')
->setName('scripts')
->addVar('scriptid', $data['scriptid'])
->addItem((new CInput('submit', null))->addStyle('display: none;'));
$parameters_table = (new CTable())
->setId('parameters-table')
->setHeader([
(new CColHeader(_('Name')))->setWidth('50%'),
(new CColHeader(_('Value')))->setWidth('50%'),
_('Action')
])
->setAttribute('style', 'width: 100%;')
->addItem(
(new CTag('tfoot', true))
->addItem(
(new CCol(
(new CButtonLink(_('Add')))->addClass('js-parameter-add')
))->setColSpan(2)
)
);
$row_template = (new CTemplateTag('script-parameter-template'))
->addItem(
(new CRow([
(new CTextBox('parameters[name][]', '', false, DB::getFieldLength('script_param', 'name')))
->setAttribute('style', 'width: 100%;')
->setAttribute('value', '#{name}')
->removeId(),
(new CTextBox('parameters[value][]', '', false, DB::getFieldLength('script_param', 'value')))
->setAttribute('style', 'width: 100%;')
->setAttribute('value', '#{value}')
->removeId(),
(new CButtonLink(_('Remove')))->addClass('js-remove')
]))->addClass('form_row')
);
$form_grid = (new CFormGrid())
->addItem([
(new CLabel(_('Name'), 'name'))
->setAsteriskMark(),
(new CFormField(
(new CTextBox('name', $data['name'], false, DB::getFieldLength('scripts', 'name')))
->setWidth(ZBX_TEXTAREA_STANDARD_WIDTH)
->setAriaRequired()
))
])
->addItem([
new CLabel(_('Scope'), 'scope'),
new CFormField(
(new CRadioButtonList('scope', (int) $data['scope']))
->addValue(_('Action operation'), ZBX_SCRIPT_SCOPE_ACTION)
->addValue(_('Manual host action'), ZBX_SCRIPT_SCOPE_HOST)
->addValue(_('Manual event action'), ZBX_SCRIPT_SCOPE_EVENT)
->setModern()
->setEnabled(!$data['actions'])
)
])
->addItem([
(new CLabel(_('Menu path'), 'menu_path'))->setId('menu-path-label'),
(new CFormField(
(new CTextBox('menu_path', $data['menu_path'], false, DB::getFieldLength('scripts', 'menu_path')))
->setWidth(ZBX_TEXTAREA_STANDARD_WIDTH)
->setAttribute('placeholder', _('<sub-menu/sub-menu/...>'))
))->setId('menu-path')
])
->addItem([
(new CLabel(_('Type'), 'type')),