From 7c6c3a65c13d8fd2cba4bc435149808b0a507368 Mon Sep 17 00:00:00 2001 From: Dries Buytaert Date: Thu, 11 Oct 2001 18:54:35 +0000 Subject: - improved the node sorting --- modules/tracker.module | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'modules/tracker.module') diff --git a/modules/tracker.module b/modules/tracker.module index 8fe01f194..462a649b4 100644 --- a/modules/tracker.module +++ b/modules/tracker.module @@ -1,6 +1,7 @@ ". t("recent comments") .""; } @@ -12,14 +13,14 @@ function tracker_comments($id = 0) { global $theme, $user; if ($id) { - $sresult = db_query("SELECT n.nid, n.title, COUNT(n.nid) AS count FROM comments c LEFT JOIN node n ON c.lid = n.nid WHERE c.author = '". check_input($id) ."' GROUP BY n.nid, n.title DESC ORDER BY c.timestamp DESC LIMIT 10"); + $sresult = db_query("SELECT n.nid, n.title, COUNT(n.nid) AS comments, MAX(c.timestamp) AS last_comment FROM comments c LEFT JOIN node n ON c.lid = n.nid WHERE c.author = '". check_input($id) ."' GROUP BY n.nid, n.title DESC ORDER BY last_comment DESC LIMIT 10"); } else { - $sresult = db_query("SELECT n.nid, n.title, COUNT(n.nid) AS count FROM comments c LEFT JOIN node n ON c.lid = n.nid GROUP BY n.nid, n.title DESC ORDER BY c.timestamp DESC LIMIT 10"); + $sresult = db_query("SELECT n.nid, n.title, COUNT(n.nid) AS comments, MAX(c.timestamp) AS last_comment FROM comments c LEFT JOIN node n ON c.lid = n.nid GROUP BY n.nid, n.title DESC ORDER BY last_comment DESC LIMIT 10"); } while ($node = db_fetch_object($sresult)) { - $output .= format_plural($node->count, "comment", "comments") ." ". t("attached to node") ." nid\">". check_output($node->title) .":\n"; + $output .= format_plural($node->comments, "comment", "comments") ." ". t("attached to node") ." nid\">". check_output($node->title) .":\n"; if ($id) { $cresult = db_query("SELECT * FROM comments WHERE author = '". check_input($id) ."' AND lid = '$node->nid' ORDER BY cid DESC"); @@ -30,7 +31,7 @@ function tracker_comments($id = 0) { $output .= "\n"; } @@ -52,6 +53,7 @@ function tracker_page() { global $theme, $id; $theme->header(); + $theme->box(t("Tracker"), tracker_menu()); if ($id) { -- cgit v1.2.3