You are here

function modr8_log_overview in modr8 6

Same name and namespace in other branches
  1. 5 modr8_admin.inc \modr8_log_overview()
  2. 7 modr8_admin.inc \modr8_log_overview()
1 call to modr8_log_overview()
modr8_log_view in ./modr8_admin.inc
menu callback for moderation log.

File

./modr8_admin.inc, line 564

Code

function modr8_log_overview($nid = 0) {
  $header = array(
    array(
      'data' => t('Action'),
    ),
    array(
      'data' => t('User'),
      'field' => 'u.name',
    ),
    array(
      'data' => t('Date'),
      'field' => 'ml.modid',
      'sort' => 'desc',
    ),
    array(
      'data' => t('Title (view event)'),
    ),
  );
  $tablesort = tablesort_sql($header);
  $count_sql = "SELECT COUNT(*) FROM {modr8_log} ml";
  $pager_sql = "SELECT ml.modid, ml.action, ml.title, ml.timestamp, u.name, u.uid FROM {modr8_log} ml LEFT JOIN {users} u ON u.uid = ml.uid";
  if ($nid) {
    $count_sql .= " WHERE ml.nid = %d";
    $pager_sql .= " WHERE ml.nid = %d";
  }
  $count_sql = db_rewrite_sql($count_sql, 'ml');
  $pager_sql = db_rewrite_sql($pager_sql, 'ml');
  $result = pager_query($pager_sql . $tablesort, 50, 0, $count_sql, $nid);
  $rows = array();
  while ($event = db_fetch_object($result)) {
    $rows[] = array(
      t($event->action),
      theme('username', $event),
      format_date($event->timestamp, 'small'),
      l(truncate_utf8($event->title, 50, TRUE, TRUE), 'admin/reports/modr8/event/' . $event->modid, array(), NULL, NULL, FALSE, TRUE),
    );
  }
  if (!$rows) {
    $rows[] = array(
      array(
        'data' => t('No log messages available.'),
        'colspan' => 4,
      ),
    );
  }
  $output = '';
  $output .= theme('table', $header, $rows);
  $output .= theme('pager', NULL, 50, 0);
  return $output;
}