Index: signup.install
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/signup/signup.install,v
retrieving revision 1.24.2.3
diff -u -5 -p -u -p -r1.24.2.3 signup.install
--- signup.install	27 Dec 2008 00:40:30 -0000	1.24.2.3
+++ signup.install	4 Feb 2009 22:35:04 -0000
@@ -14,48 +14,10 @@ function signup_schema() {
         'type' => 'int',
         'unsigned' => TRUE,
         'not null' => TRUE,
         'default' => 0,
       ),
-      'forwarding_email' => array(
-        'description' => t('Email address to send signup notifications to.'),
-        'type' => 'varchar',
-        'length' => 64,
-        'not null' => TRUE,
-        'default' => '',
-      ),
-      'send_confirmation' => array(
-        'description' => t('Boolean indicating whether confirmation emails should be sent.'),
-        'type' => 'int',
-        'not null' => TRUE,
-        'default' => 0,
-      ),
-      'confirmation_email' => array(
-        'description' => t('Email template to send to users when they signup.'),
-        'type' => 'text',
-        'size' => 'big',
-        'not null' => TRUE,
-      ),
-      'send_reminder' => array(
-        'description' => t('Boolean indicating whether reminder emails should be sent. This is set to 0 once the reminders are sent.'),
-        'type' => 'int',
-        'not null' => TRUE,
-        'default' => 0,
-      ),
-      'reminder_days_before' => array(
-        'description' => t('Number of days before the start of a time-based node when the reminder emails should be sent.'),
-        'type' => 'int',
-        'unsigned' => TRUE,
-        'not null' => TRUE,
-        'default' => 0,
-      ),
-      'reminder_email' => array(
-        'description' => t('Email template to send to users to remind them about a signup.'),
-        'type' => 'text',
-        'size' => 'big',
-        'not null' => TRUE,
-      ),
       'close_in_advance_time' => array(
         'description' => t('Number of hours before the start of a time-based node when signups should automatically be closed. This column is not currently used and the behavior is controlled by a site-wide setting.  See http://drupal.org/node/290249 for more information.'),
         'type' => 'int',
         'unsigned' => TRUE,
         'not null' => TRUE,
@@ -458,5 +420,24 @@ function signup_update_6002() {
   );
   db_add_field($ret, 'signup_log', 'attended', $field);
   return $ret;	
 }
 
+/**
+ * Remove e-mail related columns, since they are moving to the
+ * signup_mail module's own table.
+ *
+ * http://drupal.org/node/290305 for more information.
+ * *** Disabled until we find a way to make sure the data has been
+ * migrated before we drop the columns.
+function signup_update_6003() {
+  $ret = array();
+
+  db_drop_field($ret, 'signup', 'forwarding_email');
+  db_drop_field($ret, 'signup', 'send_confirmation');
+  db_drop_field($ret, 'signup', 'confirmation_email');
+  db_drop_field($ret, 'signup', 'send_reminder');
+  db_drop_field($ret, 'signup', 'reminder_days_before');
+  db_drop_field($ret, 'signup', 'reminder_email');
+  return $ret;
+}/**/
+
Index: signup.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/signup/signup.module,v
retrieving revision 1.205.2.15
diff -u -5 -p -u -p -r1.205.2.15 signup.module
--- signup.module	25 Jan 2009 03:10:58 -0000	1.205.2.15
+++ signup.module	4 Feb 2009 22:35:04 -0000
@@ -406,21 +406,10 @@ function signup_menu() {
     'type' => MENU_LOCAL_TASK,
     'weight' => 5,
     'file' => 'signup_form.inc',
     'file path' => $path,
   );
-  $items['node/%node/signups/broadcast'] = array(
-    'title' => 'Signup broadcast',
-    'page callback' => 'drupal_get_form',
-    'page arguments' => array('signup_broadcast_form', 1),
-    'access callback' => '_signup_menu_access',
-    'access arguments' => array(1, 'email'),
-    'type' => MENU_LOCAL_TASK,
-    'weight' => 10,
-    'file' => 'broadcast.inc',
-    'file path' => $path,
-  );
 
   // Add extra menu items if we're not using views.
   if (!module_exists('views')) {
     module_load_include('inc', 'signup', 'includes/no_views');
     signup_no_views_menu($items);
@@ -555,11 +544,10 @@ function _signup_menu_signup_access($sig
  * If they have permission to signup for nodes and the site is configured to
  * put the signup form on a separate tab from the node itself, display the
  * current user's signup info (either a form to signup, or their current
  * signup).  If not, see if they can view a signup user list, and redirect
  * there.  If not, see if they can administer signups and redirect there.
- * Finally, if they can at least send a signup broadcast, go there.
  *
  * @param $node
  *   Fully loaded node object to generate the node/N/signup menu handler for.
  *
  * @return
@@ -582,13 +570,10 @@ function signup_node_tab_page($node) {
     drupal_goto("node/$node->nid/signups/list");
   }
   elseif ($admin) {
     drupal_goto("node/$node->nid/signups/admin");
   }
-  elseif ($email) {
-    drupal_goto("node/$node->nid/signups/broadcast");
-  }
 }
 
 /**
  * Initialize the necessary scheduler backend(s).
  */
