tripal_stock.install

  1. 2.x tripal_stock/tripal_stock.install
  2. 3.x legacy/tripal_stock/tripal_stock.install
  3. 1.x tripal_stock/tripal_stock.install

Install the tripal stock module including it's content type

File

legacy/tripal_stock/tripal_stock.install
View source
  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_legacy_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_legacy_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_legacy_stock
  43. */
  44. function tripal_stock_install() {
  45. // set the default vocabularies
  46. tripal_set_default_cv('stock', 'type_id', 'stock_type');
  47. tripal_set_default_cv('stockprop', 'type_id', 'stock_property');
  48. tripal_set_default_cv('stock_relationship', 'type_id', 'stock_relationship');
  49. // add the materialized view
  50. tripal_stock_add_organism_count_mview();
  51. }
  52. /**
  53. * Implementation of hook_uninstall().
  54. *
  55. * @ingroup tripal_legacy_stock
  56. */
  57. function tripal_stock_uninstall() {
  58. }
  59. /**
  60. * Implementation of hook_schema().
  61. *
  62. * @ingroup tripal_legacy_stock
  63. */
  64. function tripal_stock_schema() {
  65. $schema['chado_stock'] = array(
  66. 'fields' => array(
  67. 'vid' => array(
  68. 'type' => 'int',
  69. 'unsigned' => TRUE,
  70. 'not null' => TRUE,
  71. ),
  72. 'nid' => array(
  73. 'type' => 'int',
  74. 'unsigned' => TRUE,
  75. 'not null' => TRUE,
  76. ),
  77. 'stock_id' => array(
  78. 'type' => 'int',
  79. 'unsigned' => TRUE,
  80. 'not null' => TRUE,
  81. ),
  82. ),
  83. 'indexes' => array(
  84. 'stock_id' => array('stock_id'),
  85. 'nid' => array('nid'),
  86. ),
  87. 'unique' => array(
  88. 'stock_id' => array('stock_id'),
  89. ),
  90. 'primary key' => array('vid'),
  91. );
  92. return $schema;
  93. }