You are here

function spam_logs_trace in Spam 5.3

Same name and namespace in other branches
  1. 6 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 1951

Code

function spam_logs_trace($trid = NULL) {
  if (!$trid) {
    return;
  }
  drupal_set_title(t('Spam module logs trace'));
  $breadcrumb[] = array(
    'path' => '',
    'title' => t('Home'),
  );
  $breadcrumb[] = array(
    'path' => 'admin',
    'title' => t('Administer'),
  );
  $breadcrumb[] = array(
    'path' => 'admin/logs',
    'title' => t('Logs'),
  );
  $breadcrumb[] = array(
    'path' => 'admin/logs/spam',
    'title' => t('Spam'),
  );
  $breadcrumb[] = array(
    'path' => 'admin/logs/spam/trace',
    'title' => t('Spam module log trace'),
  );
  menu_set_location($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/logs/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) . (strlen($log->function) > 20 ? '...' : ''),
        truncate_utf8($log->message, 64) . (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' => 6,
      ),
    );
  }
  return theme('table', $header, $rows) . theme('pager', NULL, 50, 0);
}