You are here

function revision_scheduler_validate_time_scheduled in Revision scheduler 7

1 string reference to 'revision_scheduler_validate_time_scheduled'
revision_scheduler_edit_form in ./revision_scheduler.pages.inc

File

./revision_scheduler.pages.inc, line 252

Code

function revision_scheduler_validate_time_scheduled($element, &$form_state) {
  $value = $element['#value'];
  if (!empty($value) && is_array($value)) {
    $value = implode(' ', array_filter($value));
  }
  if (!empty($value)) {
    $value = strtotime($value);
    if ($value === FALSE) {
      form_error($element, t('Invalid revision scheduled date.'));
    }
    elseif ($value < REQUEST_TIME) {
      form_error($element, t('You cannot set a revision scheduled date in the past.'));
    }
  }
  else {

    // Trigger an error if an operation was selected, but a datetime was not.
    $parents = $element['#parents'];
    array_pop($parents);
    $parents[] = 'operation';
    $operation_value = drupal_array_get_nested_value($form_state['values'], $parents);
    if (!empty($operation_value)) {
      form_set_error(implode('][', $element['#parents']), t('The revision scheduled date field is required.'));
    }
  }
}