/[drupal]/contributions/modules/signup/views/signup.views.inc
ViewVC logotype

Contents of /contributions/modules/signup/views/signup.views.inc

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.11 - (show annotations) (download) (as text)
Wed Jul 22 21:47:01 2009 UTC (4 months ago) by dww
Branch: MAIN
CVS Tags: HEAD
Changes since 1.10: +12 -2 lines
File MIME type: text/x-php
#367297 by dww: Changed the default signup views so that only the user
(and signup administrators) can view their own signups.
1 <?php
2 // $Id: signup.views.inc,v 1.10 2009/01/22 18:59:29 dww Exp $
3
4
5 /**
6 * @file
7 * Provides support for Views integration.
8 *
9 * This exposes signup-related data and declares handlers (fields, filters)
10 * and plugins (argument validators).
11 */
12
13 /**
14 * Implementation of hook_views_data().
15 */
16 function signup_views_data() {
17 // Define the base group of the signup table. Fields that don't
18 // have a group defined will go into this field by default.
19 $data['signup']['table']['group'] = t('Signup');
20
21 $data['signup']['table']['join'] = array(
22 'node' => array(
23 'left_field' => 'nid',
24 'field' => 'nid',
25 ),
26 );
27
28 $data['signup']['status'] = array(
29 'title' => t('Status: Open/Closed'),
30 'help' => t('Are signups open or closed for this node?'),
31 // Information for displaying the field
32 'field' => array(
33 'handler' => 'signup_handler_field_signup_status',
34 'click sortable' => TRUE,
35 ),
36 // Information for accepting status as a filter
37 'filter' => array(
38 'handler' => 'signup_handler_filter_signup_status',
39 'help' => t('Filter on if signups are open or closed for each node.'),
40 'label' => 'Signup status',
41 ),
42 // Information for sorting on status
43 'sort' => array(
44 'handler' => 'views_handler_sort',
45 'help' => t('Sort by if signups are closed or open.'),
46 ),
47 );
48
49 $data['signup']['close_signup_limit'] = array(
50 'title' => t('Signup Limit'),
51 'help' => t('Maximum number of users who can sign up before signups are automatically closed (set to 0 for no limit).'),
52 // Information for displaying the field
53 'field' => array(
54 'handler' => 'views_handler_field',
55 'click sortable' => TRUE,
56 ),
57 // Information for accepting close_signup_limit as a filter
58 'filter' => array(
59 'handler' => 'views_handler_filter_numeric',
60 'help' => t('Filter by the maximum number of users who can sign up before signups are automatically closed (set to 0 for no limit).'),
61 'label' => 'Signup limit',
62 ),
63 );
64
65 $data['signup']['forwarding_email'] = array(
66 'title' => t('Notification: Email Address'),
67 'help' => t('Address where notification emails are sent wenever a user signs up.'),
68 // Information for displaying the field
69 'field' => array(
70 'handler' => 'views_handler_field',
71 ),
72 );
73
74 $data['signup']['send_confirmation'] = array(
75 'title' => t('Send Confirmation'),
76 'help' => t('Should confirmation email be sent to each user who signs up.'),
77 // Information for displaying the field
78 'field' => array(
79 'handler' => 'signup_handler_field_signup_send_confirmation',
80 'click sortable' => TRUE,
81 ),
82 // Information for accepting send_confirmation as a filter
83 'filter' => array(
84 'handler' => 'views_handler_filter_boolean_operator',
85 'help' => t('Filter on if signup confirmation is enabled or disabled.'),
86 'label' => t('Send confirmation'),
87 ),
88 );
89
90 $data['signup']['confirmation_email'] = array(
91 'title' => t('Confirmation: Message'),
92 'help' => t('The body of the optional confirmation email that can be sent whenever a user signs up.'),
93 // Information for displaying the field
94 'field' => array(
95 'handler' => 'views_handler_field',
96 ),
97 );
98
99 $data['signup']['send_reminder'] = array(
100 'title' => t('Send Reminder'),
101 'help' => t('Should a reminder email be automatically sent to all users who signed up. This will be false if either an administrator disabled the feature for a given event, or if the reminder was already sent.'),
102 // Information for displaying the field
103 'field' => array(
104 'handler' => 'views_handler_field_boolean',
105 'click sortable' => TRUE,
106 ),
107 'filter' => array(
108 'handler' => 'views_handler_filter_boolean_operator',
109 'help' => t('Filter on if a signup reminder email will be sent.'),
110 'label' => t('Send reminder'),
111 ),
112 );
113
114 $data['signup']['reminder_days_before'] = array(
115 'title' => t('Reminder: Days Before Event for Email'),
116 'help' => t('How many days before an event will the reminder email be sent.'),
117 // Information for displaying the field
118 'field' => array(
119 'handler' => 'views_handler_field',
120 'click sortable' => TRUE,
121 ),
122 );
123
124 $data['signup']['reminder_email'] = array(
125 'title' => t('Reminder: Message'),
126 'help' => t('The body of the optional reminder email that can be sent a configurable time before an event begins.'),
127 // Information for displaying the field
128 'field' => array(
129 'handler' => 'views_handler_field',
130 ),
131 );
132
133 $data['signup']['signup_disabled'] = array(
134 'title' => t('Enabled/Disabled'),
135 'filter' => array(
136 'handler' => 'signup_handler_filter_signup_disabled',
137 'help' => t('Filter on if signups are enabled or disabled.'),
138 'label' => 'Signups',
139 ),
140 );
141
142 $data['signup']['node_link'] = array(
143 'title' => t('Node: Signup link'),
144 'field' => array(
145 'handler' => 'signup_handler_field_signup_node_link',
146 'help' => t('Link to one of the signup-related tabs on each node.'),
147 ),
148 );
149
150 // Define base group for signup_log table.
151 $data['signup_log']['table']['group'] = t('Signup');
152
153 // Advertise this table as a possible base table so that we can have
154 // "Signup" views. This is essential for Views Bulk Operations to work,
155 // since we need operations on the signups themselves, not the users or
156 // nodes they point to. With proper use of relationships, we can get
157 // everything on signup views we'd want from either node or user views.
158 $data['signup_log']['table']['base'] = array(
159 'field' => 'sid',
160 'title' => t('Signup'),
161 'help' => t('A signup represents a relationship between a user and a node.'),
162 );
163
164 $data['signup_log']['table']['join'] = array(
165 'node' => array(
166 'left_field' => 'nid',
167 'field' => 'nid',
168 ),
169 'users' => array(
170 'left_field' => 'uid',
171 'field' => 'uid',
172 ),
173 );
174
175 $data['signup_log']['nid'] = array(
176 'title' => t('Node'),
177 'help' => t('The node a user signed up to.'),
178 'relationship' => array(
179 'base' => 'node',
180 'handler' => 'views_handler_relationship',
181 'label' => t('Signup node'),
182 ),
183 );
184
185 $data['signup_log']['uid'] = array(
186 'title' => t('User'),
187 'help' => t('The user who signed up.'),
188 'relationship' => array(
189 'base' => 'users',
190 'handler' => 'views_handler_relationship',
191 'label' => t('Signup user'),
192 ),
193 );
194
195 $data['signup_log']['uid_no_signups'] = array(
196 'title' => t('User available signups'),
197 'help' => t('Displays nodes the given user has not signed up for. Note that this argument will not work properly if you add the %signup_user relationship to the view.', array('%signup_user' => t('Signup: User'))),
198 'real field' => 'uid',
199 'argument' => array(
200 'handler' => 'signup_handler_argument_signup_user_uid',
201 ),
202 );
203
204 $data['signup_log']['email'] = array(
205 'title' => t('User: Email Address'),
206 'click sortable' => TRUE,
207 'field' => array(
208 'handler' => 'signup_handler_field_signup_user_email',
209 'help' => t('Email address of a user (authenticated or anonymous) who signed up.') .' <strong>'. t('WARNING: only expose this data in a view that is restricted to users whom you can trust with such sensitive information.') .'</strong>',
210 ),
211 );
212
213 $data['signup_log']['signup_time'] = array(
214 'title' => t('User: Signup Time'),
215 'help' => t('Time when user signed up.'),
216 'field' => array(
217 'handler' => 'views_handler_field_date',
218 'click sortable' => TRUE,
219 ),
220 'filter' => array(
221 'handler' => 'views_handler_filter_date',
222 'help' => t('Time when the user signed up.'),
223 'label' => t('Signup time'),
224 ),
225 'sort' => array(
226 'handler' => 'views_handler_sort_date',
227 'help' => t('Sort by time of sign up.'),
228 ),
229 );
230
231 $data['signup_log']['attended'] = array(
232 'title' => t('User: Attended'),
233 'help' => t('Did the user attend or not?'),
234 'field' => array(
235 'handler' => 'signup_handler_field_signup_user_attended',
236 'click sortable' => TRUE,
237 ),
238 'filter' => array(
239 'handler' => 'signup_handler_filter_signup_user_attended',
240 'help' => t('Filter on users who attended or not.'),
241 'label' => 'Signup attendance',
242 ),
243 'sort' => array(
244 'handler' => 'views_handler_sort',
245 'help' => t('Sort by if the user attended or not.'),
246 ),
247 );
248
249 $data['signup_log']['form_data'] = array(
250 'title' => t('User: Additional Signup Info'),
251 'help' => t('Enter the additional field name (from signup.theme) in the Option column.'),
252 'field' => array(
253 'handler' => 'signup_handler_field_signup_user_form_data',
254 'option' => 'string',
255 ),
256 );
257
258 $data['signup_log']['signup_user_auth'] = array(
259 'title' => t('User: Anonymous/Authenticated'),
260 'real field' => 'uid',
261 'filter' => array(
262 'handler' => 'signup_handler_filter_signup_user_authenticated',
263 'help' => t('Filter on if a user who signed up is anonymous, or an authenticated user on the site.'),
264 'label' => t('Signup user'),
265 ),
266 );
267
268 $data['signup_log']['signup_user_current'] = array(
269 'title' => t('User: Current User'),
270 'real field' => 'uid',
271 'filter' => array(
272 'handler' => 'views_handler_filter_user_current',
273 'help' => t('This allows you to filter by whether or not the node was signed up by the logged in user of the view.'),
274 ),
275 );
276
277 $data['signup_log']['edit_link'] = array(
278 'title' => t('User: Edit signup link'),
279 'field' => array(
280 'handler' => 'signup_handler_field_signup_edit_link',
281 'help' => t('Link to edit this particular signup.'),
282 ),
283 );
284
285 return $data;
286 }
287
288 /**
289 * Implementation of hook_views_handlers().
290 *
291 * Register information about all of the views handlers provided by the Signup
292 * module.
293 */
294 function signup_views_handlers() {
295 return array(
296 'info' => array(
297 'path' => drupal_get_path('module', 'signup') .'/views/handlers',
298 ),
299 'handlers' => array(
300 'signup_handler_argument_signup_user_uid' => array(
301 'parent' => 'views_handler_argument_numeric',
302 ),
303 'signup_handler_field_signup_edit_link' => array(
304 'parent' => 'views_handler_field_node_link',
305 ),
306 'signup_handler_field_signup_node_link' => array(
307 'parent' => 'views_handler_field_node_link',
308 ),
309 'signup_handler_field_signup_send_confirmation' => array(
310 'parent' => 'views_handler_field',
311 ),
312 'signup_handler_field_signup_status' => array(
313 'parent' => 'views_handler_field',
314 ),
315 'signup_handler_field_signup_user_attended' => array(
316 'parent' => 'views_handler_field',
317 ),
318 'signup_handler_field_signup_user_email' => array(
319 'parent' => 'views_handler_field',
320 ),
321 'signup_handler_field_signup_user_form_data' => array(
322 'parent' => 'views_handler_field_prerender_list',
323 ),
324 'signup_handler_filter_signup_disabled' => array(
325 'parent' => 'views_handler_filter_boolean_operator',
326 ),
327 'signup_handler_filter_signup_status' => array(
328 'parent' => 'views_handler_filter_boolean_operator',
329 ),
330 'signup_handler_filter_signup_user_attended' => array(
331 'parent' => 'views_handler_filter_boolean_operator',
332 ),
333 'signup_handler_filter_signup_user_authenticated' => array(
334 'parent' => 'views_handler_filter_boolean_operator',
335 ),
336 ),
337 );
338 }
339
340 /**
341 * Implementation of hook_views_plugins().
342 */
343 function signup_views_plugins() {
344 $path = drupal_get_path('module', 'signup') .'/views/plugins';
345 return array(
346 'argument validator' => array(
347 'signup_status' => array(
348 'title' => t('Signup status'),
349 'handler' => 'signup_plugin_argument_validate_signup_status',
350 'path' => $path,
351 ),
352 ),
353 'access' => array(
354 'user_signup_list' => array(
355 'title' => t('View per-user signup lists'),
356 'help' => t("Access will be granted to users viewing their own signup list or with the 'view all signups' permission."),
357 'handler' => 'signup_plugin_access_user_signup_list',
358 'uses options' => TRUE,
359 'path' => $path,
360 ),
361 ),
362 );
363 }
364

  ViewVC Help
Powered by ViewVC 1.1.2