function simplenews_statistics_admin_opens in Simplenews Statistics 6
Same name and namespace in other branches
- 6.2 simplenews_statistics.module \simplenews_statistics_admin_opens()
Newsletter opens overview
1 string reference to 'simplenews_statistics_admin_opens'
- simplenews_statistics_menu in ./
simplenews_statistics.module - Implementation of hook_menu().
File
- ./
simplenews_statistics.module, line 202 - Gathers newsletter statistics.
Code
function simplenews_statistics_admin_opens(&$form_state, $nid = NULL) {
$node = node_load($nid);
drupal_set_title(check_plain($node->title) . ' Statistics');
$form = array();
$header = array(
array(
'data' => t('Email'),
'field' => 'email',
),
array(
'data' => t('Last open'),
'field' => 'timestamp',
'sort' => 'desc',
),
array(
'data' => t('Open(s)'),
'field' => 'opens',
),
);
$sql = "SELECT * FROM {simplenews_statistics_opens} WHERE nid = %d" . tablesort_sql($header);
$result = pager_query($sql, 50, 0, NULL, $nid);
$rows = array();
while ($view = db_fetch_object($result)) {
$rows[] = array(
$view->email,
format_date($view->timestamp, 'small'),
$view->opens,
);
}
if (!$rows) {
$rows[] = array(
array(
'data' => t('No statistics available.'),
'colspan' => '2',
),
);
}
$table = theme('table', $header, $rows);
$form['table'] = array(
'#value' => $table,
);
$form['pager'] = array(
'#value' => theme('pager', NULL, 50, 0),
);
return $form;
}