Skip to content

Commit

Permalink
rfe-1521 : Add confirmation, when delete user
Browse files Browse the repository at this point in the history
Signed-off-by: Chanaka Dharmarathna <pe.chanaka.ck@gmail.com>
  • Loading branch information
Chanaka committed Aug 16, 2014
1 parent 41c0fb5 commit 32daae2
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 42 deletions.
1 change: 1 addition & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ phpMyAdmin - ChangeLog
======================

4.3.0.0 (not yet released)
+ rfe #1521 Confirmation message when dropping user(s)
+ rfe #1518 Confirm dialog on accidentally leaving a page
+ rfe #1445 Easy access to "SHOW CREATE ..."
+ rfe #1448 Allow clicking an approximate row count to get a correct one
Expand Down
1 change: 1 addition & 0 deletions js/messages.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
$js_messages['strDropUserGroupWarning'] = __('Do you really want to delete user group "%s"?');
$js_messages['strConfirmDeleteQBESearch'] = __('Do you really want to delete the search "%s"?');
$js_messages['strConfirmNavigation'] = __('You have unsaved changes; are you sure you want to leave this page?');
$js_messages['strDropUserWarning'] = __('Do you really want to revoke the selected user(s) ?');

/* For modal dialog buttons */
$js_messages['strSaveAndClose'] = __('Save & Close');
Expand Down
88 changes: 47 additions & 41 deletions js/server_privileges.js
Original file line number Diff line number Diff line change
Expand Up @@ -294,52 +294,58 @@ AJAX.registerOnload('server_privileges.js', function () {
$("#fieldset_delete_user_footer #buttonGo.ajax").live('click', function (event) {
event.preventDefault();

$drop_users_db_checkbox = $("#checkbox_drop_users_db");
if ($drop_users_db_checkbox.is(':checked')) {
var is_confirmed = confirm(PMA_messages.strDropDatabaseStrongWarning + '\n' + $.sprintf(PMA_messages.strDoYouReally, 'DROP DATABASE'));
if (! is_confirmed) {
// Uncheck the drop users database checkbox
$drop_users_db_checkbox.prop('checked', false);
}
}

PMA_ajaxShowMessage(PMA_messages.strRemovingSelectedUsers);

var $thisButton = $(this);
var $form = $("#usersForm");

$.post($form.attr('action'), $form.serialize() + "&delete=" + $(this).val() + "&ajax_request=true", function (data) {
if (data.success === true) {
PMA_ajaxShowMessage(data.message);
// Refresh navigation, if we droppped some databases with the name
// that is the same as the username of the deleted user
if ($('#checkbox_drop_users_db:checked').length) {
PMA_reloadNavigation();

$thisButton.PMA_confirm(PMA_messages.strDropUserWarning, $form.attr('action'), function (url) {

$drop_users_db_checkbox = $("#checkbox_drop_users_db");
if ($drop_users_db_checkbox.is(':checked')) {
var is_confirmed = confirm(PMA_messages.strDropDatabaseStrongWarning + '\n' + $.sprintf(PMA_messages.strDoYouReally, 'DROP DATABASE'));
if (! is_confirmed) {
// Uncheck the drop users database checkbox
$drop_users_db_checkbox.prop('checked', false);
}
//Remove the revoked user from the users list
$form.find("input:checkbox:checked").parents("tr").slideUp("medium", function () {
var this_user_initial = $(this).find('input:checkbox').val().charAt(0).toUpperCase();
$(this).remove();

//If this is the last user with this_user_initial, remove the link from #initials_table
if ($("#tableuserrights").find('input:checkbox[value^="' + this_user_initial + '"]').length === 0) {
$("#initials_table").find('td > a:contains(' + this_user_initial + ')').parent('td').html(this_user_initial);
}

PMA_ajaxShowMessage(PMA_messages.strRemovingSelectedUsers);

$.post(url, $form.serialize() + "&delete=" + $thisButton.val() + "&ajax_request=true", function (data) {
if (data.success === true) {
PMA_ajaxShowMessage(data.message);
// Refresh navigation, if we droppped some databases with the name
// that is the same as the username of the deleted user
if ($('#checkbox_drop_users_db:checked').length) {
PMA_reloadNavigation();
}
//Remove the revoked user from the users list
$form.find("input:checkbox:checked").parents("tr").slideUp("medium", function () {
var this_user_initial = $(this).find('input:checkbox').val().charAt(0).toUpperCase();
$(this).remove();

//If this is the last user with this_user_initial, remove the link from #initials_table
if ($("#tableuserrights").find('input:checkbox[value^="' + this_user_initial + '"], input:checkbox[value^="' + this_user_initial.toLowerCase() + '"]').length === 0) {
$("#initials_table").find('td > a:contains(' + this_user_initial + ')').parent('td').html(this_user_initial);
}

//Re-check the classes of each row
$form
.find('tbody').find('tr:odd')
.removeClass('even').addClass('odd')
.end()
.find('tr:even')
.removeClass('odd').addClass('even');
//Re-check the classes of each row
$form
.find('tbody').find('tr:odd')
.removeClass('even').addClass('odd')
.end()
.find('tr:even')
.removeClass('odd').addClass('even');

//update the checkall checkbox
$(checkboxes_sel).trigger("change");
});
} else {
PMA_ajaxShowMessage(data.error, false);
}
}); // end $.post()
//update the checkall checkbox
$(checkboxes_sel).trigger("change");
});
} else {
PMA_ajaxShowMessage(data.error, false);
}
}); // end $.post()

});

}); // end Revoke User

$("a.edit_user_group_anchor.ajax").live('click', function (event) {
Expand Down
2 changes: 1 addition & 1 deletion server_privileges.php
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@
&& ! isset($_REQUEST['export'])
&& (! isset($_REQUEST['submit_mult']) || $_REQUEST['submit_mult'] != 'export')
&& (! isset($_REQUEST['adduser']) || $_add_user_error)
&& (! isset($_REQUEST['initial']) || empty($_REQUEST['initial']))
&& ((! isset($_REQUEST['initial']) || empty($_REQUEST['initial'])) || (isset($_REQUEST['delete']) && $_REQUEST['delete'] === 'Go'))
&& ! isset($_REQUEST['showall'])
&& ! isset($_REQUEST['edit_user_dialog'])
&& ! isset($_REQUEST['edit_user_group_dialog'])
Expand Down

0 comments on commit 32daae2

Please sign in to comment.