--- scheduler.module.b.before 2009-05-08 08:22:09.000000000 +0100 +++ scheduler.module 2009-05-08 08:14:27.000000000 +0100 @@ -345,37 +345,46 @@ function scheduler_nodeapi(&$node, $op, // 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 - // conversation. This prevents us running strtotime on + // conversion. This prevents us running strtotime on // a value we have already converted. This is needed // because DRUPAL6 removed 'submit' and added 'presave' // and all this happens at different times. - if (isset($node->publish_on) && !is_numeric($node->publish_on)) { + + $date_format = variable_get('scheduler_date_format', SCHEDULER_DATE_FORMAT); + + if (isset($node->publish_on) && $node->publish_on && !is_numeric($node->publish_on)) { $publishtime = _scheduler_strtotime($node->publish_on); if ($publishtime === FALSE) { - form_set_error('publish_on', t('The entered publication date is invalid.')); + form_set_error('publish_on', t("The 'publish on' value does not match the expected format of %time", array('%time' => format_date(time(), 'custom', $date_format)))); + } + elseif ($publishtime && $publishtime < time()) { + form_set_error('publish_on', t("The 'publish on' date must be in the future")); } else { $node->publish_on = $publishtime; } } - if (isset($node->unpublish_on) && !is_numeric($node->unpublish_on)) { + if (isset($node->unpublish_on) && $node->unpublish_on && !is_numeric($node->unpublish_on)) { $unpublishtime = _scheduler_strtotime($node->unpublish_on); if ($unpublishtime === FALSE) { - form_set_error('unpublish_on', t('The entered expiration date is invalid.')); + form_set_error('unpublish_on', t("The 'unpublish on' value does not match the expected format of %time", array('%time' => format_date(time(), 'custom', $date_format)))); + } + elseif ($unpublishtime && $unpublishtime < time()) { + form_set_error('unpublish_on', t("The 'unpublish on' date must be in the future")); } else { $node->unpublish_on = $unpublishtime; } } + if (isset($publishtime) && isset($unpublishtime) && $unpublishtime < $publishtime) { - form_set_error('unpublish_on', t("The expiration date is before publication date.")); + form_set_error('unpublish_on', t("The 'unpublish on' date must be later than the 'publish on' date.")); } - // right before we save the node, we need to check if a "publish on" value has been set - // if it has been set, we want to make sure the node is unpublished - // since it will be published at a later date (but only if the value is in the future. - if (isset($node->publish_on) && $node->publish_on != '' && is_numeric($node->publish_on) && $node->publish_on > time()) { + // Right before we save the node, we need to check if a "publish on" value has been set. + // If it has been set, we want to make sure the node is unpublished since it will be published at a later date + if (isset($node->publish_on) && $node->publish_on != '' && is_numeric($node->publish_on) ) { $node->status = 0; } break; @@ -401,7 +410,7 @@ function scheduler_nodeapi(&$node, $op, } } // node doesn't exist, create a record only if the (un)publish fields are blank - else if ((isset($node->publish_on) && $node->publish_on != NULL) || (isset($node->unpublish_on) && $node->unpublish_on != NULL)) { + elseif ((isset($node->publish_on) && $node->publish_on != NULL) || (isset($node->unpublish_on) && $node->unpublish_on != NULL)) { db_query('INSERT INTO {scheduler} (nid, publish_on, unpublish_on) VALUES (%d, %d, %d)', $node->nid, $node->publish_on, $node->unpublish_on); } }