You are here

function _simplenews_scheduler_send_new_edition in Simplenews Scheduler 6.2

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

Helper for hook_cron() to send a new edition.

Parameters

$edition_time: The time of the operation. Usually the current time unless testing.

$newsletter_parent_data: A row of data from {simplenews_scheduler}, as returned by simplenews_scheduler_get_newsletters_due().

$eid: The node id of the new edition to send. This should already have been created by _simplenews_scheduler_new_edition().

1 call to _simplenews_scheduler_send_new_edition()
simplenews_scheduler_cron in ./simplenews_scheduler.module
Implementation of hook_cron().

File

./simplenews_scheduler.module, line 533
Simplenews Scheduler module allows a schedule to be set for sending (and resending) a Simplenews item.

Code

function _simplenews_scheduler_send_new_edition($edition_time, $newsletter_parent_data, $eid) {
  $pid = $newsletter_parent_data->nid;
  db_query("UPDATE {simplenews_scheduler} SET last_run = %d WHERE nid = %d", $edition_time, $pid);
  $node = node_load($eid);

  // Send the newsletter edition to each subscriber of the parent newsletter
  // get the tid of this newsletter and generate a list of accounts to send this new newsletter to, based on the parent newsletter.
  $tid = db_result(db_query("SELECT tid from {simplenews_newsletters} WHERE nid = %d", $node->nid));
  $accounts = simplenews_scheduler_get_newsletter_accounts($tid);
  module_load_include('inc', 'simplenews', 'includes/simplenews.mail');
  simplenews_send_node($node, $accounts);
}