-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsignup.api.php
More file actions
196 lines (182 loc) · 7.07 KB
/
signup.api.php
File metadata and controls
196 lines (182 loc) · 7.07 KB
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
<?php
/**
* @file
* This file documents the hooks invoked by the Signup module.
*/
/**
* Hook to alter signup data before a signup is inserted or updated.
*
* @param stdClass $signup
* Reference to the fully-loaded signup object representing the signup.
* @param array $form_values
* Array of form values (if any) from the signup being inserted or updated.
*/
function hook_signup_data_alter(&$signup, $form_values) {
// TODO
}
/**
* Hook invoked when a signup is being canceled.
*
* At the time this hook is invoked the record about the signup in the
* {signup_log} table still exists, but the node has already had its signup
* total decremented.
*
* @param stdClass $node
* The fully-loaded node object that the signup is being canceled from.
* @param stdClass $signup
* An object containing all the known information about the signup being
* canceled. Contains all the data from the {signup_log} row representing
* the canceled signup. See the schema definition for descriptions of each
* field and what they represent.
*
* @see signup_cancel_signup()
*/
function hook_signup_cancel($signup, $node) {
$info = array();
$info[] = t('Signup ID: @sid', array('@sid' => $signup->sid));
$info[] = t('Node ID: @nid', array('@nid' => $signup->nid));
$info[] = t('User ID: @uid', array('@uid' => $signup->uid));
$info[] = t('Email address for anonymous signup: @anon_mail', array('@anon_mail' => $signup->anon_mail));
$info[] = t('Date/time when the signup was created: @signup_time', array('@signup_time' => $signup->signup_time));
$form_data = unserialize($signup->form_data);
$info[] = t('Custom signup form data: %signup_form_data', array('%signup_form_data' => theme('signup_custom_data_email', $form_data)));
$info[] = t('Attendance record: %attended', array('%attended' => theme('signup_attended_text', $signup->attended)));
$info[] = t('Slots consumed by this signup: @count_towards_limit', array('@count_towards_limit' => $signup->count_towards_limit));
drupal_set_message(theme('item_list', $info, t('Signup canceled for %node_title', array('%node_title' => $node->title))));
}
/**
* Hook invoked after a signup has been inserted.
*
* @param stdClass $signup
* The fully-loaded signup object representing the new signup.
*/
function hook_signup_insert($signup) {
// TODO
}
/**
* Hook invoked after a signup has been updated.
*
* @param stdClass $signup
* The fully-loaded signup object representing the updated signup.
*/
function hook_signup_update($signup) {
// TODO
}
/**
* Hook invoked when a signup is being created to gather other signup data.
*
* This hook allows other modules to inject information into the custom signup
* data for each signup. The array is merged with the values of any custom
* fields from theme_signup_user_form(), serialized, and stored in the
* {signup_log} database table.
*
* @param stdClass $node
* Fully-loaded node object being signed up to.
* @param stdClass $account
* Full-loaded user object who is signing up.
*
* @return array
* Keyed array of fields to include in the custom data for this signup. The
* keys for the array are used as labels when displaying the field, so they
* should be human-readable (and wrapped in t() to allow translation).
*
* @see signup_sign_up_user()
* @see theme_signup_user_form()
*/
function hook_signup_sign_up($node, $account) {
return array(
t('Node type') => node_type_get_name($node->type),
t('User created') => format_date($account->created),
);
}
/**
* Hook invoked whenever a node is reopened for signups.
*
* A node with signups closed could be reopened in two main cases: 1) someone
* cancels a signup and the signup limit is no longer reached; 2) a signup
* administrator manually re-opens signups.
*
* @param stdClass $node
* Fully-loaded node object that is now open for signups.
*
* @see signup_open_signup()
*/
function hook_signup_open($node) {
drupal_set_message(t('Duplicate message: signups are now open on %title.', array('%title' => $node->title)));
}
/**
* Hook invoked whenever a node is closed for signups.
*
* Signups are closed in 3 main cases: 1) it is a time-based node and the
* close-in-advance time has been reached (auto-close via cron); 2) the node
* has a signup limit and the limit is reached; 3) a signup administrator
* manually closes signups.
*
* @param stdClass $node
* Fully-loaded node object that is now closed for signups.
*
* @see signup_close_signup()
*/
function hook_signup_close($node) {
drupal_set_message(t('Duplicate message: signups are now closed on %title.', array('%title' => $node->title)));
}
/**
* Hook invoked to see if signup information should be printed for a node.
*
* This hook is invoked whenever someone is viewing a signup-enabled node and
* allows modules to suppress any signup-related output. If any module's
* implementation of this hook returns TRUE, no signup information will be
* printed for that node.
*
* @param stdClass $node
* The fully-loaded node object being viewed.
*
* @return bool|null
* TRUE if you want to prevent signup information from being printed, FALSE
* or NULL if the information should be printed.
*
* @see _signup_needs_output()
* @see _signup_menu_access()
* @see signup_nodeapi()
*/
function hook_signup_suppress($node) {
if ($node->nid % 2) {
drupal_set_message(t('Signup information suppressed for odd node ID %nid.', array('%nid' => $node->nid)));
return TRUE;
}
}
/**
* Hook invoked to control access to signup menu items.
*
* This hook is invoked to check access for signup menu items, in particular,
* the signup-related tabs on signup-enabled nodes. If no value is returned
* (NULL), the hook is ignored and the usual access logic is enforced via the
* Signup module. If multiple modules return a value, the logical OR is used,
* so if anyone returns TRUE, access is granted. If everyone returns FALSE,
* access is denied (even if the Signup module would normally grant access).
*
* @param stdClass $node
* The fully-loaded node object where the menu items would be attached.
* @param string $menu_type
* String specifying what kind of menu item to test access for. Can be:
* 'signup': the signup form
* 'list': the signup attendee listing
* 'admin': the signup administration tab
* 'add': the signup administration tab to add other users (requires
* that signups are currently open on the given node).
* 'broadcast': for the broadcast tab
*
* @return bool
* TRUE if you want to allow access to the requested menu item, FALSE if you
* want to deny access (although if another hook implementation returns
* TRUE, that will take precedence), or NULL if you don't care and want to
* let Signup module itself decide access based on its own logic.
*
* @see _signup_menu_access()
*/
function hook_signup_menu_access($node, $menu_type) {
// For example, you might want to test that the current user is the
// administrator of the organic group that a signup-enabled node belongs to,
// in which case, you'd return TRUE here to give that user full signup
// powers over events in their group.
}