tripal_pub.install 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  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. * Implementation of hook_install().
  13. */
  14. function tripal_pub_install() {
  15. // create the module's data directory
  16. tripal_create_moddir('tripal_pub');
  17. // install the tripal_oub
  18. drupal_install_schema('tripal_pub');
  19. // add any cvterms we need for this module
  20. tripal_pub_add_cvterms();
  21. }
  22. /*
  23. *
  24. *
  25. */
  26. function tripal_pub_add_cvterms(){
  27. tripal_cv_add_cvterm(array('name' => 'abstract', 'def' => 'Publication abstract'),
  28. 'tripal_pub', 0, 1, 'tripal');
  29. }
  30. /**
  31. * Implementation of hook_uninstall().
  32. */
  33. function tripal_pub_uninstall() {
  34. //Remove tables
  35. drupal_uninstall_schema('tripal_pub');
  36. }
  37. /**
  38. * Implementation of hook_schema().
  39. */
  40. function tripal_pub_schema() {
  41. $schema['chado_pub'] = array(
  42. 'fields' => array(
  43. 'vid' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0),
  44. 'nid' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0),
  45. 'pub_id' => array('type' => 'int', 'not null' => TRUE, 'default' => 0),
  46. 'sync_date' => array('type' => 'int', 'not null' => FALSE, 'description' => 'UNIX integer sync date/time'),
  47. ),
  48. 'indexes' => array(
  49. 'pub_id' => array('pub_id')
  50. ),
  51. 'unique keys' => array(
  52. 'nid_vid' => array('nid', 'vid'),
  53. 'vid' => array('vid')
  54. ),
  55. 'primary key' => array('nid'),
  56. );
  57. /*
  58. //a intfield, not null and project_id is the unique_id of the project in chado
  59. 'pubmed_id' => array(
  60. 'type' => 'int',
  61. 'unsigned' => TRUE,
  62. 'not null' => FALSE,
  63. ),
  64. 'author' => array(
  65. 'type' => 'text',
  66. 'size' => 'normal',
  67. 'not null' => TRUE,
  68. 'default' => '',
  69. 'description' => 'The Author Name.',
  70. ),*/
  71. return $schema;
  72. }
  73. /**
  74. * Implementation of hook_requirements().
  75. */
  76. function tripal_pub_requirements($phase) {
  77. $requirements = array();
  78. if ($phase == 'install') {
  79. // make sure chado is installed
  80. if (!tripal_core_is_chado_installed()) {
  81. $requirements ['tripal_pub'] = array(
  82. 'title' => "tripal_pub",
  83. 'value' => "ERROR: Chado most be installed before this module can be enabled",
  84. 'severity' => REQUIREMENT_ERROR,
  85. );
  86. }
  87. }
  88. return $requirements;
  89. }