1<?php
2/*
3** Zabbix
4** Copyright (C) 2001-2021 Zabbix SIA
5**
6** This program is free software; you can redistribute it and/or modify
7** it under the terms of the GNU General Public License as published by
8** the Free Software Foundation; either version 2 of the License, or
9** (at your option) any later version.
10**
11** This program is distributed in the hope that it will be useful,
12** but WITHOUT ANY WARRANTY; without even the implied warranty of
13** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14** GNU General Public License for more details.
15**
16** You should have received a copy of the GNU General Public License
17** along with this program; if not, write to the Free Software
18** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
19**/
20
21
22/**
23 * @var CView $this
24 */
25
26$this->includeJsFile('administration.autoreg.edit.js.php');
27
28$widget = (new CWidget())
29	->setTitle(_('Autoregistration'))
30	->setTitleSubmenu(getAdministrationGeneralSubmenu());
31
32$autoreg_form = (new CForm())
33	->setId('autoreg-form')
34	->setName('autoreg-form')
35	->setAction((new CUrl('zabbix.php'))
36		->setArgument('action', 'autoreg.edit')
37		->getUrl()
38	)
39	->setAttribute('aria-labeledby', ZBX_STYLE_PAGE_TITLE)
40	->addVar('tls_accept', $data['tls_accept']);
41
42$autoreg_tab = (new CFormList())
43	->addRow(_('Encryption level'),
44		(new CList())
45			->addClass(ZBX_STYLE_LIST_CHECK_RADIO)
46			->addItem((new CCheckBox('tls_in_none'))
47				->setAttribute('autofocus', 'autofocus')
48				->setLabel(_('No encryption'))
49			)
50			->addItem((new CCheckBox('tls_in_psk'))->setLabel(_('PSK')))
51	);
52
53if ($data['change_psk']) {
54	$autoreg_tab
55		->addRow(
56			(new CLabel(_('PSK identity'), 'tls_psk_identity'))->setAsteriskMark(),
57			(new CTextBox('tls_psk_identity', $data['tls_psk_identity'], false,
58				DB::getFieldLength('config_autoreg_tls', 'tls_psk_identity')
59			))
60				->setWidth(ZBX_TEXTAREA_BIG_WIDTH)
61				->setAriaRequired()
62				->disableAutocomplete(),
63			null,
64			'tls_psk'
65		)
66		->addRow(
67			(new CLabel(_('PSK'), 'tls_psk'))->setAsteriskMark(),
68			(new CTextBox('tls_psk', $data['tls_psk'], false, DB::getFieldLength('config_autoreg_tls', 'tls_psk')))
69				->setWidth(ZBX_TEXTAREA_BIG_WIDTH)
70				->setAriaRequired()
71				->disableAutocomplete(),
72			null,
73			'tls_psk'
74		);
75}
76else {
77	$autoreg_tab
78		->addRow(
79			(new CLabel(_('PSK')))->setAsteriskMark(),
80			(new CSimpleButton(_('Change PSK')))
81				->onClick('javascript: submitFormWithParam("'.$autoreg_form->getName().'", "change_psk", "1");')
82				->addClass(ZBX_STYLE_BTN_GREY),
83			null,
84			'tls_psk'
85		);
86}
87
88$autoreg_view = (new CTabView())
89	->addTab('autoreg', _('Autoregistration'), $autoreg_tab)
90	->setFooter(makeFormFooter((new CSubmitButton(_('Update'), 'action', 'autoreg.update'))->setId('update')));
91
92$autoreg_form->addItem($autoreg_view);
93
94$widget
95	->addItem($autoreg_form)
96	->show();
97