drupal/modules/tracker.module

100 lines
4.8 KiB
Plaintext
Raw Normal View History

<?php
// $Id$
function tracker_help() {
$output .= "The tracker module is a handy module for displaying the most recent comments happenning all over your web site. By following the <i>view new comments</i> link in the user block, a user may quickly review all recent comments. When a user first arrives at the main tracker page, she sees all recent comments in reverse chronological order, grouped by post. In addition, a self-centered user may choose to display only his own comments.</p>";
return $output;
}
function tracker_link($type) {
2001-10-11 18:54:35 +00:00
if ($type == "menu.view" && user_access("access comments")) {
$links[] = lm(t("view new comments"), array("mod" => "tracker"), "", array("title" => t("Display an overview of the recent comments.")));
}
return $links ? $links : array();
}
function tracker_conf_options() {
$period = array(3600 => format_interval(3600), 10800 => format_interval(10800), 21600 => format_interval(21600), 32400 => format_interval(32400), 43200 => format_interval(43200), 86400 => format_interval(86400), 172800 => format_interval(172800), 259200 => format_interval(259200), 604800 => format_interval(604800), 1209600 => format_interval(1209600), 2419200 => format_interval(2419200), 1000000000 => "All");
$output .= form_select("Show comments more recent than", "tracker_period", variable_get("tracker_period", 259200), $period, "Comments younger than this get displayed.");
return $output;
}
function tracker_comments($id = 0) {
$period = time() - variable_get("tracker_period", 259200); // all comments of the past 3 days if not configured to a different value
if ($id) {
$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.nid = n.nid WHERE c.timestamp > $period AND c.uid = '%s' GROUP BY n.nid, n.title DESC ORDER BY last_comment DESC LIMIT 10", $id);
}
else {
- import.module: + Improved input filtering; this should make the news items look more consistent in terms of mark-up. + Quoted all array indices: converted all instances of $foo[bar] to $foo["bar"]. Made various other changes to make the import module compliant with the coding style. - theme.inc: + Fixed small XHTML glitch - comment system: + Made it possible for users to edit their comments (when certain criteria are matched). + Renamed the SQL table field "lid" to "nid" and updated the code to reflect this change: this is a rather /annoying/ change that has been asked for a few times. It will impact the contributed BBS/forum modules and requires a tiny SQL update: sql> ALTER TABLE comments CHANGE lid nid int(10) NOT NULL; + Moved most (all?) of the comment related logic from node.php to comment.module where it belongs. This also marks a first step towards removing/reducing "node.php". + Added a delete button to the comment admin form and made it so that Drupal prompts for confirmation prior to deleting a comment from the database. This behavior is similar to that of deleting nodes. + Disabled comment moderation for now. + Some of the above changes will make it easier to integrate the upcomcing mail-to-web and web-to-mail gateways. They are part of a bigger plan. ;) - node system: + Made it so that updating nodes (like for instance updating blog entries) won't trigger the submission rate throttle. + Fixed a small glitch where a node's title wasn't always passed to the $theme->header() function. + Made "node_array()" and "node_object()" more generic and named them "object2array()" and "array2object()". + Moved most (all?) of the comment related logic from node.php to comment.module where it belongs. This also marks a first step towards removing/reducing "node.php". - misc: + Applied three patches by Foxen. One to improve performance of the book module, and two other patches to fix small glitches in common.inc. Thanks Foxen!
2001-12-30 16:16:38 +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.nid = n.nid WHERE c.timestamp > $period GROUP BY n.nid, n.title DESC ORDER BY last_comment DESC LIMIT 10");
}
while ($node = db_fetch_object($sresult)) {
$output .= format_plural($node->comments, "comment", "comments") ." ". t("attached to node") ." ". l(check_output($node->title), array("id" => $node->nid)) .":\n";
if ($id) {
$cresult = db_query("SELECT c.*, u.name FROM comments c LEFT JOIN users u ON c.uid = u.uid WHERE c.timestamp > $period AND c.uid = '%d' AND c.nid = '%d' ORDER BY cid DESC", $id, $node->nid);
}
else {
$cresult = db_query("SELECT c.*, u.name FROM comments c LEFT JOIN users u ON c.uid = u.uid WHERE c.timestamp > $period AND c.nid = '%d' ORDER BY cid DESC", $node->nid);
}
$output .= "<ul>";
while ($comment = db_fetch_object($cresult)) {
2002-05-13 22:16:33 +00:00
$output .= " <li>". l(check_output($comment->subject), array("id" => $node->nid, "cid" => $comment->cid, "pid" => $comment->pid), "node", $comment->cid) ." by ". format_name($comment) ." (". t("replies") .": ". comment_num_replies($comment->cid) .") ". (comment_is_new($comment) ? "<span style=\"color: red;\">*</span>" : "") ."</li>\n";
}
$output .= " </ul>\n";
}
return $output;
}
function tracker_menu() {
global $user;
$links[] = lm(t("your recent comments"), array("mod" => "tracker", "id" => $user->uid), "", array("title" => t("Display an overview of your recent comments.")));
$links[] = lm(t("all recent comments"), array("mod" => "tracker"), "", array("title" => t("Display an overview of all the recent comments.")));
return "<div align=\"center\">". implode(" &middot; ", $links) ."</div>";
}
function tracker_page() {
global $theme, $id, $user;
if (user_access("access comments")) {
if ($id == $user->uid) {
$theme->header(t("Your recent comments"));
$theme->box(t("Tracker"), tracker_menu());
$theme->box(t("Your recent comments"), tracker_comments($id));
$theme->footer();
}
else if ($id) {
$account = user_load(array("uid" => $id));
$theme->header(t("%u's recent comments", array("%u" => $account->name)));
$theme->box(t("Tracker"), tracker_menu());
$theme->box(t("%u's recent comments", array("%u" => $account->name)), tracker_comments($id));
$theme->footer();
}
else {
$theme->header(t("All recent comments"));
$theme->box(t("Tracker"), tracker_menu());
$theme->box(t("All recent comments"), tracker_comments());
$theme->footer();
}
}
}
function tracker_user($type, &$edit, &$user) {
switch ($type) {
case "view_public":
case "view_private":
if (user_access("access comments")) {
return form_item(t("Comments"), lm(t("View recent comments."), array("mod" => "tracker", "id" => $user->uid)));
}
}
}
?>