" . $sql . "

" . db_error() . "
"; $error = true; } $sql = "DELETE FROM gui WHERE gui_id = $1"; $v = array($guiList); $t = array('s'); $res = db_prep_query($sql,$v,$t); if (!$res) { $report .= "

" . $sql . "

" . db_error() . "
"; $error = true; } $sql = "DELETE FROM gui_element WHERE fkey_gui_id = $1"; $v = array($guiList); $t = array('s'); $res = db_prep_query($sql,$v,$t); if (!$res) { $report .= "

" . $sql . "

" . db_error() . "
"; $error = true; } $sql = "DELETE FROM gui_element_vars WHERE fkey_gui_id = $1"; $v = array($guiList); $t = array('s'); $res = db_prep_query($sql,$v,$t); if (!$res) { $report .= "

" . $sql . "

" . db_error() . "
"; $error = true; } $sql = "DELETE FROM gui_layer WHERE fkey_gui_id = $1"; $v = array($guiList); $t = array('s'); $res = db_prep_query($sql,$v,$t); if (!$res) { $report .= "

" . $sql . "

" . db_error() . "
"; $error = true; } $sql = "DELETE FROM gui_mb_group WHERE fkey_gui_id = $1"; $v = array($guiList); $t = array('s'); $res = db_prep_query($sql,$v,$t); if (!$res) { $report .= "

" . $sql . "

" . db_error() . "
"; $error = true; } $sql = "DELETE FROM gui_mb_user WHERE fkey_gui_id = $1"; $v = array($guiList); $t = array('s'); $res = db_prep_query($sql,$v,$t); if (!$res) { $report .= "

" . $sql . "

" . db_error() . "
"; $error = true; } $sql = "DELETE FROM gui_treegde WHERE fkey_gui_id = $1"; $v = array($guiList); $t = array('s'); $res = db_prep_query($sql,$v,$t); if (!$res) { $report .= "

" . $sql . "

" . db_error() . "
"; $error = true; } $sql = "DELETE FROM gui_wfs WHERE fkey_gui_id = $1"; $v = array($guiList); $t = array('s'); $res = db_prep_query($sql,$v,$t); if (!$res) { $report .= "

" . $sql . "

" . db_error() . "
"; $error = true; } $sql = "DELETE FROM gui_wms WHERE fkey_gui_id = $1"; $v = array($guiList); $t = array('s'); $res = db_prep_query($sql,$v,$t); if (!$res) { $report .= "

" . $sql . "

" . db_error() . "
"; $error = true; } // if $error is true, the transaction is aborted -> rollback if (!$error) { $sql = "COMMIT"; $res = db_query($sql); if (!$res) { $report .= "

" . $sql . "

" . db_error() . "
"; $error = true; } } //if $error is false, the transaction is executed -> commit else { $sql = "ROLLBACK"; $res = db_query($sql); if (!$res) { $report .= "

" . $sql . "

" . db_error() . "
"; $error = true; } } return !$error; } // CB - rename a GUI function renameGui ($guiId, $newGuiName) { $error = false; if ($this->copyGui($guiId, $newGuiName, true)) { $this->deleteGui($guiId); } else { $error = true; } return !$error; } // CB - copies a GUI $guiId and all its links to users, layers etc. to GUI $newGuiName function copyGui ($guiId, $newGuiName, $withUsers) { $error = false; $guiList = $guiId; if (!$this->guiExists($newGuiName)) { $sql = "BEGIN"; $res = db_query($sql); if (!$res) { $report .= "

" . $sql . "

" . db_error() . "
"; $error = true; } $sql = "INSERT INTO gui SELECT '" . $newGuiName . "', '" . $newGuiName . "',gui_description, gui_public FROM gui WHERE gui_id = '" . $guiList . "';"; $res = db_query($sql); if (!$res) { $report .= "

" . $sql . "

