You are here

function simplenews_get_filter in Simplenews 6

Same name and namespace in other branches
  1. 5 simplenews.module \simplenews_get_filter()
  2. 6.2 includes/simplenews.admin.inc \simplenews_get_filter()

Built filter selection box options and filter query where clause

Parameters

$type identification string:

$na TRUE for orphaned newsletters:

Return value

array of filter selection box options and related query where clause

1 call to simplenews_get_filter()
simplenews_admin_news in ./simplenews.admin.inc
Menu callback: Admin form for sent and draft newsletters.

File

./simplenews.admin.inc, line 1026
Newsletter admin, subscription admin, simplenews settings

Code

function simplenews_get_filter($type, $na = TRUE) {

  //Default data
  $names['all'] = t('all newsletters');
  $queries['all'] = '';
  if ($na) {
    $names['na'] = t('orphaned newsletters');
    $queries['na'] = ' AND s.tid = 0';
  }

  // Data for each newsletter
  foreach (taxonomy_get_tree(variable_get('simplenews_vid', '')) as $newsletter) {
    $names[$newsletter->tid] = $newsletter->name;
    $queries[$newsletter->tid] = ' AND s.tid = ' . $newsletter->tid;
  }
  return array(
    $names,
    $queries,
  );
}