tripal_stock.install 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  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_views_admin_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. // create the module's data directory
  46. tripal_create_files_dir('tripal_stock');
  47. }
  48. /**
  49. * Implementation of hook_uninstall().
  50. *
  51. * @ingroup tripal_stock
  52. */
  53. function tripal_stock_uninstall() {
  54. }
  55. /**
  56. * Implementation of hook_schema().
  57. *
  58. * @ingroup tripal_stock
  59. */
  60. function tripal_stock_schema() {
  61. $schema['chado_stock'] = array(
  62. 'fields' => array(
  63. 'vid' => array(
  64. 'type' => 'int',
  65. 'unsigned' => TRUE,
  66. 'not null' => TRUE,
  67. ),
  68. 'nid' => array(
  69. 'type' => 'int',
  70. 'unsigned' => TRUE,
  71. 'not null' => TRUE,
  72. ),
  73. 'stock_id' => array(
  74. 'type' => 'int',
  75. 'unsigned' => TRUE,
  76. 'not null' => TRUE,
  77. ),
  78. ),
  79. 'indexes' => array(
  80. 'stock_id' => array('stock_id'),
  81. 'nid' => array('nid'),
  82. ),
  83. 'unique' => array(
  84. 'stock_id' => array('stock_id'),
  85. ),
  86. 'primary key' => array('vid'),
  87. );
  88. return $schema;
  89. }