You are here

function revisioning_publish_confirm_validate in Revisioning 8

Same name and namespace in other branches
  1. 6.3 revisioning_scheduler/revisioning_scheduler.module \revisioning_publish_confirm_validate()
  2. 7 revisioning_scheduler/revisioning_scheduler.module \revisioning_publish_confirm_validate()

Implements hook_validate().

File

revisioning_scheduler/revisioning_scheduler.module, line 204
Allows revisions to be published at specified dates and times.

Code

function revisioning_publish_confirm_validate($node, &$form) {
  $date = check_plain($_POST['revisioning_scheduler_date']);
  $date_format = variable_get('revisioning_scheduler_date_format');
  if (empty($date_format)) {
    $date_format = REVISIONING_SCHEDULER_DEFAULT_DATE_FORMAT;
  }
  $date_only_format = drupal_substr($date_format, 0, strpos($date_format, ' '));
  if (strtotime($date) < strtotime(date($date_only_format))) {
    form_set_error('revisioning_scheduler_date', t('The publication date you set is in the past.'));
  }
  else {
    $time = check_plain($_POST['revisioning_scheduler_time']);
    $scheduled_time = strtotime($date . $time);

    // Add 90 seconds of slack to give user a chance to publish instantly by
    // leaving time as is.
    if ($scheduled_time < time() - REVISIONING_SCHEDULER_SLACK) {
      form_set_error('revisioning_scheduler_time', t('The publication time you set is in the past.'));
    }
  }
}