tracker.views.inc 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179
  1. <?php
  2. /**
  3. * @file
  4. * Provide views data for tracker.module.
  5. */
  6. /**
  7. * Implements hook_views_data().
  8. */
  9. function tracker_views_data() {
  10. $data = [];
  11. $data['tracker_node']['table']['group'] = t('Tracker');
  12. $data['tracker_node']['table']['join'] = [
  13. 'node_field_data' => [
  14. 'type' => 'INNER',
  15. 'left_field' => 'nid',
  16. 'field' => 'nid',
  17. ],
  18. ];
  19. $data['tracker_node']['nid'] = [
  20. 'title' => t('Nid'),
  21. 'help' => t('The node ID of the node.'),
  22. 'field' => [
  23. 'id' => 'node',
  24. ],
  25. 'argument' => [
  26. 'id' => 'node_nid',
  27. 'name field' => 'title',
  28. 'numeric' => TRUE,
  29. 'validate type' => 'nid',
  30. ],
  31. 'filter' => [
  32. 'id' => 'numeric',
  33. ],
  34. 'sort' => [
  35. 'id' => 'standard',
  36. ],
  37. ];
  38. $data['tracker_node']['published'] = [
  39. 'title' => t('Published'),
  40. 'help' => t('Whether or not the node is published.'),
  41. 'field' => [
  42. 'id' => 'boolean',
  43. ],
  44. 'filter' => [
  45. 'id' => 'boolean',
  46. 'label' => t('Published'),
  47. 'type' => 'yes-no',
  48. 'accept null' => TRUE,
  49. 'use_equal' => TRUE,
  50. ],
  51. 'sort' => [
  52. 'id' => 'standard',
  53. ],
  54. ];
  55. $data['tracker_node']['changed'] = [
  56. 'title' => t('Updated date'),
  57. 'help' => t('The date the node was last updated.'),
  58. 'field' => [
  59. 'id' => 'date',
  60. ],
  61. 'sort' => [
  62. 'id' => 'date',
  63. ],
  64. 'filter' => [
  65. 'id' => 'date',
  66. ],
  67. ];
  68. $data['tracker_user']['table']['group'] = t('Tracker - User');
  69. $data['tracker_user']['table']['join'] = [
  70. 'node_field_data' => [
  71. 'type' => 'INNER',
  72. 'left_field' => 'nid',
  73. 'field' => 'nid',
  74. ],
  75. 'user_field_data' => [
  76. 'type' => 'INNER',
  77. 'left_field' => 'uid',
  78. 'field' => 'uid',
  79. ],
  80. ];
  81. $data['tracker_user']['nid'] = [
  82. 'title' => t('Nid'),
  83. 'help' => t('The node ID of the node a user created or commented on. You must use an argument or filter on UID or you will get misleading results using this field.'),
  84. 'field' => [
  85. 'id' => 'node',
  86. ],
  87. 'argument' => [
  88. 'id' => 'node_nid',
  89. 'name field' => 'title',
  90. 'numeric' => TRUE,
  91. 'validate type' => 'nid',
  92. ],
  93. 'filter' => [
  94. 'id' => 'numeric',
  95. ],
  96. 'sort' => [
  97. 'id' => 'standard',
  98. ],
  99. ];
  100. $data['tracker_user']['uid'] = [
  101. 'title' => t('Uid'),
  102. 'help' => t('The user ID of a user who touched the node (either created or commented on it).'),
  103. 'field' => [
  104. 'id' => 'user_name',
  105. ],
  106. 'argument' => [
  107. 'id' => 'user_uid',
  108. 'name field' => 'name',
  109. ],
  110. 'filter' => [
  111. 'title' => t('Name'),
  112. 'id' => 'user_name',
  113. ],
  114. 'sort' => [
  115. 'id' => 'standard',
  116. ],
  117. ];
  118. $data['tracker_user']['published'] = [
  119. 'title' => t('Published'),
  120. 'help' => t('Whether or not the node is published. You must use an argument or filter on UID or you will get misleading results using this field.'),
  121. 'field' => [
  122. 'id' => 'boolean',
  123. ],
  124. 'filter' => [
  125. 'id' => 'boolean',
  126. 'label' => t('Published'),
  127. 'type' => 'yes-no',
  128. 'accept null' => TRUE,
  129. 'use_equal' => TRUE,
  130. ],
  131. 'sort' => [
  132. 'id' => 'standard',
  133. ],
  134. ];
  135. $data['tracker_user']['changed'] = [
  136. 'title' => t('Updated date'),
  137. 'help' => t('The date the node was last updated or commented on. You must use an argument or filter on UID or you will get misleading results using this field.'),
  138. 'field' => [
  139. 'id' => 'date',
  140. ],
  141. 'sort' => [
  142. 'id' => 'date',
  143. ],
  144. 'filter' => [
  145. 'id' => 'date',
  146. ],
  147. ];
  148. return $data;
  149. }
  150. /**
  151. * Implements hook_views_data_alter().
  152. */
  153. function tracker_views_data_alter(&$data) {
  154. // Provide additional uid_touch handlers which are handled by tracker
  155. $data['node_field_data']['uid_touch_tracker'] = [
  156. 'group' => t('Tracker - User'),
  157. 'title' => t('User posted or commented'),
  158. 'help' => t('Display nodes only if a user posted the node or commented on the node.'),
  159. 'argument' => [
  160. 'field' => 'uid',
  161. 'name table' => 'users_field_data',
  162. 'name field' => 'name',
  163. 'id' => 'tracker_user_uid',
  164. 'no group by' => TRUE,
  165. ],
  166. 'filter' => [
  167. 'field' => 'uid',
  168. 'name table' => 'users_field_data',
  169. 'name field' => 'name',
  170. 'id' => 'tracker_user_uid'
  171. ],
  172. ];
  173. }