Index: scheduler.module
===================================================================
--- scheduler.module	(revision 4734)
+++ scheduler.module	(working copy)
@@ -263,8 +263,7 @@
     // if scheduling has been enabled for this node type
     if ($publishing_enabled || $unpublishing_enabled) {
 
-      $node = $form['#node'];
-
+      $form['#validate'][] = 'scheduler_form_validate';
       $date_format = variable_get('scheduler_date_format', SCHEDULER_DATE_FORMAT);
       $use_date_popup = _scheduler_use_date_popup();
 
@@ -581,8 +580,8 @@
   }
 }
 
-function scheduler_node_validate($node, $form) {
-  // adjust the entered times for timezone consideration.
+function scheduler_form_validate($node, $form) {
+ // adjust the entered times for timezone consideration.
   // Note, we must check to see if the value is numeric,
   // if it is, assume we have already done the strtotime
   // conversion. This prevents us running strtotime on
@@ -590,30 +589,39 @@
   // because DRUPAL6 removed 'submit' and added 'presave'
   // and all this happens at different times.
 
-  $date_format = variable_get('scheduler_date_format', SCHEDULER_DATE_FORMAT);
+  if (!empty($form['complete form']['#node_edit_form']) && user_access('schedule (un)publishing of nodes')) {
+    $publishing_enabled = variable_get('scheduler_publish_enable_'. $form['complete form']['type']['#value'], 0) == 1;
+    $unpublishing_enabled = variable_get('scheduler_unpublish_enable_'. $form['complete form']['type']['#value'], 0) == 1;
 
-  if (!empty($node->publish_on) && !is_numeric($node->publish_on)) {
-    $publishtime = _scheduler_strtotime($node->publish_on);
-    if ($publishtime === FALSE) {
-      form_set_error('publish_on', t("The 'publish on' value does not match the expected format of %time", array('%time' => format_date(REQUEST_TIME, 'custom', $date_format))));
-    }
-    elseif ($publishtime && $publishtime < REQUEST_TIME) {
-      form_set_error('publish_on', t("The 'publish on' date must be in the future"));
-    }
-  }
+    // if scheduling has been enabled for this node type
+    if ($publishing_enabled || $unpublishing_enabled) {
 
-  if (!empty($node->unpublish_on) && !is_numeric($node->unpublish_on)) {
-    $unpublishtime = _scheduler_strtotime($node->unpublish_on);
-    if ($unpublishtime === FALSE) {
-      form_set_error('unpublish_on', t("The 'unpublish on' value does not match the expected format of %time", array('%time' => format_date(REQUEST_TIME, 'custom', $date_format))));
-    }
-    elseif ($unpublishtime && $unpublishtime < REQUEST_TIME) {
-      form_set_error('unpublish_on', t("The 'unpublish on' date must be in the future"));
+      if (isset($form['values']['publish_on'])) $publish_on_time = $form['values']['publish_on'];
+      if (isset($form['values']['unpublish_on']))  $unpublish_on_time = $form['values']['unpublish_on'];
+
+      if (!empty($publish_on_time) && !is_numeric($publish_on_time)) {
+        $publishtime = _scheduler_strtotime($publish_on_time);
+        if ($publishtime === FALSE) {
+          form_set_error('publish_on', t("The 'publish on' value does not match the expected format of %time", array('%time' => format_date(REQUEST_TIME, 'custom', $date_format))));
+        }
+        elseif ($publishtime && $publishtime < REQUEST_TIME) {
+          form_set_error('publish_on', t("The 'publish on' date must be in the future"));
+        }
+      }
+      if (!empty($unpublish_on_time) && $unpublish_on_time == 0 && !is_numeric($unpublish_on_time)) {
+        $unpublishtime = _scheduler_strtotime($unpublish_on_time);
+        if ($unpublishtime === FALSE) {
+          form_set_error('unpublish_on', t("The 'unpublish on' value does not match the expected format of %time", array('%time' => format_date(REQUEST_TIME, 'custom', $date_format))));
+        }
+        elseif ($unpublishtime && $unpublishtime < REQUEST_TIME) {
+          form_set_error('unpublish_on', t("The 'unpublish on' date must be in the future"));
+        }
+      }
+      if (isset($publishtime) && isset($unpublishtime) && $unpublishtime < $publishtime) {
+        form_set_error('unpublish_on', t("The 'unpublish on' date must be later than the 'publish on' date."));
+      }
     }
   }
-  if (isset($publishtime) && isset($unpublishtime) && $unpublishtime < $publishtime) {
-    form_set_error('unpublish_on', t("The 'unpublish on' date must be later than the 'publish on' date."));
-  }
 }
 
 function scheduler_node_presave($node) {
