tripal_organism.module

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

Integrates the Chado Organism module with Drupal Nodes & Views

File

tripal_organism/tripal_organism.module
View source
  1. <?php
  2. /**
  3. * @file
  4. * Integrates the Chado Organism module with Drupal Nodes & Views
  5. */
  6. require_once 'api/tripal_organism.api.inc';
  7. require_once 'api/tripal_organism.DEPRECATED.inc';
  8. require_once 'includes/tripal_organism.admin.inc';
  9. require_once 'includes/tripal_organism.delete.inc';
  10. require_once 'includes/tripal_organism.chado_node.inc';
  11. /**
  12. * @defgroup tripal_organism Organism Module
  13. * @ingroup tripal_modules
  14. * @{
  15. * Integrates the Chado Organism module with Drupal Nodes & Views
  16. * @}
  17. */
  18. /**
  19. * Implements hook_menu().
  20. *
  21. * Menu items are automatically added for the new node types created
  22. * by this module to the 'Create Content' Navigation menu item. This function
  23. * adds more menu items needed for this module.
  24. *
  25. * @ingroup tripal_organism
  26. */
  27. function tripal_organism_menu() {
  28. $items = array();
  29. // the administative settings menu
  30. $items['admin/tripal/chado/tripal_organism'] = array(
  31. 'title' => 'Organisms',
  32. 'description' => 'Any living biological entity, such as an animal, plant, fungus, or bacterium.',
  33. 'page callback' => 'tripal_organism_admin_organism_view',
  34. 'access arguments' => array('administer tripal organism'),
  35. 'type' => MENU_NORMAL_ITEM,
  36. );
  37. $items['admin/tripal/chado/tripal_organism/sync'] = array(
  38. 'title' => ' Sync',
  39. 'description' => 'Create pages on this site for organisms stored in Chado',
  40. 'page callback' => 'drupal_get_form',
  41. 'page arguments' => array('chado_node_sync_form', 'tripal_organism', 'chado_organism'),
  42. 'access arguments' => array('administer tripal organism'),
  43. 'type' => MENU_LOCAL_TASK,
  44. 'weight' => 1
  45. );
  46. $items['admin/tripal/chado/tripal_organism/delete'] = array(
  47. 'title' => ' Delete',
  48. 'description' => 'Delete multiple organisms from Chado',
  49. 'page callback' => 'drupal_get_form',
  50. 'page arguments' => array('tripal_organism_delete_form'),
  51. 'access arguments' => array('administer tripal feature'),
  52. 'type' => MENU_LOCAL_TASK,
  53. 'file path' => drupal_get_path('module', 'tripal_organism'),
  54. 'file' => 'includes/tripal_organism.delete.inc',
  55. 'weight' => 2
  56. );
  57. $items['admin/tripal/chado/tripal_organism/chado_organism_toc'] = array(
  58. 'title' => ' TOC',
  59. 'description' => 'Manage the table of contents for organism nodes.',
  60. 'page callback' => 'drupal_get_form',
  61. 'page arguments' => array('tripal_core_content_type_toc_form', 'chado_organism'),
  62. 'access arguments' => array('administer tripal organism'),
  63. 'type' => MENU_LOCAL_TASK,
  64. 'file' => 'includes/tripal_core.toc.inc',
  65. 'file path' => drupal_get_path('module', 'tripal_core'),
  66. 'weight' => 3
  67. );
  68. $items['admin/tripal/chado/tripal_organism/configuration'] = array(
  69. 'title' => 'Settings',
  70. 'description' => 'Manage integration of Chado organisms including associated features',
  71. 'page callback' => 'drupal_get_form',
  72. 'page arguments' => array('tripal_organism_admin'),
  73. 'access arguments' => array('administer tripal organism'),
  74. 'type' => MENU_LOCAL_TASK,
  75. 'weight' => 5
  76. );
  77. $items['admin/tripal/chado/tripal_organism/help'] = array(
  78. 'title' => 'Help',
  79. 'description' => "A description of the Tripal Organism module including a short description of it's usage.",
  80. 'page callback' => 'theme',
  81. 'page arguments' => array('tripal_organism_help'),
  82. 'access arguments' => array('administer tripal organism'),
  83. 'type' => MENU_LOCAL_TASK,
  84. 'weight' => 10
  85. );
  86. $items['admin/tripal/chado/tripal_organism/views/organisms/enable'] = array(
  87. 'title' => 'Enable Organism Administrative View',
  88. 'page callback' => 'tripal_enable_view',
  89. 'page arguments' => array('tripal_organism_admin_organisms', 'admin/tripal/chado/tripal_organism'),
  90. 'access arguments' => array('administer tripal organism'),
  91. 'type' => MENU_CALLBACK,
  92. );
  93. $items['admin/tripal/chado/tripal_organism/organism/auto_name/%'] = array(
  94. 'page callback' => 'tripal_autocomplete_organism',
  95. 'page arguments' => array(6),
  96. 'access arguments' => array('administer tripal organism'),
  97. 'type' => MENU_CALLBACK,
  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_organism_search_biological_data_views() {
  107. return array(
  108. 'tripal_organism_user_organisms' => array(
  109. 'machine_name' => 'tripal_organism_user_organisms',
  110. 'human_name' => 'Organisms',
  111. 'description' => 'Any living biological entity, such as an animal, plant, fungus, or bacterium.',
  112. 'link' => 'chado/organism'
  113. ),
  114. );
  115. }
  116. /**
  117. * Implements hook_help().
  118. * Adds a help page to the module list
  119. *
  120. * @ingroup tripal_organism
  121. */
  122. function tripal_organism_help ($path, $arg) {
  123. if ($path == 'admin/help#tripal_organism') {
  124. return theme('tripal_organism_help', array());
  125. }
  126. }
  127. /**
  128. * Implements hook_theme().
  129. *
  130. * We need to let drupal know about our theme functions and their arguments.
  131. * We create theme functions to allow users of the module to customize the
  132. * look and feel of the output generated in this module
  133. *
  134. * @ingroup tripal_organism
  135. */
  136. function tripal_organism_theme($existing, $type, $theme, $path) {
  137. $core_path = drupal_get_path('module', 'tripal_core');
  138. $items = array(
  139. 'node__chado_organism' => array(
  140. 'template' => 'node--chado-generic',
  141. 'render element' => 'node',
  142. 'base hook' => 'node',
  143. 'path' => "$core_path/theme/templates",
  144. ),
  145. 'tripal_organism_base' => array(
  146. 'variables' => array('node' => NULL),
  147. 'template' => 'tripal_organism_base',
  148. 'path' => "$path/theme/templates",
  149. ),
  150. 'tripal_organism_properties' => array(
  151. 'variables' => array('node' => NULL),
  152. 'template' => 'tripal_organism_properties',
  153. 'path' => "$path/theme/templates",
  154. ),
  155. 'tripal_organism_references' => array(
  156. 'variables' => array('node' => NULL),
  157. 'template' => 'tripal_organism_references',
  158. 'path' => "$path/theme/templates",
  159. ),
  160. 'tripal_organism_teaser' => array(
  161. 'variables' => array('node' => NULL),
  162. 'template' => 'tripal_organism_teaser',
  163. 'path' => "$path/theme/templates",
  164. ),
  165. 'tripal_organism_help' => array(
  166. 'template' => 'tripal_organism_help',
  167. 'variables' => array(NULL),
  168. 'path' => "$path/theme/templates",
  169. ),
  170. );
  171. return $items;
  172. }
  173. /**
  174. * Implements hook_permission().
  175. *
  176. * Set the permission types that the chado module uses. Essentially we
  177. * want permissionis that protect creation, editing and deleting of chado
  178. * data objects
  179. *
  180. * @ingroup tripal_organism
  181. */
  182. function tripal_organism_permission() {
  183. return array(
  184. 'access chado_organism content' => array(
  185. 'title' => t('View Organisms'),
  186. 'description' => t('Allow users to view organism pages.'),
  187. ),
  188. 'create chado_organism content' => array(
  189. 'title' => t('Create Organisms'),
  190. 'description' => t('Allow users to create new organism pages.'),
  191. ),
  192. 'delete chado_organism content' => array(
  193. 'title' => t('Delete Organisms'),
  194. 'description' => t('Allow users to delete organism pages.'),
  195. ),
  196. 'edit chado_organism content' => array(
  197. 'title' => t('Edit Organisms'),
  198. 'description' => t('Allow users to edit organism pages.'),
  199. ),
  200. 'administer tripal organism' => array(
  201. 'title' => t('Administer Organisms'),
  202. 'description' => t('Allow users to administer all organisms.'),
  203. ),
  204. );
  205. }
  206. /**
  207. * Implements hook_views_api().
  208. *
  209. * Essentially this hook tells drupal that there is views support for
  210. * for this module which then includes tripal_db.views.inc where all the
  211. * views integration code is
  212. *
  213. * @ingroup tripal_organism
  214. */
  215. function tripal_organism_views_api() {
  216. return array(
  217. 'api' => 3.0,
  218. );
  219. }
  220. /**
  221. * Implements hook_job_describe_args().
  222. *
  223. * @ingroup tripal_organism
  224. */
  225. function tripal_organism_job_describe_args($callback, $args) {
  226. $new_args = array();
  227. if ($callback == 'tripal_organism_sync_organisms') {
  228. $organism = chado_select_record('organism', array('genus', 'species'), array('organism_id' => $args[0]));
  229. $new_args['Organism'] = $organism[0]->genus . " " . $organism[0]->species;
  230. }
  231. return $new_args;
  232. }
  233. /**
  234. * Implementation of hook_form_alter().
  235. *
  236. * @param $form
  237. * @param $form_state
  238. * @param $form_id
  239. *
  240. * @ingroup tripal_organism
  241. */
  242. function tripal_organism_form_alter(&$form, &$form_state, $form_id) {
  243. // turn of preview button for insert/updates
  244. if ($form_id == "chado_organism_node_form") {
  245. $form['actions']['preview']['#access'] = FALSE;
  246. //remove the body field
  247. unset($form['body']);
  248. }
  249. }