tripal_organism.install 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. <?php
  2. /**
  3. * @file
  4. * Functions pertaining to the install/uninstall of this module
  5. */
  6. /**
  7. * Implements hook_disable().
  8. * Disable default views when module is disabled
  9. *
  10. * @ingroup tripal_organism
  11. */
  12. function tripal_organism_disable() {
  13. // Disable all default views provided by this module
  14. require_once("tripal_organism.views_default.inc");
  15. $views = tripal_organism_views_default_views();
  16. foreach (array_keys($views) as $view_name) {
  17. tripal_disable_view($view_name,FALSE,array('suppress_error' => TRUE));
  18. }
  19. }
  20. /**
  21. * Implementation of hook_install().
  22. *
  23. * @ingroup tripal_organism
  24. */
  25. function tripal_organism_install() {
  26. // cvs & cvterms
  27. tripal_organism_add_cvs();
  28. tripal_organism_add_cvterms();
  29. // set the default vocabularies
  30. tripal_set_default_cv('organismprop', 'type_id', 'organism_property');
  31. }
  32. /**
  33. * Implementation of hook_schema().
  34. *
  35. * @ingroup tripal_organism
  36. */
  37. function tripal_organism_schema() {
  38. $schema['chado_organism'] = array(
  39. 'fields' => array(
  40. 'vid' => array(
  41. 'type' => 'int',
  42. 'unsigned' => TRUE,
  43. 'not null' => TRUE,
  44. 'default' => 0
  45. ),
  46. 'nid' => array(
  47. 'type' => 'int',
  48. 'unsigned' => TRUE,
  49. 'not null' => TRUE,
  50. 'default' => 0
  51. ),
  52. 'organism_id' => array(
  53. 'type' => 'int',
  54. 'not null' => TRUE,
  55. 'default' => 0
  56. )
  57. ),
  58. 'indexes' => array(
  59. 'organism_id' => array('organism_id')
  60. ),
  61. 'unique keys' => array(
  62. 'nid_vid' => array('nid', 'vid'),
  63. 'vid' => array('vid')
  64. ),
  65. 'primary key' => array('nid'),
  66. );
  67. return $schema;
  68. }
  69. /**
  70. * Implementation of hook_uninstall().
  71. *
  72. * @ingroup tripal_organism
  73. */
  74. function tripal_organism_uninstall() {
  75. }
  76. /**
  77. * Implementation of hook_requirements().
  78. *
  79. * @ingroup tripal_organism
  80. */
  81. function tripal_organism_requirements($phase) {
  82. $requirements = array();
  83. if ($phase == 'install') {
  84. // make sure chado is installed
  85. if (!$GLOBALS["chado_is_installed"]) {
  86. $requirements ['tripal_organism'] = array(
  87. 'title' => "tripal_organism",
  88. 'value' => "ERROR: Chado must be installed before this module can be enabled",
  89. 'severity' => REQUIREMENT_ERROR,
  90. );
  91. }
  92. }
  93. return $requirements;
  94. }
  95. /**
  96. * Add cvterms related to organisms
  97. *
  98. * @ingroup tripal_organism
  99. */
  100. function tripal_organism_add_cvs() {
  101. tripal_insert_cv(
  102. 'organism_property',
  103. 'Contains properties for organisms'
  104. );
  105. }
  106. /**
  107. * Add cvterms pertaining to organisms
  108. *
  109. * @ingroup tripal_organism
  110. */
  111. function tripal_organism_add_cvterms() {
  112. }