From 7a1aee87c237402e64c7fa5324a288d059b83a34 Mon Sep 17 00:00:00 2001
From: Dries Buytaert <dries@buytaert.net>
Date: Thu, 20 Sep 2001 20:57:35 +0000
Subject: [PATCH] - added a new tracker.module (everybody kept nagging about
 the missing   "your drupal" feature). Tracker.module will be improved and
 expanded   during the process.

- renamed a link in user.module
---
 modules/tracker.module         | 67 ++++++++++++++++++++++++++++++++++
 modules/tracker/tracker.module | 67 ++++++++++++++++++++++++++++++++++
 modules/user.module            |  2 +-
 modules/user/user.module       |  2 +-
 4 files changed, 136 insertions(+), 2 deletions(-)
 create mode 100644 modules/tracker.module
 create mode 100644 modules/tracker/tracker.module

diff --git a/modules/tracker.module b/modules/tracker.module
new file mode 100644
index 000000000000..46d2fee48185
--- /dev/null
+++ b/modules/tracker.module
@@ -0,0 +1,67 @@
+<?php
+
+function tracker_link($type) {
+  if ($type == "menu") {
+    $links[] = "<a href=\"module.php?mod=tracker\">". t("recent comments") ."</a>";
+  }
+
+  return $links ? $links : array();
+}
+
+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 DESC ORDER BY n.nid DESC LIMIT 5");
+  }
+  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 DESC ORDER BY n.nid DESC LIMIT 5");
+  }
+
+  while ($node = db_fetch_object($sresult)) {
+    $output .= format_plural($node->count, "comment", "comments") ." ". t("attached to node") ." <a href=\"node.php?id=$node->nid\">". check_output($node->title) ."</a>:\n";
+
+    if ($id) {
+      $cresult = db_query("SELECT * FROM comments WHERE author = '". check_input($id) ."' AND lid = '$node->nid' ORDER BY cid DESC");
+    }
+    else {
+      $cresult = db_query("SELECT * FROM comments WHERE lid = '$node->nid' ORDER BY cid DESC");
+    }
+
+    $output .= "<ul>";
+    while ($comment = db_fetch_object($cresult)) {
+      $output .= "  <li><a href=\"node.php?id=$node->nid&cid=$comment->cid&pid=$comment->pid#$comment->cid\">". check_output($comment->subject) ."</a> (". t("replies") .": ". comment_num_replies($comment->cid) .", ". t("votes") .": $comment->votes, ". t("score") .": ". comment_score($comment) .")</li>\n";
+    }
+    $output .= " </ul>\n";
+  }
+
+  return $output;
+}
+
+function tracker_menu() {
+  global $user;
+
+  $links[] = "<a href=\"module.php?mod=tracker&id=$user->uid\">your recent comments</a>";
+  $links[] = "<a href=\"module.php?mod=tracker\">all recent comments</a>";
+
+  return "<div align=\"center\">". implode(" &middot; ", $links) ."</div>";
+}
+
+
+function tracker_page() {
+  global $theme, $id;
+
+  $theme->header();
+  $theme->box(t("Tracker"), tracker_menu());
+
+  if ($id) {
+    $theme->box(t("Your recent comments"), tracker_comments($id));
+  }
+  else {
+    $theme->box(t("All recent comments"), tracker_comments());
+  }
+
+  $theme->footer();
+}
+
+?>
diff --git a/modules/tracker/tracker.module b/modules/tracker/tracker.module
new file mode 100644
index 000000000000..46d2fee48185
--- /dev/null
+++ b/modules/tracker/tracker.module
@@ -0,0 +1,67 @@
+<?php
+
+function tracker_link($type) {
+  if ($type == "menu") {
+    $links[] = "<a href=\"module.php?mod=tracker\">". t("recent comments") ."</a>";
+  }
+
+  return $links ? $links : array();
+}
+
+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 DESC ORDER BY n.nid DESC LIMIT 5");
+  }
+  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 DESC ORDER BY n.nid DESC LIMIT 5");
+  }
+
+  while ($node = db_fetch_object($sresult)) {
+    $output .= format_plural($node->count, "comment", "comments") ." ". t("attached to node") ." <a href=\"node.php?id=$node->nid\">". check_output($node->title) ."</a>:\n";
+
+    if ($id) {
+      $cresult = db_query("SELECT * FROM comments WHERE author = '". check_input($id) ."' AND lid = '$node->nid' ORDER BY cid DESC");
+    }
+    else {
+      $cresult = db_query("SELECT * FROM comments WHERE lid = '$node->nid' ORDER BY cid DESC");
+    }
+
+    $output .= "<ul>";
+    while ($comment = db_fetch_object($cresult)) {
+      $output .= "  <li><a href=\"node.php?id=$node->nid&cid=$comment->cid&pid=$comment->pid#$comment->cid\">". check_output($comment->subject) ."</a> (". t("replies") .": ". comment_num_replies($comment->cid) .", ". t("votes") .": $comment->votes, ". t("score") .": ". comment_score($comment) .")</li>\n";
+    }
+    $output .= " </ul>\n";
+  }
+
+  return $output;
+}
+
+function tracker_menu() {
+  global $user;
+
+  $links[] = "<a href=\"module.php?mod=tracker&id=$user->uid\">your recent comments</a>";
+  $links[] = "<a href=\"module.php?mod=tracker\">all recent comments</a>";
+
+  return "<div align=\"center\">". implode(" &middot; ", $links) ."</div>";
+}
+
+
+function tracker_page() {
+  global $theme, $id;
+
+  $theme->header();
+  $theme->box(t("Tracker"), tracker_menu());
+
+  if ($id) {
+    $theme->box(t("Your recent comments"), tracker_comments($id));
+  }
+  else {
+    $theme->box(t("All recent comments"), tracker_comments());
+  }
+
+  $theme->footer();
+}
+
+?>
diff --git a/modules/user.module b/modules/user.module
index 826d61c9374e..87133ee06db2 100644
--- a/modules/user.module
+++ b/modules/user.module
@@ -230,7 +230,7 @@ function user_link($type) {
   }
 
   if ($type == "menu") {
-    $links[] = "<a href=\"module.php?mod=user&op=view\">". t("your account") ."</a>";
+    $links[] = "<a href=\"module.php?mod=user&op=view\">". t("account settings") ."</a>";
   }
 
   if ($type == "admin") {
diff --git a/modules/user/user.module b/modules/user/user.module
index 826d61c9374e..87133ee06db2 100644
--- a/modules/user/user.module
+++ b/modules/user/user.module
@@ -230,7 +230,7 @@ function user_link($type) {
   }
 
   if ($type == "menu") {
-    $links[] = "<a href=\"module.php?mod=user&op=view\">". t("your account") ."</a>";
+    $links[] = "<a href=\"module.php?mod=user&op=view\">". t("account settings") ."</a>";
   }
 
   if ($type == "admin") {
-- 
GitLab