diff -ru notify/notify.module /home/hplus/kwxport.org/sites/all/modules/notify/notify.module --- notify/notify.module 2008-12-17 14:00:06.000000000 -0800 +++ /home/hplus/kwxport.org/sites/all/modules/notify/notify.module 2009-01-28 11:03:05.000000000 -0800 @@ -97,12 +97,12 @@ $send_last = variable_get('notify_send_last', 0); $send_interval = variable_get('notify_send', 86400); $send_hour = variable_get('notify_send_hour', 9); - if ( (time() - $send_last > $send_interval) - && (date('G', time()) >= $send_hour || $send_interval < 86400) + $time_now = time(); + if ( ($time_now - $send_last > $send_interval) + && (date('G', $time_now) >= $send_hour || $send_interval < 86400) && ($send_interval != -1) //special case of settings to send 'never' ) { - _notify_send(); - variable_set('notify_send_last', time()); + _notify_send($time_now); } } @@ -325,8 +325,8 @@ drupal_set_message(t('Notify settings saved.')); if ($form_state['values']['flush']) { - list($num_sent, $num_failed) = _notify_send(); - variable_set('notify_send_last', time()); + $time_now = time(); + list($num_sent, $num_failed) = _notify_send($time_now); if ($num_sent > 0) { drupal_set_message(t('!count pending notification e-mails have been sent.', array('!count' => $num_sent))); @@ -391,8 +391,9 @@ * * TODO: Needs some cleanup and themability. */ -function _notify_send() { - $period = variable_get('notify_send_last', time() - variable_get('notify_send', 86400)); +function _notify_send($time_now) { + $period = variable_get('notify_send_last', $time_now - variable_get('notify_send', 86400)); + variable_set('notify_send_last', $time_now); $separator = '------------------------------------------------------------------------------'; $mini_separator = '---'; @@ -423,14 +424,14 @@ _notify_switch_user($user->uid); // Fetch all new nodes and 'load' it to get proper body, etc. - $nresult = db_query(db_rewrite_sql('SELECT n.nid FROM {node} n WHERE (n.status = 1 OR n.moderate = 1) '. $reqntype . ' AND ((n.created > %d AND n.created <= %d) OR (n.changed > %d AND n.changed <= %d)) ORDER BY n.created'), $period, time(), $period, time()); + $nresult = db_query(db_rewrite_sql('SELECT n.nid FROM {node} n WHERE (n.status = 1 OR n.moderate = 1) '. $reqntype . ' AND ((n.created > %d AND n.created <= %d) OR (n.changed > %d AND n.changed <= %d)) ORDER BY n.created'), $period, $time_now, $period, $time_now); $nodes = array(); while ($node = db_fetch_object($nresult)) { $nodes[$node->nid] = node_load($node->nid); } // Fetch new comments. - $cresult = db_query(db_rewrite_sql('SELECT c.nid, c.cid, c.subject, c.name FROM {comments} c INNER JOIN {node} n ON c.nid = n.nid WHERE c.status = %d AND c.timestamp > %d AND c.timestamp <= %d '. $reqntype . ' ORDER BY c.nid, c.timestamp', 'c'), COMMENT_PUBLISHED, $period, time()); + $cresult = db_query(db_rewrite_sql('SELECT c.nid, c.cid, c.subject, c.name FROM {comments} c INNER JOIN {node} n ON c.nid = n.nid WHERE c.status = %d AND c.timestamp > %d AND c.timestamp <= %d '. $reqntype . ' ORDER BY c.nid, c.timestamp', 'c'), COMMENT_PUBLISHED, $period, $time_now); $comments = array(); while ($comment = db_fetch_object($cresult)) { $comments[$comment->nid][] = $comment;