You are here

function simplenews_get_filter in Simplenews 5

Same name and namespace in other branches
  1. 6.2 includes/simplenews.admin.inc \simplenews_get_filter()
  2. 6 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.module

File

./simplenews.module, line 1684

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,
  );
}