From 9ee29caf5e0abc94390d8cb4dbad1fb5210b5601 Mon Sep 17 00:00:00 2001
From: NROTC_Webmaster <NROTC_Webmaster@1030166.no-reply.drupal.org>
Date: Sat, 28 Jan 2012 21:08:33 -0500
Subject: [PATCH 2/2] cronplus-preferred-month-1109530-3

Signed-off-by: NROTC_Webmaster <NROTC_Webmaster@1030166.no-reply.drupal.org>
---
 cronplus.module |   19 +++++++++++++++++--
 1 files changed, 17 insertions(+), 2 deletions(-)

diff --git a/cronplus.module b/cronplus.module
index 694f0b4..24263b8 100644
--- a/cronplus.module
+++ b/cronplus.module
@@ -75,6 +75,10 @@ function cronplus_settings_form_validate($form_id, $form_values) {
   if ($cronplus_preferred_wkdy < 0 || $cronplus_preferred_wkdy > 6) {
     form_set_error('cronplus_preferred_wkdy', t('Weekday must be 0 to 6 (Sunday through Saturday, respectively) inclusive'));
   }
+  $cronplus_preferred_month = intval($form_values['cronplus_preferred_month']);
+  if ($cronplus_preferred_month < 0 || $cronplus_preferred_month > 11) {
+    form_set_error('cronplus_preferred_month', t('Weekday must be 0 to 11 (January through December, respectively) inclusive'));
+  }
 }
 
 /**
@@ -83,8 +87,10 @@ function cronplus_settings_form_validate($form_id, $form_values) {
 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']);
+  $cronplus_preferred_month = intval($form_values['cronplus_preferred_month']);
   variable_set('cronplus_preferred_hour', $cronplus_preferred_hour);
   variable_set('cronplus_preferred_wkdy', $cronplus_preferred_wkdy);
+  variable_set('cronplus_preferred_month', $cronplus_preferred_month);
   drupal_set_message(t('Cronplus settings saved'), 'info');
 }
 
@@ -111,6 +117,13 @@ function cronplus_settings_form() {
     '#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_preferred_month'] = array(
+    '#type' => 'select',
+    '#title' => t('Preferred month'),
+    '#description' => t('Preferred month of the year on which yearly jobs will run, if possible. Not guaranteed.'),
+    '#default_value' => intval(variable_get('cronplus_preferred_month', 0)),
+    '#options' => _cronplus_int_options(0, 6, array('January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December', ), TRUE),
+  );
   $form['cronplus_submit'] = array(
     '#type' => 'submit',
     '#value' => t('Save settings'),
@@ -197,14 +210,14 @@ function cronplus_settings_status() {
     if (count($modules) > 0) {
       $group .= '<span class="cronplus_modules">'. implode(', ', $modules) .'</span>';
     }
-      else {
+    else {
       $group .= t('None');
     }
     $group .= '<p>'. t('Last invoked:');
     if ($period == 'cronplus') {
       $group .= t('Invoked along with each of the above');
     }
-      else {
+    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');
     }
@@ -254,6 +267,8 @@ function cronplus_cron() {
   $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));
+  // Preferred month affects yearly runs
+  $prefer_month = intval(variable_get('cronplus_preferred_month', 0));
   $interval = $now - $last_cron;   // Seconds since last run
 
   // Make the appropriate runs. In each case, we try to run in the preferred
-- 
1.7.7.GIT

