2001-09-20 20:57:35 +00:00
<?php
2001-10-20 18:57:09 +00:00
// $Id$
2001-09-20 20:57:35 +00:00
function tracker_link($type) {
2001-10-11 18:54:35 +00:00
2001-09-20 20:57:35 +00:00
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;
2001-11-17 17:37:10 +00:00
$period = time() - 259200; // all comments of the past 3 days
2001-09-20 20:57:35 +00:00
if ($id) {
2001-11-17 17:37:10 +00:00
$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.timestamp > $period AND c.uid = '". check_input($id) ."' GROUP BY n.nid, n.title DESC ORDER BY last_comment DESC LIMIT 10");
2001-09-20 20:57:35 +00:00
}
else {
2001-11-17 17:37:10 +00:00
$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.timestamp > $period GROUP BY n.nid, n.title DESC ORDER BY last_comment DESC LIMIT 10");
2001-09-20 20:57:35 +00:00
}
while ($node = db_fetch_object($sresult)) {
2001-10-11 18:54:35 +00:00
$output .= format_plural($node->comments, "comment", "comments") ." ". t("attached to node") ." <a href=\"node.php?id=$node->nid\">". check_output($node->title) ."</a>:\n";
2001-09-20 20:57:35 +00:00
if ($id) {
2001-11-17 17:37:10 +00:00
$cresult = db_query("SELECT * FROM comments WHERE timestamp > $period AND uid = '". check_input($id) ."' AND lid = '$node->nid' ORDER BY cid DESC");
2001-09-20 20:57:35 +00:00
}
else {
2001-11-17 17:37:10 +00:00
$cresult = db_query("SELECT * FROM comments WHERE timestamp > $period AND lid = '$node->nid' ORDER BY cid DESC");
2001-09-20 20:57:35 +00:00
}
$output .= "<ul>";
while ($comment = db_fetch_object($cresult)) {
2001-10-11 18:54:35 +00:00
$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) .")</li>\n";
2001-09-20 20:57:35 +00:00
}
$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(" · ", $links) ."</div>";
}
function tracker_page() {
global $theme, $id;
$theme->header();
2001-10-11 18:54:35 +00:00
2001-09-20 20:57:35 +00:00
$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();
}
2001-11-01 11:00:51 +00:00
2001-09-20 20:57:35 +00:00
?>