You are here

function _signup_get_email_tokens in Signup 6.2

Same name and namespace in other branches
  1. 5.2 signup.module \_signup_get_email_tokens()
  2. 6 signup.module \_signup_get_email_tokens()
  3. 7 signup.module \_signup_get_email_tokens()

Helper function that returns an array of tokens for signup emails.

These are the hard-coded tokens provided by signup.module which are available even when token.module is not enabled.

Parameters

$node: An object with info about the signup-enabled node. Must contain at least 'nid', 'title', and 'TODO: time?' fields.

$signup: An object with info about the user who signed up.

Return value

An array of tokens and their replacement values.

2 calls to _signup_get_email_tokens()
signup_mail in ./signup.module
Implementation of hook_mail().
signup_send_broadcast in includes/broadcast.inc
Send an email message to users who have signed up to a node.

File

./signup.module, line 1557
The Signup module (http://drupal.org/project/signup) manages replies to nodes. In particular, it's good for event management. Signup supports sending reminder emails and automatically closing signups for nodes with a start time, via the Event…

Code

function _signup_get_email_tokens($node, $signup) {

  // Tokens about the node itself are easy and don't require any logic.
  $tokens = array(
    '%node_title' => $node->title,
    '%node_url' => url('node/' . $node->nid, array(
      'absolute' => TRUE,
    )),
    '%node_start_time' => signup_format_date($node),
  );

  // Tokens about the user are harder, since we need to potentially do
  // things differently for anonymous vs. authenticated signups, and
  // might want to do other processing on the signup form data.
  // Get the array of custom signup data (if any).
  $signup_data = array();
  if (!empty($signup->form_data)) {
    if (is_array($signup->form_data)) {
      $signup_data = $signup->form_data;
    }
    else {
      $signup_data = unserialize($signup->form_data);
    }
    $tokens['%user_signup_info'] = theme('signup_email_token_custom_data', $signup_data);
  }
  else {
    $tokens['%user_signup_info'] = '';
  }
  $tokens['%user_name'] = _signup_get_username($signup);
  $tokens['%user_mail'] = _signup_get_email($signup);
  $tokens['%cancel_signup_url'] = _signup_get_cancel_link($signup->sid);
  return $tokens;
}