--- 4.7/cronplus.module	Wed May 03 22:12:40 2006
+++ cronplus.module	Fri Mar 02 21:01:25 2007
@@ -25,18 +25,27 @@ function cronplus_help($section) {
 function cronplus_menu($may_cache) {
   $items = array();
   if ($may_cache) {
-    $items[] = array('path'=>'admin/settings/cronplus', 'title'=>t('cronplus'),
-      'callback'=>'cronplus_settings_main', 'access'=>user_access('administer site configuration'),
-//      'type'=>MENU_LOCAL_TASK,
+    $items[] = array(
+      'path' => 'admin/settings/cronplus',
+      'title' => t('cronplus'),
+      'callback' => 'cronplus_settings_main',
+      'description' => 'Select which hour and on what day you would like houly and daily crons to run. Also see the status of cronplus',
+      'access' => user_access('administer site configuration'),
+//      'type' => MENU_LOCAL_TASK,
     );
-    $items[] = array('path'=>'admin/settings/cronplus/main', 'title'=>t('configuration'),
-      'type'=>MENU_DEFAULT_LOCAL_TASK,
-      'weight'=>-10,
+    $items[] = array(
+      'path' => 'admin/settings/cronplus/main',
+      'title' => t('configuration'),
+      'type' => MENU_DEFAULT_LOCAL_TASK,
+      'weight' => -10,
     );
-  } else {
-    $items[] = array('path'=>'admin/settings/cronplus/status', 'title'=>t('status report'),
-      'callback'=>'cronplus_settings_status', 'access'=>user_access('administer site configuration'),
-      'type'=>MENU_LOCAL_TASK, 'weight'=>10);
+  }
+  else {
+    $items[] = array(
+      'path' => 'admin/settings/cronplus/status',
+      'title' => t('status report'),
+      'callback' => 'cronplus_settings_status', 'access' => user_access('administer site configuration'),
+      'type' => MENU_LOCAL_TASK, 'weight' => 10);
   }
   return $items;
 }
@@ -64,35 +73,39 @@ function cronplus_settings_form_validate
 function cronplus_settings_form_submit($form_id, $form_values) {
   $cronplus_preferred_hour = intval($form_values['cronplus_preferred_hour']);
   $cronplus_preferred_wkdy = intval($form_values['cronplus_preferred_wkdy']);
-  variable_set('cronplus_preferred_hour',$cronplus_preferred_hour);
-  variable_set('cronplus_preferred_wkdy',$cronplus_preferred_wkdy);
-  drupal_set_message(t('Cronplus settings saved'),'info');
+  variable_set('cronplus_preferred_hour', $cronplus_preferred_hour);
+  variable_set('cronplus_preferred_wkdy', $cronplus_preferred_wkdy);
+  drupal_set_message(t('Cronplus settings saved'), 'info');
 }
 
 /**
  * Handle the module's settings.
  */
-function cronplus_settings_main() {
-  $form = array();
+function cronplus_settings_main() {  
+  return drupal_get_form('cronplus_settings_form');
+}
+
+function cronplus_settings_form() {
+$form = array();
   $form['cronplus_preferred_hour'] = array(
     '#type' => 'select',
     '#title' => t('Preferred hour'),
     '#description' => t('Preferred hour of the day at which daily, weekly, monthly, and yearly jobs will run, if possible. Not guaranteed.'),
-    '#default_value' => intval(variable_get('cronplus_preferred_hour',0)),
-    '#options' => _cronplus_int_options(0,23),
+    '#default_value' => intval(variable_get('cronplus_preferred_hour', 0)),
+    '#options' => _cronplus_int_options(0, 23),
   );
   $form['cronplus_preferred_wkdy'] = array(
     '#type' => 'select',
     '#title' => t('Preferred weekday'),
     '#description' => t('Preferred day of the week on which weekly, monthly, and yearly jobs will run, if possible. Not guaranteed.'),
-    '#default_value' => intval(variable_get('cronplus_preferred_wkdy',0)),
-    '#options' => _cronplus_int_options(0,6,array('Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday'), TRUE),
+    '#default_value' => intval(variable_get('cronplus_preferred_wkdy', 0)),
+    '#options' => _cronplus_int_options(0, 6, array('Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'), TRUE),
   );
   $form['cronplus_submit'] = array(
     '#type' => 'submit',
     '#value' => t('Save settings'),
   );
-  return drupal_get_form('cronplus_settings_form',$form);
+return $form;
 }
 
 /**
@@ -106,7 +119,7 @@ function cronplus_settings_main() {
  */
 function cronplus_periods() {
   $periods = array();
-  foreach (array('hourly','daily','weekly','monthly','yearly') as $period) {
+  foreach (array('hourly', 'daily', 'weekly', 'monthly', 'yearly') as $period) {
     $periods[$period] = t($period);
   }
   return $periods;
@@ -117,32 +130,34 @@ function cronplus_periods() {
  * hooks.
  */
 function cronplus_settings_status() {
-  $html = '<p>' . t('This section lists modules implementing the cronplus hook for each available time period. The listing is purely informational; there are no settings to change here.') . ' [' . l(t('view cronplus log'), 'admin/logs?filter=cronplus') . ']<p>';
+  $html = '<p>'. t('This section lists modules implementing the cronplus hook for each available time period. The listing is purely informational; there are no settings to change here.') .' ['. l(t('view cronplus log'), 'admin/logs?filter=cronplus') .']<p>';
   $periods =& cronplus_periods();
   // Add one special case.
-  $periods['cronplus'] = 'cronplus ' . t('(multiplex hook)');
-  foreach ($periods as $period=>$period_t) {
-    $html .= '<h2>' . $period_t . '</h2>';
+  $periods['cronplus'] = 'cronplus '. t('(multiplex hook)');
+  foreach ($periods as $period => $period_t) {
+    $html .= '<h2>'. $period_t .'</h2>';
     $html .= '<div class="cronplus_status">';
-    $hook = ($period == 'cronplus') ? 'cronplus' : 'cronplus_'.$period;
-    $group = '<p>' . t('Hook: {module}_%hook()', array('%hook'=>$hook)) . '<p>' . t('Implemented by: ');
+    $hook = ($period == 'cronplus') ? 'cronplus' : 'cronplus_'. $period;
+    $group = '<p>'. t('Hook: {module}_%hook()', array('%hook' => $hook)) .'<p>'. t('Implemented by: ');
     $modules = _cronplus_module_implements($hook);
     if (count($modules) > 0) {
-      $group .= '<span class="cronplus_modules">' . implode(', ',$modules) . '</span>';
-    } else {
+      $group .= '<span class="cronplus_modules">'. implode(', ', $modules) .'</span>';
+    }
+      else {
       $group .= t('None');
     }
-    $group .= '<p>' . t('Last invoked: ');
+    $group .= '<p>'. t('Last invoked: ');
     if ($period == 'cronplus') {
       $group .= t('Invoked along with each of the above');
-    } else {
-      $last_invoked = intval(variable_get('cronplus_'.$period.'_last', 0));
-      $group .= $last_invoked ? gmdate('Y-m-d H:i:s', $last_invoked).'&nbsp;UTC' : t('Never');
     }
-    $html .= $group . '</div>';
+      else {
+      $last_invoked = intval(variable_get('cronplus_'. $period .'_last', 0));
+      $group .= $last_invoked ? gmdate('Y-m-d H:i:s', $last_invoked) .'&nbsp;UTC' : t('Never');
+    }
+    $html .= $group .'</div>';
   }
   $html .= '<p>';
-  print theme("page",$html);
+  print theme("page", $html);
 }
 
 /**
@@ -151,7 +166,8 @@ function cronplus_settings_status() {
 function _cronplus_module_implements($hook) {
   if (function_exists('module_implements')) {
     return module_implements($hook);
-  } else {
+  }
+  else {
     $modules = module_list(FALSE, FALSE);
     $list = array();
     foreach ($modules as $module) {
@@ -169,7 +185,8 @@ function _cronplus_module_implements($ho
 function _cronplus_watchdog($message, $severity = WATCHDOG_NOTICE, $link='') {
   if (function_exists('module_implements')) {
     watchdog('cronplus', $message, $severity, $link);
-  } else {
+  }
+  else {
     watchdog('cronplus', $message, $link);
   }
 }
@@ -191,15 +208,15 @@ function cronplus_cron() {
   $now_year  = intval(gmdate('Y', $now));
   $now_date  = gmdate('Y-m-d', $now);
   $now_hour  = intval(gmdate('H', $now));
-  $last_cron   = intval(variable_get('cronplus_last_cron',0));
+  $last_cron   = intval(variable_get('cronplus_last_cron', 0));
   $last_cron_fmt = gmdate('Y-m-d H:i:s', $last_cron);
   $last_cron_hour = intval(gmdate('H', $last_cron));
   $last_cron_week = intval(gmdate('W', $last_cron));
   $last_cron_year = intval(gmdate('Y', $last_cron));
   // Preferred hour affects daily, weekly, monthly, and yearly runs
-  $prefer_hour = intval(variable_get('cronplus_preferred_hour',0));
+  $prefer_hour = intval(variable_get('cronplus_preferred_hour', 0));
   // Preferred wkdy affects weekly, monthly, and yearly runs
-  $prefer_wkdy = intval(variable_get('cronplus_preferred_wkdy',0));
+  $prefer_wkdy = intval(variable_get('cronplus_preferred_wkdy', 0));
   $interval = $now - $last_cron;   // Seconds since last run
 
   // Make the appropriate runs. In each case, we try to run in the preferred
@@ -243,7 +260,7 @@ function cronplus_cron() {
   }
 
   // Record the current run time
-  variable_set('cronplus_last_cron',$now);
+  variable_set('cronplus_last_cron', $now);
 }
 
 /**
@@ -253,10 +270,10 @@ function cronplus_cron() {
  */
 function cronplus_invoke_hook($period, $now, $last_cron) {
   $now_fmt = gmdate('Y-m-d H:i:s', $now);
-  $function_name = 'cronplus_'.$period;
-  $last_this = variable_get($function_name.'_last', 0);
-  variable_set($function_name.'_last', $now);
-  _cronplus_watchdog(t('Processing %period cron for %d UTC, calling {module}_%func() for all modules',array('%d'=>$now_fmt, '%period'=>t($period), '%func'=>$function_name)), WATCHDOG_NOTICE);
+  $function_name = 'cronplus_'. $period;
+  $last_this = variable_get($function_name .'_last', 0);
+  variable_set($function_name .'_last', $now);
+  _cronplus_watchdog(t('Processing %period cron for %d UTC, calling {module}_%func() for all modules', array('%d' => $now_fmt, '%period' => t($period), '%func' => $function_name)), WATCHDOG_NOTICE);
   @module_invoke_all($function_name, $now, $last_cron, $last_this);
   @module_invoke_all('cronplus', $period, $now, $last_cron, $last_this);
 } 
@@ -271,7 +288,8 @@ function _cronplus_int_options($min, $ma
   for ($i=$min; $i<=$max; $i++) {
     if (is_array($values) && isset($values[$i])) {
       $options[$i] = $translate ? t($values[$i]) : $values[$i];
-    } else {
+    }
+      else {
       $options[$i] = $i;
     }
   }
