? .svn
? scheduler_node_save.patch
? scheduler_split_publishing.patch
? po/.svn
Index: scheduler.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/scheduler/scheduler.module,v
retrieving revision 1.37.2.11
diff -u -r1.37.2.11 scheduler.module
--- scheduler.module	15 Nov 2006 21:13:51 -0000	1.37.2.11
+++ scheduler.module	20 Apr 2007 07:35:00 -0000
@@ -25,18 +25,28 @@
 function scheduler_form_alter($form_id, &$form) {
   //allow scheduling on a per-node-type basis
   if (isset($form['type']) && $form['type']['#value'] .'_node_settings' == $form_id) {
-    $form['workflow']['scheduler_'. $form['type']['#value']] = array(
+    $form['workflow']['scheduler'] = array(
+      '#type' => 'fieldset',
+      '#title' => t('Scheduled (un)publishing'),
+      '#description' => t('Check these boxes to enable scheduled (un)publishing for this node type.')
+    );
+  
+    $form['workflow']['scheduler']['scheduler_on_'. $form['type']['#value']] = array(
+      '#type' => 'checkbox', 
+      '#title' => t('Enable scheduled publishing'),
+      '#default_value' => variable_get('scheduler_on_'. $form['type']['#value'], 0),
+    );
+    $form['workflow']['scheduler']['scheduler_off_'. $form['type']['#value']] = array(
       '#type' => 'checkbox', 
-      '#title' => t('Enable scheduled (un)publishing'), 
-      '#default_value' => variable_get('scheduler_'. $form['type']['#value'], 0),
-      '#description' => t('Check this box to enable scheduled (un)publishing for this node type.')
+      '#title' => t('Enable scheduled unpublishing'),
+      '#default_value' => variable_get('scheduler_off_'. $form['type']['#value'], 0),
     );
   }
  
   else if (isset($form['type']) && $form['type']['#value'] .'_node_form' == $form_id) {
     if (user_access('schedule (un)publishing of nodes')) {
       // if scheduling has been enabled for this node type
-      if (variable_get('scheduler_'. $form['type']['#value'], 0) == 1) {
+      if (variable_get('scheduler_on_'. $form['type']['#value'], 0) == 1 || variable_get('scheduler_off_'. $form['type']['#value'], 0) == 1) {
         
         //use JScalendar picker for dates if the module exists and is enabled
         $jscalendar = FALSE;
@@ -62,31 +72,35 @@
           '#collapsed' => ($defaults->publish_on != 0 || $defaults->unpublish_on != 0) ? FALSE: TRUE,
           '#weight' => 35
         );
-        
-        $form['scheduler_settings']['publish_on'] = array(
-          '#type' => 'textfield', 
-          '#title' => t('Publish on'), 
-          '#maxlength' => 25,
-          //we subtract the time zone to show the user the correct time they entered
-          //and below that we show the timezone to adjust this time by
-          //we store the adjusted timezone value in the database for cron
-          '#default_value' => $defaults->publish_on ? date('Y-m-d H:i:s', $defaults->publish_on - $defaults->timezone) : '',
-          '#description' => t('Format: %time. Leave blank to publish on the time of form submission.', array('%time' => date('Y-m-d H:i:s'))),
-          '#attributes' => $jscalendar ? array('class' => 'jscalendar') : array()
-        );
-        
-        $form['scheduler_settings']['unpublish_on'] = array(
-          '#type' => 'textfield', 
-          '#title' => t('Unpublish on'), 
-          '#maxlength' => 25, 
-          //we subtract the time zone to show the user the correct time they entered
-          //and below that we show the timezone to adjust this time by
-          //we store the adjusted timezone value in the database for cron
-          '#default_value' => $defaults->unpublish_on ? date('Y-m-d H:i:s', $defaults->unpublish_on - $defaults->timezone) : '',
-          '#description' => t('Format: %time. Leave blank to not unpublish this node.', array('%time' => date('Y-m-d H:i:s'))),
-          '#attributes' => $jscalendar ? array('class' => 'jscalendar') : array()
-        );
-        
+
+        if (variable_get('scheduler_on_'. $form['type']['#value'], 0) == 1) {
+          $form['scheduler_settings']['publish_on'] = array(
+            '#type' => 'textfield', 
+            '#title' => t('Publish on'), 
+            '#maxlength' => 25,
+            //we subtract the time zone to show the user the correct time they entered
+            //and below that we show the timezone to adjust this time by
+            //we store the adjusted timezone value in the database for cron
+            '#default_value' => $defaults->publish_on ? date('Y-m-d H:i:s', $defaults->publish_on - $defaults->timezone) : '',
+            '#description' => t('Format: %time. Leave blank to publish on the time of form submission.', array('%time' => date('Y-m-d H:i:s'))),
+            '#attributes' => $jscalendar ? array('class' => 'jscalendar') : array()
+          );
+        }
+
+        if (variable_get('scheduler_off_'. $form['type']['#value'], 0) == 1) {
+          $form['scheduler_settings']['unpublish_on'] = array(
+            '#type' => 'textfield', 
+            '#title' => t('Unpublish on'), 
+            '#maxlength' => 25, 
+            //we subtract the time zone to show the user the correct time they entered
+            //and below that we show the timezone to adjust this time by
+            //we store the adjusted timezone value in the database for cron
+            '#default_value' => $defaults->unpublish_on ? date('Y-m-d H:i:s', $defaults->unpublish_on - $defaults->timezone) : '',
+            '#description' => t('Format: %time. Leave blank to not unpublish this node.', array('%time' => date('Y-m-d H:i:s'))),
+            '#attributes' => $jscalendar ? array('class' => 'jscalendar') : array()
+          );
+        }
+
         //default to user timezone, if not specified, default to system wide timezone
         global $user;
         $zones = _system_zonelist();
@@ -168,7 +182,10 @@
   $nodes = db_query('SELECT *, (publish_on - timezone) AS utc_publish_on FROM {scheduler} s LEFT JOIN {node} n ON s.nid = n.nid WHERE n.status = 0 AND s.publish_on > 0 AND s.publish_on < %d + s.timezone', time());
   
   while ($node = db_fetch_object($nodes)) {
-    db_query('UPDATE {node} SET created = %d, changed = %d, status = 1 WHERE nid = %d', $node->utc_publish_on, $node->utc_publish_on, $node->nid);
+    $node = node_load($node->nid);
+    $node->changed = $node->utc_publish_on;
+    $node->status = 1;
+    node_save($node);
     
     //if this node is not to be unpublished, then we can delete the record
     if ($node->unpublish_on == 0) {
@@ -191,7 +208,11 @@
   
   while ($node = db_fetch_object($nodes)) {
     //if this node is to be unpublished, we can update the node and remove the record since it can't be republished
-    db_query('UPDATE {node} SET status = 0, changed = %d WHERE nid = %d', $node->utc_unpublish_on, $node->nid);
+    $node = node_load($node->nid);
+    $node->changed = $node->utc_publish_on;
+    $node->status = 0;
+    node_save($node);
+ 
     db_query('DELETE FROM {scheduler} WHERE nid = %d', $node->nid);
     
     //invoke scheduler API
