1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147
|
<?php
/*
** Zabbix
** Copyright (C) 2001-2019 Zabbix SIA
**
** This program is free software; you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation; either version 2 of the License, or
** (at your option) any later version.
**
** 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 General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program; if not, write to the Free Software
** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
**/
$this->addJsFile('multiselect.js');
$this->includeJSfile('app/views/administration.script.edit.js.php');
$widget = (new CWidget())->setTitle(_('Scripts'));
$scriptForm = (new CForm())
->setId('scriptForm')
->setName('scripts')
->setAttribute('aria-labeledby', ZBX_STYLE_PAGE_TITLE)
->addVar('form', 1)
->addVar('scriptid', $data['scriptid']);
$scriptFormList = (new CFormList())
->addRow((new CLabel(_('Name'), 'name'))->setAsteriskMark(),
(new CTextBox('name', $data['name']))
->setWidth(ZBX_TEXTAREA_STANDARD_WIDTH)
->setAttribute('autofocus', 'autofocus')
->setAttribute('placeholder', _('<sub-menu/sub-menu/...>script'))
->setAriaRequired()
)
->addRow((new CLabel(_('Type'), 'type')),
(new CRadioButtonList('type', (int) $data['type']))
->addValue(_('IPMI'), ZBX_SCRIPT_TYPE_IPMI)
->addValue(_('Script'), ZBX_SCRIPT_TYPE_CUSTOM_SCRIPT)
->setModern(true)
)
->addRow((new CLabel(_('Execute on'), 'execute_on')),
(new CRadioButtonList('execute_on', (int) $data['execute_on']))
->addValue(_('Zabbix agent'), ZBX_SCRIPT_EXECUTE_ON_AGENT)
->addValue(_('Zabbix server (proxy)'), ZBX_SCRIPT_EXECUTE_ON_PROXY)
->addValue(_('Zabbix server'), ZBX_SCRIPT_EXECUTE_ON_SERVER)
->setModern(true)
)
->addRow((new CLabel(_('Commands'), 'command'))->setAsteriskMark(),
(new CTextArea('command', $data['command']))
->setWidth(ZBX_TEXTAREA_STANDARD_WIDTH)
->setMaxLength(255)
->setAriaRequired()
)
->addRow((new CLabel(_('Command'), 'commandipmi'))->setAsteriskMark(),
(new CTextBox('commandipmi', $data['commandipmi']))
->setWidth(ZBX_TEXTAREA_STANDARD_WIDTH)
->setAriaRequired()
)
->addRow(_('Description'),
(new CTextArea('description', $data['description']))->setWidth(ZBX_TEXTAREA_STANDARD_WIDTH)
);
$user_groups = [0 => _('All')];
foreach ($data['usergroups'] as $user_group) {
$user_groups[$user_group['usrgrpid']] = $user_group['name'];
}
$scriptFormList
->addRow(_('User group'),
new CComboBox('usrgrpid', $data['usrgrpid'], null, $user_groups))
->addRow(_('Host group'),
new CComboBox('hgstype', $data['hgstype'], null, [
0 => _('All'),
1 => _('Selected')
])
)
->addRow(null, (new CMultiSelect([
'name' => 'groupid',
'object_name' => 'hostGroup',
'multiple' => false,
'data' => $data['hostgroup'],
'popup' => [
'parameters' => [
'srctbl' => 'host_groups',
'srcfld1' => 'groupid',
'dstfrm' => $scriptForm->getName(),
'dstfld1' => 'groupid'
]
]
]))->setWidth(ZBX_TEXTAREA_STANDARD_WIDTH), 'hostGroupSelection')
->addRow((new CLabel(_('Required host permissions'), 'host_access')),
(new CRadioButtonList('host_access', (int) $data['host_access']))
->addValue(_('Read'), PERM_READ)
->addValue(_('Write'), PERM_READ_WRITE)
->setModern(true)
)
->addRow(_('Enable confirmation'),
(new CCheckBox('enable_confirmation'))->setChecked($data['enable_confirmation'] == 1)
);
$scriptFormList->addRow(new CLabel(_('Confirmation text'), 'confirmation'), [
(new CTextBox('confirmation', $data['confirmation']))->setWidth(ZBX_TEXTAREA_STANDARD_WIDTH),
SPACE,
(new CButton('testConfirmation', _('Test confirmation')))->addClass(ZBX_STYLE_BTN_GREY)
]);
$scriptView = (new CTabView())->addTab('scripts', _('Script'), $scriptFormList);
// footer
$cancelButton = (new CRedirectButton(_('Cancel'), 'zabbix.php?action=script.list'))->setId('cancel');
if ($data['scriptid'] == 0) {
$addButton = (new CSubmitButton(_('Add'), 'action', 'script.create'))->setId('add');
$scriptView->setFooter(makeFormFooter(
$addButton,
[$cancelButton]
));
}
else {
$updateButton = (new CSubmitButton(_('Update'), 'action', 'script.update'))->setId('update');
$cloneButton = (new CSimpleButton(_('Clone')))->setId('clone');
$deleteButton = (new CRedirectButton(_('Delete'),
'zabbix.php?action=script.delete&sid='.$data['sid'].'&scriptids[]='.$data['scriptid'],
_('Delete script?')
))
->setId('delete');
$scriptView->setFooter(makeFormFooter(
$updateButton,
[
$cloneButton,
$deleteButton,
$cancelButton
]
));
}
$scriptForm->addItem($scriptView);
$widget->addItem($scriptForm)->show();
|