workflow_views.views.inc 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259
  1. <?php
  2. /**
  3. * @file
  4. * Provide views data and handler information for workflow.module.
  5. */
  6. /**
  7. * @defgroup views_workflow_module workflow.module handlers
  8. *
  9. * Includes the 'workflow_node' and 'workflow_state' tables, but generates a
  10. * pseudo-table for each separate workflow that's been set up.
  11. * @{
  12. */
  13. /**
  14. * Implements hook_views_data().
  15. */
  16. function workflow_views_views_data() {
  17. // Workflow states.
  18. $data['workflow_states']['table']['group'] = t('Workflow');
  19. $data['workflow_states']['table']['join'] = array(
  20. 'node' => array(
  21. 'field' => 'sid',
  22. 'left_table' => 'workflow_node',
  23. 'left_field' => 'sid',
  24. ),
  25. );
  26. $data['workflow_states']['weight'] = array(
  27. 'title' => t('State weight'),
  28. 'help' => t('The weight of the current workflow state that the node is in.'),
  29. 'sort' => array(
  30. 'handler' => 'views_handler_sort',
  31. ),
  32. );
  33. $data['workflow_states']['state'] = array(
  34. 'title' => t('Current state name'),
  35. 'help' => t('The readable name of the workflow state that the node is in. (Less efficient, use only when click-sorting by state name.)'),
  36. 'field' => array(
  37. 'handler' => 'views_handler_field',
  38. 'click sortable' => TRUE,
  39. ),
  40. );
  41. // Workflow node.
  42. $data['workflow_node']['table']['group'] = t('Workflow');
  43. $data['workflow_node']['table']['join'] = array(
  44. 'node' => array(
  45. 'field' => 'nid',
  46. 'left_table' => 'node',
  47. 'left_field' => 'nid',
  48. ),
  49. );
  50. $data['workflow_node']['sid'] = array(
  51. 'title' => t('Current state'),
  52. 'help' => t('The current workflow state that the node is in.'),
  53. 'field' => array(
  54. 'handler' => 'workflow_views_handler_field_sid',
  55. 'click sortable' => TRUE,
  56. ),
  57. 'argument' => array(
  58. 'handler' => 'views_handler_argument_numeric',
  59. 'click sortable' => TRUE,
  60. 'numeric' => TRUE,
  61. 'name table' => 'workflow_states',
  62. 'name field' => 'state',
  63. ),
  64. 'filter' => array(
  65. 'handler' => 'workflow_views_handler_filter_sid',
  66. 'numeric' => TRUE,
  67. ),
  68. );
  69. $data['workflow_node']['stamp'] = array(
  70. 'title' => t('Current time'),
  71. 'help' => t('The time at which the node moved to the current state.'),
  72. 'field' => array(
  73. 'handler' => 'views_handler_field_date',
  74. 'click sortable' => TRUE,
  75. ),
  76. 'filter' => array(
  77. 'handler' => 'views_handler_filter_date',
  78. 'numeric' => TRUE,
  79. ),
  80. 'sort' => array(
  81. 'handler' => 'views_handler_sort_date',
  82. ),
  83. );
  84. $data['workflow_node']['uid'] = array(
  85. 'title' => t('Last changed user'),
  86. 'help' => t('The user who performed the last state change.'),
  87. 'relationship' => array(
  88. 'base' => 'users',
  89. 'base field' => 'uid',
  90. 'handler' => 'views_handler_relationship',
  91. 'label' => t('User'),
  92. ),
  93. 'argument' => array(
  94. 'handler' => 'views_handler_argument_user_uid',
  95. 'click sortable' => TRUE,
  96. 'name table' => 'workflow_node',
  97. 'name field' => 'uid',
  98. ),
  99. 'filter' => array(
  100. 'handler' => 'views_handler_filter_user_name',
  101. 'numeric' => TRUE,
  102. 'name table' => 'workflow_node',
  103. 'name field' => 'uid',
  104. ),
  105. );
  106. $data['workflow_node_current']['table']['group'] = t('Workflow');
  107. // Explain how this table joins to others.
  108. $data['workflow_node_current']['table']['join'] = array(
  109. 'node' => array(
  110. 'table' => 'workflow_node_history',
  111. 'field' => 'nid',
  112. 'left_table' => 'workflow_node',
  113. 'left_field' => 'nid',
  114. 'extra' => 'workflow_node.stamp = workflow_node_current.stamp AND workflow_node.nid = workflow_node_current.nid',
  115. ),
  116. );
  117. // Workflow node current comment.
  118. $data['workflow_node_current']['comment'] = array(
  119. 'title' => t('Current comment'),
  120. 'help' => t('The comment describing why the node was moved from the last state to the current state.'),
  121. 'field' => array(
  122. 'handler' => 'views_handler_field_xss',
  123. 'click sortable' => TRUE,
  124. ),
  125. 'filter' => array(
  126. 'handler' => 'views_handler_filter_string',
  127. 'numeric' => TRUE,
  128. ),
  129. );
  130. // Workflow scheduled transition.
  131. $data['workflow_scheduled_transition']['table']['group'] = t('Workflow');
  132. $data['workflow_scheduled_transition']['table']['join'] = array(
  133. 'node' => array(
  134. 'field' => 'nid',
  135. 'left_table' => 'node',
  136. 'left_field' => 'nid',
  137. ),
  138. );
  139. $data['workflow_scheduled_transition']['sid'] = array(
  140. 'title' => t('Scheduled state'),
  141. 'help' => t('The current workflow state that the node is in.'),
  142. 'field' => array(
  143. 'handler' => 'workflow_views_handler_field_sid',
  144. 'click sortable' => TRUE,
  145. ),
  146. 'filter' => array(
  147. 'handler' => 'workflow_views_handler_filter_sid',
  148. 'numeric' => TRUE,
  149. ),
  150. );
  151. $data['workflow_scheduled_transition']['scheduled'] = array(
  152. 'title' => t('Scheduled time'),
  153. 'help' => t('The time at which the node will change workflow states.'),
  154. 'field' => array(
  155. 'handler' => 'views_handler_field_date',
  156. 'click sortable' => TRUE,
  157. ),
  158. 'filter' => array(
  159. 'handler' => 'views_handler_filter_date',
  160. 'numeric' => TRUE,
  161. ),
  162. 'sort' => array(
  163. 'handler' => 'views_handler_sort_date',
  164. ),
  165. );
  166. $data['workflow_scheduled_transition']['comment'] = array(
  167. 'title' => t('Scheduled comment'),
  168. 'help' => t('A comment describing why the node was scheduled for state transition.'),
  169. 'field' => array(
  170. 'handler' => 'views_handler_field_xss',
  171. 'click sortable' => TRUE,
  172. ),
  173. 'filter' => array(
  174. 'handler' => 'views_handler_filter_string',
  175. 'numeric' => TRUE,
  176. ),
  177. );
  178. // Workflow node history.
  179. $data['workflow_node_history']['table']['group'] = t('Workflow');
  180. $data['workflow_node_history']['table']['join'] = array(
  181. 'node' => array(
  182. 'field' => 'nid',
  183. 'left_table' => 'node',
  184. 'left_field' => 'nid',
  185. ),
  186. );
  187. $data['workflow_node_history']['sid'] = array(
  188. 'title' => t('Previous state'),
  189. 'help' => t('A workflow state that the node was in previously.'),
  190. 'field' => array(
  191. 'handler' => 'workflow_views_handler_field_sid',
  192. 'click sortable' => TRUE,
  193. ),
  194. 'filter' => array(
  195. 'handler' => 'workflow_views_handler_filter_sid',
  196. 'numeric' => TRUE,
  197. ),
  198. );
  199. $data['workflow_node_history']['stamp'] = array(
  200. 'title' => t('Previous time'),
  201. 'help' => t('The time at which the node moved from one state to another.'),
  202. 'field' => array(
  203. 'handler' => 'views_handler_field_date',
  204. 'click sortable' => TRUE,
  205. ),
  206. 'filter' => array(
  207. 'handler' => 'views_handler_filter_date',
  208. 'numeric' => TRUE,
  209. ),
  210. 'sort' => array(
  211. 'handler' => 'views_handler_sort_date',
  212. ),
  213. );
  214. $data['workflow_node_history']['comment'] = array(
  215. 'title' => t('Previous comment'),
  216. 'help' => t('A comment describing why the node was moved from one state to another in the past.'),
  217. 'field' => array(
  218. 'handler' => 'views_handler_field_xss',
  219. 'click sortable' => TRUE,
  220. ),
  221. 'filter' => array(
  222. 'handler' => 'views_handler_filter_string',
  223. 'numeric' => TRUE,
  224. ),
  225. );
  226. $data['workflow_node_history']['uid'] = array(
  227. 'title' => t('Previous comment author'),
  228. 'help' => t('The author of a comment describing why the node was moved from one state to another in the past.'),
  229. 'field' => array(
  230. 'handler' => 'workflow_views_handler_field_username',
  231. 'click sortable' => TRUE,
  232. ),
  233. 'relationship' => array(
  234. 'title' => t('Author'),
  235. 'help' => t("The User ID of the comment's author."),
  236. 'base' => 'users',
  237. 'base field' => 'uid',
  238. 'handler' => 'views_handler_relationship',
  239. 'label' => t('author'),
  240. ),
  241. 'argument' => array(
  242. 'handler' => 'views_handler_argument_numeric',
  243. ),
  244. 'filter' => array(
  245. 'handler' => 'views_handler_filter_user_name',
  246. ),
  247. );
  248. return $data;
  249. }
  250. /**
  251. * @}
  252. */