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 * Validate import data from Zabbix 5.4.x.
24 */
25class C54XmlValidator extends CXmlValidatorGeneral {
26
27	private $PREPROCESSING_STEP_TYPE = [
28		CXmlConstantValue::MULTIPLIER => CXmlConstantName::MULTIPLIER,
29		CXmlConstantValue::RTRIM => CXmlConstantName::RTRIM,
30		CXmlConstantValue::LTRIM => CXmlConstantName::LTRIM,
31		CXmlConstantValue::TRIM => CXmlConstantName::TRIM,
32		CXmlConstantValue::REGEX => CXmlConstantName::REGEX,
33		CXmlConstantValue::BOOL_TO_DECIMAL => CXmlConstantName::BOOL_TO_DECIMAL,
34		CXmlConstantValue::OCTAL_TO_DECIMAL => CXmlConstantName::OCTAL_TO_DECIMAL,
35		CXmlConstantValue::HEX_TO_DECIMAL => CXmlConstantName::HEX_TO_DECIMAL,
36		CXmlConstantValue::SIMPLE_CHANGE => CXmlConstantName::SIMPLE_CHANGE,
37		CXmlConstantValue::CHANGE_PER_SECOND => CXmlConstantName::CHANGE_PER_SECOND,
38		CXmlConstantValue::XMLPATH => CXmlConstantName::XMLPATH,
39		CXmlConstantValue::JSONPATH => CXmlConstantName::JSONPATH,
40		CXmlConstantValue::IN_RANGE => CXmlConstantName::IN_RANGE,
41		CXmlConstantValue::MATCHES_REGEX => CXmlConstantName::MATCHES_REGEX,
42		CXmlConstantValue::NOT_MATCHES_REGEX => CXmlConstantName::NOT_MATCHES_REGEX,
43		CXmlConstantValue::CHECK_JSON_ERROR => CXmlConstantName::CHECK_JSON_ERROR,
44		CXmlConstantValue::CHECK_XML_ERROR => CXmlConstantName::CHECK_XML_ERROR,
45		CXmlConstantValue::CHECK_REGEX_ERROR => CXmlConstantName::CHECK_REGEX_ERROR,
46		CXmlConstantValue::CHECK_NOT_SUPPORTED => CXmlConstantName::CHECK_NOT_SUPPORTED,
47		CXmlConstantValue::DISCARD_UNCHANGED => CXmlConstantName::DISCARD_UNCHANGED,
48		CXmlConstantValue::DISCARD_UNCHANGED_HEARTBEAT => CXmlConstantName::DISCARD_UNCHANGED_HEARTBEAT,
49		CXmlConstantValue::JAVASCRIPT => CXmlConstantName::JAVASCRIPT,
50		CXmlConstantValue::PROMETHEUS_PATTERN => CXmlConstantName::PROMETHEUS_PATTERN,
51		CXmlConstantValue::PROMETHEUS_TO_JSON => CXmlConstantName::PROMETHEUS_TO_JSON,
52		CXmlConstantValue::CSV_TO_JSON => CXmlConstantName::CSV_TO_JSON,
53		CXmlConstantValue::STR_REPLACE => CXmlConstantName::STR_REPLACE,
54		CXmlConstantValue::XML_TO_JSON => CXmlConstantName::XML_TO_JSON
55	];
56
57	private $PREPROCESSING_STEP_TYPE_DRULE = [
58		CXmlConstantValue::REGEX => CXmlConstantName::REGEX,
59		CXmlConstantValue::XMLPATH => CXmlConstantName::XMLPATH,
60		CXmlConstantValue::JSONPATH => CXmlConstantName::JSONPATH,
61		CXmlConstantValue::NOT_MATCHES_REGEX => CXmlConstantName::NOT_MATCHES_REGEX,
62		CXmlConstantValue::CHECK_JSON_ERROR => CXmlConstantName::CHECK_JSON_ERROR,
63		CXmlConstantValue::CHECK_XML_ERROR => CXmlConstantName::CHECK_XML_ERROR,
64		CXmlConstantValue::DISCARD_UNCHANGED_HEARTBEAT => CXmlConstantName::DISCARD_UNCHANGED_HEARTBEAT,
65		CXmlConstantValue::JAVASCRIPT => CXmlConstantName::JAVASCRIPT,
66		CXmlConstantValue::PROMETHEUS_TO_JSON => CXmlConstantName::PROMETHEUS_TO_JSON,
67		CXmlConstantValue::CSV_TO_JSON => CXmlConstantName::CSV_TO_JSON,
68		CXmlConstantValue::STR_REPLACE => CXmlConstantName::STR_REPLACE,
69		CXmlConstantValue::XML_TO_JSON => CXmlConstantName::XML_TO_JSON
70	];
71
72	private $GRAPH_GRAPH_ITEM_CALC_FNC = [
73		CXmlConstantValue::MIN => CXmlConstantName::MIN,
74		CXmlConstantValue::AVG => CXmlConstantName::AVG,
75		CXmlConstantValue::MAX => CXmlConstantName::MAX,
76		CXmlConstantValue::ALL => CXmlConstantName::ALL,
77		CXmlConstantValue::LAST => CXmlConstantName::LAST
78	];
79
80	private $GRAPH_GRAPH_ITEM_DRAWTYPE = [
81		CXmlConstantValue::SINGLE_LINE => CXmlConstantName::SINGLE_LINE,
82		CXmlConstantValue::FILLED_REGION => CXmlConstantName::FILLED_REGION,
83		CXmlConstantValue::BOLD_LINE => CXmlConstantName::BOLD_LINE,
84		CXmlConstantValue::DOTTED_LINE => CXmlConstantName::DOTTED_LINE,
85		CXmlConstantValue::DASHED_LINE => CXmlConstantName::DASHED_LINE,
86		CXmlConstantValue::GRADIENT_LINE => CXmlConstantName::GRADIENT_LINE
87	];
88
89	private $GRAPH_TYPE = [
90		CXmlConstantValue::NORMAL => CXmlConstantName::NORMAL,
91		CXmlConstantValue::STACKED => CXmlConstantName::STACKED,
92		CXmlConstantValue::PIE => CXmlConstantName::PIE,
93		CXmlConstantValue::EXPLODED => CXmlConstantName::EXPLODED
94	];
95
96	private $GRAPH_Y_TYPE = [
97		CXmlConstantValue::CALCULATED => CXmlConstantName::CALCULATED,
98		CXmlConstantValue::FIXED => CXmlConstantName::FIXED,
99		CXmlConstantValue::ITEM => CXmlConstantName::ITEM
100	];
101
102	private $GRAPH_GRAPH_ITEM_YAXISSIDE = [
103		CXmlConstantValue::LEFT => CXmlConstantName::LEFT,
104		CXmlConstantValue::RIGHT => CXmlConstantName::RIGHT
105	];
106
107	private $GRAPH_GRAPH_ITEM_TYPE = [
108		CXmlConstantValue::SIMPLE => CXmlConstantName::SIMPLE,
109		CXmlConstantValue::GRAPH_SUM => CXmlConstantName::GRAPH_SUM
110	];
111
112	private $ITEM_INVENTORY_LINK = [
113		CXmlConstantValue::NONE => CXmlConstantName::NONE,
114		CXmlConstantValue::ALIAS => CXmlConstantName::ALIAS,
115		CXmlConstantValue::ASSET_TAG => CXmlConstantName::ASSET_TAG,
116		CXmlConstantValue::CHASSIS => CXmlConstantName::CHASSIS,
117		CXmlConstantValue::CONTACT => CXmlConstantName::CONTACT,
118		CXmlConstantValue::CONTRACT_NUMBER => CXmlConstantName::CONTRACT_NUMBER,
119		CXmlConstantValue::DATE_HW_DECOMM => CXmlConstantName::DATE_HW_DECOMM,
120		CXmlConstantValue::DATE_HW_EXPIRY => CXmlConstantName::DATE_HW_EXPIRY,
121		CXmlConstantValue::DATE_HW_INSTALL => CXmlConstantName::DATE_HW_INSTALL,
122		CXmlConstantValue::DATE_HW_PURCHASE => CXmlConstantName::DATE_HW_PURCHASE,
123		CXmlConstantValue::DEPLOYMENT_STATUS => CXmlConstantName::DEPLOYMENT_STATUS,
124		CXmlConstantValue::HARDWARE => CXmlConstantName::HARDWARE,
125		CXmlConstantValue::HARDWARE_FULL => CXmlConstantName::HARDWARE_FULL,
126		CXmlConstantValue::HOST_NETMASK => CXmlConstantName::HOST_NETMASK,
127		CXmlConstantValue::HOST_NETWORKS => CXmlConstantName::HOST_NETWORKS,
128		CXmlConstantValue::HOST_ROUTER => CXmlConstantName::HOST_ROUTER,
129		CXmlConstantValue::HW_ARCH => CXmlConstantName::HW_ARCH,
130		CXmlConstantValue::INSTALLER_NAME => CXmlConstantName::INSTALLER_NAME,
131		CXmlConstantValue::LOCATION => CXmlConstantName::LOCATION,
132		CXmlConstantValue::LOCATION_LAT => CXmlConstantName::LOCATION_LAT,
133		CXmlConstantValue::LOCATION_LON => CXmlConstantName::LOCATION_LON,
134		CXmlConstantValue::MACADDRESS_A => CXmlConstantName::MACADDRESS_A,
135		CXmlConstantValue::MACADDRESS_B => CXmlConstantName::MACADDRESS_B,
136		CXmlConstantValue::MODEL => CXmlConstantName::MODEL,
137		CXmlConstantValue::NAME => CXmlConstantName::NAME,
138		CXmlConstantValue::NOTES => CXmlConstantName::NOTES,
139		CXmlConstantValue::OOB_IP => CXmlConstantName::OOB_IP,
140		CXmlConstantValue::OOB_NETMASK => CXmlConstantName::OOB_NETMASK,
141		CXmlConstantValue::OOB_ROUTER => CXmlConstantName::OOB_ROUTER,
142		CXmlConstantValue::OS => CXmlConstantName::OS,
143		CXmlConstantValue::OS_FULL => CXmlConstantName::OS_FULL,
144		CXmlConstantValue::OS_SHORT => CXmlConstantName::OS_SHORT,
145		CXmlConstantValue::POC_1_CELL => CXmlConstantName::POC_1_CELL,
146		CXmlConstantValue::POC_1_EMAIL => CXmlConstantName::POC_1_EMAIL,
147		CXmlConstantValue::POC_1_NAME => CXmlConstantName::POC_1_NAME,
148		CXmlConstantValue::POC_1_NOTES => CXmlConstantName::POC_1_NOTES,
149		CXmlConstantValue::POC_1_PHONE_A => CXmlConstantName::POC_1_PHONE_A,
150		CXmlConstantValue::POC_1_PHONE_B => CXmlConstantName::POC_1_PHONE_B,
151		CXmlConstantValue::POC_1_SCREEN => CXmlConstantName::POC_1_SCREEN,
152		CXmlConstantValue::POC_2_CELL => CXmlConstantName::POC_2_CELL,
153		CXmlConstantValue::POC_2_EMAIL => CXmlConstantName::POC_2_EMAIL,
154		CXmlConstantValue::POC_2_NAME => CXmlConstantName::POC_2_NAME,
155		CXmlConstantValue::POC_2_NOTES => CXmlConstantName::POC_2_NOTES,
156		CXmlConstantValue::POC_2_PHONE_A => CXmlConstantName::POC_2_PHONE_A,
157		CXmlConstantValue::POC_2_PHONE_B => CXmlConstantName::POC_2_PHONE_B,
158		CXmlConstantValue::POC_2_SCREEN => CXmlConstantName::POC_2_SCREEN,
159		CXmlConstantValue::SERIALNO_A => CXmlConstantName::SERIALNO_A,
160		CXmlConstantValue::SERIALNO_B => CXmlConstantName::SERIALNO_B,
161		CXmlConstantValue::SITE_ADDRESS_A => CXmlConstantName::SITE_ADDRESS_A,
162		CXmlConstantValue::SITE_ADDRESS_B => CXmlConstantName::SITE_ADDRESS_B,
163		CXmlConstantValue::SITE_ADDRESS_C => CXmlConstantName::SITE_ADDRESS_C,
164		CXmlConstantValue::SITE_CITY => CXmlConstantName::SITE_CITY,
165		CXmlConstantValue::SITE_COUNTRY => CXmlConstantName::SITE_COUNTRY,
166		CXmlConstantValue::SITE_NOTES => CXmlConstantName::SITE_NOTES,
167		CXmlConstantValue::SITE_RACK => CXmlConstantName::SITE_RACK,
168		CXmlConstantValue::SITE_STATE => CXmlConstantName::SITE_STATE,
169		CXmlConstantValue::SITE_ZIP => CXmlConstantName::SITE_ZIP,
170		CXmlConstantValue::SOFTWARE => CXmlConstantName::SOFTWARE,
171		CXmlConstantValue::SOFTWARE_APP_A => CXmlConstantName::SOFTWARE_APP_A,
172		CXmlConstantValue::SOFTWARE_APP_B => CXmlConstantName::SOFTWARE_APP_B,
173		CXmlConstantValue::SOFTWARE_APP_C => CXmlConstantName::SOFTWARE_APP_C,
174		CXmlConstantValue::SOFTWARE_APP_D => CXmlConstantName::SOFTWARE_APP_D,
175		CXmlConstantValue::SOFTWARE_APP_E => CXmlConstantName::SOFTWARE_APP_E,
176		CXmlConstantValue::SOFTWARE_FULL => CXmlConstantName::SOFTWARE_FULL,
177		CXmlConstantValue::TAG => CXmlConstantName::TAG,
178		CXmlConstantValue::TYPE => CXmlConstantName::TYPE,
179		CXmlConstantValue::TYPE_FULL => CXmlConstantName::TYPE_FULL,
180		CXmlConstantValue::URL_A => CXmlConstantName::URL_A,
181		CXmlConstantValue::URL_B => CXmlConstantName::URL_B,
182		CXmlConstantValue::URL_C => CXmlConstantName::URL_C,
183		CXmlConstantValue::VENDOR => CXmlConstantName::VENDOR
184	];
185
186	private $ITEM_POST_TYPE = [
187		CXmlConstantValue::RAW => CXmlConstantName::RAW,
188		CXmlConstantValue::JSON => CXmlConstantName::JSON,
189		CXmlConstantValue::XML => CXmlConstantName::XML
190	];
191
192	private $ITEM_PREPROCESSING_ERROR_HANDLER = [
193		CXmlConstantValue::ORIGINAL_ERROR => CXmlConstantName::ORIGINAL_ERROR,
194		CXmlConstantValue::DISCARD_VALUE => CXmlConstantName::DISCARD_VALUE,
195		CXmlConstantValue::CUSTOM_VALUE => CXmlConstantName::CUSTOM_VALUE,
196		CXmlConstantValue::CUSTOM_ERROR => CXmlConstantName::CUSTOM_ERROR
197	];
198
199	private $ITEM_REQUEST_METHOD = [
200		CXmlConstantValue::GET => CXmlConstantName::GET,
201		CXmlConstantValue::POST => CXmlConstantName::POST,
202		CXmlConstantValue::PUT => CXmlConstantName::PUT,
203		CXmlConstantValue::HEAD => CXmlConstantName::HEAD
204	];
205
206	private $ITEM_RETRIEVE_MODE = [
207		CXmlConstantValue::BODY => CXmlConstantName::BODY,
208		CXmlConstantValue::HEADERS => CXmlConstantName::HEADERS,
209		CXmlConstantValue::BOTH => CXmlConstantName::BOTH
210	];
211
212	private $ITEM_SNMPV3_SECURITYLEVEL = [
213		CXmlConstantValue::NOAUTHNOPRIV => CXmlConstantName::NOAUTHNOPRIV,
214		CXmlConstantValue::AUTHNOPRIV => CXmlConstantName::AUTHNOPRIV,
215		CXmlConstantValue::AUTHPRIV => CXmlConstantName::AUTHPRIV
216	];
217
218	private $ITEM_TYPE = [
219		CXmlConstantValue::ITEM_TYPE_ZABBIX_PASSIVE => CXmlConstantName::ZABBIX_PASSIVE,
220		CXmlConstantValue::ITEM_TYPE_TRAP => CXmlConstantName::TRAP,
221		CXmlConstantValue::ITEM_TYPE_SIMPLE => CXmlConstantName::SIMPLE,
222		CXmlConstantValue::ITEM_TYPE_INTERNAL => CXmlConstantName::INTERNAL,
223		CXmlConstantValue::ITEM_TYPE_ZABBIX_ACTIVE => CXmlConstantName::ZABBIX_ACTIVE,
224		CXmlConstantValue::ITEM_TYPE_EXTERNAL => CXmlConstantName::EXTERNAL,
225		CXmlConstantValue::ITEM_TYPE_ODBC => CXmlConstantName::ODBC,
226		CXmlConstantValue::ITEM_TYPE_IPMI => CXmlConstantName::IPMI,
227		CXmlConstantValue::ITEM_TYPE_SSH => CXmlConstantName::SSH,
228		CXmlConstantValue::ITEM_TYPE_TELNET => CXmlConstantName::TELNET,
229		CXmlConstantValue::ITEM_TYPE_CALCULATED => CXmlConstantName::CALCULATED,
230		CXmlConstantValue::ITEM_TYPE_JMX => CXmlConstantName::JMX,
231		CXmlConstantValue::ITEM_TYPE_SNMP_TRAP => CXmlConstantName::SNMP_TRAP,
232		CXmlConstantValue::ITEM_TYPE_DEPENDENT => CXmlConstantName::DEPENDENT,
233		CXmlConstantValue::ITEM_TYPE_HTTP_AGENT => CXmlConstantName::HTTP_AGENT,
234		CXmlConstantValue::ITEM_TYPE_SNMP => CXmlConstantName::SNMP_AGENT,
235		CXmlConstantValue::ITEM_TYPE_SCRIPT => CXmlConstantName::SCRIPT
236	];
237
238	private $ITEM_TYPE_DRULE = [
239		CXmlConstantValue::ITEM_TYPE_ZABBIX_PASSIVE => CXmlConstantName::ZABBIX_PASSIVE,
240		CXmlConstantValue::ITEM_TYPE_TRAP => CXmlConstantName::TRAP,
241		CXmlConstantValue::ITEM_TYPE_SIMPLE => CXmlConstantName::SIMPLE,
242		CXmlConstantValue::ITEM_TYPE_INTERNAL => CXmlConstantName::INTERNAL,
243		CXmlConstantValue::ITEM_TYPE_ZABBIX_ACTIVE => CXmlConstantName::ZABBIX_ACTIVE,
244		CXmlConstantValue::ITEM_TYPE_EXTERNAL => CXmlConstantName::EXTERNAL,
245		CXmlConstantValue::ITEM_TYPE_ODBC => CXmlConstantName::ODBC,
246		CXmlConstantValue::ITEM_TYPE_IPMI => CXmlConstantName::IPMI,
247		CXmlConstantValue::ITEM_TYPE_SSH => CXmlConstantName::SSH,
248		CXmlConstantValue::ITEM_TYPE_TELNET => CXmlConstantName::TELNET,
249		CXmlConstantValue::ITEM_TYPE_JMX => CXmlConstantName::JMX,
250		CXmlConstantValue::ITEM_TYPE_DEPENDENT => CXmlConstantName::DEPENDENT,
251		CXmlConstantValue::ITEM_TYPE_HTTP_AGENT => CXmlConstantName::HTTP_AGENT,
252		CXmlConstantValue::ITEM_TYPE_SNMP => CXmlConstantName::SNMP_AGENT,
253		CXmlConstantValue::ITEM_TYPE_SCRIPT => CXmlConstantName::SCRIPT
254	];
255
256	private $ITEM_VALUE_TYPE = [
257		CXmlConstantValue::FLOAT => CXmlConstantName::FLOAT,
258		CXmlConstantValue::CHAR => CXmlConstantName::CHAR,
259		CXmlConstantValue::LOG => CXmlConstantName::LOG,
260		CXmlConstantValue::UNSIGNED => CXmlConstantName::UNSIGNED,
261		CXmlConstantValue::TEXT => CXmlConstantName::TEXT
262	];
263
264	private $TRIGGER_PRIORITY = [
265		CXmlConstantValue::NOT_CLASSIFIED => CXmlConstantName::NOT_CLASSIFIED,
266		CXmlConstantValue::INFO => CXmlConstantName::INFO,
267		CXmlConstantValue::WARNING => CXmlConstantName::WARNING,
268		CXmlConstantValue::AVERAGE => CXmlConstantName::AVERAGE,
269		CXmlConstantValue::HIGH => CXmlConstantName::HIGH,
270		CXmlConstantValue::DISASTER => CXmlConstantName::DISASTER
271	];
272
273	private $TRIGGER_RECOVERY_MODE = [
274		CXmlConstantValue::TRIGGER_EXPRESSION => CXmlConstantName::EXPRESSION,
275		CXmlConstantValue::TRIGGER_RECOVERY_EXPRESSION => CXmlConstantName::RECOVERY_EXPRESSION,
276		CXmlConstantValue::TRIGGER_NONE => CXmlConstantName::NONE
277	];
278
279	private $MEDIA_TYPE = [
280		CXmlConstantValue::MEDIA_TYPE_EMAIL => CXmlConstantName::EMAIL,
281		CXmlConstantValue::MEDIA_TYPE_SCRIPT => CXmlConstantName::SCRIPT,
282		CXmlConstantValue::MEDIA_TYPE_SMS => CXmlConstantName::SMS,
283		CXmlConstantValue::MEDIA_TYPE_WEBHOOK => CXmlConstantName::WEBHOOK
284	];
285
286	private $SMTP_AUTHENTICATION = [
287		CXmlConstantValue::SMTP_AUTHENTICATION_NONE => CXmlConstantName::SMTP_AUTHENTICATION_NONE,
288		CXmlConstantValue::SMTP_AUTHENTICATION_PASSWORD => CXmlConstantName::SMTP_AUTHENTICATION_PASSWORD
289	];
290
291	private $SNMPV3_AUTHPROTOCOL = [
292		CXmlConstantValue::SNMPV3_MD5 => CXmlConstantName::MD5,
293		CXmlConstantValue::SNMPV3_SHA1 => CXmlConstantName::SHA1,
294		CXmlConstantValue::SNMPV3_SHA224 => CXmlConstantName::SHA224,
295		CXmlConstantValue::SNMPV3_SHA256 => CXmlConstantName::SHA256,
296		CXmlConstantValue::SNMPV3_SHA384 => CXmlConstantName::SHA384,
297		CXmlConstantValue::SNMPV3_SHA512 => CXmlConstantName::SHA512
298	];
299
300	private $SNMPV3_PRIVPROTOCOL = [
301		CXmlConstantValue::SNMPV3_DES => CXmlConstantName::DES,
302		CXmlConstantValue::SNMPV3_AES128 => CXmlConstantName::AES128,
303		CXmlConstantValue::SNMPV3_AES192 => CXmlConstantName::AES192,
304		CXmlConstantValue::SNMPV3_AES256 => CXmlConstantName::AES256,
305		CXmlConstantValue::SNMPV3_AES192C => CXmlConstantName::AES192C,
306		CXmlConstantValue::SNMPV3_AES256C => CXmlConstantName::AES256C
307	];
308
309	private $EVENT_SOURCE = [
310		CXmlConstantValue::EVENT_SOURCE_TRIGGERS => CXmlConstantName::TRIGGERS,
311		CXmlConstantValue::EVENT_SOURCE_DISCOVERY => CXmlConstantName::DISCOVERY,
312		CXmlConstantValue::EVENT_SOURCE_AUTOREGISTRATION => CXmlConstantName::AUTOREGISTRATION,
313		CXmlConstantValue::EVENT_SOURCE_INTERNAL => CXmlConstantName::INTERNAL
314	];
315
316	private $OPERATION_MODE = [
317		CXmlConstantValue::OPERATION_MODE_PROBLEM => CXmlConstantName::PROBLEM,
318		CXmlConstantValue::OPERATION_MODE_RECOVERY => CXmlConstantName::RECOVERY,
319		CXmlConstantValue::OPERATION_MODE_UPDATE => CXmlConstantName::UPDATE
320	];
321
322	private $LLD_OVERRIDE_STOP = [
323		CXmlConstantValue::LLD_OVERRIDE_STOP_NO => CXmlConstantName::LLD_OVERRIDE_STOP_NO,
324		CXmlConstantValue::LLD_OVERRIDE_STOP_YES => CXmlConstantName::LLD_OVERRIDE_STOP_YES
325	];
326
327	private $EVALTPYE = [
328		CXmlConstantValue::AND_OR => CXmlConstantName::AND_OR,
329		CXmlConstantValue::XML_AND => CXmlConstantName::XML_AND,
330		CXmlConstantValue::XML_OR => CXmlConstantName::XML_OR,
331		CXmlConstantValue::FORMULA => CXmlConstantName::FORMULA
332	];
333
334	private $FILTER_CONDITION_OPERATOR = [
335		CXmlConstantValue::CONDITION_MATCHES_REGEX => CXmlConstantName::MATCHES_REGEX,
336		CXmlConstantValue::CONDITION_NOT_MATCHES_REGEX => CXmlConstantName::NOT_MATCHES_REGEX,
337		CXmlConstantValue::CONDITION_EXISTS => CXmlConstantName::EXISTS,
338		CXmlConstantValue::CONDITION_NOT_EXISTS => CXmlConstantName::NOT_EXISTS
339	];
340
341	private $LLD_OVERRIDE_OPERATION_OBJECT = [
342		CXmlConstantValue::LLD_OVERRIDE_OPERATION_OBJECT_ITEM_PROTOTYPE => CXmlConstantName::LLD_OVERRIDE_OPERATION_OBJECT_ITEM_PROTOTYPE,
343		CXmlConstantValue::LLD_OVERRIDE_OPERATION_OBJECT_TRIGGER_PROTOTYPE => CXmlConstantName::LLD_OVERRIDE_OPERATION_OBJECT_TRIGGER_PROTOTYPE,
344		CXmlConstantValue::LLD_OVERRIDE_OPERATION_OBJECT_GRAPH_PROTOTYPE => CXmlConstantName::LLD_OVERRIDE_OPERATION_OBJECT_GRAPH_PROTOTYPE,
345		CXmlConstantValue::LLD_OVERRIDE_OPERATION_OBJECT_HOST_PROTOTYPE => CXmlConstantName::LLD_OVERRIDE_OPERATION_OBJECT_HOST_PROTOTYPE
346	];
347
348	private $CONDITION_OPERATOR = [
349		CXmlConstantValue::CONDITION_OPERATOR_EQUAL => CXmlConstantName::CONDITION_OPERATOR_EQUAL,
350		CXmlConstantValue::CONDITION_OPERATOR_NOT_EQUAL => CXmlConstantName::CONDITION_OPERATOR_NOT_EQUAL,
351		CXmlConstantValue::CONDITION_OPERATOR_LIKE => CXmlConstantName::CONDITION_OPERATOR_LIKE,
352		CXmlConstantValue::CONDITION_OPERATOR_NOT_LIKE => CXmlConstantName::CONDITION_OPERATOR_NOT_LIKE,
353		CXmlConstantValue::CONDITION_OPERATOR_REGEXP => CXmlConstantName::CONDITION_OPERATOR_REGEXP,
354		CXmlConstantValue::CONDITION_OPERATOR_NOT_REGEXP => CXmlConstantName::CONDITION_OPERATOR_NOT_REGEXP
355	];
356
357	private $INVENTORY_MODE = [
358		CXmlConstantValue::INV_MODE_DISABLED => CXmlConstantName::DISABLED,
359		CXmlConstantValue::INV_MODE_MANUAL => CXmlConstantName::MANUAL,
360		CXmlConstantValue::INV_MODE_AUTOMATIC => CXmlConstantName::AUTOMATIC
361	];
362
363	private $CUSTOM_INTERFACES = [
364		CXmlConstantValue::CUSTOM_INTERFACES_NO => CXmlConstantName::NO,
365		CXmlConstantValue::CUSTOM_INTERFACES_YES => CXmlConstantName::YES
366	];
367
368	private $DASHBOARD_WIDGET_TYPE = [
369		CXmlConstantValue::DASHBOARD_WIDGET_TYPE_CLOCK => CXmlConstantName::DASHBOARD_WIDGET_TYPE_CLOCK,
370		CXmlConstantValue::DASHBOARD_WIDGET_TYPE_GRAPH_CLASSIC => CXmlConstantName::DASHBOARD_WIDGET_TYPE_GRAPH_CLASSIC,
371		CXmlConstantValue::DASHBOARD_WIDGET_TYPE_GRAPH_PROTOTYPE => CXmlConstantName::DASHBOARD_WIDGET_TYPE_GRAPH_PROTOTYPE,
372		CXmlConstantValue::DASHBOARD_WIDGET_TYPE_PLAIN_TEXT => CXmlConstantName::DASHBOARD_WIDGET_TYPE_PLAIN_TEXT,
373		CXmlConstantValue::DASHBOARD_WIDGET_TYPE_URL => CXmlConstantName::DASHBOARD_WIDGET_TYPE_URL
374	];
375
376	private $DASHBOARD_WIDGET_FIELD_TYPE = [
377		CXmlConstantValue::DASHBOARD_WIDGET_FIELD_TYPE_INTEGER => CXmlConstantName::DASHBOARD_WIDGET_FIELD_TYPE_INTEGER,
378		CXmlConstantValue::DASHBOARD_WIDGET_FIELD_TYPE_STRING => CXmlConstantName::DASHBOARD_WIDGET_FIELD_TYPE_STRING,
379		CXmlConstantValue::DASHBOARD_WIDGET_FIELD_TYPE_HOST => CXmlConstantName::DASHBOARD_WIDGET_FIELD_TYPE_HOST,
380		CXmlConstantValue::DASHBOARD_WIDGET_FIELD_TYPE_ITEM => CXmlConstantName::DASHBOARD_WIDGET_FIELD_TYPE_ITEM,
381		CXmlConstantValue::DASHBOARD_WIDGET_FIELD_TYPE_ITEM_PROTOTYPE => CXmlConstantName::DASHBOARD_WIDGET_FIELD_TYPE_ITEM_PROTOTYPE,
382		CXmlConstantValue::DASHBOARD_WIDGET_FIELD_TYPE_GRAPH => CXmlConstantName::DASHBOARD_WIDGET_FIELD_TYPE_GRAPH,
383		CXmlConstantValue::DASHBOARD_WIDGET_FIELD_TYPE_GRAPH_PROTOTYPE => CXmlConstantName::DASHBOARD_WIDGET_FIELD_TYPE_GRAPH_PROTOTYPE
384	];
385
386	private $VALUEMAP_MAPPING_TYPE = [
387		CXmlConstantValue::MAPPING_EQUAL => CXmlConstantName::MAPPING_EQUAL,
388		CXmlConstantValue::MAPPING_GREATER_EQUAL => CXmlConstantName::MAPPING_GREATER_EQUAL,
389		CXmlConstantValue::MAPPING_LESS_EQUAL => CXmlConstantName::MAPPING_LESS_EQUAL,
390		CXmlConstantValue::MAPPING_IN_RANGE => CXmlConstantName::MAPPING_IN_RANGE,
391		CXmlConstantValue::MAPPING_REGEXP => CXmlConstantName::MAPPING_REGEXP,
392		CXmlConstantValue::MAPPING_DEFAULT => CXmlConstantName::MAPPING_DEFAULT
393	];
394
395	private $HTTP_TEST_AUTHENTICATION = [
396		CXmlConstantValue::NONE => CXmlConstantName::NONE,
397		CXmlConstantValue::BASIC => CXmlConstantName::BASIC,
398		CXmlConstantValue::NTLM => CXmlConstantName::NTLM,
399		CXmlConstantValue::KERBEROS => CXmlConstantName::KERBEROS
400	];
401
402	/**
403	 * Get validation rules schema.
404	 *
405	 * @return array
406	 */
407	public function getSchema() {
408		return ['type' => XML_ARRAY, 'rules' => [
409			'version' =>				['type' => XML_STRING | XML_REQUIRED],
410			'date' =>					['type' => XML_STRING, 'ex_validate' => [$this, 'validateDateTime']],
411			'groups' =>					['type' => XML_INDEXED_ARRAY, 'prefix' => 'group', 'rules' => [
412				'group' =>					['type' => XML_ARRAY, 'rules' => [
413					'uuid' =>					['type' => XML_STRING | XML_REQUIRED, 'flags' => CImportDataNormalizer::LOWERCASE],
414					'name' =>					['type' => XML_STRING | XML_REQUIRED]
415				]]
416			]],
417			'hosts' =>					['type' => XML_INDEXED_ARRAY, 'prefix' => 'host', 'rules' => [
418				'host' =>					['type' => XML_ARRAY, 'rules' => [
419					'host' =>					['type' => XML_STRING | XML_REQUIRED],
420					'name' =>					['type' => XML_STRING, 'default' => ''],
421					'description' =>			['type' => XML_STRING, 'default' => ''],
422					'proxy' =>					['type' => XML_ARRAY, 'rules' => [
423						'name' =>					['type' => XML_STRING | XML_REQUIRED]
424					]],
425					'status' =>					['type' => XML_STRING, 'default' => CXmlConstantValue::ENABLED, 'in' => [CXmlConstantValue::ENABLED => CXmlConstantName::ENABLED, CXmlConstantValue::DISABLED => CXmlConstantName::DISABLED]],
426					'ipmi_authtype' =>			['type' => XML_STRING, 'default' => CXmlConstantValue::XML_DEFAULT, 'in' => [CXmlConstantValue::XML_DEFAULT => CXmlConstantName::XML_DEFAULT, CXmlConstantValue::NONE => CXmlConstantName::NONE, CXmlConstantValue::MD2 => CXmlConstantName::MD2, CXmlConstantValue::MD5 => CXmlConstantName::MD5, CXmlConstantValue::STRAIGHT => CXmlConstantName::STRAIGHT, CXmlConstantValue::OEM => CXmlConstantName::OEM, CXmlConstantValue::RMCP_PLUS => CXmlConstantName::RMCP_PLUS]],
427					'ipmi_privilege' =>			['type' => XML_STRING, 'default' => CXmlConstantValue::USER, 'in' => [CXmlConstantValue::CALLBACK => CXmlConstantName::CALLBACK, CXmlConstantValue::USER => CXmlConstantName::USER, CXmlConstantValue::OPERATOR => CXmlConstantName::OPERATOR, CXmlConstantValue::ADMIN => CXmlConstantName::ADMIN, CXmlConstantValue::OEM => CXmlConstantName::OEM]],
428					'ipmi_username' =>			['type' => XML_STRING, 'default' => ''],
429					'ipmi_password' =>			['type' => XML_STRING, 'default' => ''],
430					'templates' =>				['type' => XML_INDEXED_ARRAY, 'prefix' => 'template', 'rules' => [
431						'template' =>				['type' => XML_ARRAY, 'rules' => [
432							'name' =>					['type' => XML_STRING | XML_REQUIRED]
433						]]
434					]],
435					'groups' =>					['type' => XML_INDEXED_ARRAY | XML_REQUIRED, 'prefix' => 'group', 'rules' => [
436						'group' =>					['type' => XML_ARRAY, 'rules' => [
437							'name' =>					['type' => XML_STRING | XML_REQUIRED]
438						]]
439					]],
440					'interfaces' =>				['type' => XML_INDEXED_ARRAY, 'prefix' => 'interface', 'rules' => [
441						'interface' =>				['type' => XML_ARRAY, 'rules' => [
442							'default' =>				['type' => XML_STRING, 'default' => CXmlConstantValue::YES, 'in' => [CXmlConstantValue::NO => CXmlConstantName::NO, CXmlConstantValue::YES => CXmlConstantName::YES]],
443							'type' =>					['type' => XML_STRING, 'default' => CXmlConstantValue::ZABBIX, 'in' => [CXmlConstantValue::ZABBIX => CXmlConstantName::ZABBIX, CXmlConstantValue::SNMP => CXmlConstantName::SNMP, CXmlConstantValue::IPMI => CXmlConstantName::IPMI, CXmlConstantValue::JMX => CXmlConstantName::JMX]],
444							'useip' =>					['type' => XML_STRING, 'default' => CXmlConstantValue::YES, 'in' => [CXmlConstantValue::NO => CXmlConstantName::NO, CXmlConstantValue::YES => CXmlConstantName::YES]],
445							'ip' =>						['type' => XML_STRING, 'default' => '127.0.0.1'],
446							'dns' =>					['type' => XML_STRING, 'default' => ''],
447							'port' =>					['type' => XML_STRING, 'default' => '10050'],
448							'details' =>				['type' => XML_ARRAY, 'rules' => [
449								'version' =>				['type' => XML_STRING, 'default' => CXmlConstantValue::SNMP_V2, 'in' => [CXmlConstantValue::SNMP_V1 => CXmlConstantName::SNMPV1, CXmlConstantValue::SNMP_V2 => CXmlConstantName::SNMPV2, CXmlConstantValue::SNMP_V3 => CXmlConstantName::SNMPV3]],
450								'community' =>				['type' => XML_STRING, 'default' => ''],
451								'contextname' =>			['type' => XML_STRING, 'default' => ''],
452								'securityname' =>			['type' => XML_STRING, 'default' => ''],
453								'securitylevel' =>			['type' => XML_STRING, 'default' => CXmlConstantValue::NOAUTHNOPRIV, 'in' => $this->ITEM_SNMPV3_SECURITYLEVEL],
454								'authprotocol' =>			['type' => XML_STRING, 'default' => CXmlConstantValue::SNMPV3_MD5, 'in' => $this->SNMPV3_AUTHPROTOCOL],
455								'authpassphrase' =>			['type' => XML_STRING, 'default' => ''],
456								'privprotocol' =>			['type' => XML_STRING, 'default' => CXmlConstantValue::SNMPV3_DES, 'in' => $this->SNMPV3_PRIVPROTOCOL],
457								'privpassphrase' =>			['type' => XML_STRING, 'default' => ''],
458								'bulk' =>					['type' => XML_STRING, 'default' => CXmlConstantValue::YES, 'in' => [CXmlConstantValue::NO => CXmlConstantName::NO, CXmlConstantValue::YES => CXmlConstantName::YES]]
459							]],
460							'interface_ref' =>			['type' => XML_STRING | XML_REQUIRED]
461						]]
462					]],
463					'items' =>					['type' => XML_INDEXED_ARRAY, 'prefix' => 'item', 'rules' => [
464						'item' =>					['type' => XML_ARRAY, 'rules' => [
465							'name' =>					['type' => XML_STRING | XML_REQUIRED],
466							'type' =>					['type' => XML_STRING, 'default' => CXmlConstantValue::ITEM_TYPE_ZABBIX_PASSIVE, 'in' => $this->ITEM_TYPE],
467							'snmp_oid' =>				['type' => XML_STRING, 'default' => ''],
468							'key' =>					['type' => XML_STRING | XML_REQUIRED],
469							'delay' =>					['type' => XML_STRING, 'default' => '1m'],
470							'history' =>				['type' => XML_STRING, 'default' => '90d'],
471							'trends' =>					['type' => XML_STRING, 'default' => '365d'],
472							'status' =>					['type' => XML_STRING, 'default' => CXmlConstantValue::ENABLED, 'in' => [CXmlConstantValue::ENABLED => CXmlConstantName::ENABLED, CXmlConstantValue::DISABLED => CXmlConstantName::DISABLED]],
473							'value_type' =>				['type' => XML_STRING, 'default' => CXmlConstantValue::UNSIGNED, 'in' => $this->ITEM_VALUE_TYPE],
474							'allowed_hosts' =>			['type' => XML_STRING, 'default' => ''],
475							'units' =>					['type' => XML_STRING, 'default' => ''],
476							'params' =>					['type' => XML_STRING, 'default' => ''],
477							'ipmi_sensor' =>			['type' => XML_STRING, 'default' => ''],
478							'authtype' =>				['type' => XML_STRING, 'default' => CXmlConstantValue::NONE, 'ex_validate' => [$this, 'validateAuthType'], 'ex_rules' => [$this, 'getAuthTypeExtendedRules'], 'export' => [$this, 'itemAuthtypeExport']],
479							'username' =>				['type' => XML_STRING, 'default' => ''],
480							'password' =>				['type' => XML_STRING, 'default' => ''],
481							'publickey' =>				['type' => XML_STRING, 'default' => ''],
482							'privatekey' =>				['type' => XML_STRING, 'default' => ''],
483							'description' =>			['type' => XML_STRING, 'default' => ''],
484							'inventory_link' =>			['type' => XML_STRING, 'default' => CXmlConstantValue::NONE, 'in' => $this->ITEM_INVENTORY_LINK],
485							'valuemap' =>				['type' => XML_ARRAY, 'rules' => [
486								'name' =>					['type' => XML_STRING | XML_REQUIRED]
487							]],
488							'logtimefmt' =>				['type' => XML_STRING, 'default' => ''],
489							'preprocessing' =>			['type' => XML_INDEXED_ARRAY, 'prefix' => 'step', 'rules' => [
490								'step' =>					['type' => XML_ARRAY, 'rules' => [
491									'type' =>					['type' => XML_STRING | XML_REQUIRED, 'in' => $this->PREPROCESSING_STEP_TYPE],
492									'parameters' =>				['type' => XML_INDEXED_ARRAY | XML_REQUIRED, 'prefix' => 'parameter', 'export' => [$this, 'preprocessingParametersExport'], 'rules' => [
493										'parameter' =>				['type' => XML_STRING, 'flags' => CImportDataNormalizer::EOL_LF]
494									]],
495									'error_handler' =>			['type' => XML_STRING, 'ex_default' => [$this, 'defaultPreprocErrHandler'], 'ex_validate' => [$this, 'validatePreprocErrHandler'], 'in' => $this->ITEM_PREPROCESSING_ERROR_HANDLER],
496									'error_handler_params' =>	['type' => XML_STRING, 'default' => '']
497								]]
498							]],
499							'interface_ref' =>			['type' => XML_STRING],
500							'jmx_endpoint' =>			['type' => XML_STRING, 'default' => ''],
501							'master_item' =>			['type' => XML_ARRAY, 'ex_validate' => [$this, 'validateMasterItem'], 'rules' => [
502								'key' =>					['type' => XML_STRING | XML_REQUIRED]
503							]],
504							'timeout' =>				['type' => XML_STRING, 'default' => '3s'],
505							'url' =>					['type' => XML_STRING, 'default' => ''],
506							'query_fields' =>			['type' => XML_INDEXED_ARRAY, 'prefix' => 'query_field', 'rules' => [
507								'query_field' =>			['type' => XML_ARRAY, 'rules' => [
508									'name' =>					['type' => XML_STRING | XML_REQUIRED],
509									'value' =>					['type' => XML_STRING, 'default' => '']
510								]]
511							]],
512							'parameters' =>			['type' => XML_INDEXED_ARRAY, 'prefix' => 'parameter', 'rules' => [
513								'parameter' =>			['type' => XML_ARRAY, 'rules' => [
514									'name' =>					['type' => XML_STRING | XML_REQUIRED],
515									'value' =>					['type' => XML_STRING, 'default' => '']
516								]]
517							]],
518							'posts' =>					['type' => XML_STRING, 'default' => ''],
519							'status_codes' =>			['type' => XML_STRING, 'default' => '200'],
520							'follow_redirects' =>		['type' => XML_STRING, 'default' => CXmlConstantValue::YES, 'in' => [CXmlConstantValue::NO => CXmlConstantName::NO, CXmlConstantValue::YES => CXmlConstantName::YES]],
521							'post_type' =>				['type' => XML_STRING, 'default' => CXmlConstantValue::RAW, 'in' => $this->ITEM_POST_TYPE],
522							'http_proxy' =>				['type' => XML_STRING, 'default' => ''],
523							'headers' =>				['type' => XML_INDEXED_ARRAY, 'prefix' => 'header', 'rules' => [
524								'header' =>					['type' => XML_ARRAY, 'rules' => [
525									'name' =>					['type' => XML_STRING | XML_REQUIRED],
526									'value' =>					['type' => XML_STRING | XML_REQUIRED]
527								]]
528							]],
529							'retrieve_mode' =>			['type' => XML_STRING, 'default' => CXmlConstantValue::BODY, 'in' => $this->ITEM_RETRIEVE_MODE],
530							'request_method' =>			['type' => XML_STRING, 'default' => CXmlConstantValue::GET, 'in' => $this->ITEM_REQUEST_METHOD],
531							'output_format' =>			['type' => XML_STRING, 'default' => CXmlConstantValue::OUTPUT_FORMAT_RAW, 'in' => [CXmlConstantValue::OUTPUT_FORMAT_RAW => CXmlConstantName::RAW, CXmlConstantValue::OUTPUT_FORMAT_JSON => CXmlConstantName::JSON]],
532							'allow_traps' =>			['type' => XML_STRING, 'default' => CXmlConstantValue::NO, 'in' => [CXmlConstantValue::NO => CXmlConstantName::NO, CXmlConstantValue::YES => CXmlConstantName::YES]],
533							'ssl_cert_file' =>			['type' => XML_STRING, 'default' => ''],
534							'ssl_key_file' =>			['type' => XML_STRING, 'default' => ''],
535							'ssl_key_password' =>		['type' => XML_STRING, 'default' => ''],
536							'verify_peer' =>			['type' => XML_STRING, 'default' => CXmlConstantValue::NO, 'in' => [CXmlConstantValue::NO => CXmlConstantName::NO, CXmlConstantValue::YES => CXmlConstantName::YES]],
537							'verify_host' =>			['type' => XML_STRING, 'default' => CXmlConstantValue::NO, 'in' => [CXmlConstantValue::NO => CXmlConstantName::NO, CXmlConstantValue::YES => CXmlConstantName::YES]],
538							'tags' =>					['type' => XML_INDEXED_ARRAY, 'prefix' => 'tag', 'rules' => [
539								'tag' =>					['type' => XML_ARRAY, 'rules' => [
540									'tag' =>					['type' => XML_STRING | XML_REQUIRED],
541									'value' =>					['type' => XML_STRING, 'default' => '']
542								]]
543							]],
544							'triggers' =>				['type' => XML_INDEXED_ARRAY, 'prefix' => 'trigger', 'rules' => [
545								'trigger' =>				['type' => XML_ARRAY, 'rules' => [
546									'expression' =>				['type' => XML_STRING | XML_REQUIRED],
547									'recovery_mode' =>			['type' => XML_STRING, 'default' => CXmlConstantValue::TRIGGER_EXPRESSION, 'in' => $this->TRIGGER_RECOVERY_MODE],
548									'recovery_expression' =>	['type' => XML_STRING, 'default' => ''],
549									'correlation_mode' =>		['type' => XML_STRING, 'default' => CXmlConstantValue::TRIGGER_DISABLED, 'in' => [CXmlConstantValue::TRIGGER_DISABLED => CXmlConstantName::DISABLED, CXmlConstantValue::TRIGGER_TAG_VALUE => CXmlConstantName::TAG_VALUE]],
550									'correlation_tag' =>		['type' => XML_STRING, 'default' => ''],
551									'name' =>					['type' => XML_STRING | XML_REQUIRED],
552									'event_name' =>				['type' => XML_STRING, 'default' => ''],
553									'opdata' =>					['type' => XML_STRING, 'default' => ''],
554									'url' =>					['type' => XML_STRING, 'default' => ''],
555									'status' =>					['type' => XML_STRING, 'default' => CXmlConstantValue::ENABLED, 'in' => [CXmlConstantValue::ENABLED => CXmlConstantName::ENABLED, CXmlConstantValue::DISABLED => CXmlConstantName::DISABLED]],
556									'priority' =>				['type' => XML_STRING, 'default' => CXmlConstantValue::NOT_CLASSIFIED, 'in' => $this->TRIGGER_PRIORITY],
557									'description' =>			['type' => XML_STRING, 'default' => ''],
558									'type' =>					['type' => XML_STRING, 'default' => CXmlConstantValue::SINGLE, 'in' => [CXmlConstantValue::SINGLE => CXmlConstantName::SINGLE, CXmlConstantValue::MULTIPLE => CXmlConstantName::MULTIPLE]],
559									'manual_close' =>			['type' => XML_STRING, 'default' => CXmlConstantValue::NO, 'in' => [CXmlConstantValue::NO => CXmlConstantName::NO, CXmlConstantValue::YES => CXmlConstantName::YES]],
560									'dependencies' =>			['type' => XML_INDEXED_ARRAY, 'prefix' => 'dependency', 'rules' => [
561										'dependency' =>				['type' => XML_ARRAY, 'rules' => [
562											'name' =>					['type' => XML_STRING | XML_REQUIRED],
563											'expression' =>				['type' => XML_STRING | XML_REQUIRED],
564											'recovery_expression' =>	['type' => XML_STRING, 'default' => '']
565										]]
566									]],
567									'tags' =>					['type' => XML_INDEXED_ARRAY, 'prefix' => 'tag', 'rules' => [
568										'tag' =>					['type' => XML_ARRAY, 'rules' => [
569											'tag' =>					['type' => XML_STRING | XML_REQUIRED],
570											'value' =>					['type' => XML_STRING, 'default' => '']
571										]]
572									]]
573								]]
574							]]
575						]]
576					]],
577					'discovery_rules' =>		['type' => XML_INDEXED_ARRAY, 'prefix' => 'discovery_rule', 'rules' => [
578						'discovery_rule' =>			['type' => XML_ARRAY, 'rules' => [
579							'name' =>					['type' => XML_STRING | XML_REQUIRED],
580							'type' =>					['type' => XML_STRING, 'default' => CXmlConstantValue::ITEM_TYPE_ZABBIX_PASSIVE, 'in' => $this->ITEM_TYPE_DRULE],
581							'snmp_oid' =>				['type' => XML_STRING, 'default' => ''],
582							'key' =>					['type' => XML_STRING | XML_REQUIRED],
583							'delay' =>					['type' => XML_STRING, 'default' => '1m'],
584							'status' =>					['type' => XML_STRING, 'default' => CXmlConstantValue::ENABLED, 'in' => [CXmlConstantValue::ENABLED => CXmlConstantName::ENABLED, CXmlConstantValue::DISABLED => CXmlConstantName::DISABLED]],
585							'allowed_hosts' =>			['type' => XML_STRING, 'default' => ''],
586							'params' =>					['type' => XML_STRING, 'default' => ''],
587							'ipmi_sensor' =>			['type' => XML_STRING, 'default' => ''],
588							'authtype' =>				['type' => XML_STRING, 'default' => CXmlConstantValue::NONE, 'ex_validate' => [$this, 'validateAuthType'], 'ex_rules' => [$this, 'getAuthTypeExtendedRules'], 'export' => [$this, 'itemAuthtypeExport']],
589							'username' =>				['type' => XML_STRING, 'default' => ''],
590							'password' =>				['type' => XML_STRING, 'default' => ''],
591							'publickey' =>				['type' => XML_STRING, 'default' => ''],
592							'privatekey' =>				['type' => XML_STRING, 'default' => ''],
593							'filter' =>					['type' => XML_ARRAY, 'import' => [$this, 'itemFilterImport'], 'rules' => [
594								'evaltype' =>				['type' => XML_STRING, 'default' => CXmlConstantValue::AND_OR, 'in' => $this->EVALTPYE],
595								'formula' =>				['type' => XML_STRING, 'default' => ''],
596								'conditions' =>				['type' => XML_INDEXED_ARRAY, 'prefix' => 'condition', 'rules' => [
597									'condition' =>				['type' => XML_ARRAY, 'rules' => [
598										'macro' =>					['type' => XML_STRING | XML_REQUIRED],
599										'value' =>					['type' => XML_STRING, 'default' => ''],
600										'operator' =>				['type' => XML_STRING, 'default' => CXmlConstantValue::CONDITION_MATCHES_REGEX, 'in' => $this->FILTER_CONDITION_OPERATOR],
601										'formulaid' =>				['type' => XML_STRING | XML_REQUIRED]
602									]]
603								]]
604							]],
605							'lifetime' =>				['type' => XML_STRING, 'default' => '30d'],
606							'description' =>			['type' => XML_STRING, 'default' => ''],
607							'interface_ref' =>			['type' => XML_STRING],
608							'item_prototypes' =>		['type' => XML_INDEXED_ARRAY, 'prefix' => 'item_prototype', 'rules' => [
609								'item_prototype' =>			['type' => XML_ARRAY, 'rules' => [
610									'name' =>					['type' => XML_STRING | XML_REQUIRED],
611									'type' =>					['type' => XML_STRING, 'default' => CXmlConstantValue::ITEM_TYPE_ZABBIX_PASSIVE, 'in' => $this->ITEM_TYPE],
612									'snmp_oid' =>				['type' => XML_STRING, 'default' => ''],
613									'key' =>					['type' => XML_STRING | XML_REQUIRED],
614									'delay' =>					['type' => XML_STRING, 'default' => '1m'],
615									'history' =>				['type' => XML_STRING, 'default' => '90d'],
616									'trends' =>					['type' => XML_STRING, 'default' => '365d'],
617									'status' =>					['type' => XML_STRING, 'default' => CXmlConstantValue::ENABLED, 'in' => [CXmlConstantValue::ENABLED => CXmlConstantName::ENABLED, CXmlConstantValue::DISABLED => CXmlConstantName::DISABLED]],
618									'discover' =>				['type' => XML_STRING, 'default' => CXmlConstantValue::ITEM_DISCOVER, 'in' => [CXmlConstantValue::ITEM_DISCOVER => CXmlConstantName::DISCOVER, CXmlConstantValue::ITEM_NO_DISCOVER => CXmlConstantName::NO_DISCOVER]],
619									'value_type' =>				['type' => XML_STRING, 'default' => CXmlConstantValue::UNSIGNED, 'in' => $this->ITEM_VALUE_TYPE],
620									'allowed_hosts' =>			['type' => XML_STRING, 'default' => ''],
621									'units' =>					['type' => XML_STRING, 'default' => ''],
622									'params' =>					['type' => XML_STRING, 'default' => ''],
623									'ipmi_sensor' =>			['type' => XML_STRING, 'default' => ''],
624									'authtype' =>				['type' => XML_STRING, 'default' => CXmlConstantValue::NONE, 'ex_validate' => [$this, 'validateAuthType'], 'ex_rules' => [$this, 'getAuthTypeExtendedRules'], 'export' => [$this, 'itemAuthtypeExport']],
625									'username' =>				['type' => XML_STRING, 'default' => ''],
626									'password' =>				['type' => XML_STRING, 'default' => ''],
627									'publickey' =>				['type' => XML_STRING, 'default' => ''],
628									'privatekey' =>				['type' => XML_STRING, 'default' => ''],
629									'description' =>			['type' => XML_STRING, 'default' => ''],
630									'inventory_link' =>			['type' => XML_STRING, 'default' => CXmlConstantValue::NONE, 'in' => $this->ITEM_INVENTORY_LINK],
631									'valuemap' =>				['type' => XML_ARRAY, 'rules' => [
632										'name' =>					['type' => XML_STRING | XML_REQUIRED]
633									]],
634									'logtimefmt' =>				['type' => XML_STRING, 'default' => ''],
635									'preprocessing' =>			['type' => XML_INDEXED_ARRAY, 'prefix' => 'step', 'rules' => [
636										'step' =>					['type' => XML_ARRAY, 'rules' => [
637											'type' =>					['type' => XML_STRING | XML_REQUIRED, 'in' => $this->PREPROCESSING_STEP_TYPE],
638											'parameters' =>				['type' => XML_INDEXED_ARRAY | XML_REQUIRED, 'prefix' => 'parameter', 'export' => [$this, 'preprocessingParametersExport'], 'rules' => [
639												'parameter' =>				['type' => XML_STRING, 'flags' => CImportDataNormalizer::EOL_LF]
640											]],
641											'error_handler' =>			['type' => XML_STRING, 'ex_default' => [$this, 'defaultPreprocErrHandler'], 'ex_validate' => [$this, 'validatePreprocErrHandler'], 'in' => $this->ITEM_PREPROCESSING_ERROR_HANDLER],
642											'error_handler_params' =>	['type' => XML_STRING, 'default' => '']
643										]]
644									]],
645									'interface_ref' =>			['type' => XML_STRING],
646									'jmx_endpoint' =>			['type' => XML_STRING, 'default' => ''],
647									'master_item' =>			['type' => XML_ARRAY, 'ex_validate' => [$this, 'validateMasterItem'],  'rules' => [
648										'key' =>					['type' => XML_STRING | XML_REQUIRED]
649									]],
650									'timeout' =>				['type' => XML_STRING, 'default' => '3s'],
651									'url' =>					['type' => XML_STRING, 'default' => ''],
652									'query_fields' =>			['type' => XML_INDEXED_ARRAY, 'prefix' => 'query_field', 'rules' => [
653										'query_field' =>			['type' => XML_ARRAY, 'rules' => [
654											'name' =>					['type' => XML_STRING | XML_REQUIRED],
655											'value' =>					['type' => XML_STRING, 'default' => '']
656										]]
657									]],
658									'parameters' =>			['type' => XML_INDEXED_ARRAY, 'prefix' => 'parameter', 'rules' => [
659										'parameter' =>			['type' => XML_ARRAY, 'rules' => [
660											'name' =>					['type' => XML_STRING | XML_REQUIRED],
661											'value' =>					['type' => XML_STRING, 'default' => '']
662										]]
663									]],
664									'posts' =>					['type' => XML_STRING, 'default' => ''],
665									'status_codes' =>			['type' => XML_STRING, 'default' => '200'],
666									'follow_redirects' =>		['type' => XML_STRING, 'default' => CXmlConstantValue::YES, 'in' => [CXmlConstantValue::NO => CXmlConstantName::NO, CXmlConstantValue::YES => CXmlConstantName::YES]],
667									'post_type' =>				['type' => XML_STRING, 'default' => CXmlConstantValue::RAW, 'in' => $this->ITEM_POST_TYPE],
668									'http_proxy' =>				['type' => XML_STRING, 'default' => ''],
669									'headers' =>				['type' => XML_INDEXED_ARRAY, 'prefix' => 'header', 'rules' => [
670										'header' =>					['type' => XML_ARRAY, 'rules' => [
671											'name' =>					['type' => XML_STRING | XML_REQUIRED],
672											'value' =>					['type' => XML_STRING | XML_REQUIRED]
673										]]
674									]],
675									'retrieve_mode' =>			['type' => XML_STRING, 'default' => CXmlConstantValue::BODY, 'in' => $this->ITEM_RETRIEVE_MODE],
676									'request_method' =>			['type' => XML_STRING, 'default' => CXmlConstantValue::GET, 'in' => $this->ITEM_REQUEST_METHOD],
677									'output_format' =>			['type' => XML_STRING, 'default' => CXmlConstantValue::OUTPUT_FORMAT_RAW, 'in' => [CXmlConstantValue::OUTPUT_FORMAT_RAW => CXmlConstantName::RAW, CXmlConstantValue::OUTPUT_FORMAT_JSON => CXmlConstantName::JSON]],
678									'allow_traps' =>			['type' => XML_STRING, 'default' => CXmlConstantValue::NO, 'in' => [CXmlConstantValue::NO => CXmlConstantName::NO, CXmlConstantValue::YES => CXmlConstantName::YES]],
679									'ssl_cert_file' =>			['type' => XML_STRING, 'default' => ''],
680									'ssl_key_file' =>			['type' => XML_STRING, 'default' => ''],
681									'ssl_key_password' =>		['type' => XML_STRING, 'default' => ''],
682									'verify_peer' =>			['type' => XML_STRING, 'default' => CXmlConstantValue::NO, 'in' => [CXmlConstantValue::NO => CXmlConstantName::NO, CXmlConstantValue::YES => CXmlConstantName::YES]],
683									'verify_host' =>			['type' => XML_STRING, 'default' => CXmlConstantValue::NO, 'in' => [CXmlConstantValue::NO => CXmlConstantName::NO, CXmlConstantValue::YES => CXmlConstantName::YES]],
684									'tags' =>					['type' => XML_INDEXED_ARRAY, 'prefix' => 'tag', 'rules' => [
685										'tag' =>					['type' => XML_ARRAY, 'rules' => [
686											'tag' =>					['type' => XML_STRING | XML_REQUIRED],
687											'value' =>					['type' => XML_STRING, 'default' => '']
688										]]
689									]],
690									'trigger_prototypes' =>		['type' => XML_INDEXED_ARRAY, 'prefix' => 'trigger_prototype', 'rules' => [
691										'trigger_prototype' =>		['type' => XML_ARRAY, 'rules' => [
692											'expression' =>				['type' => XML_STRING | XML_REQUIRED],
693											'recovery_mode' =>			['type' => XML_STRING, 'default' => CXmlConstantValue::TRIGGER_EXPRESSION, 'in' => $this->TRIGGER_RECOVERY_MODE],
694											'recovery_expression' =>	['type' => XML_STRING, 'default' => ''],
695											'correlation_mode' =>		['type' => XML_STRING, 'default' => CXmlConstantValue::TRIGGER_DISABLED, 'in' => [CXmlConstantValue::TRIGGER_DISABLED => CXmlConstantName::DISABLED, CXmlConstantValue::TRIGGER_TAG_VALUE => CXmlConstantName::TAG_VALUE]],
696											'correlation_tag' =>		['type' => XML_STRING, 'default' => ''],
697											'name' =>					['type' => XML_STRING | XML_REQUIRED],
698											'event_name' =>				['type' => XML_STRING, 'default' => ''],
699											'opdata' =>					['type' => XML_STRING, 'default' => ''],
700											'url' =>					['type' => XML_STRING, 'default' => ''],
701											'status' =>					['type' => XML_STRING, 'default' => CXmlConstantValue::ENABLED, 'in' => [CXmlConstantValue::ENABLED => CXmlConstantName::ENABLED, CXmlConstantValue::DISABLED => CXmlConstantName::DISABLED]],
702											'discover' =>				['type' => XML_STRING, 'default' => CXmlConstantValue::TRIGGER_DISCOVER, 'in' => [CXmlConstantValue::TRIGGER_DISCOVER => CXmlConstantName::DISCOVER, CXmlConstantValue::TRIGGER_NO_DISCOVER => CXmlConstantName::NO_DISCOVER]],
703											'priority' =>				['type' => XML_STRING, 'default' => CXmlConstantValue::NOT_CLASSIFIED, 'in' => $this->TRIGGER_PRIORITY],
704											'description' =>			['type' => XML_STRING, 'default' => ''],
705											'type' =>					['type' => XML_STRING, 'default' => CXmlConstantValue::SINGLE, 'in' => [CXmlConstantValue::SINGLE => CXmlConstantName::SINGLE, CXmlConstantValue::MULTIPLE => CXmlConstantName::MULTIPLE]],
706											'manual_close' =>			['type' => XML_STRING, 'default' => CXmlConstantValue::NO, 'in' => [CXmlConstantValue::NO => CXmlConstantName::NO, CXmlConstantValue::YES => CXmlConstantName::YES]],
707											'dependencies' =>			['type' => XML_INDEXED_ARRAY, 'prefix' => 'dependency', 'rules' => [
708												'dependency' =>				['type' => XML_ARRAY, 'rules' => [
709													'name' =>					['type' => XML_STRING | XML_REQUIRED],
710													'expression' =>				['type' => XML_STRING | XML_REQUIRED],
711													'recovery_expression' =>	['type' => XML_STRING, 'default' => '']
712												]]
713											]],
714											'tags' =>					['type' => XML_INDEXED_ARRAY, 'prefix' => 'tag', 'rules' => [
715												'tag' =>					['type' => XML_ARRAY, 'rules' => [
716													'tag' =>					['type' => XML_STRING | XML_REQUIRED],
717													'value' =>					['type' => XML_STRING, 'default' => '']
718												]]
719											]]
720										]]
721									]]
722								]]
723							]],
724							'trigger_prototypes' =>		['type' => XML_INDEXED_ARRAY, 'prefix' => 'trigger_prototype', 'rules' => [
725								'trigger_prototype' =>		['type' => XML_ARRAY, 'rules' => [
726									'expression' =>				['type' => XML_STRING | XML_REQUIRED],
727									'recovery_mode' =>			['type' => XML_STRING, 'default' => CXmlConstantValue::TRIGGER_EXPRESSION, 'in' => $this->TRIGGER_RECOVERY_MODE],
728									'recovery_expression' =>	['type' => XML_STRING, 'default' => ''],
729									'correlation_mode' =>		['type' => XML_STRING, 'default' => CXmlConstantValue::TRIGGER_DISABLED, 'in' => [CXmlConstantValue::TRIGGER_DISABLED => CXmlConstantName::DISABLED, CXmlConstantValue::TRIGGER_TAG_VALUE => CXmlConstantName::TAG_VALUE]],
730									'correlation_tag' =>		['type' => XML_STRING, 'default' => ''],
731									'name' =>					['type' => XML_STRING | XML_REQUIRED],
732									'event_name' =>				['type' => XML_STRING, 'default' => ''],
733									'opdata' =>					['type' => XML_STRING, 'default' => ''],
734									'url' =>					['type' => XML_STRING, 'default' => ''],
735									'status' =>					['type' => XML_STRING, 'default' => CXmlConstantValue::ENABLED, 'in' => [CXmlConstantValue::ENABLED => CXmlConstantName::ENABLED, CXmlConstantValue::DISABLED => CXmlConstantName::DISABLED]],
736									'discover' =>				['type' => XML_STRING, 'default' => CXmlConstantValue::TRIGGER_DISCOVER, 'in' => [CXmlConstantValue::TRIGGER_DISCOVER => CXmlConstantName::DISCOVER, CXmlConstantValue::TRIGGER_NO_DISCOVER => CXmlConstantName::NO_DISCOVER]],
737									'priority' =>				['type' => XML_STRING, 'default' => CXmlConstantValue::NOT_CLASSIFIED, 'in' => $this->TRIGGER_PRIORITY],
738									'description' =>			['type' => XML_STRING, 'default' => ''],
739									'type' =>					['type' => XML_STRING, 'default' => CXmlConstantValue::SINGLE, 'in' => [CXmlConstantValue::SINGLE => CXmlConstantName::SINGLE, CXmlConstantValue::MULTIPLE => CXmlConstantName::MULTIPLE]],
740									'manual_close' =>			['type' => XML_STRING, 'default' => CXmlConstantValue::NO, 'in' => [CXmlConstantValue::NO => CXmlConstantName::NO, CXmlConstantValue::YES => CXmlConstantName::YES]],
741									'dependencies' =>			['type' => XML_INDEXED_ARRAY, 'prefix' => 'dependency', 'rules' => [
742										'dependency' =>				['type' => XML_ARRAY, 'rules' => [
743											'name' =>					['type' => XML_STRING | XML_REQUIRED],
744											'expression' =>				['type' => XML_STRING | XML_REQUIRED],
745											'recovery_expression' =>	['type' => XML_STRING, 'default' => '']
746										]]
747									]],
748									'tags' =>					['type' => XML_INDEXED_ARRAY, 'prefix' => 'tag', 'rules' => [
749										'tag' =>					['type' => XML_ARRAY, 'rules' => [
750											'tag' =>					['type' => XML_STRING | XML_REQUIRED],
751											'value' =>					['type' => XML_STRING, 'default' => '']
752										]]
753									]]
754								]]
755							]],
756							'graph_prototypes' =>		['type' => XML_INDEXED_ARRAY, 'prefix' => 'graph_prototype', 'rules' => [
757								'graph_prototype' =>		['type' => XML_ARRAY, 'rules' => [
758									'name' =>					['type' => XML_STRING | XML_REQUIRED],
759									'width' =>					['type' => XML_STRING, 'default' => '900'],
760									'height' =>					['type' => XML_STRING, 'default' => '200'],
761									'yaxismin' =>				['type' => XML_STRING, 'default' => '0'],
762									'yaxismax' =>				['type' => XML_STRING, 'default' => '100'],
763									'show_work_period' =>		['type' => XML_STRING, 'default' => CXmlConstantValue::YES, 'in' => [CXmlConstantValue::NO => CXmlConstantName::NO, CXmlConstantValue::YES => CXmlConstantName::YES]],
764									'show_triggers' =>			['type' => XML_STRING, 'default' => CXmlConstantValue::YES, 'in' => [CXmlConstantValue::NO => CXmlConstantName::NO, CXmlConstantValue::YES => CXmlConstantName::YES]],
765									'type' =>					['type' => XML_STRING, 'default' => CXmlConstantValue::NORMAL, 'in' => $this->GRAPH_TYPE],
766									'show_legend' =>			['type' => XML_STRING, 'default' => CXmlConstantValue::YES, 'in' => [CXmlConstantValue::NO => CXmlConstantName::NO, CXmlConstantValue::YES => CXmlConstantName::YES]],
767									'show_3d' =>				['type' => XML_STRING, 'default' => CXmlConstantValue::NO, 'in' => [CXmlConstantValue::NO => CXmlConstantName::NO, CXmlConstantValue::YES => CXmlConstantName::YES]],
768									'percent_left' =>			['type' => XML_STRING, 'default' => '0'],
769									'percent_right' =>			['type' => XML_STRING, 'default' => '0'],
770									// The tag 'ymin_type_1' should be validated before the 'ymin_item_1' because it is used in 'ex_validate' method.
771									'ymin_type_1' =>			['type' => XML_STRING, 'default' => CXmlConstantValue::CALCULATED, 'in' => $this->GRAPH_Y_TYPE],
772									'ymin_item_1' =>			['type' => 0, 'default' => '0', 'preprocessor' => [$this, 'transformZero2Array'], 'ex_validate' => [$this, 'validateYMinItem'], 'export' => [$this, 'graphMinItemExport']],
773									// The tag 'ymax_type_1' should be validated before the 'ymax_item_1' because it is used in 'ex_validate' method.
774									'ymax_type_1' =>			['type' => XML_STRING, 'default' => CXmlConstantValue::CALCULATED, 'in' => $this->GRAPH_Y_TYPE],
775									'ymax_item_1' =>			['type' => 0, 'default' => '0', 'preprocessor' => [$this, 'transformZero2Array'], 'ex_validate' => [$this, 'validateYMaxItem'], 'export' => [$this, 'graphMaxItemExport']],
776									'graph_items' =>			['type' => XML_INDEXED_ARRAY | XML_REQUIRED, 'prefix' => 'graph_item', 'ex_validate' => [$this, 'validateGraphItems'], 'rules' => [
777										'graph_item' =>				['type' => XML_ARRAY, 'rules' => [
778											'sortorder' =>				['type' => XML_STRING, 'default' => '0'],
779											'drawtype' =>				['type' => XML_STRING, 'default' => CXmlConstantValue::SINGLE_LINE, 'in' => $this->GRAPH_GRAPH_ITEM_DRAWTYPE],
780											'color' =>					['type' => XML_STRING, 'default' => '009600'],
781											'yaxisside' =>				['type' => XML_STRING, 'default' => CXmlConstantValue::LEFT, 'in' => $this->GRAPH_GRAPH_ITEM_YAXISSIDE],
782											'calc_fnc' =>				['type' => XML_STRING, 'default' => CXmlConstantValue::AVG, 'in' => $this->GRAPH_GRAPH_ITEM_CALC_FNC],
783											'type' =>					['type' => XML_STRING, 'default' => CXmlConstantValue::SIMPLE, 'in' => $this->GRAPH_GRAPH_ITEM_TYPE],
784											'item' =>					['type' => XML_ARRAY | XML_REQUIRED, 'rules' => [
785												'host' =>					['type' => XML_STRING | XML_REQUIRED],
786												'key' =>					['type' => XML_STRING | XML_REQUIRED]
787											]]
788										]]
789									]],
790									'discover' =>				['type' => XML_STRING, 'default' => CXmlConstantValue::GRAPH_DISCOVER, 'in' => [CXmlConstantValue::GRAPH_DISCOVER => CXmlConstantName::DISCOVER, CXmlConstantValue::GRAPH_NO_DISCOVER => CXmlConstantName::NO_DISCOVER]]
791								]]
792							]],
793							'host_prototypes' =>		['type' => XML_INDEXED_ARRAY, 'prefix' => 'host_prototype', 'rules' => [
794								'host_prototype' =>			['type' => XML_ARRAY, 'rules' => [
795									'host' =>					['type' => XML_STRING | XML_REQUIRED],
796									'name' =>					['type' => XML_STRING, 'default' => ''],
797									'status' =>					['type' => XML_STRING, 'default' => CXmlConstantValue::ENABLED, 'in' => [CXmlConstantValue::ENABLED => CXmlConstantName::ENABLED, CXmlConstantValue::DISABLED => CXmlConstantName::DISABLED]],
798									'discover' =>				['type' => XML_STRING, 'default' => CXmlConstantValue::HOST_DISCOVER, 'in' => [CXmlConstantValue::HOST_DISCOVER => CXmlConstantName::DISCOVER, CXmlConstantValue::HOST_NO_DISCOVER => CXmlConstantName::NO_DISCOVER]],
799									'inventory_mode' =>			['type' => XML_STRING, 'default' => CXmlConstantValue::INV_MODE_MANUAL, 'in' => $this->INVENTORY_MODE],
800									'group_links' =>			['type' => XML_INDEXED_ARRAY, 'prefix' => 'group_link', 'rules' => [
801										'group_link' =>				['type' => XML_ARRAY, 'rules' => [
802											'group' =>					['type' => XML_ARRAY | XML_REQUIRED, 'rules' => [
803												'name' =>					['type' => XML_STRING | XML_REQUIRED]
804											]]
805										]]
806									]],
807									'group_prototypes' =>		['type' => XML_INDEXED_ARRAY, 'prefix' => 'group_prototype', 'rules' => [
808										'group_prototype' =>		['type' => XML_ARRAY, 'rules' => [
809											'name' =>					['type' => XML_STRING | XML_REQUIRED]
810										]]
811									]],
812									'templates' =>				['type' => XML_INDEXED_ARRAY, 'prefix' => 'template', 'rules' => [
813										'template' =>				['type' => XML_ARRAY, 'rules' => [
814											'name' =>					['type' => XML_STRING | XML_REQUIRED]
815										]]
816									]],
817									'macros' =>					['type' => XML_INDEXED_ARRAY, 'prefix' => 'macro', 'rules' => [
818										'macro' =>					['type' => XML_ARRAY, 'rules' => [
819											'macro' =>					['type' => XML_STRING | XML_REQUIRED],
820											'type' =>					['type' => XML_STRING, 'default' => CXmlConstantValue::MACRO_TYPE_TEXT, 'in' => [CXmlConstantValue::MACRO_TYPE_TEXT => CXmlConstantName::MACRO_TYPE_TEXT, CXmlConstantValue::MACRO_TYPE_SECRET => CXmlConstantName::MACRO_TYPE_SECRET, CXmlConstantValue::MACRO_TYPE_VAULT => CXmlConstantName::MACRO_TYPE_VAULT]],
821											'value' =>					['type' => XML_STRING, 'default' => ''],
822											'description' =>			['type' => XML_STRING, 'default' => '']
823										]]
824									]],
825									'tags' =>					['type' => XML_INDEXED_ARRAY, 'prefix' => 'tag', 'rules' => [
826										'tag' =>					['type' => XML_ARRAY, 'rules' => [
827											'tag' =>					['type' => XML_STRING | XML_REQUIRED],
828											'value' =>					['type' => XML_STRING, 'default' => '']
829										]]
830									]],
831									'custom_interfaces' =>		['type' => XML_STRING, 'default' => CXmlConstantValue::CUSTOM_INTERFACES_NO, 'in' => $this->CUSTOM_INTERFACES],
832									'interfaces' =>				['type' => XML_INDEXED_ARRAY, 'prefix' => 'interface', 'rules' => [
833										'interface' =>				['type' => XML_ARRAY, 'rules' => [
834											'default' =>				['type' => XML_STRING, 'default' => CXmlConstantValue::YES, 'in' => [CXmlConstantValue::NO => CXmlConstantName::NO, CXmlConstantValue::YES => CXmlConstantName::YES]],
835											'type' =>					['type' => XML_STRING, 'default' => CXmlConstantValue::ZABBIX, 'in' => [CXmlConstantValue::ZABBIX => CXmlConstantName::ZABBIX, CXmlConstantValue::SNMP => CXmlConstantName::SNMP, CXmlConstantValue::IPMI => CXmlConstantName::IPMI, CXmlConstantValue::JMX => CXmlConstantName::JMX]],
836											'useip' =>					['type' => XML_STRING, 'default' => CXmlConstantValue::YES, 'in' => [CXmlConstantValue::NO => CXmlConstantName::NO, CXmlConstantValue::YES => CXmlConstantName::YES]],
837											'ip' =>						['type' => XML_STRING, 'default' => '127.0.0.1'],
838											'dns' =>					['type' => XML_STRING, 'default' => ''],
839											'port' =>					['type' => XML_STRING, 'default' => '10050'],
840											'details' =>				['type' => XML_ARRAY, 'rules' => [
841												'version' =>				['type' => XML_STRING, 'default' => CXmlConstantValue::SNMP_V2, 'in' => [CXmlConstantValue::SNMP_V1 => CXmlConstantName::SNMPV1, CXmlConstantValue::SNMP_V2 => CXmlConstantName::SNMPV2, CXmlConstantValue::SNMP_V3 => CXmlConstantName::SNMPV3]],
842												'community' =>				['type' => XML_STRING, 'default' => ''],
843												'contextname' =>			['type' => XML_STRING, 'default' => ''],
844												'securityname' =>			['type' => XML_STRING, 'default' => ''],
845												'securitylevel' =>			['type' => XML_STRING, 'default' => CXmlConstantValue::NOAUTHNOPRIV, 'in' => $this->ITEM_SNMPV3_SECURITYLEVEL],
846												'authprotocol' =>			['type' => XML_STRING, 'default' => CXmlConstantValue::SNMPV3_MD5, 'in' => $this->SNMPV3_AUTHPROTOCOL],
847												'authpassphrase' =>			['type' => XML_STRING, 'default' => ''],
848												'privprotocol' =>			['type' => XML_STRING, 'default' => CXmlConstantValue::SNMPV3_DES, 'in' => $this->SNMPV3_PRIVPROTOCOL],
849												'privpassphrase' =>			['type' => XML_STRING, 'default' => ''],
850												'bulk' =>					['type' => XML_STRING, 'default' => CXmlConstantValue::YES, 'in' => [CXmlConstantValue::NO => CXmlConstantName::NO, CXmlConstantValue::YES => CXmlConstantName::YES]]
851											]]
852										]]
853									]]
854								]]
855							]],
856							'jmx_endpoint' =>			['type' => XML_STRING, 'default' => ''],
857							'master_item' =>			['type' => XML_ARRAY, 'ex_validate' => [$this, 'validateMasterItem'], 'rules' => [
858								'key' =>					['type' => XML_STRING | XML_REQUIRED]
859							]],
860							'timeout' =>				['type' => XML_STRING, 'default' => '3s'],
861							'url' =>					['type' => XML_STRING, 'default' => ''],
862							'query_fields' =>			['type' => XML_INDEXED_ARRAY, 'prefix' => 'query_field', 'rules' => [
863								'query_field' =>			['type' => XML_ARRAY, 'rules' => [
864									'name' =>					['type' => XML_STRING | XML_REQUIRED],
865									'value' =>					['type' => XML_STRING, 'default' => '']
866								]]
867							]],
868							'parameters' =>			['type' => XML_INDEXED_ARRAY, 'prefix' => 'parameter', 'rules' => [
869								'parameter' =>			['type' => XML_ARRAY, 'rules' => [
870									'name' =>					['type' => XML_STRING | XML_REQUIRED],
871									'value' =>					['type' => XML_STRING, 'default' => '']
872								]]
873							]],
874							'posts' =>					['type' => XML_STRING, 'default' => ''],
875							'status_codes' =>			['type' => XML_STRING, 'default' => '200'],
876							'follow_redirects' =>		['type' => XML_STRING, 'default' => CXmlConstantValue::YES, 'in' => [CXmlConstantValue::NO => CXmlConstantName::NO, CXmlConstantValue::YES => CXmlConstantName::YES]],
877							'post_type' =>				['type' => XML_STRING, 'default' => CXmlConstantValue::RAW, 'in' => $this->ITEM_POST_TYPE],
878							'http_proxy' =>				['type' => XML_STRING, 'default' => ''],
879							'headers' =>				['type' => XML_INDEXED_ARRAY, 'prefix' => 'header', 'rules' => [
880								'header' =>					['type' => XML_ARRAY, 'rules' => [
881									'name' =>					['type' => XML_STRING | XML_REQUIRED],
882									'value' =>					['type' => XML_STRING | XML_REQUIRED]
883								]]
884							]],
885							'retrieve_mode' =>			['type' => XML_STRING, 'default' => CXmlConstantValue::BODY, 'in' => $this->ITEM_RETRIEVE_MODE],
886							'request_method' =>			['type' => XML_STRING, 'default' => CXmlConstantValue::GET, 'in' => $this->ITEM_REQUEST_METHOD],
887							'allow_traps' =>			['type' => XML_STRING, 'default' => CXmlConstantValue::NO, 'in' => [CXmlConstantValue::NO => CXmlConstantName::NO, CXmlConstantValue::YES => CXmlConstantName::YES]],
888							'ssl_cert_file' =>			['type' => XML_STRING, 'default' => ''],
889							'ssl_key_file' =>			['type' => XML_STRING, 'default' => ''],
890							'ssl_key_password' =>		['type' => XML_STRING, 'default' => ''],
891							'verify_peer' =>			['type' => XML_STRING, 'default' => CXmlConstantValue::NO, 'in' => [CXmlConstantValue::NO => CXmlConstantName::NO, CXmlConstantValue::YES => CXmlConstantName::YES]],
892							'verify_host' =>			['type' => XML_STRING, 'default' => CXmlConstantValue::NO, 'in' => [CXmlConstantValue::NO => CXmlConstantName::NO, CXmlConstantValue::YES => CXmlConstantName::YES]],
893							'lld_macro_paths' =>		['type' => XML_INDEXED_ARRAY, 'prefix' => 'lld_macro_path', 'rules' => [
894								'lld_macro_path' =>			['type' => XML_ARRAY, 'rules' => [
895									'lld_macro' =>				['type' => XML_STRING | XML_REQUIRED],
896									'path' =>					['type' => XML_STRING | XML_REQUIRED]
897								]]
898							]],
899							'preprocessing' =>			['type' => XML_INDEXED_ARRAY, 'prefix' => 'step', 'rules' => [
900								'step' =>					['type' => XML_ARRAY, 'rules' => [
901									'type' =>					['type' => XML_STRING | XML_REQUIRED, 'in' => $this->PREPROCESSING_STEP_TYPE_DRULE],
902									'parameters' =>				['type' => XML_INDEXED_ARRAY | XML_REQUIRED, 'prefix' => 'parameter', 'export' => [$this, 'preprocessingParametersExport'], 'rules' => [
903										'parameter' =>				['type' => XML_STRING, 'flags' => CImportDataNormalizer::EOL_LF]
904									]],
905									'error_handler' =>			['type' => XML_STRING, 'ex_default' => [$this, 'defaultPreprocErrHandler'], 'ex_validate' => [$this, 'validatePreprocErrHandler'], 'in' => $this->ITEM_PREPROCESSING_ERROR_HANDLER],
906									'error_handler_params' =>	['type' => XML_STRING, 'default' => '']
907								]]
908							]],
909							'overrides'	=>				['type' => XML_INDEXED_ARRAY, 'prefix' => 'override', 'rules' => [
910								'override' =>				['type' => XML_ARRAY, 'rules' => [
911									'name' =>					['type' => XML_STRING | XML_REQUIRED],
912									'step' =>					['type' => XML_STRING | XML_REQUIRED],
913									'stop' =>					['type' => XML_STRING, 'default' => CXmlConstantValue::LLD_OVERRIDE_STOP_NO, 'in' => $this->LLD_OVERRIDE_STOP],
914									'filter' =>					['type' => XML_ARRAY, 'rules' => [
915										'evaltype' =>				['type' => XML_STRING, 'default' => CXmlConstantValue::AND_OR, 'in' => $this->EVALTPYE],
916										'formula' =>				['type' => XML_STRING, 'default' => ''],
917										'conditions' =>				['type' => XML_INDEXED_ARRAY | XML_REQUIRED, 'prefix' => 'condition', 'rules' => [
918											'condition' =>				['type' => XML_ARRAY | XML_REQUIRED, 'rules' => [
919												'macro' =>					['type' => XML_STRING | XML_REQUIRED],
920												'value' =>					['type' => XML_STRING, 'default' => ''],
921												'operator' =>				['type' => XML_STRING, 'default' => CXmlConstantValue::CONDITION_MATCHES_REGEX, 'in' => $this->FILTER_CONDITION_OPERATOR],
922												'formulaid' =>				['type' => XML_STRING | XML_REQUIRED]
923											]]
924										]]
925									]],
926									'operations' =>				['type' => XML_INDEXED_ARRAY, 'prefix' => 'operation', 'rules' => [
927										'operation' =>				['type' => XML_ARRAY, 'rules' => [
928											'operationobject' =>		['type' => XML_STRING, 'in' => $this->LLD_OVERRIDE_OPERATION_OBJECT],
929											'operator' =>				['type' => XML_STRING, 'default' => CXmlConstantValue::CONDITION_OPERATOR_EQUAL, 'in' => $this->CONDITION_OPERATOR],
930											'value' =>					['type' => XML_STRING, 'default' => ''],
931											'status' =>					['type' => XML_STRING, 'in' => [CXmlConstantValue::LLD_OVERRIDE_OPERATION_STATUS_ENABLED => CXmlConstantName::ENABLED, CXmlConstantValue::LLD_OVERRIDE_OPERATION_STATUS_DISABLED => CXmlConstantName::DISABLED]],
932											'discover' =>				['type' => XML_STRING, 'in' => [CXmlConstantValue::LLD_OVERRIDE_OPERATION_DISCOVER => CXmlConstantName::DISCOVER, CXmlConstantValue::LLD_OVERRIDE_OPERATION_NO_DISCOVER => CXmlConstantName::NO_DISCOVER]],
933											'delay' =>					['type' => XML_STRING, 'default' => ''],
934											'history' =>				['type' => XML_STRING, 'default' => ''],
935											'trends' =>					['type' => XML_STRING, 'default' => ''],
936											'severity' =>				['type' => XML_STRING, 'in' => $this->TRIGGER_PRIORITY],
937											'tags' =>					['type' => XML_INDEXED_ARRAY, 'prefix' => 'tag', 'rules' => [
938												'tag' =>					['type' => XML_ARRAY, 'rules' => [
939													'tag' =>					['type' => XML_STRING | XML_REQUIRED],
940													'value' =>					['type' => XML_STRING, 'default' => '']
941												]]
942											]],
943											'templates' =>				['type' => XML_INDEXED_ARRAY, 'prefix' => 'template', 'rules' => [
944												'template' =>				['type' => XML_ARRAY, 'rules' => [
945													'name' =>					['type' => XML_STRING | XML_REQUIRED]
946												]]
947											]],
948											'inventory_mode' =>			['type' => XML_STRING, 'in' => $this->INVENTORY_MODE]
949										]]
950									]]
951								]]
952							]]
953						]]
954					]],
955					'httptests' =>				['type' => XML_INDEXED_ARRAY, 'prefix' => 'httptest', 'rules' => [
956						'httptest' =>				['type' => XML_ARRAY, 'rules' => [
957							'name' =>					['type' => XML_STRING | XML_REQUIRED],
958							'delay' =>					['type' => XML_STRING, 'default' => '1m'],
959							'attempts' =>				['type' => XML_STRING, 'default' => '1'],
960							'agent' =>					['type' => XML_STRING, 'default' => 'Zabbix'],
961							'http_proxy' =>				['type' => XML_STRING, 'default' => ''],
962							'variables' =>				['type' => XML_INDEXED_ARRAY, 'prefix' => 'variable', 'rules' => [
963								'variable' =>				['type' => XML_ARRAY, 'rules' => [
964									'name' =>					['type' => XML_STRING | XML_REQUIRED],
965									'value' =>					['type' => XML_STRING | XML_REQUIRED]
966								]]
967							]],
968							'headers' =>				['type' => XML_INDEXED_ARRAY, 'prefix' => 'header', 'rules' => [
969								'header' =>					['type' => XML_ARRAY, 'rules' => [
970									'name' =>					['type' => XML_STRING | XML_REQUIRED],
971									'value' =>					['type' => XML_STRING | XML_REQUIRED]
972								]]
973							]],
974							'status' =>					['type' => XML_STRING, 'default' => CXmlConstantValue::ENABLED, 'in' => [CXmlConstantValue::ENABLED => CXmlConstantName::ENABLED, CXmlConstantValue::DISABLED => CXmlConstantName::DISABLED]],
975							'authentication' =>			['type' => XML_STRING, 'default' => CXmlConstantValue::NONE, 'in' => $this->HTTP_TEST_AUTHENTICATION],
976							'http_user' =>				['type' => XML_STRING, 'default' => ''],
977							'http_password' =>			['type' => XML_STRING, 'default' => ''],
978							'verify_peer' =>			['type' => XML_STRING, 'default' => CXmlConstantValue::NO, 'in' => [CXmlConstantValue::NO => CXmlConstantName::NO, CXmlConstantValue::YES => CXmlConstantName::YES]],
979							'verify_host' =>			['type' => XML_STRING, 'default' => CXmlConstantValue::NO, 'in' => [CXmlConstantValue::NO => CXmlConstantName::NO, CXmlConstantValue::YES => CXmlConstantName::YES]],
980							'ssl_cert_file' =>			['type' => XML_STRING, 'default' => ''],
981							'ssl_key_file' =>			['type' => XML_STRING, 'default' => ''],
982							'ssl_key_password' =>		['type' => XML_STRING, 'default' => ''],
983							'steps' =>					['type' => XML_INDEXED_ARRAY | XML_REQUIRED, 'prefix' => 'step', 'rules' => [
984								'step' =>					['type' => XML_ARRAY, 'rules' => [
985									'name' =>					['type' => XML_STRING | XML_REQUIRED],
986									'url' =>					['type' => XML_STRING | XML_REQUIRED],
987									'query_fields' =>			['type' => XML_INDEXED_ARRAY, 'prefix' => 'query_field', 'rules' => [
988										'query_field' =>			['type' => XML_ARRAY, 'rules' => [
989											'name' =>					['type' => XML_STRING | XML_REQUIRED],
990											'value' =>					['type' => XML_STRING, 'default' => '']
991										]]
992									]],
993									'posts' =>					['type' => 0, 'ex_validate' => [$this, 'validateHttpPosts']],
994									'variables' =>				['type' => XML_INDEXED_ARRAY, 'prefix' => 'variable', 'rules' => [
995										'variable' =>				['type' => XML_ARRAY, 'rules' => [
996											'name' =>					['type' => XML_STRING | XML_REQUIRED],
997											'value' =>					['type' => XML_STRING | XML_REQUIRED]
998										]]
999									]],
1000									'headers' =>				['type' => XML_INDEXED_ARRAY, 'prefix' => 'header', 'rules' => [
1001										'header' =>					['type' => XML_ARRAY, 'rules' => [
1002											'name' =>					['type' => XML_STRING | XML_REQUIRED],
1003											'value' =>					['type' => XML_STRING | XML_REQUIRED]
1004										]]
1005									]],
1006									'follow_redirects' =>		['type' => XML_STRING, 'default' => CXmlConstantValue::YES, 'in' => [CXmlConstantValue::NO => CXmlConstantName::NO, CXmlConstantValue::YES => CXmlConstantName::YES]],
1007									'retrieve_mode' =>			['type' => XML_STRING, 'default' => CXmlConstantValue::BODY, 'in' => $this->ITEM_RETRIEVE_MODE],
1008									'timeout' =>				['type' => XML_STRING, 'default' => '15s'],
1009									'required' =>				['type' => XML_STRING, 'default' => ''],
1010									'status_codes' =>			['type' => XML_STRING, 'default' => '']
1011								]]
1012							]],
1013							'tags' =>					['type' => XML_INDEXED_ARRAY, 'prefix' => 'tag', 'rules' => [
1014								'tag' =>					['type' => XML_ARRAY, 'rules' => [
1015									'tag' =>					['type' => XML_STRING | XML_REQUIRED],
1016									'value' =>					['type' => XML_STRING, 'default' => '']
1017								]]
1018							]]
1019						]]
1020					]],
1021					'tags' =>					['type' => XML_INDEXED_ARRAY, 'prefix' => 'tag', 'rules' => [
1022						'tag' =>					['type' => XML_ARRAY, 'rules' => [
1023							'tag' =>					['type' => XML_STRING | XML_REQUIRED],
1024							'value' =>					['type' => XML_STRING, 'default' => '']
1025						]]
1026					]],
1027					'macros' =>					['type' => XML_INDEXED_ARRAY, 'prefix' => 'macro', 'rules' => [
1028						'macro' =>					['type' => XML_ARRAY, 'rules' => [
1029							'macro' =>					['type' => XML_STRING | XML_REQUIRED],
1030							'type' =>					['type' => XML_STRING, 'default' => CXmlConstantValue::MACRO_TYPE_TEXT, 'in' => [CXmlConstantValue::MACRO_TYPE_TEXT => CXmlConstantName::MACRO_TYPE_TEXT, CXmlConstantValue::MACRO_TYPE_SECRET => CXmlConstantName::MACRO_TYPE_SECRET, CXmlConstantValue::MACRO_TYPE_VAULT => CXmlConstantName::MACRO_TYPE_VAULT]],
1031							'value' =>					['type' => XML_STRING, 'default' => ''],
1032							'description' =>			['type' => XML_STRING, 'default' => '']
1033						]]
1034					]],
1035					'inventory' =>				['type' => XML_ARRAY, 'rules' => [
1036						'type' =>					['type' => XML_STRING, 'default' => ''],
1037						'type_full' =>				['type' => XML_STRING, 'default' => ''],
1038						'name' =>					['type' => XML_STRING, 'default' => ''],
1039						'alias' =>					['type' => XML_STRING, 'default' => ''],
1040						'os' =>						['type' => XML_STRING, 'default' => ''],
1041						'os_full' =>				['type' => XML_STRING, 'default' => ''],
1042						'os_short' =>				['type' => XML_STRING, 'default' => ''],
1043						'serialno_a' =>				['type' => XML_STRING, 'default' => ''],
1044						'serialno_b' =>				['type' => XML_STRING, 'default' => ''],
1045						'tag' =>					['type' => XML_STRING, 'default' => ''],
1046						'asset_tag' =>				['type' => XML_STRING, 'default' => ''],
1047						'macaddress_a' =>			['type' => XML_STRING, 'default' => ''],
1048						'macaddress_b' =>			['type' => XML_STRING, 'default' => ''],
1049						'hardware' =>				['type' => XML_STRING, 'default' => ''],
1050						'hardware_full' =>			['type' => XML_STRING, 'default' => ''],
1051						'software' =>				['type' => XML_STRING, 'default' => ''],
1052						'software_full' =>			['type' => XML_STRING, 'default' => ''],
1053						'software_app_a' =>			['type' => XML_STRING, 'default' => ''],
1054						'software_app_b' =>			['type' => XML_STRING, 'default' => ''],
1055						'software_app_c' =>			['type' => XML_STRING, 'default' => ''],
1056						'software_app_d' =>			['type' => XML_STRING, 'default' => ''],
1057						'software_app_e' =>			['type' => XML_STRING, 'default' => ''],
1058						'contact' =>				['type' => XML_STRING, 'default' => ''],
1059						'location' =>				['type' => XML_STRING, 'default' => ''],
1060						'location_lat' =>			['type' => XML_STRING, 'default' => ''],
1061						'location_lon' =>			['type' => XML_STRING, 'default' => ''],
1062						'notes' =>					['type' => XML_STRING, 'default' => ''],
1063						'chassis' =>				['type' => XML_STRING, 'default' => ''],
1064						'model' =>					['type' => XML_STRING, 'default' => ''],
1065						'hw_arch' =>				['type' => XML_STRING, 'default' => ''],
1066						'vendor' =>					['type' => XML_STRING, 'default' => ''],
1067						'contract_number' =>		['type' => XML_STRING, 'default' => ''],
1068						'installer_name' =>			['type' => XML_STRING, 'default' => ''],
1069						'deployment_status' =>		['type' => XML_STRING, 'default' => ''],
1070						'url_a' =>					['type' => XML_STRING, 'default' => ''],
1071						'url_b' =>					['type' => XML_STRING, 'default' => ''],
1072						'url_c' =>					['type' => XML_STRING, 'default' => ''],
1073						'host_networks' =>			['type' => XML_STRING, 'default' => ''],
1074						'host_netmask' =>			['type' => XML_STRING, 'default' => ''],
1075						'host_router' =>			['type' => XML_STRING, 'default' => ''],
1076						'oob_ip' =>					['type' => XML_STRING, 'default' => ''],
1077						'oob_netmask' =>			['type' => XML_STRING, 'default' => ''],
1078						'oob_router' =>				['type' => XML_STRING, 'default' => ''],
1079						'date_hw_purchase' =>		['type' => XML_STRING, 'default' => ''],
1080						'date_hw_install' =>		['type' => XML_STRING, 'default' => ''],
1081						'date_hw_expiry' =>			['type' => XML_STRING, 'default' => ''],
1082						'date_hw_decomm' =>			['type' => XML_STRING, 'default' => ''],
1083						'site_address_a' =>			['type' => XML_STRING, 'default' => ''],
1084						'site_address_b' =>			['type' => XML_STRING, 'default' => ''],
1085						'site_address_c' =>			['type' => XML_STRING, 'default' => ''],
1086						'site_city' =>				['type' => XML_STRING, 'default' => ''],
1087						'site_state' =>				['type' => XML_STRING, 'default' => ''],
1088						'site_country' =>			['type' => XML_STRING, 'default' => ''],
1089						'site_zip' =>				['type' => XML_STRING, 'default' => ''],
1090						'site_rack' =>				['type' => XML_STRING, 'default' => ''],
1091						'site_notes' =>				['type' => XML_STRING, 'default' => ''],
1092						'poc_1_name' =>				['type' => XML_STRING, 'default' => ''],
1093						'poc_1_email' =>			['type' => XML_STRING, 'default' => ''],
1094						'poc_1_phone_a' =>			['type' => XML_STRING, 'default' => ''],
1095						'poc_1_phone_b' =>			['type' => XML_STRING, 'default' => ''],
1096						'poc_1_cell' =>				['type' => XML_STRING, 'default' => ''],
1097						'poc_1_screen' =>			['type' => XML_STRING, 'default' => ''],
1098						'poc_1_notes' =>			['type' => XML_STRING, 'default' => ''],
1099						'poc_2_name' =>				['type' => XML_STRING, 'default' => ''],
1100						'poc_2_email' =>			['type' => XML_STRING, 'default' => ''],
1101						'poc_2_phone_a' =>			['type' => XML_STRING, 'default' => ''],
1102						'poc_2_phone_b' =>			['type' => XML_STRING, 'default' => ''],
1103						'poc_2_cell' =>				['type' => XML_STRING, 'default' => ''],
1104						'poc_2_screen' =>			['type' => XML_STRING, 'default' => ''],
1105						'poc_2_notes' =>			['type' => XML_STRING, 'default' => '']
1106					]],
1107					'inventory_mode' =>			['type' => XML_STRING, 'default' => CXmlConstantValue::INV_MODE_MANUAL, 'in' => $this->INVENTORY_MODE],
1108					'valuemaps' =>				['type' => XML_INDEXED_ARRAY, 'prefix' => 'valuemap', 'rules' => [
1109						'valuemap' =>				['type' => XML_ARRAY, 'rules' => [
1110							'name' =>					['type' => XML_STRING | XML_REQUIRED],
1111							'mappings' =>				['type' => XML_INDEXED_ARRAY | XML_REQUIRED, 'prefix' => 'mapping', 'rules' => [
1112								'mapping' =>				['type' => XML_ARRAY, 'rules' => [
1113									'type' =>					['type' => XML_STRING, 'default' => CXmlConstantValue::MAPPING_EQUAL, 'in' => $this->VALUEMAP_MAPPING_TYPE],
1114									'value' =>					['type' => XML_STRING, 'default' => ''],
1115									'newvalue' =>				['type' => XML_STRING | XML_REQUIRED]
1116								]]
1117							]]
1118						]]
1119					]]
1120				]]
1121			]],
1122			'templates' =>				['type' => XML_INDEXED_ARRAY, 'prefix' => 'template', 'rules' => [
1123				'template' =>				['type' => XML_ARRAY, 'rules' => [
1124					'uuid' =>				['type' => XML_STRING | XML_REQUIRED, 'flags' => CImportDataNormalizer::LOWERCASE],
1125					'template' =>				['type' => XML_STRING | XML_REQUIRED],
1126					'name' =>					['type' => XML_STRING, 'default' => ''],
1127					'description' =>			['type' => XML_STRING, 'default' => ''],
1128					'templates' =>				['type' => XML_INDEXED_ARRAY, 'prefix' => 'template', 'rules' => [
1129						'template' =>				['type' => XML_ARRAY, 'rules' => [
1130							'name' =>					['type' => XML_STRING | XML_REQUIRED]
1131						]]
1132					]],
1133					'groups' =>					['type' => XML_INDEXED_ARRAY | XML_REQUIRED, 'prefix' => 'group', 'rules' => [
1134						'group' =>					['type' => XML_ARRAY, 'rules' => [
1135							'name' =>					['type' => XML_STRING | XML_REQUIRED]
1136						]]
1137					]],
1138					'items' =>					['type' => XML_INDEXED_ARRAY, 'prefix' => 'item', 'rules' => [
1139						'item' =>					['type' => XML_ARRAY, 'rules' => [
1140							'uuid' =>					['type' => XML_STRING | XML_REQUIRED, 'flags' => CImportDataNormalizer::LOWERCASE],
1141							'name' =>					['type' => XML_STRING | XML_REQUIRED],
1142							'type' =>					['type' => XML_STRING, 'default' => CXmlConstantValue::ITEM_TYPE_ZABBIX_PASSIVE, 'in' => $this->ITEM_TYPE],
1143							'snmp_oid' =>				['type' => XML_STRING, 'default' => ''],
1144							'key' =>					['type' => XML_STRING | XML_REQUIRED],
1145							'delay' =>					['type' => XML_STRING, 'default' => '1m'],
1146							'history' =>				['type' => XML_STRING, 'default' => '90d'],
1147							'trends' =>					['type' => XML_STRING, 'default' => '365d'],
1148							'status' =>					['type' => XML_STRING, 'default' => CXmlConstantValue::ENABLED, 'in' => [CXmlConstantValue::ENABLED => CXmlConstantName::ENABLED, CXmlConstantValue::DISABLED => CXmlConstantName::DISABLED]],
1149							'value_type' =>				['type' => XML_STRING, 'default' => CXmlConstantValue::UNSIGNED, 'in' => $this->ITEM_VALUE_TYPE],
1150							'allowed_hosts' =>			['type' => XML_STRING, 'default' => ''],
1151							'units' =>					['type' => XML_STRING, 'default' => ''],
1152							'params' =>					['type' => XML_STRING, 'default' => ''],
1153							'ipmi_sensor' =>			['type' => XML_STRING, 'default' => ''],
1154							'authtype' =>				['type' => XML_STRING, 'default' => CXmlConstantValue::NONE, 'ex_validate' => [$this, 'validateAuthType'], 'ex_rules' => [$this, 'getAuthTypeExtendedRules'], 'export' => [$this, 'itemAuthtypeExport']],
1155							'username' =>				['type' => XML_STRING, 'default' => ''],
1156							'password' =>				['type' => XML_STRING, 'default' => ''],
1157							'publickey' =>				['type' => XML_STRING, 'default' => ''],
1158							'privatekey' =>				['type' => XML_STRING, 'default' => ''],
1159							'description' =>			['type' => XML_STRING, 'default' => ''],
1160							'inventory_link' =>			['type' => XML_STRING, 'default' => CXmlConstantValue::NONE, 'in' => $this->ITEM_INVENTORY_LINK],
1161							'valuemap' =>				['type' => XML_ARRAY, 'rules' => [
1162								'name' =>					['type' => XML_STRING | XML_REQUIRED]
1163							]],
1164							'logtimefmt' =>				['type' => XML_STRING, 'default' => ''],
1165							'preprocessing' =>			['type' => XML_INDEXED_ARRAY, 'prefix' => 'step', 'rules' => [
1166								'step' =>					['type' => XML_ARRAY, 'rules' => [
1167									'type' =>					['type' => XML_STRING | XML_REQUIRED, 'in' => $this->PREPROCESSING_STEP_TYPE],
1168									'parameters' =>				['type' => XML_INDEXED_ARRAY | XML_REQUIRED, 'prefix' => 'parameter', 'export' => [$this, 'preprocessingParametersExport'], 'rules' => [
1169										'parameter' =>				['type' => XML_STRING, 'flags' => CImportDataNormalizer::EOL_LF]
1170									]],
1171									'error_handler' =>			['type' => XML_STRING, 'ex_default' => [$this, 'defaultPreprocErrHandler'], 'ex_validate' => [$this, 'validatePreprocErrHandler'], 'in' => $this->ITEM_PREPROCESSING_ERROR_HANDLER],
1172									'error_handler_params' =>	['type' => XML_STRING, 'default' => '']
1173								]]
1174							]],
1175							'jmx_endpoint' =>			['type' => XML_STRING, 'default' => ''],
1176							'master_item' =>			['type' => XML_ARRAY, 'ex_validate' => [$this, 'validateMasterItem'], 'rules' => [
1177								'key' =>					['type' => XML_STRING | XML_REQUIRED]
1178							]],
1179							'timeout' =>				['type' => XML_STRING, 'default' => '3s'],
1180							'url' =>					['type' => XML_STRING, 'default' => ''],
1181							'query_fields' =>			['type' => XML_INDEXED_ARRAY, 'prefix' => 'query_field', 'rules' => [
1182								'query_field' =>			['type' => XML_ARRAY, 'rules' => [
1183									'name' =>					['type' => XML_STRING | XML_REQUIRED],
1184									'value' =>					['type' => XML_STRING, 'default' => '']
1185								]]
1186							]],
1187							'parameters' =>			['type' => XML_INDEXED_ARRAY, 'prefix' => 'parameter', 'rules' => [
1188								'parameter' =>			['type' => XML_ARRAY, 'rules' => [
1189									'name' =>					['type' => XML_STRING | XML_REQUIRED],
1190									'value' =>					['type' => XML_STRING, 'default' => '']
1191								]]
1192							]],
1193							'posts' =>					['type' => XML_STRING, 'default' => ''],
1194							'status_codes' =>			['type' => XML_STRING, 'default' => '200'],
1195							'follow_redirects' =>		['type' => XML_STRING, 'default' => CXmlConstantValue::YES, 'in' => [CXmlConstantValue::NO => CXmlConstantName::NO, CXmlConstantValue::YES => CXmlConstantName::YES]],
1196							'post_type' =>				['type' => XML_STRING, 'default' => CXmlConstantValue::RAW, 'in' => $this->ITEM_POST_TYPE],
1197							'http_proxy' =>				['type' => XML_STRING, 'default' => ''],
1198							'headers' =>				['type' => XML_INDEXED_ARRAY, 'prefix' => 'header', 'rules' => [
1199								'header' =>					['type' => XML_ARRAY, 'rules' => [
1200									'name' =>					['type' => XML_STRING | XML_REQUIRED],
1201									'value' =>					['type' => XML_STRING | XML_REQUIRED]
1202								]]
1203							]],
1204							'retrieve_mode' =>			['type' => XML_STRING, 'default' => CXmlConstantValue::BODY, 'in' => $this->ITEM_RETRIEVE_MODE],
1205							'request_method' =>			['type' => XML_STRING, 'default' => CXmlConstantValue::GET, 'in' => $this->ITEM_REQUEST_METHOD],
1206							'output_format' =>			['type' => XML_STRING, 'default' => CXmlConstantValue::OUTPUT_FORMAT_RAW, 'in' => [CXmlConstantValue::OUTPUT_FORMAT_RAW => CXmlConstantName::RAW, CXmlConstantValue::OUTPUT_FORMAT_JSON => CXmlConstantName::JSON]],
1207							'allow_traps' =>			['type' => XML_STRING, 'default' => CXmlConstantValue::NO, 'in' => [CXmlConstantValue::NO => CXmlConstantName::NO, CXmlConstantValue::YES => CXmlConstantName::YES]],
1208							'ssl_cert_file' =>			['type' => XML_STRING, 'default' => ''],
1209							'ssl_key_file' =>			['type' => XML_STRING, 'default' => ''],
1210							'ssl_key_password' =>		['type' => XML_STRING, 'default' => ''],
1211							'verify_peer' =>			['type' => XML_STRING, 'default' => CXmlConstantValue::NO, 'in' => [CXmlConstantValue::NO => CXmlConstantName::NO, CXmlConstantValue::YES => CXmlConstantName::YES]],
1212							'verify_host' =>			['type' => XML_STRING, 'default' => CXmlConstantValue::NO, 'in' => [CXmlConstantValue::NO => CXmlConstantName::NO, CXmlConstantValue::YES => CXmlConstantName::YES]],
1213							'tags' =>					['type' => XML_INDEXED_ARRAY, 'prefix' => 'tag', 'rules' => [
1214								'tag' =>					['type' => XML_ARRAY, 'rules' => [
1215									'tag' =>					['type' => XML_STRING | XML_REQUIRED],
1216									'value' =>					['type' => XML_STRING, 'default' => '']
1217								]]
1218							]],
1219							'triggers' =>				['type' => XML_INDEXED_ARRAY, 'prefix' => 'trigger', 'rules' => [
1220								'trigger' =>				['type' => XML_ARRAY, 'rules' => [
1221									'uuid' =>					['type' => XML_STRING | XML_REQUIRED, 'flags' => CImportDataNormalizer::LOWERCASE],
1222									'expression' =>				['type' => XML_STRING | XML_REQUIRED],
1223									'recovery_mode' =>			['type' => XML_STRING, 'default' => CXmlConstantValue::TRIGGER_EXPRESSION, 'in' => $this->TRIGGER_RECOVERY_MODE],
1224									'recovery_expression' =>	['type' => XML_STRING, 'default' => ''],
1225									'correlation_mode' =>		['type' => XML_STRING, 'default' => CXmlConstantValue::TRIGGER_DISABLED, 'in' => [CXmlConstantValue::TRIGGER_DISABLED => CXmlConstantName::DISABLED, CXmlConstantValue::TRIGGER_TAG_VALUE => CXmlConstantName::TAG_VALUE]],
1226									'correlation_tag' =>		['type' => XML_STRING, 'default' => ''],
1227									'name' =>					['type' => XML_STRING | XML_REQUIRED],
1228									'event_name' =>				['type' => XML_STRING, 'default' => ''],
1229									'opdata' =>					['type' => XML_STRING, 'default' => ''],
1230									'url' =>					['type' => XML_STRING, 'default' => ''],
1231									'status' =>					['type' => XML_STRING, 'default' => CXmlConstantValue::ENABLED, 'in' => [CXmlConstantValue::ENABLED => CXmlConstantName::ENABLED, CXmlConstantValue::DISABLED => CXmlConstantName::DISABLED]],
1232									'priority' =>				['type' => XML_STRING, 'default' => CXmlConstantValue::NOT_CLASSIFIED, 'in' => $this->TRIGGER_PRIORITY],
1233									'description' =>			['type' => XML_STRING, 'default' => ''],
1234									'type' =>					['type' => XML_STRING, 'default' => CXmlConstantValue::SINGLE, 'in' => [CXmlConstantValue::SINGLE => CXmlConstantName::SINGLE, CXmlConstantValue::MULTIPLE => CXmlConstantName::MULTIPLE]],
1235									'manual_close' =>			['type' => XML_STRING, 'default' => CXmlConstantValue::NO, 'in' => [CXmlConstantValue::NO => CXmlConstantName::NO, CXmlConstantValue::YES => CXmlConstantName::YES]],
1236									'dependencies' =>			['type' => XML_INDEXED_ARRAY, 'prefix' => 'dependency', 'rules' => [
1237										'dependency' =>				['type' => XML_ARRAY, 'rules' => [
1238											'name' =>					['type' => XML_STRING | XML_REQUIRED],
1239											'expression' =>				['type' => XML_STRING | XML_REQUIRED],
1240											'recovery_expression' =>	['type' => XML_STRING, 'default' => '']
1241										]]
1242									]],
1243									'tags' =>					['type' => XML_INDEXED_ARRAY, 'prefix' => 'tag', 'rules' => [
1244										'tag' =>					['type' => XML_ARRAY, 'rules' => [
1245											'tag' =>					['type' => XML_STRING | XML_REQUIRED],
1246											'value' =>					['type' => XML_STRING, 'default' => '']
1247										]]
1248									]]
1249								]]
1250							]]
1251						]]
1252					]],
1253					'discovery_rules' =>		['type' => XML_INDEXED_ARRAY, 'prefix' => 'discovery_rule', 'rules' => [
1254						'discovery_rule' =>			['type' => XML_ARRAY, 'rules' => [
1255							'uuid' =>					['type' => XML_STRING | XML_REQUIRED, 'flags' => CImportDataNormalizer::LOWERCASE],
1256							'name' =>					['type' => XML_STRING | XML_REQUIRED],
1257							'type' =>					['type' => XML_STRING, 'default' => CXmlConstantValue::ITEM_TYPE_ZABBIX_PASSIVE, 'in' => $this->ITEM_TYPE_DRULE],
1258							'snmp_oid' =>				['type' => XML_STRING, 'default' => ''],
1259							'key' =>					['type' => XML_STRING | XML_REQUIRED],
1260							'delay' =>					['type' => XML_STRING, 'default' => '1m'],
1261							'status' =>					['type' => XML_STRING, 'default' => CXmlConstantValue::ENABLED, 'in' => [CXmlConstantValue::ENABLED => CXmlConstantName::ENABLED, CXmlConstantValue::DISABLED => CXmlConstantName::DISABLED]],
1262							'allowed_hosts' =>			['type' => XML_STRING, 'default' => ''],
1263							'params' =>					['type' => XML_STRING, 'default' => ''],
1264							'ipmi_sensor' =>			['type' => XML_STRING, 'default' => ''],
1265							'authtype' =>				['type' => XML_STRING, 'default' => CXmlConstantValue::NONE, 'ex_validate' => [$this, 'validateAuthType'], 'ex_rules' => [$this, 'getAuthTypeExtendedRules'], 'export' => [$this, 'itemAuthtypeExport']],
1266							'username' =>				['type' => XML_STRING, 'default' => ''],
1267							'password' =>				['type' => XML_STRING, 'default' => ''],
1268							'publickey' =>				['type' => XML_STRING, 'default' => ''],
1269							'privatekey' =>				['type' => XML_STRING, 'default' => ''],
1270							'filter' =>					['type' => XML_ARRAY, 'import' => [$this, 'itemFilterImport'], 'rules' => [
1271								'evaltype' =>				['type' => XML_STRING, 'default' => CXmlConstantValue::AND_OR, 'in' => $this->EVALTPYE],
1272								'formula' =>				['type' => XML_STRING, 'default' => ''],
1273								'conditions' =>				['type' => XML_INDEXED_ARRAY, 'prefix' => 'condition', 'rules' => [
1274									'condition' =>				['type' => XML_ARRAY, 'rules' => [
1275										'macro' =>					['type' => XML_STRING | XML_REQUIRED],
1276										'value' =>					['type' => XML_STRING, 'default' => ''],
1277										'operator' =>				['type' => XML_STRING, 'default' => CXmlConstantValue::CONDITION_MATCHES_REGEX, 'in' => $this->FILTER_CONDITION_OPERATOR],
1278										'formulaid' =>				['type' => XML_STRING | XML_REQUIRED]
1279									]]
1280								]]
1281							]],
1282							'lifetime' =>				['type' => XML_STRING, 'default' => '30d'],
1283							'description' =>			['type' => XML_STRING, 'default' => ''],
1284							'item_prototypes' =>		['type' => XML_INDEXED_ARRAY, 'prefix' => 'item_prototype', 'rules' => [
1285								'item_prototype' =>			['type' => XML_ARRAY, 'rules' => [
1286									'uuid' =>					['type' => XML_STRING | XML_REQUIRED, 'flags' => CImportDataNormalizer::LOWERCASE],
1287									'name' =>					['type' => XML_STRING | XML_REQUIRED],
1288									'type' =>					['type' => XML_STRING, 'default' => CXmlConstantValue::ITEM_TYPE_ZABBIX_PASSIVE, 'in' => $this->ITEM_TYPE],
1289									'snmp_oid' =>				['type' => XML_STRING, 'default' => ''],
1290									'key' =>					['type' => XML_STRING | XML_REQUIRED],
1291									'delay' =>					['type' => XML_STRING, 'default' => '1m'],
1292									'history' =>				['type' => XML_STRING, 'default' => '90d'],
1293									'trends' =>					['type' => XML_STRING, 'default' => '365d'],
1294									'status' =>					['type' => XML_STRING, 'default' => CXmlConstantValue::ENABLED, 'in' => [CXmlConstantValue::ENABLED => CXmlConstantName::ENABLED, CXmlConstantValue::DISABLED => CXmlConstantName::DISABLED]],
1295									'discover' =>				['type' => XML_STRING, 'default' => CXmlConstantValue::ITEM_DISCOVER, 'in' => [CXmlConstantValue::ITEM_DISCOVER => CXmlConstantName::DISCOVER, CXmlConstantValue::ITEM_NO_DISCOVER => CXmlConstantName::NO_DISCOVER]],
1296									'value_type' =>				['type' => XML_STRING, 'default' => CXmlConstantValue::UNSIGNED, 'in' => $this->ITEM_VALUE_TYPE],
1297									'allowed_hosts' =>			['type' => XML_STRING, 'default' => ''],
1298									'units' =>					['type' => XML_STRING, 'default' => ''],
1299									'params' =>					['type' => XML_STRING, 'default' => ''],
1300									'ipmi_sensor' =>			['type' => XML_STRING, 'default' => ''],
1301									'authtype' =>				['type' => XML_STRING, 'default' => CXmlConstantValue::NONE, 'ex_validate' => [$this, 'validateAuthType'], 'ex_rules' => [$this, 'getAuthTypeExtendedRules'], 'export' => [$this, 'itemAuthtypeExport']],
1302									'username' =>				['type' => XML_STRING, 'default' => ''],
1303									'password' =>				['type' => XML_STRING, 'default' => ''],
1304									'publickey' =>				['type' => XML_STRING, 'default' => ''],
1305									'privatekey' =>				['type' => XML_STRING, 'default' => ''],
1306									'description' =>			['type' => XML_STRING, 'default' => ''],
1307									'inventory_link' =>			['type' => XML_STRING, 'default' => CXmlConstantValue::NONE, 'in' => $this->ITEM_INVENTORY_LINK],
1308									'valuemap' =>				['type' => XML_ARRAY, 'rules' => [
1309										'name' =>					['type' => XML_STRING | XML_REQUIRED]
1310									]],
1311									'logtimefmt' =>				['type' => XML_STRING, 'default' => ''],
1312									'preprocessing' =>			['type' => XML_INDEXED_ARRAY, 'prefix' => 'step', 'rules' => [
1313										'step' =>					['type' => XML_ARRAY, 'rules' => [
1314											'type' =>					['type' => XML_STRING | XML_REQUIRED, 'in' => $this->PREPROCESSING_STEP_TYPE],
1315											'parameters' =>				['type' => XML_INDEXED_ARRAY | XML_REQUIRED, 'prefix' => 'parameter', 'export' => [$this, 'preprocessingParametersExport'], 'rules' => [
1316												'parameter' =>				['type' => XML_STRING, 'flags' => CImportDataNormalizer::EOL_LF]
1317											]],
1318											'error_handler' =>			['type' => XML_STRING, 'ex_default' => [$this, 'defaultPreprocErrHandler'], 'ex_validate' => [$this, 'validatePreprocErrHandler'], 'in' => $this->ITEM_PREPROCESSING_ERROR_HANDLER],
1319											'error_handler_params' =>	['type' => XML_STRING, 'default' => '']
1320										]]
1321									]],
1322									'jmx_endpoint' =>			['type' => XML_STRING, 'default' => ''],
1323									'master_item' =>			['type' => XML_ARRAY, 'ex_validate' => [$this, 'validateMasterItem'],  'rules' => [
1324										'key' =>					['type' => XML_STRING | XML_REQUIRED]
1325									]],
1326									'timeout' =>				['type' => XML_STRING, 'default' => '3s'],
1327									'url' =>					['type' => XML_STRING, 'default' => ''],
1328									'query_fields' =>			['type' => XML_INDEXED_ARRAY, 'prefix' => 'query_field', 'rules' => [
1329										'query_field' =>			['type' => XML_ARRAY, 'rules' => [
1330											'name' =>					['type' => XML_STRING | XML_REQUIRED],
1331											'value' =>					['type' => XML_STRING, 'default' => '']
1332										]]
1333									]],
1334									'parameters' =>			['type' => XML_INDEXED_ARRAY, 'prefix' => 'parameter', 'rules' => [
1335										'parameter' =>			['type' => XML_ARRAY, 'rules' => [
1336											'name' =>					['type' => XML_STRING | XML_REQUIRED],
1337											'value' =>					['type' => XML_STRING, 'default' => '']
1338										]]
1339									]],
1340									'posts' =>					['type' => XML_STRING, 'default' => ''],
1341									'status_codes' =>			['type' => XML_STRING, 'default' => '200'],
1342									'follow_redirects' =>		['type' => XML_STRING, 'default' => CXmlConstantValue::YES, 'in' => [CXmlConstantValue::NO => CXmlConstantName::NO, CXmlConstantValue::YES => CXmlConstantName::YES]],
1343									'post_type' =>				['type' => XML_STRING, 'default' => CXmlConstantValue::RAW, 'in' => $this->ITEM_POST_TYPE],
1344									'http_proxy' =>				['type' => XML_STRING, 'default' => ''],
1345									'headers' =>				['type' => XML_INDEXED_ARRAY, 'prefix' => 'header', 'rules' => [
1346										'header' =>					['type' => XML_ARRAY, 'rules' => [
1347											'name' =>					['type' => XML_STRING | XML_REQUIRED],
1348											'value' =>					['type' => XML_STRING | XML_REQUIRED]
1349										]]
1350									]],
1351									'retrieve_mode' =>			['type' => XML_STRING, 'default' => CXmlConstantValue::BODY, 'in' => $this->ITEM_RETRIEVE_MODE],
1352									'request_method' =>			['type' => XML_STRING, 'default' => CXmlConstantValue::GET, 'in' => $this->ITEM_REQUEST_METHOD],
1353									'output_format' =>			['type' => XML_STRING, 'default' => CXmlConstantValue::OUTPUT_FORMAT_RAW, 'in' => [CXmlConstantValue::OUTPUT_FORMAT_RAW => CXmlConstantName::RAW, CXmlConstantValue::OUTPUT_FORMAT_JSON => CXmlConstantName::JSON]],
1354									'allow_traps' =>			['type' => XML_STRING, 'default' => CXmlConstantValue::NO, 'in' => [CXmlConstantValue::NO => CXmlConstantName::NO, CXmlConstantValue::YES => CXmlConstantName::YES]],
1355									'ssl_cert_file' =>			['type' => XML_STRING, 'default' => ''],
1356									'ssl_key_file' =>			['type' => XML_STRING, 'default' => ''],
1357									'ssl_key_password' =>		['type' => XML_STRING, 'default' => ''],
1358									'verify_peer' =>			['type' => XML_STRING, 'default' => CXmlConstantValue::NO, 'in' => [CXmlConstantValue::NO => CXmlConstantName::NO, CXmlConstantValue::YES => CXmlConstantName::YES]],
1359									'verify_host' =>			['type' => XML_STRING, 'default' => CXmlConstantValue::NO, 'in' => [CXmlConstantValue::NO => CXmlConstantName::NO, CXmlConstantValue::YES => CXmlConstantName::YES]],
1360									'tags' =>					['type' => XML_INDEXED_ARRAY, 'prefix' => 'tag', 'rules' => [
1361										'tag' =>					['type' => XML_ARRAY, 'rules' => [
1362											'tag' =>					['type' => XML_STRING | XML_REQUIRED],
1363											'value' =>					['type' => XML_STRING, 'default' => '']
1364										]]
1365									]],
1366									'trigger_prototypes' =>		['type' => XML_INDEXED_ARRAY, 'prefix' => 'trigger_prototype', 'rules' => [
1367										'trigger_prototype' =>		['type' => XML_ARRAY, 'rules' => [
1368											'uuid' =>					['type' => XML_STRING | XML_REQUIRED, 'flags' => CImportDataNormalizer::LOWERCASE],
1369											'expression' =>				['type' => XML_STRING | XML_REQUIRED],
1370											'recovery_mode' =>			['type' => XML_STRING, 'default' => CXmlConstantValue::TRIGGER_EXPRESSION, 'in' => $this->TRIGGER_RECOVERY_MODE],
1371											'recovery_expression' =>	['type' => XML_STRING, 'default' => ''],
1372											'correlation_mode' =>		['type' => XML_STRING, 'default' => CXmlConstantValue::TRIGGER_DISABLED, 'in' => [CXmlConstantValue::TRIGGER_DISABLED => CXmlConstantName::DISABLED, CXmlConstantValue::TRIGGER_TAG_VALUE => CXmlConstantName::TAG_VALUE]],
1373											'correlation_tag' =>		['type' => XML_STRING, 'default' => ''],
1374											'name' =>					['type' => XML_STRING | XML_REQUIRED],
1375											'event_name' =>				['type' => XML_STRING, 'default' => ''],
1376											'opdata' =>					['type' => XML_STRING, 'default' => ''],
1377											'url' =>					['type' => XML_STRING, 'default' => ''],
1378											'status' =>					['type' => XML_STRING, 'default' => CXmlConstantValue::ENABLED, 'in' => [CXmlConstantValue::ENABLED => CXmlConstantName::ENABLED, CXmlConstantValue::DISABLED => CXmlConstantName::DISABLED]],
1379											'discover' =>				['type' => XML_STRING, 'default' => CXmlConstantValue::TRIGGER_DISCOVER, 'in' => [CXmlConstantValue::TRIGGER_DISCOVER => CXmlConstantName::DISCOVER, CXmlConstantValue::TRIGGER_NO_DISCOVER => CXmlConstantName::NO_DISCOVER]],
1380											'priority' =>				['type' => XML_STRING, 'default' => CXmlConstantValue::NOT_CLASSIFIED, 'in' => $this->TRIGGER_PRIORITY],
1381											'description' =>			['type' => XML_STRING, 'default' => ''],
1382											'type' =>					['type' => XML_STRING, 'default' => CXmlConstantValue::SINGLE, 'in' => [CXmlConstantValue::SINGLE => CXmlConstantName::SINGLE, CXmlConstantValue::MULTIPLE => CXmlConstantName::MULTIPLE]],
1383											'manual_close' =>			['type' => XML_STRING, 'default' => CXmlConstantValue::NO, 'in' => [CXmlConstantValue::NO => CXmlConstantName::NO, CXmlConstantValue::YES => CXmlConstantName::YES]],
1384											'dependencies' =>			['type' => XML_INDEXED_ARRAY, 'prefix' => 'dependency', 'rules' => [
1385												'dependency' =>				['type' => XML_ARRAY, 'rules' => [
1386													'name' =>					['type' => XML_STRING | XML_REQUIRED],
1387													'expression' =>				['type' => XML_STRING | XML_REQUIRED],
1388													'recovery_expression' =>	['type' => XML_STRING, 'default' => '']
1389												]]
1390											]],
1391											'tags' =>					['type' => XML_INDEXED_ARRAY, 'prefix' => 'tag', 'rules' => [
1392												'tag' =>					['type' => XML_ARRAY, 'rules' => [
1393													'tag' =>					['type' => XML_STRING | XML_REQUIRED],
1394													'value' =>					['type' => XML_STRING, 'default' => '']
1395												]]
1396											]]
1397										]]
1398									]]
1399								]]
1400							]],
1401							'trigger_prototypes' =>		['type' => XML_INDEXED_ARRAY, 'prefix' => 'trigger_prototype', 'rules' => [
1402								'trigger_prototype' =>		['type' => XML_ARRAY, 'rules' => [
1403									'uuid' =>					['type' => XML_STRING | XML_REQUIRED, 'flags' => CImportDataNormalizer::LOWERCASE],
1404									'expression' =>				['type' => XML_STRING | XML_REQUIRED],
1405									'recovery_mode' =>			['type' => XML_STRING, 'default' => CXmlConstantValue::TRIGGER_EXPRESSION, 'in' => $this->TRIGGER_RECOVERY_MODE],
1406									'recovery_expression' =>	['type' => XML_STRING, 'default' => ''],
1407									'correlation_mode' =>		['type' => XML_STRING, 'default' => CXmlConstantValue::TRIGGER_DISABLED, 'in' => [CXmlConstantValue::TRIGGER_DISABLED => CXmlConstantName::DISABLED, CXmlConstantValue::TRIGGER_TAG_VALUE => CXmlConstantName::TAG_VALUE]],
1408									'correlation_tag' =>		['type' => XML_STRING, 'default' => ''],
1409									'name' =>					['type' => XML_STRING | XML_REQUIRED],
1410									'event_name' =>				['type' => XML_STRING, 'default' => ''],
1411									'opdata' =>					['type' => XML_STRING, 'default' => ''],
1412									'url' =>					['type' => XML_STRING, 'default' => ''],
1413									'status' =>					['type' => XML_STRING, 'default' => CXmlConstantValue::ENABLED, 'in' => [CXmlConstantValue::ENABLED => CXmlConstantName::ENABLED, CXmlConstantValue::DISABLED => CXmlConstantName::DISABLED]],
1414									'discover' =>				['type' => XML_STRING, 'default' => CXmlConstantValue::TRIGGER_DISCOVER, 'in' => [CXmlConstantValue::TRIGGER_DISCOVER => CXmlConstantName::DISCOVER, CXmlConstantValue::TRIGGER_NO_DISCOVER => CXmlConstantName::NO_DISCOVER]],
1415									'priority' =>				['type' => XML_STRING, 'default' => CXmlConstantValue::NOT_CLASSIFIED, 'in' => $this->TRIGGER_PRIORITY],
1416									'description' =>			['type' => XML_STRING, 'default' => ''],
1417									'type' =>					['type' => XML_STRING, 'default' => CXmlConstantValue::SINGLE, 'in' => [CXmlConstantValue::SINGLE => CXmlConstantName::SINGLE, CXmlConstantValue::MULTIPLE => CXmlConstantName::MULTIPLE]],
1418									'manual_close' =>			['type' => XML_STRING, 'default' => CXmlConstantValue::NO, 'in' => [CXmlConstantValue::NO => CXmlConstantName::NO, CXmlConstantValue::YES => CXmlConstantName::YES]],
1419									'dependencies' =>			['type' => XML_INDEXED_ARRAY, 'prefix' => 'dependency', 'rules' => [
1420										'dependency' =>				['type' => XML_ARRAY, 'rules' => [
1421											'name' =>					['type' => XML_STRING | XML_REQUIRED],
1422											'expression' =>				['type' => XML_STRING | XML_REQUIRED],
1423											'recovery_expression' =>	['type' => XML_STRING, 'default' => '']
1424										]]
1425									]],
1426									'tags' =>					['type' => XML_INDEXED_ARRAY, 'prefix' => 'tag', 'rules' => [
1427										'tag' =>					['type' => XML_ARRAY, 'rules' => [
1428											'tag' =>					['type' => XML_STRING | XML_REQUIRED],
1429											'value' =>					['type' => XML_STRING, 'default' => '']
1430										]]
1431									]]
1432								]]
1433							]],
1434							'graph_prototypes' =>		['type' => XML_INDEXED_ARRAY, 'prefix' => 'graph_prototype', 'rules' => [
1435								'graph_prototype' =>		['type' => XML_ARRAY, 'rules' => [
1436									'uuid' =>					['type' => XML_STRING | XML_REQUIRED, 'flags' => CImportDataNormalizer::LOWERCASE],
1437									'name' =>					['type' => XML_STRING | XML_REQUIRED],
1438									'width' =>					['type' => XML_STRING, 'default' => '900'],
1439									'height' =>					['type' => XML_STRING, 'default' => '200'],
1440									'yaxismin' =>				['type' => XML_STRING, 'default' => '0'],
1441									'yaxismax' =>				['type' => XML_STRING, 'default' => '100'],
1442									'show_work_period' =>		['type' => XML_STRING, 'default' => CXmlConstantValue::YES, 'in' => [CXmlConstantValue::NO => CXmlConstantName::NO, CXmlConstantValue::YES => CXmlConstantName::YES]],
1443									'show_triggers' =>			['type' => XML_STRING, 'default' => CXmlConstantValue::YES, 'in' => [CXmlConstantValue::NO => CXmlConstantName::NO, CXmlConstantValue::YES => CXmlConstantName::YES]],
1444									'type' =>					['type' => XML_STRING, 'default' => CXmlConstantValue::NORMAL, 'in' => $this->GRAPH_TYPE],
1445									'show_legend' =>			['type' => XML_STRING, 'default' => CXmlConstantValue::YES, 'in' => [CXmlConstantValue::NO => CXmlConstantName::NO, CXmlConstantValue::YES => CXmlConstantName::YES]],
1446									'show_3d' =>				['type' => XML_STRING, 'default' => CXmlConstantValue::NO, 'in' => [CXmlConstantValue::NO => CXmlConstantName::NO, CXmlConstantValue::YES => CXmlConstantName::YES]],
1447									'percent_left' =>			['type' => XML_STRING, 'default' => '0'],
1448									'percent_right' =>			['type' => XML_STRING, 'default' => '0'],
1449									// The tag 'ymin_type_1' should be validated before the 'ymin_item_1' because it is used in 'ex_validate' method.
1450									'ymin_type_1' =>			['type' => XML_STRING, 'default' => CXmlConstantValue::CALCULATED, 'in' => $this->GRAPH_Y_TYPE],
1451									'ymin_item_1' =>			['type' => 0, 'default' => '0', 'preprocessor' => [$this, 'transformZero2Array'], 'ex_validate' => [$this, 'validateYMinItem'], 'export' => [$this, 'graphMinItemExport']],
1452									// The tag 'ymax_type_1' should be validated before the 'ymax_item_1' because it is used in 'ex_validate' method.
1453									'ymax_type_1' =>			['type' => XML_STRING, 'default' => CXmlConstantValue::CALCULATED, 'in' => $this->GRAPH_Y_TYPE],
1454									'ymax_item_1' =>			['type' => 0, 'default' => '0', 'preprocessor' => [$this, 'transformZero2Array'], 'ex_validate' => [$this, 'validateYMaxItem'], 'export' => [$this, 'graphMaxItemExport']],
1455									'graph_items' =>			['type' => XML_INDEXED_ARRAY | XML_REQUIRED, 'prefix' => 'graph_item', 'ex_validate' => [$this, 'validateGraphItems'], 'rules' => [
1456										'graph_item' =>				['type' => XML_ARRAY, 'rules' => [
1457											'sortorder' =>				['type' => XML_STRING, 'default' => '0'],
1458											'drawtype' =>				['type' => XML_STRING, 'default' => CXmlConstantValue::SINGLE_LINE, 'in' => $this->GRAPH_GRAPH_ITEM_DRAWTYPE],
1459											'color' =>					['type' => XML_STRING, 'default' => '009600'],
1460											'yaxisside' =>				['type' => XML_STRING, 'default' => CXmlConstantValue::LEFT, 'in' => $this->GRAPH_GRAPH_ITEM_YAXISSIDE],
1461											'calc_fnc' =>				['type' => XML_STRING, 'default' => CXmlConstantValue::AVG, 'in' => $this->GRAPH_GRAPH_ITEM_CALC_FNC],
1462											'type' =>					['type' => XML_STRING, 'default' => CXmlConstantValue::SIMPLE, 'in' => $this->GRAPH_GRAPH_ITEM_TYPE],
1463											'item' =>					['type' => XML_ARRAY | XML_REQUIRED, 'rules' => [
1464												'host' =>					['type' => XML_STRING | XML_REQUIRED],
1465												'key' =>					['type' => XML_STRING | XML_REQUIRED]
1466											]]
1467										]]
1468									]],
1469									'discover' =>				['type' => XML_STRING, 'default' => CXmlConstantValue::GRAPH_DISCOVER, 'in' => [CXmlConstantValue::GRAPH_DISCOVER => CXmlConstantName::DISCOVER, CXmlConstantValue::GRAPH_NO_DISCOVER => CXmlConstantName::NO_DISCOVER]]
1470								]]
1471							]],
1472							'host_prototypes' =>		['type' => XML_INDEXED_ARRAY, 'prefix' => 'host_prototype', 'rules' => [
1473								'host_prototype' =>			['type' => XML_ARRAY, 'rules' => [
1474									'uuid' =>					['type' => XML_STRING | XML_REQUIRED, 'flags' => CImportDataNormalizer::LOWERCASE],
1475									'host' =>					['type' => XML_STRING | XML_REQUIRED],
1476									'name' =>					['type' => XML_STRING, 'default' => ''],
1477									'status' =>					['type' => XML_STRING, 'default' => CXmlConstantValue::ENABLED, 'in' => [CXmlConstantValue::ENABLED => CXmlConstantName::ENABLED, CXmlConstantValue::DISABLED => CXmlConstantName::DISABLED]],
1478									'discover' =>				['type' => XML_STRING, 'default' => CXmlConstantValue::HOST_DISCOVER, 'in' => [CXmlConstantValue::HOST_DISCOVER => CXmlConstantName::DISCOVER, CXmlConstantValue::HOST_NO_DISCOVER => CXmlConstantName::NO_DISCOVER]],
1479									'group_links' =>			['type' => XML_INDEXED_ARRAY, 'prefix' => 'group_link', 'rules' => [
1480										'group_link' =>				['type' => XML_ARRAY, 'rules' => [
1481											'group' =>					['type' => XML_ARRAY | XML_REQUIRED, 'rules' => [
1482												'name' =>					['type' => XML_STRING | XML_REQUIRED]
1483											]]
1484										]]
1485									]],
1486									'group_prototypes' =>		['type' => XML_INDEXED_ARRAY, 'prefix' => 'group_prototype', 'rules' => [
1487										'group_prototype' =>		['type' => XML_ARRAY, 'rules' => [
1488											'name' =>					['type' => XML_STRING | XML_REQUIRED]
1489										]]
1490									]],
1491									'templates' =>				['type' => XML_INDEXED_ARRAY, 'prefix' => 'template', 'rules' => [
1492										'template' =>				['type' => XML_ARRAY, 'rules' => [
1493											'name' =>					['type' => XML_STRING | XML_REQUIRED]
1494										]]
1495									]],
1496									'macros' =>					['type' => XML_INDEXED_ARRAY, 'prefix' => 'macro', 'rules' => [
1497										'macro' =>					['type' => XML_ARRAY, 'rules' => [
1498											'macro' =>					['type' => XML_STRING | XML_REQUIRED],
1499											'type' =>					['type' => XML_STRING, 'default' => CXmlConstantValue::MACRO_TYPE_TEXT, 'in' => [CXmlConstantValue::MACRO_TYPE_TEXT => CXmlConstantName::MACRO_TYPE_TEXT, CXmlConstantValue::MACRO_TYPE_SECRET => CXmlConstantName::MACRO_TYPE_SECRET, CXmlConstantValue::MACRO_TYPE_VAULT => CXmlConstantName::MACRO_TYPE_VAULT]],
1500											'value' =>					['type' => XML_STRING, 'default' => ''],
1501											'description' =>			['type' => XML_STRING, 'default' => '']
1502										]]
1503									]],
1504									'tags' =>					['type' => XML_INDEXED_ARRAY, 'prefix' => 'tag', 'rules' => [
1505										'tag' =>					['type' => XML_ARRAY, 'rules' => [
1506											'tag' =>					['type' => XML_STRING | XML_REQUIRED],
1507											'value' =>					['type' => XML_STRING, 'default' => '']
1508										]]
1509									]],
1510									'custom_interfaces' =>		['type' => XML_STRING, 'default' => CXmlConstantValue::CUSTOM_INTERFACES_NO, 'in' => $this->CUSTOM_INTERFACES],
1511									'interfaces' =>				['type' => XML_INDEXED_ARRAY, 'prefix' => 'interface', 'rules' => [
1512										'interface' =>				['type' => XML_ARRAY, 'rules' => [
1513											'default' =>				['type' => XML_STRING, 'default' => CXmlConstantValue::YES, 'in' => [CXmlConstantValue::NO => CXmlConstantName::NO, CXmlConstantValue::YES => CXmlConstantName::YES]],
1514											'type' =>					['type' => XML_STRING, 'default' => CXmlConstantValue::ZABBIX, 'in' => [CXmlConstantValue::ZABBIX => CXmlConstantName::ZABBIX, CXmlConstantValue::SNMP => CXmlConstantName::SNMP, CXmlConstantValue::IPMI => CXmlConstantName::IPMI, CXmlConstantValue::JMX => CXmlConstantName::JMX]],
1515											'useip' =>					['type' => XML_STRING, 'default' => CXmlConstantValue::YES, 'in' => [CXmlConstantValue::NO => CXmlConstantName::NO, CXmlConstantValue::YES => CXmlConstantName::YES]],
1516											'ip' =>						['type' => XML_STRING, 'default' => '127.0.0.1'],
1517											'dns' =>					['type' => XML_STRING, 'default' => ''],
1518											'port' =>					['type' => XML_STRING, 'default' => '10050'],
1519											'details' =>				['type' => XML_ARRAY, 'rules' => [
1520												'version' =>				['type' => XML_STRING, 'default' => CXmlConstantValue::SNMP_V2, 'in' => [CXmlConstantValue::SNMP_V1 => CXmlConstantName::SNMPV1, CXmlConstantValue::SNMP_V2 => CXmlConstantName::SNMPV2, CXmlConstantValue::SNMP_V3 => CXmlConstantName::SNMPV3]],
1521												'community' =>				['type' => XML_STRING, 'default' => ''],
1522												'contextname' =>			['type' => XML_STRING, 'default' => ''],
1523												'securityname' =>			['type' => XML_STRING, 'default' => ''],
1524												'securitylevel' =>			['type' => XML_STRING, 'default' => CXmlConstantValue::NOAUTHNOPRIV, 'in' => $this->ITEM_SNMPV3_SECURITYLEVEL],
1525												'authprotocol' =>			['type' => XML_STRING, 'default' => CXmlConstantValue::SNMPV3_MD5, 'in' => $this->SNMPV3_AUTHPROTOCOL],
1526												'authpassphrase' =>			['type' => XML_STRING, 'default' => ''],
1527												'privprotocol' =>			['type' => XML_STRING, 'default' => CXmlConstantValue::SNMPV3_DES, 'in' => $this->SNMPV3_PRIVPROTOCOL],
1528												'privpassphrase' =>			['type' => XML_STRING, 'default' => ''],
1529												'bulk' =>					['type' => XML_STRING, 'default' => CXmlConstantValue::YES, 'in' => [CXmlConstantValue::NO => CXmlConstantName::NO, CXmlConstantValue::YES => CXmlConstantName::YES]]
1530											]]
1531										]]
1532									]],
1533									'inventory_mode' =>			['type' => XML_STRING, 'default' => CXmlConstantValue::INV_MODE_DISABLED, 'in' => $this->INVENTORY_MODE]
1534								]]
1535							]],
1536							'jmx_endpoint' =>			['type' => XML_STRING, 'default' => ''],
1537							'master_item' =>			['type' => XML_ARRAY, 'ex_validate' => [$this, 'validateMasterItem'], 'rules' => [
1538								'key' =>					['type' => XML_STRING | XML_REQUIRED]
1539							]],
1540							'timeout' =>				['type' => XML_STRING, 'default' => '3s'],
1541							'url' =>					['type' => XML_STRING, 'default' => ''],
1542							'query_fields' =>			['type' => XML_INDEXED_ARRAY, 'prefix' => 'query_field', 'rules' => [
1543								'query_field' =>			['type' => XML_ARRAY, 'rules' => [
1544									'name' =>					['type' => XML_STRING | XML_REQUIRED],
1545									'value' =>					['type' => XML_STRING, 'default' => '']
1546								]]
1547							]],
1548							'parameters' =>			['type' => XML_INDEXED_ARRAY, 'prefix' => 'parameter', 'rules' => [
1549								'parameter' =>			['type' => XML_ARRAY, 'rules' => [
1550									'name' =>					['type' => XML_STRING | XML_REQUIRED],
1551									'value' =>					['type' => XML_STRING, 'default' => '']
1552								]]
1553							]],
1554							'posts' =>					['type' => XML_STRING, 'default' => ''],
1555							'status_codes' =>			['type' => XML_STRING, 'default' => '200'],
1556							'follow_redirects' =>		['type' => XML_STRING, 'default' => CXmlConstantValue::YES, 'in' => [CXmlConstantValue::NO => CXmlConstantName::NO, CXmlConstantValue::YES => CXmlConstantName::YES]],
1557							'post_type' =>				['type' => XML_STRING, 'default' => CXmlConstantValue::RAW, 'in' => $this->ITEM_POST_TYPE],
1558							'http_proxy' =>				['type' => XML_STRING, 'default' => ''],
1559							'headers' =>				['type' => XML_INDEXED_ARRAY, 'prefix' => 'header', 'rules' => [
1560								'header' =>					['type' => XML_ARRAY, 'rules' => [
1561									'name' =>					['type' => XML_STRING | XML_REQUIRED],
1562									'value' =>					['type' => XML_STRING | XML_REQUIRED]
1563								]]
1564							]],
1565							'retrieve_mode' =>			['type' => XML_STRING, 'default' => CXmlConstantValue::BODY, 'in' => $this->ITEM_RETRIEVE_MODE],
1566							'request_method' =>			['type' => XML_STRING, 'default' => CXmlConstantValue::GET, 'in' => $this->ITEM_REQUEST_METHOD],
1567							'allow_traps' =>			['type' => XML_STRING, 'default' => CXmlConstantValue::NO, 'in' => [CXmlConstantValue::NO => CXmlConstantName::NO, CXmlConstantValue::YES => CXmlConstantName::YES]],
1568							'ssl_cert_file' =>			['type' => XML_STRING, 'default' => ''],
1569							'ssl_key_file' =>			['type' => XML_STRING, 'default' => ''],
1570							'ssl_key_password' =>		['type' => XML_STRING, 'default' => ''],
1571							'verify_peer' =>			['type' => XML_STRING, 'default' => CXmlConstantValue::NO, 'in' => [CXmlConstantValue::NO => CXmlConstantName::NO, CXmlConstantValue::YES => CXmlConstantName::YES]],
1572							'verify_host' =>			['type' => XML_STRING, 'default' => CXmlConstantValue::NO, 'in' => [CXmlConstantValue::NO => CXmlConstantName::NO, CXmlConstantValue::YES => CXmlConstantName::YES]],
1573							'lld_macro_paths' =>		['type' => XML_INDEXED_ARRAY, 'prefix' => 'lld_macro_path', 'rules' => [
1574								'lld_macro_path' =>			['type' => XML_ARRAY, 'rules' => [
1575									'lld_macro' =>				['type' => XML_STRING | XML_REQUIRED],
1576									'path' =>					['type' => XML_STRING | XML_REQUIRED]
1577								]]
1578							]],
1579							'preprocessing' =>			['type' => XML_INDEXED_ARRAY, 'prefix' => 'step', 'rules' => [
1580								'step' =>					['type' => XML_ARRAY, 'rules' => [
1581									'type' =>					['type' => XML_STRING | XML_REQUIRED, 'in' => $this->PREPROCESSING_STEP_TYPE_DRULE],
1582									'parameters' =>				['type' => XML_INDEXED_ARRAY | XML_REQUIRED, 'prefix' => 'parameter', 'export' => [$this, 'preprocessingParametersExport'], 'rules' => [
1583										'parameter' =>				['type' => XML_STRING, 'flags' => CImportDataNormalizer::EOL_LF]
1584									]],
1585									'error_handler' =>			['type' => XML_STRING, 'ex_default' => [$this, 'defaultPreprocErrHandler'], 'ex_validate' => [$this, 'validatePreprocErrHandler'], 'in' => $this->ITEM_PREPROCESSING_ERROR_HANDLER],
1586									'error_handler_params' =>	['type' => XML_STRING, 'default' => '']
1587								]]
1588							]],
1589							'overrides'	=>				['type' => XML_INDEXED_ARRAY, 'prefix' => 'override', 'rules' => [
1590								'override' =>				['type' => XML_ARRAY, 'rules' => [
1591									'name' =>					['type' => XML_STRING | XML_REQUIRED],
1592									'step' =>					['type' => XML_STRING | XML_REQUIRED],
1593									'stop' =>					['type' => XML_STRING, 'default' => CXmlConstantValue::LLD_OVERRIDE_STOP_NO, 'in' => $this->LLD_OVERRIDE_STOP],
1594									'filter' =>					['type' => XML_ARRAY, 'rules' => [
1595										'evaltype' =>				['type' => XML_STRING, 'default' => CXmlConstantValue::AND_OR, 'in' => $this->EVALTPYE],
1596										'formula' =>				['type' => XML_STRING, 'default' => ''],
1597										'conditions' =>				['type' => XML_INDEXED_ARRAY | XML_REQUIRED, 'prefix' => 'condition', 'rules' => [
1598											'condition' =>				['type' => XML_ARRAY | XML_REQUIRED, 'rules' => [
1599												'macro' =>					['type' => XML_STRING | XML_REQUIRED],
1600												'value' =>					['type' => XML_STRING, 'default' => ''],
1601												'operator' =>				['type' => XML_STRING, 'default' => CXmlConstantValue::CONDITION_MATCHES_REGEX, 'in' => $this->FILTER_CONDITION_OPERATOR],
1602												'formulaid' =>				['type' => XML_STRING | XML_REQUIRED]
1603											]]
1604										]]
1605									]],
1606									'operations' =>				['type' => XML_INDEXED_ARRAY, 'prefix' => 'operation', 'rules' => [
1607										'operation' =>				['type' => XML_ARRAY, 'rules' => [
1608											'operationobject' =>		['type' => XML_STRING, 'in' => $this->LLD_OVERRIDE_OPERATION_OBJECT],
1609											'operator' =>				['type' => XML_STRING, 'default' => CXmlConstantValue::CONDITION_OPERATOR_EQUAL, 'in' => $this->CONDITION_OPERATOR],
1610											'value' =>					['type' => XML_STRING, 'default' => ''],
1611											'status' =>					['type' => XML_STRING, 'in' => [CXmlConstantValue::LLD_OVERRIDE_OPERATION_STATUS_ENABLED => CXmlConstantName::ENABLED, CXmlConstantValue::LLD_OVERRIDE_OPERATION_STATUS_DISABLED => CXmlConstantName::DISABLED]],
1612											'discover' =>				['type' => XML_STRING, 'in' => [CXmlConstantValue::LLD_OVERRIDE_OPERATION_DISCOVER => CXmlConstantName::DISCOVER, CXmlConstantValue::LLD_OVERRIDE_OPERATION_NO_DISCOVER => CXmlConstantName::NO_DISCOVER]],
1613											'delay' =>					['type' => XML_STRING, 'default' => ''],
1614											'history' =>				['type' => XML_STRING, 'default' => ''],
1615											'trends' =>					['type' => XML_STRING, 'default' => ''],
1616											'severity' =>				['type' => XML_STRING, 'in' => $this->TRIGGER_PRIORITY],
1617											'tags' =>					['type' => XML_INDEXED_ARRAY, 'prefix' => 'tag', 'rules' => [
1618												'tag' =>					['type' => XML_ARRAY, 'rules' => [
1619													'tag' =>					['type' => XML_STRING | XML_REQUIRED],
1620													'value' =>					['type' => XML_STRING, 'default' => '']
1621												]]
1622											]],
1623											'templates' =>				['type' => XML_INDEXED_ARRAY, 'prefix' => 'template', 'rules' => [
1624												'template' =>				['type' => XML_ARRAY, 'rules' => [
1625													'name' =>					['type' => XML_STRING | XML_REQUIRED]
1626												]]
1627											]],
1628											'inventory_mode' =>			['type' => XML_STRING, 'in' => $this->INVENTORY_MODE]
1629										]]
1630									]]
1631								]]
1632							]]
1633						]]
1634					]],
1635					'httptests' =>				['type' => XML_INDEXED_ARRAY, 'prefix' => 'httptest', 'rules' => [
1636						'httptest' =>				['type' => XML_ARRAY, 'rules' => [
1637							'uuid' =>					['type' => XML_STRING | XML_REQUIRED, 'flags' => CImportDataNormalizer::LOWERCASE],
1638							'name' =>					['type' => XML_STRING | XML_REQUIRED],
1639							'delay' =>					['type' => XML_STRING, 'default' => '1m'],
1640							'attempts' =>				['type' => XML_STRING, 'default' => '1'],
1641							'agent' =>					['type' => XML_STRING, 'default' => 'Zabbix'],
1642							'http_proxy' =>				['type' => XML_STRING, 'default' => ''],
1643							'variables' =>				['type' => XML_INDEXED_ARRAY, 'prefix' => 'variable', 'rules' => [
1644								'variable' =>				['type' => XML_ARRAY, 'rules' => [
1645									'name' =>					['type' => XML_STRING | XML_REQUIRED],
1646									'value' =>					['type' => XML_STRING | XML_REQUIRED]
1647								]]
1648							]],
1649							'headers' =>				['type' => XML_INDEXED_ARRAY, 'prefix' => 'header', 'rules' => [
1650								'header' =>					['type' => XML_ARRAY, 'rules' => [
1651									'name' =>					['type' => XML_STRING | XML_REQUIRED],
1652									'value' =>					['type' => XML_STRING | XML_REQUIRED]
1653								]]
1654							]],
1655							'status' =>					['type' => XML_STRING, 'default' => CXmlConstantValue::ENABLED, 'in' => [CXmlConstantValue::ENABLED => CXmlConstantName::ENABLED, CXmlConstantValue::DISABLED => CXmlConstantName::DISABLED]],
1656							'authentication' =>			['type' => XML_STRING, 'default' => CXmlConstantValue::NONE, 'in' => $this->HTTP_TEST_AUTHENTICATION],
1657							'http_user' =>				['type' => XML_STRING, 'default' => ''],
1658							'http_password' =>			['type' => XML_STRING, 'default' => ''],
1659							'verify_peer' =>			['type' => XML_STRING, 'default' => CXmlConstantValue::NO, 'in' => [CXmlConstantValue::NO => CXmlConstantName::NO, CXmlConstantValue::YES => CXmlConstantName::YES]],
1660							'verify_host' =>			['type' => XML_STRING, 'default' => CXmlConstantValue::NO, 'in' => [CXmlConstantValue::NO => CXmlConstantName::NO, CXmlConstantValue::YES => CXmlConstantName::YES]],
1661							'ssl_cert_file' =>			['type' => XML_STRING, 'default' => ''],
1662							'ssl_key_file' =>			['type' => XML_STRING, 'default' => ''],
1663							'ssl_key_password' =>		['type' => XML_STRING, 'default' => ''],
1664							'steps' =>					['type' => XML_INDEXED_ARRAY | XML_REQUIRED, 'prefix' => 'step', 'rules' => [
1665								'step' =>					['type' => XML_ARRAY, 'rules' => [
1666									'name' =>					['type' => XML_STRING | XML_REQUIRED],
1667									'url' =>					['type' => XML_STRING | XML_REQUIRED],
1668									'query_fields' =>			['type' => XML_INDEXED_ARRAY, 'prefix' => 'query_field', 'rules' => [
1669										'query_field' =>			['type' => XML_ARRAY, 'rules' => [
1670											'name' =>					['type' => XML_STRING | XML_REQUIRED],
1671											'value' =>					['type' => XML_STRING, 'default' => '']
1672										]]
1673									]],
1674									'posts' =>					['type' => 0, 'ex_validate' => [$this, 'validateHttpPosts']],
1675									'variables' =>				['type' => XML_INDEXED_ARRAY, 'prefix' => 'variable', 'rules' => [
1676										'variable' =>				['type' => XML_ARRAY, 'rules' => [
1677											'name' =>					['type' => XML_STRING | XML_REQUIRED],
1678											'value' =>					['type' => XML_STRING | XML_REQUIRED]
1679										]]
1680									]],
1681									'headers' =>				['type' => XML_INDEXED_ARRAY, 'prefix' => 'header', 'rules' => [
1682										'header' =>					['type' => XML_ARRAY, 'rules' => [
1683											'name' =>					['type' => XML_STRING | XML_REQUIRED],
1684											'value' =>					['type' => XML_STRING | XML_REQUIRED]
1685										]]
1686									]],
1687									'follow_redirects' =>		['type' => XML_STRING, 'default' => CXmlConstantValue::YES, 'in' => [CXmlConstantValue::NO => CXmlConstantName::NO, CXmlConstantValue::YES => CXmlConstantName::YES]],
1688									'retrieve_mode' =>			['type' => XML_STRING, 'default' => CXmlConstantValue::BODY, 'in' => $this->ITEM_RETRIEVE_MODE],
1689									'timeout' =>				['type' => XML_STRING, 'default' => '15s'],
1690									'required' =>				['type' => XML_STRING, 'default' => ''],
1691									'status_codes' =>			['type' => XML_STRING, 'default' => '']
1692								]]
1693							]],
1694							'tags' =>					['type' => XML_INDEXED_ARRAY, 'prefix' => 'tag', 'rules' => [
1695								'tag' =>					['type' => XML_ARRAY, 'rules' => [
1696									'tag' =>					['type' => XML_STRING | XML_REQUIRED],
1697									'value' =>					['type' => XML_STRING, 'default' => '']
1698								]]
1699							]]
1700						]]
1701					]],
1702					'tags' =>					['type' => XML_INDEXED_ARRAY, 'prefix' => 'tag', 'rules' => [
1703						'tag' =>					['type' => XML_ARRAY, 'rules' => [
1704							'tag' =>					['type' => XML_STRING | XML_REQUIRED],
1705							'value' =>					['type' => XML_STRING, 'default' => '']
1706						]]
1707					]],
1708					'macros' =>					['type' => XML_INDEXED_ARRAY, 'prefix' => 'macro', 'rules' => [
1709						'macro' =>					['type' => XML_ARRAY, 'rules' => [
1710							'macro' =>					['type' => XML_STRING | XML_REQUIRED],
1711							'type' =>					['type' => XML_STRING, 'default' => CXmlConstantValue::MACRO_TYPE_TEXT, 'in' => [CXmlConstantValue::MACRO_TYPE_TEXT => CXmlConstantName::MACRO_TYPE_TEXT, CXmlConstantValue::MACRO_TYPE_SECRET => CXmlConstantName::MACRO_TYPE_SECRET, CXmlConstantValue::MACRO_TYPE_VAULT => CXmlConstantName::MACRO_TYPE_VAULT]],
1712							'value' =>					['type' => XML_STRING, 'default' => ''],
1713							'description' =>			['type' => XML_STRING, 'default' => '']
1714						]]
1715					]],
1716					'dashboards' =>				['type' => XML_INDEXED_ARRAY, 'prefix' => 'dashboard', 'rules' => [
1717						'dashboard' =>				['type' => XML_ARRAY, 'rules' => [
1718							'uuid' =>					['type' => XML_STRING | XML_REQUIRED, 'flags' => CImportDataNormalizer::LOWERCASE],
1719							'name' =>					['type' => XML_STRING | XML_REQUIRED],
1720							'display_period' =>				['type' => XML_STRING, 'default' => '30'],
1721							'auto_start' =>					['type' => XML_STRING, 'default' => CXmlConstantValue::YES, 'in' => [CXmlConstantValue::NO => CXmlConstantName::NO, CXmlConstantValue::YES => CXmlConstantName::YES]],
1722							'pages' =>						['type' => XML_INDEXED_ARRAY, 'prefix' => 'page', 'rules' => [
1723								'page' =>						['type' => XML_ARRAY, 'rules' => [
1724									'name' =>						['type' => XML_STRING, 'default' => ''],
1725									'display_period' =>				['type' => XML_STRING, 'default' => '0'],
1726									'widgets' =>					['type' => XML_INDEXED_ARRAY, 'prefix' => 'widget', 'rules' => [
1727										'widget' =>						['type' => XML_ARRAY, 'rules' => [
1728											'type' =>						['type' => XML_STRING | XML_REQUIRED, 'in' => $this->DASHBOARD_WIDGET_TYPE],
1729											'name' =>						['type' => XML_STRING, 'default' => ''],
1730											'x' =>							['type' => XML_STRING, 'default' => '0'],
1731											'y' =>							['type' => XML_STRING, 'default' => '0'],
1732											'width' =>						['type' => XML_STRING, 'default' => '1'],
1733											'height' =>						['type' => XML_STRING, 'default' => '2'],
1734											'hide_header' =>				['type' => XML_STRING, 'default' => CXmlConstantValue::NO, 'in' => [CXmlConstantValue::NO => CXmlConstantName::NO, CXmlConstantValue::YES => CXmlConstantName::YES]],
1735											'fields' =>						['type' => XML_INDEXED_ARRAY, 'prefix' => 'field', 'rules' => [
1736												'field' =>						['type' => XML_ARRAY, 'rules' => [
1737													'type' =>						['type' => XML_STRING | XML_REQUIRED, 'in' => $this->DASHBOARD_WIDGET_FIELD_TYPE],
1738													'name' =>						['type' => XML_STRING | XML_REQUIRED],
1739													'value' =>						['type' => XML_REQUIRED, 'ex_validate' => [$this, 'validateWidgetFieldValue'], 'ex_rules' => [$this, 'getWidgetFieldValueExtendedRules']]
1740												]]
1741											]]
1742										]]
1743									]]
1744								]]
1745							]]
1746						]]
1747					]],
1748					'valuemaps' =>				['type' => XML_INDEXED_ARRAY, 'prefix' => 'valuemap', 'rules' => [
1749						'valuemap' =>				['type' => XML_ARRAY, 'rules' => [
1750							'uuid' =>					['type' => XML_STRING | XML_REQUIRED, 'flags' => CImportDataNormalizer::LOWERCASE],
1751							'name' =>					['type' => XML_STRING | XML_REQUIRED],
1752							'mappings' =>				['type' => XML_INDEXED_ARRAY | XML_REQUIRED, 'prefix' => 'mapping', 'rules' => [
1753								'mapping' =>				['type' => XML_ARRAY, 'rules' => [
1754									'type' =>					['type' => XML_STRING, 'default' => CXmlConstantValue::MAPPING_EQUAL, 'in' => $this->VALUEMAP_MAPPING_TYPE],
1755									'value' =>					['type' => XML_STRING, 'default' => ''],
1756									'newvalue' =>				['type' => XML_STRING | XML_REQUIRED]
1757								]]
1758							]]
1759						]]
1760					]]
1761				]]
1762			]],
1763			'triggers' =>				['type' => XML_INDEXED_ARRAY, 'prefix' => 'trigger', 'rules' => [
1764				'trigger' =>				['type' => XML_ARRAY, 'rules' => [
1765					'uuid' =>					['type' => XML_STRING, 'flags' => CImportDataNormalizer::LOWERCASE],
1766					'expression' =>				['type' => XML_STRING | XML_REQUIRED],
1767					'recovery_mode' =>			['type' => XML_STRING, 'default' => CXmlConstantValue::TRIGGER_EXPRESSION, 'in' => $this->TRIGGER_RECOVERY_MODE],
1768					'recovery_expression' =>	['type' => XML_STRING, 'default' => ''],
1769					'correlation_mode' =>		['type' => XML_STRING, 'default' => CXmlConstantValue::TRIGGER_DISABLED, 'in' => [CXmlConstantValue::TRIGGER_DISABLED => CXmlConstantName::DISABLED, CXmlConstantValue::TRIGGER_TAG_VALUE => CXmlConstantName::TAG_VALUE]],
1770					'correlation_tag' =>		['type' => XML_STRING, 'default' => ''],
1771					'name' =>					['type' => XML_STRING | XML_REQUIRED],
1772					'event_name' =>				['type' => XML_STRING, 'default' => ''],
1773					'opdata' =>					['type' => XML_STRING, 'default' => ''],
1774					'url' =>					['type' => XML_STRING, 'default' => ''],
1775					'status' =>					['type' => XML_STRING, 'default' => CXmlConstantValue::ENABLED, 'in' => [CXmlConstantValue::ENABLED => CXmlConstantName::ENABLED, CXmlConstantValue::DISABLED => CXmlConstantName::DISABLED]],
1776					'priority' =>				['type' => XML_STRING, 'default' => CXmlConstantValue::NOT_CLASSIFIED, 'in' => $this->TRIGGER_PRIORITY],
1777					'description' =>			['type' => XML_STRING, 'default' => ''],
1778					'type' =>					['type' => XML_STRING, 'default' => CXmlConstantValue::SINGLE, 'in' => [CXmlConstantValue::SINGLE => CXmlConstantName::SINGLE, CXmlConstantValue::MULTIPLE => CXmlConstantName::MULTIPLE]],
1779					'manual_close' =>			['type' => XML_STRING, 'default' => CXmlConstantValue::NO, 'in' => [CXmlConstantValue::NO => CXmlConstantName::NO, CXmlConstantValue::YES => CXmlConstantName::YES]],
1780					'dependencies' =>			['type' => XML_INDEXED_ARRAY, 'prefix' => 'dependency', 'rules' => [
1781						'dependency' =>				['type' => XML_ARRAY, 'rules' => [
1782							'name' =>					['type' => XML_STRING | XML_REQUIRED],
1783							'expression' =>				['type' => XML_STRING | XML_REQUIRED],
1784							'recovery_expression' =>	['type' => XML_STRING, 'default' => '']
1785						]]
1786					]],
1787					'tags' =>					['type' => XML_INDEXED_ARRAY, 'prefix' => 'tag', 'rules' => [
1788						'tag' =>					['type' => XML_ARRAY, 'rules' => [
1789							'tag' =>					['type' => XML_STRING | XML_REQUIRED],
1790							'value' =>					['type' => XML_STRING, 'default' => '']
1791						]]
1792					]]
1793				]]
1794			]],
1795			'graphs' =>					['type' => XML_INDEXED_ARRAY, 'prefix' => 'graph', 'rules' => [
1796				'graph' =>					['type' => XML_ARRAY, 'rules' => [
1797					'uuid' =>					['type' => XML_STRING, 'flags' => CImportDataNormalizer::LOWERCASE],
1798					'name' =>					['type' => XML_STRING | XML_REQUIRED],
1799					'width' =>					['type' => XML_STRING, 'default' => '900'],
1800					'height' =>					['type' => XML_STRING, 'default' => '200'],
1801					'yaxismin' =>				['type' => XML_STRING, 'default' => '0'],
1802					'yaxismax' =>				['type' => XML_STRING, 'default' => '100'],
1803					'show_work_period' =>		['type' => XML_STRING, 'default' => CXmlConstantValue::YES, 'in' => [CXmlConstantValue::NO => CXmlConstantName::NO, CXmlConstantValue::YES => CXmlConstantName::YES]],
1804					'show_triggers' =>			['type' => XML_STRING, 'default' => CXmlConstantValue::YES, 'in' => [CXmlConstantValue::NO => CXmlConstantName::NO, CXmlConstantValue::YES => CXmlConstantName::YES]],
1805					'type' =>					['type' => XML_STRING, 'default' => CXmlConstantValue::NORMAL, 'in' => $this->GRAPH_TYPE],
1806					'show_legend' =>			['type' => XML_STRING, 'default' => CXmlConstantValue::YES, 'in' => [CXmlConstantValue::NO => CXmlConstantName::NO, CXmlConstantValue::YES => CXmlConstantName::YES]],
1807					'show_3d' =>				['type' => XML_STRING, 'default' => CXmlConstantValue::NO, 'in' => [CXmlConstantValue::NO => CXmlConstantName::NO, CXmlConstantValue::YES => CXmlConstantName::YES]],
1808					'percent_left' =>			['type' => XML_STRING, 'default' => '0'],
1809					'percent_right' =>			['type' => XML_STRING, 'default' => '0'],
1810					// The tag 'ymin_type_1' should be validated before the 'ymin_item_1' because it is used in 'ex_validate' method.
1811					'ymin_type_1' =>			['type' => XML_STRING, 'default' => CXmlConstantValue::CALCULATED, 'in' => $this->GRAPH_Y_TYPE],
1812					'ymin_item_1' =>			['type' => 0, 'default' => '0', 'preprocessor' => [$this, 'transformZero2Array'], 'ex_validate' => [$this, 'validateYMinItem'], 'export' => [$this, 'graphMinItemExport']],
1813					// The tag 'ymax_type_1' should be validated before the 'ymax_item_1' because it is used in 'ex_validate' method.
1814					'ymax_type_1' =>			['type' => XML_STRING, 'default' => CXmlConstantValue::CALCULATED, 'in' => $this->GRAPH_Y_TYPE],
1815					'ymax_item_1' =>			['type' => 0, 'default' => '0', 'preprocessor' => [$this, 'transformZero2Array'], 'ex_validate' => [$this, 'validateYMaxItem'], 'export' => [$this, 'graphMaxItemExport']],
1816					'graph_items' =>			['type' => XML_INDEXED_ARRAY | XML_REQUIRED, 'prefix' => 'graph_item', 'ex_validate' => [$this, 'validateGraphItems'], 'rules' => [
1817						'graph_item' =>				['type' => XML_ARRAY, 'rules' => [
1818							'sortorder' =>				['type' => XML_STRING, 'default' => '0'],
1819							'drawtype' =>				['type' => XML_STRING, 'default' => CXmlConstantValue::SINGLE_LINE, 'in' => $this->GRAPH_GRAPH_ITEM_DRAWTYPE],
1820							'color' =>					['type' => XML_STRING, 'default' => '009600'],
1821							'yaxisside' =>				['type' => XML_STRING, 'default' => CXmlConstantValue::LEFT, 'in' => $this->GRAPH_GRAPH_ITEM_YAXISSIDE],
1822							'calc_fnc' =>				['type' => XML_STRING, 'default' => CXmlConstantValue::AVG, 'in' => $this->GRAPH_GRAPH_ITEM_CALC_FNC],
1823							'type' =>					['type' => XML_STRING, 'default' => CXmlConstantValue::SIMPLE, 'in' => $this->GRAPH_GRAPH_ITEM_TYPE],
1824							'item' =>					['type' => XML_ARRAY | XML_REQUIRED, 'rules' => [
1825								'host' =>					['type' => XML_STRING | XML_REQUIRED],
1826								'key' =>					['type' => XML_STRING | XML_REQUIRED]
1827							]]
1828						]]
1829					]]
1830				]]
1831			]],
1832			'images' =>					['type' => XML_INDEXED_ARRAY, 'prefix' => 'image', 'rules' => [
1833				'image' =>					['type' => XML_ARRAY, 'rules' => [
1834					'name' =>					['type' => XML_STRING | XML_REQUIRED],
1835					'imagetype' =>				['type' => XML_STRING | XML_REQUIRED],
1836					'encodedImage' =>			['type' => XML_STRING | XML_REQUIRED]
1837				]]
1838			]],
1839			'maps' =>					['type' => XML_INDEXED_ARRAY, 'prefix' => 'map', 'rules' => [
1840				'map' =>					['type' => XML_ARRAY, 'rules' => [
1841					'name' =>					['type' => XML_STRING | XML_REQUIRED],
1842					'width' =>					['type' => XML_STRING | XML_REQUIRED],
1843					'height' =>					['type' => XML_STRING | XML_REQUIRED],
1844					'label_type' =>				['type' => XML_STRING | XML_REQUIRED],
1845					'label_location' =>			['type' => XML_STRING | XML_REQUIRED],
1846					'highlight' =>				['type' => XML_STRING | XML_REQUIRED],
1847					'expandproblem' =>			['type' => XML_STRING | XML_REQUIRED],
1848					'markelements' =>			['type' => XML_STRING | XML_REQUIRED],
1849					'show_unack' =>				['type' => XML_STRING | XML_REQUIRED],
1850					'severity_min' =>			['type' => XML_STRING | XML_REQUIRED],
1851					'show_suppressed' =>		['type' => XML_STRING | XML_REQUIRED],
1852					'grid_size' =>				['type' => XML_STRING | XML_REQUIRED],
1853					'grid_show' =>				['type' => XML_STRING | XML_REQUIRED],
1854					'grid_align' =>				['type' => XML_STRING | XML_REQUIRED],
1855					'label_format' =>			['type' => XML_STRING | XML_REQUIRED],
1856					'label_type_host' =>		['type' => XML_STRING | XML_REQUIRED],
1857					'label_type_hostgroup' =>	['type' => XML_STRING | XML_REQUIRED],
1858					'label_type_trigger' =>		['type' => XML_STRING | XML_REQUIRED],
1859					'label_type_map' =>			['type' => XML_STRING | XML_REQUIRED],
1860					'label_type_image' =>		['type' => XML_STRING | XML_REQUIRED],
1861					'label_string_host' =>		['type' => XML_STRING | XML_REQUIRED],
1862					'label_string_hostgroup' =>	['type' => XML_STRING | XML_REQUIRED],
1863					'label_string_trigger' =>	['type' => XML_STRING | XML_REQUIRED],
1864					'label_string_map' =>		['type' => XML_STRING | XML_REQUIRED],
1865					'label_string_image' =>		['type' => XML_STRING | XML_REQUIRED],
1866					'expand_macros' =>			['type' => XML_STRING | XML_REQUIRED],
1867					'background' =>				['type' => XML_ARRAY | XML_REQUIRED, 'rules' => [
1868						'name' =>					['type' => XML_STRING]
1869					]],
1870					'iconmap' =>				['type' => XML_ARRAY | XML_REQUIRED, 'rules' => [
1871						'name' =>					['type' => XML_STRING]
1872					]],
1873					'urls' =>					['type' => XML_INDEXED_ARRAY | XML_REQUIRED, 'prefix' => 'url', 'rules' => [
1874						'url' =>					['type' => XML_ARRAY, 'rules' => [
1875							'name' =>					['type' => XML_STRING | XML_REQUIRED],
1876							'url' =>					['type' => XML_STRING | XML_REQUIRED],
1877							'elementtype' =>			['type' => XML_STRING | XML_REQUIRED]
1878						]]
1879					]],
1880					'selements' =>				['type' => XML_INDEXED_ARRAY | XML_REQUIRED, 'prefix' => 'selement', 'rules' => [
1881						'selement' =>				['type' => XML_ARRAY, 'rules' => [
1882							// The tag 'elementtype' should be validated before the 'elements' because it is used in 'ex_required' and 'ex_validate' methods.
1883							'elementtype' =>			['type' => XML_STRING | XML_REQUIRED],
1884							'elements' =>				['type' => 0, 'ex_required' => [$this, 'requiredMapElement'], 'ex_validate' => [$this, 'validateMapElements'], 'ex_rules' => [$this, 'getMapElementsExtendedRules'], 'export' => [$this, 'mapElementsExport']],
1885							'label' =>					['type' => XML_STRING | XML_REQUIRED],
1886							'label_location' =>			['type' => XML_STRING | XML_REQUIRED],
1887							'x' =>						['type' => XML_STRING | XML_REQUIRED],
1888							'y' =>						['type' => XML_STRING | XML_REQUIRED],
1889							'elementsubtype' =>			['type' => XML_STRING | XML_REQUIRED],
1890							'areatype' =>				['type' => XML_STRING | XML_REQUIRED],
1891							'width' =>					['type' => XML_STRING | XML_REQUIRED],
1892							'height' =>					['type' => XML_STRING | XML_REQUIRED],
1893							'viewtype' =>				['type' => XML_STRING | XML_REQUIRED],
1894							'use_iconmap' =>			['type' => XML_STRING | XML_REQUIRED],
1895							'selementid' =>				['type' => XML_STRING | XML_REQUIRED],
1896							'icon_off' =>				['type' => XML_ARRAY | XML_REQUIRED, 'rules' => [
1897								'name' =>					['type' => XML_STRING | XML_REQUIRED]
1898							]],
1899							'icon_on' =>				['type' => XML_ARRAY | XML_REQUIRED, 'rules' => [
1900								'name' =>					['type' => XML_STRING]
1901							]],
1902							'icon_disabled' =>			['type' => XML_ARRAY | XML_REQUIRED, 'rules' => [
1903								'name' =>					['type' => XML_STRING]
1904							]],
1905							'icon_maintenance' =>		['type' => XML_ARRAY | XML_REQUIRED, 'rules' => [
1906								'name' =>					['type' => XML_STRING]
1907							]],
1908							'urls' =>					['type' => XML_INDEXED_ARRAY | XML_REQUIRED, 'prefix' => 'url', 'rules' => [
1909								'url' =>					['type' => XML_ARRAY, 'rules' => [
1910									'name' =>					['type' => XML_STRING | XML_REQUIRED],
1911									'url' =>					['type' => XML_STRING | XML_REQUIRED]
1912								]]
1913							]],
1914							'evaltype' =>				['type' => XML_STRING],
1915							'tags' =>					['type' => XML_INDEXED_ARRAY, 'prefix' => 'tag', 'rules' => [
1916								'tag' =>					['type' => XML_ARRAY, 'rules' => [
1917									'tag' =>					['type' => XML_STRING | XML_REQUIRED],
1918									'value' =>					['type' => XML_STRING],
1919									'operator' =>				['type' => XML_STRING]
1920								]]
1921							]]
1922						]]
1923					]],
1924					'shapes' =>				['type' => XML_INDEXED_ARRAY | XML_REQUIRED, 'prefix' => 'shape', 'rules' => [
1925						'shape' =>				['type' => XML_ARRAY, 'rules' => [
1926							'type' =>				['type' => XML_STRING | XML_REQUIRED],
1927							'x' =>					['type' => XML_STRING | XML_REQUIRED],
1928							'y' =>					['type' => XML_STRING | XML_REQUIRED],
1929							'width' =>				['type' => XML_STRING | XML_REQUIRED],
1930							'height' =>				['type' => XML_STRING | XML_REQUIRED],
1931							'text' =>				['type' => XML_STRING | XML_REQUIRED],
1932							'font' =>				['type' => XML_STRING | XML_REQUIRED],
1933							'font_size' =>			['type' => XML_STRING | XML_REQUIRED],
1934							'font_color' =>			['type' => XML_STRING | XML_REQUIRED],
1935							'text_halign' =>		['type' => XML_STRING | XML_REQUIRED],
1936							'text_valign' =>		['type' => XML_STRING | XML_REQUIRED],
1937							'border_type' =>		['type' => XML_STRING | XML_REQUIRED],
1938							'border_width' =>		['type' => XML_STRING | XML_REQUIRED],
1939							'border_color' =>		['type' => XML_STRING | XML_REQUIRED],
1940							'background_color' =>	['type' => XML_STRING | XML_REQUIRED],
1941							'zindex' =>				['type' => XML_STRING | XML_REQUIRED]
1942						]]
1943					]],
1944					'lines' =>				['type' => XML_INDEXED_ARRAY | XML_REQUIRED, 'prefix' => 'line', 'rules' => [
1945						'line' =>				['type' => XML_ARRAY, 'rules' => [
1946							'x1' =>					['type' => XML_STRING | XML_REQUIRED],
1947							'y1' =>					['type' => XML_STRING | XML_REQUIRED],
1948							'x2' =>					['type' => XML_STRING | XML_REQUIRED],
1949							'y2' =>					['type' => XML_STRING | XML_REQUIRED],
1950							'line_type' =>			['type' => XML_STRING | XML_REQUIRED],
1951							'line_width' =>			['type' => XML_STRING | XML_REQUIRED],
1952							'line_color' =>			['type' => XML_STRING | XML_REQUIRED],
1953							'zindex' =>				['type' => XML_STRING | XML_REQUIRED]
1954						]]
1955					]],
1956					'links' =>					['type' => XML_INDEXED_ARRAY | XML_REQUIRED, 'prefix' => 'link', 'rules' => [
1957						'link' =>					['type' => XML_ARRAY, 'rules' => [
1958							'drawtype' =>				['type' => XML_STRING | XML_REQUIRED],
1959							'color' =>					['type' => XML_STRING | XML_REQUIRED],
1960							'label' =>					['type' => XML_STRING | XML_REQUIRED],
1961							'selementid1' =>			['type' => XML_STRING | XML_REQUIRED],
1962							'selementid2' =>			['type' => XML_STRING | XML_REQUIRED],
1963							'linktriggers' =>			['type' => XML_INDEXED_ARRAY | XML_REQUIRED, 'prefix' => 'linktrigger', 'rules' => [
1964								'linktrigger' =>            ['type' => XML_ARRAY, 'rules' => [
1965									'drawtype' =>				['type' => XML_STRING | XML_REQUIRED],
1966									'color' =>					['type' => XML_STRING | XML_REQUIRED],
1967									'trigger' =>				['type' => XML_ARRAY | XML_REQUIRED, 'rules' => [
1968										'description' =>			['type' => XML_STRING | XML_REQUIRED],
1969										'expression' =>				['type' => XML_STRING | XML_REQUIRED],
1970										'recovery_expression' =>	['type' => XML_STRING | XML_REQUIRED]
1971									]]
1972								]]
1973							]]
1974						]]
1975					]]
1976				]]
1977			]],
1978			'media_types' =>			['type' => XML_INDEXED_ARRAY, 'prefix' => 'media_type', 'rules' => [
1979				'media_type' =>				['type' => XML_ARRAY, 'rules' => [
1980					'name' =>					['type' => XML_STRING | XML_REQUIRED],
1981					'type' =>					['type' => XML_STRING | XML_REQUIRED, 'in' => $this->MEDIA_TYPE],
1982					'smtp_server' =>			['type' => XML_STRING, 'default' => ''],
1983					'smtp_port' =>				['type' => XML_STRING, 'default' => '25'],
1984					'smtp_helo' =>				['type' => XML_STRING, 'default' => ''],
1985					'smtp_email' =>				['type' => XML_STRING, 'default' => ''],
1986					'smtp_security' =>			['type' => XML_STRING, 'default' => CXmlConstantValue::NONE, 'in' => [CXmlConstantValue::NONE => CXmlConstantName::NONE, CXmlConstantValue::STARTTLS => CXmlConstantName::STARTTLS, CXmlConstantValue::SSL_OR_TLS => CXmlConstantName::SSL_OR_TLS]],
1987					'smtp_verify_host' =>		['type' => XML_STRING, 'default' => CXmlConstantValue::NO, 'in' => [CXmlConstantValue::NO => CXmlConstantName::NO, CXmlConstantValue::YES => CXmlConstantName::YES]],
1988					'smtp_verify_peer' =>		['type' => XML_STRING, 'default' => CXmlConstantValue::NO, 'in' => [CXmlConstantValue::NO => CXmlConstantName::NO, CXmlConstantValue::YES => CXmlConstantName::YES]],
1989					'smtp_authentication' =>	['type' => XML_STRING, 'default' => CXmlConstantValue::SMTP_AUTHENTICATION_NONE, 'in' => $this->SMTP_AUTHENTICATION],
1990					'username' =>				['type' => XML_STRING, 'default' => ''],
1991					'password' =>				['type' => XML_STRING, 'default' => ''],
1992					'content_type' =>			['type' => XML_STRING, 'default' => CXmlConstantValue::CONTENT_TYPE_HTML, 'in' => [CXmlConstantValue::CONTENT_TYPE_TEXT => CXmlConstantName::CONTENT_TYPE_TEXT, CXmlConstantValue::CONTENT_TYPE_HTML => CXmlConstantName::CONTENT_TYPE_HTML]],
1993					'script_name' =>			['type' => XML_STRING, 'default' => ''],
1994					'parameters' =>				['type' => 0, 'ex_validate' => [$this, 'validateMediaTypeParameters'], 'ex_rules' => [$this, 'getMediaTypeParametersExtendedRules'], 'export' => [$this, 'mediaTypeParametersExport']],
1995					'gsm_modem' =>				['type' => XML_STRING, 'default' => ''],
1996					'status' =>					['type' => XML_STRING, 'default' => CXmlConstantValue::ENABLED, 'in' => [CXmlConstantValue::ENABLED => CXmlConstantName::ENABLED, CXmlConstantValue::DISABLED => CXmlConstantName::DISABLED]],
1997					'max_sessions' =>			['type' => XML_STRING, 'default' => '1'],
1998					'attempts' =>				['type' => XML_STRING, 'default' => '3'],
1999					'attempt_interval' =>		['type' => XML_STRING, 'default' => '10s'],
2000					'script' => 				['type' => XML_STRING, 'default' => ''],
2001					'timeout' => 				['type' => XML_STRING, 'default' => '30s'],
2002					'process_tags' => 			['type' => XML_STRING, 'default' => CXmlConstantValue::NO, 'in' => [CXmlConstantValue::NO => CXmlConstantName::NO, CXmlConstantValue::YES => CXmlConstantName::YES]],
2003					'show_event_menu' => 		['type' => XML_STRING, 'default' => CXmlConstantValue::NO, 'in' => [CXmlConstantValue::NO => CXmlConstantName::NO, CXmlConstantValue::YES => CXmlConstantName::YES]],
2004					'event_menu_url' => 		['type' => XML_STRING, 'default' => ''],
2005					'event_menu_name' => 		['type' => XML_STRING, 'default' => ''],
2006					'description' => 			['type' => XML_STRING, 'default' => ''],
2007					'message_templates' =>		['type' => XML_INDEXED_ARRAY, 'prefix' => 'message_template', 'rules' => [
2008						'message_template' =>		['type' => XML_ARRAY, 'rules' => [
2009							'event_source' =>			['type' => XML_STRING | XML_REQUIRED, 'in' => $this->EVENT_SOURCE],
2010							'operation_mode' =>			['type' => XML_STRING | XML_REQUIRED, 'in' => $this->OPERATION_MODE],
2011							'subject' =>				['type' => XML_STRING, 'default' => ''],
2012							'message' =>				['type' => XML_STRING, 'default' => '']
2013						]]
2014					]]
2015				]]
2016			]]
2017		]];
2018	}
2019
2020	/**
2021	 * Base validation function.
2022	 *
2023	 * @param array  $data  Import data.
2024	 * @param string $path  XML path (for error reporting).
2025	 *
2026	 * @throws Exception if $data does not correspond to validation rules.
2027	 *
2028	 * @return array  Validator does some manipulations for the incoming data. For example, converts empty tags to an
2029	 *                array, if desired. Converted array is returned.
2030	 */
2031	public function validate(array $data, $path) {
2032		return $this->doValidate($this->getSchema(), $data, $path);
2033	}
2034
2035	/**
2036	 * Validate date and time format.
2037	 *
2038	 * @param string $data         Import data.
2039	 * @param array  $parent_data  Data's parent array.
2040	 * @param string $path         XML path (for error reporting).
2041	 *
2042	 * @throws Exception if the date or time is invalid.
2043	 *
2044	 * @return string
2045	 */
2046	public function validateDateTime($data, array $parent_data = null, $path) {
2047		if (!preg_match('/^20[0-9]{2}-(0[1-9]|1[0-2])-(0[1-9]|[1-2][0-9]|3[01])T(2[0-3]|[01][0-9]):[0-5][0-9]:[0-5][0-9]Z$/', $data)) {
2048			throw new Exception(_s('Invalid tag "%1$s": %2$s.', $path, _s('"%1$s" is expected', _x('YYYY-MM-DDThh:mm:ssZ', 'XML date and time format'))));
2049		}
2050
2051		return $data;
2052	}
2053
2054	/**
2055	 * Checking the map element for requirement.
2056	 *
2057	 * @param array $parent_data  Data's parent array.
2058	 *
2059	 * @throws Exception if the check is failed.
2060	 *
2061	 * @return bool
2062	 */
2063	public function requiredMapElement(array $parent_data = null) {
2064		if (zbx_is_int($parent_data['elementtype'])) {
2065			switch ($parent_data['elementtype']) {
2066				case SYSMAP_ELEMENT_TYPE_HOST:
2067				case SYSMAP_ELEMENT_TYPE_MAP:
2068				case SYSMAP_ELEMENT_TYPE_TRIGGER:
2069				case SYSMAP_ELEMENT_TYPE_HOST_GROUP:
2070					return true;
2071			}
2072		}
2073
2074		return false;
2075	}
2076
2077	/**
2078	 * Validate map elements.
2079	 *
2080	 * @param array|string $data         Import data.
2081	 * @param array        $parent_data  Data's parent array.
2082	 * @param string       $path         XML path.
2083	 *
2084	 * @throws Exception if the map elements are invalid.
2085	 *
2086	 * @return array|string
2087	 */
2088	public function validateMapElements($data, array $parent_data = null, $path) {
2089		$rules = $this->getMapElementsExtendedRules($parent_data);
2090
2091		return $this->doValidate($rules, $data, $path);
2092	}
2093
2094	/**
2095	 * Chooses default value for preprocessing step error handler.
2096	 *
2097	 * @param array $parent_data  Data's parent array.
2098	 *
2099	 * @return int
2100	 */
2101	public function defaultPreprocErrHandler(array $parent_data): int {
2102		if ($parent_data['type'] == CXmlConstantValue::CHECK_NOT_SUPPORTED) {
2103			return CXmlConstantValue::DISCARD_VALUE;
2104		}
2105
2106		return CXmlConstantValue::ORIGINAL_ERROR;
2107	}
2108
2109	/**
2110	 * Validate "ymin_item_1" tag.
2111	 *
2112	 * @param string $data         Import data.
2113	 * @param array  $parent_data  Data's parent array.
2114	 * @param string $path         XML path.
2115	 *
2116	 * @throws Exception if the element is invalid.
2117	 *
2118	 * @return array
2119	 */
2120	public function validateYMinItem($data, array $parent_data = null, $path) {
2121		if (array_key_exists('ymin_type_1', $parent_data)) {
2122			if (($parent_data['ymin_type_1'] == GRAPH_YAXIS_TYPE_ITEM_VALUE || $parent_data['ymin_type_1'] == CXmlConstantName::ITEM)) {
2123				$rules = ['type' => XML_ARRAY, 'rules' => [
2124					'host' =>	['type' => XML_STRING | XML_REQUIRED],
2125					'key' =>	['type' => XML_STRING | XML_REQUIRED]
2126				]];
2127			}
2128			else {
2129				$rules = ['type' => XML_ARRAY, 'rules' => []];
2130			}
2131		}
2132		else {
2133			$rules = ['type' => XML_ARRAY, 'rules' => []];
2134		}
2135
2136		return $this->doValidate($rules, $data, $path);
2137	}
2138
2139	/**
2140	 * Validate "ymax_item_1" tag.
2141	 *
2142	 * @param string $data         Import data.
2143	 * @param array  $parent_data  Data's parent array.
2144	 * @param string $path         XML path.
2145	 *
2146	 * @throws Exception if the element is invalid.
2147	 *
2148	 * @return array
2149	 */
2150	public function validateYMaxItem($data, array $parent_data = null, $path) {
2151		if (array_key_exists('ymax_type_1', $parent_data)) {
2152			if (($parent_data['ymax_type_1'] == GRAPH_YAXIS_TYPE_ITEM_VALUE || $parent_data['ymax_type_1'] == CXmlConstantName::ITEM)) {
2153				$rules = ['type' => XML_ARRAY, 'rules' => [
2154					'host' =>	['type' => XML_STRING | XML_REQUIRED],
2155					'key' =>	['type' => XML_STRING | XML_REQUIRED]
2156				]];
2157			}
2158			else {
2159				$rules = ['type' => XML_ARRAY, 'rules' => []];
2160			}
2161		}
2162		else {
2163			$rules = ['type' => XML_ARRAY, 'rules' => []];
2164		}
2165
2166		return $this->doValidate($rules, $data, $path);
2167	}
2168
2169	/**
2170	 * Validate media type "parameters" tag.
2171	 *
2172	 * @param string $data         Import data.
2173	 * @param array  $parent_data  Data's parent array.
2174	 * @param string $path         XML path.
2175	 *
2176	 * @throws Exception if the element is invalid.
2177	 *
2178	 * @return array
2179	 */
2180	public function validateMediaTypeParameters($data, array $parent_data, $path) {
2181		$rules = $this->getMediaTypeParametersExtendedRules($parent_data);
2182
2183		return $this->doValidate($rules, $data, $path);
2184	}
2185
2186	/**
2187	 * Transforms tags containing zero into an empty array.
2188	 *
2189	 * @param mixed $value
2190	 *
2191	 * @return mixed  Converted value.
2192	 */
2193	public function transformZero2Array($value) {
2194		return ($value === '0') ? [] : $value;
2195	}
2196
2197	/**
2198	 * Validate "posts" tag of http test step.
2199	 *
2200	 * @param array|string $data         Import data.
2201	 * @param array        $parent_data  Data's parent array.
2202	 * @param string       $path         XML path.
2203	 *
2204	 * @throws Exception if the element is invalid.
2205	 *
2206	 * @return array
2207	 */
2208	public function validateHttpPosts($data, array $parent_data = null, $path) {
2209		if (is_array($data)) {
2210			// Posts can be an HTTP pair array.
2211			$rules = ['type' => XML_INDEXED_ARRAY, 'prefix' => 'post_field', 'rules' => [
2212				'post_field' =>	['type' => XML_ARRAY, 'rules' => [
2213					'name' =>		['type' => XML_STRING | XML_REQUIRED],
2214					'value' =>		['type' => XML_STRING | XML_REQUIRED]
2215				]]
2216			]];
2217		}
2218		else {
2219			// Posts can be string.
2220			$rules = ['type' => XML_STRING, 'default' => ''];
2221		}
2222
2223		return $this->doValidate($rules, $data, $path);
2224	}
2225
2226	/**
2227	 * Validate master item.
2228	 *
2229	 * @param string $data         Import data.
2230	 * @param array  $parent_data  Data's parent array.
2231	 * @param string $path         XML path.
2232	 *
2233	 * @throws Exception if the element is invalid.
2234	 *
2235	 * @return array
2236	 */
2237	public function validateMasterItem($data, array $parent_data = null, $path) {
2238		$prefix = substr(strrchr($path, '/'), 1);
2239		$rules = ['type' => XML_ARRAY | XML_REQUIRED, 'prefix' => $prefix, 'rules' => ['key' => ['type' => XML_STRING]]];
2240
2241		if ($parent_data['type'] == ITEM_TYPE_DEPENDENT) {
2242			$rules['rules']['key']['type'] |= XML_REQUIRED;
2243		}
2244
2245		return $this->doValidate($rules, $data, $path);
2246	}
2247
2248	/**
2249	 * Validate authtype.
2250	 *
2251	 * @param string $data         Import data.
2252	 * @param array  $parent_data  Data's parent array.
2253	 * @param string $path         XML path.
2254	 *
2255	 * @throws Exception if the element is invalid.
2256	 *
2257	 * @return array
2258	 */
2259	public function validateAuthType($data, array $parent_data = null, $path) {
2260		$rules = $this->getAuthTypeExtendedRules($parent_data);
2261
2262		return $this->doValidate($rules, $data, $path);
2263	}
2264
2265	/**
2266	 * Validate graph_items tag.
2267	 *
2268	 * @param array  $data         Import data.
2269	 * @param array  $parent_data  Data's parent array.
2270	 * @param string $path         XML path.
2271	 *
2272	 * @throws Exception if the element is invalid.
2273	 *
2274	 * @return array
2275	 */
2276	public function validateGraphItems(array $data, array $parent_data = null, $path) {
2277		if (!$data) {
2278			throw new Exception(_s('Invalid tag "%1$s": %2$s.', $path, _s('the tag "%1$s" is missing', 'graph_item')));
2279		}
2280
2281		return $data;
2282	}
2283
2284	/**
2285	 * Validate preprocessing step error handler.
2286	 *
2287	 * @param string|array $data         Import data.
2288	 * @param array        $parent_data  Data's parent array.
2289	 * @param string       $path         XML path.
2290	 *
2291	 * @throws Exception if the element is invalid.
2292	 *
2293	 * @return string|array
2294	 */
2295	public function validatePreprocErrHandler($data, array $parent_data, $path) {
2296		$in = $this->ITEM_PREPROCESSING_ERROR_HANDLER;
2297
2298		if ($parent_data['type'] == CXmlConstantName::CHECK_NOT_SUPPORTED) {
2299			unset($in[CXmlConstantValue::ORIGINAL_ERROR]);
2300		}
2301
2302		$rules = ['type' => XML_STRING, 'in' => $in];
2303
2304		return $this->doValidate($rules, $data, $path);
2305	}
2306
2307	/**
2308	 * Validate widget field "value" tag.
2309	 *
2310	 * @param string|array $data         Import data.
2311	 * @param array        $parent_data  Data's parent array.
2312	 * @param string       $path         XML path.
2313	 *
2314	 * @throws Exception if the element is invalid.
2315	 *
2316	 * @return string|array
2317	 */
2318	public function validateWidgetFieldValue($data, array $parent_data = null, string $path) {
2319		$rules = $this->getWidgetFieldValueExtendedRules($parent_data);
2320
2321		return $this->doValidate($rules, $data, $path);
2322	}
2323
2324	/**
2325	 * Get extended validation rules.
2326	 *
2327	 * @param array $data  Import data.
2328	 *
2329	 * @return array
2330	 */
2331	public function getAuthTypeExtendedRules(array $data) {
2332		if (array_key_exists('type', $data)) {
2333			if ($data['type'] == CXmlConstantValue::ITEM_TYPE_SSH || $data['type'] == CXmlConstantName::SSH) {
2334				return ['type' => XML_STRING, 'default' => CXmlConstantValue::PASSWORD, 'in' => [CXmlConstantValue::PASSWORD => CXmlConstantName::PASSWORD, CXmlConstantValue::PUBLIC_KEY => CXmlConstantName::PUBLIC_KEY]];
2335			}
2336		}
2337
2338		return ['type' => XML_STRING, 'default' => CXmlConstantValue::NONE, 'in' => [CXmlConstantValue::NONE => CXmlConstantName::NONE, CXmlConstantValue::BASIC => CXmlConstantName::BASIC, CXmlConstantValue::NTLM => CXmlConstantName::NTLM, CXmlConstantValue::KERBEROS => CXmlConstantName::KERBEROS, CXmlConstantValue::DIGEST => CXmlConstantName::DIGEST]];
2339	}
2340
2341	/**
2342	 * Get extended validation rules for map elements.
2343	 *
2344	 * @param array $data  Import data.
2345	 *
2346	 * @return array
2347	 */
2348	public function getMapElementsExtendedRules(array $data) {
2349		if (array_key_exists('elementtype', $data)) {
2350			switch ($data['elementtype']) {
2351				case SYSMAP_ELEMENT_TYPE_HOST:
2352					return ['type' => XML_INDEXED_ARRAY, 'prefix' => 'element', 'rules' => [
2353						'element' => ['type' => XML_ARRAY, 'rules' => [
2354							'host' =>					['type' => XML_STRING | XML_REQUIRED]
2355						]]
2356					]];
2357					// no break;
2358
2359				case SYSMAP_ELEMENT_TYPE_MAP:
2360				case SYSMAP_ELEMENT_TYPE_HOST_GROUP:
2361					return ['type' => XML_INDEXED_ARRAY, 'prefix' => 'element', 'rules' => [
2362						'element' => ['type' => XML_ARRAY, 'rules' => [
2363							'name' =>					['type' => XML_STRING | XML_REQUIRED]
2364						]]
2365					]];
2366					// no break;
2367
2368				case SYSMAP_ELEMENT_TYPE_TRIGGER:
2369					return ['type' => XML_INDEXED_ARRAY, 'prefix' => 'element', 'rules' => [
2370						'element' => ['type' => XML_ARRAY, 'rules' => [
2371							'description' =>			['type' => XML_STRING | XML_REQUIRED],
2372							'expression' =>				['type' => XML_STRING | XML_REQUIRED],
2373							'recovery_expression' =>	['type' => XML_STRING | XML_REQUIRED]
2374						]]
2375					]];
2376					// no break;
2377
2378				case SYSMAP_ELEMENT_TYPE_IMAGE:
2379					return ['type' => XML_ARRAY, 'rules' => []];
2380					// no break;
2381			}
2382		}
2383
2384		return ['type' => XML_ARRAY, 'rules' => []];
2385	}
2386
2387	/**
2388	 * Get extended validation rules for media type "parameters" tag.
2389	 *
2390	 * @param array $data  Import data.
2391	 *
2392	 * @return array
2393	 */
2394	public function getMediaTypeParametersExtendedRules(array $data) {
2395		switch ($data['type']) {
2396			case CXmlConstantName::SCRIPT:
2397			case CXmlConstantValue::MEDIA_TYPE_SCRIPT:
2398				return ['type' => XML_INDEXED_ARRAY, 'prefix' => 'parameter', 'rules' => [
2399					'parameter' => ['type' => XML_STRING]
2400				]];
2401
2402			case CXmlConstantName::WEBHOOK:
2403			case CXmlConstantValue::MEDIA_TYPE_WEBHOOK:
2404				return ['type' => XML_INDEXED_ARRAY, 'prefix' => 'parameter', 'rules' => [
2405					'parameter' => ['type' => XML_ARRAY, 'rules' => [
2406						'name' => ['type' => XML_STRING | XML_REQUIRED],
2407						'value' => ['type' => XML_STRING, 'default' => '']
2408					]]
2409				]];
2410
2411			default:
2412				return ['type' => XML_ARRAY, 'rules' => []];
2413		}
2414	}
2415
2416	/**
2417	 * Get extended validation rules for widget field "value" tag.
2418	 *
2419	 * @param array $data
2420	 *
2421	 * @return array
2422	 */
2423	public function getWidgetFieldValueExtendedRules(array $data): array {
2424		switch ($data['type']) {
2425			case CXmlConstantName::DASHBOARD_WIDGET_FIELD_TYPE_HOST:
2426			case CXmlConstantValue::DASHBOARD_WIDGET_FIELD_TYPE_HOST:
2427				return ['type' => XML_ARRAY, 'rules' => [
2428					'host' => ['type' => XML_STRING | XML_REQUIRED]
2429				]];
2430			case CXmlConstantName::DASHBOARD_WIDGET_FIELD_TYPE_ITEM:
2431			case CXmlConstantName::DASHBOARD_WIDGET_FIELD_TYPE_ITEM_PROTOTYPE:
2432			case CXmlConstantValue::DASHBOARD_WIDGET_FIELD_TYPE_ITEM:
2433			case CXmlConstantValue::DASHBOARD_WIDGET_FIELD_TYPE_ITEM_PROTOTYPE:
2434				return ['type' => XML_ARRAY, 'rules' => [
2435					'host' => ['type' => XML_STRING | XML_REQUIRED],
2436					'key' => ['type' => XML_STRING | XML_REQUIRED]
2437				]];
2438			case CXmlConstantName::DASHBOARD_WIDGET_FIELD_TYPE_GRAPH:
2439			case CXmlConstantName::DASHBOARD_WIDGET_FIELD_TYPE_GRAPH_PROTOTYPE:
2440			case CXmlConstantValue::DASHBOARD_WIDGET_FIELD_TYPE_GRAPH:
2441			case CXmlConstantValue::DASHBOARD_WIDGET_FIELD_TYPE_GRAPH_PROTOTYPE:
2442				return ['type' => XML_ARRAY, 'rules' => [
2443					'host' => ['type' => XML_STRING | XML_REQUIRED],
2444					'name' => ['type' => XML_STRING | XML_REQUIRED]
2445				]];
2446			default:
2447				return ['type' => XML_STRING | XML_REQUIRED];
2448		}
2449	}
2450
2451	/**
2452	 * Export check for ymax_item_1 if ymax_type_1 === ITEM.
2453	 *
2454	 * @param array $data  Export data.
2455	 *
2456	 * @throws Exception if the element is invalid.
2457	 *
2458	 * @return array
2459	 */
2460	public function graphMaxItemExport(array $data) {
2461		if ($data['ymax_type_1'] == CXmlConstantValue::ITEM
2462				&& array_key_exists('ymax_item_1', $data)
2463				&& (!array_key_exists('host', $data['ymax_item_1'])
2464					|| !array_key_exists('key', $data['ymax_item_1']))) {
2465			throw new Exception(_s('Invalid tag "%1$s": %2$s.', 'ymax_item_1', _('an array is expected')));
2466		}
2467
2468		return $data['ymax_item_1'];
2469	}
2470
2471	/**
2472	 * Export check for ymin_item_1 if ymin_type_1 === ITEM.
2473	 *
2474	 * @param array $data  Export data.
2475	 *
2476	 * @throws Exception if the element is invalid.
2477	 *
2478	 * @return array
2479	 */
2480	public function graphMinItemExport(array $data) {
2481		if ($data['ymin_type_1'] == CXmlConstantValue::ITEM
2482				&& array_key_exists('ymin_item_1', $data)
2483				&& (!array_key_exists('host', $data['ymin_item_1'])
2484					|| !array_key_exists('key', $data['ymin_item_1']))) {
2485			throw new Exception(_s('Invalid tag "%1$s": %2$s.', 'ymin_item_1', _('an array is expected')));
2486		}
2487
2488		return $data['ymin_item_1'];
2489	}
2490
2491	/**
2492	 * Export check for authtype tag.
2493	 *
2494	 * @param array $data  Export data.
2495	 *
2496	 * @throws Exception if the element is invalid.
2497	 *
2498	 * @return string Tag constant.
2499	 */
2500	public function itemAuthtypeExport(array $data) {
2501		if ($data['type'] != CXmlConstantValue::ITEM_TYPE_HTTP_AGENT
2502				&& $data['type'] != CXmlConstantValue::ITEM_TYPE_SSH) {
2503			return CXmlConstantName::NONE;
2504		}
2505
2506		$rules = $this->getAuthTypeExtendedRules($data);
2507
2508		if (!array_key_exists($data['authtype'], $rules['in'])) {
2509			throw new Exception(_s('Invalid tag "%1$s": %2$s.',
2510				'authtype', _s('unexpected constant value "%1$s"', $data['type'])
2511			));
2512		}
2513
2514		return $rules['in'][$data['authtype']];
2515	}
2516
2517	/**
2518	 * Export transformation for media type "parameters" tag.
2519	 *
2520	 * @param array $data  Export data.
2521	 *
2522	 * @throws Exception if the element is invalid.
2523	 *
2524	 * @return array
2525	 */
2526	public function mediaTypeParametersExport(array $data) {
2527		switch ($data['type']) {
2528			case CXmlConstantValue::MEDIA_TYPE_SCRIPT:
2529				return $this->scriptParameterExport($data);
2530
2531			case CXmlConstantValue::MEDIA_TYPE_WEBHOOK:
2532				return $data['parameters'];
2533
2534			default:
2535				return [];
2536		}
2537	}
2538
2539	/**
2540	 * Import check for filter tag.
2541	 * API validation throws an error when filter tag is an empty array.
2542	 *
2543	 * @param array $data  Import data.
2544	 *
2545	 * @return array
2546	 */
2547	public function itemFilterImport(array $data) {
2548		if (!array_key_exists('filter', $data)) {
2549			return [
2550				'conditions' => '',
2551				'evaltype' => CXmlConstantName::AND_OR,
2552				'formula' => ''
2553			];
2554		}
2555
2556		return $data['filter'];
2557	}
2558
2559	/**
2560	 * Converts script parameters to an array.
2561	 *
2562	 * @param array  $data               Export data.
2563	 * @param string $data['parameters]  Script parameters.
2564	 *
2565	 * @return array
2566	 */
2567	public function scriptParameterExport(array $data) {
2568		return explode("\n", substr($data['parameters'], 0, -1));
2569	}
2570
2571	/**
2572	 * Function prepares map element for export builder.
2573	 *
2574	 * @param array $data  Export data.
2575	 *
2576	 * @throws Exception on invalid input.
2577	 *
2578	 * @return array
2579	 */
2580	public function mapElementsExport(array $data): array {
2581		$element_types = [SYSMAP_ELEMENT_TYPE_HOST, SYSMAP_ELEMENT_TYPE_MAP, SYSMAP_ELEMENT_TYPE_TRIGGER,
2582			SYSMAP_ELEMENT_TYPE_HOST_GROUP
2583		];
2584
2585		if (!array_key_exists('elementtype', $data) || !in_array($data['elementtype'], $element_types)) {
2586			throw new Exception(_s('Invalid tag "%1$s": %2$s.',
2587				'elementtype', _s('value must be one of %1$s', implode(', ', $element_types))
2588			));
2589		}
2590
2591		if (!array_key_exists('elements', $data) || !is_array($data['elements'])) {
2592			throw new Exception(_s('Invalid tag "%1$s": %2$s.', 'elements', _('an array is expected')));
2593		}
2594
2595		return ($data['elementtype'] == SYSMAP_ELEMENT_TYPE_TRIGGER)
2596			? array_map(function($trigger) {
2597					if (array_key_exists('expression', $trigger)) {
2598						$trigger['expression'] = str_replace("\r\n", "\n", $trigger['expression']);
2599					}
2600					if (array_key_exists('recovery_expression', $trigger)) {
2601						$trigger['recovery_expression'] = str_replace("\r\n", "\n", $trigger['recovery_expression']);
2602					}
2603					return $trigger;
2604				}, $data['elements'])
2605			: $data['elements'];
2606	}
2607
2608	/**
2609	 * Function prepares preprocessing parameters for export builder.
2610	 *
2611	 * @param array $data  Export data.
2612	 *
2613	 * @throws Exception on invalid input.
2614	 *
2615	 * @return array
2616	 */
2617	public function preprocessingParametersExport(array $data): array {
2618		return $data['parameters'];
2619	}
2620}
2621