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$item = new CNavigationTree([
22	'problems' => $data['problems'],
23	'severity_config' => $data['severity_config'],
24	'initial_load' => $data['initial_load'],
25	'uniqueid' => $data['uniqueid'],
26	'maps_accessible' => $data['maps_accessible'],
27	'navtree_item_selected' => $data['navtree_item_selected'],
28	'navtree_items_opened' => $data['navtree_items_opened'],
29	'show_unavailable' => $data['show_unavailable']
30]);
31
32if ($data['error'] !== null) {
33	$item->setError($data['error']);
34}
35
36$output = [
37	'header' => $data['name'],
38	'body' => $item->toString(),
39	'script_inline' => $item->getScriptRun()
40];
41
42if (($messages = getMessages()) !== null) {
43	$output['messages'] = $messages->toString();
44}
45
46if ($data['user']['debug_mode'] == GROUP_DEBUG_MODE_ENABLED) {
47	CProfiler::getInstance()->stop();
48	$output['debug'] = CProfiler::getInstance()->make()->toString();
49}
50
51echo (new CJson())->encode($output);
52