Skip to content

Commit

Permalink
Fixed ajax-loaded privileges pages
Browse files Browse the repository at this point in the history
  • Loading branch information
roccivic committed Oct 30, 2012
1 parent 76d65f3 commit e9cc1a2
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 29 deletions.
16 changes: 5 additions & 11 deletions js/server_privileges.js
Expand Up @@ -142,11 +142,8 @@ $(function() {

$("#add_user_dialog").dialog("close");
PMA_ajaxShowMessage(data.message);
$("#floating_menubar")
.next('div')
.remove()
.end()
.after(data.sql_query);
$("#result_query").remove();
$('#floating_menubar').after(data.sql_query);

//Remove the empty notice div generated due to a NULL query passed to PMA_getMessage()
var $notice_class = $("#floating_menubar").next("div").find('.notice');
Expand Down Expand Up @@ -393,12 +390,9 @@ $(function() {
$("#edit_user_dialog").dialog("close");

if(data.sql_query) {
$("#floating_menubar")
.next('div')
.remove()
.end()
.after(data.sql_query);
var $notice_class = $("#floating_menubar").next("div").find('.notice');
$("#result_query").remove();
$('#floating_menubar').after(data.sql_query);
var $notice_class = $("#result_query").find('.notice');
if($notice_class.text() == '') {
$notice_class.remove();
}
Expand Down
37 changes: 20 additions & 17 deletions libraries/server_privileges.lib.php
Expand Up @@ -1613,7 +1613,7 @@ function PMA_getHtmlForSpecificDbPrivileges($link_edit, $conditional_class)
. '</fieldset>'
. '</form>' . "\n";

if ($GLOBALS['is_ajax_request'] == true) {
if ($GLOBALS['is_ajax_request'] == true && empty($_REQUEST['ajax_page_request'])) {
$message = PMA_Message::success(__('User has been added.'));
$response = PMA_Response::getInstance();
$response->addJSON('message', $message);
Expand Down Expand Up @@ -2948,10 +2948,9 @@ function PMA_getHtmlForDisplayUserOverviewPage($link_edit, $pmaThemeImage,

/**
* Displays the initials
* In an Ajax request, we don't need to show this.
* Also not necassary if there is less than 20 privileges
*/
if ($GLOBALS['is_ajax_request'] != true && PMA_DBI_num_rows($res) > 20 ) {
if (PMA_DBI_num_rows($res) > 20 ) {
$html_output .= PMA_getHtmlForDisplayTheInitials(
$array_initials, $conditional_class
);
Expand All @@ -2973,20 +2972,24 @@ function PMA_getHtmlForDisplayUserOverviewPage($link_edit, $pmaThemeImage,
$html_output .= PMA_getAddUserHtmlFieldset($conditional_class);
} // end if (display overview)

$flushnote = new PMA_Message(
__('Note: phpMyAdmin gets the users\' privileges directly from MySQL\'s privilege tables. The content of these tables may differ from the privileges the server uses, if they have been changed manually. In this case, you should %sreload the privileges%s before you continue.'),
PMA_Message::NOTICE
);
$flushLink = '<a href="server_privileges.php?' . $GLOBALS['url_query']
. '&amp;' . 'flush_privileges=1" id="reload_privileges_anchor" '
. 'class="' . $conditional_class . '">';
$flushnote->addParam(
$flushLink,
false
);
$flushnote->addParam('</a>', false);
$html_output .= $flushnote->getDisplay();

if (! $GLOBALS['is_ajax_request'] || ! empty($_REQUEST['ajax_page_request'])) {
$flushnote = new PMA_Message(
__('Note: phpMyAdmin gets the users\' privileges directly from MySQL\'s privilege tables. The content of these tables may differ from the privileges the server uses, if they have been changed manually. In this case, you should %sreload the privileges%s before you continue.'),
PMA_Message::NOTICE
);
$flushLink = '<a href="server_privileges.php?' . $GLOBALS['url_query'] . '&amp;'
. 'flush_privileges=1" id="reload_privileges_anchor" '
. 'class="' . $conditional_class . '">';
$flushnote->addParam(
$flushLink,
false
);
$flushnote->addParam('</a>', false);
$html_output .= $flushnote->getDisplay();
}
if ($GLOBALS['is_ajax_request']) {
exit;
}
return $html_output;
}
}
Expand Down
2 changes: 1 addition & 1 deletion server_privileges.php
Expand Up @@ -392,7 +392,7 @@
$link_edit, $hostname, $username
);

if ($message instanceof PMA_Message) {
if (! empty($message) && $message instanceof PMA_Message) {
$response = PMA_Response::getInstance();
$response->isSuccess($message->isSuccess());
$response->addJSON('message', $message);
Expand Down

0 comments on commit e9cc1a2

Please sign in to comment.