You are here

function spam_logs_overview in Spam 5

Same name and namespace in other branches
  1. 5.3 spam.module \spam_logs_overview()
  2. 6 spam.module \spam_logs_overview()

Displays an overview of the latest spam log entries.

Parameters

$source: The type of spam log entry to view.

$id: The specific set of log entries to view.

1 string reference to 'spam_logs_overview'
spam_menu in ./spam.module
Implementation of hook_menu().

File

./spam.module, line 1549

Code

function spam_logs_overview($source = NULL, $id = NULL) {
  drupal_set_title(t('Spam module logs'));
  $header = array(
    array(
      'data' => t('type'),
      'field' => 'source',
    ),
    array(
      'data' => t('id'),
      'field' => 'id',
    ),
    array(
      'data' => t('date'),
      'field' => 'timestamp',
    ),
    array(
      'data' => t('message'),
      'field' => 'entry',
    ),
    array(
      'data' => t('user'),
      'field' => 'uid',
    ),
    array(
      'data' => t('more'),
      'field' => 'sid',
      'sort' => 'desc',
    ),
  );
  if ($id) {
    $sql = "SELECT * FROM {spam_log} WHERE source = '%s' AND id = %d";
    $arguments = array(
      $source,
      $id,
    );
  }
  else {
    if ($source) {
      $sql = "SELECT * FROM {spam_log} WHERE source = '%s'";
      $arguments = array(
        $source,
      );
    }
    else {
      $sql = "SELECT * FROM {spam_log}";
      $arguments = array();
    }
  }
  $result = pager_query($sql . tablesort_sql($header), 50, 0, NULL, $arguments);
  while ($log = db_fetch_object($result)) {
    $rows[] = array(
      'data' => array(
        t($log->source),
        $log->id,
        format_date($log->timestamp, 'small'),
        truncate_utf8($log->entry, 64),
        theme('username', user_load(array(
          'uid' => $log->uid,
        ))),
        l(t('details'), "admin/content/spam/logs/entry/{$log->sid}"),
      ),
    );
  }
  if (!$rows) {
    $rows[] = array(
      array(
        'data' => t('No log messages available.'),
        'colspan' => 6,
      ),
    );
  }
  return theme('table', $header, $rows) . theme('pager', NULL, 50, 0);
}