tripal_stock.install 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. <?php
  2. /**
  3. * Install the tripal stock module including it's content type
  4. * @file
  5. */
  6. /**
  7. * Disable default views when module is disabled
  8. */
  9. function tripal_stock_disable() {
  10. // Disable all default views provided by this module
  11. require_once("tripal_stock.views_default.inc");
  12. $views = tripal_stock_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_requirements().
  19. *
  20. */
  21. function tripal_stock_requirements($phase) {
  22. $requirements = array();
  23. if ($phase == 'install') {
  24. // make sure chado is installed
  25. if (!$GLOBALS["chado_is_installed"]) {
  26. $requirements ['tripal_stock'] = array(
  27. 'title' => "tripal_stock",
  28. 'value' => "ERROR: Chado must be installed before this module can be enabled",
  29. 'severity' => REQUIREMENT_ERROR,
  30. );
  31. }
  32. }
  33. return $requirements;
  34. }
  35. /**
  36. * Implementation of hook_install().
  37. */
  38. function tripal_stock_install() {
  39. // create the module's data directory
  40. tripal_create_moddir('tripal_stock');
  41. }
  42. /**
  43. * Implementation of hook_uninstall().
  44. */
  45. function tripal_stock_uninstall() {
  46. }
  47. /**
  48. * Implementation of hook_schema().
  49. */
  50. function tripal_stock_schema() {
  51. $schema['chado_stock'] = array(
  52. 'fields' => array(
  53. 'vid' => array(
  54. 'type' => 'int',
  55. 'unsigned' => TRUE,
  56. 'not null' => TRUE,
  57. ),
  58. 'nid' => array(
  59. 'type' => 'int',
  60. 'unsigned' => TRUE,
  61. 'not null' => TRUE,
  62. ),
  63. 'stock_id' => array(
  64. 'type' => 'int',
  65. 'unsigned' => TRUE,
  66. 'not null' => TRUE,
  67. ),
  68. ),
  69. 'indexes' => array(
  70. 'stock_id' => array('stock_id'),
  71. 'nid' => array('nid'),
  72. ),
  73. 'unique' => array(
  74. 'stock_id' => array('stock_id'),
  75. ),
  76. 'primary key' => array('vid'),
  77. );
  78. return $schema;
  79. }