Chris@0
|
1 <?php
|
Chris@0
|
2
|
Chris@0
|
3 namespace Drupal\user;
|
Chris@0
|
4
|
Chris@0
|
5 use Drupal\views\EntityViewsData;
|
Chris@0
|
6
|
Chris@0
|
7 /**
|
Chris@0
|
8 * Provides the views data for the user entity type.
|
Chris@0
|
9 */
|
Chris@0
|
10 class UserViewsData extends EntityViewsData {
|
Chris@0
|
11
|
Chris@0
|
12 /**
|
Chris@0
|
13 * {@inheritdoc}
|
Chris@0
|
14 */
|
Chris@0
|
15 public function getViewsData() {
|
Chris@0
|
16 $data = parent::getViewsData();
|
Chris@0
|
17
|
Chris@0
|
18 $data['users_field_data']['table']['base']['help'] = $this->t('Users who have created accounts on your site.');
|
Chris@0
|
19 $data['users_field_data']['table']['base']['access query tag'] = 'user_access';
|
Chris@0
|
20
|
Chris@0
|
21 $data['users_field_data']['table']['wizard_id'] = 'user';
|
Chris@0
|
22
|
Chris@0
|
23 $data['users_field_data']['uid']['argument']['id'] = 'user_uid';
|
Chris@0
|
24 $data['users_field_data']['uid']['argument'] += [
|
Chris@0
|
25 'name table' => 'users_field_data',
|
Chris@0
|
26 'name field' => 'name',
|
Chris@0
|
27 'empty field name' => \Drupal::config('user.settings')->get('anonymous'),
|
Chris@0
|
28 ];
|
Chris@0
|
29 $data['users_field_data']['uid']['filter']['id'] = 'user_name';
|
Chris@0
|
30 $data['users_field_data']['uid']['filter']['title'] = $this->t('Name (autocomplete)');
|
Chris@0
|
31 $data['users_field_data']['uid']['filter']['help'] = $this->t('The user or author name. Uses an autocomplete widget to find a user name, the actual filter uses the resulting user ID.');
|
Chris@0
|
32 $data['users_field_data']['uid']['relationship'] = [
|
Chris@0
|
33 'title' => $this->t('Content authored'),
|
Chris@0
|
34 'help' => $this->t('Relate content to the user who created it. This relationship will create one record for each content item created by the user.'),
|
Chris@0
|
35 'id' => 'standard',
|
Chris@0
|
36 'base' => 'node_field_data',
|
Chris@0
|
37 'base field' => 'uid',
|
Chris@0
|
38 'field' => 'uid',
|
Chris@0
|
39 'label' => $this->t('nodes'),
|
Chris@0
|
40 ];
|
Chris@0
|
41
|
Chris@0
|
42 $data['users_field_data']['uid_raw'] = [
|
Chris@0
|
43 'help' => $this->t('The raw numeric user ID.'),
|
Chris@0
|
44 'real field' => 'uid',
|
Chris@0
|
45 'filter' => [
|
Chris@0
|
46 'title' => $this->t('The user ID'),
|
Chris@0
|
47 'id' => 'numeric',
|
Chris@0
|
48 ],
|
Chris@0
|
49 ];
|
Chris@0
|
50
|
Chris@0
|
51 $data['users_field_data']['uid_representative'] = [
|
Chris@0
|
52 'relationship' => [
|
Chris@0
|
53 'title' => $this->t('Representative node'),
|
Chris@0
|
54 'label' => $this->t('Representative node'),
|
Chris@0
|
55 'help' => $this->t('Obtains a single representative node for each user, according to a chosen sort criterion.'),
|
Chris@0
|
56 'id' => 'groupwise_max',
|
Chris@0
|
57 'relationship field' => 'uid',
|
Chris@0
|
58 'outer field' => 'users_field_data.uid',
|
Chris@0
|
59 'argument table' => 'users_field_data',
|
Chris@0
|
60 'argument field' => 'uid',
|
Chris@0
|
61 'base' => 'node_field_data',
|
Chris@0
|
62 'field' => 'nid',
|
Chris@17
|
63 'relationship' => 'node_field_data:uid',
|
Chris@0
|
64 ],
|
Chris@0
|
65 ];
|
Chris@0
|
66
|
Chris@0
|
67 $data['users']['uid_current'] = [
|
Chris@0
|
68 'real field' => 'uid',
|
Chris@0
|
69 'title' => $this->t('Current'),
|
Chris@0
|
70 'help' => $this->t('Filter the view to the currently logged in user.'),
|
Chris@0
|
71 'filter' => [
|
Chris@0
|
72 'id' => 'user_current',
|
Chris@0
|
73 'type' => 'yes-no',
|
Chris@0
|
74 ],
|
Chris@0
|
75 ];
|
Chris@0
|
76
|
Chris@0
|
77 $data['users_field_data']['name']['help'] = $this->t('The user or author name.');
|
Chris@0
|
78 $data['users_field_data']['name']['field']['default_formatter'] = 'user_name';
|
Chris@0
|
79 $data['users_field_data']['name']['filter']['title'] = $this->t('Name (raw)');
|
Chris@0
|
80 $data['users_field_data']['name']['filter']['help'] = $this->t('The user or author name. This filter does not check if the user exists and allows partial matching. Does not use autocomplete.');
|
Chris@0
|
81
|
Chris@0
|
82 // Note that this field implements field level access control.
|
Chris@0
|
83 $data['users_field_data']['mail']['help'] = $this->t('Email address for a given user. This field is normally not shown to users, so be cautious when using it.');
|
Chris@0
|
84
|
Chris@0
|
85 $data['users_field_data']['langcode']['help'] = $this->t('Original language of the user information');
|
Chris@0
|
86 $data['users_field_data']['langcode']['help'] = $this->t('Language of the translation of user information');
|
Chris@0
|
87
|
Chris@0
|
88 $data['users_field_data']['preferred_langcode']['title'] = $this->t('Preferred language');
|
Chris@0
|
89 $data['users_field_data']['preferred_langcode']['help'] = $this->t('Preferred language of the user');
|
Chris@0
|
90 $data['users_field_data']['preferred_admin_langcode']['title'] = $this->t('Preferred admin language');
|
Chris@0
|
91 $data['users_field_data']['preferred_admin_langcode']['help'] = $this->t('Preferred administrative language of the user');
|
Chris@0
|
92
|
Chris@0
|
93 $data['users_field_data']['created_fulldate'] = [
|
Chris@0
|
94 'title' => $this->t('Created date'),
|
Chris@0
|
95 'help' => $this->t('Date in the form of CCYYMMDD.'),
|
Chris@0
|
96 'argument' => [
|
Chris@0
|
97 'field' => 'created',
|
Chris@0
|
98 'id' => 'date_fulldate',
|
Chris@0
|
99 ],
|
Chris@0
|
100 ];
|
Chris@0
|
101
|
Chris@0
|
102 $data['users_field_data']['created_year_month'] = [
|
Chris@0
|
103 'title' => $this->t('Created year + month'),
|
Chris@0
|
104 'help' => $this->t('Date in the form of YYYYMM.'),
|
Chris@0
|
105 'argument' => [
|
Chris@0
|
106 'field' => 'created',
|
Chris@0
|
107 'id' => 'date_year_month',
|
Chris@0
|
108 ],
|
Chris@0
|
109 ];
|
Chris@0
|
110
|
Chris@0
|
111 $data['users_field_data']['created_year'] = [
|
Chris@0
|
112 'title' => $this->t('Created year'),
|
Chris@0
|
113 'help' => $this->t('Date in the form of YYYY.'),
|
Chris@0
|
114 'argument' => [
|
Chris@0
|
115 'field' => 'created',
|
Chris@0
|
116 'id' => 'date_year',
|
Chris@0
|
117 ],
|
Chris@0
|
118 ];
|
Chris@0
|
119
|
Chris@0
|
120 $data['users_field_data']['created_month'] = [
|
Chris@0
|
121 'title' => $this->t('Created month'),
|
Chris@0
|
122 'help' => $this->t('Date in the form of MM (01 - 12).'),
|
Chris@0
|
123 'argument' => [
|
Chris@0
|
124 'field' => 'created',
|
Chris@0
|
125 'id' => 'date_month',
|
Chris@0
|
126 ],
|
Chris@0
|
127 ];
|
Chris@0
|
128
|
Chris@0
|
129 $data['users_field_data']['created_day'] = [
|
Chris@0
|
130 'title' => $this->t('Created day'),
|
Chris@0
|
131 'help' => $this->t('Date in the form of DD (01 - 31).'),
|
Chris@0
|
132 'argument' => [
|
Chris@0
|
133 'field' => 'created',
|
Chris@0
|
134 'id' => 'date_day',
|
Chris@0
|
135 ],
|
Chris@0
|
136 ];
|
Chris@0
|
137
|
Chris@0
|
138 $data['users_field_data']['created_week'] = [
|
Chris@0
|
139 'title' => $this->t('Created week'),
|
Chris@0
|
140 'help' => $this->t('Date in the form of WW (01 - 53).'),
|
Chris@0
|
141 'argument' => [
|
Chris@0
|
142 'field' => 'created',
|
Chris@0
|
143 'id' => 'date_week',
|
Chris@0
|
144 ],
|
Chris@0
|
145 ];
|
Chris@0
|
146
|
Chris@0
|
147 $data['users_field_data']['status']['filter']['label'] = $this->t('Active');
|
Chris@0
|
148 $data['users_field_data']['status']['filter']['type'] = 'yes-no';
|
Chris@0
|
149
|
Chris@0
|
150 $data['users_field_data']['changed']['title'] = $this->t('Updated date');
|
Chris@0
|
151
|
Chris@0
|
152 $data['users_field_data']['changed_fulldate'] = [
|
Chris@0
|
153 'title' => $this->t('Updated date'),
|
Chris@0
|
154 'help' => $this->t('Date in the form of CCYYMMDD.'),
|
Chris@0
|
155 'argument' => [
|
Chris@0
|
156 'field' => 'changed',
|
Chris@0
|
157 'id' => 'date_fulldate',
|
Chris@0
|
158 ],
|
Chris@0
|
159 ];
|
Chris@0
|
160
|
Chris@0
|
161 $data['users_field_data']['changed_year_month'] = [
|
Chris@0
|
162 'title' => $this->t('Updated year + month'),
|
Chris@0
|
163 'help' => $this->t('Date in the form of YYYYMM.'),
|
Chris@0
|
164 'argument' => [
|
Chris@0
|
165 'field' => 'changed',
|
Chris@0
|
166 'id' => 'date_year_month',
|
Chris@0
|
167 ],
|
Chris@0
|
168 ];
|
Chris@0
|
169
|
Chris@0
|
170 $data['users_field_data']['changed_year'] = [
|
Chris@0
|
171 'title' => $this->t('Updated year'),
|
Chris@0
|
172 'help' => $this->t('Date in the form of YYYY.'),
|
Chris@0
|
173 'argument' => [
|
Chris@0
|
174 'field' => 'changed',
|
Chris@0
|
175 'id' => 'date_year',
|
Chris@0
|
176 ],
|
Chris@0
|
177 ];
|
Chris@0
|
178
|
Chris@0
|
179 $data['users_field_data']['changed_month'] = [
|
Chris@0
|
180 'title' => $this->t('Updated month'),
|
Chris@0
|
181 'help' => $this->t('Date in the form of MM (01 - 12).'),
|
Chris@0
|
182 'argument' => [
|
Chris@0
|
183 'field' => 'changed',
|
Chris@0
|
184 'id' => 'date_month',
|
Chris@0
|
185 ],
|
Chris@0
|
186 ];
|
Chris@0
|
187
|
Chris@0
|
188 $data['users_field_data']['changed_day'] = [
|
Chris@0
|
189 'title' => $this->t('Updated day'),
|
Chris@0
|
190 'help' => $this->t('Date in the form of DD (01 - 31).'),
|
Chris@0
|
191 'argument' => [
|
Chris@0
|
192 'field' => 'changed',
|
Chris@0
|
193 'id' => 'date_day',
|
Chris@0
|
194 ],
|
Chris@0
|
195 ];
|
Chris@0
|
196
|
Chris@0
|
197 $data['users_field_data']['changed_week'] = [
|
Chris@0
|
198 'title' => $this->t('Updated week'),
|
Chris@0
|
199 'help' => $this->t('Date in the form of WW (01 - 53).'),
|
Chris@0
|
200 'argument' => [
|
Chris@0
|
201 'field' => 'changed',
|
Chris@0
|
202 'id' => 'date_week',
|
Chris@0
|
203 ],
|
Chris@0
|
204 ];
|
Chris@0
|
205
|
Chris@0
|
206 $data['users']['data'] = [
|
Chris@0
|
207 'title' => $this->t('Data'),
|
Chris@0
|
208 'help' => $this->t('Provides access to the user data service.'),
|
Chris@0
|
209 'real field' => 'uid',
|
Chris@0
|
210 'field' => [
|
Chris@0
|
211 'id' => 'user_data',
|
Chris@0
|
212 ],
|
Chris@0
|
213 ];
|
Chris@0
|
214
|
Chris@0
|
215 $data['users']['user_bulk_form'] = [
|
Chris@0
|
216 'title' => $this->t('Bulk update'),
|
Chris@0
|
217 'help' => $this->t('Add a form element that lets you run operations on multiple users.'),
|
Chris@0
|
218 'field' => [
|
Chris@0
|
219 'id' => 'user_bulk_form',
|
Chris@0
|
220 ],
|
Chris@0
|
221 ];
|
Chris@0
|
222
|
Chris@14
|
223 // Alter the user roles target_id column.
|
Chris@14
|
224 $data['user__roles']['roles_target_id']['field']['id'] = 'user_roles';
|
Chris@14
|
225 $data['user__roles']['roles_target_id']['field']['no group by'] = TRUE;
|
Chris@0
|
226
|
Chris@14
|
227 $data['user__roles']['roles_target_id']['filter']['id'] = 'user_roles';
|
Chris@14
|
228 $data['user__roles']['roles_target_id']['filter']['allow empty'] = TRUE;
|
Chris@0
|
229
|
Chris@14
|
230 $data['user__roles']['roles_target_id']['argument'] = [
|
Chris@14
|
231 'id' => 'user__roles_rid',
|
Chris@14
|
232 'name table' => 'role',
|
Chris@14
|
233 'name field' => 'name',
|
Chris@14
|
234 'empty field name' => $this->t('No role'),
|
Chris@14
|
235 'zero is null' => TRUE,
|
Chris@14
|
236 'numeric' => TRUE,
|
Chris@0
|
237 ];
|
Chris@0
|
238
|
Chris@0
|
239 $data['user__roles']['permission'] = [
|
Chris@0
|
240 'title' => $this->t('Permission'),
|
Chris@0
|
241 'help' => $this->t('The user permissions.'),
|
Chris@0
|
242 'field' => [
|
Chris@0
|
243 'id' => 'user_permissions',
|
Chris@0
|
244 'no group by' => TRUE,
|
Chris@0
|
245 ],
|
Chris@0
|
246 'filter' => [
|
Chris@0
|
247 'id' => 'user_permissions',
|
Chris@0
|
248 'real field' => 'roles_target_id',
|
Chris@0
|
249 ],
|
Chris@0
|
250 ];
|
Chris@0
|
251
|
Chris@0
|
252 return $data;
|
Chris@0
|
253 }
|
Chris@0
|
254
|
Chris@0
|
255 }
|