tripal_jbrowse_page.api.inc 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. <?php
  2. /**
  3. * @file
  4. * Contains Application Programmer Interface (API) functions for this module.
  5. */
  6. /**
  7. * Retrieve the instance id based on the organism.
  8. */
  9. function tripal_jbrowse_page_get_instance_id($conditions, $options) {
  10. // First retrieve the organism_id.
  11. $organism_id = chado_query('SELECT organism_id FROM {organism} WHERE genus=:genus AND species=:species',
  12. [
  13. ':genus' => $conditions['genus'],
  14. ':species' => $conditions['species']
  15. ])->fetchField();
  16. // Then retrieve the instance for that organism.
  17. if ($options['load_instance']) {
  18. $instances = tripal_jbrowse_mgmt_get_instances(['organism_id' => $organism_id]);
  19. return $instances[0];
  20. }
  21. else {
  22. return db_select('tripal_jbrowse_mgmt_instances', 'I')
  23. ->fields('I', ['id'])
  24. ->condition('organism_id', $organism_id)
  25. ->execute()->fetchField();
  26. }
  27. }
  28. /**
  29. * Retrieve the instance id based on the organism.
  30. */
  31. function tripal_jbrowse_page_is_instance_public($instance_id) {
  32. $excluded_instances = variable_get('trpjbrowse_page_exclude', []);
  33. if (!is_array($excluded_instances)) {
  34. $excluded_instances = unserialize($excluded_instances);
  35. }
  36. if (isset($excluded_instances[$instance_id])) {
  37. if ($excluded_instances[$instance_id] === $instance_id) {
  38. return FALSE;
  39. }
  40. else {
  41. return TRUE;
  42. }
  43. }
  44. else {
  45. return TRUE;
  46. }
  47. }