本文整理汇总了PHP中API::IconMap方法的典型用法代码示例。如果您正苦于以下问题:PHP API::IconMap方法的具体用法?PHP API::IconMap怎么用?PHP API::IconMap使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类API
的用法示例。
在下文中一共展示了API::IconMap方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getSelementsInfo
/**
* Prepare map elements data.
* Calculate problem triggers and priorities. Populate map elements with automatic icon mapping, acknowledging and
* recent change markers.
*
* @param array $sysmap
* @param int $options
* @param int $options['severity_min'] Minimum trigger severity, default value is maximal (Disaster)
*
* @return array
*/
function getSelementsInfo($sysmap, array $options = array())
{
if (!isset($options['severity_min'])) {
$options['severity_min'] = TRIGGER_SEVERITY_NOT_CLASSIFIED;
}
$config = select_config();
$showUnacknowledged = $config['event_ack_enable'] ? $sysmap['show_unack'] : EXTACK_OPTION_ALL;
$triggerIdToSelementIds = array();
$subSysmapTriggerIdToSelementIds = array();
$hostGroupIdToSelementIds = array();
$hostIdToSelementIds = array();
if ($sysmap['sysmapid']) {
$iconMap = API::IconMap()->get(array('sysmapids' => $sysmap['sysmapid'], 'selectMappings' => API_OUTPUT_EXTEND, 'output' => API_OUTPUT_EXTEND));
$iconMap = reset($iconMap);
}
$hostsToGetInventories = array();
$selements = $sysmap['selements'];
$selementIdToSubSysmaps = array();
foreach ($selements as $selementId => &$selement) {
$selement['hosts'] = array();
$selement['triggers'] = array();
switch ($selement['elementtype']) {
case SYSMAP_ELEMENT_TYPE_MAP:
$sysmapIds = array($selement['elementid']);
while (!empty($sysmapIds)) {
$subSysmaps = API::Map()->get(array('sysmapids' => $sysmapIds, 'output' => array('sysmapid'), 'selectSelements' => API_OUTPUT_EXTEND, 'nopermissions' => true, 'preservekeys' => true));
if (!isset($selementIdToSubSysmaps[$selementId])) {
$selementIdToSubSysmaps[$selementId] = array();
}
$selementIdToSubSysmaps[$selementId] += $subSysmaps;
$sysmapIds = array();
foreach ($subSysmaps as $subSysmap) {
foreach ($subSysmap['selements'] as $subSysmapSelement) {
switch ($subSysmapSelement['elementtype']) {
case SYSMAP_ELEMENT_TYPE_MAP:
$sysmapIds[] = $subSysmapSelement['elementid'];
break;
case SYSMAP_ELEMENT_TYPE_HOST_GROUP:
$hostGroupIdToSelementIds[$subSysmapSelement['elementid']][$selementId] = $selementId;
break;
case SYSMAP_ELEMENT_TYPE_HOST:
$hostIdToSelementIds[$subSysmapSelement['elementid']][$selementId] = $selementId;
break;
case SYSMAP_ELEMENT_TYPE_TRIGGER:
$subSysmapTriggerIdToSelementIds[$subSysmapSelement['elementid']][$selementId] = $selementId;
break;
}
}
}
}
break;
case SYSMAP_ELEMENT_TYPE_HOST_GROUP:
$hostGroupId = $selement['elementid'];
$hostGroupIdToSelementIds[$hostGroupId][$selementId] = $selementId;
break;
case SYSMAP_ELEMENT_TYPE_HOST:
$hostId = $selement['elementid'];
$hostIdToSelementIds[$hostId][$selementId] = $selementId;
// if we have icon map applied, we need to get inventories for all hosts,
// where automatic icon selection is enabled.
if ($sysmap['iconmapid'] && $selement['use_iconmap']) {
$hostsToGetInventories[] = $hostId;
}
break;
case SYSMAP_ELEMENT_TYPE_TRIGGER:
$triggerId = $selement['elementid'];
$triggerIdToSelementIds[$triggerId][$selementId] = $selementId;
break;
}
}
unset($selement);
// get host inventories
if ($sysmap['iconmapid']) {
$hostInventories = API::Host()->get(array('hostids' => $hostsToGetInventories, 'output' => array('hostid'), 'nopermissions' => true, 'preservekeys' => true, 'selectInventory' => API_OUTPUT_EXTEND));
}
$allHosts = array();
if (!empty($hostIdToSelementIds)) {
$hosts = API::Host()->get(array('hostids' => array_keys($hostIdToSelementIds), 'output' => array('name', 'status', 'maintenance_status', 'maintenanceid'), 'nopermissions' => true, 'preservekeys' => true));
$allHosts = array_merge($allHosts, $hosts);
foreach ($hosts as $hostId => $host) {
foreach ($hostIdToSelementIds[$hostId] as $selementId) {
$selements[$selementId]['hosts'][$hostId] = $hostId;
}
}
}
$hostsFromHostGroups = array();
if (!empty($hostGroupIdToSelementIds)) {
$hostsFromHostGroups = API::Host()->get(array('groupids' => array_keys($hostGroupIdToSelementIds), 'output' => array('name', 'status', 'maintenance_status', 'maintenanceid'), 'selectGroups' => array('groupid'), 'nopermissions' => true, 'preservekeys' => true));
foreach ($hostsFromHostGroups as $hostId => $host) {
//.........这里部分代码省略.........
示例2: addRelatedObjects
protected function addRelatedObjects(array $options, array $result)
{
$result = parent::addRelatedObjects($options, $result);
$sysmapIds = array_keys($result);
// adding elements
if ($options['selectSelements'] !== null && $options['selectSelements'] != API_OUTPUT_COUNT) {
$selements = API::getApiService()->select('sysmaps_elements', array('output' => $this->outputExtend($options['selectSelements'], array('selementid', 'sysmapid')), 'filter' => array('sysmapid' => $sysmapIds), 'preservekeys' => true));
$relationMap = $this->createRelationMap($selements, 'sysmapid', 'selementid');
// add selement URLs
if ($this->outputIsRequested('urls', $options['selectSelements'])) {
foreach ($selements as &$selement) {
$selement['urls'] = array();
}
unset($selement);
if (!is_null($options['expandUrls'])) {
$dbMapUrls = DBselect('SELECT su.sysmapurlid,su.sysmapid,su.name,su.url,su.elementtype' . ' FROM sysmap_url su' . ' WHERE ' . dbConditionInt('su.sysmapid', $sysmapIds));
while ($mapUrl = DBfetch($dbMapUrls)) {
foreach ($selements as $snum => $selement) {
if (bccomp($selement['sysmapid'], $mapUrl['sysmapid']) == 0 && ($selement['elementtype'] == $mapUrl['elementtype'] && $selement['elementsubtype'] == SYSMAP_ELEMENT_SUBTYPE_HOST_GROUP || $selement['elementsubtype'] == SYSMAP_ELEMENT_SUBTYPE_HOST_GROUP_ELEMENTS && $mapUrl['elementtype'] == SYSMAP_ELEMENT_TYPE_HOST)) {
$selements[$snum]['urls'][] = $this->expandUrlMacro($mapUrl, $selement);
}
}
}
}
$dbSelementUrls = DBselect('SELECT seu.sysmapelementurlid,seu.selementid,seu.name,seu.url' . ' FROM sysmap_element_url seu' . ' WHERE ' . dbConditionInt('seu.selementid', array_keys($selements)));
while ($selementUrl = DBfetch($dbSelementUrls)) {
$selements[$selementUrl['selementid']]['urls'][] = is_null($options['expandUrls']) ? $selementUrl : $this->expandUrlMacro($selementUrl, $selements[$selementUrl['selementid']]);
}
}
$selements = $this->unsetExtraFields($selements, array('sysmapid', 'selementid'), $options['selectSelements']);
$result = $relationMap->mapMany($result, $selements, 'selements');
}
// adding icon maps
if ($options['selectIconMap'] !== null && $options['selectIconMap'] != API_OUTPUT_COUNT) {
$iconMaps = API::IconMap()->get(array('output' => $this->outputExtend($options['selectIconMap'], array('sysmapid', 'iconmapid')), 'sysmapids' => $sysmapIds, 'preservekeys' => true, 'nopermissions' => true));
$relationMap = $this->createRelationMap($iconMaps, 'sysmapid', 'iconmapid');
$iconMaps = $this->unsetExtraFields($iconMaps, array('sysmapid', 'iconmapid'), $options['selectIconMap']);
$result = $relationMap->mapOne($result, $iconMaps, 'iconmap');
}
// adding links
if ($options['selectLinks'] !== null && $options['selectLinks'] != API_OUTPUT_COUNT) {
$links = API::getApiService()->select('sysmaps_links', array('output' => $this->outputExtend($options['selectLinks'], array('sysmapid', 'linkid')), 'filter' => array('sysmapid' => $sysmapIds), 'preservekeys' => true));
$relationMap = $this->createRelationMap($links, 'sysmapid', 'linkid');
// add link triggers
if ($this->outputIsRequested('linktriggers', $options['selectLinks'])) {
$linkTriggers = DBFetchArrayAssoc(DBselect('SELECT DISTINCT slt.*' . ' FROM sysmaps_link_triggers slt' . ' WHERE ' . dbConditionInt('slt.linkid', $relationMap->getRelatedIds())), 'linktriggerid');
$linkTriggerRelationMap = $this->createRelationMap($linkTriggers, 'linkid', 'linktriggerid');
$links = $linkTriggerRelationMap->mapMany($links, $linkTriggers, 'linktriggers');
}
$links = $this->unsetExtraFields($links, array('sysmapid', 'linkid'), $options['selectLinks']);
$result = $relationMap->mapMany($result, $links, 'links');
}
// adding urls
if ($options['selectUrls'] !== null && $options['selectUrls'] != API_OUTPUT_COUNT) {
$links = API::getApiService()->select('sysmap_url', array('output' => $this->outputExtend($options['selectUrls'], array('sysmapid', 'sysmapurlid')), 'filter' => array('sysmapid' => $sysmapIds), 'preservekeys' => true));
$relationMap = $this->createRelationMap($links, 'sysmapid', 'sysmapurlid');
$links = $this->unsetExtraFields($links, array('sysmapid', 'sysmapurlid'), $options['selectUrls']);
$result = $relationMap->mapMany($result, $links, 'urls');
}
return $result;
}
示例3: update
/**
* Update IconMap.
* @param array $iconMaps
* @return array
*/
public function update(array $iconMaps)
{
if (USER_TYPE_SUPER_ADMIN != self::$userData['type']) {
self::exception(ZBX_API_ERROR_PERMISSIONS, _('Only Super Admins can update icon maps.'));
}
$iconMaps = zbx_toArray($iconMaps);
$iconMapids = zbx_objectValues($iconMaps, 'iconmapid');
$updates = [];
$duplicates = [];
foreach ($iconMaps as $iconMap) {
if (!check_db_fields(['iconmapid' => null], $iconMap)) {
self::exception(ZBX_API_ERROR_PARAMETERS, _s('Incorrect parameters for icon map update method "%s".', $iconMap['name']));
}
if (isset($iconMap['name'])) {
if (zbx_empty($iconMap['name'])) {
self::exception(ZBX_API_ERROR_PARAMETERS, _s('Icon map name cannot be empty.'));
} elseif (isset($duplicates[$iconMap['name']])) {
self::exception(ZBX_API_ERROR_PARAMETERS, _s('Cannot create icon maps with identical name "%s".', $iconMap['name']));
} else {
$duplicates[$iconMap['name']] = $iconMap['name'];
}
}
}
$this->validateMappings($iconMaps, false);
$iconMapsUpd = API::IconMap()->get(['iconmapids' => $iconMapids, 'output' => API_OUTPUT_EXTEND, 'preservekeys' => true, 'selectMappings' => API_OUTPUT_EXTEND]);
$oldIconMappings = [];
$newIconMappings = [];
foreach ($iconMaps as $iconMap) {
if (!isset($iconMapsUpd[$iconMap['iconmapid']])) {
self::exception(ZBX_API_ERROR_PARAMETERS, _s('Icon map with iconmapid "%s" does not exist.', $iconMap['iconmapid']));
}
// Existence
if (isset($iconMap['name'])) {
$iconMapExists = $this->get(['filter' => ['name' => $iconMap['name']], 'output' => ['iconmapid'], 'editable' => true, 'nopermissions' => true, 'preservekeys' => true]);
if (($iconMapExists = reset($iconMapExists)) && bccomp($iconMapExists['iconmapid'], $iconMap['iconmapid']) != 0) {
self::exception(ZBX_API_ERROR_PARAMETERS, _s('Icon map "%s" already exists.', $iconMap['name']));
}
}
if (isset($iconMap['mappings'])) {
$mappingsDb = $iconMapsUpd[$iconMap['iconmapid']]['mappings'];
foreach ($mappingsDb as $mapping) {
$oldIconMappings[] = $mapping;
}
foreach ($iconMap['mappings'] as $mapping) {
$mapping['iconmapid'] = $iconMap['iconmapid'];
$newIconMappings[] = $mapping;
}
}
$iconMapid = $iconMap['iconmapid'];
unset($iconMap['iconmapid']);
if (!empty($iconMap)) {
$updates[] = ['values' => $iconMap, 'where' => ['iconmapid' => $iconMapid]];
}
}
DB::save('icon_map', $iconMaps);
DB::replace('icon_mapping', $oldIconMappings, $newIconMappings);
return ['iconmapids' => $iconMapids];
}
示例4: add_elementNames
add_elementNames($map['selements']);
}
if (isset($_REQUEST['links']) || isset($_REQUEST['nolinks'])) {
$map['links'] = get_request('links', '[]');
$map['links'] = $json->decode($map['links'], true);
}
if (get_request('nocalculations', false)) {
foreach ($map['selements'] as $selement) {
if ($selement['elementtype'] != SYSMAP_ELEMENT_TYPE_IMAGE) {
add_elementNames($map['selements']);
break;
}
}
// get default iconmap id to use for elements that use icon map
if ($map['iconmapid']) {
$iconMaps = API::IconMap()->get(array('iconmapids' => $map['iconmapid'], 'output' => array('default_iconid'), 'preservekeys' => true));
$iconMap = reset($iconMaps);
$defaultAutoIconId = $iconMap['default_iconid'];
}
$mapInfo = array();
foreach ($map['selements'] as $selement) {
// if element use icon map and icon map is set for map, and is host like element, we use default icon map icon
if ($map['iconmapid'] && $selement['use_iconmap'] && ($selement['elementtype'] == SYSMAP_ELEMENT_TYPE_HOST || $selement['elementtype'] == SYSMAP_ELEMENT_SUBTYPE_HOST_GROUP && $selement['elementsubtype'] == SYSMAP_ELEMENT_SUBTYPE_HOST_GROUP_ELEMENTS)) {
$iconid = $defaultAutoIconId;
} else {
$iconid = $selement['iconid_off'];
}
$mapInfo[$selement['selementid']] = array('iconid' => $iconid, 'icon_type' => SYSMAP_ELEMENT_ICON_OFF);
$mapInfo[$selement['selementid']]['name'] = $selement['elementtype'] == SYSMAP_ELEMENT_TYPE_IMAGE ? _('Image') : $selement['elementName'];
}
$allLinks = true;
示例5: selectIconMaps
/**
* Select icon map ids for previously added icon maps names.
*/
protected function selectIconMaps()
{
if (!empty($this->iconMaps)) {
$this->iconMapsRefs = array();
$dbIconMaps = API::IconMap()->get(array('filter' => array('name' => $this->iconMaps), 'output' => array('iconmapid', 'name'), 'preservekeys' => true));
foreach ($dbIconMaps as $iconMap) {
$this->iconMapsRefs[$iconMap['name']] = $iconMap['iconmapid'];
}
$this->iconMaps = array();
}
}
示例6: update
/**
* Update IconMap.
* @param array $iconMaps
* @return array
*/
public function update(array $iconMaps)
{
if (USER_TYPE_SUPER_ADMIN != self::$userData['type']) {
self::exception(ZBX_API_ERROR_PERMISSIONS, _('Only Super Admins can update icon maps.'));
}
$iconMaps = zbx_toArray($iconMaps);
$iconMapids = zbx_objectValues($iconMaps, 'iconmapid');
$updates = array();
$duplicates = array();
foreach ($iconMaps as $iconMap) {
if (!check_db_fields(array('iconmapid' => null), $iconMap)) {
self::exception(ZBX_API_ERROR_PARAMETERS, _s('Incorrect parameters for icon map update method "%s".', $iconMap['name']));
}
if (isset($iconMap['name'])) {
if (zbx_empty($iconMap['name'])) {
self::exception(ZBX_API_ERROR_PARAMETERS, _s('Icon map name cannot be empty.'));
} elseif (isset($duplicates[$iconMap['name']])) {
self::exception(ZBX_API_ERROR_PARAMETERS, _s('Cannot create icon maps with identical name "%s".', $iconMap['name']));
} else {
$duplicates[$iconMap['name']] = $iconMap['name'];
}
}
}
$this->validateMappings($iconMaps, false);
$iconMapsUpd = API::IconMap()->get(array('iconmapids' => $iconMapids, 'output' => API_OUTPUT_EXTEND, 'preservekeys' => true, 'selectMappings' => API_OUTPUT_EXTEND));
$mappingsCreate = $mappingsUpdate = $mappingidsDelete = array();
foreach ($iconMaps as $iconMap) {
if (!isset($iconMapsUpd[$iconMap['iconmapid']])) {
self::exception(ZBX_API_ERROR_PARAMETERS, _s('Icon map with iconmapid "%s" does not exist.', $iconMap['iconmapid']));
}
// Existence
if (isset($iconMap['name'])) {
$iconMapExists = $this->get(array('filter' => array('name' => $iconMap['name']), 'output' => API_OUTPUT_SHORTEN, 'editable' => true, 'nopermissions' => true, 'preservekeys' => true));
if (($iconMapExists = reset($iconMapExists)) && bccomp($iconMapExists['iconmapid'], $iconMap['iconmapid']) != 0) {
self::exception(ZBX_API_ERROR_PARAMETERS, _s('Icon map "%s" already exists.', $iconMap['name']));
}
}
if (isset($iconMap['mappings'])) {
$mappingsDb = $iconMapsUpd[$iconMap['iconmapid']]['mappings'];
foreach ($iconMap['mappings'] as $mapping) {
$mapping['iconmapid'] = $iconMap['iconmapid'];
if (isset($mapping['iconmappingid']) && isset($mappingsDb[$mapping['iconmappingid']])) {
$iconmappingid = $mapping['iconmappingid'];
unset($mapping['iconmappingid']);
$mappingsUpdate[] = array('values' => $mapping, 'where' => array('iconmappingid' => $iconmappingid));
unset($mappingsDb[$iconmappingid]);
} else {
$mappingsCreate[] = $mapping;
}
}
$mappingidsDelete = array_merge($mappingidsDelete, array_keys($mappingsDb));
}
$iconMapid = $iconMap['iconmapid'];
unset($iconMap['iconmapid']);
if (!empty($iconMap)) {
$updates[] = array('values' => $iconMap, 'where' => array('iconmapid' => $iconMapid));
}
}
DB::update('icon_map', $updates);
DB::insert('icon_mapping', $mappingsCreate);
DB::update('icon_mapping', $mappingsUpdate);
if (!empty($mappingidsDelete)) {
DB::delete('icon_mapping', array('iconmappingid' => $mappingidsDelete));
}
return array('iconmapids' => $iconMapids);
}
示例7: zbx_toHash
$data['sysmap']['selements'] = zbx_toHash($data['sysmap']['selements'], 'selementid');
$data['sysmap']['links'] = zbx_toHash($data['sysmap']['links'], 'linkid');
// get links
foreach ($data['sysmap']['links'] as &$link) {
foreach ($link['linktriggers'] as $lnum => $linkTrigger) {
$dbTrigger = API::Trigger()->get(array('triggerids' => $linkTrigger['triggerid'], 'output' => array('description', 'expression'), 'selectHosts' => API_OUTPUT_EXTEND, 'preservekeys' => true, 'expandDescription' => true));
$dbTrigger = reset($dbTrigger);
$host = reset($dbTrigger['hosts']);
$link['linktriggers'][$lnum]['desc_exp'] = $host['name'] . NAME_DELIMITER . $dbTrigger['description'];
}
order_result($link['linktriggers'], 'desc_exp');
}
unset($link);
// get iconmapping
if ($data['sysmap']['iconmapid']) {
$iconMap = API::IconMap()->get(array('iconmapids' => $data['sysmap']['iconmapid'], 'output' => array('default_iconid'), 'preservekeys' => true));
$iconMap = reset($iconMap);
$data['defaultAutoIconId'] = $iconMap['default_iconid'];
}
// get icon list
$icons = DBselect('SELECT i.imageid,i.name FROM images i WHERE i.imagetype=' . IMAGE_TYPE_ICON);
while ($icon = DBfetch($icons)) {
$data['iconList'][] = array('imageid' => $icon['imageid'], 'name' => $icon['name']);
if ($icon['name'] == MAP_DEFAULT_ICON || !isset($data['defaultIconId'])) {
$data['defaultIconId'] = $icon['imageid'];
$data['defaultIconName'] = $icon['name'];
}
}
if ($data['iconList']) {
CArrayHelper::sort($data['iconList'], array('name'));
$data['iconList'] = array_values($data['iconList']);
示例8: getHostInventories
$data['iconList'][$icon['imageid']] = $icon['name'];
}
$inventoryFields = getHostInventories();
foreach ($inventoryFields as $field) {
$data['inventoryList'][$field['nr']] = $field['title'];
}
if (isset($_REQUEST['form'])) {
if ($data['form_refresh'] || $_REQUEST['form'] === 'clone') {
$data['iconmap'] = get_request('iconmap');
} elseif (isset($_REQUEST['iconmapid'])) {
$data['iconmap'] = reset($iconMap);
} else {
$firstIcon = reset($iconList);
$data['iconmap'] = array('name' => '', 'default_iconid' => $firstIcon['imageid'], 'mappings' => array());
}
$iconMapView = new CView('administration.general.iconmap.edit', $data);
} else {
$iconMapWidget->addHeader(_('Icon mapping'));
$data['iconmaps'] = API::IconMap()->get(array('output' => API_OUTPUT_EXTEND, 'editable' => true, 'preservekeys' => true, 'selectMappings' => API_OUTPUT_EXTEND));
order_result($data['iconmaps'], 'name');
// nodes
foreach ($data['iconmaps'] as &$iconMap) {
order_result($iconMap['mappings'], 'sortorder');
$iconMap['nodename'] = $data['displayNodes'] ? get_node_name_by_elid($iconMap['iconmapid'], true) : '';
}
unset($iconMap);
$iconMapView = new CView('administration.general.iconmap.list', $data);
}
$iconMapWidget->addItem($iconMapView->render());
$iconMapWidget->show();
require_once dirname(__FILE__) . '/include/page_footer.php';
示例9: zbx_toHash
$data['sysmap']['selements'] = zbx_toHash($data['sysmap']['selements'], 'selementid');
$data['sysmap']['links'] = zbx_toHash($data['sysmap']['links'], 'linkid');
// get links
foreach ($data['sysmap']['links'] as &$link) {
foreach ($link['linktriggers'] as $lnum => $linkTrigger) {
$dbTrigger = API::Trigger()->get(['triggerids' => $linkTrigger['triggerid'], 'output' => ['description', 'expression'], 'selectHosts' => API_OUTPUT_EXTEND, 'preservekeys' => true, 'expandDescription' => true]);
$dbTrigger = reset($dbTrigger);
$host = reset($dbTrigger['hosts']);
$link['linktriggers'][$lnum]['desc_exp'] = $host['name'] . NAME_DELIMITER . $dbTrigger['description'];
}
order_result($link['linktriggers'], 'desc_exp');
}
unset($link);
// get iconmapping
if ($data['sysmap']['iconmapid']) {
$iconMap = API::IconMap()->get(['iconmapids' => $data['sysmap']['iconmapid'], 'output' => ['default_iconid'], 'preservekeys' => true]);
$iconMap = reset($iconMap);
$data['defaultAutoIconId'] = $iconMap['default_iconid'];
}
// get icon list
$icons = DBselect('SELECT i.imageid,i.name FROM images i WHERE i.imagetype=' . IMAGE_TYPE_ICON);
while ($icon = DBfetch($icons)) {
$data['iconList'][] = ['imageid' => $icon['imageid'], 'name' => $icon['name']];
if ($icon['name'] == MAP_DEFAULT_ICON || !isset($data['defaultIconId'])) {
$data['defaultIconId'] = $icon['imageid'];
$data['defaultIconName'] = $icon['name'];
}
}
if ($data['iconList']) {
CArrayHelper::sort($data['iconList'], ['name']);
$data['iconList'] = array_values($data['iconList']);
示例10: get
/**
* Get Map data
*
* @param array $options
* @param array $options['nodeids'] Node IDs
* @param array $options['groupids'] HostGroup IDs
* @param array $options['hostids'] Host IDs
* @param boolean $options['monitored_hosts'] only monitored Hosts
* @param boolean $options['templated_hosts'] include templates in result
* @param boolean $options['with_items'] only with items
* @param boolean $options['with_historical_items'] only with historical items
* @param boolean $options['with_triggers'] only with triggers
* @param boolean $options['with_httptests'] only with http tests
* @param boolean $options['with_graphs'] only with graphs
* @param boolean $options['editable'] only with read-write permission. Ignored for SuperAdmins
* @param int $options['count'] count Hosts, returned column name is rowscount
* @param string $options['pattern'] search hosts by pattern in host names
* @param int $options['limit'] limit selection
* @param string $options['sortorder']
* @param string $options['sortfield']
* @return array|boolean Host data as array or false if error
*/
public function get($options = array())
{
$result = array();
$userType = self::$userData['type'];
// allowed columns for sorting
$sortColumns = array('name', 'width', 'height');
// allowed output options for [ select_* ] params
$subselectsAllowedOutputs = array(API_OUTPUT_REFER, API_OUTPUT_EXTEND);
$sqlParts = array('select' => array('sysmaps' => 's.sysmapid'), 'from' => array('sysmaps' => 'sysmaps s'), 'where' => array(), 'order' => array(), 'limit' => null);
$defOptions = array('nodeids' => null, 'sysmapids' => null, 'editable' => null, 'nopermissions' => null, 'filter' => null, 'search' => null, 'searchByAny' => null, 'startSearch' => null, 'excludeSearch' => null, 'searchWildcardsEnabled' => null, 'output' => API_OUTPUT_REFER, 'selectSelements' => null, 'selectLinks' => null, 'selectIconMap' => null, 'countOutput' => null, 'expandUrls' => null, 'preservekeys' => null, 'sortfield' => '', 'sortorder' => '', 'limit' => null);
$options = zbx_array_merge($defOptions, $options);
if (is_array($options['output'])) {
unset($sqlParts['select']['sysmaps']);
$dbTable = DB::getSchema('sysmaps');
$sqlParts['select']['sysmapid'] = 's.sysmapid';
foreach ($options['output'] as $field) {
if (isset($dbTable['fields'][$field])) {
$sqlParts['select'][$field] = 's.' . $field;
}
}
$options['output'] = API_OUTPUT_CUSTOM;
}
// sysmapids
if (!is_null($options['sysmapids'])) {
zbx_value2array($options['sysmapids']);
$sqlParts['where']['sysmapid'] = dbConditionInt('s.sysmapid', $options['sysmapids']);
}
// search
if (!is_null($options['search'])) {
zbx_db_search('sysmaps s', $options, $sqlParts);
}
// filter
if (!is_null($options['filter'])) {
$this->dbFilter('sysmaps s', $options, $sqlParts);
}
// output
if ($options['output'] == API_OUTPUT_EXTEND) {
$sqlParts['select']['sysmaps'] = 's.*';
}
// countOutput
if (!is_null($options['countOutput'])) {
$options['sortfield'] = '';
$sqlParts['select'] = array('count(DISTINCT s.sysmapid) as rowscount');
}
// sorting
zbx_db_sorting($sqlParts, $options, $sortColumns, 's');
// limit
if (zbx_ctype_digit($options['limit']) && $options['limit']) {
$sqlParts['limit'] = $options['limit'];
}
$sysmapids = array();
$sqlParts = $this->applyQueryNodeOptions($this->tableName(), $this->tableAlias(), $options, $sqlParts);
$res = DBselect($this->createSelectQueryFromParts($sqlParts), $sqlParts['limit']);
while ($sysmap = DBfetch($res)) {
if ($options['countOutput']) {
$result = $sysmap['rowscount'];
} else {
$sysmapids[$sysmap['sysmapid']] = $sysmap['sysmapid'];
if ($options['output'] == API_OUTPUT_SHORTEN) {
$result[$sysmap['sysmapid']] = array('sysmapid' => $sysmap['sysmapid']);
} else {
if (!isset($result[$sysmap['sysmapid']])) {
$result[$sysmap['sysmapid']] = array();
}
// originally we intended not to pass those parameters if advanced labels are off, but they might be useful
// leaving this block commented
// if (isset($sysmap['label_format']) && ($sysmap['label_format'] == SYSMAP_LABEL_ADVANCED_OFF)) {
// unset($sysmap['label_string_hostgroup'], $sysmap['label_string_host'], $sysmap['label_string_trigger'], $sysmap['label_string_map'], $sysmap['label_string_image']);
// }
if (!is_null($options['selectSelements']) && !isset($result[$sysmap['sysmapid']]['selements'])) {
$result[$sysmap['sysmapid']]['selements'] = array();
}
if (!is_null($options['selectLinks']) && !isset($result[$sysmap['sysmapid']]['links'])) {
$result[$sysmap['sysmapid']]['links'] = array();
}
if (!is_null($options['selectIconMap']) && !isset($result[$sysmap['sysmapid']]['iconmap'])) {
$result[$sysmap['sysmapid']]['iconmap'] = array();
}
//.........这里部分代码省略.........
示例11: getRequest
}
$data['current_user_userid'] = $current_userid;
$data['form_refresh'] = getRequest('form_refresh');
// config
$data['config'] = select_config();
// advanced labels
$data['labelTypes'] = sysmapElementLabel();
$data['labelTypesLimited'] = $data['labelTypes'];
unset($data['labelTypesLimited'][MAP_LABEL_TYPE_IP]);
$data['labelTypesImage'] = $data['labelTypesLimited'];
unset($data['labelTypesImage'][MAP_LABEL_TYPE_STATUS]);
// images
$data['images'] = API::Image()->get(['output' => ['imageid', 'name'], 'filter' => ['imagetype' => IMAGE_TYPE_BACKGROUND]]);
order_result($data['images'], 'name');
// icon maps
$data['iconMaps'] = API::IconMap()->get(['output' => ['iconmapid', 'name'], 'preservekeys' => true]);
order_result($data['iconMaps'], 'name');
// render view
$mapView = new CView('monitoring.sysmap.edit', $data);
$mapView->render();
$mapView->show();
} else {
CProfile::delete('web.maps.sysmapid');
$sortField = getRequest('sort', CProfile::get('web.' . $page['file'] . '.sort', 'name'));
$sortOrder = getRequest('sortorder', CProfile::get('web.' . $page['file'] . '.sortorder', ZBX_SORT_UP));
CProfile::update('web.' . $page['file'] . '.sort', $sortField, PROFILE_TYPE_STR);
CProfile::update('web.' . $page['file'] . '.sortorder', $sortOrder, PROFILE_TYPE_STR);
if (hasRequest('filter_set')) {
CProfile::update('web.sysmapconf.filter_name', getRequest('filter_name', ''), PROFILE_TYPE_STR);
} elseif (hasRequest('filter_rst')) {
DBStart();
示例12: select_config
// config
$data['config'] = select_config();
// advanced labels
$data['labelTypes'] = sysmapElementLabel();
$data['labelTypesLimited'] = $data['labelTypes'];
unset($data['labelTypesLimited'][MAP_LABEL_TYPE_IP]);
$data['labelTypesImage'] = $data['labelTypesLimited'];
unset($data['labelTypesImage'][MAP_LABEL_TYPE_STATUS]);
// images
$data['images'] = API::Image()->get(array('output' => array('imageid', 'name'), 'filter' => array('imagetype' => IMAGE_TYPE_BACKGROUND)));
order_result($data['images'], 'name');
foreach ($data['images'] as $num => $image) {
$data['images'][$num]['name'] = get_node_name_by_elid($image['imageid'], null, NAME_DELIMITER) . $image['name'];
}
// icon maps
$data['iconMaps'] = API::IconMap()->get(array('output' => array('iconmapid', 'name'), 'preservekeys' => true));
order_result($data['iconMaps'], 'name');
// render view
$mapView = new CView('configuration.sysmap.edit', $data);
$mapView->render();
$mapView->show();
} else {
$data = array();
// get maps
$sortField = getPageSortField('name');
$sortOrder = getPageSortOrder();
$data['maps'] = API::Map()->get(array('editable' => true, 'output' => array('sysmapid', 'name', 'width', 'height'), 'sortfield' => $sortField, 'limit' => $config['search_limit'] + 1));
order_result($data['maps'], $sortField, $sortOrder);
// paging
$data['paging'] = getPagingLine($data['maps'], array('sysmapid'));
// nodes
示例13: add_elementNames
add_elementNames($map['selements']);
}
if (isset($_REQUEST['links']) || isset($_REQUEST['nolinks'])) {
$map['links'] = getRequest('links', '[]');
$map['links'] = $json->decode($map['links'], true);
}
if (getRequest('nocalculations', false)) {
foreach ($map['selements'] as $selement) {
if ($selement['elementtype'] != SYSMAP_ELEMENT_TYPE_IMAGE) {
add_elementNames($map['selements']);
break;
}
}
// get default iconmap id to use for elements that use icon map
if ($map['iconmapid']) {
$iconMaps = API::IconMap()->get(['iconmapids' => $map['iconmapid'], 'output' => ['default_iconid'], 'preservekeys' => true]);
$iconMap = reset($iconMaps);
$defaultAutoIconId = $iconMap['default_iconid'];
}
$mapInfo = [];
foreach ($map['selements'] as $selement) {
// if element use icon map and icon map is set for map, and is host like element, we use default icon map icon
if ($map['iconmapid'] && $selement['use_iconmap'] && ($selement['elementtype'] == SYSMAP_ELEMENT_TYPE_HOST || $selement['elementtype'] == SYSMAP_ELEMENT_SUBTYPE_HOST_GROUP && $selement['elementsubtype'] == SYSMAP_ELEMENT_SUBTYPE_HOST_GROUP_ELEMENTS)) {
$iconid = $defaultAutoIconId;
} else {
$iconid = $selement['iconid_off'];
}
$mapInfo[$selement['selementid']] = ['iconid' => $iconid, 'icon_type' => SYSMAP_ELEMENT_ICON_OFF];
$mapInfo[$selement['selementid']]['name'] = $selement['elementtype'] == SYSMAP_ELEMENT_TYPE_IMAGE ? _('Image') : $selement['elementName'];
}
$allLinks = true;