tripal_organism.install 2.7 KB

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