You are here

function email_confirm_mail_text in Email Change Confirmation 7

Same name and namespace in other branches
  1. 6 email_confirm.module \email_confirm_mail_text()

Returns a mail string for a variable name.

3 calls to email_confirm_mail_text()
email_confirm_admin_settings in ./email_confirm.module
Implements hook_settings().
email_confirm_mail in ./email_confirm.module
Implements hook_mail().
email_confirm_variable_info in ./email_confirm.module
Implements hook_variable_info().

File

./email_confirm.module, line 402
The Email Change Confirmation module.

Code

function email_confirm_mail_text($key, $language = NULL, $variables = array(), $replace = TRUE) {
  $langcode = isset($language) ? $language->language : NULL;
  if (module_exists('i18n_variable') && $langcode) {
    $admin_setting = i18n_variable_get('email_confirm_' . $key, $langcode);
  }
  else {
    $admin_setting = variable_get('email_confirm_' . $key, FALSE);
  }
  if ($admin_setting) {

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

    // No override, return default string.
    switch ($key) {
      case 'confirmation_email_subject':
        $text = t('Email address change request for [user:name] at [site:name]', array(), array(
          'langcode' => $langcode,
        ));
        break;
      case 'confirmation_email_body':
        $text = t("Hello [user:name],\n\nA request to change your email address has been made at [site:name].\nYou need to verify the change by clicking on the link below or by\ncopying and pasting it in your browser:\n\n[email_confirm:email_url]\n\nThis is a one-time URL - it can be used only once. It expires after\n24 hours. If you do not click the link to confirm, your email address\nat [site:name] will not be updated.\n", array(), array(
          'langcode' => $langcode,
        ));
        break;
      case 'confirmation_original_email_body':
        $text = t("Hello [user:name],\n\nA request to change your email address has been made at [site:name].\nIn order to confirm the update of your email address you will\nneed to follow the instructions sent to your new email address\nwithin 24 hours.\n", 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' => 'email_confirm_mail_tokens',
      'sanitize' => FALSE,
    ));
  }
  return $text;
}