? 86462_signup_date_2.x.81.patch
? signup_date_2.x.68.patch
? signup_date_5.x-1.inc
? signup_date_5.x-2.inc
Index: signup.install
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/signup/signup.install,v
retrieving revision 1.16
diff -u -p -r1.16 signup.install
--- signup.install	22 Dec 2007 09:07:18 -0000	1.16
+++ signup.install	9 Aug 2008 00:55:59 -0000
@@ -106,6 +106,34 @@ function signup_uninstall() {
 }
 
 /**
+ * Implementation of hook_requirements().
+ */
+function signup_requirements($phase) {
+  $requirements = array();
+  // Ensure translations don't break at install time
+  $t = get_t();
+  
+  switch ($phase) {
+    case 'runtime':
+      if (function_exists('signup_field_names')) {
+        foreach (signup_content_types() as $type) {
+          if (!variable_get('signup_form_field_'. $type, 0) && signup_field_names($type) != array()) {
+            $requirements['signup_date'] = array(
+              'title' => $t('Signup: %content_type', array('%content_type' => $type)),
+              'value' => $t('empty'),
+              'description' => $t('Your signup enabled content type (%content_type) has one or more Date fields, but no Date field is set to be used for signup date integration. Please select the appopriate Event Date field on the <a href="!url">Content Type edit form</a>', array('%content_type' => $type, '!url' => url('admin/content/types/'. $type))),
+              'severity' => REQUIREMENT_ERROR,
+            );
+          }
+        }
+      }
+      break;
+  }
+
+  return $requirements;
+}
+
+/**
  * Helper method to insert the default signup information into the
  * {signup} table (stored in a row for nid 0).  These are the default
  * settings for new signup-enabled nodes.
@@ -283,7 +311,6 @@ function signup_update_5203() {
   return array();
 }
 
-
 function _signup_db_column_exists($table, $column) {
   switch ($GLOBALS['db_type']) {
     case 'mysql':
Index: signup.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/signup/signup.module,v
retrieving revision 1.141
diff -u -p -r1.141 signup.module
--- signup.module	7 Aug 2008 19:41:18 -0000	1.141
+++ signup.module	9 Aug 2008 00:55:59 -0000
@@ -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;
   }
@@ -87,11 +90,11 @@ function _signup_cron_send_reminders() {
       }
       drupal_mail('signup_reminder_mail', $mail_address, $subject, $message, $from);
       watchdog('signup', t('Reminder for %event sent to %useremail.', array('%event' => $event->title, '%useremail' => $mail_address)), WATCHDOG_NOTICE, l(t('view'), 'node/'. $event->nid));
-    }
 
     // Reminders for this event are all sent, so mark it in the
     // database so they're not sent again.
     db_query("UPDATE {signup} SET send_reminder = 0 WHERE nid = %d", $event->nid);
+    }
   }
 }
 
@@ -108,9 +111,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;
   }
@@ -156,31 +161,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);
@@ -300,6 +324,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') {
@@ -308,10 +339,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');
@@ -387,6 +419,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;
   }
 }
 
@@ -407,6 +444,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.');
+    }
+  }
 }
 
 /**
@@ -705,7 +752,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 {
@@ -969,6 +1018,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'),
@@ -1069,7 +1119,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");
@@ -1125,11 +1175,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.
@@ -1356,17 +1406,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
Index: signup_event_5.x-1.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/signup/signup_event_5.x-1.inc,v
retrieving revision 1.6
diff -u -p -r1.6 signup_event_5.x-1.inc
--- signup_event_5.x-1.inc	6 Aug 2008 08:12:13 -0000	1.6
+++ signup_event_5.x-1.inc	9 Aug 2008 00:55:59 -0000
@@ -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";
 }
 
Index: signup_event_5.x-2.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/signup/signup_event_5.x-2.inc,v
retrieving revision 1.5
diff -u -p -r1.5 signup_event_5.x-2.inc
--- signup_event_5.x-2.inc	6 Aug 2008 08:12:13 -0000	1.5
+++ signup_event_5.x-2.inc	9 Aug 2008 00:55:59 -0000
@@ -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?
  */
Index: signup_event_none.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/signup/signup_event_none.inc,v
retrieving revision 1.3
diff -u -p -r1.3 signup_event_none.inc
--- signup_event_none.inc	6 Aug 2008 08:12:13 -0000	1.3
+++ signup_event_none.inc	9 Aug 2008 00:55:59 -0000
@@ -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";
 }
 
