tripal_organism.module 8.5 KB

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