The tracker module is a handy module for displaying the most recently added or updated content to a Drupal site. The link to the tracker is labeled recent posts in the user\'s navigation block. Updates include changes to the text by either the original author or someone else that has permission to edit the content, such as an editor or administrator as well as all comments added to an item.

The Tracker module presents a page listing the recently-updated content written by the user with the content type, the title, the user\'s name, how many comments that item has received, as well as how long ago it was updated. If an item was written by someone else, tracker will show that item at the top of the list. An example:

A user named Jessica writes a blog post, then some time passes, and others write blog posts. Then if John posts a comment to Jessica\'s post, and you have bookmarked John\'s tracker page (see below on how to do this) then Jessica\'s content will appear at the top.

If an user with administer comments (e.g. an administrator or editor of a site) deletes a comment (e.g. it is off-topic, inappropriate language, or unsolicited advertisement), the content item will drop down to when it was updated previous to that deleted comment.

To use the Tracker module to "watch" for a user\'s updated content, click on that user\'s profile, then the "track" tab.

'); case 'admin/modules#description': return t('Enables tracking of recent posts for users.'); } } /** * Implementation of hook_menu(). */ function tracker_menu($may_cache) { global $user; $items = array(); if ($may_cache) { $items[] = array('path' => 'tracker', 'title' => t('recent posts'), 'callback' => 'tracker_page', 'access' => user_access('access content'), 'weight' => 1); if ($user->uid) { $items[] = array('path' => 'tracker/all', 'title' => t('all recent posts'), 'type' => MENU_DEFAULT_LOCAL_TASK); $items[] = array('path' => 'tracker/'. $user->uid, 'title' => t('my recent posts'), 'type' => MENU_LOCAL_TASK); } } else { if (arg(0) == 'user' && is_numeric(arg(1))) { $items[] = array('path' => 'user/'. arg(1) .'/track', 'title' => t('track'), 'callback' => 'tracker_track_user', 'access' => user_access('access content'), 'type' => MENU_IS_LOCAL_TASK); $items[] = array('path' => 'user/'. arg(1) .'/track/posts', 'title' => t('track posts'), 'type' => MENU_DEFAULT_LOCAL_TASK); } } return $items; } /** * Menu callback. Prints a listing of active nodes on the site. */ function tracker_track_user() { if ($account = user_load(array('uid' => arg(1)))) { drupal_set_title($account->name); tracker_page($account->uid); } } /** * Menu callback. Prints a listing of active nodes on the site. */ function tracker_page($uid = 0) { global $user; $output .= ''; if ($uid) { $sql = 'SELECT DISTINCT(n.nid), n.title, n.type, n.changed, n.uid, u.name, l.last_comment_timestamp AS last_post, l.comment_count FROM {node} n INNER JOIN {node_comment_statistics} l ON n.nid = l.nid INNER JOIN {users} u ON n.uid = u.uid LEFT JOIN {comments} c ON n.nid = c.nid AND (c.status = 0 OR c.status IS NULL) WHERE n.status = 1 AND (n.uid = %d OR c.uid = %d) ORDER BY last_post DESC'; $sql = db_rewrite_sql($sql); $sql_count = 'SELECT COUNT(DISTINCT(n.nid)) FROM {node} n LEFT JOIN {comments} c ON n.nid = c.nid AND (c.status = 0 OR c.status IS NULL) WHERE n.status = 1 AND (n.uid = %d OR c.uid = %d)'; $sql_count = db_rewrite_sql($sql_count); $result = pager_query($sql, 25, 0, $sql_count, $uid, $uid); } else { $sql = 'SELECT DISTINCT(n.nid), n.title, n.type, n.changed, n.uid, u.name, l.last_comment_timestamp AS last_post, l.comment_count FROM {node} n INNER JOIN {users} u ON n.uid = u.uid INNER JOIN {node_comment_statistics} l ON n.nid = l.nid WHERE n.status = 1 ORDER BY last_post DESC'; $sql = db_rewrite_sql($sql); $sql_count = 'SELECT COUNT(n.nid) FROM {node} n WHERE n.status = 1'; $sql_count = db_rewrite_sql($sql_count); $result = pager_query($sql, 25, 0, $sql_count); } while ($node = db_fetch_object($result)) { // Determine the number of comments: $comments = 0; if (module_exist('comment') && $node->comment_count) { $comments = $node->comment_count; if ($new = comment_num_new($node->nid)) { $comments .= '
'; $comments .= l(t('%num new', array('%num' => $new)), "node/$node->nid", NULL, NULL, 'new'); } } $rows[] = array( node_invoke($node->type, 'node_name'), l($node->title, "node/$node->nid") .' '. theme('mark', node_mark($node->nid, $node->changed)), format_name($node), array('class' => 'replies', 'data' => $comments), t('%time ago', array('%time' => format_interval(time() - $node->last_post))) ); } if ($pager = theme('pager', NULL, 25, 0)) { $rows[] = array(array('data' => $pager, 'colspan' => '5')); } $header = array(t('Type'), t('Post'), t('Author'), t('Replies'), t('Last post')); $output .= '
'; $output .= theme('table', $header, $rows); $output .= '
'; print theme('page', $output); } ?>