From 62fa5541dd2d865620a958722781f345af5f69f6 Mon Sep 17 00:00:00 2001 From: Dries Buytaert Date: Sun, 29 Dec 2002 18:31:46 +0000 Subject: [PATCH] - Added pager support to watchdog. Based on modified patch from Moshe. --- modules/watchdog.module | 10 ++++++++-- modules/watchdog/watchdog.module | 10 ++++++++-- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/modules/watchdog.module b/modules/watchdog.module index 9bd1de201a2..d09ab9e16a7 100644 --- a/modules/watchdog.module +++ b/modules/watchdog.module @@ -45,7 +45,7 @@ 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'"); - $result = db_query("SELECT w.*, u.name, u.uid FROM watchdog w LEFT JOIN users u ON w.uid = u.uid ". ($type ? $query[$type] : "") ." ORDER BY timestamp DESC LIMIT 1000"); + $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", 100); $output .= ""; $output .= " "; @@ -54,13 +54,19 @@ function watchdog_overview($type) { $output .= " "; } } + + if ($pager = pager_display(NULL, 100, 0, "admin")) { + $output .= " "; + } + $output .= "
" . t("date") . "" . t("message") . "" . t("user") . "" . t("operations") . "
". format_date($watchdog->timestamp, "small") ."". substr(strip_tags($watchdog->message), 0, 64) ."". format_name($watchdog) ."". la(t("details"), array("mod" => "watchdog", "op" => "view", "id" => $watchdog->wid)) ."
$pager
"; return $output; } function watchdog_view($id) { - $result = db_query("SELECT w.*, u.name, u.uid FROM watchdog w LEFT JOIN users u ON w.uid = u.uid WHERE w.wid = '$id'"); + + $result = db_query("SELECT w.*, u.name, u.uid FROM watchdog w LEFT JOIN users u ON w.uid = u.uid WHERE w.wid = '%d'", $id); if ($watchdog = db_fetch_object($result)) { $output .= ""; diff --git a/modules/watchdog/watchdog.module b/modules/watchdog/watchdog.module index 9bd1de201a2..d09ab9e16a7 100644 --- a/modules/watchdog/watchdog.module +++ b/modules/watchdog/watchdog.module @@ -45,7 +45,7 @@ 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'"); - $result = db_query("SELECT w.*, u.name, u.uid FROM watchdog w LEFT JOIN users u ON w.uid = u.uid ". ($type ? $query[$type] : "") ." ORDER BY timestamp DESC LIMIT 1000"); + $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", 100); $output .= "
"; $output .= " "; @@ -54,13 +54,19 @@ function watchdog_overview($type) { $output .= " "; } } + + if ($pager = pager_display(NULL, 100, 0, "admin")) { + $output .= " "; + } + $output .= "
" . t("date") . "" . t("message") . "" . t("user") . "" . t("operations") . "
". format_date($watchdog->timestamp, "small") ."". substr(strip_tags($watchdog->message), 0, 64) ."". format_name($watchdog) ."". la(t("details"), array("mod" => "watchdog", "op" => "view", "id" => $watchdog->wid)) ."
$pager
"; return $output; } function watchdog_view($id) { - $result = db_query("SELECT w.*, u.name, u.uid FROM watchdog w LEFT JOIN users u ON w.uid = u.uid WHERE w.wid = '$id'"); + + $result = db_query("SELECT w.*, u.name, u.uid FROM watchdog w LEFT JOIN users u ON w.uid = u.uid WHERE w.wid = '%d'", $id); if ($watchdog = db_fetch_object($result)) { $output .= "";