From f328f6d4a933cb4b0d0328687c214f809a919749 Mon Sep 17 00:00:00 2001 From: Marc Delisle Date: Sat, 5 Feb 2011 07:18:42 -0500 Subject: [PATCH] Conditional Ajax in Privileges --- js/server_privileges.js | 27 ++++++++++++++++++--------- server_privileges.php | 18 ++++++++++++------ 2 files changed, 30 insertions(+), 15 deletions(-) diff --git a/js/server_privileges.js b/js/server_privileges.js index 01ffac448..a18ec9f4a 100644 --- a/js/server_privileges.js +++ b/js/server_privileges.js @@ -148,11 +148,12 @@ $(document).ready(function() { * * @see PMA_ajaxShowMessage() * @see appendNewUser() + * @see $cfg['AjaxEnable'] * @memberOf jQuery * @name add_user_click * */ - $("#fieldset_add_user a").live("click", function(event) { + $("#fieldset_add_user a.ajax").live("click", function(event) { /** @lends jQuery */ event.preventDefault(); @@ -225,10 +226,11 @@ $(document).ready(function() { * Ajax event handler for 'Reload Privileges' anchor * * @see PMA_ajaxShowMessage() + * @see $cfg['AjaxEnable'] * @memberOf jQuery * @name reload_privileges_click */ - $("#reload_privileges_anchor").live("click", function(event) { + $("#reload_privileges_anchor.ajax").live("click", function(event) { event.preventDefault(); PMA_ajaxShowMessage(PMA_messages['strReloadingPrivileges']); @@ -248,20 +250,23 @@ $(document).ready(function() { * AJAX handler for 'Revoke User' * * @see PMA_ajaxShowMessage() + * @see $cfg['AjaxEnable'] * @memberOf jQuery * @name revoke_user_click */ - $("#fieldset_delete_user_footer #buttonGo").live('click', function(event) { + $("#fieldset_delete_user_footer #buttonGo.ajax").live('click', function(event) { event.preventDefault(); PMA_ajaxShowMessage(PMA_messages['strRemovingSelectedUsers']); + + $form = $("#usersForm"); - $.post($("#usersForm").attr('action'), $("#usersForm").serialize() + "&delete=" + $(this).attr('value') + "&ajax_request=true", function(data) { + $.post($form.attr('action'), $form.serialize() + "&delete=" + $(this).attr('value') + "&ajax_request=true", function(data) { if(data.success == true) { PMA_ajaxShowMessage(data.message); //Remove the revoked user from the users list - $("#usersForm").find("input:checkbox:checked").parents("tr").slideUp("medium", function() { + $form.find("input:checkbox:checked").parents("tr").slideUp("medium", function() { var this_user_initial = $(this).find('input:checkbox').val().charAt(0).toUpperCase(); $(this).remove(); @@ -271,7 +276,7 @@ $(document).ready(function() { } //Re-check the classes of each row - $("#usersForm") + $form .find('tbody').find('tr:odd') .removeClass('even').addClass('odd') .end() @@ -296,8 +301,9 @@ $(document).ready(function() { * Step 1: Load Edit User Dialog * @memberOf jQuery * @name edit_user_click + * @see $cfg['AjaxEnable'] */ - $(".edit_user_anchor").live('click', function(event) { + $(".edit_user_anchor.ajax").live('click', function(event) { /** @lends jQuery */ event.preventDefault(); @@ -326,6 +332,7 @@ $(document).ready(function() { * Step 2: Submit the Edit User Dialog * * @see PMA_ajaxShowMessage() + * @see $cfg['AjaxEnable'] * @memberOf jQuery * @name edit_user_submit */ @@ -395,10 +402,11 @@ $(document).ready(function() { * AJAX handler for 'Export Privileges' * * @see PMA_ajaxShowMessage() + * @see $cfg['AjaxEnable'] * @memberOf jQuery * @name export_user_click */ - $(".export_user_anchor").live('click', function(event) { + $(".export_user_anchor.ajax").live('click', function(event) { /** @lends jQuery */ event.preventDefault(); @@ -424,10 +432,11 @@ $(document).ready(function() { * AJAX handler to Paginate the Users Table * * @see PMA_ajaxShowMessage() + * @see $cfg['AjaxEnable'] * @name paginate_users_table_click * @memberOf jQuery */ - $("#initials_table").find("a").live('click', function(event) { + $("#initials_table.ajax").find("a").live('click', function(event) { event.preventDefault(); PMA_ajaxShowMessage(); diff --git a/server_privileges.php b/server_privileges.php index c65030026..499fea693 100644 --- a/server_privileges.php +++ b/server_privileges.php @@ -19,6 +19,12 @@ $GLOBALS['js_include'][] = 'jquery/jquery-ui-1.8.custom.js'; require './libraries/server_common.inc.php'; +if ($GLOBALS['cfg']['AjaxEnable']) { + $conditional_class = 'ajax'; +} else { + $conditional_class = ''; +} + /** * Messages are built using the message name */ @@ -1346,7 +1352,7 @@ if (isset($_REQUEST['flush_privileges'])) { /** * defines some standard links */ -$link_edit = ''; -$link_export = ''; + echo ''; foreach ($array_initials as $tmp_initial => $initial_was_found) { if ($initial_was_found) { echo '' . "\n"; @@ -1685,7 +1691,7 @@ if (empty($_REQUEST['adduser']) && (! isset($checkprivs) || ! strlen($checkprivs // add/delete user fieldset echo '
' . "\n" - . ' ' . "\n" + . ' ' . "\n" . PMA_getIcon('b_usradd.png') . ' ' . __('Add a new User') . '' . "\n" . '
' . "\n" @@ -1702,7 +1708,7 @@ if (empty($_REQUEST['adduser']) && (! isset($checkprivs) || ! strlen($checkprivs . ' ' . "\n" . ' ' . "\n" . ' ' . "\n" . '' . "\n"; } else { @@ -1720,7 +1726,7 @@ if (empty($_REQUEST['adduser']) && (! isset($checkprivs) || ! strlen($checkprivs } $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); - $flushnote->addParam('', false); + $flushnote->addParam('', false); $flushnote->addParam('', false); $flushnote->display(); }
' . $tmp_initial . '