Welcome to mirror list, hosted at ThFree Co, Russian Federation.

configuration.host.massupdate.php « views « include « php « frontends - github.com/zabbix/zabbix.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 594058e939d20d26df6880921c00753c4739c873 (plain)
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
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
<?php
/*
** Zabbix
** Copyright (C) 2001-2014 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.
**/


require_once dirname(__FILE__).'/js/configuration.host.edit.js.php';

// create form
$hostForm = new CForm();
$hostForm->setName('hostForm');
$hostForm->addVar('go', 'massupdate');
foreach ($this->data['hosts'] as $hostid) {
	$hostForm->addVar('hosts['.$hostid.']', $hostid);
}

// create form list
$hostFormList = new CFormList('hostFormList');

// replace host groups
$hostGroupsToReplace = null;
if (isset($_REQUEST['groups'])) {
	$getHostGroups = API::HostGroup()->get(array(
		'groupids' => $_REQUEST['groups'],
		'output' => array('groupid', 'name'),
		'editable' => true
	));
	foreach ($getHostGroups as $getHostGroup) {
		$hostGroupsToReplace[] = array(
			'id' => $getHostGroup['groupid'],
			'name' => $getHostGroup['name']
		);
	}
}

$replaceGroups = new CMultiSelect(array(
	'name' => 'groups[]',
	'objectName' => 'hostGroup',
	'objectOptions' => array('editable' => true),
	'data' => $hostGroupsToReplace
));

$hostFormList->addRow(
	array(
		_('Replace host groups'),
		SPACE,
		new CVisibilityBox('visible[groups]', isset($this->data['visible']['groups']), 'groups_', _('Original'))
	),
	$replaceGroups
);

// add new or existing host groups
$hostGroupsToAdd = null;
if (isset($_REQUEST['new_groups'])) {
	foreach ($_REQUEST['new_groups'] as $newHostGroup) {
		if (is_array($newHostGroup) && isset($newHostGroup['new'])) {
			$hostGroupsToAdd[] = array(
				'id' => $newHostGroup['new'],
				'name' => $newHostGroup['new'] . ' (new)',
				'isNew' => true
			);
		}
		else {
			$hostGroupIds[] = $newHostGroup;
		}
	}

	if (isset($hostGroupIds)) {
		$getHostGroups = API::HostGroup()->get(array(
			'groupids' => $hostGroupIds,
			'output' => array('groupid', 'name')
		));
		foreach ($getHostGroups as $getHostGroup) {
			$hostGroupsToAdd[] = array(
				'id' => $getHostGroup['groupid'],
				'name' => $getHostGroup['name']
			);
		}
	}
}
if (CWebUser::getType() == USER_TYPE_SUPER_ADMIN) {
	$newGroups = new CMultiSelect(array(
		'name' => 'new_groups[]',
		'objectName' => 'hostGroup',
		'objectOptions' => array('editable' => true),
		'data' => $hostGroupsToAdd,
		'addNew' => true
	));

	$hostFormList->addRow(
		array(
			_('Add new or existing host groups'),
			SPACE,
			new CVisibilityBox('visible[new_groups]', isset($this->data['visible']['new_groups']), 'new_groups_', _('Original'))
		),
		$newGroups
	);
}
else {
	$newGroups = new CMultiSelect(array(
		'name' => 'new_groups[]',
		'objectName' => 'hostGroup',
		'objectOptions' => array('editable' => true),
		'data' => $hostGroupsToAdd
	));

	$hostFormList->addRow(
		array(
			_('New host group'),
			SPACE,
			new CVisibilityBox('visible[new_groups]', isset($this->data['visible']['new_groups']), 'new_groups_', _('Original'))
		),
		$newGroups
	);
}

// append proxy to form list
$proxyComboBox = new CComboBox('proxy_hostid', $this->data['proxy_hostid']);
$proxyComboBox->addItem(0, _('(no proxy)'));
foreach ($this->data['proxies'] as $proxie) {
	$proxyComboBox->addItem($proxie['hostid'], $proxie['host']);
}
$hostFormList->addRow(
	array(
		_('Monitored by proxy'),
		SPACE,
		new CVisibilityBox('visible[proxy_hostid]', isset($this->data['visible']['proxy_hostid']), 'proxy_hostid', _('Original'))
	),
	$proxyComboBox
);

// append status to form list
$statusComboBox = new CComboBox('status', $this->data['status']);
$statusComboBox->addItem(HOST_STATUS_MONITORED, _('Monitored'));
$statusComboBox->addItem(HOST_STATUS_NOT_MONITORED, _('Not monitored'));
$hostFormList->addRow(
	array(
		_('Status'),
		SPACE,
		new CVisibilityBox('visible[status]', isset($this->data['visible']['status']), 'status', _('Original'))
	),
	$statusComboBox
);

$templatesFormList = new CFormList('templatesFormList');
// append templates table to from list
$templatesTable = new CTable(null, 'formElementTable');
$templatesTable->setAttribute('style', 'min-width: 500px;');
$templatesTable->setAttribute('id', 'template_table');

