tracker.views.inc 4.5 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 = array();
  11. $data['tracker_node']['table']['group'] = t('Tracker');
  12. $data['tracker_node']['table']['join'] = array(
  13. 'node_field_data' => array(
  14. 'type' => 'INNER',
  15. 'left_field' => 'nid',
  16. 'field' => 'nid',
  17. ),
  18. );
  19. $data['tracker_node']['nid'] = array(
  20. 'title' => t('Nid'),
  21. 'help' => t('The node ID of the node.'),
  22. 'field' => array(
  23. 'id' => 'node',
  24. ),
  25. 'argument' => array(
  26. 'id' => 'node_nid',
  27. 'name field' => 'title',
  28. 'numeric' => TRUE,
  29. 'validate type' => 'nid',
  30. ),
  31. 'filter' => array(
  32. 'id' => 'numeric',
  33. ),
  34. 'sort' => array(
  35. 'id' => 'standard',
  36. ),
  37. );
  38. $data['tracker_node']['published'] = array(
  39. 'title' => t('Published'),
  40. 'help' => t('Whether or not the node is published.'),
  41. 'field' => array(
  42. 'id' => 'boolean',
  43. ),
  44. 'filter' => array(
  45. 'id' => 'boolean',
  46. 'label' => t('Published'),
  47. 'type' => 'yes-no',
  48. 'accept null' => TRUE,
  49. 'use_equal' => TRUE,
  50. ),
  51. 'sort' => array(
  52. 'id' => 'standard',
  53. ),
  54. );
  55. $data['tracker_node']['changed'] = array(
  56. 'title' => t('Updated date'),
  57. 'help' => t('The date the node was last updated.'),
  58. 'field' => array(
  59. 'id' => 'date',
  60. ),
  61. 'sort' => array(
  62. 'id' => 'date',
  63. ),
  64. 'filter' => array(
  65. 'id' => 'date',
  66. ),
  67. );
  68. $data['tracker_user']['table']['group'] = t('Tracker - User');
  69. $data['tracker_user']['table']['join'] = array(
  70. 'node_field_data' => array(
  71. 'type' => 'INNER',
  72. 'left_field' => 'nid',
  73. 'field' => 'nid',
  74. ),
  75. 'user_field_data' => array(
  76. 'type' => 'INNER',
  77. 'left_field' => 'uid',
  78. 'field' => 'uid',
  79. ),
  80. );
  81. $data['tracker_user']['nid'] = array(
  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' => array(
  85. 'id' => 'node',
  86. ),
  87. 'argument' => array(
  88. 'id' => 'node_nid',
  89. 'name field' => 'title',
  90. 'numeric' => TRUE,
  91. 'validate type' => 'nid',
  92. ),
  93. 'filter' => array(
  94. 'id' => 'numeric',
  95. ),
  96. 'sort' => array(
  97. 'id' => 'standard',
  98. ),
  99. );
  100. $data['tracker_user']['uid'] = array(
  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' => array(
  104. 'id' => 'user_name',
  105. ),
  106. 'argument' => array(
  107. 'id' => 'user_uid',
  108. 'name field' => 'name',
  109. ),
  110. 'filter' => array(
  111. 'title' => t('Name'),
  112. 'id' => 'user_name',
  113. ),
  114. 'sort' => array(
  115. 'id' => 'standard',
  116. ),
  117. );
  118. $data['tracker_user']['published'] = array(
  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' => array(
  122. 'id' => 'boolean',
  123. ),
  124. 'filter' => array(
  125. 'id' => 'boolean',
  126. 'label' => t('Published'),
  127. 'type' => 'yes-no',
  128. 'accept null' => TRUE,
  129. 'use_equal' => TRUE,
  130. ),
  131. 'sort' => array(
  132. 'id' => 'standard',
  133. ),
  134. );
  135. $data['tracker_user']['changed'] = array(
  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' => array(
  139. 'id' => 'date',
  140. ),
  141. 'sort' => array(
  142. 'id' => 'date',
  143. ),
  144. 'filter' => array(
  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'] = array(
  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' => array(
  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' => array(
  167. 'field' => 'uid',
  168. 'name table' => 'users_field_data',
  169. 'name field' => 'name',
  170. 'id' => 'tracker_user_uid'
  171. ),
  172. );
  173. }