diff --git a/js/server_privileges.js b/js/server_privileges.js index fcc028dc2..40b424e4b 100755 --- a/js/server_privileges.js +++ b/js/server_privileges.js @@ -102,7 +102,7 @@ function suggestPassword(passwd_form) { * Revoke a user * Edit privileges * Export privileges - * Paginate table of users - use ajax, replace #usersForm + * Paginate table of users * Flush privileges */ @@ -144,6 +144,37 @@ $(document).ready(function() { if($(notice_class).text() == '') { $(notice_class).remove(); } + + //Append the newly retrived user to the table now + + //Calculate the index for the new row + var curr_last_row = $("#usersForm").find('tbody').find('tr:last'); + var curr_last_row_index_string = $(curr_last_row).find('input:checkbox').attr('id').match(/\d+/)[0]; + var curr_last_row_index = parseFloat(curr_last_row_index_string); + var new_last_row_index = curr_last_row_index + 1; + var new_last_row_id = 'checkbox_sel_users_' + new_last_row_index; + + //Append to the table and set the id/names correctly + $(data.new_user_string) + .insertAfter($(curr_last_row)) + .find('input:checkbox') + .attr('id', new_last_row_id) + .val(function() { + //the insert messes up the &27; part. let's fix it + return $(this).val().replace(/&/,'&'); + }) + .end() + .find('label') + .attr('for', new_last_row_id) + .end(); + + //Re-check the classes of each row + $("#usersForm") + .find('tbody').find('tr:odd') + .removeClass('even').addClass('odd') + .end() + .find('tr:even') + .removeClass('odd').addClass('even'); } else { PMA_ajaxShowMessage(PMA_messages['strErrorProcessingRequest'] + " : "+data.error, "7000"); diff --git a/server_privileges.php b/server_privileges.php index 78d4d1d8e..cff400d78 100755 --- a/server_privileges.php +++ b/server_privileges.php @@ -981,8 +981,11 @@ if (isset($_REQUEST['adduser_submit']) || isset($_REQUEST['change_copy'])) { $message = PMA_Message::rawError(PMA_DBI_getError()); break; } - $GLOBALS['reload'] = TRUE; - PMA_reloadNavigation(); + + if($GLOBALS['is_ajax_request'] != true) { + $GLOBALS['reload'] = TRUE; + PMA_reloadNavigation(); + } $q = 'GRANT ALL PRIVILEGES ON ' . PMA_backquote(PMA_sqlAddslashes($username)) . '.* TO \'' @@ -1336,33 +1339,6 @@ if (isset($_REQUEST['flush_privileges'])) { $message = PMA_Message::success(__('The privileges were reloaded successfully.')); } -/** - * If we are in an Ajax request for Create User/Edit User/Revoke User/Flush Privileges, - * show $message and exit. - */ -if( $GLOBALS['is_ajax_request'] && !isset($_REQUEST['export']) && !isset($_REQUEST['adduser']) && !isset($_REQUEST['initial']) && !isset($_REQUEST['showall']) && !isset($_REQUEST['edit_user_dialog'])) { - if(isset($sql_query)) { - $extra_data['sql_query'] = PMA_showMessage(NULL, $sql_query); - } - PMA_ajaxResponse($message, $message->isSuccess(), $extra_data); -} - -/** - * Displays the links - */ -if (isset($viewing_mode) && $viewing_mode == 'db') { - $db = $checkprivs; - $url_query .= '&goto=db_operations.php'; - - // Gets the database structure - $sub_part = '_structure'; - require './libraries/db_info.inc.php'; - echo "\n"; -} else { - require './libraries/server_links.inc.php'; -} - - /** * defines some standard links */ @@ -1391,6 +1367,68 @@ $link_export = ' '."\n" + .'