function simplenews_admin_news in Simplenews 5
Same name and namespace in other branches
- 6.2 includes/simplenews.admin.inc \simplenews_admin_news()
- 6 simplenews.admin.inc \simplenews_admin_news()
1 string reference to 'simplenews_admin_news'
- simplenews_menu in ./
simplenews.module - Implementation of hook_menu().
File
- ./
simplenews.module, line 1700
Code
function simplenews_admin_news($action = 'sent') {
$vid = variable_get('simplenews_vid', '');
$form = array();
$form['simplenews_issue_filter'] = array(
'#type' => 'fieldset',
'#title' => t('Show issues from'),
'#collapsible' => FALSE,
'#prefix' => '<div class="container-inline">',
'#suffix' => '</div>',
);
$header = array(
t('Title'),
t('Newsletter'),
t('Date created'),
t('Published'),
t('Sent'),
t('Edit'),
);
list($names, $queries) = array_values(simplenews_get_filter('simplenews_newsletters_filter'));
if ($action == 'notsent') {
$form['simplenews_issue_filter']['filter'] = array(
'#type' => 'select',
'#options' => $names,
'#default_value' => $_SESSION['simplenews_newsletters_filter'],
);
$query = "SELECT DISTINCT n.*, s.s_status FROM {node} n INNER JOIN {simplenews_newsletters} s ON n.nid = s.nid WHERE s.s_status = %d" . $queries[$_SESSION['simplenews_newsletters_filter']] . " ORDER BY n.created DESC";
$count_query = "SELECT COUNT(n.nid) FROM {node} n INNER JOIN {simplenews_newsletters} s ON n.nid = s.nid WHERE s.s_status = %d" . $queries[$_SESSION['simplenews_newsletters_filter']];
}
else {
$form['simplenews_issue_filter']['filter'] = array(
'#type' => 'select',
'#options' => $names,
'#default_value' => $_SESSION['simplenews_newsletters_filter'],
);
$query = "SELECT n.*, s.s_status FROM {node} n INNER JOIN {simplenews_newsletters} s ON n.nid = s.nid WHERE s.s_status > %d" . $queries[$_SESSION['simplenews_newsletters_filter']] . " ORDER BY n.created DESC";
$count_query = "SELECT COUNT(n.nid) FROM {node} n INNER JOIN {simplenews_newsletters} s ON n.nid = s.nid WHERE s.s_status > %d" . $queries[$_SESSION['simplenews_newsletters_filter']];
}
$result = pager_query(db_rewrite_sql($query), 10, 0, db_rewrite_sql($count_query), 0);
while ($node = db_fetch_object($result)) {
$terms = array_keys(taxonomy_node_get_terms_by_vocabulary($node->nid, $vid, 'name'));
$rows[] = array(
l($node->title, 'node/' . $node->nid),
$terms[0] ? $terms[0] : t('n/a'),
format_date($node->created, 'small'),
theme('simplenews_status', $node->status, 'published'),
theme('simplenews_status', $node->s_status, 'sent'),
l(t('edit'), 'node/' . $node->nid . '/edit', array(), drupal_get_destination()),
);
}
if ($pager = theme('pager', NULL, 10, 0)) {
$rows[] = array(
array(
'data' => $pager,
'colspan' => '6',
),
);
}
if (!$rows) {
$rows[] = array(
array(
'data' => t('No newsletters available.'),
'colspan' => '6',
),
);
}
$form['simplenews_issue_filter']['submit'] = array(
'#type' => 'submit',
'#value' => t('Filter'),
);
$table = theme('table', $header, $rows);
$form['table'] = array(
'#value' => $table,
);
return $form;
}