You are here

function simplenews_get_subscriptions_by_list in Simplenews 7.2

Same name and namespace in other branches
  1. 7 simplenews.module \simplenews_get_subscriptions_by_list()

Returns a list of active subscriptions for a given newsletter.

WARNING: Use with caution - this might return a huge list

Parameters

$newsletter_id: The newsletter id.

Return value

An array keyed by the mail address, containing another array with the keys mail, uid, language, snid and status.

Related topics

File

./simplenews.module, line 1654
Simplenews node handling, sent email, newsletter block and general hooks

Code

function simplenews_get_subscriptions_by_list($newsletter_id) {
  $query = db_select('simplenews_subscriber', 'sn');
  $query
    ->innerJoin('simplenews_subscription', 'ss', 'ss.snid = sn.snid');
  $query
    ->fields('sn', array(
    'mail',
    'uid',
    'language',
    'snid',
  ))
    ->fields('ss', array(
    'status',
  ))
    ->condition('sn.activated', 1)
    ->condition('ss.newsletter_id', $newsletter_id)
    ->condition('ss.status', SIMPLENEWS_SUBSCRIPTION_STATUS_SUBSCRIBED);
  return $query
    ->execute()
    ->fetchAllAssoc('mail');
}