tripal_project.module 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264
  1. <?php
  2. require('api/tripal_project.api.inc');
  3. require('theme/tripal_project.theme.inc');
  4. require('includes/tripal_project.admin.inc');
  5. require('includes/tripal_project.chado_node.inc');
  6. /**
  7. * @file
  8. * This file contains the basic functions needed for this drupal module.
  9. * The drupal tripal_project module maps directly to the chado general module.
  10. *
  11. * For documentation regarding the Chado General module:
  12. * @see http://gmod.org/wiki/Chado_General_Module
  13. *
  14. * @defgroup tripal_project Project Module
  15. * @ingroup tripal_modules
  16. */
  17. /**
  18. * Implements hook_views_api()
  19. *
  20. * Purpose: 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. */
  27. function tripal_project_views_api() {
  28. return array(
  29. 'api' => 2.0,
  30. );
  31. }
  32. /**
  33. * Implements hook_menu
  34. *
  35. * @ingroup tripal_project
  36. */
  37. function tripal_project_menu() {
  38. $items[ 'admin/tripal/chado/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('adminster tripal projects'),
  43. 'type' => MENU_NORMAL_ITEM
  44. );
  45. $items['admin/tripal/chado/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('adminster tripal projects'),
  51. 'type' => MENU_LOCAL_TASK,
  52. 'weight' => 6
  53. );
  54. $items['admin/tripal/chado/tripal_project/configuration']= array(
  55. 'title' => 'Settings',
  56. 'page callback' => 'drupal_get_form',
  57. 'page arguments' => array('tripal_project_admin'),
  58. 'access arguments' => array('adminster tripal projects'),
  59. 'type' => MENU_LOCAL_TASK,
  60. 'weight' => 4
  61. );
  62. $items['admin/tripal/chado/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('tripal_core_chado_node_sync_form', 'tripal_project', 'chado_project'),
  67. 'access arguments' => array('administer tripal projects'),
  68. 'type' => MENU_LOCAL_TASK,
  69. 'weight' => 0
  70. );
  71. $items['admin/tripal/chado/tripal_project/views/projects/enable'] = array(
  72. 'title' => 'Enable Project Administrative View',
  73. 'page callback' => 'tripal_views_admin_enable_view',
  74. 'page arguments' => array('tripal_project_admin_projects', 'admin/tripal/chado/tripal_project'),
  75. 'access arguments' => array('administer tripal projects'),
  76. 'type' => MENU_CALLBACK,
  77. );
  78. return $items;
  79. }
  80. /**
  81. * Implements hook_help()
  82. * Purpose: Adds a help page to the module list
  83. */
  84. function tripal_project_help ($path, $arg) {
  85. if ($path == 'admin/help#tripal_project') {
  86. return theme('tripal_project_help', array());
  87. }
  88. }
  89. /**
  90. * Implements hook_perm()
  91. *
  92. * This function sets the permission for the user to access the information in the database.
  93. * This includes creating, inserting, deleting and updating of information in the database
  94. *
  95. *
  96. * @ingroup tripal_project
  97. */
  98. function tripal_project_permission() {
  99. return array(
  100. 'access chado_project content' => array(
  101. 'title' => t('View Projects'),
  102. 'description' => t('Allow users to view project pages.'),
  103. ),
  104. 'create chado_project content' => array(
  105. 'title' => t('Create Projects'),
  106. 'description' => t('Allow users to create new project pages.'),
  107. ),
  108. 'delete chado_project content' => array(
  109. 'title' => t('Delete Projects'),
  110. 'description' => t('Allow users to delete project pages.'),
  111. ),
  112. 'edit chado_project content' => array(
  113. 'title' => t('Edit Projects'),
  114. 'description' => t('Allow users to edit project pages.'),
  115. ),
  116. 'adminster tripal project' => array(
  117. 'title' => t('Administer Projects'),
  118. 'description' => t('Allow users to administer all projects.'),
  119. ),
  120. );
  121. }
  122. /**
  123. * We need to let drupal know about our theme functions and their arguments.
  124. * We create theme functions to allow users of the module to customize the
  125. * look and feel of the output generated in this module
  126. *
  127. * @ingroup tripal_project
  128. */
  129. function tripal_project_theme($existing, $type, $theme, $path) {
  130. $core_path = drupal_get_path('module', 'tripal_core');
  131. $items = array(
  132. 'node__chado_project' => array(
  133. 'template' => 'node--chado-generic',
  134. 'render element' => 'node',
  135. 'base hook' => 'node',
  136. 'path' => "$core_path/theme",
  137. ),
  138. 'tripal_project_base' => array(
  139. 'variables' => array('node' => NULL),
  140. 'template' => 'tripal_project.base',
  141. 'path' => "$path/theme/tripal_project",
  142. ),
  143. 'tripal_project_contact' => array(
  144. 'variables' => array('node' => NULL),
  145. 'template' => 'tripal_project.contact',
  146. 'path' => "$path/theme/tripal_project",
  147. ),
  148. 'tripal_project_properties' => array(
  149. 'variables' => array('node' => NULL),
  150. 'template' => 'tripal_project.properties',
  151. 'path' => "$path/theme/tripal_project",
  152. ),
  153. 'tripal_project_publications' => array(
  154. 'variables' => array('node' => NULL),
  155. 'template' => 'tripal_project.publications',
  156. 'path' => "$path/theme/tripal_project",
  157. ),
  158. 'tripal_project_relationships' => array(
  159. 'variables' => array('node' => NULL),
  160. 'template' => 'tripal_project.relationships',
  161. 'path' => "$path/theme/tripal_project",
  162. ),
  163. 'tripal_project_teaser' => array(
  164. 'variables' => array('node' => NULL),
  165. 'template' => 'tripal_project.teaser',
  166. 'path' => "$path/theme/tripal_project",
  167. ),
  168. 'tripal_project_help' => array(
  169. 'variables' => 'tripal_project.help',
  170. 'variables' => array(NULL),
  171. 'path' => "$path/theme",
  172. ),
  173. );
  174. return $items;
  175. }
  176. /**
  177. *
  178. * @ingroup tripal_project
  179. */
  180. function tripal_project_block_info() {
  181. $blocks['projectbase']['info'] = t('Tripal Project Details');
  182. $blocks['projectbase']['cache'] = DRUPAL_NO_CACHE;
  183. $blocks['projectprops']['info'] = t('Tripal Project Properties');
  184. $blocks['projectprops']['cache'] = DRUPAL_NO_CACHE;
  185. $blocks['projectpubs']['info'] = t('Tripal Project Publications');
  186. $blocks['projectpubs']['cache'] = DRUPAL_NO_CACHE;
  187. $blocks['projectcont']['info'] = t('Tripal Project Contact');
  188. $blocks['projectcont']['cache'] = DRUPAL_NO_CACHE;
  189. $blocks['projectrels']['info'] = t('Tripal Project Relationships');
  190. $blocks['projectrels']['cache'] = DRUPAL_NO_CACHE;
  191. return $blocks;
  192. }
  193. /**
  194. *
  195. * @ingroup tripal_project
  196. */
  197. function tripal_project_block_view($delta = '') {
  198. if (user_access('access chado_project content') and arg(0) == 'node' and is_numeric(arg(1))) {
  199. $nid = arg(1);
  200. $node = node_load($nid);
  201. $block = array();
  202. switch ($delta) {
  203. case 'projectbase':
  204. $block['subject'] = t('Project Details');
  205. $block['content'] = theme('tripal_project_base', $node);
  206. break;
  207. case 'projectprops':
  208. $block['subject'] = t('Properties');
  209. $block['content'] = theme('tripal_project_properties', $node);
  210. break;
  211. case 'projectpubs':
  212. $block['subject'] = t('Publications');
  213. $block['content'] = theme('tripal_project_publications', $node);
  214. break;
  215. case 'projectcont':
  216. $block['subject'] = t('Contact');
  217. $block['content'] = theme('tripal_project_contact', $node);
  218. break;
  219. case 'projectrels':
  220. $block['subject'] = t('Relationships');
  221. $block['content'] = theme('tripal_project_relationships', $node);
  222. break;
  223. default :
  224. }
  225. return $block;
  226. }
  227. }
  228. /**
  229. * Implementation of hook_form_alter()
  230. *
  231. * @param $form
  232. * @param $form_state
  233. * @param $form_id
  234. */
  235. function tripal_project_form_alter(&$form, &$form_state, $form_id) {
  236. // turn of preview button for insert/updates
  237. if ($form_id == "chado_project_node_form") {
  238. $form['actions']['preview']['#access'] = FALSE;
  239. }
  240. }