Integrated ajax responses from user_password.php with PMA_Response class
This commit is contained in:
parent
bc7753ee7c
commit
3cf937022e
@ -2631,7 +2631,7 @@ $(function() {
|
||||
|
||||
$.post($the_form.attr('action'), $the_form.serialize() + '&change_pw='+ this_value, function(data) {
|
||||
if (data.success == true) {
|
||||
$("#floating_menubar").after(data.sql_query);
|
||||
$("#floating_menubar").after(data.message);
|
||||
$("#change_password_dialog").hide().remove();
|
||||
$("#edit_user_dialog").dialog("close").remove();
|
||||
$('#change_password_anchor.dialog_active').removeClass('dialog_active').addClass('ajax');
|
||||
|
||||
@ -66,6 +66,14 @@ class PMA_Response
|
||||
* @var bool
|
||||
*/
|
||||
private $_isAjax;
|
||||
/**
|
||||
* Whether there were any errors druing the processing of the request
|
||||
* Only used for ajax responses
|
||||
*
|
||||
* @access private
|
||||
* @var bool
|
||||
*/
|
||||
private $_isSuccess;
|
||||
|
||||
/**
|
||||
* Cretes a new class instance
|
||||
@ -81,6 +89,7 @@ class PMA_Response
|
||||
$this->_JSON = array();
|
||||
$this->_footer = new PMA_Footer();
|
||||
|
||||
$this->_isSuccess = true;
|
||||
$this->_isAjax = false;
|
||||
if (isset($_REQUEST['ajax_request']) && $_REQUEST['ajax_request'] == true) {
|
||||
$this->_isAjax = true;
|
||||
@ -102,6 +111,20 @@ class PMA_Response
|
||||
return self::$_instance;
|
||||
}
|
||||
|
||||
/**
|
||||
* FIXME
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function isSuccess($state)
|
||||
{
|
||||
if ($state) {
|
||||
$this->_isSuccess = true;
|
||||
} else {
|
||||
$this->_isSuccess = false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Disables the rendering of the header
|
||||
* and the footer in responses
|
||||
@ -144,8 +167,10 @@ class PMA_Response
|
||||
*/
|
||||
public function addHTML($content)
|
||||
{
|
||||
if (is_string($content)) {
|
||||
$this->_HTML .= $content;
|
||||
if ($value instanceof PMA_Message) {
|
||||
$this->_HTML = $value->getDisplay();
|
||||
} else {
|
||||
$this->_HTML = $value;
|
||||
}
|
||||
}
|
||||
|
||||
@ -166,7 +191,11 @@ class PMA_Response
|
||||
$this->addJSON($key, $value);
|
||||
}
|
||||
} else {
|
||||
$this->_JSON[$json] .= $value;
|
||||
if ($value instanceof PMA_Message) {
|
||||
$this->_JSON[$json] = $value->getDisplay();
|
||||
} else {
|
||||
$this->_JSON[$json] = $value;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@ -209,13 +238,12 @@ class PMA_Response
|
||||
// header('Content-Type: text/html; charset=utf-8');
|
||||
echo $this->_getDisplay();
|
||||
} else {
|
||||
if (isset($this->_JSON['message'])) {
|
||||
$message = $this->_JSON['message'];
|
||||
unset($this->_JSON['message']);
|
||||
} else {
|
||||
$message = $this->_getDisplay();
|
||||
if (! isset($this->_JSON['message'])) {
|
||||
$this->_JSON['message'] = $this->_getDisplay();
|
||||
}
|
||||
PMA_ajaxResponse($message, true, $this->_JSON);
|
||||
$message = $this->_JSON['message'];
|
||||
unset($this->_JSON['message']);
|
||||
PMA_ajaxResponse($message, $this->_isSuccess, $this->_JSON);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -77,12 +77,19 @@ function PMA_getChangePassMessage($change_password_message, $sql_query = '')
|
||||
/**
|
||||
* If in an Ajax request, we don't need to show the rest of the page
|
||||
*/
|
||||
$response = PMA_Response::getInstance();
|
||||
if ($change_password_message['error']) {
|
||||
PMA_ajaxResponse($change_password_message['msg'], false);
|
||||
$response->addJSON('message', $change_password_message['msg']);
|
||||
$response->isSuccess(false);
|
||||
} else {
|
||||
$extra_data['sql_query'] = PMA_getMessage($change_password_message['msg'], $sql_query, 'success');
|
||||
PMA_ajaxResponse($change_password_message['msg'], true, $extra_data);
|
||||
$sql_query = PMA_getMessage(
|
||||
$change_password_message['msg'],
|
||||
$sql_query,
|
||||
'success'
|
||||
);
|
||||
$response->addJSON('message', $sql_query);
|
||||
}
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user