diff --git a/ChangeLog b/ChangeLog index 489a1999e3..39a3e64aac 100644 --- a/ChangeLog +++ b/ChangeLog @@ -51,6 +51,9 @@ VerboseMultiSubmit, ReplaceHelpImg - bug Fix popup message on build SQL of import - bug #3523499 [core] Make X-WebKit-CSP work better - replace Highcharts with jqplot for query profiling, zoom search +- bug #3531584 [interface] No form validation in change password dialog +- bug #3531585 [interface] Broken password validation in copy user form +- bug #3531586 [unterface] Add user form prints JSON when user presses enter 3.5.1.0 (2012-05-03) - bug #3510784 [edit] Limit clause ignored when sort order is remembered diff --git a/js/functions.js b/js/functions.js index 02583f1a49..03eeaa693a 100644 --- a/js/functions.js +++ b/js/functions.js @@ -2543,6 +2543,47 @@ $(function() { }); // end $().live() }); // end $() for Create Database +/** + * Validates the password field in a form + * + * @see PMA_messages['strPasswordEmpty'] + * @see PMA_messages['strPasswordNotSame'] + * @param object the form + * @return boolean whether the field value is valid or not + */ +function checkPassword(the_form) +{ + // Did the user select 'no password'? + if (typeof(the_form.elements['nopass']) != 'undefined' + && the_form.elements['nopass'][0].checked) { + return true; + } else if (typeof(the_form.elements['pred_password']) != 'undefined' + && (the_form.elements['pred_password'].value == 'none' + || the_form.elements['pred_password'].value == 'keep')) { + return true; + } + + var password = the_form.elements['pma_pw']; + var password_repeat = the_form.elements['pma_pw2']; + var alert_msg = false; + + if (password.value == '') { + alert_msg = PMA_messages['strPasswordEmpty']; + } else if (password.value != password_repeat.value) { + alert_msg = PMA_messages['strPasswordNotSame']; + } + + if (alert_msg) { + alert(alert_msg); + password.value = ''; + password_repeat.value = ''; + password.focus(); + return false; + } + + return true; +} // end of the 'checkPassword()' function + /** * Attach Ajax event handlers for 'Change Password' on main.php */ @@ -2575,6 +2616,10 @@ $(function() { */ var $the_form = $("#change_password_form"); + if (! checkPassword($the_form[0])) { + return false; + } + /** * @var this_value String containing the value of the submit button. * Need to append this for the change password form on Server Privileges @@ -2624,14 +2669,16 @@ $(function() { displayPasswordGenerateButton(); $('#fieldset_change_password_footer').hide(); PMA_ajaxRemoveMessage($msgbox); + $('#change_password_form').bind('submit', function (e) { + e.preventDefault(); + $(this) + .closest('.ui-dialog') + .find('.ui-dialog-buttonpane .ui-button') + .first() + .click(); + }); }); // end $.get() }); // end handler for change password anchor - - /** - * Attach Ajax event handler for Change Password form submission - * - * @see $cfg['AjaxEnable'] - */ }); // end $() for Change Password /** diff --git a/js/server_privileges.js b/js/server_privileges.js index fa2cc53119..d5c9a2d3e5 100644 --- a/js/server_privileges.js +++ b/js/server_privileges.js @@ -9,48 +9,6 @@ * */ -/** - * Validates the password field in a form - * - * @see PMA_messages['strPasswordEmpty'] - * @see PMA_messages['strPasswordNotSame'] - * @param object the form - * @return boolean whether the field value is valid or not - */ -function checkPassword(the_form) -{ - // Did the user select 'no password'? - if (typeof(the_form.elements['nopass']) != 'undefined' - && the_form.elements['nopass'][0].checked) { - return true; - } else if (typeof(the_form.elements['pred_password']) != 'undefined' - && (the_form.elements['pred_password'].value == 'none' - || the_form.elements['pred_password'].value == 'keep')) { - return true; - } - - var password = the_form.elements['pma_pw']; - var password_repeat = the_form.elements['pma_pw2']; - var alert_msg = false; - - if (password.value == '') { - alert_msg = PMA_messages['strPasswordEmpty']; - } else if (password.value != password_repeat.value) { - alert_msg = PMA_messages['strPasswordNotSame']; - } - - if (alert_msg) { - alert(alert_msg); - password.value = ''; - password_repeat.value = ''; - password.focus(); - return false; - } - - return true; -} // end of the 'checkPassword()' function - - /** * Validates the "add a user" form * @@ -167,7 +125,6 @@ $(function() { var $form = $(this).find("form[name=usersForm]").last(); if (! checkAddUser($form.get(0))) { - PMA_ajaxShowMessage(PMA_messages['strFormEmpty']); return false; } @@ -264,6 +221,15 @@ $(function() { PMA_convertFootnotesToTooltips($div); PMA_ajaxRemoveMessage($msgbox); $div.find("input[autofocus]").focus(); + + $div.find('form[name=usersForm]').bind('submit', function (e) { + e.preventDefault(); + $(this) + .closest('.ui-dialog') + .find('.ui-dialog-buttonpane .ui-button') + .first() + .click(); + }); }); // end $.get() });//end of Add New User AJAX event handler @@ -404,10 +370,14 @@ $(function() { /** @lends jQuery */ event.preventDefault(); - PMA_ajaxShowMessage(PMA_messages['strProcessingRequest']); - var $t = $(this); + if ($t.is('.copyUserForm') && ! checkPassword($t[0])) { + return false; + } + + PMA_ajaxShowMessage(PMA_messages['strProcessingRequest']); + $t.append(''); /** diff --git a/libraries/display_change_password.lib.php b/libraries/display_change_password.lib.php index ccf8eba31f..a6c19fdb47 100644 --- a/libraries/display_change_password.lib.php +++ b/libraries/display_change_password.lib.php @@ -19,7 +19,7 @@ $chg_evt_handler = (PMA_USR_BROWSER_AGENT == 'IE' && PMA_USR_BROWSER_VER >= 5 && // Displays the form ?> -
onsubmit="return checkPassword(this)"> + > ' . "\n" diff --git a/server_privileges.php b/server_privileges.php index 27bdf30c44..006f2e8933 100644 --- a/server_privileges.php +++ b/server_privileges.php @@ -2352,7 +2352,7 @@ if (empty($_REQUEST['adduser']) && (! isset($checkprivs) || ! strlen($checkprivs if (! isset($dbname) && ! $user_does_not_exists) { include_once 'libraries/display_change_password.lib.php'; - echo '' . "\n" + echo '' . "\n" . PMA_generate_common_hidden_inputs('', '') . '' . "\n" . '' . "\n"