function simplenews_add_node_to_spool in Simplenews 7
Same name and namespace in other branches
- 7.2 includes/simplenews.mail.inc \simplenews_add_node_to_spool()
Add the newsletter node to the mail spool.
Parameters
$node: The newsletter node to be sent.
Related topics
11 calls to simplenews_add_node_to_spool()
- SimplenewsSendTestCase::testProgrammaticNewsletter in tests/
simplenews.test - Creates and sends a node using the API.
- SimplenewsSourceTestCase::testSendCaching in tests/
simplenews.test - Test sending a newsletter to 100 recipients with caching enabled.
- SimplenewsSourceTestCase::testSendHidden in tests/
simplenews.test - Send a newsletter with the category set to hidden.
- SimplenewsSourceTestCase::testSendHTML in tests/
simplenews.test - Send a newsletter with the HTML format.
- SimplenewsSourceTestCase::testSendMissingNode in tests/
simplenews.test - Test with disabled caching.
File
- includes/
simplenews.mail.inc, line 18 - Simplenews email send and spool handling
Code
function simplenews_add_node_to_spool($node) {
// To send the newsletter, the node id and target email addresses
// are stored in the spool.
// Only subscribed recipients are stored in the spool (status = 1).
$select = db_select('simplenews_subscriber', 's');
$select
->innerJoin('simplenews_subscription', 't', 's.snid = t.snid');
$select
->addField('s', 'mail');
$select
->addField('s', 'snid');
$select
->addField('t', 'tid');
$select
->addExpression($node->nid, 'nid');
$select
->addExpression(SIMPLENEWS_SUBSCRIPTION_STATUS_SUBSCRIBED, 'status');
$select
->addExpression(REQUEST_TIME, 'timestamp');
$select
->condition('t.tid', $node->simplenews->tid);
$select
->condition('t.status', SIMPLENEWS_SUBSCRIPTION_STATUS_SUBSCRIBED);
$select
->condition('s.activated', SIMPLENEWS_SUBSCRIPTION_ACTIVE);
db_insert('simplenews_mail_spool')
->from($select)
->execute();
// Update simplenews newsletter status to send pending.
simplenews_newsletter_update_sent_status($node);
// Notify other modules that a newsletter was just spooled.
module_invoke_all('simplenews_spooled', $node);
}