tripal_organism.install 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  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_views_admin_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. // create the module's data directory
  27. tripal_create_files_dir('tripal_organism');
  28. // create the directory where image files will be stored. We create this
  29. tripal_create_files_dir('tripal_organism', '/images');
  30. // cvs & cvterms
  31. tripal_organism_add_cvs();
  32. tripal_organism_add_cvterms();
  33. }
  34. /**
  35. * Implementation of hook_schema().
  36. *
  37. * @ingroup tripal_organism
  38. */
  39. function tripal_organism_schema() {
  40. $schema['chado_organism'] = array(
  41. 'fields' => array(
  42. 'vid' => array(
  43. 'type' => 'int',
  44. 'unsigned' => TRUE,
  45. 'not null' => TRUE,
  46. 'default' => 0
  47. ),
  48. 'nid' => array(
  49. 'type' => 'int',
  50. 'unsigned' => TRUE,
  51. 'not null' => TRUE,
  52. 'default' => 0
  53. ),
  54. 'organism_id' => array(
  55. 'type' => 'int',
  56. 'not null' => TRUE,
  57. 'default' => 0
  58. )
  59. ),
  60. 'indexes' => array(
  61. 'organism_id' => array('organism_id')
  62. ),
  63. 'unique keys' => array(
  64. 'nid_vid' => array('nid', 'vid'),
  65. 'vid' => array('vid')
  66. ),
  67. 'primary key' => array('nid'),
  68. );
  69. return $schema;
  70. }
  71. /**
  72. * Implementation of hook_uninstall().
  73. *
  74. * @ingroup tripal_organism
  75. */
  76. function tripal_organism_uninstall() {
  77. }
  78. /**
  79. * Implementation of hook_requirements().
  80. *
  81. * @ingroup tripal_organism
  82. */
  83. function tripal_organism_requirements($phase) {
  84. $requirements = array();
  85. if ($phase == 'install') {
  86. // make sure chado is installed
  87. if (!$GLOBALS["chado_is_installed"]) {
  88. $requirements ['tripal_organism'] = array(
  89. 'title' => "tripal_organism",
  90. 'value' => "ERROR: Chado must be installed before this module can be enabled",
  91. 'severity' => REQUIREMENT_ERROR,
  92. );
  93. }
  94. }
  95. return $requirements;
  96. }
  97. /**
  98. * Add cvterms related to organisms
  99. *
  100. * @ingroup tripal_organism
  101. */
  102. function tripal_organism_add_cvs() {
  103. tripal_cv_add_cv('organism_property', 'Contains properties for organisms');
  104. }
  105. /**
  106. * Add cvterms pertaining to organisms
  107. *
  108. * @ingroup tripal_organism
  109. */
  110. function tripal_organism_add_cvterms() {
  111. }
  112. /**
  113. * This is the required update for tripal_organism when upgrading from Drupal core API 6.x.
  114. *
  115. * @ingroup tripal_organism
  116. */
  117. function tripal_organism_update_7000() {
  118. tripal_organism_add_cvs();
  119. tripal_organism_add_cvterms();
  120. }