You are here

function _user_mail_text in Drupal 7

Same name and namespace in other branches
  1. 4 modules/user.module \_user_mail_text()
  2. 5 modules/user/user.module \_user_mail_text()
  3. 6 modules/user/user.module \_user_mail_text()

Returns a mail string for a variable name.

Used by user_mail() and the settings forms to retrieve strings.

2 calls to _user_mail_text()
user_admin_settings in modules/user/user.admin.inc
Form builder; Configure user settings for this site.
user_mail in modules/user/user.module
Implements hook_mail().

File

modules/user/user.module, line 2751
Enables the user registration and login system.

Code

function _user_mail_text($key, $language = NULL, $variables = array(), $replace = TRUE) {
  $langcode = isset($language) ? $language->language : NULL;
  if ($admin_setting = variable_get('user_mail_' . $key, FALSE)) {

    // An admin setting overrides the default string.
    $text = $admin_setting;
  }
  else {

    // No override, return default string.
    switch ($key) {
      case 'register_no_approval_required_subject':
        $text = t('Account details for [user:name] at [site:name]', array(), array(
          'langcode' => $langcode,
        ));
        break;
      case 'register_no_approval_required_body':
        $text = t("[user:name],\n\nThank you for registering at [site:name]. You may now log in by clicking this link or copying and pasting it to your browser:\n\n[user:one-time-login-url]\n\nThis link can only be used once to log in and will lead you to a page where you can set your password.\n\nAfter setting your password, you will be able to log in at [site:login-url] in the future using:\n\nusername: [user:name]\npassword: Your password\n\n--  [site:name] team", array(), array(
          'langcode' => $langcode,
        ));
        break;
      case 'register_admin_created_subject':
        $text = t('An administrator created an account for you at [site:name]', array(), array(
          'langcode' => $langcode,
        ));
        break;
      case 'register_admin_created_body':
        $text = t("[user:name],\n\nA site administrator at [site:name] has created an account for you. You may now log in by clicking this link or copying and pasting it to your browser:\n\n[user:one-time-login-url]\n\nThis link can only be used once to log in and will lead you to a page where you can set your password.\n\nAfter setting your password, you will be able to log in at [site:login-url] in the future using:\n\nusername: [user:name]\npassword: Your password\n\n--  [site:name] team", array(), array(
          'langcode' => $langcode,
        ));
        break;
      case 'register_pending_approval_subject':
      case 'register_pending_approval_admin_subject':
        $text = t('Account details for [user:name] at [site:name] (pending admin approval)', array(), array(
          'langcode' => $langcode,
        ));
        break;
      case 'register_pending_approval_body':
        $text = t("[user:name],\n\nThank you for registering at [site:name]. Your application for an account is currently pending approval. Once it has been approved, you will receive another e-mail containing information about how to log in, set your password, and other details.\n\n\n--  [site:name] team", array(), array(
          'langcode' => $langcode,
        ));
        break;
      case 'register_pending_approval_admin_body':
        $text = t("[user:name] has applied for an account.\n\n[user:edit-url]", array(), array(
          'langcode' => $langcode,
        ));
        break;
      case 'password_reset_subject':
        $text = t('Replacement login information for [user:name] at [site:name]', array(), array(
          'langcode' => $langcode,
        ));
        break;
      case 'password_reset_body':
        $text = t("[user:name],\n\nA request to reset the password for your account has been made at [site:name].\n\nYou may now log in by clicking this link or copying and pasting it to your browser:\n\n[user:one-time-login-url]\n\nThis link can only be used once to log in and will lead you to a page where you can set your password. It expires after one day and nothing will happen if it's not used.\n\n--  [site:name] team", array(), array(
          'langcode' => $langcode,
        ));
        break;
      case 'status_activated_subject':
        $text = t('Account details for [user:name] at [site:name] (approved)', array(), array(
          'langcode' => $langcode,
        ));
        break;
      case 'status_activated_body':
        $text = t("[user:name],\n\nYour account at [site:name] has been activated.\n\nYou may now log in by clicking this link or copying and pasting it into your browser:\n\n[user:one-time-login-url]\n\nThis link can only be used once to log in and will lead you to a page where you can set your password.\n\nAfter setting your password, you will be able to log in at [site:login-url] in the future using:\n\nusername: [user:name]\npassword: Your password\n\n--  [site:name] team", array(), array(
          'langcode' => $langcode,
        ));
        break;
      case 'status_blocked_subject':
        $text = t('Account details for [user:name] at [site:name] (blocked)', array(), array(
          'langcode' => $langcode,
        ));
        break;
      case 'status_blocked_body':
        $text = t("[user:name],\n\nYour account on [site:name] has been blocked.\n\n--  [site:name] team", array(), array(
          'langcode' => $langcode,
        ));
        break;
      case 'cancel_confirm_subject':
        $text = t('Account cancellation request for [user:name] at [site:name]', array(), array(
          'langcode' => $langcode,
        ));
        break;
      case 'cancel_confirm_body':
        $text = t("[user:name],\n\nA request to cancel your account has been made at [site:name].\n\nYou may now cancel your account on [site:url-brief] by clicking this link or copying and pasting it into your browser:\n\n[user:cancel-url]\n\nNOTE: The cancellation of your account is not reversible.\n\nThis link expires in one day and nothing will happen if it is not used.\n\n--  [site:name] team", array(), array(
          'langcode' => $langcode,
        ));
        break;
      case 'status_canceled_subject':
        $text = t('Account details for [user:name] at [site:name] (canceled)', array(), array(
          'langcode' => $langcode,
        ));
        break;
      case 'status_canceled_body':
        $text = t("[user:name],\n\nYour account on [site:name] has been canceled.\n\n--  [site:name] team", array(), array(
          'langcode' => $langcode,
        ));
        break;
    }
  }
  if ($replace) {

    // We do not sanitize the token replacement, since the output of this
    // replacement is intended for an e-mail message, not a web browser.
    return token_replace($text, $variables, array(
      'language' => $language,
      'callback' => 'user_mail_tokens',
      'sanitize' => FALSE,
      'clear' => TRUE,
    ));
  }
  return $text;
}