You are here

function simplenews_user_is_subscribed in Simplenews 6

Same name and namespace in other branches
  1. 5 simplenews.module \simplenews_user_is_subscribed()
  2. 6.2 simplenews.module \simplenews_user_is_subscribed()
  3. 7.2 simplenews.module \simplenews_user_is_subscribed()
  4. 7 simplenews.module \simplenews_user_is_subscribed()

Check if the email address is subscribed to the given newsletter.

Parameters

string $mail email address:

integer $tid newsletter term id:

Return value

boolean TRUE = email address is subscribed to given newsletter term id

3 calls to simplenews_user_is_subscribed()
simplenews_block_form in ./simplenews.module
Newsletter (un)subscription form for authenticated and anonymous users.
simplenews_mail in ./simplenews.module
Implementation of hook_mail().
template_preprocess_simplenews_block in ./simplenews.module
Process variables to format the simplenews block.

File

./simplenews.module, line 1111
Simplnews node handling, sent email, newsletter block and general hooks

Code

function simplenews_user_is_subscribed($mail, $tid, $reset = FALSE) {
  static $subscribed = array();
  if ($reset) {
    unset($subscribed);
  }
  if (!isset($subscribed[$mail][$tid])) {
    $subscribed[$mail][$tid] = db_result(db_query("SELECT COUNT(*) FROM {simplenews_subscriptions} s INNER JOIN {simplenews_snid_tid} t ON s.snid = t.snid WHERE s.mail = '%s' AND t.tid = %d", $mail, $tid)) ? TRUE : FALSE;
  }
  return $subscribed[$mail][$tid];
}