You are here

function logintoboggan_tokens in LoginToboggan 7

Same name and namespace in other branches
  1. 8 logintoboggan.tokens.inc \logintoboggan_tokens()

Implements hook_tokens().

File

./logintoboggan.tokens.inc, line 26
Builds placeholder replacement tokens for logintoboggan-related data.

Code

function logintoboggan_tokens($type, $tokens, array $data = array(), array $options = array()) {
  $replacements = array();
  $url_options = array(
    'absolute' => TRUE,
  );
  if (isset($options['language'])) {
    $url_options['language'] = $options['language'];
  }
  if ($type == 'user' && !empty($data['user'])) {
    $account = $data['user'];
    foreach ($tokens as $name => $original) {
      switch ($name) {

        // Validating URL.
        case 'validate-url':
          if (variable_get('user_register', USER_REGISTER_VISITORS_ADMINISTRATIVE_APPROVAL) == USER_REGISTER_VISITORS) {
            $replacements[$original] = logintoboggan_eml_validate_url($account, $url_options);
          }
          break;
        case 'password':
          if (isset($account->password)) {
            $replacements[$original] = $account->password;
          }
          break;
      }
    }
  }
  return $replacements;
}