-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathregistration.install
512 lines (496 loc) · 15.1 KB
/
registration.install
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
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
<?php
/**
* @file
* Schema and installation hooks for registration module.
*/
/**
* Implements hook_schema().
*/
function registration_schema() {
$schema['registration'] = array(
'description' => 'The base table for registration module.',
'fields' => array(
'registration_id' => array(
'description' => 'The primary identifier for a registration.',
'type' => 'serial',
'unsigned' => TRUE,
'not null' => TRUE,
),
'type' => array(
'description' => 'The {registration_type}.type of this registration.',
'type' => 'varchar',
'length' => 32,
'not null' => TRUE,
'default' => '',
),
'entity_id' => array(
'description' => 'The id of the entity this registration is associated with.',
'type' => 'int',
'not null' => TRUE,
'default' => 0,
),
'entity_type' => array(
'description' => 'The entity type of the entity this registration is associated with.',
'type' => 'varchar',
'length' => 32,
'not null' => TRUE,
'default' => '',
),
'anon_mail' => array(
'type' => 'varchar',
'length' => 254,
'not null' => FALSE,
'description' => "Anonymous registrant's e-mail address.",
),
'count' => array(
'description' => 'How many spaces this registration should use towards the total capacity for this event.',
'type' => 'int',
'not null' => TRUE,
'default' => 1,
),
'user_uid' => array(
'description' => 'The uid of the user associated with this registration.',
'type' => 'int',
'not null' => FALSE,
'default' => 0,
),
'author_uid' => array(
'description' => 'The uid of the user who created this registration.',
'type' => 'int',
'not null' => TRUE,
'default' => 0,
),
'state' => array(
'description' => 'The {registration_state}.name of this registration.',
'type' => 'varchar',
'length' => 32,
'not null' => TRUE,
'default' => '',
),
'created' => array(
'description' => 'The Unix timestamp when the registration was created.',
'type' => 'int',
'not null' => TRUE,
'default' => 0,
),
'updated' => array(
'description' => 'The Unix timestamp when the registration was most recently saved.',
'type' => 'int',
'not null' => TRUE,
'default' => 0,
),
),
'indexes' => array(
'registration_updated' => array('updated'),
'registration_created' => array('created'),
'registration_type' => array(array('type', 4)),
'registration_state' => array('state'),
),
'foreign keys' => array(
'registration_author' => array(
'table' => 'users',
'columns' => array('author_uid' => 'uid'),
),
'registration_user' => array(
'table' => 'users',
'columns' => array('user_uid' => 'uid'),
),
'registration_state' => array(
'table' => 'registration_state',
'columns' => array('state' => 'name'),
),
),
'primary key' => array('registration_id'),
);
$schema['registration_entity'] = array(
'description' => 'Registration per-entity settings.',
'fields' => array(
'entity_id' => array(
'description' => 'Entity id these registration settings are for.',
'type' => 'int',
'not null' => TRUE,
),
'entity_type' => array(
'description' => 'The entity type of the entity these registration settings are for.',
'type' => 'varchar',
'length' => 32,
'not null' => TRUE,
'default' => '',
),
'capacity' => array(
'description' => 'Maximum number of users who can signup for this event.',
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
),
'status' => array(
'description' => 'Boolean indicating if registrations are open (1) or closed (0) for the given entity',
'type' => 'int',
'not null' => TRUE,
'default' => 1,
),
'send_confirmation' => array(
'description' => 'Boolean indicating whether confirmation emails should be sent.',
'type' => 'int',
'not null' => TRUE,
'default' => 0,
),
'confirmation_template' => array(
'description' => 'Confirmation email template.',
'type' => 'text',
'size' => 'big',
'not null' => FALSE,
),
'send_reminder' => array(
'description' => 'Boolean indicating whether reminder emails should be sent. This is set to 0 once the reminders are sent.',
'type' => 'int',
'not null' => TRUE,
'default' => 0,
),
'reminder_date' => array(
'description' => 'Date to send the reminder on.',
'type' => 'datetime',
'mysql_type' => 'datetime',
'pgsql_type' => 'timestamp',
'sqlite_type' => 'varchar',
'sqlsrv_type' => 'smalldatetime',
'not null' => FALSE,
),
'reminder_template' => array(
'description' => 'Reminder email template.',
'type' => 'text',
'size' => 'big',
'not null' => FALSE,
),
'open' => array(
'description' => 'Date to open registrations. Or NULL to open immediately.',
'type' => 'datetime',
'mysql_type' => 'datetime',
'pgsql_type' => 'timestamp',
'sqlite_type' => 'varchar',
'sqlsrv_type' => 'smalldatetime',
'not null' => FALSE,
),
'close' => array(
'description' => 'Date to close registrations. Or NULL to never close automatically.',
'type' => 'datetime',
'mysql_type' => 'datetime',
'pgsql_type' => 'timestamp',
'sqlite_type' => 'varchar',
'sqlsrv_type' => 'smalldatetime',
'not null' => FALSE,
),
'settings' => array(
'type' => 'blob',
'not null' => TRUE,
'size' => 'big',
'serialize' => TRUE,
'description' => 'A serialized object that stores additional registration settings.',
),
),
'primary key' => array('entity_id', 'entity_type'),
);
$schema['registration_type'] = array(
'description' => 'Stores information about all defined registration types.',
'fields' => array(
'id' => array(
'type' => 'serial',
'not null' => TRUE,
'description' => 'Primary Key: Unique registration type ID.',
),
'name' => array(
'description' => 'The machine-readable name of this registration type.',
'type' => 'varchar',
'length' => 32,
'not null' => TRUE,
),
'label' => array(
'description' => 'The human-readable name of this registration type.',
'type' => 'varchar',
'length' => 255,
'not null' => TRUE,
'default' => '',
),
'weight' => array(
'type' => 'int',
'not null' => TRUE,
'default' => 0,
'size' => 'tiny',
'description' => 'The weight of this registration type in relation to others.',
),
'locked' => array(
'description' => 'A boolean indicating whether the administrator may delete this type.',
'type' => 'int',
'not null' => TRUE,
'default' => 0,
'size' => 'tiny',
),
'default_state' => array(
'type' => 'varchar',
'length' => 128,
'not null' => FALSE,
'description' => 'The machine name of the default registration state.',
),
'data' => array(
'type' => 'text',
'not null' => FALSE,
'size' => 'big',
'serialize' => TRUE,
'description' => 'A serialized array of additional data related to this entity_test type.',
'merge' => TRUE,
),
'status' => array(
'type' => 'int',
'not null' => TRUE,
// Set the default to ENTITY_CUSTOM without using the constant as it is
// not safe to use it at this point.
'default' => 0x01,
'size' => 'tiny',
'description' => 'The exportable status of the entity.',
),
'module' => array(
'description' => 'The name of the providing module if the entity has been defined in code.',
'type' => 'varchar',
'length' => 255,
'not null' => FALSE,
),
),
'primary key' => array('id'),
'unique keys' => array(
'name' => array('name'),
),
);
$schema['registration_state'] = array(
'description' => 'Stores registration states configuration.',
'fields' => array(
'registration_state_id' => array(
'type' => 'serial',
'unsigned' => TRUE,
'not null' => TRUE,
'description' => 'The registration state ID.',
),
'name' => array(
'type' => 'varchar',
'length' => 128,
'not null' => TRUE,
'description' => 'The machine name of the registration state.',
),
'label' => array(
'type' => 'varchar',
'length' => 128,
'not null' => TRUE,
'description' => 'The human readable name of the registration state.',
),
'description' => array(
'type' => 'text',
'size' => 'big',
'not null' => FALSE,
'description' => 'The description of the registration state.',
),
'default_state' => array(
'description' => 'A boolean indicating default registration state.',
'type' => 'int',
'not null' => TRUE,
'default' => 0,
'size' => 'tiny',
),
'active' => array(
'type' => 'int',
'not null' => TRUE,
'default' => 0,
'size' => 'tiny',
'description' => 'A flag showing active registration states.',
),
'held' => array(
'type' => 'int',
'not null' => TRUE,
'default' => 0,
'size' => 'tiny',
'description' => 'A flag showing held registration states.',
),
'show_on_form' => array(
'type' => 'int',
'not null' => TRUE,
'default' => 0,
'size' => 'tiny',
'description' => 'A flag showing if this registration state should be shown on the registration form.',
),
'weight' => array(
'type' => 'int',
'not null' => TRUE,
'default' => 0,
'description' => 'The weight of this registration state in the UI',
),
'status' => array(
'type' => 'int',
'not null' => TRUE,
// Set the default to ENTITY_CUSTOM without using the constant as it is
// not safe to use it at this point.
'default' => 0x01,
'size' => 'tiny',
'description' => 'The exportable status of the entity.',
),
'module' => array(
'description' => 'The name of the providing module if the entity has been defined in code.',
'type' => 'varchar',
'length' => 255,
'not null' => FALSE,
),
),
'indexes' => array(
'registration_state_name' => array('name'),
'registration_state_default_state' => array('default_state'),
),
'primary key' => array('registration_state_id'),
'unique keys' => array(
'name' => array('name'),
),
);
// Create cache bins for Entity-cache module.
$cache_schema = backdrop_get_schema_unprocessed('system', 'cache');
$types = array(
'registration',
'registration_type',
'registration_state',
);
foreach ($types as $type) {
$schema["cache_entity_$type"] = $cache_schema;
$schema["cache_entity_$type"]['description'] = "Cache table used to store $type entity records.";
}
return $schema;
}
/**
* Implements hook_field_schema().
*/
function registration_field_schema($field) {
$columns = array(
'registration_type' => array(
'type' => 'varchar',
'length' => 32,
'not null' => FALSE,
),
);
$indexes = array(
'registration_type' => array('registration_type'),
);
$foreign_keys = array(
'registration_type' => array(
'table' => 'registration_type',
'columns' => array('registration_type' => 'name'),
),
);
return array(
'columns' => $columns,
'indexes' => $indexes,
'foreign keys' => $foreign_keys,
);
}
/**
* Implements hook_install().
*/
function registration_install() {
// Create default states.
$states = array(
'complete' => array(
'label' => 'Complete',
'description' => 'Registration has been completed.',
'default_state' => 1,
'active' => 1,
'held' => 0,
'show_on_form' => 0,
'weight' => 1,
),
'pending' => array(
'label' => 'Pending',
'description' => 'Registration is pending.',
'default_state' => 0,
'active' => 0,
'held' => 0,
'show_on_form' => 0,
'weight' => 1,
),
'held' => array(
'label' => 'Held',
'description' => 'Registration is held.',
'default_state' => 0,
'active' => 0,
'held' => 1,
'show_on_form' => 0,
'weight' => 1,
),
'canceled' => array(
'label' => 'Canceled',
'description' => 'Registration was cancelled',
'default_state' => 0,
'active' => 0,
'held' => 0,
'show_on_form' => 0,
'weight' => 1,
),
);
foreach ($states as $state_name => $state_label) {
$registration_state = entity_create('registration_state',
array(
'name' => $state_name,
'label' => $state_label['label'],
'description' => $state_label['description'],
'default_state' => $state_label['default_state'],
'active' => $state_label['active'],
'held' => $state_label['held'],
'show_on_form' => $state_label['show_on_form'],
'weight' => $state_label['weight'],
)
);
$registration_state->save();
}
// Dynamically generated variable data was detected on the following lines.
}
/**
* Implements hook_uninstall().
*/
function registration_uninstall() {
// Remove default states.
$default_states = array(
'complete',
'complete',
'canceled',
);
db_delete('registration_state')
->condition('name', $default_states, 'IN')
->execute();
}
/**
* Implements hook_update_last_removed().
*/
function registration_update_last_removed() {
return 7108;
}
/**
* Implements hook_update_N().
*/
function registration_update_1000() {
$config = config('registration.settings');
$config->set('registration_paths_administrative', update_variable_get('registration_paths_administrative', 'FALSE'));
$config->save();
update_variable_del('registration_paths_administrative');
}
/**
* Adds confirmation email fields to the registration DB table.
*/
function registration_update_1001(&$sandbox) {
$send_confirmation_spec = array(
'description' => 'Boolean indicating whether confirmation emails should be sent.',
'type' => 'int',
'not null' => TRUE,
'default' => 0,
);
db_add_field('registration_entity', 'send_confirmation', $send_confirmation_spec);
$confirmation_template_spec = array(
'description' => 'Confirmation email template.',
'type' => 'text',
'size' => 'big',
'not null' => FALSE,
);
db_add_field('registration_entity', 'confirmation_template', $confirmation_template_spec);
}