You are here

function simplenews_recent_newsletters in Simplenews 6.2

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

Create a list of recent newsletters.

Parameters

integer $tid term id of selected newsletter:

integer $count number of newsletters in the list:

1 call to simplenews_recent_newsletters()
template_preprocess_simplenews_block in ./simplenews.module
Process variables to format the simplenews block.

File

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

Code

function simplenews_recent_newsletters($tid, $count = 5) {
  $result = db_query_range(db_rewrite_sql('
    SELECT n.nid, n.title, sn.s_status, n.created
    FROM {node} n
    INNER JOIN {term_node} t
      ON n.vid = t.vid
    INNER JOIN {simplenews_newsletters} sn
      ON n.nid = sn.nid
    WHERE (t.tid = %d
      AND n.status = %d)
      ORDER BY n.created DESC'), $tid, 1, 0, $count);
  $titles = array();
  while ($item = db_fetch_object($result)) {
    $titles[$item->nid]['data'] = l($item->title, 'node/' . $item->nid);
    $titles[$item->nid]['class'] = $item->s_status == SIMPLENEWS_STATUS_SEND_NOT ? 'newsletter-created' : 'newsletter-send';
  }
  return $titles;
}