function tripal_get_organism_select_options

2.x tripal_organism.api.inc tripal_get_organism_select_options($syncd_only = TRUE)

Returns a list of organisms that are currently synced with Drupal to use in select lists

Parameters

$syncd_only: Whether or not to return all chado organisms or just those sync'd with drupal. Defaults to TRUE (only sync'd organisms)

Return value

An array of organisms sync'd with Drupal where each value is the organism scientific name and the keys are organism_id's

Related topics

3 calls to tripal_get_organism_select_options()
chado_example_form in tripal_example/includes/tripal_example.chado_node.inc
Implementation of hook_form()
tripal_feature_delete_form in tripal_feature/includes/tripal_feature.delete.inc
A form for indicating the features to delete
tripal_organism_get_synced in tripal_organism/api/tripal_organism.DEPRECATED.inc
1 string reference to 'tripal_get_organism_select_options'

File

tripal_organism/api/tripal_organism.api.inc, line 141
Provides an application programming interface (API) to manage organisms

Code

function tripal_get_organism_select_options($syncd_only = TRUE) {
  $org_list = array();
  $org_list[] = 'Select an organism';

  if ($syncd_only) {
    // @todo: Re-write to support external chado databases.
    $sql = "
      SELECT *
      FROM [chado_organism] CO
        INNER JOIN {organism} O ON O.organism_id = CO.organism_id
      ORDER BY O.genus, O.species
    ";
    $orgs = chado_query($sql);

    // iterate through the organisms and build an array of those that are synced
    foreach ($orgs as $org) {
      $org_list[$org->organism_id] = $org->genus . ' ' . $org->species;
    }
  }
  else {
    // use this SQL statement for getting the organisms
    $csql = "SELECT * FROM {organism} ORDER BY genus, species";
    $orgs = chado_query($csql);

    // iterate through the organisms and build an array of those that are synced
    foreach ($orgs as $org) {
      $org_list[$org->organism_id] = $org->genus . ' ' . $org->species;
    }
  }
  return $org_list;
}