tripal_db.module

  1. 2.x tripal_db/tripal_db.module
  2. 3.x legacy/tripal_db/tripal_db.module
  3. 1.x tripal_db/tripal_db.module

File

tripal_db/tripal_db.module
View source
  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' => 'theme',
  27. 'page arguments' => array('tripal_db_admin'),
  28. 'access callback' => 'user_access',
  29. 'access arguments' => array('administer db cross-references'),
  30. 'type' => MENU_NORMAL_ITEM,
  31. );
  32. $items['admin/tripal/tripal_db/edit_db'] = array(
  33. 'title' => 'Edit a Database',
  34. 'description' => 'Manage Databases ',
  35. 'page callback' => 'drupal_get_form',
  36. 'page arguments' => array('tripal_db_form', 'Update'),
  37. 'access callback' => 'user_access',
  38. 'access arguments' => array('administer db cross-references'),
  39. 'type' => MENU_NORMAL_ITEM,
  40. );
  41. $items['admin/tripal/tripal_db/add_db'] = array(
  42. 'title' => 'Add a Database',
  43. 'page callback' => 'drupal_get_form',
  44. 'page arguments' => array('tripal_db_form', 'Add'),
  45. 'access callback' => 'user_access',
  46. 'access arguments' => array('administer db cross-references'),
  47. 'type' => MENU_NORMAL_ITEM,
  48. );
  49. $items['admin/tripal/tripal_db/edit/js'] = array(
  50. 'page callback' => 'tripal_ajax_db_edit',
  51. 'access callback' => 'user_access',
  52. 'access arguments' => array('access administration pages'),
  53. 'type' => MENU_CALLBACK,
  54. );
  55. return $items;
  56. }
  57. /**
  58. * Set the permission types that the chado module uses. Essentially we
  59. * want permissionis that protect creation, editing and deleting of chado
  60. * data objects
  61. *
  62. * @ingroup tripal_db
  63. */
  64. function tripal_db_perm() {
  65. return array(
  66. 'administer db cross-references',
  67. );
  68. }
  69. /**
  70. * Implements hook_views_api()
  71. * Purpose: Essentially this hook tells drupal that there is views support for
  72. * for this module which then includes tripal_db.views.inc where all the
  73. * views integration code is
  74. *
  75. * @ingroup tripal_db
  76. */
  77. function tripal_db_views_api() {
  78. return array('api' => 2.0);
  79. }
  80. function tripal_db_form_alter(&$form, &$form_state, $form_id) {
  81. if ($form_id == "tripal_db_form") {
  82. // updating the form through the ahah callback sets the action of
  83. // the form to the ahah callback URL. We need to set it back
  84. // to the normal form URL
  85. if ($form_state['values']['form_action'] == 'Update') {
  86. $form['#action'] = url("admin/tripal/tripal_db/edit_db");
  87. }
  88. if ($form_state['values']['form_action'] == 'Add') {
  89. $form['#action'] = url("admin/tripal/tripal_db/add_db");
  90. }
  91. }
  92. }
  93. /**
  94. * We need to let drupal know about our theme functions and their arguments.
  95. * We create theme functions to allow users of the module to customize the
  96. * look and feel of the output generated in this module
  97. *
  98. * @ingroup tripal_db
  99. */
  100. function tripal_db_theme() {
  101. return array(
  102. 'tripal_db_admin' => array(
  103. 'template' => 'tripal_db_admin',
  104. 'arguments' => array(NULL),
  105. 'path' => drupal_get_path('module', 'tripal_db') . '/theme',
  106. ),
  107. );
  108. }