diff options
Diffstat (limited to 'modules/watchdog/watchdog.module')
-rw-r--r-- | modules/watchdog/watchdog.module | 33 |
1 files changed, 24 insertions, 9 deletions
diff --git a/modules/watchdog/watchdog.module b/modules/watchdog/watchdog.module index 08863f15c..0d3165351 100644 --- a/modules/watchdog/watchdog.module +++ b/modules/watchdog/watchdog.module @@ -71,21 +71,36 @@ function watchdog_overview($type) { $color = array("user" => "#FFEEAA", "message" => "#FFFFFF", "special" => "#A49FFF", "warning" => "#FFAA22", "httpd" => "#99DD99", "error" => "#EE4C4C"); $query = array("user" => "WHERE type = 'user'", "regular" => "WHERE type = 'message'", "special" => "WHERE type = 'special'", "warning" => "WHERE type = 'warning'", "error" => "WHERE type = 'error'", "httpd" => "WHERE type = 'httpd'", "actions" => "WHERE link != ''"); - $result = pager_query("SELECT w.*, u.name, u.uid FROM {watchdog} w LEFT JOIN {users} u ON w.uid = u.uid ". ($type ? $query[$type] : "") ." ORDER BY w.timestamp DESC", 50); + $header = array( + array("data" => t("date"), "field" => "w.timestamp", "sort" => "desc"), + array("data" => t("event"), "field" => "w.message"), + array("data" => t("user"), "field" => "u.name"), + array("data" => t("operations"), "colspan" => "2") + ); + $sql = "SELECT w.*, u.name, u.uid FROM {watchdog} w LEFT JOIN {users} u ON w.uid = u.uid ". ($type ? $query[$type] : ""); + $sql .= tablesort_sql($header); + $result = pager_query($sql, 50); while ($watchdog = db_fetch_object($result)) { if ($background = $color[$watchdog->type]) { - $data .= " <tr style=\"background-color: $background\"><td>". format_date($watchdog->timestamp, "small") ."</td><td>". substr(strip_tags($watchdog->message), 0, 64) ."</td><td style=\"text-align: center;\">". format_name($watchdog) ."</td><td style=\"text-align: center;\">$watchdog->link</td><td style=\"text-align: center;\">". l(t("view details"), "admin/watchdog/view/$watchdog->wid") ."</td></tr>"; + $rows[] = array( + array("data" => format_date($watchdog->timestamp, "small"), "style" => "background-color: $background"), + array("data" => substr(strip_tags($watchdog->message), 0, 64), "style" => "background-color: $background"), + array("data" => format_name($watchdog), "style" => "background-color: $background"), + array("data" => $watchdog->link, "style" => "background-color: $background"), + array("data" => l(t("view details"), "admin/watchdog/view/$watchdog->wid"), "style" => "background-color: $background") + ); } } - $output .= "<table>"; - $output .= " <tr><th>" . t("date") . "</th><th>" . t("event") . "</th><th>" . t("user") . "</th><th colspan=\"2\">" . t("operations") . "</th></tr>"; - $output .= ($data ? $data : "<tr><td style=\"text-align: center;\" colspan=\"4\">". t("No system messages currently available.") ."</td></tr>"); - $output .= (($pager = pager_display(NULL, 50, 0, "admin")) ? "<tr><td style=\"text-align: center;\" colspan=\"4\">$pager</td></tr>" : ""); - $output .= "</table>"; - - return $output; + if (!$rows) { + $rows[] = array(array("data" => t("No <i>%s</i> messages currently available.", array("%s" => $type)), "colspan" => "5")); + } + $pager = pager_display(NULL, 50, 0, "admin", tablesort_pager()); + if (!empty($pager)) { + $rows[] = array(array("data" => $pager, "colspan" => "5")); + } + return table($header, $rows); } function watchdog_view($id) { |