You are here

function _scheduler_form_validate in Scheduler 5

Implementation of hook_form_validate() Validate the input of the publish and unpublish date fields

File

./scheduler.module, line 314

Code

function _scheduler_form_validate($form_id, $form) {
  $publishtime = NULL;
  $unpublishtime = NULL;
  if (isset($form['publish_on'])) {
    $publishtime = _scheduler_strtotime($form['publish_on']);
    if ($publishtime === FALSE) {
      form_set_error('publish_on', t('The entered publication date is invalid.'));
    }
  }
  if (isset($form['unpublish_on'])) {
    $unpublishtime = _scheduler_strtotime($form['unpublish_on']);
    if ($unpublishtime === FALSE) {
      form_set_error('unpublish_on', t('The entered expiration date is invalid.'));
    }
  }
  if (is_integer($publishtime) && is_integer($unpublishtime) && $unpublishtime < $publishtime) {
    form_set_error('unpublish_on', t("The expiration date is before publication date."));
  }
}