@@ -1156,84 +1141,14 @@ function signup_sign_up_user($signup_for
     if (!empty($extra)) {
       $signup_info = array_merge($signup_info, $extra);
     }
     $signup_form_data = serialize($signup_info);
 
-    // Figure out if confirmation or reminder emails will be sent and
-    // inform the user.
-    $confirmation_email = $node->signup_send_confirmation ? '  '. t('You will receive a confirmation email shortly which contains further information about this %node_type.', array('%node_type' => node_get_types('name', $node->type))) : '';
-    $reminder_email = $node->signup_send_reminder ? '  '. t('You will receive a reminder email !number !days before the %node_type.', array('!number' => $node->signup_reminder_days_before, '!days' => format_plural($node->signup_reminder_days_before, 'day', 'days'), '%node_type' => node_get_types('name', $node->type))) : '';
-
     // Insert the user into the signup_log.
     db_query("INSERT INTO {signup_log} (uid, nid, anon_mail, signup_time, form_data) VALUES (%d, %d, '%s', %d, '%s')", $signup_form['uid'], $signup_form['nid'], $signup_anon_mail, $curtime, $signup_form_data);
     $sid = db_last_insert_id('signup_log', 'sid');
 
-    $from = variable_get('site_mail', ini_get('sendmail_from'));
-
-    // Get the hard-coded tokens provided by the signup module to use
-    // for the confirmation and/or forwarding emails.  We need to create
-    // an object representing the user's signup to get the right values.
-    $signup = $user;
-    $signup->form_data = $signup_info;
-    $signup->sid = $sid;
-    if (!empty($signup_anon_mail)) {
-      $signup->anon_mail = $signup_anon_mail;
-    }
-    $user_mail = _signup_get_email($signup);
-    $node_type_name = node_get_types('name', $node->type);
-    // If a confirmation is to be sent, compose the mail message,
-    // replace the tokens with the right values, and send it.
-    if ($node->signup_send_confirmation && $user_mail) {
-      $params = array(
-        'subject' => t('Signup confirmation for !node_type: !title', array('!node_type' => $node_type_name, '!title' => $node->title)),
-        'body' => $node->signup_confirmation_email,
-        'node' => $node,
-        'signup' => $signup,
-      );
-      if (module_exists('token')) {
-        $params['body'] = token_replace($params['body'], 'node', $node);
-      }
-      $language = user_preferred_language($signup);
-      drupal_mail('signup', 'signup_confirmation_mail', $user_mail, $language, $params, $from);
-    }
-
-    // If a forwarding email is to be sent, compose the mail message,
-    // replace the tokens with the right values, and send it.
-    if ($node->signup_forwarding_email) {
-      $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($user->uid) ? variable_get('anonymous', t('Anonymous')) : $user->name));
-      if (!empty($user->uid)) {
-        // For authenticated users, just include a link to their profile page.
-        $message .= "\n\r". t('Profile page: !url', array('!url' => url('user/'. $user->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_tokens['%user_signup_info'])) {
-        $message .= "\n\r\n\r". $signup_tokens['%user_signup_info'];
-      }
-      $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($params['body'], 'node', $node);
-      }
-      $language = user_preferred_language($signup);
-      drupal_mail('signup', 'signup_forwarding_mail', $node->signup_forwarding_email, $language, $params, $from);
-    }
-
-    drupal_set_message(t('Signup to !title confirmed.', array('!title' => l($node->title, "node/$node->nid"))) . $confirmation_email . $reminder_email);
-
     $node->signup_total++;
     if ($node->signup_close_signup_limit) {
       _signup_check_limit($node, 'total');
     }
   }