$templatesDiv = new CDiv(
	array(
		$templatesTable,
		new CMultiSelect(array(
			'name' => 'templates[]',
			'objectName' => 'templates',
			'data' => $this->data['linkedTemplates']
		)),
		new CCheckBox('mass_replace_tpls', $this->data['mass_replace_tpls']),
		SPACE,
		_('Replace'),
		BR(),
		new CCheckBox('mass_clear_tpls', $this->data['mass_clear_tpls']),
		SPACE,
		_('Clear when unlinking')
	),
	'objectgroup inlineblock border_dotted ui-corner-all'
);
$templatesDiv->setAttribute('id', 'templates_div');

$templatesFormList->addRow(
	array(
		_('Link templates'),
		SPACE,
		new CVisibilityBox('visible[template_table]', !empty($this->data['visible']['template_table']) ? 'yes' : 'no', 'templates_div', _('Original'))
	),
	$templatesDiv
);

$ipmiFormList = new CFormList('ipmiFormList');
// append ipmi to form list
$ipmiAuthtypeComboBox = new CComboBox('ipmi_authtype', $this->data['ipmi_authtype']);
$ipmiAuthtypeComboBox->addItems(ipmiAuthTypes());
$ipmiFormList->addRow(
	array(
		_('IPMI authentication algorithm'),
		SPACE,
		new CVisibilityBox('visible[ipmi_authtype]', isset($this->data['visible']['ipmi_authtype']), 'ipmi_authtype', _('Original'))
	),
	$ipmiAuthtypeComboBox
);

$ipmiPrivilegeComboBox = new CComboBox('ipmi_privilege', $this->data['ipmi_privilege']);
$ipmiPrivilegeComboBox->addItems(ipmiPrivileges());
$ipmiFormList->addRow(
	array(
		_('IPMI privilege level'),
		SPACE,
		new CVisibilityBox('visible[ipmi_privilege]', isset($this->data['visible']['ipmi_privilege']), 'ipmi_privilege', _('Original'))
	),
	$ipmiPrivilegeComboBox
);

$ipmiFormList->addRow(
	array(
		_('IPMI username'),
		SPACE,
		new CVisibilityBox('visible[ipmi_username]', isset($this->data['visible']['ipmi_username']), 'ipmi_username', _('Original'))
	),
	new CTextBox('ipmi_username', $this->data['ipmi_username'], ZBX_TEXTBOX_SMALL_SIZE)
);

$ipmiFormList->addRow(
	array(
		_('IPMI password'),
		SPACE,
		new CVisibilityBox('visible[ipmi_password]', isset($this->data['visible']['ipmi_password']), 'ipmi_password', _('Original'))
	),
	new CTextBox('ipmi_password', $this->data['ipmi_password'], ZBX_TEXTBOX_SMALL_SIZE)
);

$inventoryFormList = new CFormList('inventoryFormList');
// append inventories to form list
$inventoryModesComboBox = new CComboBox('inventory_mode', $this->data['inventory_mode'], 'submit()');
$inventoryModesComboBox->addItem(HOST_INVENTORY_DISABLED, _('Disabled'));
$inventoryModesComboBox->addItem(HOST_INVENTORY_MANUAL, _('Manual'));
$inventoryModesComboBox->addItem(HOST_INVENTORY_AUTOMATIC, _('Automatic'));
$inventoryFormList->addRow(
	array(
		_('Inventory mode'),
		SPACE,
		new CVisibilityBox('visible[inventory_mode]', isset($this->data['visible']['inventory_mode']), 'inventory_mode', _('Original'))
	),
	$inventoryModesComboBox
);

$hostInventoryTable = DB::getSchema('host_inventory');
if ($this->data['inventory_mode'] != HOST_INVENTORY_DISABLED) {
	foreach ($this->data['inventories'] as $field => $fieldInfo) {
		if (!isset($this->data['host_inventory'][$field])) {
			$this->data['host_inventory'][$field] = '';
		}

		if ($hostInventoryTable['fields'][$field]['type'] == DB::FIELD_TYPE_TEXT) {
			$fieldInput = new CTextArea('host_inventory['.$field.']', $this->data['host_inventory'][$field]);
			$fieldInput->addStyle('width: 64em;');
		}
		else {
			$fieldLength = $hostInventoryTable['fields'][$field]['length'];
			$fieldInput = new CTextBox('host_inventory['.$field.']', $this->data['host_inventory'][$field]);
			$fieldInput->setAttribute('maxlength', $fieldLength);
			$fieldInput->addStyle('width: '.($fieldLength > 64 ? 64 : $fieldLength).'em;');
		}

		$inventoryFormList->addRow(
			array(
				$fieldInfo['title'],
				SPACE,
				new CVisibilityBox(
					'visible['.$field.']',
					isset($this->data['visible'][$field]),
					'host_inventory['.$field.']',
					_('Original')
				)
			),
			$fieldInput
		);
	}
}

// append tabs to form
$hostTab = new CTabView();
// reset the tab when opening the form for the first time
if (!hasRequest('masssave')) {
	$hostTab->setSelected(0);
}
$hostTab->addTab('hostTab', _('Host'), $hostFormList);
$hostTab->addTab('templatesTab', _('Templates'), $templatesFormList);
$hostTab->addTab('ipmiTab', _('IPMI'), $ipmiFormList);
$hostTab->addTab('inventoryTab', _('Inventory'), $inventoryFormList);
$hostForm->addItem($hostTab);

// append buttons to form
$hostForm->addItem(makeFormFooter(new CSubmit('masssave', _('Update')), new CButtonCancel(url_param('groupid'))));

return $hostForm;