function chado_library_validate

2.x tripal_library.chado_node.inc chado_library_validate($node, $form, &$form_state)
3.x tripal_library.chado_node.inc chado_library_validate($node, $form, &$form_state)
1.x tripal_library.module chado_library_validate($node)

validates submission of form when adding or updating a library node

Related topics

File

tripal_library/tripal_library.module, line 537

Code

function chado_library_validate($node) {
  $lib = 0;
  // check to make sure the unique name on the library is unique
  // before we try to insert into chado.
  if ($node->library_id) {
    $sql = "SELECT * FROM " .
      "{Library} WHERE " .
      "uniquename = '%s' " .
      "AND NOT library_id = %d";
    $lib = db_fetch_object(chado_query($sql, $node->uniquename, $node->library_id));
  }
  else {
    $sql = "SELECT * FROM " .
      "{Library} " .
      "WHERE uniquename = '%s'";
    $lib = db_fetch_object(chado_query($sql, $node->uniquename));
  }
  if ($lib) {
    form_set_error('uniquename', t('The unique library name already exists. ' .
      'Please choose another'));
  }
}