? .DS_Store
? 983632-comment-mark-2.patch
Index: modules/comment/comment.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/comment/comment.module,v
retrieving revision 1.929
diff -u -p -r1.929 comment.module
--- modules/comment/comment.module	18 Dec 2010 01:50:15 -0000	1.929
+++ modules/comment/comment.module	28 Dec 2010 08:33:24 -0000
@@ -1704,7 +1704,7 @@ class CommentController extends DrupalDe
     // Setup standard comment properties.
     foreach ($comments as $key => $comment) {
       $comment->name = $comment->uid ? $comment->registered_name : $comment->name;
-      $comment->new = node_mark($comment->nid, $comment->changed);
+      $comment->new = comment_mark($comment->nid, $comment->changed, $comment->created);
       $comment->node_type = 'comment_node_' . $comment->node_type;
       $comments[$key] = $comment;
     }
@@ -1713,6 +1713,34 @@ class CommentController extends DrupalDe
 }
 
 /**
+ * Decide on the type of marker to be displayed for a comment of a given node.
+ *
+ * @param $nid
+ *   Comment's node ID whose history supplies the "last viewed" timestamp.
+ * @param $changed
+ *   Time when the comment was last updated, which is compared against node's "last viewed" timestamp.
+ * @param $created
+ *   Time when the comment was created, which is compared against node's "last viewed" timestamp.
+ * @return
+ *   One of the MARK constants.
+ */
+function comment_mark($nid, $changed, $created) {
+  global $user;
+  if (!$user->uid) {
+    return MARK_READ;
+  }
+
+  $timestamp = node_last_viewed($nid);
+  if ($timestamp != 0 && $created > $cache[$nid] && $created > NODE_NEW_LIMIT) {
+    return MARK_NEW;
+  }
+  elseif ($timestamp != 0 && $changed > $cache[$nid] && $changed > NODE_NEW_LIMIT) {
+    return MARK_UPDATED;
+  }
+  return MARK_READ;
+}
+
+/**
  * Get number of new comments for current user and specified node.
  *
  * @param $nid
@@ -2272,7 +2300,7 @@ function template_preprocess_comment(&$v
   $variables['created']   = format_date($comment->created);
   $variables['changed']   = format_date($comment->changed);
 
-  $variables['new']       = !empty($comment->new) ? t('new') : '';
+  $variables['new']       = !empty($comment->new) ? theme('mark', array('type' => $comment->new)) : '';
   $variables['picture']   = theme_get_setting('toggle_comment_user_picture') ? theme('user_picture', array('account' => $comment)) : '';
   $variables['signature'] = $comment->signature;
 
Index: modules/comment/comment.test
===================================================================
RCS file: /cvs/drupal/drupal/modules/comment/comment.test,v
retrieving revision 1.96
diff -u -p -r1.96 comment.test
--- modules/comment/comment.test	18 Dec 2010 01:50:16 -0000	1.96
+++ modules/comment/comment.test	28 Dec 2010 08:33:25 -0000
@@ -473,6 +473,38 @@ class CommentInterfaceTest extends Comme
     $this->assertEqual($node->last_comment_uid, 0, t('The value of node last_comment_uid is zero.'));
     $this->assertEqual($node->comment_count, 2, t('The value of node comment_count is 2.'));
   }
+
+  /**
+   * Tests new comments markers.
+   */
+  public function testCommentNewCommentsIndicator() {
+    // Test if the right links are displayed when no comment is present for the node.
+    $this->drupalLogin($this->admin_user);
+    $this->drupalGet('node');
+    $this->assertLink(t('Add new comment'));
+    $this->assertNoLink(t('@count comments', array('@count' => 0)));
+    $this->assertNoLink(t('@count new comments', array('@count' => 0)));
+
+    // Post comment with admin user.
+    $this->postComment($this->node, $this->randomName());
+    $this->drupalGet('node');
+    $this->drupalLogout();
+
+    // Login whith web user and check links.
+    $this->drupalLogin($this->web_user);
+    $this->drupalGet('node');
+    $this->assertNoLink(t('Add new comment'));
+    $this->assertLink(t('1 new comment'));
+    $this->clickLink(t('1 new comment'));
+    $this->assertRaw('<span class="new">' . t('new') . '</span>', t('Found "new" marker.'));
+    $this->assertTrue($this->xpath('//a[@id=:new]/following-sibling::a[1][@id=:comment_id]', array(':new' => 'new', ':comment_id' => 'comment-1')), t('The "new" anchor is positioned at the right comment.'));
+
+    // Test if "new comment" link is correctly removed.
+    $this->drupalGet('node');
+    $this->assertLink(t('1 comment'));
+    $this->assertNoLink(t('1 new comment'));
+    $this->assertNoLink(t('@count new comments', array('@count' => 0)));
+  }
 }
 
 /**
Index: modules/node/node.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/node/node.module,v
retrieving revision 1.1333
diff -u -p -r1.1333 node.module
--- modules/node/node.module	15 Dec 2010 03:47:28 -0000	1.1333
+++ modules/node/node.module	28 Dec 2010 08:33:26 -0000
@@ -1403,11 +1403,13 @@ function node_show($node, $message = FAL
     drupal_set_title(t('Revision of %title from %date', array('%title' => $node->title, '%date' => format_date($node->revision_timestamp))), PASS_THROUGH);
   }
 
+  // For markup consistency with other pages, use node_view_multiple() rather than node_view().
+  $nodes = node_view_multiple(array($node->nid => $node), 'full');
+
   // Update the history table, stating that this user viewed this node.
   node_tag_new($node);
 
-  // For markup consistency with other pages, use node_view_multiple() rather than node_view().
-  return node_view_multiple(array($node->nid => $node), 'full');
+  return $nodes;
 }
 
 /**
