function library_cron in Library 5.2
Same name and namespace in other branches
- 8 library.module \library_cron()
- 6.2 library.module \library_cron()
- 6 library.module \library_cron()
- 7 library.module \library_cron()
Implementation of hook_cron().
1 string reference to 'library_cron'
- library_uninstall in ./
library.install - Implementation of hook_uninstall().
File
- ./
library.module, line 1255
Code
function library_cron() {
$last_update = variable_get('library_cron', 0);
$next_update = $last_update + 24 * 60 * 60;
if (time() > $next_update && library_duedates_enabled()) {
$records = library_get_overdue_items();
if (!empty($records)) {
$num_emails = 0;
foreach ($records as $patron_id => $record) {
/*
$items = array();
foreach ($record['items'] as $id => $item) {
if (($last_update < $item['due_date']) && ($item['due_date'] <= $next_update)) {
$items[$id] = $item;
}
}
$record['items'] = $items;
*/
$params = $record;
drupal_mail('library', 'notify_overdue', $params['patron']['patron_email'], language_default(), $params);
$num_emails++;
}
watchdog('library', '%number overdue email notifications sent successfully.', array(
'%number' => $num_emails,
));
}
variable_set('library_cron', time());
}
}