diff --git a/modules/user/user.module b/modules/user/user.module index 0ba9654..6b6c028 100644 --- a/modules/user/user.module +++ b/modules/user/user.module @@ -2290,7 +2290,7 @@ function user_authenticate($name, $password) { */ function user_login_finalize(&$edit = array()) { global $user; - watchdog('user', 'Session opened for %name.', array('%name' => $user->name)); + watchdog('user', 'Session opened for %name.', array('%name' => format_username($user))); // Update the user table timestamp noting user has logged in. // This is also used to invalidate one-time login links. $user->login = REQUEST_TIME; @@ -2519,8 +2519,8 @@ function _user_cancel($edit, $account, $method) { _user_mail_notify('status_blocked', $account); } user_save($account, array('status' => 0)); - drupal_set_message(t('%name has been disabled.', array('%name' => $account->name))); - watchdog('user', 'Blocked user: %name %email.', array('%name' => $account->name, '%email' => '<' . $account->mail . '>'), WATCHDOG_NOTICE); + drupal_set_message(t('%name has been disabled.', array('%name' => format_username($account)))); + watchdog('user', 'Blocked user: %name %email.', array('%name' => format_username($account), '%email' => '<' . $account->mail . '>'), WATCHDOG_NOTICE); break; case 'user_cancel_reassign': @@ -2529,9 +2529,13 @@ function _user_cancel($edit, $account, $method) { if (!empty($edit['user_cancel_notify'])) { _user_mail_notify('status_canceled', $account); } + + // Save username before deleting the account for further usage. + $username = format_username($account); + user_delete($account->uid); - drupal_set_message(t('%name has been deleted.', array('%name' => $account->name))); - watchdog('user', 'Deleted user: %name %email.', array('%name' => $account->name, '%email' => '<' . $account->mail . '>'), WATCHDOG_NOTICE); + drupal_set_message(t('%name has been deleted.', array('%name' => $username))); + watchdog('user', 'Deleted user: %name %email.', array('%name' => $username, '%email' => '<' . $account->mail . '>'), WATCHDOG_NOTICE); break; } @@ -3351,14 +3355,14 @@ function user_multiple_cancel_confirm($form, &$form_state) { '#type' => 'hidden', '#value' => $uid, '#prefix' => '
  • ', - '#suffix' => check_plain($account->name) . "
  • \n", + '#suffix' => check_plain(format_username($account)) . "\n", ); } // Output a notice that user 1 cannot be canceled. if (isset($accounts[1])) { $redirect = (count($accounts) == 1); - $message = t('The user account %name cannot be cancelled.', array('%name' => $accounts[1]->name)); + $message = t('The user account %name cannot be cancelled.', array('%name' => format_username($accounts[1]))); drupal_set_message($message, $redirect ? 'error' : 'warning'); // If only user 1 was selected, redirect to the overview. if ($redirect) { @@ -3759,7 +3763,7 @@ function user_block_user_action(&$entity, $context = array()) { } $account = user_load($uid); $account = user_save($account, array('status' => 0)); - watchdog('action', 'Blocked user %name.', array('%name' => $account->name)); + watchdog('action', 'Blocked user %name.', array('%name' => format_username($account))); } /** @@ -3933,7 +3937,7 @@ function user_register_submit($form, &$form_state) { // New administrative account without notification. $uri = entity_uri('user', $account); if ($admin && !$notify) { - drupal_set_message(t('Created a new user account for %name. No e-mail has been sent.', array('@url' => url($uri['path'], $uri['options']), '%name' => $account->name))); + drupal_set_message(t('Created a new user account for %name. No e-mail has been sent.', array('@url' => url($uri['path'], $uri['options']), '%name' => format_username($account)))); } // No e-mail verification required; log in user immediately. elseif (!$admin && !variable_get('user_email_verification', TRUE) && $account->status) { @@ -3948,7 +3952,7 @@ function user_register_submit($form, &$form_state) { $op = $notify ? 'register_admin_created' : 'register_no_approval_required'; _user_mail_notify($op, $account); if ($notify) { - drupal_set_message(t('A welcome message with further instructions has been e-mailed to the new user %name.', array('@url' => url($uri['path'], $uri['options']), '%name' => $account->name))); + drupal_set_message(t('A welcome message with further instructions has been e-mailed to the new user %name.', array('@url' => url($uri['path'], $uri['options']), '%name' => format_username($account)))); } else { drupal_set_message(t('A welcome message with further instructions has been sent to your e-mail address.')); diff --git a/modules/user/user.pages.inc b/modules/user/user.pages.inc index 6f997a6..76a24d3 100644 --- a/modules/user/user.pages.inc +++ b/modules/user/user.pages.inc @@ -124,7 +124,7 @@ function user_pass_submit($form, &$form_state) { // Mail one time login URL and instructions using current language. $mail = _user_mail_notify('password_reset', $account, $language); if (!empty($mail)) { - watchdog('user', 'Password reset instructions mailed to %name at %email.', array('%name' => $account->name, '%email' => $account->mail)); + watchdog('user', 'Password reset instructions mailed to %name at %email.', array('%name' => format_username($account), '%email' => $account->mail)); drupal_set_message(t('Further instructions have been sent to your e-mail address.')); } @@ -161,7 +161,7 @@ function user_pass_reset($form, &$form_state, $uid, $timestamp, $hashed_pass, $a $reset_link_account = user_load($uid); if (!empty($reset_link_account)) { drupal_set_message(t('Another user (%other_user) is already logged into the site on this computer, but you tried to use a one-time link for user %resetting_user. Please logout and try using the link again.', - array('%other_user' => $user->name, '%resetting_user' => $reset_link_account->name, '!logout' => url('user/logout'))), 'warning'); + array('%other_user' => format_username($user), '%resetting_user' => format_username($reset_link_account), '!logout' => url('user/logout'))), 'warning'); } else { // Invalid one-time link specifies an unknown user. drupal_set_message(t('The one-time login link you clicked is invalid.'), 'error'); @@ -192,7 +192,7 @@ function user_pass_reset($form, &$form_state, $uid, $timestamp, $hashed_pass, $a user_login_finalize(); // Clear any password reset flood events for this user. flood_clear_event('pass_reset_user', $account->uid); - watchdog('user', 'User %name used one-time login link at time %timestamp.', array('%name' => $account->name, '%timestamp' => $timestamp)); + watchdog('user', 'User %name used one-time login link at time %timestamp.', array('%name' => format_username($account), '%timestamp' => $timestamp)); drupal_set_message(t('You have just used your one-time login link. It is no longer necessary to use this link to log in. Please change your password.')); // Let the user's password be changed without the current password check. $token = drupal_random_key(); @@ -200,7 +200,7 @@ function user_pass_reset($form, &$form_state, $uid, $timestamp, $hashed_pass, $a drupal_goto('user/' . $user->uid . '/edit', array('query' => array('pass-reset-token' => $token))); } else { - $form['message'] = array('#markup' => t('

    This is a one-time login for %user_name and will expire on %expiration_date.

    Click on this button to log in to the site and change your password.

    ', array('%user_name' => $account->name, '%expiration_date' => format_date($timestamp + $timeout)))); + $form['message'] = array('#markup' => t('

    This is a one-time login for %user_name and will expire on %expiration_date.

    Click on this button to log in to the site and change your password.

    ', array('%user_name' => format_username($account), '%expiration_date' => format_date($timestamp + $timeout)))); $form['help'] = array('#markup' => '

    ' . t('This login can be used only once.') . '

    '); $form['actions'] = array('#type' => 'actions'); $form['actions']['submit'] = array('#type' => 'submit', '#value' => t('Log in')); @@ -236,7 +236,7 @@ function user_logout() { function user_logout_current_user() { global $user; - watchdog('user', 'Session closed for %name.', array('%name' => $user->name)); + watchdog('user', 'Session closed for %name.', array('%name' => format_username($user))); module_invoke_all('user_logout', $user); @@ -462,7 +462,7 @@ function user_cancel_confirm_form($form, &$form_state, $account) { $question = t('Are you sure you want to cancel your account?'); } else { - $question = t('Are you sure you want to cancel the account %name?', array('%name' => $account->name)); + $question = t('Are you sure you want to cancel the account %name?', array('%name' => format_username($account))); } $description = ''; if ($can_select_method) { @@ -519,7 +519,7 @@ function user_cancel_confirm_form_submit($form, &$form_state) { $account = user_save($account, $edit); _user_mail_notify('cancel_confirm', $account); drupal_set_message(t('A confirmation request to cancel your account has been sent to your e-mail address.')); - watchdog('user', 'Sent account cancellation request to %name %email.', array('%name' => $account->name, '%email' => '<' . $account->mail . '>'), WATCHDOG_NOTICE); + watchdog('user', 'Sent account cancellation request to %name %email.', array('%name' => format_username($account), '%email' => '<' . $account->mail . '>'), WATCHDOG_NOTICE); $form_state['redirect'] = "user/$account->uid"; }