From be35a2a1ee9400c4e046f13fef3d2fd95d0bbe29 Mon Sep 17 00:00:00 2001 From: mdtrooper Date: Thu, 28 Jan 2010 17:58:30 +0000 Subject: [PATCH] 2010-01-27 Miguel de Dios * include/functions_gis.php: add function "deleteMap" for to delete the map and other rows in tables related. * godmode/gis_maps/index.php: use the "deleteMap" in link of delete map. * include/functions_db.php: add function "clean_cache" for clean the problematic (sometimes) cache. git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@2317 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f --- pandora_console/ChangeLog | 10 ++++++++++ pandora_console/godmode/gis_maps/index.php | 9 +++++++++ pandora_console/include/functions_db.php | 18 ++++++++++++++++++ pandora_console/include/functions_gis.php | 21 +++++++++++++++++++++ 4 files changed, 58 insertions(+) diff --git a/pandora_console/ChangeLog b/pandora_console/ChangeLog index e3a2122bf9..f35a05608f 100644 --- a/pandora_console/ChangeLog +++ b/pandora_console/ChangeLog @@ -1,3 +1,13 @@ +2010-01-27 Miguel de Dios + + * include/functions_gis.php: add function "deleteMap" for to delete the map + and other rows in tables related. + + * godmode/gis_maps/index.php: use the "deleteMap" in link of delete map. + + * include/functions_db.php: add function "clean_cache" for clean the + problematic (sometimes) cache. + 2010-01-27 Miguel de Dios * operation/gis_maps/ajax.php: clean source code, erased comment lines. diff --git a/pandora_console/godmode/gis_maps/index.php b/pandora_console/godmode/gis_maps/index.php index 3a20693b48..77a01b4495 100644 --- a/pandora_console/godmode/gis_maps/index.php +++ b/pandora_console/godmode/gis_maps/index.php @@ -25,6 +25,15 @@ if (! give_acl ($config['id_user'], 0, "IW")) { return; } +$action = get_parameter('action'); + +switch ($action) { + case 'delete_map': + $idMap = get_parameter('id_map'); + deleteMap($idMap); + break; +} + echo "

" . __('GIS Maps') . " » " . __('Builder') . "

"; $table->width = '500px'; diff --git a/pandora_console/include/functions_db.php b/pandora_console/include/functions_db.php index 6c09ab1e5d..dbd84bc444 100644 --- a/pandora_console/include/functions_db.php +++ b/pandora_console/include/functions_db.php @@ -19,6 +19,12 @@ * @subpackage DataBase */ +/** + * When you delete (with the function "process_sql_delete" or other) any row in + * any table, some times the cache save the data just deleted, because you + * must use "clean_cache". + */ + /** * Check if login session variables are set. * @@ -1985,6 +1991,18 @@ function add_database_debug_trace ($sql, $result = false, $affected = false, $ex $config['db_debug'][$sql] = $var; } +/** + * Clean the cache for to have errors and ghost rows when you do "select ", + * "delete
" and "select
". + * + * @return None + */ +function clean_cache() { + global $sql_cache; + + $sql_cache = array ('saved' => 0); +} + /** * This function comes back with an array in case of SELECT * in case of UPDATE, DELETE etc. with affected rows diff --git a/pandora_console/include/functions_gis.php b/pandora_console/include/functions_gis.php index fce69dee86..e8d30e5b65 100644 --- a/pandora_console/include/functions_gis.php +++ b/pandora_console/include/functions_gis.php @@ -455,6 +455,27 @@ function saveMapConnection($mapConnection_name, $mapConnection_group, return $returnQuery; } +/** + * Delete the map in the all tables are related. + * + * @param $idMap integer The id of map. + * @return None + */ +function deleteMap($idMap) { + $listIdLayers = get_db_all_rows_sql("SELECT id_tmap_layer FROM tgis_map_layer WHERE tgis_map_id_tgis_map = " . $idMap); + + if ($listIdLayers !== false) { + foreach ($listIdLayers as $idLayer) { + process_sql_delete('tgis_map_layer_has_tagente', array('tgis_map_layer_id_tmap_layer' => $idLayer)); + } + } + process_sql_delete('tgis_map_layer', array('tgis_map_id_tgis_map' => $idMap)); + process_sql_delete('tgis_map_has_tgis_map_connection', array('tgis_map_id_tgis_map' => $idMap)); + process_sql_delete('tgis_map', array('id_tgis_map' => $idMap)); + + clean_cache(); +} + /** * Save the map into DB, tgis_map and with id_map save the connetions in * tgis_map_has_tgis_map_connection, and with id_map save the layers in