You are here

function simplenews_count_spool in Simplenews 6.2

Same name and namespace in other branches
  1. 6 simplenews.module \simplenews_count_spool()
  2. 7.2 includes/simplenews.mail.inc \simplenews_count_spool()
  3. 7 includes/simplenews.mail.inc \simplenews_count_spool()

Count data in mail spool table.

Parameters

integer $nid newsletter node id:

integer $vid newsletter revision id:

string $status email sent status:

Return value

integer count of mail spool elements wich owns the attributes passed in as params

2 calls to simplenews_count_spool()
simplenews_admin_news in includes/simplenews.admin.inc
Menu callback: Admin form for sent and draft newsletters.
simplenews_send_status_update in includes/simplenews.mail.inc
Update newsletter sent status.

File

includes/simplenews.mail.inc, line 499
Simplenews email send and spool handling

Code

function simplenews_count_spool($nid, $vid, $status = array(
  SIMPLENEWS_SPOOL_PENDING,
  SIMPLENEWS_SPOOL_IN_PROGRESS,
)) {
  $clauses = array();
  $params = array();
  if (!is_array($status)) {
    $status = array(
      $status,
    );
  }
  foreach ($status as $s) {
    $clauses[] = 's.status = %d';
    $params[] = $s;
  }
  $params[] = $nid;
  $params[] = $vid;
  $query = "SELECT COUNT(nid)\n    FROM {simplenews_mail_spool} s\n    WHERE (" . implode(' OR ', $clauses) . ")\n    AND nid = %d\n    AND vid = %d";
  return db_result(db_query($query, $params));
}