Index: modules/user/user.module =================================================================== RCS file: /cvs/drupal/drupal/modules/user/user.module,v @@ -490,7 +490,7 @@ * Implementation of hook_perm(). */ function user_perm() { - return array('administer access control', 'administer users', 'access user profiles', 'change own username'); + return array('administer access control', 'administer users', 'access user profiles', 'change own username', 'delete own account'); } /** @@ -1034,8 +1034,8 @@ $items['user/%user/delete'] = array( 'title' => 'Delete', 'page callback' => 'user_edit', - 'access callback' => 'user_access', - 'access arguments' => array('administer users'), + 'access callback' => 'user_edit_access', + 'access arguments' => array(1), 'type' => MENU_CALLBACK, ); @@ -1701,7 +1701,12 @@ if (arg(2) == 'delete') { if (!empty($edit['confirm'])) { user_delete($edit, $account->uid); - drupal_goto('admin/user/user'); + if ($account->uid == $user->uid) { + drupal_goto(); + } + else { + drupal_goto('admin/user/user'); + } } else { return drupal_get_form('user_confirm_delete', $account->name, $account->uid); @@ -1721,7 +1726,7 @@ $form['_category'] = array('#type' => 'value', '#value' => $category); $form['_account'] = array('#type' => 'value', '#value' => $account); $form['submit'] = array('#type' => 'submit', '#value' => t('Save'), '#weight' => 30); - if (user_access('administer users')) { + if (user_access('administer users') || (user_access('delete own account') && $account->uid == $user->uid)) { $form['delete'] = array('#type' => 'submit', '#value' => t('Delete'), '#weight' => 31); } $form['#attributes']['enctype'] = 'multipart/form-data'; @@ -1732,10 +1737,18 @@ } function user_confirm_delete(&$form_state, $name, $uid) { - $options = t('All submissions made by this user will be attributed to the anonymous account. This action cannot be undone.'); + global $user; + if ($user->uid == $uid) { + $options = t('All submissions you made to this website will no longer be linked to your account. This action cannot be undone.'); + $message = t('Are you sure you want to delete your own account?'); + } + else { + $options = t('All submissions made by this user will be attributed to the anonymous account. This action cannot be undone.'); + $message = t('Are you sure you want to delete the account %name?', array('%name' => $name)); + } return confirm_form(array(), - t('Are you sure you want to delete the account %name?', array('%name' => $name)), + $message, 'user/'. $uid, $options); }