tripal_contact.module

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

Functions related to general module functionality.

File

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