logintoboggan.tokens.inc 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. <?php
  2. /**
  3. * @file
  4. * Builds placeholder replacement tokens for logintoboggan-related data.
  5. */
  6. /**
  7. * Implements hook_token_info().
  8. */
  9. function logintoboggan_token_info() {
  10. $info['tokens']['user']['validate-url'] = array(
  11. 'name' => t('Validate URL'),
  12. 'description' => t('The URL of the account validation page, provided by logintoboggan.'),
  13. );
  14. return $info;
  15. }
  16. /**
  17. * Implements hook_tokens().
  18. */
  19. function logintoboggan_tokens($type, $tokens, array $data = array(), array $options = array()) {
  20. $replacements = array();
  21. $url_options = array('absolute' => TRUE);
  22. if (isset($options['language'])) {
  23. $url_options['language'] = $options['language'];
  24. }
  25. if ($type == 'user' && !empty($data['user'])) {
  26. $account = $data['user'];
  27. foreach ($tokens as $name => $original) {
  28. switch ($name) {
  29. // Validating URL.
  30. case 'validate-url':
  31. if (variable_get('user_register', USER_REGISTER_VISITORS_ADMINISTRATIVE_APPROVAL) == USER_REGISTER_VISITORS) {
  32. $replacements[$original] = logintoboggan_eml_validate_url($account, $url_options);
  33. }
  34. break;
  35. }
  36. }
  37. }
  38. return $replacements;
  39. }