@@ -1335,90 +1250,10 @@ function signup_views_api() {
     'api' => 2.0,
     'path' => drupal_get_path('module', 'signup') .'/views',
   );
 }
 
-/**
- * Implementation of hook_mail().
- *
- * Constructs all of the email messages generated by the signup module.
- *
- * @param $key
- *   Unique key to indicate what message to build.
- * @param $message
- *   Reference to the message array being built.
- * @param $params
- *   Array of parameters to indicate what text to include in the message body.
- *   If $params['ignore_tokens'] is TRUE, none of the signup-provided tokens
- *   in the message body will be replaced, otherwise, tokens are replaced
- *   using the node passed in as $params['node'] and the signup data from
- *   $params['signup'].
- *
- * @see drupal_mail()
- * @see _signup_cron_send_reminders()
- * @see signup_sign_up_user()
- * @see signup_broadcast_form_submit()
- */
-function signup_mail($key, &$message, $params) {
-  if (empty($params['ignore_tokens'])) {
-    $tokens = _signup_get_email_tokens($params['node'], $params['signup']);
-    $body = strtr($params['body'], $tokens);
-    $subject = strtr($params['subject'], $tokens);
-  }
-  else {
-    $body = $params['body'];
-    $subject = $params['subject'];
-  }
-  $message['subject'] .= str_replace(array("\r", "\n"), '', $subject);
-  $message['body'][] = $body;
-}
-
-/**
- * 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.
- *
- * @param $node
- *   An object with info about the signup-enabled node. Must contain
- *   at least 'nid', 'title', and 'TODO: time?' fields.
- * @param $signup
- *   An object with info about the user who signed up.
- *
- * @return
- *   An array of tokens and their replacement values.
- */
-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);
-  }
-
-  $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;
-}
 
 /**
  * Get the email address to use for a given signup.
  *
  * @param $signup
Index: signup_mail/signup_mail.broadcast.inc
===================================================================
RCS file: signup_mail/signup_mail.broadcast.inc
diff -N signup_mail/signup_mail.broadcast.inc
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ signup_mail/signup_mail.broadcast.inc	4 Feb 2009 22:35:04 -0000
@@ -0,0 +1,189 @@
+<?php
+// $Id$
+
+
+/**
+ * @file signup_mail_broadcast.inc
+ * Code related to sending signup broadcast messages.
+ */
+
+/**
+ * Form builder for the signup broadcast form.
+ *
+ * @param $node
+ *   The node that the broadcast form is being attached to.
+ */
+function signup_broadcast_form($form_state, $node) {
+  $signups = signup_get_signups($node->nid);
+  if (empty($signups)) {
+    $form['no_users'] = array(
+      '#value' => t('No users have signup up for this %node_type.', array('%node_type' => node_get_types('name', $node->type))),
+    );
+    return $form;
+  }
+
+  $tokens = array('%node_title', '%node_url', '%user_mail', '%user_name', t('%cancel_signup_url (access to this link is denied to users without the "cancel own signups" permission)'));
+  if (_signup_get_node_scheduler($node) != 'none') {
+    $tokens = array_merge(array('%node_start_time'), $tokens);
+  }
+  if (module_exists('token')) {
+    $token_text = t('Supported string substitutions: %tokens, and any tokens in the %replacement_tokens list.', array('%tokens' => implode(', ', $tokens), '%replacement_tokens' => t('Replacement tokens')));
+  }
+  else {
+    $token_text = t('Supported string substitutions: %tokens.', array('%tokens' => implode(', ', $tokens)));
+  }
+
+  $form['subject'] = array(
+    '#type' => 'textfield',
+    '#title' => t('Subject'),
+    '#required' => TRUE,
+  );
+  $form['message'] = array(
+    '#type' => 'textarea',
+    '#title' => t('Message body'),
+    '#required' => TRUE,
+    '#description' => t('Body of the email message you wish to send to all users who have signed up for this %node_type. !token_description', array('%node_type' => node_get_types('name', $node->type), '!token_description' => $token_text)),
+    '#rows' => 10,
+  );
+
+  if (module_exists('token')) {
+    module_load_include('inc', 'signup', 'includes/token_help');
+    _signup_token_help($form, 'message_tokens_fieldset');
+  }
+
+  $form['copy'] = array(
+    '#type' => 'checkbox',
+    '#title' => t('Send yourself a copy.'),
+  );
+
+  $form['send'] = array(
+    '#type' => 'submit',
+    '#value' => t('Send'),
+  );
+  $form['nid'] = array(
+    '#type' => 'value',
+    '#value' => $node->nid,
+  );
+
+  global $user;
+  if (user_access('administer site configuration')) {
+    $form['from'] = array(
+      '#type' => 'textfield',
+      '#title' => t('From'),
+      '#required' => TRUE,
+      '#default_value' => $user->mail,
+      '#weight' => '-10',
+    );
+  }
+  else {
+    $form['from'] = array(
+      '#value' => t('This message will be sent from: %from', array('%from' => $user->mail)),
+      '#pre' => '<strong>',
+      '#post' => '</strong>',
+    );
+  }
+  return $form;
+}
+
+/**
+ * Submit callback for the signup broadcast form.
+ *
+ * @param $form
+ *   The broadcast form being submitted.
+ * @param $form_state
+ *   The state of the submitted form (including values).
+ *
+ * @see signup_send_broadcast()
+ */
+function signup_broadcast_form_submit($form, &$form_state) {
+  global $user;
+  if (user_access('administer site configuration')) {
+    $from = $form_state['values']['from'];
+  }
+  else {
+    $from = $user->mail;
+  }
+  signup_send_broadcast($form_state['values']['nid'], $form_state['values']['subject'], $form_state['values']['message'], $from, !empty($form_state['values']['copy']));
+}
+
+/**
+ * Send an email message to users who have signed up to a node.
+ *
+ * @param $nid
+ *   Node ID of the signup node to send a broadcast about.
+ * @param $subject
+ *   The subject of the broadcast message to send.
+ * @param $body
+ *   The body of the broadcast message to send.
+ * @param $from
+ *   The from address to use when sending the broadcast message.
+ * @param $copy
+ *   Optional boolean indicating if the current user should get a copy.
+ * @param $signups
+ *   Optional array of signup objects to send the broadcast to.  Each object
+ *   in the array should at least contain the following fields:
+ *   - "sid": The unique signup ID
+ *   - "mail" or "anon_mail": E-mail address to send to depending on if it's
+ *     an authenticated or anonymous signup.
+ *   - "name": Username of an authenticated signup.
+ *   - "form_data": The optional custom signup form data for this signup.
+ *   - "language": The user's prefered language (if known).
+ *
+ * @see signup_get_signup()
+ * @see _signup_get_email()
+ * @see _signup_get_email_tokens()
+ */
+function signup_send_broadcast($nid, $subject, $body, $from, $copy = FALSE, $signups = array()) {
+  global $user;
+  $send_all = FALSE;
+  // If the parameter isn't defined, grab all users who signed up to the node.
+  if (empty($signups)) {
+    $signups = signup_get_signups($nid);
+    $send_all = TRUE;
+  }
+  // Make sure that signup_get_signups() returned something for this node.
+  if (!empty($signups)) {
+    $node = node_load($nid);
+    foreach ($signups as $signup) {
+      $user_mail = _signup_get_email($signup);
+      $params = array(
+        'subject' => $subject,
+        'body' => $body,
+        'node' => $node,
+        'signup' => $signup,
+      );
+      if (module_exists('token')) {
+        $params['body'] = token_replace($params['body'], 'node', $node);
+      }
+      $language = user_preferred_language($signup);
+      drupal_mail('signup', 'signup_broadcast_mail', $user_mail, $language, $params, $from);
+      watchdog('signup', 'Broadcast email for %title sent to %email.', array('%title' => $node->title, '%email' => $user_mail), WATCHDOG_NOTICE, l(t('view'), 'node/'. $node->nid));
+    }
+    if ($copy) {
+      $sender_email = _signup_get_email($user);
+      $signup_tokens = _signup_get_email_tokens($node, $user);
+      $message = strtr($body, $signup_tokens);
+      if (module_exists('token')) {
+        // If the token.module is enabled, also handle any tokens it provides.
+        $message = token_replace($message, 'node', $node);
+      }
+      $final_text = theme('signup_broadcast_sender_copy', $body, $message);
+      $params = array(
+        'subject' => $subject,
+        'body' => $final_text,
+        'ignore_tokens' => TRUE,
+      );
+      $language = user_preferred_language($user);
+      drupal_mail('signup', 'signup_broadcast_mail', $sender_email, $language, $params, $from);
+      watchdog('signup', 'Broadcast email copy for %title sent to %email.', array('%title' => $node->title, '%email' => $sender_email), WATCHDOG_NOTICE, l(t('view'), 'node/'. $node->nid));
+      drupal_set_message(t('Sent a copy of this message to %email', array('%email' => $sender_email)));
+    }
+  }
+  if ($send_all) {
+    drupal_set_message(t('Message sent to all users who have signed up'));
+  }
+  else {
+    drupal_set_message(t('Message sent to selected users who have signed up'));
+  }
+}
+
Index: signup_mail/signup_mail.info
===================================================================
RCS file: signup_mail/signup_mail.info
diff -N signup_mail/signup_mail.info
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ signup_mail/signup_mail.info	4 Feb 2009 22:35:04 -0000
@@ -0,0 +1,6 @@
+; $Id$
+name = Signup e-mails
+description = "Handles the sending of email for the signup module"
+core = 6.x
+dependencies[] = signup
+
Index: signup_mail/signup_mail.install
===================================================================
RCS file: signup_mail/signup_mail.install
diff -N signup_mail/signup_mail.install
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ signup_mail/signup_mail.install	4 Feb 2009 22:35:04 -0000
@@ -0,0 +1,102 @@
+<?php
+// $Id$
+
+/**
+ * Implementation of hook_install().
+ */
+function signup_mail_install() {
+  // Create table.
+  drupal_install_schema('signup_mail');
+}
+
+/**
+ * Implementation of hook_uninstall().
+ */
+function signup_mail_uninstall() {
+  // Remove tables.
+  drupal_uninstall_schema('signup_mail');
+
+  $variables = db_query("SELECT name FROM {variable} WHERE name LIKE 'signup_mail%%'");
+  while ($variable = db_fetch_object($variables)) {
+    variable_del($variable->name);
+  }
+}
+
+/**
+ * Implementation of hook_schema().
+ */
+function signup_mail_schema() {
+  $schema = array();
+  $schema['signup_mail'] = array(
+    'description' => t('Signup e-mail module per-node settings.'),
+    'fields' => array(
+      'nid' => array(
+        'description' => t('Primary key: node ID'),
+        'type' => 'int',
+        'unsigned' => TRUE,
+        'not null' => TRUE,
+        'default' => 0,
+      ),
+      'forwarding_mail' => array(
+        'description' => t('E-mail address to send signup notifications to.'),
+        'type' => 'varchar',
+        'length' => 64,
+        'not null' => TRUE,
+        'default' => '',
+      ),
+      'send_confirmation' => array(
+        'description' => t('Boolean indicating whether confirmation e-mails should be sent.'),
+        'type' => 'int',
+        'not null' => TRUE,
+        'default' => 0,
+      ),
+      'confirmation_message' => array(
+        'description' => t('E-mail template to send to users when they signup.'),
+        'type' => 'text',
+        'size' => 'medium',
+        'not null' => TRUE,
+      ),
+      'send_reminder' => array(
+        'description' => t('Boolean indicating whether reminder e-mails should be sent. This is set to 0 once the reminders are sent.'),
+        'type' => 'int',
+        'not null' => TRUE,
+        'default' => 0,
+      ),
+      'reminder_days_before' => array(
+        'description' => t('Number of days before the start of a time-based node when the reminder e-mails should be sent.'),
+        'type' => 'int',
+        'unsigned' => TRUE,
+        'not null' => TRUE,
+        'default' => 0,
+      ),
+      'reminder_message' => array(
+        'description' => t('E-mail template to send to users to remind them about a signup.'),
+        'type' => 'text',
+        'size' => 'medium',
+        'not null' => TRUE,
+      ),
+    ),
+    'primary key' => array('nid'),
+  );
+  return $schema;
+}
+/**
+ * Implementation of hook_update_N().
+ *
+ * Migrate the contents of the mail-related fields from the main signup
+ * table, since those are going away, and the data is supposed to be
+ * stored here.
+ */
+function signup_mail_update_6000() {
+  $query = db_query("SELECT nid, forwarding_email, send_confirmation,
+    confirmation_email, send_reminder, reminder_days_before, reminder_email FROM {signup}");
+  while ($signup = db_fetch_array($query)) {
+    db_query("INSERT INTO {signup_mail} (nid, forwarding_mail,
+      send_confirmation, confirmation_message, send_reminder,
+      reminder_days_before, reminder_message) 
+      VALUES (%d, '%s', %d, '%s', %d, %d, '%s');", $signup);
+  }
+  drupal_set_message(t('Data migration from signup.module to
+    signup_email module completed.'));
+  return array();
+}
Index: signup_mail/signup_mail.module
===================================================================
RCS file: signup_mail/signup_mail.module
diff -N signup_mail/signup_mail.module
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ signup_mail/signup_mail.module	4 Feb 2009 22:35:05 -0000
@@ -0,0 +1,185 @@
+<?php
+// $Id$
+
+/**
+ * @file signup_mail/signup_mail.module
+ * Handle e-mail messages from the signup module. Originally a part of
+ * signup module itself, but split off to make the signup module leaner.
+ */
+
+/**
+ * Implementation of hook_menu().
+ */
+function signup_mail_menu() {
+  $items = array();
+
+  $items['node/%node/signups/broadcast'] = array(
+    'title' => 'Signup broadcast',
+    'page callback' => 'drupal_get_form',
+    'page arguments' => array('signup_broadcast_form', 1),
+    'access callback' => '_signup_menu_access',
+    'access arguments' => array(1, 'email'),
+    'type' => MENU_LOCAL_TASK,
+    'weight' => 10,
+    'file' => 'signup_mail.broadcast.inc',
+  );
+
+  return $items;
+}
+
+/**
+ * Implementation of hook_signup_sign_up().
+ */
+function signup_mail_signup_sign_up($node, $account) {
+  // Figure out if confirmation or reminder emails will be sent and
+  // inform the user.
+  $confirmation_email = $node->signup_send_confirmation ? '  '. t('You will receive a confirmation email shortly which contains further information about this %node_type.', array('%node_type' => node_get_types('name', $node->type))) : '';
+  $reminder_email = $node->signup_send_reminder ? '  '. t('You will receive a reminder email !number !days before the %node_type.', array('!number' => $node->signup_reminder_days_before, '!days' => format_plural($node->signup_reminder_days_before, 'day', 'days'), '%node_type' => node_get_types('name', $node->type))) : '';
+
+  $from = variable_get('site_mail', ini_get('sendmail_from'));
+
+  // Get the hard-coded tokens provided by the signup module to use
+  // for the confirmation and/or forwarding emails.  We need to create
+  // an object representing the user's signup to get the right values.
+  $signup = $account;
+  $signup->form_data = $signup_info;
+  $signup->sid = $sid;
+  if (!empty($signup_anon_mail)) {
+    $signup->anon_mail = $signup_anon_mail;
+  }
+  $account_mail = _signup_get_email($signup);
+  $node_type_name = node_get_types('name', $node->type);
+  // If a confirmation is to be sent, compose the mail message,
+  // replace the tokens with the right values, and send it.
+  if ($node->signup_send_confirmation && $account_mail) {
+    $params = array(
+      'subject' => t('Signup confirmation for !node_type: !title', array('!node_type' => $node_type_name, '!title' => $node->title)),
+      'body' => $node->signup_confirmation_email,
+      'node' => $node,
+      'signup' => $signup,
+    );
+    if (module_exists('token')) {
+      $params['body'] = token_replace($params['body'], 'node', $node);
+    }
+    $language = user_preferred_language($signup);
+    drupal_mail('signup', 'signup_confirmation_mail', $account_mail, $language, $params, $from);
+  }
+
+  // If a forwarding email is to be sent, compose the mail message,
+  // replace the tokens with the right values, and send it.
+  if ($node->signup_forwarding_email) {
+    $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($account->uid) ? variable_get('anonymous', t('Anonymous')) : $account->name));
+    if (!empty($account->uid)) {
+      // For authenticated users, just include a link to their profile page.
+      $message .= "\n\r". t('Profile page: !url', array('!url' => url('user/'. $account->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' => $account_mail));
+    }
+    if (!empty($signup_tokens['%user_signup_info'])) {
+      $message .= "\n\r\n\r". $signup_tokens['%user_signup_info'];
+    }
+    $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($params['body'], 'node', $node);
+    }
+    $language = user_preferred_language($signup);
+    drupal_mail('signup', 'signup_forwarding_mail', $node->signup_forwarding_email, $language, $params, $from);
+  }
+
+  drupal_set_message(t('Signup to !title confirmed.', array('!title' => l($node->title, "node/$node->nid"))) . $confirmation_email . $reminder_email);
+}
+
+/**
+ * Implementation of hook_mail().
+ *
+ * Constructs all of the email messages generated by the signup module.
+ *
+ * @param $key
+ *   Unique key to indicate what message to build.
+ * @param $message
+ *   Reference to the message array being built.
+ * @param $params
+ *   Array of parameters to indicate what text to include in the message body.
+ *   If $params['ignore_tokens'] is TRUE, none of the signup-provided tokens
+ *   in the message body will be replaced, otherwise, tokens are replaced
+ *   using the node passed in as $params['node'] and the signup data from
+ *   $params['signup'].
+ *
+ * @see drupal_mail()
+ * @see _signup_cron_send_reminders()
+ * @see signup_sign_up_user()
+ * @see signup_broadcast_form_submit()
+ */
+function signup_mail_mail($key, &$message, $params) {
+  if (empty($params['ignore_tokens'])) {
+    $tokens = _signup_get_email_tokens($params['node'], $params['signup']);
+    $body = strtr($params['body'], $tokens);
+    $subject = strtr($params['subject'], $tokens);
+  }
+  else {
+    $body = $params['body'];
+    $subject = $params['subject'];
+  }
+  $message['subject'] .= str_replace(array("\r", "\n"), '', $subject);
+  $message['body'][] = $body;
+}
+
+/**
+ * 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.
+ *
+ * @param $node
+ *   An object with info about the signup-enabled node. Must contain
+ *   at least 'nid', 'title', and 'TODO: time?' fields.
+ * @param $signup
+ *   An object with info about the user who signed up.
+ *
+ * @return
+ *   An array of tokens and their replacement values.
+ */
+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);
+  }
+
+  $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;
+}
+
Index: includes/broadcast.inc
===================================================================
RCS file: includes/broadcast.inc
diff -N includes/broadcast.inc
--- includes/broadcast.inc	19 Jan 2009 16:45:24 -0000	1.1.2.2
+++ /dev/null	1 Jan 1970 00:00:00 -0000
@@ -1,189 +0,0 @@
-<?php
-// $Id: broadcast.inc,v 1.1.2.2 2009/01/19 16:45:24 dww Exp $
-
-
-/**
- * @file
- * Code related to sending signup broadcast messages.
- */
-
-/**
- * Form builder for the signup broadcast form.
- *
- * @param $node
- *   The node that the broadcast form is being attached to.
- */
-function signup_broadcast_form($form_state, $node) {
-  $signups = signup_get_signups($node->nid);
-  if (empty($signups)) {
-    $form['no_users'] = array(
-      '#value' => t('No users have signup up for this %node_type.', array('%node_type' => node_get_types('name', $node->type))),
-    );
-    return $form;
-  }
-
-  $tokens = array('%node_title', '%node_url', '%user_mail', '%user_name', t('%cancel_signup_url (access to this link is denied to users without the "cancel own signups" permission)'));
-  if (_signup_get_node_scheduler($node) != 'none') {
-    $tokens = array_merge(array('%node_start_time'), $tokens);
-  }
-  if (module_exists('token')) {
-    $token_text = t('Supported string substitutions: %tokens, and any tokens in the %replacement_tokens list.', array('%tokens' => implode(', ', $tokens), '%replacement_tokens' => t('Replacement tokens')));
-  }
-  else {
-    $token_text = t('Supported string substitutions: %tokens.', array('%tokens' => implode(', ', $tokens)));
-  }
-
-  $form['subject'] = array(
-    '#type' => 'textfield',
-    '#title' => t('Subject'),
-    '#required' => TRUE,
-  );
-  $form['message'] = array(
-    '#type' => 'textarea',
-    '#title' => t('Message body'),
-    '#required' => TRUE,
-    '#description' => t('Body of the email message you wish to send to all users who have signed up for this %node_type. !token_description', array('%node_type' => node_get_types('name', $node->type), '!token_description' => $token_text)),
-    '#rows' => 10,
-  );
-
-  if (module_exists('token')) {
-    module_load_include('inc', 'signup', 'includes/token_help');
-    _signup_token_help($form, 'message_tokens_fieldset');
-  }
-
-  $form['copy'] = array(
-    '#type' => 'checkbox',
-    '#title' => t('Send yourself a copy.'),
-  );
-
-  $form['send'] = array(
-    '#type' => 'submit',
-    '#value' => t('Send'),
-  );
-  $form['nid'] = array(
-    '#type' => 'value',
-    '#value' => $node->nid,
-  );
-
-  global $user;
-  if (user_access('administer site configuration')) {
-    $form['from'] = array(
-      '#type' => 'textfield',
-      '#title' => t('From'),
-      '#required' => TRUE,
-      '#default_value' => $user->mail,
-      '#weight' => '-10',
-    );
-  }
-  else {
-    $form['from'] = array(
-      '#value' => t('This message will be sent from: %from', array('%from' => $user->mail)),
-      '#pre' => '<strong>',
-      '#post' => '</strong>',
-    );
-  }
-  return $form;
-}
-
-/**
- * Submit callback for the signup broadcast form.
- *
- * @param $form
- *   The broadcast form being submitted.
- * @param $form_state
- *   The state of the submitted form (including values).
- *
- * @see signup_send_broadcast()
- */
-function signup_broadcast_form_submit($form, &$form_state) {
-  global $user;
-  if (user_access('administer site configuration')) {
-    $from = $form_state['values']['from'];
-  }
-  else {
-    $from = $user->mail;
-  }
-  signup_send_broadcast($form_state['values']['nid'], $form_state['values']['subject'], $form_state['values']['message'], $from, !empty($form_state['values']['copy']));
-}
-
-/**
- * Send an email message to users who have signed up to a node.
- *
- * @param $nid
- *   Node ID of the signup node to send a broadcast about.
- * @param $subject
- *   The subject of the broadcast message to send.
- * @param $body
- *   The body of the broadcast message to send.
- * @param $from
- *   The from address to use when sending the broadcast message.
- * @param $copy
- *   Optional boolean indicating if the current user should get a copy.
- * @param $signups
- *   Optional array of signup objects to send the broadcast to.  Each object
- *   in the array should at least contain the following fields:
- *   - "sid": The unique signup ID
- *   - "mail" or "anon_mail": E-mail address to send to depending on if it's
- *     an authenticated or anonymous signup.
- *   - "name": Username of an authenticated signup.
- *   - "form_data": The optional custom signup form data for this signup.
- *   - "language": The user's prefered language (if known).
- *
- * @see signup_get_signup()
- * @see _signup_get_email()
- * @see _signup_get_email_tokens()
- */
-function signup_send_broadcast($nid, $subject, $body, $from, $copy = FALSE, $signups = array()) {
-  global $user;
-  $send_all = FALSE;
-  // If the parameter isn't defined, grab all users who signed up to the node.
-  if (empty($signups)) {
-    $signups = signup_get_signups($nid);
-    $send_all = TRUE;
-  }
-  // Make sure that signup_get_signups() returned something for this node.
-  if (!empty($signups)) {
-    $node = node_load($nid);
-    foreach ($signups as $signup) {
-      $user_mail = _signup_get_email($signup);
-      $params = array(
-        'subject' => $subject,
-        'body' => $body,
-        'node' => $node,
-        'signup' => $signup,
-      );
-      if (module_exists('token')) {
-        $params['body'] = token_replace($params['body'], 'node', $node);
-      }
-      $language = user_preferred_language($signup);
-      drupal_mail('signup', 'signup_broadcast_mail', $user_mail, $language, $params, $from);
-      watchdog('signup', 'Broadcast email for %title sent to %email.', array('%title' => $node->title, '%email' => $user_mail), WATCHDOG_NOTICE, l(t('view'), 'node/'. $node->nid));
-    }
-    if ($copy) {
-      $sender_email = _signup_get_email($user);
-      $signup_tokens = _signup_get_email_tokens($node, $user);
-      $message = strtr($body, $signup_tokens);
-      if (module_exists('token')) {
-        // If the token.module is enabled, also handle any tokens it provides.
-        $message = token_replace($message, 'node', $node);
-      }
-      $final_text = theme('signup_broadcast_sender_copy', $body, $message);
-      $params = array(
-        'subject' => $subject,
-        'body' => $final_text,
-        'ignore_tokens' => TRUE,
-      );
-      $language = user_preferred_language($user);
-      drupal_mail('signup', 'signup_broadcast_mail', $sender_email, $language, $params, $from);
-      watchdog('signup', 'Broadcast email copy for %title sent to %email.', array('%title' => $node->title, '%email' => $sender_email), WATCHDOG_NOTICE, l(t('view'), 'node/'. $node->nid));
-      drupal_set_message(t('Sent a copy of this message to %email', array('%email' => $sender_email)));
-    }
-  }
-  if ($send_all) {
-    drupal_set_message(t('Message sent to all users who have signed up'));
-  }
-  else {
-    drupal_set_message(t('Message sent to selected users who have signed up'));
-  }
-}
-
