Index: modules/signup/signup.module =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/signup/signup.module,v retrieving revision 1.107 diff -u -p -r1.107 signup.module --- modules/signup/signup.module 10 May 2007 07:30:30 -0000 1.107 +++ modules/signup/signup.module 6 Jun 2007 01:20:44 -0000 @@ -50,6 +50,8 @@ function signup_init() { * @ingroup signup_core */ function signup_cron() { + $curtime = time(); + $closing_time = $curtime + (variable_get('signup_close_early', 1) * 3600); // Only run this function if the event module is enabled. if (module_exists('event')) { // We must manually include this here as the event module doesn't @@ -60,7 +62,7 @@ function signup_cron() { // current time + the reminder_days_before time is greater than // the event's start date. These are the events for which a // reminder email needs to be sent. - $curtime = time(); + $result = db_query("SELECT n.title, n.nid, e.event_start, e.timezone, s.reminder_email, s.forwarding_email FROM {signup} s INNER JOIN {node} n ON n.nid = s.nid INNER JOIN {event} e ON e.nid = s.nid WHERE s.send_reminder = 1 AND (%d + ((s.reminder_days_before) * 86400)) > e.event_start", $curtime); @@ -106,7 +108,7 @@ function signup_cron() { // time + the number of hours before the event start when closing is // preferred. Query the database for all signup events which have a // start time less than this. - $closing_time = $curtime + (variable_get('signup_close_early', 1) * 3600); + $result = db_query("SELECT s.nid FROM {signup} s INNER JOIN {event} e ON e.nid = s.nid WHERE s.status = 1 AND e.event_start < %d", $closing_time); // Loop through the results, calling the event closing function. @@ -120,6 +122,41 @@ function signup_cron() { watchdog('signup', t('Signups closed for %event by cron.', array('%event' => $node->title)), WATCHDOG_NOTICE, l(t('view'), 'node/'. $node->nid)); } } + else if(module_exists('date')) { + /* + * 1.) Get content fields + * 2.) loop through content fields + * 3.) if date field + * 4.) get table + * 5.) Grab each event, create subject etc and grab the users + * 6.) compose message + * 7.) do closing time + */ + $fields = content_fields(); + foreach($fields as $field) { + if ($field['type'] == 'date' || $field['type'] == 'datestamp') { + $db_info = content_database_info($field); + $table = $db_info['table']; + $column = $db_info['columns']['value']['column']; + + // closing of signup nodes + $closing_time = $curtime + (variable_get('signup_close_early', 1) * 3600); + $result = db_query("SELECT s.nid FROM {signup} s INNER JOIN {". $table . "} e ON e.nid = s.nid WHERE s.status = 1 AND e." . $column . " < %d", $closing_time); + // Loop through the results, calling the event closing function. + while ($signup = db_fetch_object($result)) { + signup_close_signup($signup->nid, $cron = 'yes'); + + $node = node_load($signup->nid); + foreach (module_implements('signup_close') as $module) { + $function = $module .'_signup_close'; + $function($node); + } + watchdog('signup', t('Signups closed for %event by cron.', array('%event' => $node->title)), WATCHDOG_NOTICE, l(t('view'), 'node/'. $node->nid)); + } + + } + } + } } /**