From 79c5181d2a20646c1ad091955c95d9035eae7c04 Mon Sep 17 00:00:00 2001 From: Marc Delisle Date: Sat, 25 Sep 2010 08:50:39 -0400 Subject: [PATCH] bug #3060972 Password generation not available with AJAX --- js/functions.js | 37 +++++++++++++++++++++++++++++++++++++ js/password_generation.js | 10 ---------- js/server_privileges.js | 31 ++++--------------------------- server_privileges.php | 1 - user_password.php | 1 - 5 files changed, 41 insertions(+), 39 deletions(-) delete mode 100644 js/password_generation.js diff --git a/js/functions.js b/js/functions.js index 6efa1e045..bd3a2b88b 100644 --- a/js/functions.js +++ b/js/functions.js @@ -20,6 +20,42 @@ var only_once_elements = new Array(); */ var ajax_message_init = false; +/** + * Generate a new password and copy it to the password input areas + * + * @param object the form that holds the password fields + * + * @return boolean always true + */ +function suggestPassword(passwd_form) { + // restrict the password to just letters and numbers to avoid problems: + // "editors and viewers regard the password as multiple words and + // things like double click no longer work" + var pwchars = "abcdefhjmnpqrstuvwxyz23456789ABCDEFGHJKLMNPQRSTUVWYXZ"; + var passwordlength = 16; // do we want that to be dynamic? no, keep it simple :) + var passwd = passwd_form.generated_pw; + passwd.value = ''; + + for ( i = 0; i < passwordlength; i++ ) { + passwd.value += pwchars.charAt( Math.floor( Math.random() * pwchars.length ) ) + } + passwd_form.text_pma_pw.value = passwd.value; + passwd_form.text_pma_pw2.value = passwd.value; + return true; +} + +/** + * for libraries/display_change_password.lib.php + * libraries/user_password.php + * + */ + +function displayPasswordGenerateButton() { + $('#tr_element_before_generate_password').parent().append('' + PMA_messages['strGeneratePassword'] + ''); + $('#div_element_before_generate_password').parent().append('
'); +} + + /** * selects the content of a given object, f.e. a textarea * @@ -2281,6 +2317,7 @@ $(document).ready(function() { buttons : button_options }) .append(data); + displayPasswordGenerateButton(); }) // end $.get() }) // end handler for change password anchor diff --git a/js/password_generation.js b/js/password_generation.js deleted file mode 100644 index 9153cc9b5..000000000 --- a/js/password_generation.js +++ /dev/null @@ -1,10 +0,0 @@ -/* vim: set expandtab sw=4 ts=4 sts=4: */ -/** - * for libraries/display_change_password.lib.php - * - */ - -$(document).ready(function() { - $('#tr_element_before_generate_password').parent().append('' + PMA_messages['strGeneratePassword'] + ''); - $('#div_element_before_generate_password').parent().append('
'); -}); diff --git a/js/server_privileges.js b/js/server_privileges.js index a3c63853d..519f9f931 100644 --- a/js/server_privileges.js +++ b/js/server_privileges.js @@ -73,31 +73,6 @@ function checkAddUser(the_form) return checkPassword(the_form); } // end of the 'checkAddUser()' function - -/** - * Generate a new password and copy it to the password input areas - * - * @param object the form that holds the password fields - * - * @return boolean always true - */ -function suggestPassword(passwd_form) { - // restrict the password to just letters and numbers to avoid problems: - // "editors and viewers regard the password as multiple words and - // things like double click no longer work" - var pwchars = "abcdefhjmnpqrstuvwxyz23456789ABCDEFGHJKLMNPQRSTUVWYXZ"; - var passwordlength = 16; // do we want that to be dynamic? no, keep it simple :) - var passwd = passwd_form.generated_pw; - passwd.value = ''; - - for ( i = 0; i < passwordlength; i++ ) { - passwd.value += pwchars.charAt( Math.floor( Math.random() * pwchars.length ) ) - } - passwd_form.text_pma_pw.value = passwd.value; - passwd_form.text_pma_pw2.value = passwd.value; - return true; -} - /** * When a new user is created and retrieved over Ajax, append the user's row to * the user's table @@ -238,6 +213,7 @@ $(document).ready(function() { modal: true, buttons: button_options }); //dialog options end + displayPasswordGenerateButton(); }); // end $.get() });//end of Add New User AJAX event handler @@ -339,7 +315,8 @@ $(document).ready(function() { .dialog({ width: 900, buttons: button_options - }) + }); //dialog options end + displayPasswordGenerateButton(); }) // end $.get() }) @@ -467,4 +444,4 @@ $(document).ready(function() { }, 'top.frame_content'); //end $(document).ready() -/**#@- */ \ No newline at end of file +/**#@- */ diff --git a/server_privileges.php b/server_privileges.php index 710151ef3..abb65cbcc 100644 --- a/server_privileges.php +++ b/server_privileges.php @@ -17,7 +17,6 @@ $GLOBALS['js_include'][] = 'server_privileges.js'; $GLOBALS['js_include'][] = 'functions.js'; $GLOBALS['js_include'][] = 'jquery/jquery-ui-1.8.custom.js'; -$GLOBALS['js_include'][] = 'password_generation.js'; require './libraries/server_common.inc.php'; /** diff --git a/user_password.php b/user_password.php index 58f9cfcc7..d3b577b7c 100644 --- a/user_password.php +++ b/user_password.php @@ -35,7 +35,6 @@ if (! defined('PMA_NO_VARIABLES_IMPORT')) { require_once './libraries/common.inc.php'; $GLOBALS['js_include'][] = 'server_privileges.js'; -$GLOBALS['js_include'][] = 'password_generation.js'; /** * Displays an error message and exits if the user isn't allowed to use this