You are here

function simplenews_get_subscriptions_by_list in Simplenews 7

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

Returns a list of active subscriptions for a given newsletter category.

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

Parameters

$tid: The newsletter category term 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 1453
Simplenews node handling, sent email, newsletter block and general hooks

Code

function simplenews_get_subscriptions_by_list($tid) {
  $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.tid', $tid)
    ->condition('ss.status', SIMPLENEWS_SUBSCRIPTION_STATUS_SUBSCRIBED);
  return $query
    ->execute()
    ->fetchAllAssoc('mail');
}