You are here

function _password_policy_mail_text in Password Policy 7

Same name and namespace in other branches
  1. 5 password_policy.module \_password_policy_mail_text()
  2. 6 password_policy.module \_password_policy_mail_text()

Returns a mail string for a variable name.

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

1 call to _password_policy_mail_text()
password_policy_mail in ./password_policy.module
Implements hook_mail().

File

./password_policy.module, line 1172
Allows enforcing restrictions on user passwords by defining policies.

Code

function _password_policy_mail_text($key, $language = NULL, $variables = array(), $replace = TRUE) {
  $langcode = isset($language) ? $language->language : NULL;
  switch ($key) {
    case 'warning_subject':
      if (function_exists('i18n_variable_get')) {
        $text = i18n_variable_get('password_policy_warning_subject', $langcode, PASSWORD_POLICY_DEFAULT_WARNING_SUBJECT);
      }
      else {
        $text = variable_get('password_policy_warning_subject', PASSWORD_POLICY_DEFAULT_WARNING_SUBJECT);
      }
      break;
    case 'warning_body':
      if (function_exists('i18n_variable_get')) {
        $text = i18n_variable_get('password_policy_warning_body', $langcode, PASSWORD_POLICY_DEFAULT_WARNING_BODY);
      }
      else {
        $text = variable_get('password_policy_warning_body', PASSWORD_POLICY_DEFAULT_WARNING_BODY);
      }
      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' => 'password_policy_mail_tokens',
      'sanitize' => FALSE,
      'clear' => TRUE,
    ));
  }
  return $text;
}