You are here

function spam_logs_trace in Spam 6

Same name and namespace in other branches
  1. 5.3 spam.module \spam_logs_trace()

Trace all logs generated by the same page load.

1 string reference to 'spam_logs_trace'
spam_menu in ./spam.module
Drupal _menu() hook.

File

./spam.module, line 2071
Spam module, v3 Copyright(c) 2006-2008 Jeremy Andrews <jeremy@tag1consulting.com>. All rights reserved.

Code

function spam_logs_trace($trid = NULL) {
  if (!$trid) {
    return;
  }
  drupal_set_title(t('Spam module logs trace'));
  $breadcrumb[] = l(t('Home'), NULL);
  $breadcrumb[] = l(t('Administer'), 'admin');
  $breadcrumb[] = l(t('Logs'), 'admin/reports');
  $breadcrumb[] = l(t('Spam'), 'admin/reports/spam');
  $breadcrumb[] = l(t('Spam module log trace'), 'admin/reports/spam/trace');
  drupal_set_breadcrumb($breadcrumb);
  $header = array(
    array(
      'data' => t('type'),
      'field' => 'content_type',
    ),
    array(
      'data' => t('id'),
      'field' => 'content_id',
    ),
    array(
      'data' => t('date'),
      'field' => 'lid',
      'sort' => 'asc',
    ),
    array(
      'data' => t('function'),
      'field' => 'function',
    ),
    array(
      'data' => t('message'),
      'field' => 'message',
    ),
    array(
      'data' => t('user'),
      'field' => 'uid',
    ),
    array(
      'data' => t('operations'),
    ),
  );
  $sql = "SELECT * FROM {spam_log} WHERE trid = %d";
  $arguments = array(
    $trid,
  );
  $result = pager_query($sql . tablesort_sql($header), 50, 0, NULL, $arguments);
  while ($log = db_fetch_object($result)) {
    $options = l(t('detail'), "admin/reports/spam/{$log->lid}/detail");
    $rows[] = array(
      'data' => array(
        t($log->content_type),
        $log->content_id,
        format_date($log->timestamp, 'small'),
        truncate_utf8($log->function, 20) . (drupal_strlen($log->function) > 20 ? '...' : ''),
        truncate_utf8($log->message, 64) . (drupal_strlen($log->message) > 64 ? '...' : ''),
        theme('username', user_load(array(
          'uid' => $log->uid,
        ))),
        $options,
      ),
    );
  }
  if (!$rows) {
    $rows[] = array(
      array(
        'data' => t('No log messages available.'),
        'colspan' => 7,
      ),
    );
  }
  return theme('table', $header, $rows) . theme('pager', NULL, 50, 0);
}