Only in signupNew: signup_date_5.x-1.inc
Only in signupNew: signup_date_5.x-2.inc
diff -urp signup/signup_event_5.x-1.inc signupNew/signup_event_5.x-1.inc
--- signup/signup_event_5.x-1.inc	2008-10-14 09:47:31.000000000 -0400
+++ signupNew/signup_event_5.x-1.inc	2008-10-14 09:49:59.000000000 -0400
@@ -4,7 +4,7 @@
 /**
  * @return Array of SQL clauses for cron reminder email query builder.
  */
-function signup_reminder_sql() {
+function signup_reminder_sql($content_type = NULL) {
   // We must manually include this here as the event module doesn't
   // include timezone support on all page requests.
   include_once(drupal_get_path('module', 'event') .'/event_timezones.inc');
@@ -18,7 +18,7 @@ function signup_reminder_sql() {
 /**
  * @return Array of SQL clauses for cron auto-close query builder.
  */
-function signup_autoclose_sql() {
+function signup_autoclose_sql($content_type = NULL) {
   // We must manually include this here as the event module doesn't
   // include timezone support on all page requests.
   include_once(drupal_get_path('module', 'event') .'/event_timezones.inc');
@@ -32,7 +32,7 @@ function signup_autoclose_sql() {
 /**
  * @return Array of SQL clauses for admin overview page query builder.
  */
-function signup_admin_sql() {
+function signup_admin_sql($content_type = NULL) {
   $fields = array('e.event_start', 'e.timezone');
   return array(
     'fields' => $fields,
@@ -53,7 +53,7 @@ function signup_admin_form_extra($signup
   );
 }
 
-function signup_list_user_signups_sql() {
+function signup_list_user_signups_sql($content_type = NULL) {
   return "SELECT n.nid, n.title, e.event_start FROM {node} n INNER JOIN {signup_log} s_l ON n.nid = s_l.nid LEFT JOIN {event} e ON e.nid = n.nid WHERE s_l.uid = %d AND (e.event_start >= ". time() ." OR e.event_start IS NULL) ORDER BY e.event_start";
 }
 
Only in signupNew: signup_event_5.x-1.inc.rej
diff -urp signup/signup_event_5.x-2.inc signupNew/signup_event_5.x-2.inc
--- signup/signup_event_5.x-2.inc	2008-10-14 09:47:31.000000000 -0400
+++ signupNew/signup_event_5.x-2.inc	2008-10-14 09:49:59.000000000 -0400
@@ -4,7 +4,7 @@
 /**
  * @return Array of SQL clauses for cron reminder email query builder.
  */
-function signup_reminder_sql() {
+function signup_reminder_sql($content_type = NULL) {
   global $db_type;
   event_include_files();
   switch ($db_type) {
@@ -25,7 +25,7 @@ function signup_reminder_sql() {
 /**
  * @return Array of SQL clauses for cron auto-close query builder.
  */
-function signup_autoclose_sql() {
+function signup_autoclose_sql($content_type = NULL) {
   event_include_files();
   return array(
     'fields' => array(event_select(), 'e.timezone'),
@@ -37,7 +37,7 @@ function signup_autoclose_sql() {
 /**
  * @return Array of SQL clauses for admin overview page query builder.
  */
-function signup_admin_sql() {
+function signup_admin_sql($content_type = NULL) {
   return array(
     'fields' => array(event_select(), 'e.timezone'),
     'group_by' => array('event_start', 'e.timezone'),
@@ -56,7 +56,7 @@ function signup_admin_form_extra($signup
   );
 }
 
-function signup_list_user_signups_sql() {
+function signup_list_user_signups_sql($content_type = NULL) {
   return 'SELECT n.nid, n.title, '. event_select() .' FROM {node} n INNER JOIN {signup_log} s_l ON n.nid = s_l.nid '. event_join('n', 'LEFT') .' WHERE s_l.uid = %d AND ('. event_where() ." >= '". event_implode_date(_event_user_time()) ."' OR e.event_start IS NULL) ORDER BY event_start";
 }
 
@@ -94,6 +94,10 @@ function signup_site_has_dates() {
   return TRUE;
 }
 
+function signup_content_type_fields() {
+  return array('Event');
+}
+
 /**
  * @return Bool: Is this node type date-enabled?
  */
Only in signupNew: signup_event_5.x-2.inc.rej
diff -urp signup/signup_event_none.inc signupNew/signup_event_none.inc
--- signup/signup_event_none.inc	2008-10-14 09:47:31.000000000 -0400
+++ signupNew/signup_event_none.inc	2008-10-14 09:49:59.000000000 -0400
@@ -12,7 +12,7 @@
  *
  * The call site assumes the one and only %d in this query is the user's uid.
  */
-function signup_list_user_signups_sql() {
+function signup_list_user_signups_sql($content_type = NULL) {
   return "SELECT n.nid, n.title FROM {node} n INNER JOIN {signup_log} s_l ON n.nid = s_l.nid WHERE s_l.uid = %d ORDER BY n.nid";
 }
 
Only in signupNew: signup_event_none.inc.rej
diff -urp signup/signup.module signupNew/signup.module
--- signup/signup.module	2008-10-14 09:47:31.000000000 -0400
+++ signupNew/signup.module	2008-10-14 09:49:59.000000000 -0400
@@ -38,10 +38,13 @@ function signup_cron() {
  * @see _signup_build_query()
  */
 function _signup_cron_send_reminders() {
+  $reminder_sql = array();
   if (function_exists('signup_reminder_sql')) {
-    $reminder_sql = signup_reminder_sql();
+    foreach (signup_content_type_fields() as $field) {
+      $reminder_sql[] = signup_reminder_sql($field);
+    }
   }
-  if (empty($reminder_sql)) {
+  if (empty($reminder_sql[0])) {
     // The backend doesn't support reminder emails, so bail out now.
     return;
   }
@@ -97,9 +100,11 @@ function _signup_cron_send_reminders() {
  */
 function _signup_cron_autoclose() {
   if (function_exists('signup_autoclose_sql')) {
-    $autoclose_sql = signup_autoclose_sql();
+    foreach (signup_content_type_fields() as $type) {
+      $autoclose_sql[] = signup_autoclose_sql($type);
+    }
   }
-  if (empty($autoclose_sql)) {
+  if (empty($autoclose_sql[0])) {
     // The backend doesn't support auto-closing events, so bail out now.
     return;
   }
@@ -145,31 +150,50 @@ function _signup_cron_autoclose() {
  *   Complete SQL statement based on the given query fragments.
  */
 function _signup_build_query($common_sql, $backend_sql) {
+  // Combine all the backend_sql values into a single array.
+  $fields = array();
+  $joins = array();
+  $where = array();
+  $group_by = array();
+  foreach ($backend_sql as $sql) {
+    $fields = array_merge($fields, (!empty($sql['fields']) ? $sql['fields'] : array()));
+    $joins = array_merge($joins, (!empty($sql['joins']) ? $sql['joins'] : array()));
+    $where = array_merge($where, (!empty($sql['where']) ? $sql['where'] : array()));
+    $group_by = array_merge($group_by, (!empty($sql['group_by']) ? $sql['group_by'] : array()));
+  }
 
+  // Combine backend sql with common_sql.
   $fields = array_merge(
     (!empty($common_sql['fields']) ? $common_sql['fields'] : array()),
-    (!empty($backend_sql['fields']) ? $backend_sql['fields'] : array())
+    (!empty($fields) ? $fields : array())
   );
   $joins = array_merge(
     (!empty($common_sql['joins']) ? $common_sql['joins'] : array()),
-    (!empty($backend_sql['joins']) ? $backend_sql['joins'] : array())
-  );
-  $where = array_merge(
-    (!empty($common_sql['where']) ? $common_sql['where'] : array()),
-    (!empty($backend_sql['where']) ? $backend_sql['where'] : array())
+    (!empty($joins) ? $joins : array())
   );
   $group_by = array_merge(
     (!empty($common_sql['group_by']) ? $common_sql['group_by'] : array()),
-    (!empty($backend_sql['group_by']) ? $backend_sql['group_by'] : array())
+    (!empty($group_by) ? $group_by : array())
   );
 
+  // Combine each of the backend_sql content type 'where' criteria with the common 'where'
+  // criteria to create the OR where clause.
+  if (!empty($where)) {
+    foreach ($where as $criteria) {
+      $where_or[] = implode(' AND ', array_merge($common_sql['where'], array($criteria)));
+    }
+  }
+  elseif (!empty($common_sql['where'])) {
+    $where_or = $common_sql['where'];
+  }
+
   $sql = 'SELECT '. implode(', ', $fields);
   $sql .= ' FROM '. $common_sql['primary'] .' ';
   if (!empty($joins)) {
     $sql .= implode(' ', $joins);
   }
-  if (!empty($where)) {
-    $sql .= ' WHERE '. implode(' AND ', $where);
+  if (!empty($where_or)) {
+    $sql .= ' WHERE ('. implode(') OR (', $where_or) .')';
   }
   if (!empty($group_by)) {
     $sql .= ' GROUP BY '. implode(', ', $group_by);
@@ -289,6 +313,13 @@ function signup_menu($may_cache) {
   return $items;
 }
 
+/**
+ * Loads relevant backend event backend code based on which modules
+ * exists and which version is loaded.  Currently, checks for the
+ * event modules first, then the date module, and doesn't allow for
+ * either event or date to be used if both modules are present.
+ * @ingroup signup_core
+ */
 function _signup_initialize_event_backend() {
   define('SIGNUP_PATH', drupal_get_path('module', 'signup'));
   if (defined('EVENT_API') && EVENT_API == '5.2') {
@@ -297,10 +328,11 @@ function _signup_initialize_event_backen
   else if (module_exists('event')) {
     include_once(SIGNUP_PATH .'/signup_event_5.x-1.inc');
   }
+  else if (variable_get('date_api_version', 0) == '5.2') {
+    include_once(SIGNUP_PATH .'/signup_date_5.x-2.inc');
+  }
   else if (module_exists('date')) {
-    // include_once(SIGNUP_PATH .'/signup_date.inc');
-    // Until date.module support exists, fall back to the no event case.
-    include_once(SIGNUP_PATH .'/signup_event_none.inc');
+    include_once(SIGNUP_PATH .'/signup_date_5.x-1.inc');
   }
   else {
     include_once(SIGNUP_PATH .'/signup_event_none.inc');
@@ -376,6 +408,11 @@ function signup_form_alter($form_id, &$f
     case $form['type']['#value'] .'_node_form':
       signup_alter_node_form($form_id, $form);
       break;
+    case '_content_admin_field':
+      if (function_exists('signup_date_form_alter')) {
+        signup_date_form_alter($form_id, $form);
+      }
+      break;
   }
 }
 
@@ -396,6 +433,16 @@ function signup_alter_node_type_form($fo
     '#default_value' => variable_get('signup_node_default_state_'. $type, 'disabled'),
     '#description' => t('If %disabled is selected, signups will not be possible for this content type. If %allowed_off is selected, signups will be off by default, but users with the %admin_all_signups permission will be able to allow signups for specific posts of this content type. If %enabled_on is selected, users will be allowed to signup for this content type unless an administrator disbles signups on specific posts.', array('%disabled' => t('Disabled'), '%allowed_off' => t('Allowed (off by default)'), '%enabled_on' => t('Enabled (on by default)'), '%admin_all_signups' => t('administer all signups'))),
   );
+
+  if (function_exists('signup_field_names') && variable_get('signup_node_default_state_'. $type, 'disabled') != 'disabled') {
+    if (signup_field_names($type)) { 
+      if(!signup_date_field($type)) {
+        drupal_set_message('You have enabled this content type for signup, and have added one or more date fields, but have not selected a date field for use with signup.');
+      }
+    } else {
+      drupal_set_message('You have enabled this content type for signup but have not added a date field.');
+    }
+  }
 }
 
 /**
@@ -694,7 +741,9 @@ function signup_nodeapi(&$node, $op, $te
         $node->signup_close_signup_limit = $signup->close_signup_limit;
         $node->signup_status = $signup->status;
         if ($node->nid) {
-          $node->signup_total = db_result(db_query("SELECT COUNT(*) FROM {signup_log} WHERE nid = %d", $node->nid));
+          if (!($node->signup_total = db_result(db_query("SELECT COUNT(*) FROM {signup_log} WHERE nid = %d", $node->nid)))) {
+            $node->signup_total = 0;
+          }
         }
       }
       else {
@@ -958,6 +1007,7 @@ function signup_form($node, $signup_type
   $signup_form += $signup_themed_form;
   
   $form['collapse']['signup_user_form'] = $signup_form;
+
   $form['collapse']['submit'] = array(
     '#type' => 'submit',
     '#value' => t('Sign up'),
@@ -1058,7 +1108,7 @@ function signup_admin_form() {
     $row['status'] = $node_admin_form['status'];
     $row['total'] = array(
       '#type' => 'markup',
-      '#value' => $signup_event->signup_total,
+      '#value' => $signup_event->signup_total?$signup_event->signup_total:0,
       );
     $row['limit'] = $node_admin_form['limit'];
     $op_links = l(t('View signups'), "node/$signup_event->nid/signups");
@@ -1114,11 +1164,11 @@ function signup_admin_form_sql() {
   }
 
   // Get the right query elements from the currently installed backend
+  $admin_sql = array();
   if (function_exists('signup_admin_sql')) {
-    $admin_sql = signup_admin_sql();
-  }
-  else {
-    $admin_sql = array();
+    foreach (signup_content_type_fields() as $field) {
+      $admin_sql[] = signup_admin_sql($field);
+    }
   }
 
   // Build the main query.
@@ -1346,17 +1396,34 @@ function signup_list_user_signups($uid) 
 
   // We don't want to return anything for anon users.
   if ($uid != 0) {
-    $sql = signup_list_user_signups_sql();
-    // Pull all open signup nodes for this user.
-    $result = db_query(db_rewrite_sql($sql), $uid);
-    while ($node = db_fetch_array($result)) {
-      $titles[$node['nid']] = l($node['title'], 'node/'. $node['nid']);
+    foreach (signup_content_types() as $type) {
+      $sql = signup_list_user_signups_sql($type);
+      if ($sql) {
+        // Pull all open signup nodes for this user.
+        $result = db_query(db_rewrite_sql($sql), $uid);
+        while ($node = db_fetch_array($result)) {
+          $titles[$node['nid']] = l($node['title'], 'node/'. $node['nid']);
+        }
+      }
     }
   }
   return $titles;
 }
 
 /**
+ * Returns a list of content types that have signups enabled
+ */
+function signup_content_types() {
+  $signup_content_types = array();
+  foreach (node_get_types('names') as $content_type => $content_name) {
+    if (variable_get('signup_node_default_state_'. $content_type, 'disabled') != 'disabled') {
+      $signup_content_types[] = $content_type;
+    }
+  }
+  return $signup_content_types;
+}
+
+/**
  * Signs up a user to a node.
  *
  * NOTE: other modules can call this function. To do so, $signup_form
Only in signupNew: signup.module.orig
Only in signupNew: signup.module.rej
