-
Notifications
You must be signed in to change notification settings - Fork 3
/
open_badges.views.inc
275 lines (252 loc) · 8.35 KB
/
open_badges.views.inc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
<?php
/**
* @file
* This defines views hooks for the Open_badges module. It will be loaded automatically as needed by the Views module.
*
* @author Heine Deelstra (Heine), http://drupal.org/user/17943
* @author Richard Skinner (Likeless), http://drupal.org/user/310635
*
*/
/**
* Implements hook_views_handlers().
*/
function open_badges_views_handlers() {
//dpm("open_badges_views_handlers: entered");
return array(
'handlers' => array(
'views_handler_field_open_badges_badges_badge' => array(
'parent' => 'views_handler_field',
),
'views_handler_field_open_badges_user_uid' => array(
'parent' => 'views_handler_field',
),
'views_handler_filter_open_badges_user_type' => array(
'parent' => 'views_handler_filter_in_operator',
),
'views_handler_filter_open_badges_badge_state' => array(
'parent' => 'views_handler_filter_in_operator',
),
'views_handler_filter_open_badges_user_decision' => array(
'parent' => 'views_handler_filter_in_operator',
),
),
);
}
/**
* Implements hook_views_data().
*/
function open_badges_views_data() {
//dpm("open_badges_views_data: entered");
// Describe the open_badges_user table.
// Define the base group of this table. Fields that don't
// have a group defined will go into this field by default.
$data['open_badges_user']['table']['group'] = t('Open Badges');
// How to join this table to the users table
$data['open_badges_user']['table']['join']['users'] = array(
'left_field' => 'uid',
'field' => 'uid',
);
// How to join this table to the node table
$data['open_badges_user']['table']['join']['node'] = array(
'left_field' => 'uid',
'field' => 'uid',
);
// How to join to node_revisions; through the node table for consistent authorship.
$data['open_badges_user']['table']['join']['node_revisions'] = array(
'left_table' => 'node',
'left_field' => 'uid',
'field' => 'uid',
);
// Describe the open_badges_badges table.
$data['open_badges_badges']['table']['group'] = t('Open Badges');
//We always join the open_badges_badges table on to the open_badges_user table
$open_badges_badges_join_info = array(
'left_table' => 'open_badges_user',
'left_field' => 'bid',
'field' => 'bid',
);
$data['open_badges_badges']['table']['join']['users'] = $open_badges_badges_join_info;
$data['open_badges_badges']['table']['join']['node'] = $open_badges_badges_join_info;
$data['open_badges_badges']['table']['join']['node_revisions'] = $open_badges_badges_join_info;
// Information for processing badge IDs
$data['open_badges_user']['bid'] = array(
'title' => t('Bid'),
'help' => t('The badge ID of the open badge itself.'),
'field' => array(
'handler' => 'views_handler_field_numeric',
'click sortable' => TRUE,
),
// Information for accepting a bid as an argument
'argument' => array(
'handler' => 'views_handler_argument_numeric',
'name field' => 'Badge ID',
'numeric' => TRUE,
),
//Info for filtering by bid
'filter' => array(
'handler' => 'views_handler_filter_numeric',
),
// Information for sorting on a bid.
'sort' => array(
'handler' => 'views_handler_sort',
),
);
// Information for processing badge types
$data['open_badges_user']['type'] = array(
'title' => t('Type'),
'help' => t('Whether the badge was set as part of the role, or individually assigned.'),
'field' => array(
'handler' => 'views_handler_field',
'click sortable' => TRUE,
),
//Info for filtering by badge type
'filter' => array(
'handler' => 'views_handler_filter_open_badges_user_type',
),
// Information for sorting on a bid.
'sort' => array(
'handler' => 'views_handler_sort',
),
);
// Information for processing badge states
$data['open_badges_user']['state'] = array(
'title' => t('State'),
'help' => t('State of this badge in the Mozilla OBI process of "baking", sharing, etc.'),
'field' => array(
'handler' => 'views_handler_field',
'click sortable' => TRUE,
),
//Info for filtering by badge type
'filter' => array(
'handler' => 'views_handler_filter_open_badges_badge_state',
),
// Information for sorting on a bid.
'sort' => array(
'handler' => 'views_handler_sort',
),
);
// Information for processing badge display decision
$data['open_badges_user']['allowdisplay'] = array(
'title' => t('AllowDisplay'),
'help' => t('Whether the user has chosen to allow the badge to be displayed locally.'),
'field' => array(
'handler' => 'views_handler_field',
'click sortable' => TRUE,
),
//Info for filtering by badge type
'filter' => array(
'handler' => 'views_handler_filter_open_badges_user_decision',
),
// Information for sorting on a bid.
'sort' => array(
'handler' => 'views_handler_sort',
),
);
// Information about the issue date of the badge
$data['open_badges_user']['issuedate'] = array(
'title' => t('IssueDate'),
'help' => t('Date when the badge was issued.'),
'field' => array(
'handler' => 'views_handler_field',
'click sortable' => TRUE,
),
//Info for filtering by badge type
'filter' => array(
'handler' => 'views_handler_filter_date',
),
// Information for sorting on a bid.
'sort' => array(
'handler' => 'views_handler_sort',
),
);
// Information about the expiration time of the badge
$data['open_badges_user']['expirationdate'] = array(
'title' => t('Expiration'),
'help' => t('Date when the badge expires. The default is that the badge does not expire.'),
'field' => array(
'handler' => 'views_handler_field',
'click sortable' => TRUE,
),
//Info for filtering by badge type
'filter' => array(
'handler' => 'views_handler_filter_date',
),
// Information for sorting on a bid.
'sort' => array(
'handler' => 'views_handler_sort',
),
);
// Information about whether the user has been notified about the badge
$data['open_badges_user']['usernotified'] = array(
'title' => t('UserNotified'),
'help' => t('If this is 1, the user has been notified that the badge has been issued.'),
'field' => array(
'handler' => 'views_handler_field',
'click sortable' => TRUE,
),
//Info for filtering by badge type
'filter' => array(
'handler' => 'views_handler_filter_boolean_operator',
),
// Information for sorting on a bid.
'sort' => array(
'handler' => 'views_handler_sort',
),
);
// Information for processing badges by name
$data['open_badges_badges']['name'] = array(
'title' => t('Badge Name'),
'help' => t('The name of the open badge.'),
'field' => array(
'handler' => 'views_handler_field',
'click sortable' => TRUE,
),
'argument' => array(
'handler' => 'views_handler_argument',
'name field' => 'Badge Name',
),
//Info for filtering by badge name
'filter' => array(
'handler' => 'views_handler_filter_string',
),
// Information for sorting on a bid.
'sort' => array(
'handler' => 'views_handler_sort',
),
);
// Information for processing badges weights
$data['open_badges_badges']['weight'] = array(
'title' => t('Badge Weight'),
'help' => t('The weight of the badge, as defined on the open badges settings page.'),
'field' => array(
'handler' => 'views_handler_field_numeric',
),
'argument' => array(
'handler' => 'views_handler_argument_numeric',
),
'sort' => array(
'handler' => 'views_handler_sort',
),
);
$data['open_badges_badges']['badge'] = array(
'title' => t('Open Badge'),
'real field' => 'bid',
'help' => t('An individual open badge.'),
'field' => array(
'handler' => 'views_handler_field_open_badges_badges_badge',
),
);
// Add the grouped open badges to the user table
$data['users']['open_badges_html'] = array(
'real field' => 'uid',
'title' => t('Grouped Open Badges'),
'help' => t("All the user's open badges."),
'group' => t('Open Badges'),
'field' => array(
'handler' => 'views_handler_field_open_badges_user_uid',
),
);
//dpm("open_badges_views_data: returning data...");
//dpr($data, FALSE, "Data from open_badges_views_data");
return $data;
}