Source
xxxxxxxxxx
* @param array $areas Areas representing array containing host group element IDs and dimension
<?php
/*
** Copyright (C) 2001-2025 Zabbix SIA
**
** This program is free software: you can redistribute it and/or modify it under the terms of
** the GNU Affero General Public License as published by the Free Software Foundation, version 3.
**
** This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
** without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
** See the GNU Affero General Public License for more details.
**
** You should have received a copy of the GNU Affero General Public License along with this program.
** If not, see <https://www.gnu.org/licenses/>.
**/
class CMapHelper {
/**
* Get map data with resolved element / link states.
*
* @param array $sysmapids Map IDs.
* @param array $options Options used to retrieve actions.
* @param int $options['severity_min'] Minimum severity.
* @param int $options['unique_id']
*
* @return array
*/
public static function get($sysmapids, array $options = []) {
$maps = API::Map()->get([
'output' => ['sysmapid', 'name', 'width', 'height', 'backgroundid', 'label_type', 'label_location',
'highlight', 'expandproblem', 'markelements', 'show_unack', 'label_format', 'label_type_host',
'label_type_hostgroup', 'label_type_trigger', 'label_type_map', 'label_type_image', 'label_string_host',
'label_string_hostgroup', 'label_string_trigger', 'label_string_map', 'label_string_image', 'iconmapid',
'severity_min', 'show_suppressed'
],
'selectShapes' => ['sysmap_shapeid', 'type', 'x', 'y', 'width', 'height', 'text', 'font', 'font_size',
'font_color', 'text_halign', 'text_valign', 'border_type', 'border_width', 'border_color',
'background_color', 'zindex'
],
'selectLines' => ['sysmap_shapeid', 'x1', 'x2', 'y1', 'y2', 'line_type', 'line_width', 'line_color',
'zindex'
],
'selectSelements' => ['selementid', 'elements', 'elementtype', 'iconid_off', 'iconid_on', 'label',
'label_location', 'x', 'y', 'iconid_disabled', 'iconid_maintenance', 'elementsubtype', 'areatype',
'width', 'height', 'viewtype', 'use_iconmap', 'permission', 'evaltype', 'tags'
],
'selectLinks' => ['linkid', 'selementid1', 'selementid2', 'drawtype', 'color', 'label', 'linktriggers',
'permission'
],
'sysmapids' => $sysmapids,
'preservekeys' => true
]);
$map = reset($maps);
$theme = getUserGraphTheme();
if (!$map) {
$map = [
'sysmapid' => -1,
'width' => 320,
'height' => 150,
'backgroundid' => null,
'severity_min' => 0,
'show_unack' => EXTACK_OPTION_ALL,
'label_location' => MAP_LABEL_LOC_BOTTOM,
'selements' => [],
'links' => [],
'shapes' => [[
'type' => SYSMAP_SHAPE_TYPE_RECTANGLE,
'x' => 0,
'y' => 0,
'width' => 320,
'height' => 150,
'font' => 9,
'font_size' => 11,
'font_color' => 'FF0000',
'text' => _('No permissions to referred object or it does not exist!')
]],
'aria_label' => ''
];
}
else {
if (array_key_exists('severity_min', $options)) {
$map['severity_min'] = $options['severity_min'];
}
else {
$options['severity_min'] = $map['severity_min'];
}
// Populate host group elements of subtype 'SYSMAP_ELEMENT_SUBTYPE_HOST_GROUP_ELEMENTS' with hosts.