function spam_logs_overview in Spam 5.3
Same name and namespace in other branches
- 5 spam.module \spam_logs_overview()
- 6 spam.module \spam_logs_overview()
Display an overview of the latest spam_log entries.
1 string reference to 'spam_logs_overview'
- spam_menu in ./
spam.module - Drupal _menu() hook.
File
- ./
spam.module, line 1864
Code
function spam_logs_overview($type = NULL, $id = NULL) {
drupal_set_title(t('Spam module logs'));
$header = array(
array(
'data' => t('type'),
'field' => 'content_type',
),
array(
'data' => t('id'),
'field' => 'content_id',
),
array(
'data' => t('date'),
'field' => 'lid',
'sort' => 'desc',
),
array(
'data' => t('message'),
'field' => 'message',
),
array(
'data' => t('user'),
'field' => 'uid',
),
array(
'data' => t('operations'),
),
);
if ($id) {
$sql = "SELECT * FROM {spam_log} WHERE content_type = '%s' AND content_id = %d";
$arguments = array(
$type,
$id,
);
}
else {
if ($type) {
$sql = "SELECT * FROM {spam_log} WHERE content_type = '%s'";
$arguments = array(
$type,
);
}
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)) {
$options = '';
if ($log->trid > 1) {
$options = l(t('trace'), "admin/logs/spam/{$log->trid}/trace") . ' | ';
}
$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->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);
}