You are here

function simplenews_statistics_admin_clicks in Simplenews Statistics 6

Same name and namespace in other branches
  1. 6.2 simplenews_statistics.module \simplenews_statistics_admin_clicks()

Newsletter clicks overview

1 string reference to 'simplenews_statistics_admin_clicks'
simplenews_statistics_menu in ./simplenews_statistics.module
Implementation of hook_menu().

File

./simplenews_statistics.module, line 233
Gathers newsletter statistics.

Code

function simplenews_statistics_admin_clicks(&$form_state, $nid = NULL) {
  $node = node_load($nid);
  drupal_set_title(check_plain($node->title) . ' Statistics');
  $form = array();
  $header = array(
    array(
      'data' => t('Url'),
      'field' => 'url',
      'sort' => 'desc',
    ),
    array(
      'data' => t('Email'),
      'field' => 'email',
      'sort' => 'desc',
    ),
    array(
      'data' => t('Date'),
      'field' => 'timestamp',
      'sort' => 'desc',
    ),
  );
  $sql = "SELECT * FROM {simplenews_statistics_clicks} 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->url,
      $view->email,
      format_date($view->timestamp, 'small'),
    );
  }
  if (!$rows) {
    $rows[] = array(
      array(
        'data' => t('No statistics available.'),
        'colspan' => '3',
      ),
    );
  }
  $table = theme('table', $header, $rows);
  $form['table'] = array(
    '#value' => $table,
  );
  $form['pager'] = array(
    '#value' => theme('pager', NULL, 50, 0),
  );
  return $form;
}