diff --git a/pandora_console/ChangeLog b/pandora_console/ChangeLog index f6ac654626..83c5b5f8fa 100644 --- a/pandora_console/ChangeLog +++ b/pandora_console/ChangeLog @@ -1,3 +1,7 @@ +2013-03-01 Miguel de Dios + + * include/functions_gis.php: fixed the delete layers. + 2013-03-01 Sergio Martin * include/javascript/jquery.pandora.js diff --git a/pandora_console/include/functions_gis.php b/pandora_console/include/functions_gis.php index 4c72d3a74f..b156404fd6 100644 --- a/pandora_console/include/functions_gis.php +++ b/pandora_console/include/functions_gis.php @@ -780,19 +780,25 @@ function gis_update_map($idMap, $map_name, $map_initial_longitude, $map_initial_ ); } - $listOldIdLayers = db_get_all_rows_sql('SELECT id_tmap_layer FROM tgis_map_layer WHERE tgis_map_id_tgis_map = ' . $idMap); + $listOldIdLayers = db_get_all_rows_sql('SELECT id_tmap_layer + FROM tgis_map_layer WHERE tgis_map_id_tgis_map = ' . $idMap); if ($listOldIdLayers == false) $listOldIdLayers = array(); - foreach($listOldIdLayers as $idLayer) { - db_process_sql_delete('tgis_map_layer_has_tagente', array('tgis_map_layer_id_tmap_layer' => $idLayer['id_tmap_layer'])); + + $list_onlyIDsLayers = array(); + foreach ($listOldIdLayers as $idLayer) { + db_process_sql_delete('tgis_map_layer_has_tagente', + array('tgis_map_layer_id_tmap_layer' => $idLayer['id_tmap_layer'])); + + $list_onlyIDsLayers[$idLayer['id_tmap_layer']] = 0; } foreach ($arrayLayers as $index => $layer) { - if ($layer['id'] != 0) { $idLayer = $layer['id']; + unset($list_onlyIDsLayers[$idLayer]); db_process_sql_update('tgis_map_layer', array( @@ -832,6 +838,12 @@ function gis_update_map($idMap, $map_name, $map_initial_longitude, $map_initial_ } } + + //Delete layers that not carry the $arrayLayers + foreach ($list_onlyIDsLayers as $idLayer => $trash) { + db_process_sql_delete('tgis_map_layer', + array('id_tmap_layer' => $idLayer)); + } } /**