tripal_analysis.module 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283
  1. <?php
  2. /**
  3. * @file
  4. * Contains basic functionality for the analysis module.
  5. *
  6. * @ingroup tripal_legacy_analysis
  7. */
  8. /**
  9. * @defgroup tripal_analysis Legacy Analysis Module
  10. * @ingroup tripal_modules
  11. * @{
  12. * Integrates the Chado Analysis module with Drupal Nodes & Views
  13. * @}
  14. */
  15. require_once 'api/tripal_analysis.DEPRECATED.inc';
  16. require_once 'includes/tripal_analysis.delete.inc';
  17. require_once 'includes/tripal_analysis_privacy.inc';
  18. require_once 'includes/tripal_analysis.admin.inc';
  19. require_once 'includes/tripal_analysis.chado_node.inc';
  20. /**
  21. * Implements hook_init().
  22. * Add tripal javascript to page headers
  23. *
  24. * @ingroup tripal_legacy_analysis
  25. */
  26. function tripal_analysis_init() {
  27. }
  28. /**
  29. * Implementation of hook_menu().
  30. * Entry points and paths of the module
  31. *
  32. * @ingroup tripal_legacy_analysis
  33. */
  34. function tripal_analysis_menu() {
  35. $items = array();
  36. // Tripal Analysis administrative settings
  37. $items['admin/tripal/legacy/tripal_analysis'] = array(
  38. 'title' => 'Analyses',
  39. 'description' => 'A bioinformatics analysis producing features.',
  40. 'page callback' => 'tripal_analysis_admin_analysis_view',
  41. 'access arguments' => array('administer tripal analysis'),
  42. 'type' => MENU_NORMAL_ITEM,
  43. );
  44. $items['admin/tripal/legacy/tripal_analysis/help'] = array(
  45. 'title' => 'Help',
  46. 'description' => "A description of the Tripal Analysis module including a short description of it's usage.",
  47. 'page callback' => 'theme',
  48. 'page arguments' => array('tripal_analysis_help'),
  49. 'access arguments' => array('administer tripal analysis'),
  50. 'type' => MENU_LOCAL_TASK,
  51. 'weight' => 10,
  52. );
  53. $items['admin/tripal/legacy/tripal_analysis/configuration'] = array(
  54. 'title' => 'Settings',
  55. 'description' => 'Settings for the displays of analysis results.',
  56. 'page callback' => 'drupal_get_form',
  57. 'page arguments' => array('tripal_analysis_admin'),
  58. 'access arguments' => array('administer tripal analysis'),
  59. 'type' => MENU_LOCAL_TASK,
  60. 'weight' => 5
  61. );
  62. $items['admin/tripal/legacy/tripal_analysis/sync'] = array(
  63. 'title' => ' Sync',
  64. 'description' => 'Create pages on this site for analyses stored in Chado',
  65. 'page callback' => 'drupal_get_form',
  66. 'page arguments' => array('chado_node_sync_form', 'tripal_analysis', 'chado_analysis'),
  67. 'access arguments' => array('administer tripal analysis'),
  68. 'type' => MENU_LOCAL_TASK,
  69. 'weight' => 1
  70. );
  71. $items['admin/tripal/legacy/tripal_analysis/delete'] = array(
  72. 'title' => ' Delete',
  73. 'description' => 'Delete multiple analyses from Chado',
  74. 'page callback' => 'drupal_get_form',
  75. 'page arguments' => array('tripal_analysis_delete_form'),
  76. 'access arguments' => array('administer tripal feature'),
  77. 'type' => MENU_LOCAL_TASK,
  78. 'file path' => drupal_get_path('module', 'tripal_analysis'),
  79. 'file' => 'includes/tripal_analysis.delete.inc',
  80. 'weight' => 2
  81. );
  82. $items['admin/tripal/legacy/tripal_analysis/chado_analysis_toc'] = array(
  83. 'title' => ' TOC',
  84. 'description' => 'Manage the table of contents for analysis nodes.',
  85. 'page callback' => 'drupal_get_form',
  86. 'page arguments' => array('tripal_core_content_type_toc_form', 'chado_analysis'),
  87. 'access arguments' => array('administer tripal analysis'),
  88. 'type' => MENU_LOCAL_TASK,
  89. 'file' => 'includes/tripal_core.toc.inc',
  90. 'file path' => drupal_get_path('module', 'tripal_core'),
  91. 'weight' => 3
  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_analysis_search_biological_data_views() {
  101. return array(
  102. 'tripal_analysis_user_analyses' => array(
  103. 'machine_name' => 'tripal_analysis_user_analyses',
  104. 'human_name' => 'Analyses',
  105. 'description' => 'Bioinformatics analyses which often produces features.',
  106. 'link' => 'chado/analysis'
  107. ),
  108. );
  109. }
  110. /**
  111. * Implements hook_help().
  112. * Purpose: Adds a help page to the module list
  113. *
  114. * @ingroup tripal_legacy_analysis
  115. */
  116. function tripal_analysis_help ($path, $arg) {
  117. if ($path == 'admin/help#tripal_analysis') {
  118. return theme('tripal_analysis_help', array());
  119. }
  120. }
  121. /**
  122. * Implements hook_permission().
  123. *
  124. * Set the permission types that the chado module uses. Essentially we
  125. * want permissionis that protect creation, editing and deleting of chado
  126. * data objects
  127. *
  128. * @ingroup tripal_legacy_analysis
  129. */
  130. function tripal_analysis_permission() {
  131. return array(
  132. /*
  133. 'access chado_analysis content' => array(
  134. 'title' => t('View Analyses'),
  135. 'description' => t('Allow users to view analysis pages.'),
  136. ),
  137. 'create chado_analysis content' => array(
  138. 'title' => t('Create Analyses'),
  139. 'description' => t('Allow users to create new analysis pages.'),
  140. ),
  141. 'delete chado_analysis content' => array(
  142. 'title' => t('Delete Analyses'),
  143. 'description' => t('Allow users to delete analysis pages.'),
  144. ),
  145. 'edit chado_analysis content' => array(
  146. 'title' => t('Edit Analyses'),
  147. 'description' => t('Allow users to edit analysis pages.'),
  148. ),
  149. 'administer tripal analysis' => array(
  150. 'title' => t('Administer Analyses'),
  151. 'description' => t('Allow users to administer all analyses.'),
  152. ),
  153. */
  154. );
  155. }
  156. /**
  157. * We need to let drupal know about our theme functions and their arguments.
  158. * We create theme functions to allow users of the module to customize the
  159. * look and feel of the output generated in this module
  160. *
  161. * @ingroup tripal_legacy_analysis
  162. */
  163. function tripal_analysis_theme($existing, $type, $theme, $path) {
  164. $core_path = drupal_get_path('module', 'tripal_core');
  165. $items = array(
  166. 'node__chado_analysis' => array(
  167. 'template' => 'node--chado-generic',
  168. 'render element' => 'node',
  169. 'base hook' => 'node',
  170. 'path' => "$core_path/theme/templates",
  171. ),
  172. 'tripal_analysis_base' => array(
  173. 'variables' => array('node' => NULL),
  174. 'template' => 'tripal_analysis_base',
  175. 'path' => "$path/theme/templates",
  176. ),
  177. 'tripal_analysis_properties' => array(
  178. 'variables' => array('node' => NULL),
  179. 'template' => 'tripal_analysis_properties',
  180. 'path' => "$path/theme/templates",
  181. ),
  182. 'tripal_analysis_teaser' => array(
  183. 'variables' => array('node' => NULL),
  184. 'template' => 'tripal_analysis_teaser',
  185. 'path' => "$path/theme/templates",
  186. ),
  187. 'tripal_analysis_help' => array(
  188. 'template' => 'tripal_analysis_help',
  189. 'variables' => array(NULL),
  190. 'path' => "$path/theme/templates",
  191. ),
  192. // tripal_feature theme
  193. 'tripal_feature_analyses' => array(
  194. 'template' => 'tripal_feature_analyses',
  195. 'variables' => array('node' => NULL),
  196. 'path' => "$path/theme/templates",
  197. ),
  198. );
  199. return $items;
  200. }
  201. /**
  202. * Implements hook_views_api().
  203. * Essentially this hook tells drupal that there is views support for
  204. * for this module which then includes tripal_analysis.views.inc where all the
  205. * views integration code is
  206. *
  207. * @ingroup tripal_legacy_analysis
  208. */
  209. function tripal_analysis_views_api() {
  210. return array(
  211. 'api' => 3.0,
  212. );
  213. }
  214. /**
  215. * Implementation of hook_form_alter().
  216. *
  217. * @ingroup tripal_legacy_analysis
  218. */
  219. function tripal_analysis_form_alter(&$form, &$form_state, $form_id) {
  220. // turn of preview button for insert/updates
  221. if ($form_id == "chado_analysis_node_form") {
  222. $form['actions']['preview']['#access'] = FALSE;
  223. //remove the body field
  224. unset($form['body']);
  225. }
  226. }
  227. /**
  228. * Register tripal_analysis_api sub-modules
  229. *
  230. * @param $modulename
  231. * The name of the module to be registered as a tripal analysis submodule
  232. *
  233. * @ingroup tripal_legacy_analysis_api
  234. */
  235. function tripal_register_analysis_child($modulename) {
  236. $sql = "SELECT * FROM {tripal_analysis} WHERE modulename = :modname";
  237. if (!db_query($sql, array(':modname' => $modulename))->fetchField()) {
  238. $sql = "INSERT INTO {tripal_analysis} (modulename) VALUES (:modname)";
  239. db_query($sql, array(':modname' => $modulename));
  240. }
  241. }
  242. /**
  243. * Un-register a tripal analysis sub-module
  244. *
  245. * @param $modulename
  246. * The name of the module to un-register
  247. *
  248. * @ingroup tripal_legacy_analysis_api
  249. */
  250. function tripal_unregister_analysis_child($modulename) {
  251. if (db_table_exists('tripal_analysis')) {
  252. $sql = "DELETE FROM {tripal_analysis} WHERE modulename = :modname";
  253. db_query($sql, array(':modname' => $modulename));
  254. }
  255. }