tripal_project.module 7.3 KB

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