tripal_project.install

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

Install the tripal project

File

legacy/tripal_project/tripal_project.install
View source
  1. <?php
  2. /**
  3. * @file
  4. * Install the tripal project
  5. */
  6. /**
  7. * Implements hook_disable().
  8. * Disable default views when module is disabled
  9. *
  10. * @ingroup tripal_legacy_project
  11. */
  12. function tripal_project_disable() {
  13. // Disable all default views provided by this module
  14. require_once("tripal_project.views_default.inc");
  15. $views = tripal_project_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_project
  24. */
  25. function tripal_project_requirements($phase) {
  26. $requirements = array();
  27. if ($phase == 'install') {
  28. // make sure chado is installed
  29. if (!$GLOBALS["chado_is_installed"]) {
  30. $requirements ['tripal_project'] = array(
  31. 'title' => "tripal_project",
  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_project
  43. */
  44. function tripal_project_install() {
  45. tripal_project_add_cvs();
  46. tripal_project_add_cvterms();
  47. // set the default vocabularies
  48. tripal_set_default_cv('projectprop', 'type_id', 'project_property');
  49. tripal_set_default_cv('project_relationship', 'type_id', 'project_relationship');
  50. }
  51. /**
  52. * Implementation of hook_uninstall().
  53. *
  54. * @ingroup tripal_legacy_project
  55. */
  56. function tripal_project_uninstall() {
  57. }
  58. /**
  59. * Implementation of hook_schema().
  60. *
  61. * @ingroup tripal_legacy_project
  62. */
  63. function tripal_project_schema() {
  64. $schema['chado_project'] = array(
  65. 'fields' => array(
  66. 'nid' => array(
  67. 'type' => 'int',
  68. 'unsigned' => TRUE,
  69. 'not null' => TRUE,
  70. ),
  71. 'vid' => array(
  72. 'type' => 'int',
  73. 'not null' => TRUE,
  74. ),
  75. 'project_id' => array(
  76. 'type' => 'int',
  77. 'unsigned' => TRUE,
  78. 'not null' => TRUE,
  79. ),
  80. ),
  81. 'primary key' => array('nid', 'vid', 'project_id'),
  82. );
  83. return $schema;
  84. }
  85. /**
  86. * Add cvs pertaining to projects
  87. *
  88. * @ingroup tripal_legacy_project
  89. */
  90. function tripal_project_add_cvs() {
  91. // Add the cv for project properties
  92. tripal_insert_cv(
  93. 'project_property',
  94. 'Contains properties for projects'
  95. );
  96. // Add cv for relationship types
  97. tripal_insert_cv(
  98. 'project_relationship',
  99. 'Contains Types of relationships between projects.'
  100. );
  101. }
  102. /**
  103. * Add cvterms pertaining to projects
  104. *
  105. * @ingroup tripal_legacy_project
  106. */
  107. function tripal_project_add_cvterms() {
  108. // Insert cvterm 'Project Description' into cvterm table of chado
  109. // database. This CV term is used to keep track of the project
  110. // description in the projectprop table.
  111. tripal_insert_cvterm(
  112. array(
  113. 'name' => 'Project Description',
  114. 'definition' => 'Description of a project',
  115. 'cv_name' => 'project_property',
  116. 'is_relationship' => 0,
  117. 'db_name' => 'tripal'
  118. ),
  119. array('update_existing' => TRUE)
  120. );
  121. }