tripal_contact.install 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  1. <?php
  2. /**
  3. * @file
  4. * Handles install, uninstall, disable and enable functionality including database tables.
  5. *
  6. * @ingroup tripal_legacy_contact
  7. */
  8. /**
  9. * Implements hook_disable().
  10. * Disable default views when module is disabled
  11. *
  12. * @ingroup tripal_legacy_contact
  13. */
  14. function tripal_contact_disable() {
  15. // Disable all default views provided by this module
  16. require_once("tripal_contact.views_default.inc");
  17. $views = tripal_contact_views_default_views();
  18. foreach (array_keys($views) as $view_name) {
  19. tripal_disable_view($view_name,FALSE,array('suppress_error' => TRUE));
  20. }
  21. }
  22. /**
  23. * Implementation of hook_requirements().
  24. *
  25. * @ingroup tripal_legacy_contact
  26. */
  27. function tripal_contact_requirements($phase) {
  28. $requirements = array();
  29. if ($phase == 'install') {
  30. // make sure chado is installed
  31. if (!$GLOBALS["chado_is_installed"]) {
  32. $requirements ['tripal_contact'] = array(
  33. 'title' => "tripal_contact",
  34. 'value' => "ERROR: Chado must be installed before this module can be enabled",
  35. 'severity' => REQUIREMENT_ERROR,
  36. );
  37. }
  38. }
  39. return $requirements;
  40. }
  41. /**
  42. * Implementation of hook_install().
  43. *
  44. * @ingroup tripal_legacy_contact
  45. */
  46. function tripal_contact_install() {
  47. // Add cvterms for relationship types.
  48. tripal_contact_add_cvs();
  49. tripal_contact_add_cvterms();
  50. // Set the default vocabularies.
  51. tripal_set_default_cv('contact', 'type_id', 'tripal_contact');
  52. tripal_set_default_cv('contactprop', 'type_id', 'tripal_contact');
  53. tripal_set_default_cv('contact_relationship', 'type_id', 'contact_relationship');
  54. }
  55. /**
  56. * Implementation of hook_uninstall().
  57. *
  58. * @ingroup tripal_legacy_contact
  59. */
  60. function tripal_contact_uninstall() {
  61. }
  62. /**
  63. * Adds any cvs needed by this module.
  64. *
  65. * @ingroup tripal_legacy_contact
  66. */
  67. function tripal_contact_add_cvs() {
  68. // Add the cv for contact properties. This is a default vocabulary in the event
  69. // that a user does not want to use the tripal_contact vocabulary
  70. tripal_insert_cv(
  71. 'contact_property',
  72. 'Contains properties for contacts. This can be used if the tripal_contact vocabulary (which is default for contacts in Tripal) is not desired.'
  73. );
  74. // add the cv for the contact type. This is a default vocabulary in the event
  75. // that a user does not want to use the tripal_contact vocabulary
  76. tripal_insert_cv(
  77. 'contact_type',
  78. 'Contains types of contacts. This can be used if the tripal_contact vocabulary (which is default for contacts in Tripal) is not desired.'
  79. );
  80. // Add the cv for the tripal_contact vocabulary which is loaded via the OBO
  81. tripal_insert_cv(
  82. 'tripal_contact',
  83. 'A heirarchical set of terms for describing a contact. It is intended to be used as the default vocabularies in Tripal for contact types and contact properties.'
  84. );
  85. // add the cv for contact relationships
  86. tripal_insert_cv(
  87. 'contact_relationship',
  88. 'Contains types of relationships between contacts.'
  89. );
  90. }
  91. /**
  92. * Adds any cvterms needed by this module.
  93. *
  94. * @ingroup tripal_legacy_contact
  95. */
  96. function tripal_contact_add_cvterms() {
  97. }
  98. /**
  99. * Implementation of hook_schema().
  100. *
  101. * @ingroup tripal_legacy_contact
  102. */
  103. function tripal_contact_schema() {
  104. $schema['chado_contact'] = array(
  105. 'fields' => array(
  106. 'vid' => array(
  107. 'type' => 'int',
  108. 'unsigned' => TRUE,
  109. 'not null' => TRUE,
  110. 'default' => 0
  111. ),
  112. 'nid' => array(
  113. 'type' => 'int',
  114. 'unsigned' => TRUE,
  115. 'not null' => TRUE,
  116. 'default' => 0
  117. ),
  118. 'contact_id' => array(
  119. 'type' => 'int',
  120. 'not null' => TRUE,
  121. 'default' => 0
  122. )
  123. ),
  124. 'indexes' => array(
  125. 'contact_id' => array('contact_id')
  126. ),
  127. 'unique keys' => array(
  128. 'nid_vid' => array('nid', 'vid'),
  129. 'vid' => array('vid')
  130. ),
  131. 'primary key' => array('nid'),
  132. );
  133. return $schema;
  134. }