function _scs_create_newsletter in Simplenews Content Selection 7
Same name and namespace in other branches
- 6.2 scs.module \_scs_create_newsletter()
- 6 scs.module \_scs_create_newsletter()
Newsletter creator function
1 call to _scs_create_newsletter()
- _scs_nodes_submit in ./
scs.module - Helper function: submit handler
File
- ./
scs.module, line 118 - Select Drupal content to create a newsletter
Code
function _scs_create_newsletter($title, $nodes, $toc = 0, $type) {
global $user;
//TODO Fix this
/*if ($custom_theme = variable_get('theme_default', FALSE)) {
$theme = $custom_theme;
drupal_theme_initialize();
}*/
//Title
if ($title == '') {
$title = variable_get('scs_default_title', t('Please edit the title of this newsletter'));
}
// Load node information
foreach ($nodes as $node) {
$complete_nodes[] = node_load($node);
}
// Create the body of the newsletter
$body = theme('scs_newsletter_output', array(
'nodes' => $complete_nodes,
'toc' => $toc,
));
$newsletter = new StdClass();
//TODO Make this variable
$newsletter->type = 'simplenews';
$newsletter->uid = $user->uid;
$newsletter->language = LANGUAGE_NONE;
$newsletter->title = $title;
$newsletter->body[LANGUAGE_NONE][0]['value'] = $body;
//$newsletter->teaser['und']['summary'] = node_teaser($body);
$newsletter->body[LANGUAGE_NONE][0]['summary'] = '';
if ($format = variable_get('scs_body_format', FALSE)) {
$newsletter->body[LANGUAGE_NONE][0]['format'] = $format;
}
$newsletter->status = variable_get('scs_publish_default', 1);
$newsletter->revision = 1;
$newsletter->promote = 0;
$newsletter->comment = 0;
$newsletter->created = REQUEST_TIME;
$newsletter->changed = REQUEST_TIME;
$newsletter->simplenews['s_format'] = strtolower(variable_get('scs_format', 'plain'));
$newsletter->priority = 0;
$newsletter->receipt = 0;
$newsletter->field_simplenews_term[LANGUAGE_NONE][0]['tid'] = 1;
node_save($newsletter);
drupal_goto('node/' . $newsletter->nid . '/edit');
}