tripal_cv.install 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. <?php
  2. /**
  3. * @file
  4. * Contains functions executed only on install/uninstall of this module
  5. */
  6. /**
  7. * Implements hook_disable().
  8. * Disable default views when module is disabled
  9. *
  10. * @ingroup tripal_legacy_cv
  11. */
  12. function tripal_cv_disable() {
  13. // Disable all default views provided by this module
  14. require_once("tripal_cv.views_default.inc");
  15. $views = tripal_cv_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_requirements().
  22. *
  23. * @ingroup tripal_legacy_cv
  24. */
  25. function tripal_cv_requirements($phase) {
  26. $requirements = array();
  27. if ($phase == 'install') {
  28. // make sure chado is installed
  29. if (!$GLOBALS["chado_is_installed"]) {
  30. $requirements ['tripal_cv'] = array(
  31. 'title' => "tripal_cv",
  32. 'value' => "ERROR: Chado must be installed before this module can be enabled",
  33. 'severity' => REQUIREMENT_ERROR,
  34. );
  35. }
  36. }
  37. return $requirements;
  38. }
  39. /**
  40. * Implementation of hook_install().
  41. *
  42. * @ingroup tripal_legacy_cv
  43. */
  44. function tripal_cv_install() {
  45. }
  46. /**
  47. * Implementation of hook_uninstall().
  48. *
  49. * @ingroup tripal_legacy_cv
  50. */
  51. function tripal_cv_uninstall() {
  52. }
  53. /**
  54. * Implements hook_schema().
  55. */
  56. function tripal_cv_schema() {
  57. $schema['tripal_cv_defaults'] = tripal_chado_tripal_cv_defaults_schema();
  58. return $schema;
  59. }
  60. /**
  61. * * Table definition for the tripal_cv_defaults table
  62. * @param unknown $schema
  63. */
  64. function tripal_chado_tripal_cv_defaults_schema() {
  65. return array(
  66. 'fields' => array(
  67. 'cv_default_id' => array(
  68. 'type' => 'serial',
  69. 'unsigned' => TRUE,
  70. 'not null' => TRUE
  71. ),
  72. 'table_name' => array(
  73. 'type' => 'varchar',
  74. 'length' => 128,
  75. 'not null' => TRUE,
  76. ),
  77. 'field_name' => array(
  78. 'type' => 'varchar',
  79. 'length' => 128,
  80. 'not null' => TRUE,
  81. ),
  82. 'cv_id' => array(
  83. 'type' => 'int',
  84. 'not null' => TRUE,
  85. )
  86. ),
  87. 'indexes' => array(
  88. 'tripal_cv_defaults_idx1' => array('table_name', 'field_name'),
  89. ),
  90. 'unique keys' => array(
  91. 'tripal_cv_defaults_unq1' => array('table_name', 'field_name', 'cv_id'),
  92. ),
  93. 'primary key' => array('cv_default_id')
  94. );
  95. }