Index: signup.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/signup/signup.module,v
retrieving revision 1.74.2.45
diff -u -p -r1.74.2.45 signup.module
--- signup.module	9 Aug 2008 10:57:31 -0000	1.74.2.45
+++ signup.module	10 Oct 2008 00:59:58 -0000
@@ -50,6 +50,9 @@ function signup_cron() {
     // include timezone support on all page requests.
     include_once(drupal_get_path('module', 'event') .'/event_timezones.inc');
 
+    // Also include the file of default theme functions in case we need it.
+    include_once(drupal_get_path('module', 'signup') .'/signup.theme');
+
     // Get the current time, and pull all of the nodes for which the
     // current time + the reminder_days_before time is greater than
     // the event's start date.  These are the events for which a
@@ -73,10 +76,9 @@ function signup_cron() {
       // and sending the email.
       while ($signup = db_fetch_object($signups)) {
         $mail_address = $signup->anon_mail ? $signup->anon_mail : $signup->mail;
-        $signup_data_array = unserialize($signup->form_data);
-        if (!empty($signup_data_array)) {
-          $signup_data = signup_build_signup_data($signup_data_array, 'email');
-          $signup_info = t('SIGNUP INFORMATION') ."\n\r". $signup_data;
+        $signup_data = unserialize($signup->form_data);
+        if (!empty($signup_data)) {
+          $signup_info = theme('signup_email_token_custom_data', $signup_data)
         }
 
         $trans = array(
@@ -610,7 +612,9 @@ function signup_nodeapi(&$node, $op, $te
             $header = array(array('data' => t('Your signup information'), 'colspan' => 2));
             $rows = array();
             if (is_array($form_data)) {
-              $rows += signup_build_signup_data($form_data, 'table');
+              // Include the default copy of theme_signup_custom_data().
+              include_once(drupal_get_path('module', 'signup') .'/signup.theme');
+              $rows += theme('signup_custom_data', $form_data, 'table');
             }
             $output = '';
             if (!empty($rows)) {
@@ -1057,10 +1061,10 @@ function signup_sign_up_user($signup_for
     // later use in the emails.
     $offset = $node->event_start ? event_get_offset($node->timezone, $node->event_start) : '';
     $starttime = $node->event_start ? _event_date(variable_get('signup_date_string', 'D, M jS, g:i A'), $node->event_start, $offset) : t('[Untimed]');
-    $signup_data_array = array();
+    $signup_data = '';
     if (isset($signup_form['signup_form_data'])) {
-      $signup_form_data = signup_build_signup_data($signup_form['signup_form_data'], 'email');
-      $signup_data = t('SIGNUP INFORMATION') ."\n\r\n\r". $signup_form_data;
+      include_once(drupal_get_path('module', 'signup') .'/signup.theme');
+      $signup_data = theme('signup_email_token_custom_data', $signup_form['signup_form_data']);
     }
     // Determine if this is an anon signup or not, and get the
     // appropriate email address to use.
@@ -1138,6 +1142,9 @@ function signup_user_schedule($uid) {
 function signup_user_signups_form($node) {
   drupal_set_title(check_plain($node->title));
 
+  // Include the default copy of theme_signup_custom_data().
+  include_once(drupal_get_path('module', 'signup') .'/signup.theme');
+
   // Display if signups are open/closed, and print a button to toggle
   $ctrl_row = array();
   if ($node->signup_completed) {
@@ -1166,7 +1173,7 @@ function signup_user_signups_form($node)
     $form_data = unserialize($signed_up_user->form_data);
 
     // Compose the user data.
-    $signup_form_data = signup_build_signup_data($form_data);
+    $signup_form_data = theme('signup_custom_data', $form_data);
 
     // The username and the unique form identifier are different for
     // anon signups and registered user signups.  For registered users,
@@ -1352,55 +1359,12 @@ function _signup_admin_form($node) {
 }
 
 /**
- * Builds serialized user signup data into user-readable format.
+ * Deprecated function to render signup data in a human-readable form.
  *
- * @param $data The serialized user signup data.
- * @param $type The type of formatting -- defaults to 'output'.
- *
- * @return For table formatting, an array of table rows, for output formatting, raw user data in divs.
+ * @see theme_signup_custom_data()
  */
 function signup_build_signup_data($data, $type = 'output') {
-
-  switch ($type) {
-    case 'table':
-      static $rows = array();
-      // Loop through each first level element.
-      foreach ($data as $key => $value) {
-        // Element is nested, render it recursively.
-        if (is_array($value)) {
-          $rows[] = array('<div id="'. $key .'"></div>');
-          signup_build_signup_data($value, 'table');
-        }
-        else {
-          $rows[] = array($key .':', check_plain($value));
-        }
-      }
-      return $rows;
-    case 'output':
-      $output = '';
-      // Loop through each first level element.
-      foreach ($data as $key => $value) {
-        // Element is nested, render it recursively.
-        if (is_array($value)) {
-          $output .= '<div id="'. $key .'">'. signup_build_signup_data($value) .'</div>';
-        }
-        else {
-          $output .= '<div>'. $key .': '. check_plain($value) .'</div>';
-        }
-      }
-      return $output;
-    case 'email':
-      $output = '';
-      // Loop through each first level element.
-      foreach ($data as $key => $value) {
-        // Element is nested, render it recursively.
-        if (is_array($value)) {
-          $output .= "\n\r". signup_build_signup_data($value, 'email') ."\n\r";
-        }
-        else {
-          $output .= $value ."\n\r";
-        }
-      }
-      return $output;
-  }
+  // Include the default copy of theme_signup_custom_data().
+  include_once(SIGNUP_PATH .'/signup.theme');
+  return theme('signup_custom_data', $data, $type);
 }
Index: signup.theme
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/signup/signup.theme,v
retrieving revision 1.7.2.5
diff -u -p -r1.7.2.5 signup.theme
--- signup.theme	16 May 2008 19:21:13 -0000	1.7.2.5
+++ signup.theme	10 Oct 2008 00:59:58 -0000
@@ -79,3 +79,82 @@ function theme_signup_user_form() {
 
   return $form;
 }
+
+/**
+ * Returns the value to use for the %info email token for custom signup data.
+ *
+ * @param $signup_data
+ *   Array of custom data for a particular signup.
+ *
+ * @see theme_signup_user_form()
+ */
+function theme_signup_email_token_custom_data($signup_data) {
+  return t('SIGNUP INFORMATION') . "\n\r" . theme('signup_custom_data', $signup
+_data, 'email');
+}
+
+
+/**
+ * Renders custom signup user data into a human-readable format.
+ *
+ * @param $data
+ *    Array of custom user signup data.
+ * @param $type
+ *    The type of formatting to render. Supported values are 'table' to
+ *    return an array of rows for a table, 'output' for output in HTML
+ *    div tags, or 'email' for unfiltered output for use in email bodies.
+ *
+ * @return
+ *    'table' formatting:  an array of table rows
+ *    'output' formatting: user data directly formatted in divs
+ *    'email' formatting:  plain text output with newlines
+ *
+ * @see theme_signup_user_form()
+ */
+function theme_signup_custom_data($data, $type = 'output') {
+  switch ($type) {
+    case 'table':
+      static $rows = array();
+      // Loop through each first level element.
+      foreach ($data as $key => $value) {
+        // Element is nested, render it recursively.
+        if (is_array($value)) {
+          $rows[] = array('<div id="'. $key .'"></div>');
+          theme('signup_custom_data', $value, 'table');
+        }
+        else {
+          $rows[] = array($key .':', check_plain($value));
+        }
+      }
+      return $rows;
+
+    case 'output':
+      $output = '';
+      // Loop through each first level element.
+      foreach ($data as $key => $value) {
+        // Element is nested, render it recursively.
+        if (is_array($value)) {
+          $output .= '<div id="'. $key .'">'. theme('signup_custom_data', $value) .'</div>';
+        }
+        else {
+          $output .= '<div>'. $key .': '. check_plain($value) .'</div>';
+        }
+      }
+      return $output;
+
+    case 'email':
+      $output = '';
+      // Loop through each first level element.
+      foreach ($data as $key => $value) {
+        // Element is nested, render it recursively.
+        if (is_array($value)) {
+          $output .= "\n\r". theme('signup_custom_data', $value, 'email') ."\n\r";
+        }
+        else {
+          $output .= $key . ': ' . $value . "\n\r";
+        }
+      }
+      return $output;
+
+  }
+}
