You are here

function signup_send_forwarding_mail in Signup 6.2

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

Send the signup forwarding mail when a user signs up for something.

Parameters

$signup: The fully-loaded signup object representing the user's signup.

$node: The fully-loaded node object which the user signed up to.

Return value

The return value from drupal_mail() if the mail is sent, or FALSE if the messsage is aborted for some reason (node not configured to send it, user doesn't have a valid e-mail address, etc).

See also

signup_sign_up_user()

drupal_mail()

1 call to signup_send_forwarding_mail()
signup_sign_up_user in ./signup.module
Signs up a user to a node.

File

./signup.module, line 1371
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_send_forwarding_mail($signup, $node) {
  if (!$node->signup_forwarding_email) {
    return FALSE;
  }
  $user_mail = _signup_get_email($signup);
  if (empty($user_mail)) {
    return FALSE;
  }
  $message = t('The following information was submitted as a signup for !title', array(
    '!title' => $node->title,
  ));
  if (_signup_get_node_scheduler($node) != 'none') {
    $message .= "\n\r" . t('Date/Time: !time', array(
      '!time' => signup_format_date($node),
    ));
  }
  $message .= "\n\r\n\r" . t('Username: !name', array(
    '!name' => empty($signup->uid) ? variable_get('anonymous', t('Anonymous')) : $signup->name,
  ));
  if (!empty($signup->uid)) {

    // For authenticated users, just include a link to their profile page.
    $message .= "\n\r" . t('Profile page: !url', array(
      '!url' => url('user/' . $signup->uid, array(
        'absolute' => TRUE,
      )),
    ));
  }
  else {

    // For anonymous users, their email is all we've got, so disclose it.
    $message .= "\n\r" . t('E-mail: !email', array(
      '!email' => $user_mail,
    ));
  }
  if (!empty($signup->form_data)) {
    $message .= "\n\r\n\r" . theme('signup_email_token_custom_data', $signup->form_data);
  }
  $node_type_name = node_get_types('name', $node->type);
  $from = variable_get('site_mail', ini_get('sendmail_from'));
  $params = array(
    'subject' => t('Signup confirmation for !node_type: !title', array(
      '!node_type' => $node_type_name,
      '!title' => $node->title,
    )),
    'body' => $message,
    'node' => $node,
    'signup' => $signup,
    'header' => array(
      'From' => t('New !node_type Signup', array(
        '!node_type' => $node_type_name,
      )) . "<{$from}>",
    ),
  );
  if (module_exists('token')) {
    $params['body'] = token_replace_multiple($params['body'], array(
      'node' => $node,
      'signup' => $signup,
      'global' => NULL,
    ));
  }
  $language = user_preferred_language($signup);
  return drupal_mail('signup', 'signup_forwarding_mail', $node->signup_forwarding_email, $language, $params, $from);
}