function tripal_pub_importer_setup_form_validate

2.x tripal_pub.pub_importers.inc tripal_pub_importer_setup_form_validate($form, &$form_state)
3.x tripal_chado.pub_importers.inc tripal_pub_importer_setup_form_validate($form, &$form_state)
1.x pub_importers.inc tripal_pub_importer_setup_form_validate($form, &$form_state)

Validate the tripal_pub_importer_setup_form form

Related topics

File

tripal_pub/includes/tripal_pub.pub_importers.inc, line 612
Management of importers

Code

function tripal_pub_importer_setup_form_validate($form, &$form_state) {
  $num_criteria = $form_state['values']['num_criteria'];
  $remote_db = $form_state['values']["remote_db"];
  $days = trim($form_state['values']["days"]);
  $disabled = $form_state['values']["disabled"];
  $do_contact = $form_state['values']["do_contact"];
  $loader_name = trim($form_state['values']["loader_name"]);

  for ($i = 1; $i <= $num_criteria; $i++) {
    $search_terms = trim($form_state['values']["search_terms-$i"]);
    $scope = $form_state['values']["scope-$i"];
    $is_phrase = $form_state['values']["is_phrase-$i"];
    $operation = '';
    if ($i > 1) {
      $operation = $form_state['values']["operation-$i"];
    }

    if (!$is_phrase) {
      if (preg_match('/and/i', $search_terms) and preg_match('/or/i', $search_terms)) {
        form_set_error("search_terms-$i", "You may use 'AND' or 'OR' but cannot use both. Add a new entry below with the same scope for the other conunction.");
        $_SESSION['tripal_pub_import']['perform_search'] = 0;
      }
    }
  }

  if ($days and !is_numeric($days) or preg_match('/\./', $days)) {
    form_set_error("days", "Please enter a numeric, non decimal value, for the number of days.");
    $_SESSION['tripal_pub_import']['perform_search'] = 0;
  }
  // allow the selected remote database to validate any changes to the form if needed
  $callback = "tripal_pub_remote_validate_form_$remote_db";
  $form = call_user_func($callback, $form, $form_state);
}