tripal_organism.module 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262
  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. return $items;
  94. }
  95. /**
  96. * Implements hook_search_biological_data_views().
  97. *
  98. * Adds the described views to the "Search Data" Page created by Tripal Views
  99. */
  100. function tripal_organism_search_biological_data_views() {
  101. return array(
  102. 'tripal_organism_user_organisms' => array(
  103. 'machine_name' => 'tripal_organism_user_organisms',
  104. 'human_name' => 'Organisms',
  105. 'description' => 'Any living biological entity, such as an animal, plant, fungus, or bacterium.',
  106. 'link' => 'chado/organism'
  107. ),
  108. );
  109. }
  110. /**
  111. * Implements hook_help().
  112. * Adds a help page to the module list
  113. *
  114. * @ingroup tripal_organism
  115. */
  116. function tripal_organism_help ($path, $arg) {
  117. if ($path == 'admin/help#tripal_organism') {
  118. return theme('tripal_organism_help', array());
  119. }
  120. }
  121. /**
  122. * Implements hook_theme().
  123. *
  124. * We need to let drupal know about our theme functions and their arguments.
  125. * We create theme functions to allow users of the module to customize the
  126. * look and feel of the output generated in this module
  127. *
  128. * @ingroup tripal_organism
  129. */
  130. function tripal_organism_theme($existing, $type, $theme, $path) {
  131. $core_path = drupal_get_path('module', 'tripal_core');
  132. $items = array(
  133. 'node__chado_organism' => array(
  134. 'template' => 'node--chado-generic',
  135. 'render element' => 'node',
  136. 'base hook' => 'node',
  137. 'path' => "$core_path/theme/templates",
  138. ),
  139. 'tripal_organism_base' => array(
  140. 'variables' => array('node' => NULL),
  141. 'template' => 'tripal_organism_base',
  142. 'path' => "$path/theme/templates",
  143. ),
  144. 'tripal_organism_properties' => array(
  145. 'variables' => array('node' => NULL),
  146. 'template' => 'tripal_organism_properties',
  147. 'path' => "$path/theme/templates",
  148. ),
  149. 'tripal_organism_references' => array(
  150. 'variables' => array('node' => NULL),
  151. 'template' => 'tripal_organism_references',
  152. 'path' => "$path/theme/templates",
  153. ),
  154. 'tripal_organism_teaser' => array(
  155. 'variables' => array('node' => NULL),
  156. 'template' => 'tripal_organism_teaser',
  157. 'path' => "$path/theme/templates",
  158. ),
  159. 'tripal_organism_help' => array(
  160. 'template' => 'tripal_organism_help',
  161. 'variables' => array(NULL),
  162. 'path' => "$path/theme/templates",
  163. ),
  164. );
  165. return $items;
  166. }
  167. /**
  168. * Implements hook_permission().
  169. *
  170. * Set the permission types that the chado module uses. Essentially we
  171. * want permissionis that protect creation, editing and deleting of chado
  172. * data objects
  173. *
  174. * @ingroup tripal_organism
  175. */
  176. function tripal_organism_permission() {
  177. return array(
  178. 'access chado_organism content' => array(
  179. 'title' => t('View Organisms'),
  180. 'description' => t('Allow users to view organism pages.'),
  181. ),
  182. 'create chado_organism content' => array(
  183. 'title' => t('Create Organisms'),
  184. 'description' => t('Allow users to create new organism pages.'),
  185. ),
  186. 'delete chado_organism content' => array(
  187. 'title' => t('Delete Organisms'),
  188. 'description' => t('Allow users to delete organism pages.'),
  189. ),
  190. 'edit chado_organism content' => array(
  191. 'title' => t('Edit Organisms'),
  192. 'description' => t('Allow users to edit organism pages.'),
  193. ),
  194. 'administer tripal organism' => array(
  195. 'title' => t('Administer Organisms'),
  196. 'description' => t('Allow users to administer all organisms.'),
  197. ),
  198. );
  199. }
  200. /**
  201. * Implements hook_views_api().
  202. *
  203. * Essentially this hook tells drupal that there is views support for
  204. * for this module which then includes tripal_db.views.inc where all the
  205. * views integration code is
  206. *
  207. * @ingroup tripal_organism
  208. */
  209. function tripal_organism_views_api() {
  210. return array(
  211. 'api' => 3.0,
  212. );
  213. }
  214. /**
  215. * Implements hook_job_describe_args().
  216. *
  217. * @ingroup tripal_organism
  218. */
  219. function tripal_organism_job_describe_args($callback, $args) {
  220. $new_args = array();
  221. if ($callback == 'tripal_organism_sync_organisms') {
  222. $organism = chado_select_record('organism', array('genus', 'species'), array('organism_id' => $args[0]));
  223. $new_args['Organism'] = $organism[0]->genus . " " . $organism[0]->species;
  224. }
  225. return $new_args;
  226. }
  227. /**
  228. * Implementation of hook_form_alter().
  229. *
  230. * @param $form
  231. * @param $form_state
  232. * @param $form_id
  233. *
  234. * @ingroup tripal_organism
  235. */
  236. function tripal_organism_form_alter(&$form, &$form_state, $form_id) {
  237. // turn of preview button for insert/updates
  238. if ($form_id == "chado_organism_node_form") {
  239. $form['actions']['preview']['#access'] = FALSE;
  240. //remove the body field
  241. unset($form['body']);
  242. }
  243. }