diff --git a/scheduler.install b/scheduler.install index 4584f80..bc887f7 100644 --- a/scheduler.install +++ b/scheduler.install @@ -60,6 +60,7 @@ function scheduler_uninstall() { $variables[] = "scheduler_publish_touch_" . $type_name; $variables[] = "scheduler_publish_required_" . $type_name; $variables[] = "scheduler_publish_revision_" . $type_name; + $variables[] = "scheduler_publish_ignore_" . $type_name; $variables[] = "scheduler_unpublish_enable_" . $type_name; $variables[] = "scheduler_unpublish_required_" . $type_name; $variables[] = "scheduler_unpublish_revision_" . $type_name; diff --git a/scheduler.module b/scheduler.module index 48b22d1..79ce723 100644 --- a/scheduler.module +++ b/scheduler.module @@ -233,6 +233,11 @@ function scheduler_form_node_type_form_alter(&$form, $form_state) { '#title' => t('Create a new revision on publishing'), '#default_value' => variable_get('scheduler_publish_revision_' . $form['#node_type']->type, 0), ); + $form['scheduler']['publish']['scheduler_publish_ignore'] = array( + '#type' => 'checkbox', + '#title' => t('Ignore publish time that is not in the future (Advanced)'), + '#default_value' => variable_get('scheduler_publish_ignore_' . $form['#node_type']->type, 0), + ); $form['scheduler']['unpublish'] = array( '#type' => 'fieldset', '#title' => 'Unpublishing', @@ -613,7 +618,9 @@ function scheduler_node_validate($node, $form) { 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 (variable_get('scheduler_publish_ignore_'. $node->type, 0) == 0) { + form_set_error('publish_on', t("The 'publish on' date must be in the future")); + } } } @@ -639,6 +646,12 @@ function scheduler_node_presave($node) { } elseif (!is_numeric($node->$key)) { $node->$key= _scheduler_strtotime($node->$key); + + if (variable_get('scheduler_publish_ignore_'. $node->type, 0) == 1) { + if ($node->$key && $node->$key < REQUEST_TIME) { + $node->$key = 0; + } + } } } // Right before we save the node, we need to check if a "publish on" value has been set.