views_send.tokens.inc 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. <?php
  2. /**
  3. * @file
  4. * Token integration for the Views Send module.
  5. */
  6. /**
  7. * Implements hook_token_info().
  8. *
  9. * These token are used by Rules and not in the Views form.
  10. */
  11. function views_send_token_info() {
  12. $data = array();
  13. foreach (_views_send_email_message_property_info() as $key => $info) {
  14. $data[$key] = array(
  15. 'name' => $info['label'],
  16. 'description' => ''
  17. );
  18. }
  19. $type = array(
  20. 'name' => t('Views Send e-mail message'),
  21. 'description' => t('Tokens for Views Send e-mail message.'),
  22. 'needs-data' => 'views_send_email_message',
  23. );
  24. return array(
  25. 'types' => array('views_send_email_message' => $type),
  26. 'tokens' => array('views_send_email_message' => $data),
  27. );
  28. }
  29. /**
  30. * Implementation hook_tokens().
  31. *
  32. * These token replacements are used by Rules and not in the Views form.
  33. */
  34. function views_send_tokens($type, $tokens, array $data = array(), array $options = array()) {
  35. $replacements = array();
  36. if ($type == 'views_send_email_message' && !empty($data['views_send_email_message'])) {
  37. foreach ($tokens as $name => $original) {
  38. $replacements[$original] = $data['views_send_email_message']->{$name};
  39. }
  40. }
  41. return $replacements;
  42. }