tripal_stock.install 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. <?php
  2. /**
  3. * Install the tripal stock module including it's content type
  4. * @file
  5. */
  6. /**
  7. * Implements hook_disable().
  8. * Disable default views when module is disabled
  9. *
  10. * @ingroup tripal_stock
  11. */
  12. function tripal_stock_disable() {
  13. // Disable all default views provided by this module
  14. require_once("tripal_stock.views_default.inc");
  15. $views = tripal_stock_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_stock
  24. */
  25. function tripal_stock_requirements($phase) {
  26. $requirements = array();
  27. if ($phase == 'install') {
  28. // make sure chado is installed
  29. if (!$GLOBALS["chado_is_installed"]) {
  30. $requirements ['tripal_stock'] = array(
  31. 'title' => "tripal_stock",
  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_stock
  43. */
  44. function tripal_stock_install() {
  45. // add some controlled vocabularies
  46. tripal_stock_add_cvs();
  47. tripal_stock_add_cvterms();
  48. // set the default vocabularies
  49. tripal_set_default_cv('stock', 'type_id', 'stock_type');
  50. tripal_set_default_cv('stockprop', 'type_id', 'stock_property');
  51. tripal_set_default_cv('stock_relationship', 'type_id', 'stock_relationship');
  52. // add the materialized view
  53. tripal_stock_add_organism_count_mview();
  54. }
  55. /**
  56. * Implementation of hook_uninstall().
  57. *
  58. * @ingroup tripal_stock
  59. */
  60. function tripal_stock_uninstall() {
  61. }
  62. /**
  63. * Implementation of hook_schema().
  64. *
  65. * @ingroup tripal_stock
  66. */
  67. function tripal_stock_schema() {
  68. $schema['chado_stock'] = array(
  69. 'fields' => array(
  70. 'vid' => array(
  71. 'type' => 'int',
  72. 'unsigned' => TRUE,
  73. 'not null' => TRUE,
  74. ),
  75. 'nid' => array(
  76. 'type' => 'int',
  77. 'unsigned' => TRUE,
  78. 'not null' => TRUE,
  79. ),
  80. 'stock_id' => array(
  81. 'type' => 'int',
  82. 'unsigned' => TRUE,
  83. 'not null' => TRUE,
  84. ),
  85. ),
  86. 'indexes' => array(
  87. 'stock_id' => array('stock_id'),
  88. 'nid' => array('nid'),
  89. ),
  90. 'unique' => array(
  91. 'stock_id' => array('stock_id'),
  92. ),
  93. 'primary key' => array('vid'),
  94. );
  95. return $schema;
  96. }
  97. /**
  98. * Add cvs related to publications
  99. *
  100. * @ingroup tripal_pub
  101. */
  102. function tripal_stock_add_cvs() {
  103. // Add cv for relationship types
  104. tripal_insert_cv(
  105. 'stock_relationship',
  106. 'Contains types of relationships between stocks.'
  107. );
  108. tripal_insert_cv(
  109. 'stock_property',
  110. 'Contains properties for stocks.'
  111. );
  112. tripal_insert_cv(
  113. 'stock_type',
  114. 'Contains a list of types for stocks.'
  115. );
  116. }
  117. /**
  118. * Add cvterms related to publications
  119. *
  120. * @ingroup tripal_pub
  121. */
  122. function tripal_stock_add_cvterms() {
  123. }