You are here

function _scs_create_newsletter in Simplenews Content Selection 6

Same name and namespace in other branches
  1. 6.2 scs.module \_scs_create_newsletter()
  2. 7 scs.module \_scs_create_newsletter()
3 calls to _scs_create_newsletter()
scs_admin_content_node_submit in ./scs.module
scs_node_selection_submit in ./scs.pages.inc
scs_views_create_newsletter_action in simplenews_content_selection_views/scs_views.module

File

./scs.module, line 117

Code

function _scs_create_newsletter($title, $nodes) {
  global $user;

  //Title
  if ($title == '') {
    $title = t('Please edit the title of this newsletter');
  }

  //Create the body of the newsletter
  $body = '';
  foreach ($nodes as $node) {
    $node = node_load(array(
      'nid' => $node,
    ));
    $body .= theme('scs_node_output', $node);
  }
  $newsletter = new StdClass();
  $newsletter->type = 'simplenews';
  $newsletter->uid = $user->uid;
  $newsletter->title = $title;
  $newsletter->body = $body;
  $newsletter->teaser = node_teaser($body);
  $newsletter->filter = variable_get('filter_default_format', 1);
  $newsletter->status = 1;
  $newsletter->revision = 1;
  $newsletter->promote = 0;
  $newsletter->comment = 0;
  $newsletter->created = time();
  $newsletter->changed = time();
  $newsletter->simplenews['s_format'] = strtolower(variable_get('scs_format', 'plain'));
  $newsletter->priority = 0;
  $newsletter->receipt = 0;
  node_save($newsletter);
  drupal_goto('node/' . $newsletter->nid . '/edit');
}