tripal_contact.module 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218
  1. <?php
  2. /**
  3. * @file
  4. * Functions related to general module functionality.
  5. *
  6. * @ingroup tripal_contact
  7. */
  8. /**
  9. * @defgroup tripal_contact Contact Module
  10. * @ingroup tripal_modules
  11. * @{
  12. * Integrates the Chado Contact module with Drupal Nodes & Views
  13. * @}
  14. */
  15. require_once 'api/tripal_contact.api.inc';
  16. require_once 'api/tripal_contact.DEPRECATED.inc';
  17. require_once 'theme/tripal_contact.theme.inc';
  18. require_once 'includes/tripal_contact.admin.inc';
  19. require_once 'includes/tripal_contact.chado_node.inc';
  20. /**
  21. * Implements hook_views_api().
  22. * Essentially this hook tells drupal that there is views support for
  23. * for this module which then includes tripal_contact.views.inc where all the
  24. * views integration code is.
  25. *
  26. * @ingroup tripal_contact
  27. */
  28. function tripal_contact_views_api() {
  29. return array(
  30. 'api' => 3.0,
  31. );
  32. }
  33. /**
  34. * Implemets hook_menu().
  35. * Adds menu items for the tripal_contact module menu. This section
  36. * gives the outline for the main menu of the Tripal-contact module
  37. *
  38. * @return
  39. * An array of menu items that is visible within the Drupal Menu, returned as soon
  40. * as the program is ran
  41. *
  42. * @ingroup tripal_contact
  43. */
  44. function tripal_contact_menu() {
  45. $items = array();
  46. $items['admin/tripal/chado/tripal_contact']= array(
  47. 'title' => 'Contacts',
  48. 'description' => ('Model persons, institutes, groups, organizations, etc.'),
  49. 'page callback' => 'tripal_contact_admin_contact_view',
  50. 'access arguments' => array('administer tripal contact'),
  51. 'type' => MENU_NORMAL_ITEM
  52. );
  53. $items['admin/tripal/chado/tripal_contact/configuration'] = array(
  54. 'title' => 'Settings',
  55. 'description' => 'Integration of Chado contacts.',
  56. 'page callback' => 'drupal_get_form',
  57. 'page arguments' => array('tripal_contact_admin'),
  58. 'access arguments' => array('administer tripal contact'),
  59. 'type' => MENU_LOCAL_TASK,
  60. 'weight' => 5
  61. );
  62. $items['admin/tripal/chado/tripal_contact/help']= array(
  63. 'title' => 'Help',
  64. 'description' => ('Help with the contact module.'),
  65. 'page callback' => 'theme',
  66. 'page arguments' => array('tripal_contact_help'),
  67. 'access arguments' => array('administer tripal contact'),
  68. 'type' => MENU_LOCAL_TASK,
  69. 'weight' => 10
  70. );
  71. $items['admin/tripal/chado/tripal_contact/sync'] = array(
  72. 'title' => ' Sync',
  73. 'description' => 'Sync contacts in Chado with Drupal',
  74. 'page callback' => 'drupal_get_form',
  75. 'page arguments' => array('tripal_contact_sync_form'),
  76. 'access arguments' => array('administer tripal contact'),
  77. 'type' => MENU_LOCAL_TASK,
  78. 'weight' => 0
  79. );
  80. $items['admin/tripal/chado/tripal_contact/toc'] = array(
  81. 'title' => ' TOC',
  82. 'description' => 'Manage the table of contents for contact nodes.',
  83. 'page callback' => 'drupal_get_form',
  84. 'page arguments' => array('tripal_core_content_type_toc_form', 'chado_contact'),
  85. 'access arguments' => array('administer tripal contact'),
  86. 'type' => MENU_LOCAL_TASK,
  87. 'file' => 'includes/tripal_core.toc.inc',
  88. 'file path' => drupal_get_path('module', 'tripal_core'),
  89. 'weight' => 3
  90. );
  91. return $items;
  92. }
  93. /**
  94. * Implements hook_search_biological_data_views().
  95. *
  96. * Adds the described views to the "Search Data" Page created by Tripal Views
  97. */
  98. function tripal_contact_search_biological_data_views() {
  99. return array(
  100. 'tripal_contact_user_contacts' => array(
  101. 'machine_name' => 'tripal_contact_user_contacts',
  102. 'human_name' => 'Contacts',
  103. 'description' => 'Information about persons, institutes, groups, organizations, etc.',
  104. 'link' => 'chado/contact'
  105. ),
  106. );
  107. }
  108. /**
  109. * Implements hook_theme().
  110. * Register themeing functions for this module
  111. *
  112. * @return
  113. * An array of themeing functions to register
  114. *
  115. * @ingroup tripal_contact
  116. */
  117. function tripal_contact_theme($existing, $type, $theme, $path) {
  118. $core_path = drupal_get_path('module', 'tripal_core');
  119. $items = array(
  120. 'node__chado_contact' => array(
  121. 'template' => 'node--chado-generic',
  122. 'render element' => 'node',
  123. 'base hook' => 'node',
  124. 'path' => "$core_path/theme/templates",
  125. ),
  126. 'tripal_contact_base' => array(
  127. 'variables' => array('node' => NULL),
  128. 'template' => 'tripal_contact_base',
  129. 'path' => "$path/theme/templates",
  130. ),
  131. 'tripal_contact_properties' => array(
  132. 'variables' => array('node' => NULL),
  133. 'template' => 'tripal_contact_properties',
  134. 'path' => "$path/theme/templates",
  135. ),
  136. 'tripal_contact_relationships' => array(
  137. 'variables' => array('node' => NULL),
  138. 'template' => 'tripal_contact_relationships',
  139. 'path' => "$path/theme/templates",
  140. ),
  141. 'tripal_contact_publications' => array(
  142. 'variables' => array('node' => NULL),
  143. 'template' => 'tripal_contact_publications',
  144. 'path' => "$path/theme/templates",
  145. ),
  146. 'tripal_contact_help' => array(
  147. 'template' => 'tripal_contact_help',
  148. 'variables' => array(NULL),
  149. 'path' => "$path/theme/templates",
  150. ),
  151. 'tripal_contact_teaser' => array(
  152. 'variables' => array('node' => NULL),
  153. 'template' => 'tripal_contact_teaser',
  154. 'path' => "$path/theme/templates",
  155. ),
  156. );
  157. return $items;
  158. }
  159. /**
  160. * Implement hook_permission().
  161. *
  162. * @ingroup tripal_contact
  163. */
  164. function tripal_contact_permission() {
  165. return array(
  166. 'access chado_contact content' => array(
  167. 'title' => t('View Contacts'),
  168. 'description' => t('Allow users to view contact pages.'),
  169. ),
  170. 'create chado_contact content' => array(
  171. 'title' => t('Create Contacts'),
  172. 'description' => t('Allow users to create new contact pages.'),
  173. ),
  174. 'delete chado_contact content' => array(
  175. 'title' => t('Delete Contacts'),
  176. 'description' => t('Allow users to delete contact pages.'),
  177. ),
  178. 'edit chado_contact content' => array(
  179. 'title' => t('Edit Contacts'),
  180. 'description' => t('Allow users to edit contact pages.'),
  181. ),
  182. 'administer tripal contact' => array(
  183. 'title' => t('Administer Contacts'),
  184. 'description' => t('Allow users to administer all contacts.'),
  185. ),
  186. );
  187. }
  188. /**
  189. * Implementation of hook_form_alter().
  190. *
  191. * @ingroup tripal_contact
  192. */
  193. function tripal_contact_form_alter(&$form, &$form_state, $form_id) {
  194. if ($form_id == "chado_contact_node_form") {
  195. // turn of preview button for insert/updates
  196. $form['actions']['preview']['#access'] = FALSE;
  197. //remove the body field
  198. unset($form['body']);
  199. }
  200. }