drupal/modules/tracker.module

94 lines
3.6 KiB
Plaintext
Raw Normal View History

<?php
// $Id$
function tracker_help() {
$output .= "<p>The tracker module is a handy module for displaying the most recent posts. By following the <i>view recent posts</i> link in the user block, a user may quickly review all recent postings.</p>";
return $output;
}
function tracker_system($field) {
$system["description"] = t("Enables tracking of recent posts for users.");
return $system[$field];
}
function tracker_link($type) {
2001-10-11 18:54:35 +00:00
2003-04-21 14:55:03 +00:00
$links = array();
if ($type == "menu.view" && user_access("access content")) {
$links[] = l(t("view recent posts"), "tracker", array("title" => t("Display an overview of the recent posts.")));
}
2003-04-21 14:55:03 +00:00
return $links;
}
function tracker_posts($id = 0) {
if ($id) {
- Bugfix: made request_uri() rewrite ( and ) with their entity equivalents to avoid XSS attacks! Patch by Al, Moshe, Marco, Kjartan and me. - Bugfix: the admin module does now import drupal.css prior to admin.css. Patch by me. - Bugfix: the admin module was still emitting a <base href=""> tag. I removed this as it is been taken care of by theme_head(); Patch by me. - Bugfix: made the tracker module's pager only consider published pages. Patch by Moshe. - Bugfix: cured some typos in the comment module's help function. Patch by Marco. - Bugfix: fixed a typo in the pager_display() that caused optional attributes to be discarded. - Bugfix: made the Xtemplate emit empty boxes like any other theme does. Patch by Al. - Bugfix: fixed broken link on the statistics module's log page. Reported by Kjartan. - CSS improvements: made the HTML output emitted by the tracker module look nicer. Patch by Moshe and Al. - CSS improvements: added CSS classes for form elements. Patch by Al. - CSS improvements: added a vertical gap between the last form item and the submit button. Patch by Al. Note that Opera 6 is not picking up this CSS but apparently others browsers such as Konqueror do. - Xtemplate improvements: changed the color of the selected day in the archive module's calendar. Patch by Al. - Usability improvements: made the "birthday" field of the profile module look nicer. Patch by Al. ------ - TODO: it might be a good idea to emit the following meta tag in the theme_head() function: <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> Currently, some themes (and modules!) emit this while others don't. This would also make it possible to change the charset site-wide. - TODO: now we added support for td.dark and td.light to drupal.css, maybe it can be removed from admin.css as well as xtemplate.css?
2003-06-03 18:04:47 +00:00
$sresult = pager_query("SELECT n.nid, n.title, n.type, n.changed, n.uid, u.name, MAX(GREATEST(n.changed, c.timestamp)) AS last_activity FROM node n LEFT JOIN comments c ON n.nid = c.nid LEFT JOIN users u ON n.uid = u.uid WHERE n.uid = '". check_query($id) ."' AND n.status = 1 GROUP BY n.nid, n.title, n.type, n.changed, n.uid, u.name ORDER BY last_activity DESC", 10, 0, "SELECT COUNT(nid) FROM node WHERE status = 1 AND uid = '". check_query($id) ."'");
}
else {
- Bugfix: made request_uri() rewrite ( and ) with their entity equivalents to avoid XSS attacks! Patch by Al, Moshe, Marco, Kjartan and me. - Bugfix: the admin module does now import drupal.css prior to admin.css. Patch by me. - Bugfix: the admin module was still emitting a <base href=""> tag. I removed this as it is been taken care of by theme_head(); Patch by me. - Bugfix: made the tracker module's pager only consider published pages. Patch by Moshe. - Bugfix: cured some typos in the comment module's help function. Patch by Marco. - Bugfix: fixed a typo in the pager_display() that caused optional attributes to be discarded. - Bugfix: made the Xtemplate emit empty boxes like any other theme does. Patch by Al. - Bugfix: fixed broken link on the statistics module's log page. Reported by Kjartan. - CSS improvements: made the HTML output emitted by the tracker module look nicer. Patch by Moshe and Al. - CSS improvements: added CSS classes for form elements. Patch by Al. - CSS improvements: added a vertical gap between the last form item and the submit button. Patch by Al. Note that Opera 6 is not picking up this CSS but apparently others browsers such as Konqueror do. - Xtemplate improvements: changed the color of the selected day in the archive module's calendar. Patch by Al. - Usability improvements: made the "birthday" field of the profile module look nicer. Patch by Al. ------ - TODO: it might be a good idea to emit the following meta tag in the theme_head() function: <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> Currently, some themes (and modules!) emit this while others don't. This would also make it possible to change the charset site-wide. - TODO: now we added support for td.dark and td.light to drupal.css, maybe it can be removed from admin.css as well as xtemplate.css?
2003-06-03 18:04:47 +00:00
$sresult = pager_query("SELECT n.nid, n.title, n.type, n.changed, n.uid, u.name, MAX(GREATEST(n.changed, c.timestamp)) AS last_activity FROM node n LEFT JOIN comments c ON n.nid = c.nid LEFT JOIN users u ON n.uid = u.uid WHERE n.status = 1 GROUP BY n.nid, n.title, n.type, n.changed, n.uid, u.name ORDER BY last_activity DESC", 10, 0, "SELECT COUNT(nid) FROM node WHERE status = 1");
}
$header = array(t("Type"), t("Title"), t("Author"));
while ($node = db_fetch_object($sresult)) {
if ($id) {
$cresult = db_query("SELECT c.*, u.name FROM comments c LEFT JOIN users u ON c.uid = u.uid WHERE c.uid = %d AND c.nid = %d AND c.status = 0 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.nid = %d AND c.status = 0 ORDER BY cid DESC", $node->nid);
}
$type = ucfirst(module_invoke($node->type, "node", "name"));
$title = l($node->title, "node/view/$node->nid") ." ". (node_is_new($node->nid, $node->changed) ? theme("theme_mark") : "");
$author = format_name($node);
$comments = array();
while ($comment = db_fetch_object($cresult)) {
$comments[] = "<li>". t("%subject by %author", array("%subject" => l($comment->subject, "node/view/$node->nid#$comment->cid"), "%author" => format_name($comment))). " ". (node_is_new($comment->nid, $comment->timestamp) ? theme("theme_mark") : "") ."</li>\n";
}
if ($comments) {
$comments = "<ul>". implode("\n", $comments) ."</ul>";
}
else {
$comments = "";
}
$rows[] = array(array("data" => $type, "class" => "type"), array("data" => $title . $comments, "class" => "content"), array("data" => $author, "class" => "author"));
}
2003-03-16 07:38:39 +00:00
if ($pager = pager_display(NULL, 10)) {
$rows[] = array(array("data" => $pager, "colspan" => 3));
}
$output = "<div id=\"tracker\">";
$output .= table($header, $rows);
$output .= "</div>";
return $output;
}
function tracker_user($type, &$edit, &$user) {
switch ($type) {
case "view_public":
if (user_access("access content")) {
return form_item(t("Recent posts"), l(t("view recent posts"), "tracker/$user->uid"));
}
}
}
function tracker_page() {
global $user;
if (user_access("access content")) {
theme("header", t("Recent activity"));
theme("box", t("Recent activity"), tracker_posts(arg(1)));
theme("footer");
}
}
?>