tripal_organism.install 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  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_moddir('tripal_organism');
  25. // create the directory where image files will be stored. We create this
  26. tripal_create_mod_subdir('tripal_organism', '/images');
  27. }
  28. /**
  29. * Implementation of hook_schema().
  30. *
  31. * @ingroup tripal_organism
  32. */
  33. function tripal_organism_schema() {
  34. $schema['chado_organism'] = array(
  35. 'fields' => array(
  36. 'vid' => array(
  37. 'type' => 'int',
  38. 'unsigned' => TRUE,
  39. 'not null' => TRUE,
  40. 'default' => 0
  41. ),
  42. 'nid' => array(
  43. 'type' => 'int',
  44. 'unsigned' => TRUE,
  45. 'not null' => TRUE,
  46. 'default' => 0
  47. ),
  48. 'organism_id' => array(
  49. 'type' => 'int',
  50. 'not null' => TRUE,
  51. 'default' => 0
  52. )
  53. ),
  54. 'indexes' => array(
  55. 'organism_id' => array('organism_id')
  56. ),
  57. 'unique keys' => array(
  58. 'nid_vid' => array('nid', 'vid'),
  59. 'vid' => array('vid')
  60. ),
  61. 'primary key' => array('nid'),
  62. );
  63. return $schema;
  64. }
  65. /**
  66. * Implementation of hook_uninstall().
  67. *
  68. * @ingroup tripal_organism
  69. */
  70. function tripal_organism_uninstall() {
  71. }
  72. /**
  73. * Implementation of hook_requirements().
  74. *
  75. */
  76. function tripal_organism_requirements($phase) {
  77. $requirements = array();
  78. if ($phase == 'install') {
  79. // make sure chado is installed
  80. if (!$GLOBALS["chado_is_installed"]) {
  81. $requirements ['tripal_organism'] = array(
  82. 'title' => "tripal_organism",
  83. 'value' => "ERROR: Chado most be installed before this module can be enabled",
  84. 'severity' => REQUIREMENT_ERROR,
  85. );
  86. }
  87. }
  88. return $requirements;
  89. }