Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Merge remote-tracking branch 'origin/master'
  • Loading branch information
weblate committed Jun 3, 2012
2 parents ac384f0 + 9b9bd23 commit 654b8a0
Show file tree
Hide file tree
Showing 5 changed files with 73 additions and 53 deletions.
3 changes: 3 additions & 0 deletions ChangeLog
Expand Up @@ -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
Expand Down
59 changes: 53 additions & 6 deletions js/functions.js
Expand Up @@ -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
*/
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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

/**
Expand Down
60 changes: 15 additions & 45 deletions js/server_privileges.js
Expand Up @@ -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
*
Expand Down Expand Up @@ -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;
}

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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('<input type="hidden" name="ajax_request" value="true" />');

/**
Expand Down
2 changes: 1 addition & 1 deletion libraries/display_change_password.lib.php
Expand Up @@ -19,7 +19,7 @@

// Displays the form
?>
<form method="post" id="change_password_form" action="<?php echo $GLOBALS['PMA_PHP_SELF']; ?>" name="chgPassword" <?php echo ($GLOBALS['cfg']['AjaxEnable'] ? 'class="ajax" ' : ''); ?> onsubmit="return checkPassword(this)">
<form method="post" id="change_password_form" action="<?php echo $GLOBALS['PMA_PHP_SELF']; ?>" name="chgPassword" <?php echo ($GLOBALS['cfg']['AjaxEnable'] ? 'class="ajax" ' : ''); ?>>
<?php echo PMA_generate_common_hidden_inputs();
if (strpos($GLOBALS['PMA_PHP_SELF'], 'server_privileges') !== false) {
echo '<input type="hidden" name="username" value="' . htmlspecialchars($username) . '" />' . "\n"
Expand Down
2 changes: 1 addition & 1 deletion server_privileges.php
Expand Up @@ -2352,7 +2352,7 @@ function PMA_getGrants($user, $host)
if (! isset($dbname) && ! $user_does_not_exists) {
include_once 'libraries/display_change_password.lib.php';

echo '<form action="server_privileges.php" method="post" onsubmit="return checkPassword(this);">' . "\n"
echo '<form action="server_privileges.php" method="post" class="copyUserForm">' . "\n"
. PMA_generate_common_hidden_inputs('', '')
. '<input type="hidden" name="old_username" value="' . htmlspecialchars($username) . '" />' . "\n"
. '<input type="hidden" name="old_hostname" value="' . htmlspecialchars($hostname) . '" />' . "\n"
Expand Down

0 comments on commit 654b8a0

Please sign in to comment.