Ajaxified Change Password action on main page
This commit is contained in:
@@ -2073,3 +2073,50 @@ $(document).ready(function() {
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
/**
|
||||
* jQuery coding for 'Change Password' on main.php
|
||||
*/
|
||||
$(document).ready(function() {
|
||||
|
||||
$('#change_password_anchor').live('click', function(event) {
|
||||
event.preventDefault();
|
||||
|
||||
var button_options = {};
|
||||
|
||||
button_options[PMA_messages['strCancel']] = function() {$(this).dialog('close').remove();}
|
||||
|
||||
$.get($(this).attr('href'), {'ajax_request': true}, function(data) {
|
||||
$('<div id="change_password_dialog></div>')
|
||||
.dialog({
|
||||
title: top.frame_content.PMA_messages['strChangePassword'],
|
||||
width: 600,
|
||||
buttons : button_options
|
||||
})
|
||||
.append(data);
|
||||
})
|
||||
})
|
||||
|
||||
$("#change_password_form").find('input[name=change_pw]').live('click', function(event) {
|
||||
event.preventDefault();
|
||||
|
||||
var the_form = $("#change_password_form");
|
||||
|
||||
PMA_ajaxShowMessage(PMA_messages['strProcessingRequest']);
|
||||
$(the_form).append('<input type="hidden" name="ajax_request" value="true" />');
|
||||
|
||||
$.post($(the_form).attr('action'), $(the_form).serialize(), function(data) {
|
||||
if(data.success == true) {
|
||||
|
||||
PMA_ajaxShowMessage(data.message);
|
||||
|
||||
$("#topmenucontainer").after(data.sql_query);
|
||||
|
||||
$("#change_password_dialog").hide().remove();
|
||||
}
|
||||
else {
|
||||
PMA_ajaxShowMessage(data.error);
|
||||
}
|
||||
})
|
||||
})
|
||||
})
|
@@ -103,6 +103,7 @@ $js_messages['strChangeDisplay'] = __('Choose column to display');
|
||||
/* password generation */
|
||||
$js_messages['strGeneratePassword'] = __('Generate password');
|
||||
$js_messages['strGenerate'] = __('Generate');
|
||||
$js_messages['strChangePassword'] = __('Change Password');
|
||||
|
||||
echo "var PMA_messages = new Array();\n";
|
||||
foreach ($js_messages as $name => $js_message) {
|
||||
|
@@ -19,7 +19,7 @@ $chg_evt_handler = (PMA_USR_BROWSER_AGENT == 'IE' && PMA_USR_BROWSER_VER >= 5)
|
||||
|
||||
// Displays the form
|
||||
?>
|
||||
<form method="post" action="<?php echo $GLOBALS['PMA_PHP_SELF']; ?>" name="chgPassword" onsubmit="return checkPassword(this)">
|
||||
<form method="post" id="change_password_form" action="<?php echo $GLOBALS['PMA_PHP_SELF']; ?>" name="chgPassword" onsubmit="return checkPassword(this)">
|
||||
<?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"
|
||||
|
9
main.php
9
main.php
@@ -13,6 +13,7 @@ require_once './libraries/common.inc.php';
|
||||
|
||||
$GLOBALS['js_include'][] = 'colorpicker/js/colorpicker.js';
|
||||
$GLOBALS['js_include'][] = 'main_custom_color.js';
|
||||
$GLOBALS['js_include'][] = 'jquery/jquery-ui-1.8.custom.js';
|
||||
|
||||
// Handles some variables that may have been sent by the calling script
|
||||
$GLOBALS['db'] = '';
|
||||
@@ -88,7 +89,7 @@ if ($server > 0
|
||||
if ($cfg['Server']['auth_type'] != 'config') {
|
||||
if ($cfg['ShowChgPassword']) {
|
||||
PMA_printListItem(__('Change password'), 'li_change_password',
|
||||
'./user_password.php?' . $common_url_query);
|
||||
'./user_password.php?' . $common_url_query, null, null, 'change_password_anchor');
|
||||
}
|
||||
|
||||
$http_logout = ($cfg['Server']['auth_type'] == 'http')
|
||||
@@ -364,8 +365,9 @@ if ($cfg['SuhosinDisableWarning'] == false && @ini_get('suhosin.request.max_valu
|
||||
* @param string $url make item as link with $url as target
|
||||
* @param string $mysql_help_page display a link to MySQL's manual
|
||||
* @param string $target special target for $url
|
||||
* @param string $a_id id for the anchor, used for jQuery to hook in functions
|
||||
*/
|
||||
function PMA_printListItem($name, $id = null, $url = null, $mysql_help_page = null, $target = null)
|
||||
function PMA_printListItem($name, $id = null, $url = null, $mysql_help_page = null, $target = null, $a_id = null)
|
||||
{
|
||||
echo '<li id="' . $id . '">';
|
||||
if (null !== $url) {
|
||||
@@ -373,6 +375,9 @@ function PMA_printListItem($name, $id = null, $url = null, $mysql_help_page = nu
|
||||
if (null !== $target) {
|
||||
echo ' target="' . $target . '"';
|
||||
}
|
||||
if (null != $a_id) {
|
||||
echo ' id="' . $a_id .'"';
|
||||
}
|
||||
echo '>';
|
||||
}
|
||||
|
||||
|
@@ -71,6 +71,10 @@ if (isset($_REQUEST['nopass'])) {
|
||||
$password = $_REQUEST['pma_pw'];
|
||||
}
|
||||
|
||||
if($GLOBALS['is_ajax_request'] == true && $_error == true) {
|
||||
PMA_ajaxResponse($message, false);
|
||||
}
|
||||
|
||||
if (! $_error) {
|
||||
|
||||
// Defines the url to return to in case of error in the sql statement
|
||||
@@ -101,10 +105,17 @@ if (isset($_REQUEST['nopass'])) {
|
||||
$_url_params['old_usr'] = 'relog';
|
||||
}
|
||||
|
||||
$message = PMA_Message::success(__('The profile has been updated.'));
|
||||
|
||||
if($GLOBALS['is_ajax_request'] == true) {
|
||||
$extra_data['sql_query'] = PMA_showMessage(NULL, $sql_query, 'success');
|
||||
PMA_ajaxResponse($message, true, $extra_data);
|
||||
}
|
||||
|
||||
// Displays the page
|
||||
require_once './libraries/header.inc.php';
|
||||
echo '<h1>' . __('Change password') . '</h1>' . "\n\n";
|
||||
PMA_showMessage(__('The profile has been updated.'), $sql_query, 'success');
|
||||
PMA_showMessage($message, $sql_query, 'success');
|
||||
?>
|
||||
<a href="index.php<?php echo PMA_generate_common_url($_url_params); ?>" target="_parent">
|
||||
<strong><?php echo __('Back'); ?></strong></a>
|
||||
|
Reference in New Issue
Block a user