tripal_project.install 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. <?php
  2. /**
  3. * @file
  4. * This file contains all the functions which describe and implement drupal database tables
  5. * needed by this module. This module was developed by Chad N.A. Krilow and Lacey-Anne Sanderson,
  6. * University of Saskatchewan.
  7. *
  8. * The project manamgenet module allows you to sync data in a chado/Tripal instance with
  9. * multiple project/mysql instances as well as manage and create such project instances
  10. */
  11. /**
  12. * Disable default views when module is disabled
  13. */
  14. function tripal_project_disable() {
  15. // Disable all default views provided by this module
  16. require_once("tripal_project.views_default.inc");
  17. $views = tripal_project_views_default_views();
  18. foreach (array_keys($views) as $view_name) {
  19. tripal_views_admin_disable_view($view_name,FALSE,array('suppress_error' => TRUE));
  20. }
  21. }
  22. /**
  23. * Implementation of hook_requirements().
  24. *
  25. */
  26. function tripal_project_requirements($phase) {
  27. $requirements = array();
  28. if ($phase == 'install') {
  29. // make sure chado is installed
  30. if (!$GLOBALS["chado_is_installed"]) {
  31. $requirements ['tripal_project'] = array(
  32. 'title' => "tripal_project",
  33. 'value' => "ERROR: Chado most be installed before this module can be enabled",
  34. 'severity' => REQUIREMENT_ERROR,
  35. );
  36. }
  37. }
  38. return $requirements;
  39. }
  40. /**
  41. * Implementation of hook_install().
  42. */
  43. function tripal_project_install() {
  44. // create the module's data directory
  45. tripal_create_moddir('tripal_project');
  46. tripal_project_add_cvterms();
  47. }
  48. /**
  49. * Implementation of hook_uninstall().
  50. */
  51. function tripal_project_uninstall() {
  52. }
  53. /**
  54. * Implementation of hook_schema().
  55. */
  56. function tripal_project_schema() {
  57. $schema['chado_project'] = array(
  58. 'fields' => array(
  59. 'nid' => array(
  60. 'type' => 'int',
  61. 'unsigned' => TRUE,
  62. 'not null' => TRUE,
  63. ),
  64. 'vid' => array(
  65. 'type' => 'int',
  66. 'not null' => TRUE,
  67. ),
  68. 'project_id' => array(
  69. 'type' => 'int',
  70. 'unsigned' => TRUE,
  71. 'not null' => TRUE,
  72. ),
  73. ),
  74. 'primary key' => array('nid', 'vid', 'project_id'),
  75. );
  76. return $schema;
  77. }
  78. /*
  79. *
  80. */
  81. function tripal_project_add_cvterms() {
  82. // Insert cvterm 'library_description' into cvterm table of chado
  83. // database. This CV term is used to keep track of the library
  84. // description in the libraryprop table.
  85. tripal_cv_add_cvterm(array('name' => 'project_description', 'def' => 'Description of a project'),
  86. 'tripal', 0, 1, 'tripal');
  87. }