tripal_project.module 7.2 KB

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