? .DS_Store ? 439342.6.simplenews.admin-tabs.patch ? 439342_simplenews_adminmenutabs_6dev.patch ? 536620.simplenews.recipientAPI-rough-1.patch ? simplenews_subscriptions ? po/.DS_Store ? simplenews_action/.DS_Store ? simplenews_action/translations/.DS_Store ? simplenews_test/.DS_Store ? tests/.DS_Store ? translations/.DS_Store Index: simplenews.module =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/simplenews/simplenews.module,v retrieving revision 1.220 diff -u -p -r1.220 simplenews.module --- simplenews.module 24 Nov 2009 21:59:34 -0000 1.220 +++ simplenews.module 3 Dec 2009 22:24:21 -0000 @@ -1395,7 +1395,7 @@ function simplenews_block_form_submit($f } /** - * Send newsletter node to subcribers. + * Send newsletter node to recipients. * * @param integer or object $node Newsletter node to be send. integer = nid; object = node object * @param array $accounts account objects to send the newsletter to. @@ -1426,13 +1426,16 @@ function simplenews_send_node($node, $ac if (empty($accounts)) { - // No accounts specified. Get email address of all accounts subscribed to this newsletter. - $result = db_query('SELECT s.mail FROM {simplenews_subscriptions} s - INNER JOIN {simplenews_snid_tid} t ON s.snid = t.snid - WHERE s.activated = %d AND t.tid = %d AND t.status = %d', - 1, $node_data['tid'], SIMPLENEWS_SUBSCRIPTION_STATUS_SUBSCRIBED); - while ($account = db_fetch_object($result)) { - $mails[] = array('mail' => $account->mail); + // Invoke hook_simplenews_recipients in all modules this newsletter requests. + + // hardcoding for now: all newsletters (trivially) just invoke simplenews itself. + // @todo: this should be stored in {simplenews_newsletters} + // (as an array of module names?) + $recipient_providers = array('simplenews'); + + $mails = array(); + foreach ($recipient_providers as $module) { + $mails = array_merge($mails, module_invoke($module, 'simplenews_recipients', $node)); } } else { @@ -1464,6 +1467,23 @@ function simplenews_send_node($node, $ac } /** + * Implement hook_simplenews_recipients. + * + * @todo: move this to a separate subscriptions module. + */ +function simplenews_simplenews_recipients($node) { + // No accounts specified. Get email address of all accounts subscribed to this newsletter. + $result = db_query('SELECT s.mail FROM {simplenews_subscriptions} s + INNER JOIN {simplenews_snid_tid} t ON s.snid = t.snid + WHERE s.activated = %d AND t.tid = %d AND t.status = %d', + 1, $node->simplenews['tid'], SIMPLENEWS_SUBSCRIPTION_STATUS_SUBSCRIBED); + while ($account = db_fetch_object($result)) { + $mails[] = array('mail' => $account->mail); + } + return $mails; +} + +/** * Send test version of newsletter. * * @param integer or object $node Newsletter node to be send. Integer = nid; Object = node object