You are here

function simplenews_scheduler_cron in Simplenews Scheduler 6.2

Same name and namespace in other branches
  1. 8 simplenews_scheduler.module \simplenews_scheduler_cron()
  2. 5 simplenews_scheduler.module \simplenews_scheduler_cron()
  3. 6 simplenews_scheduler.module \simplenews_scheduler_cron()
  4. 7 simplenews_scheduler.module \simplenews_scheduler_cron()
  5. 2.0.x simplenews_scheduler.module \simplenews_scheduler_cron()

Implementation of hook_cron().

Essentially we are just checking against a status table and recreating nodes to be sent.

1 call to simplenews_scheduler_cron()
SimpleNewsSchedulerNodeCreationTest::testNewsletterGeneration in tests/simplenews_scheduler.test
Basic simplenews newsletter generation test create a simplenews node,

File

./simplenews_scheduler.module, line 323
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 = $_SERVER['REQUEST_TIME'];
  $newsletters_to_send = simplenews_scheduler_get_newsletters_due($now_time);
  foreach ($newsletters_to_send as $newsletter_parent_data) {

    // Get the node id of the parent newsletter.
    $pid = $newsletter_parent_data->nid;
    $edition_time = simplenews_scheduler_calculate_edition_time($newsletter_parent_data, $now_time);

    // Create a new edition.
    $eid = _simplenews_scheduler_new_edition($pid, $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);
  }
}