tripal_organism.module 7.2 KB

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