diff --git a/ChangeLog b/ChangeLog index 65fbbbf2c..0e19f9119 100755 --- a/ChangeLog +++ b/ChangeLog @@ -7,6 +7,8 @@ $Source$ 2003-08-12 Michal Cihar * libraries/export/csv.php3: Don't trim resulting line (bug #782483). + * libraries/functions.js: Don't ask for confirmation of query that will + not be executed (bug #783667). 2003-08-11 Michal Cihar * libraries/export/csv.php3, libraries/export/latex.php3, diff --git a/libraries/functions.js b/libraries/functions.js index 8dba0b46c..1add85718 100644 --- a/libraries/functions.js +++ b/libraries/functions.js @@ -137,24 +137,30 @@ function checkSqlQuery(theForm) // js1.2+ -> validation with regular expressions else { var space_re = new RegExp('\\s+'); - isEmpty = (sqlQuery.value.replace(space_re, '') == '') ? 1 : 0; + if (typeof(theForm.elements['sql_file']) != 'undefined' && + theForm.elements['sql_file'].value.replace(space_re, '') != '') { + return true; + } + if (typeof(theForm.elements['sql_localfile']) != 'undefined' && + theForm.elements['sql_localfile'].value.replace(space_re, '') != '') { + return true; + } + if (isEmpty && typeof(theForm.elements['id_bookmark']) != 'undefined' && + (theForm.elements['id_bookmark'].value != null || theForm.elements['id_bookmark'].value != '') && + theForm.elements['id_bookmark'].selectedIndex != 0 + ) { + return true; + } // Checks for "DROP/DELETE/ALTER" statements - if (!isEmpty && !confirmQuery(theForm, sqlQuery)) { - return false; - } - if (isEmpty && typeof(theForm.elements['sql_file']) != 'undefined') { - isEmpty = (theForm.elements['sql_file'].value.replace(space_re, '') == '') ? 1 : 0; - } - if (isEmpty && typeof(theForm.elements['sql_localfile']) != 'undefined') { - isEmpty = (theForm.elements['sql_localfile'].value.replace(space_re, '') == '') ? 1 : 0; - } - if (isEmpty && typeof(theForm.elements['id_bookmark']) != 'undefined') { - isEmpty = (theForm.elements['id_bookmark'].value == null || theForm.elements['id_bookmark'].value == ''); - isEmpty = (theForm.elements['id_bookmark'].selectedIndex == 0); - } - if (isEmpty) { - theForm.reset(); + if (sqlQuery.value.replace(space_re, '') != '') { + if (confirmQuery(theForm, sqlQuery)) { + return true; + } else { + return false; + } } + theForm.reset(); + isEmpty = 1; } if (isEmpty) {