Source
* TRIGGER_SEVERITY_WARNING, TRIGGER_SEVERITY_AVERAGE, TRIGGER_SEVERITY_HIGH,
<?php
/*
** Copyright (C) 2001-2024 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/>.
**/
function sysmap_element_types($type = null) {
$types = [
SYSMAP_ELEMENT_TYPE_HOST => _('Host'),
SYSMAP_ELEMENT_TYPE_HOST_GROUP => _('Host group'),
SYSMAP_ELEMENT_TYPE_TRIGGER => _('Trigger'),
SYSMAP_ELEMENT_TYPE_MAP => _('Map'),
SYSMAP_ELEMENT_TYPE_IMAGE => _('Image')
];
if (is_null($type)) {
natsort($types);
return $types;
}
elseif (isset($types[$type])) {
return $types[$type];
}
else {
return _('Unknown');
}
}
function sysmapElementLabel($label = null) {
$labels = [
MAP_LABEL_TYPE_LABEL => _('Label'),
MAP_LABEL_TYPE_IP => _('IP address'),
MAP_LABEL_TYPE_NAME => _('Element name'),
MAP_LABEL_TYPE_STATUS => _('Status only'),
MAP_LABEL_TYPE_NOTHING => _('Nothing'),
MAP_LABEL_TYPE_CUSTOM => _('Custom label')
];
if (is_null($label)) {
return $labels;
}
elseif (isset($labels[$label])) {
return $labels[$label];
}
else {
return false;
}
}
/**
* Get actions (data for popup menu) for map elements.
*
* @param array $sysmap
* @param array $sysmap['selements']
* @param array $options Options used to retrieve actions.
* @param int $options['severity_min'] Minimal severity used.
* @param int $options['unique_id']
*
* @return array
*/
function getActionsBySysmap(array $sysmap, array $options = []) {
$actions = [];
$severity_min = array_key_exists('severity_min', $options)
? $options['severity_min']
: TRIGGER_SEVERITY_NOT_CLASSIFIED;
foreach ($sysmap['selements'] as $selementid => $elem) {
if ($elem['permission'] < PERM_READ) {
continue;
}
if (array_key_exists('unique_id', $options)) {
$elem['unique_id'] = $options['unique_id'];
}
$hostid = ($elem['elementtype_orig'] == SYSMAP_ELEMENT_TYPE_HOST_GROUP
&& $elem['elementsubtype_orig'] == SYSMAP_ELEMENT_SUBTYPE_HOST_GROUP_ELEMENTS)
? $elem['elements'][0]['hostid']
: 0;
$map = CMenuPopupHelper::getMapElement($sysmap['sysmapid'], $elem, $severity_min, $hostid);