tripal_project.module 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243
  1. <?php
  2. /**
  3. * @file
  4. * Integrates the Chado Project tables with Drupal Nodes & Views
  5. */
  6. /**
  7. * @defgroup tripal_legacy_project Legacy Project Module
  8. * @ingroup tripal_legacy_modules
  9. * @{
  10. * Integrates the Chado Project tables with Drupal Nodes & Views
  11. * @}
  12. */
  13. require_once 'api/tripal_project.DEPRECATED.inc';
  14. require_once 'theme/tripal_project.theme.inc';
  15. require_once 'includes/tripal_project.admin.inc';
  16. require_once 'includes/tripal_project.chado_node.inc';
  17. /**
  18. * Implements hook_views_api().
  19. *
  20. * Essentially this hook tells drupal that there is views support for
  21. * for this module which then includes tripal_project.views.inc where all the
  22. * views integration code is
  23. *
  24. * @ingroup tripal_legacy_project
  25. */
  26. function tripal_project_views_api() {
  27. return array(
  28. 'api' => 3.0,
  29. );
  30. }
  31. /**
  32. * Implements hook_menu().
  33. *
  34. * @ingroup tripal_legacy_project
  35. */
  36. function tripal_project_menu() {
  37. $items = array();
  38. $items[ 'admin/tripal/legacy/tripal_project' ]= array(
  39. 'title' => 'Projects',
  40. 'description' => ('A project. Can be used for grouping data such as with the natural diversity module data.'),
  41. 'page callback' => 'tripal_project_admin_project_view',
  42. 'access arguments' => array('administer tripal project'),
  43. 'type' => MENU_NORMAL_ITEM
  44. );
  45. $items['admin/tripal/legacy/tripal_project/help']= array(
  46. 'title' => 'Help',
  47. 'description' => ("Basic Description of Tripal Project Module Functionality."),
  48. 'page callback' => 'theme',
  49. 'page arguments' => array('tripal_project_help'),
  50. 'access arguments' => array('administer tripal project'),
  51. 'type' => MENU_LOCAL_TASK,
  52. 'weight' => 6
  53. );
  54. $items['admin/tripal/legacy/tripal_project/configuration']= array(
  55. 'title' => 'Settings',
  56. 'page callback' => 'drupal_get_form',
  57. 'page arguments' => array('tripal_project_admin'),
  58. 'access arguments' => array('administer tripal project'),
  59. 'type' => MENU_LOCAL_TASK,
  60. 'weight' => 4
  61. );
  62. $items['admin/tripal/legacy/tripal_project/sync'] = array(
  63. 'title' => ' Sync',
  64. 'description' => 'Create pages on this site for projects stored in Chado',
  65. 'page callback' => 'drupal_get_form',
  66. 'page arguments' => array('chado_node_sync_form', 'tripal_project', 'chado_project'),
  67. 'access arguments' => array('administer tripal project'),
  68. 'type' => MENU_LOCAL_TASK,
  69. 'weight' => 0
  70. );
  71. $items['admin/tripal/legacy/tripal_project/chado_project_toc'] = array(
  72. 'title' => ' TOC',
  73. 'description' => 'Manage the table of contents for project nodes.',
  74. 'page callback' => 'drupal_get_form',
  75. 'page arguments' => array('tripal_core_content_type_toc_form', 'chado_project'),
  76. 'access arguments' => array('administer tripal project'),
  77. 'type' => MENU_LOCAL_TASK,
  78. 'file' => 'includes/tripal_core.toc.inc',
  79. 'file path' => drupal_get_path('module', 'tripal_core'),
  80. 'weight' => 3
  81. );
  82. $items['admin/tripal/legacy/tripal_project/views/projects/enable'] = array(
  83. 'title' => 'Enable Project Administrative View',
  84. 'page callback' => 'tripal_enable_view',
  85. 'page arguments' => array('tripal_project_admin_projects', 'admin/tripal/legacy/tripal_project'),
  86. 'access arguments' => array('administer tripal project'),
  87. 'type' => MENU_CALLBACK,
  88. );
  89. return $items;
  90. }
  91. /**
  92. * Implements hook_search_biological_data_views().
  93. *
  94. * Adds the described views to the "Search Data" Page created by Tripal Views
  95. */
  96. function tripal_project_search_biological_data_views() {
  97. return array(
  98. 'tripal_project_user_projects' => array(
  99. 'machine_name' => 'tripal_project_user_projects',
  100. 'human_name' => 'Projects',
  101. 'description' => 'A project. Can be used for grouping data such as with the natural diversity module data.',
  102. 'link' => 'chado/project'
  103. ),
  104. );
  105. }
  106. /**
  107. * Implements hook_help().
  108. * Adds a help page to the module list
  109. *
  110. * @ingroup tripal_legacy_project
  111. */
  112. function tripal_project_help ($path, $arg) {
  113. if ($path == 'admin/help#tripal_project') {
  114. return theme('tripal_project_help', array());
  115. }
  116. }
  117. /**
  118. * Implements hook_permission()
  119. *
  120. * This function sets the permission for the user to access the information in the database.
  121. * This includes creating, inserting, deleting and updating of information in the database
  122. *
  123. * @ingroup tripal_legacy_project
  124. */
  125. function tripal_project_permission() {
  126. return array(
  127. /*
  128. 'access chado_project content' => array(
  129. 'title' => t('View Projects'),
  130. 'description' => t('Allow users to view project pages.'),
  131. ),
  132. 'create chado_project content' => array(
  133. 'title' => t('Create Projects'),
  134. 'description' => t('Allow users to create new project pages.'),
  135. ),
  136. 'delete chado_project content' => array(
  137. 'title' => t('Delete Projects'),
  138. 'description' => t('Allow users to delete project pages.'),
  139. ),
  140. 'edit chado_project content' => array(
  141. 'title' => t('Edit Projects'),
  142. 'description' => t('Allow users to edit project pages.'),
  143. ),
  144. 'administer tripal project' => array(
  145. 'title' => t('Administer Projects'),
  146. 'description' => t('Allow users to administer all projects.'),
  147. ),
  148. */
  149. );
  150. }
  151. /**
  152. * Implements hook_theme().
  153. *
  154. * We need to let drupal know about our theme functions and their arguments.
  155. * We create theme functions to allow users of the module to customize the
  156. * look and feel of the output generated in this module
  157. *
  158. * @ingroup tripal_legacy_project
  159. */
  160. function tripal_project_theme($existing, $type, $theme, $path) {
  161. $core_path = drupal_get_path('module', 'tripal_core');
  162. $items = array(
  163. 'node__chado_project' => array(
  164. 'template' => 'node--chado-generic',
  165. 'render element' => 'node',
  166. 'base hook' => 'node',
  167. 'path' => "$core_path/theme/templates",
  168. ),
  169. 'tripal_project_base' => array(
  170. 'variables' => array('node' => NULL),
  171. 'template' => 'tripal_project_base',
  172. 'path' => "$path/theme/templates",
  173. ),
  174. 'tripal_project_contact' => array(
  175. 'variables' => array('node' => NULL),
  176. 'template' => 'tripal_project_contact',
  177. 'path' => "$path/theme/templates",
  178. ),
  179. 'tripal_project_properties' => array(
  180. 'variables' => array('node' => NULL),
  181. 'template' => 'tripal_project_properties',
  182. 'path' => "$path/theme/templates",
  183. ),
  184. 'tripal_project_publications' => array(
  185. 'variables' => array('node' => NULL),
  186. 'template' => 'tripal_project_publications',
  187. 'path' => "$path/theme/templates",
  188. ),
  189. 'tripal_project_relationships' => array(
  190. 'variables' => array('node' => NULL),
  191. 'template' => 'tripal_project_relationships',
  192. 'path' => "$path/theme/templates",
  193. ),
  194. 'tripal_project_teaser' => array(
  195. 'variables' => array('node' => NULL),
  196. 'template' => 'tripal_project_teaser',
  197. 'path' => "$path/theme/templates",
  198. ),
  199. 'tripal_project_help' => array(
  200. 'variables' => array(NULL),
  201. 'template' => 'tripal_project_help',
  202. 'path' => "$path/theme/templates",
  203. ),
  204. );
  205. return $items;
  206. }
  207. /**
  208. * Implementation of hook_form_alter().
  209. *
  210. * @param $form
  211. * @param $form_state
  212. * @param $form_id
  213. *
  214. * @ingroup tripal_legacy_project
  215. */
  216. function tripal_project_form_alter(&$form, &$form_state, $form_id) {
  217. if ($form_id == "chado_project_node_form") {
  218. // turn of preview button for insert/updates
  219. $form['actions']['preview']['#access'] = FALSE;
  220. //remove the body field
  221. unset($form['body']);
  222. }
  223. }