--- \\Ninjapanda\webvcr\drupal-4.6.0\modules\forum.module Sun Jun 12 18:28:39 2005
+++ \\Ninjapanda\webvcr\modules\forum.module Sun Jun 12 18:43:19 2005
@@ -892,7 +892,7 @@
$rows[] = array(
array('data' => _forum_icon($topic->new, $topic->num_comments, $topic->comment_mode, $topic->sticky), 'class' => 'icon'),
array('data' => l($topic->title, "node/$topic->nid"), 'class' => 'topic'),
- array('data' => $topic->num_comments . ($topic->new_replies ? '
'. l(t('%a new', array('%a' => $topic->new_replies)), "node/$topic->nid", NULL, NULL, 'new') : ''), 'class' => 'replies'),
+ array('data' => $topic->num_comments . ($topic->new_replies ? '
'. l(t('%a new', array('%a' => $topic->new_replies)), "node/$topic->nid".comment_new_link($topic->num_comments,$topic->new_replies), NULL, NULL, 'new') : ''), 'class' => 'replies'),
array('data' => _forum_format($topic), 'class' => 'created'),
array('data' => _forum_format($topic->last_reply), 'class' => 'last-reply')
);
--- \\Ninjapanda\webvcr\drupal-4.6.0\modules\node.module Sun Jun 12 18:28:39 2005
+++ \\Ninjapanda\webvcr\modules\node.module Sun Jun 12 18:44:26 2005
@@ -78,8 +78,14 @@
* An HTML list suitable as content for a block.
*/
function node_title_list($result, $title = NULL) {
+ global $user;
while ($node = db_fetch_object($result)) {
- $items[] = l($node->title, 'node/'. $node->nid, $node->comment_count ? array('title' => format_plural($node->comment_count, '1 comment', '%count comments')) : '');
+ if ($node->comment_count && $user->uid) {
+ $new_link = comment_new_link($node->comment_count,comment_num_new($node->nid));
+ } else {
+ $new_link = '';
+ }
+ $items[] = l($node->title, 'node/'. $node->nid.$new_link, $node->comment_count ? array('title' => format_plural($node->comment_count, '1 comment', '%count comments')) : '', NULL, $new_link ? 'new' : '');
}
return theme('node_list', $items, $title);
--- \\Ninjapanda\webvcr\drupal-4.6.0\modules\tracker.module Sun Jun 12 18:28:39 2005
+++ \\Ninjapanda\webvcr\modules\tracker.module Sun Jun 12 18:45:20 2005
@@ -95,7 +95,7 @@
if ($new = comment_num_new($node->nid)) {
$comments .= '
';
- $comments .= l(t('%num new', array('%num' => $new)), "node/$node->nid", NULL, NULL, 'new');
+ $comments .= l(t('%num new', array('%num' => $new)), "node/$node->nid".comment_new_link($node->comment_count,$new), NULL, NULL, 'new');
}
}
--- \\Ninjapanda\webvcr\drupal-4.6.0\modules\comment.module Sun Jun 12 18:28:39 2005
+++ \\Ninjapanda\webvcr\modules\comment.module Sun Jun 12 18:50:28 2005
@@ -193,9 +193,8 @@
if ($all) {
$links[] = l(format_plural($all, '1 comment', '%count comments'), "node/$node->nid", array('title' => t('Jump to the first comment of this posting.')), NULL, 'comment');
-
if ($new) {
- $links[] = l(format_plural($new, '1 new comment', '%count new comments'), "node/$node->nid", array('title' => t('Jump to the first new comment of this posting.')), NULL, 'new');
+ $links[] = l(format_plural($new, '1 new comment', '%count new comments'), "node/$node->nid".comment_new_link($all,$new), array('title' => t('Jump to the first new comment of this posting.')), NULL, 'new');
}
}
else {
@@ -1665,6 +1664,24 @@
// no comments
else {
db_query("UPDATE {node_comment_statistics} SET comment_count = %d, last_comment_timestamp = %d, last_comment_name = '%s', last_comment_uid = %d WHERE nid = %d", 0, NULL, 0, 0, $nid);
+ }
+}
+
+/**
+ * Returns the end of a link to the last unread comment in a node, handles multiple pages of comments
+ * Parameters
+ * $num_comments - the overall number of comments
+ * $new_comments - the number of new comments
+ * Returns string to attach to a link to navigate to the last unread comment
+*/
+function comment_new_link($num_comments,$new_comments) {
+ global $user;
+ if ($user->uid) {
+ $comments_per_page = $user->comments_per_page = $user->comments_per_page ? $user->comments_per_page : ($_SESSION['comment_comments_per_page'] ? $_SESSION['comment_comments_per_page'] : variable_get('comment_default_per_page', '50'));
+ $start_comment = floor(($num_comments-$new_comments) / $comments_per_page)*$comments_per_page;
+ return "?from=$start_comment&comments_per_page=$comments_per_page";
+ } else {
+ return '';
}
}
?>