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