You are here

function simplenews_scheduler_new_edition in Simplenews Scheduler 5

1 call to simplenews_scheduler_new_edition()
simplenews_scheduler_cron in ./simplenews_scheduler.module
implementation of hook_cron

File

./simplenews_scheduler.module, line 181

Code

function simplenews_scheduler_new_edition($sched_nid) {
  $node = simplenews_replace_vars(node_load(array(
    'nid' => $sched_nid,
  )));
  $node = node_build_content($node, FALSE, FALSE);
  $content = drupal_render($node->content);

  // @todo: how the hell do you save taxonomy correctly/better?
  $tids = array();
  foreach ($node->taxonomy as $tid => $tax) {
    $tids[$tid] = $tid;
  }
  $node->taxonomy = $tids;

  // now save it as a new node
  unset($node->nid);

  // append title
  $edition_no = simplenews_scheduler_get_edition_number($sched_nid) + 1;
  $node->title = theme('simplenews_scheduler_title', $node->title, $edition_no);

  // trigger it for sending
  $node->send = 1;
  node_save($node);
  return $node->nid;
}