" . db_error() . "
"; $error = true; } $sql = "INSERT INTO gui_element SELECT '" . $newGuiName . "', e_id, e_pos, e_public, e_comment, e_element, e_src, e_attributes, e_left, e_top, e_width, e_height, e_z_index, e_more_styles, e_content, e_closetag, e_js_file, e_mb_mod, e_target, e_requires FROM gui_element WHERE fkey_gui_id = '" . $guiList . "';"; $res = db_query($sql); if (!$res) { $report .= "

" . $sql . "

" . db_error() . "
"; $error = true; } $sql = "INSERT INTO gui_element_vars SELECT '" . $newGuiName . "', fkey_e_id, var_name, var_value, context, var_type FROM gui_element_vars WHERE fkey_gui_id = '" . $guiList . "';"; $res = db_query($sql); if (!$res) { $report .= "

" . $sql . "

" . db_error() . "
"; $error = true; } $sql = "INSERT INTO gui_layer SELECT '" . $newGuiName . "', fkey_layer_id, gui_layer_wms_id, gui_layer_status, gui_layer_selectable, gui_layer_visible, gui_layer_queryable, gui_layer_querylayer, gui_layer_minscale, gui_layer_maxscale, gui_layer_priority, gui_layer_style, gui_layer_wfs_featuretype FROM gui_layer WHERE fkey_gui_id = '" . $guiList . "';"; $res = db_query($sql); if (!$res) { $report .= "

" . $sql . "

" . db_error() . "
"; $error = true; } $sql = "INSERT INTO gui_mb_group SELECT '" . $newGuiName . "', fkey_mb_group_id, mb_group_type FROM gui_mb_group WHERE fkey_gui_id = '" . $guiList . "';"; $res = db_query($sql); if (!$res) { $report .= "

" . $sql . "

" . db_error() . "
"; $error = true; } if ($withUsers == true) { /* users of original gui are copied as well */ $sql = "INSERT INTO gui_mb_user SELECT '" . $newGuiName . "', fkey_mb_user_id, mb_user_type FROM gui_mb_user WHERE fkey_gui_id = '" . $guiList . "';"; $res = db_query($sql); if (!$res) { $report .= "

" . $sql . "

" . db_error() . "
"; $error = true; } } else { // users of original gui are not copied, the current user is set as owner $sql = "INSERT INTO gui_mb_user VALUES ($1, $2, 'owner')"; $v = array($newGuiName, $_SESSION["mb_user_id"]); $t = array('s', 'i'); $res = db_prep_query($sql,$v,$t); if (!$res) { $report .= "

" . $sql . "

" . db_error() . "
"; $error = true; } } $sql = "INSERT INTO gui_treegde SELECT '" . $newGuiName . "', fkey_layer_id, id, lft, rgt, my_layer_title, layer, wms_id FROM gui_treegde WHERE fkey_gui_id = '" . $guiList . "';"; $res = db_query($sql); if (!$res) { $report .= "

" . $sql . "

" . db_error() . "
"; $error = true; } $sql = "INSERT INTO gui_wfs SELECT '" . $newGuiName . "', fkey_wfs_id FROM gui_wfs WHERE fkey_gui_id = '" . $guiList . "';"; $res = db_query($sql); if (!$res) { $report .= "

" . $sql . "

" . db_error() . "
"; $error = true; } $sql = "INSERT INTO gui_wms SELECT '" . $newGuiName . "', fkey_wms_id, gui_wms_position, gui_wms_mapformat, gui_wms_featureinfoformat, gui_wms_exceptionformat, gui_wms_epsg, gui_wms_visible FROM gui_wms WHERE fkey_gui_id = '" . $guiList . "';"; $res = db_query($sql); if (!$res) { $report .= "

" . $sql . "

" . db_error() . "
"; $error = true; } // if $error is false, the transaction is executed -> commit if (!$error) { $sql = "COMMIT"; } else { $sql = "ROLLBACK"; } $res = db_query($sql); if (!$res) { $report .= "

" . $sql . "

" . db_error() . "
"; $error = true; } return !$error; } else { echo ""; return false; } } } ?>