--- notify.module	Tue Jul 27 10:32:40 2010
+++ notify.module.new	Sun Aug 01 12:14:02 2010
@@ -33,6 +33,8 @@ function notify_help($section) {
  */
 function notify_admin_settings() {
   $period = array(
+//    60          => format_interval(60),    // for test purposes
+//    300         => format_interval(300),   // for test purposes
     900         => format_interval(900),
     1800        => format_interval(1800),
     3600        => format_interval(3600),
@@ -119,17 +121,23 @@ function notify_admin_settings() {
  * Implementation of hook_cron().
  */
 function notify_cron() {
+  global $user;
+  $original_user = $user;
+  session_save_session(FALSE); // D7: use drupal_save_session(FALSE);
+  $user = user_load(array('uid' => 1)); // D7: use user_load(1);
   $send_last = variable_get('notify_send_last', 0);
   $send_interval = variable_get('notify_send', 86400);
   $send_hour = variable_get('notify_send_hour', 9);
   $send_start = time();
-  if ( ($send_start - $send_last > $send_interval)
-    && (date('G', $send_start) >= $send_hour || $send_interval < 86400)
-    && ($send_interval != -1) //special case of settings to send 'never'
+	if ( ($send_interval != -1)  // not disabled, settings not set to send 'never'
+    && ($send_start - $send_last > $send_interval)
+    && (($send_interval < 86400) || (date('G', $send_start) >= $send_hour))
       ) {
     _notify_send($send_start);
-    variable_set('notify_send_last', $send_start);
+//    variable_set('notify_send_last', $send_start);  // Moved to _notify_send, rather than have in two places
   }
+  $user = $original_user;
+  session_save_session(TRUE); // // D7: use drupal_save_session(TRUE);
 }
 
 /**
@@ -370,7 +378,7 @@ function notify_admin_users_submit($form
   if ($form_state['values']['flush']) {
     $send_start = time();
     list($num_sent, $num_failed) = _notify_send($send_start);
-    variable_set('notify_send_last', $send_start);
+//    variable_set('notify_send_last', $send_start);  // move to _notify_send to have in one place only rather than two
 
     if ($num_sent > 0) {
       drupal_set_message(t('!count pending notification e-mails have been sent.', array('!count' => $num_sent)));
@@ -435,9 +443,11 @@ function _notify_content($node, $notify)
  *
  * TODO: Needs some cleanup and themability.
  */
-function _notify_send($send_start = NULL) {
-  $send_start = $send_start ? $send_start : time();
+
+function _notify_send($send_start) {
+  $send_start = $send_start ? $send_start : time();  // If $send_start = NULL, set it to time()
   $period = variable_get('notify_send_last', $send_start - variable_get('notify_send', 86400));
+  variable_set('notify_send_last', $send_start);    // Moved from hook_cron and notify_admin_user_submit
   $separator = '------------------------------------------------------------------------------';
   $mini_separator = '---';
 
