function _signup_check_limit in Signup 7
Same name and namespace in other branches
- 5.2 signup.module \_signup_check_limit()
- 6.2 signup.module \_signup_check_limit()
- 6 signup.module \_signup_check_limit()
Checks the signup limit for a given node, and sees if a change in either the limit or total # of signups should result in a change in signup status (open vs. closed) and prints a message indicating what happened.
Parameters
stdClass $node: The node to update, can be a full $node object or a numeric nid.
stdClass $type: String indicating what changed -- can be either 'limit' or 'total'.
Return value
int A flag indicating what change (if any) to the signup status was required due to the change in limit. 0 if there was no change, -1 if signups are now closed, and 1 if signups are now open.
4 calls to _signup_check_limit()
- signup_cancel_signup in ./
signup.module - Cancel the given signup.
- signup_node_admin_summary_form_submit in includes/
node_admin_summary.inc - @todo Please document this function.
- signup_node_settings_form_submit in includes/
node_settings.inc - Submit handler for the per-node signup settings form.
- signup_sign_up_user in ./
signup.module - Signs up a user to a node.
File
- ./
signup.module, line 1551 - The Signup module (http://drupal.org/project/signup) manages replies to nodes. In particular, it's good for event management. Signup supports sending reminder emails and automatically closing signups for nodes with a start time, via the Event…
Code
function _signup_check_limit($node, $type) {
$status_change = 0;
if (is_numeric($node)) {
$node = node_load($node);
}
$node_link = l($node->title, "node/{$node->nid}");
$limit = $node->signup_close_signup_limit;
if ($limit) {
if ($node->signup_effective_total >= $limit) {
if ($node->signup_status) {
signup_close_signup($node->nid);
$status_change = -1;
drupal_set_message(t('Signup limit reached for !title, signups closed.', array(
'!title' => $node_link,
)));
}
elseif ($type == 'limit') {
// This is a weird special case, where signups are already
// closed, but the admin lowers the limit to the signup total
// or lower. We need to print a message about this, and also
// return -1 so that callers know signups must remain closed.
drupal_set_message(t('Signup limit reached.'));
$status_change = -1;
}
}
elseif ($node->signup_effective_total < $limit && !$node->signup_status && !_signup_node_completed($node)) {
signup_open_signup($node->nid);
$status_change = 1;
if ($type == 'limit') {
drupal_set_message(t('Signup limit increased for !title, signups re-opened.', array(
'!title' => $node_link,
)));
}
else {
drupal_set_message(t('Total signups for !title now below limit, signups re-opened.', array(
'!title' => $node_link,
)));
}
}
elseif ($type == 'limit') {
drupal_set_message(t('Signup limit updated for !title.', array(
'!title' => $node_link,
)));
}
}
elseif ($type == 'limit') {
// These checks should only happen if the limit was just changed...
if (!$node->signup_status && !_signup_node_completed($node)) {
signup_open_signup($node->nid);
$status_change = 1;
drupal_set_message(t('Signup limit removed for !title, signups now open.', array(
'!title' => $node_link,
)));
}
else {
drupal_set_message(t('Signup limit removed for !title.', array(
'!title' => $node_link,
)));
}
}
return $status_change;
}