You are here

function simplenews_count_subscriptions in Simplenews 7

Same name and namespace in other branches
  1. 8 simplenews.module \simplenews_count_subscriptions()
  2. 6.2 includes/simplenews.admin.inc \simplenews_count_subscriptions()
  3. 7.2 includes/simplenews.admin.inc \simplenews_count_subscriptions()

Count number of subscribers per newsletter list.

Return value

number of subscribers.

3 calls to simplenews_count_subscriptions()
SimpleNewsAdministrationTestCase::testSubscriptionManagement in tests/simplenews.test
Test newsletter subscription management.
simplenews_admin_categories in includes/simplenews.admin.inc
Menu callback: list admin form with list of available list categories.
simplenews_admin_issues in includes/simplenews.admin.inc
Form builder: Builds a list of newsletters with operations.
1 string reference to 'simplenews_count_subscriptions'
SimpleNewsAdministrationTestCase::testSubscriptionManagement in tests/simplenews.test
Test newsletter subscription management.

File

includes/simplenews.admin.inc, line 1703
Newsletter admin, subscription admin, simplenews settings

Code

function simplenews_count_subscriptions($tid) {
  $subscription_count =& drupal_static(__FUNCTION__);
  if (isset($subscription_count[$tid])) {
    return $subscription_count[$tid];
  }
  $query = db_select('simplenews_subscription', 'ss');
  $query
    ->leftJoin('simplenews_subscriber', 'sn', 'sn.snid = ss.snid');
  $query
    ->condition('tid', $tid)
    ->condition('sn.activated', 1)
    ->condition('status', SIMPLENEWS_SUBSCRIPTION_STATUS_SUBSCRIBED);
  $subscription_count[$tid] = $query
    ->countQuery()
    ->execute()
    ->fetchField();
  return $subscription_count[$tid];
}