function _signup_cron_autoclose in Signup 5.2
Same name and namespace in other branches
- 6.2 includes/cron.inc \_signup_cron_autoclose()
- 6 includes/cron.inc \_signup_cron_autoclose()
- 7 includes/cron.inc \_signup_cron_autoclose()
Helper function that handles auto-closing time-based nodes during cron.
Loops over all the node types that are signup-enabled. For each one, it invokes the method for the installed event/date backend module to get the right query fragments, and builds a query to find all nodes of that type where signups should be closed (e.g. events that already started, etc).
See also
1 call to _signup_cron_autoclose()
- signup_cron in ./
signup.module - Implementation of hook_cron().
File
- ./
signup.module, line 117 - 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_cron_autoclose() {
$type_autoclose_sql = array();
foreach (signup_content_types() as $type) {
$type_sql = signup_autoclose_sql($type);
if (!empty($type_sql)) {
$type_autoclose_sql[$type] = $type_sql;
}
}
if (empty($type_autoclose_sql)) {
// No node types support auto-close, so bail out now.
return;
}
$autoclose_common_sql = array(
'primary' => '{node} n',
'fields' => array(
'n.nid',
'n.type',
),
'where' => array(
's.status = 1',
"n.type = '%s'",
),
'joins' => array(
'INNER JOIN {signup} s ON s.nid = n.nid',
),
);
foreach ($type_autoclose_sql as $type => $autoclose_sql) {
$sql = _signup_build_query($autoclose_common_sql, $autoclose_sql);
$result = db_query($sql, $type);
// Loop through the results, calling the signup closing function.
while ($signup = db_fetch_object($result)) {
signup_close_signup($signup->nid, $cron = 'yes');
$node = node_load($signup->nid);
foreach (module_implements('signup_close') as $module) {
$function = $module . '_signup_close';
$function($node);
}
watchdog('signup', t('Signups closed for %title by cron.', array(
'%title' => $node->title,
)), WATCHDOG_NOTICE, l(t('view'), 'node/' . $node->nid));
}
}
}