-
Notifications
You must be signed in to change notification settings - Fork 1
/
registration.api.php
141 lines (134 loc) · 3.93 KB
/
registration.api.php
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
<?php
/**
* @file
* API documentation for Relation module.
*/
/**
* Override registration_access with custom access control logic.
*
* @param $op
* @param Registration $registration
* @param object $account
*
* @return bool
*/
function hook_registration_access($op, $registration, $account = NULL) {
if ($registration->user_uid == $account->uid) {
return TRUE;
}
}
/**
* Provide a form API element exposed as a Registration entity setting.
*
* @param array $settings
* Existing settings values.
*
* @return array
* A FAPI array for a registration setting.
*/
function hook_registration_entity_settings($settings) {
return array(
'registration_entity_access_roles' => array(
'#type' => 'checkboxes',
'#title' => t('Roles'),
'#description' => t('Override default access control settings by selecting which roles can register for this event.'),
'#options' => user_roles(),
'#default_value' => isset($settings['settings']['registration_entity_access_roles']) ? $settings['settings']['registration_entity_access_roles'] : NULL,
),
);
}
/**
* Allow modules to override event count.
*
* This can impact access control and the ability for users to register.
*
* @param int $count
*
* @param array $context
* array(
* 'entity_type' => $entity_type,
* 'entity_id' => $entity_id,
* 'registration_id' => $registration_id,
* 'settings' => $settings,
* );
*/
function hook_registration_event_count_alter(&$count, $context) {
}
/**
* Allow modules to alter registration entity settings prior to sending email
* to all registrants.
*
* This could be used, for example, to allow users to opt-out of broadcast
* emails.
*
* @param array $registrations
*
* @param array $context
* array(
* 'entity_type' => $entity_type,
* 'entity_id' => $entity_id,
* );
*/
function hook_registration_send_broadcast_alter(&$registrations, $context) {
// Loop through each registration.
foreach ($registrations as $reg_id => $registration) {
// Only send broadcast email for registrations where
// user registered themself; not other user or anonymous.
if (!($registration->user_uid == $registration->author_uid) ||
!empty($registration->anon_mail)) {
unset($registrations[$reg_id]);
}
}
}
/**
* Allow modules to alter registration entity settings for a specific node type
* prior to sending email to all registrants.
*
* This could be used, for example, to allow users to opt-out of broadcast
* emails.
*
* @param array $registrations
*
* @param array $context
* array(
* 'entity_type' => $entity_type,
* 'entity_id' => $entity_id,
* );
*/
function hook_registration_send_broadcast_ENTITY_TYPE_alter(&$registrations, $context) {
// Loop through each registration.
foreach ($registrations as $reg_id => $registration) {
// Only send broadcast email for registrations where
// user registered themself; not other user or anonymous.
if (!($registration->user_uid == $registration->author_uid) ||
!empty($registration->anon_mail)) {
unset($registrations[$reg_id]);
}
}
}
/**
* Allow modules to alter registration entity settings for a particular entity
* type and entity ID prior to sending email to all registrants.
*
* This could be used, for example, to allow users to opt-out of broadcast
* emails.
*
* @param array $registrations
*
* @param array $context
* array(
* 'entity_type' => $entity_type,
* 'entity_id' => $entity_id,
* );
*/
function hook_registration_send_broadcast_ENTITY_TYPE_ID_alter(&$registrations, $context) {
// Loop through each registration.
foreach ($registrations as $reg_id => $registration) {
// Only send broadcast email for registrations where
// user registered themself; not other user or anonymous.
if (!($registration->user_uid == $registration->author_uid) ||
!empty($registration->anon_mail)) {
unset($registrations[$reg_id]);
}
}
}