tripal_organism.module 7.7 KB

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