You are here

function globallink_create_submission_form_validate in GlobalLink Connect for Drupal 7.7

Validates form actions for GlobalLink submissions.

File

./globallink_send_translations.inc, line 1835

Code

function globallink_create_submission_form_validate($form, &$form_state) {
  module_load_include('inc', 'globallink', 'globallink_settings');
  module_load_include('inc', 'globallink', 'globallink');
  $op = isset($form_state['values']['op']) ? $form_state['values']['op'] : '';
  if ($op != t('Request Translation')) {
    return;
  }
  $pd4 = globallink_get_project_director_details();
  if (!globallink_validate_project_director_details($pd4)) {
    return;
  }
  $source_locale = $form_state['values']['submission_source_locale'];
  $target_locale_arr = $form_state['values']['submission_target_locale'];
  $cart_count = get_cart_count();
  if ($cart_count == 0) {
    form_set_error('', t('No items in Submission. Cannot create translation job.'));
  }
  if (!empty($form_state['values']['submission_due_date'])) {
    $due_date = globallink_convert_date_to_timestamp($form_state['values']['submission_due_date']) / 1000;
    if ($due_date < REQUEST_TIME) {
      form_set_error('', t('The specified date is in past.'));
    }
  }
  if (!isset($source_locale) || !isset($target_locale_arr)) {
    return;
  }
  foreach ($target_locale_arr as $key => $target) {
    if ($target == FALSE) {
      unset($target_locale_arr[$key]);
    }
  }
  $message = FALSE;
  if (count($target_locale_arr) == 0) {
    return;
  }
}