diff --git a/ChangeLog b/ChangeLog index 4f363a38e..ee2402542 100644 --- a/ChangeLog +++ b/ChangeLog @@ -4,6 +4,9 @@ * FIX: Fixed keeping unlisted values of dropdowns (object names, backend_id) * FIX: Cleaning up host/service attributes when changing the backend_id +Geomap: + * Added support for host and service group objects + 1.9b7 Fronted: * FIX: Fixed "function sidebarUpdatePosition is not defined" when header not shown diff --git a/share/server/core/defines/matches.php b/share/server/core/defines/matches.php index 0ae728709..ab6c7f103 100644 --- a/share/server/core/defines/matches.php +++ b/share/server/core/defines/matches.php @@ -93,6 +93,7 @@ define('MATCH_ROLE_NAME', '/^[0-9A-Za-z_\-.@\s]+$/'); define('MATCH_DYN_GROUP_TYPES', '/^(?:host|service)$/'); define('MATCH_DYN_OBJECT_TYPES', '/^(?:host|service|hostgroup|servicegroup)$/'); +define('MATCH_GEO_OBJECT_TYPES', '/^(?:host|hostgroup|servicegroup)$/'); define('MATCH_LIVESTATUS_FILTER', '/^(?:Filter: .*\\\n)+$/i'); define('MATCH_ZOOM_FACTOR', '/^(?:[0-9]+|fill)$/'); diff --git a/share/server/core/sources/geomap.php b/share/server/core/sources/geomap.php index 2735529df..c707ddca4 100644 --- a/share/server/core/sources/geomap.php +++ b/share/server/core/sources/geomap.php @@ -155,6 +155,14 @@ function list_geomap_source_files() { return $CORE->getAvailableGeomapSourceFiles(); } +function list_geomap_object_types() { + return Array( + 'host' => l('Hosts'), + 'hostgroup' => l('Hostgroup'), + 'servicegroup' => l('Servicegroup'), + ); +} + // Register this source as being selectable by the user global $selectable; $selectable = true; @@ -165,6 +173,7 @@ function list_geomap_source_files() { 'geomap' => array( 'backend_id', 'geomap_type', + 'geomap_object_types', 'geomap_zoom', 'geomap_border', 'source_type', @@ -213,6 +222,13 @@ function list_geomap_source_files() { 'default' => 0.25, 'match' => MATCH_FLOAT, ), + 'geomap_object_types' => Array( + 'must' => false, + 'default' => 'host', + 'field_type' => 'dropdown', + 'match' => MATCH_GEO_OBJECT_TYPES, + 'list' => 'list_geomap_object_types', + ), ); // Assign config variables to specific object types @@ -220,11 +236,12 @@ function list_geomap_source_files() { $configVarMap = array( 'global' => array( 'geomap' => array( - 'geomap_type' => null, - 'geomap_zoom' => null, - 'source_type' => null, - 'source_file' => null, - 'geomap_border' => null, + 'geomap_type' => null, + 'geomap_zoom' => null, + 'source_type' => null, + 'source_file' => null, + 'geomap_border' => null, + 'geomap_object_types' => null, ), ), ); @@ -264,6 +281,7 @@ function geomap_files($params) { function process_geomap($MAPCFG, $map_name, &$map_config) { $params = $MAPCFG->getSourceParams(); list($image_name, $image_path, $data_path) = geomap_files($params); + $type = $params['geomap_object_types']; // Load the list of locations $locations = geomap_get_locations($params); @@ -285,15 +303,19 @@ function process_geomap($MAPCFG, $map_name, &$map_config) { // Now add the objects to the map foreach($locations AS $loc) { - $object_id = $MAPCFG->genObjId($loc['name']); + if (isset($loc['backend_id'])) { + $object_id = $MAPCFG->genObjId($loc['backend_id'].'~~'.$loc['name']); + } else { + $object_id = $MAPCFG->genObjId($loc['name']); + } $map_config[$object_id] = array( - 'type' => 'host', - 'host_name' => $loc['name'], - 'iconset' => $iconset, - 'object_id' => $object_id, - 'alias' => $loc['alias'], - 'lat' => $loc['lat'], - 'long' => $loc['long'], + 'type' => $type, + $type.'_name' => $loc['name'], + 'iconset' => $iconset, + 'object_id' => $object_id, + 'alias' => $loc['alias'], + 'lat' => $loc['lat'], + 'long' => $loc['long'], ); if (isset($loc['backend_id'])) {