You are here

function _user_registrationpassword_mail_text in User registration password 7

Same name and namespace in other branches
  1. 6 user_registrationpassword.module \_user_registrationpassword_mail_text()

Returns a mail string for a variable name.

See also

user_registrationpassword_mail()

user_registrationpassword_mail_tokens()

user_registrationpassword_mailkeys()

user_registrationpassword_mail_edit_text()

user_registrationpassword_mail_edit_token_types()

4 calls to _user_registrationpassword_mail_text()
user_registrationpassword_form_user_admin_settings_alter in ./user_registrationpassword.module
Implements hook_form_FORM_ID_alter().
user_registrationpassword_mail in ./user_registrationpassword.module
Implements hook_mail().
user_registrationpassword_mail_edit_text in ./user_registrationpassword.module
Implements hook_mail_edit_text().
user_registrationpassword_variable_mail_default in ./user_registrationpassword.module
Default callback for user_registrationpassword mail variables.

File

./user_registrationpassword.module, line 324
Enables password creation on registration form.

Code

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

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

    // No override, return default string.
    switch ($key) {
      case 'register_subject':
        $text = t('Account details for [user:name] at [site:name]', array(), array(
          'langcode' => $langcode,
        ));
        break;
      case 'register_body':
        $text = t("[user:name],\n\nThank you for registering at [site:name]. You may now log in and verify your account by clicking this link or copying and pasting it to your browser:\n\n[user:registrationpassword-url]\n\nThis link can only be used once. 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_activated_subject':
        $text = t('Welcome message for [user:name] at [site:name]', array(), array(
          'langcode' => $langcode,
        ));
        break;
      case 'status_activated_body':
        $text = t("[user:name],\n\nYour account at [site:name] has been activated.\n\nYou will be able to log in to [site:login-url] in the future using:\n\nusername: [user:name]\npassword: your password.\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_registrationpassword_mail_tokens',
      'sanitize' => FALSE,
      'clear' => TRUE,
    ));
  }
  return $text;
}