tripal_contact.module 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228
  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.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_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_contact
  42. */
  43. function tripal_contact_menu() {
  44. $items = array();
  45. /*
  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. 'page arguments' => array('chado_node_sync_form', 'tripal_contact', 'chado_contact'),
  77. 'access arguments' => array('administer tripal contact'),
  78. 'type' => MENU_LOCAL_TASK,
  79. 'weight' => 0
  80. );
  81. $items['admin/tripal/chado/tripal_contact/chado_contact_toc'] = array(
  82. 'title' => ' TOC',
  83. 'description' => 'Manage the table of contents for contact nodes.',
  84. 'page callback' => 'drupal_get_form',
  85. 'page arguments' => array('tripal_core_content_type_toc_form', 'chado_contact'),
  86. 'access arguments' => array('administer tripal contact'),
  87. 'type' => MENU_LOCAL_TASK,
  88. 'file' => 'includes/tripal_core.toc.inc',
  89. 'file path' => drupal_get_path('module', 'tripal_core'),
  90. 'weight' => 3
  91. );
  92. $items['admin/tripal/chado/tripal_contact/contact/auto_name/%'] = array(
  93. 'page callback' => 'tripal_autocomplete_contact',
  94. 'page arguments' => array(6),
  95. 'access arguments' => array('administer tripal contact'),
  96. 'type' => MENU_CALLBACK,
  97. );
  98. */
  99. return $items;
  100. }
  101. /**
  102. * Implements hook_search_biological_data_views().
  103. *
  104. * Adds the described views to the "Search Data" Page created by Tripal Views
  105. */
  106. function tripal_contact_search_biological_data_views() {
  107. return array(
  108. 'tripal_contact_user_contacts' => array(
  109. 'machine_name' => 'tripal_contact_user_contacts',
  110. 'human_name' => 'Contacts',
  111. 'description' => 'Information about persons, institutes, groups, organizations, etc.',
  112. 'link' => 'chado/contact'
  113. ),
  114. );
  115. }
  116. /**
  117. * Implements hook_theme().
  118. * Register themeing functions for this module
  119. *
  120. * @return
  121. * An array of themeing functions to register
  122. *
  123. * @ingroup tripal_contact
  124. */
  125. function tripal_contact_theme($existing, $type, $theme, $path) {
  126. $core_path = drupal_get_path('module', 'tripal_core');
  127. $items = array(
  128. 'node__chado_contact' => array(
  129. 'template' => 'node--chado-generic',
  130. 'render element' => 'node',
  131. 'base hook' => 'node',
  132. 'path' => "$core_path/theme/templates",
  133. ),
  134. 'tripal_contact_base' => array(
  135. 'variables' => array('node' => NULL),
  136. 'template' => 'tripal_contact_base',
  137. 'path' => "$path/theme/templates",
  138. ),
  139. 'tripal_contact_properties' => array(
  140. 'variables' => array('node' => NULL),
  141. 'template' => 'tripal_contact_properties',
  142. 'path' => "$path/theme/templates",
  143. ),
  144. 'tripal_contact_relationships' => array(
  145. 'variables' => array('node' => NULL),
  146. 'template' => 'tripal_contact_relationships',
  147. 'path' => "$path/theme/templates",
  148. ),
  149. 'tripal_contact_publications' => array(
  150. 'variables' => array('node' => NULL),
  151. 'template' => 'tripal_contact_publications',
  152. 'path' => "$path/theme/templates",
  153. ),
  154. 'tripal_contact_help' => array(
  155. 'template' => 'tripal_contact_help',
  156. 'variables' => array(NULL),
  157. 'path' => "$path/theme/templates",
  158. ),
  159. 'tripal_contact_teaser' => array(
  160. 'variables' => array('node' => NULL),
  161. 'template' => 'tripal_contact_teaser',
  162. 'path' => "$path/theme/templates",
  163. ),
  164. );
  165. return $items;
  166. }
  167. /**
  168. * Implement hook_permission().
  169. *
  170. * @ingroup tripal_contact
  171. */
  172. function tripal_contact_permission() {
  173. return array(
  174. /*
  175. 'access chado_contact content' => array(
  176. 'title' => t('View Contacts'),
  177. 'description' => t('Allow users to view contact pages.'),
  178. ),
  179. 'create chado_contact content' => array(
  180. 'title' => t('Create Contacts'),
  181. 'description' => t('Allow users to create new contact pages.'),
  182. ),
  183. 'delete chado_contact content' => array(
  184. 'title' => t('Delete Contacts'),
  185. 'description' => t('Allow users to delete contact pages.'),
  186. ),
  187. 'edit chado_contact content' => array(
  188. 'title' => t('Edit Contacts'),
  189. 'description' => t('Allow users to edit contact pages.'),
  190. ),
  191. 'administer tripal contact' => array(
  192. 'title' => t('Administer Contacts'),
  193. 'description' => t('Allow users to administer all contacts.'),
  194. ),
  195. */
  196. );
  197. }
  198. /**
  199. * Implementation of hook_form_alter().
  200. *
  201. * @ingroup tripal_contact
  202. */
  203. function tripal_contact_form_alter(&$form, &$form_state, $form_id) {
  204. if ($form_id == "chado_contact_node_form") {
  205. // turn of preview button for insert/updates
  206. $form['actions']['preview']['#access'] = FALSE;
  207. //remove the body field
  208. unset($form['body']);
  209. }
  210. }