tripal_db.module 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. <?php
  2. require_once "api/tripal_db.api.inc";
  3. require_once "includes/tripal_db.admin.inc";
  4. /**
  5. * @defgroup tripal_db DB Module
  6. * @ingroup tripal_modules
  7. */
  8. /**
  9. *
  10. * @ingroup tripal_db
  11. */
  12. function tripal_db_init() {
  13. // add the tripal_db JS and CSS
  14. drupal_add_css(drupal_get_path('theme', 'tripal') . '/css/tripal_db.css');
  15. drupal_add_js(drupal_get_path('theme', 'tripal') . '/js/tripal_db.js');
  16. }
  17. /**
  18. *
  19. * @ingroup tripal_db
  20. */
  21. function tripal_db_menu() {
  22. $items = array();
  23. $items['admin/tripal/tripal_db'] = array(
  24. 'title' => 'Databases',
  25. 'description' => 'Basic Description of Tripal DB Module Functionality',
  26. 'page callback' => 'tripal_db_module_description_page',
  27. 'access callback' => 'user_access',
  28. 'access arguments' => array('administer db cross-references'),
  29. 'type' => MENU_NORMAL_ITEM,
  30. );
  31. $items['admin/tripal/tripal_db/edit_db'] = array(
  32. 'title' => 'Edit a Database',
  33. 'description' => 'Manage Databases ',
  34. 'page callback' => 'drupal_get_form',
  35. 'page arguments' => array('tripal_db_form', 'Update'),
  36. 'access callback' => 'user_access',
  37. 'access arguments' => array('administer db cross-references'),
  38. 'type' => MENU_NORMAL_ITEM,
  39. );
  40. $items['admin/tripal/tripal_db/add_db'] = array(
  41. 'title' => 'Add a Database',
  42. 'page callback' => 'drupal_get_form',
  43. 'page arguments' => array('tripal_db_form', 'Add'),
  44. 'access callback' => 'user_access',
  45. 'access arguments' => array('administer db cross-references'),
  46. 'type' => MENU_NORMAL_ITEM,
  47. );
  48. $items['admin/tripal/tripal_db/edit/js'] = array(
  49. 'page callback' => 'tripal_ajax_db_edit',
  50. 'access callback' => 'user_access',
  51. 'access arguments' => array('access administration pages'),
  52. 'type' => MENU_CALLBACK,
  53. );
  54. return $items;
  55. }
  56. /**
  57. * Set the permission types that the chado module uses. Essentially we
  58. * want permissionis that protect creation, editing and deleting of chado
  59. * data objects
  60. *
  61. * @ingroup tripal_db
  62. */
  63. function tripal_db_perm() {
  64. return array(
  65. 'administer db cross-references',
  66. );
  67. }
  68. /**
  69. * Implements hook_views_api()
  70. * Purpose: Essentially this hook tells drupal that there is views support for
  71. * for this module which then includes tripal_db.views.inc where all the
  72. * views integration code is
  73. *
  74. * @ingroup tripal_db
  75. */
  76. function tripal_db_views_api() {
  77. return array('api' => 2.0);
  78. }
  79. function tripal_db_form_alter(&$form, &$form_state, $form_id) {
  80. if ($form_id == "tripal_db_form") {
  81. // updating the form through the ahah callback sets the action of
  82. // the form to the ahah callback URL. We need to set it back
  83. // to the normal form URL
  84. if ($form_state['values']['form_action'] == 'Update') {
  85. $form['#action'] = url("admin/tripal/tripal_db/edit_db");
  86. }
  87. if ($form_state['values']['form_action'] == 'Add') {
  88. $form['#action'] = url("admin/tripal/tripal_db/add_db");
  89. }
  90. }
  91. }