function simplenews_scheduler_cron in Simplenews Scheduler 7
Same name and namespace in other branches
- 8 simplenews_scheduler.module \simplenews_scheduler_cron()
- 5 simplenews_scheduler.module \simplenews_scheduler_cron()
- 6.2 simplenews_scheduler.module \simplenews_scheduler_cron()
- 6 simplenews_scheduler.module \simplenews_scheduler_cron()
- 2.0.x simplenews_scheduler.module \simplenews_scheduler_cron()
Implements hook_cron().
Essentially we are just checking against a status table and cloning the node into edition nodes which will be sent.
File
- ./
simplenews_scheduler.module, line 335 - Simplenews Scheduler module allows a schedule to be set for sending (and resending) a Simplenews item.
Code
function simplenews_scheduler_cron() {
// Get the newsletters that need to be sent at this time.
$now_time = REQUEST_TIME;
$newsletters_to_send = simplenews_scheduler_get_newsletters_due($now_time);
foreach ($newsletters_to_send as $newsletter_parent_data) {
$edition_time = simplenews_scheduler_calculate_edition_time($newsletter_parent_data, $now_time);
// Create a new edition.
$eid = _simplenews_scheduler_new_edition($newsletter_parent_data->nid, $edition_time);
// Update the edition record.
simplenews_scheduler_scheduler_update($newsletter_parent_data, $now_time);
// Send it.
_simplenews_scheduler_send_new_edition($edition_time, $newsletter_parent_data, $eid);
}
}