Index: modules/comment.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/comment.module,v
retrieving revision 1.413
diff -u -p -r1.413 comment.module
--- modules/comment.module	6 Jan 2006 01:14:17 -0000	1.413
+++ modules/comment.module	7 Jan 2006 17:31:22 -0000
@@ -181,13 +181,15 @@ function comment_block($op = 'list', $de
 function comment_link($type, $node = 0, $main = 0) {
   $links = array();
 
+  $user_can_access = user_access('access comments');
+  $user_can_post = user_access('post comments');
+
   if ($type == 'node' && $node->comment) {
 
     if ($main) {
       // Main page: display the number of comments that have been posted.
-
-      if (user_access('access comments')) {
-        $all = comment_num_all($node->nid);
+      $all = comment_num_all($node->nid);
+      if ($user_can_access) {
         $new = comment_num_new($node->nid);
 
         if ($all) {
@@ -199,23 +201,28 @@ function comment_link($type, $node = 0, 
         }
         else {
           if ($node->comment == COMMENT_NODE_READ_WRITE) {
-            if (user_access('post comments')) {
+            if ($user_can_post) {
               $links[] = l(t('add new comment'), "comment/reply/$node->nid", array('title' => t('Add a new comment to this page.')));
             }
             else {
-              $links[] = theme('comment_post_forbidden');
+              $links[] = theme('comment_forbidden', 'post');
             }
           }
         }
       }
+      else {
+        // Change link message base on whether the node has comments
+        $links[] = $all ? theme('comment_forbidden', 'view') : theme('comment_forbidden', 'post');
+      }
     }
     else {
       // Node page: add a "post comment" link if the user is allowed to
       // post comments, if this node is not read-only, and if the comment form isn't already shown
 
       if ($node->comment == COMMENT_NODE_READ_WRITE && variable_get('comment_form_location', COMMENT_FORM_SEPARATE_PAGE) == COMMENT_FORM_SEPARATE_PAGE) {
-        if (user_access('post comments')) {
-          $links[] = l(t('add new comment'), "comment/reply/$node->nid", array('title' => t('Share your thoughts and opinions related to this posting.')), NULL, 'comment');
+        if ($user_can_post && $user_can_access) {
+          $links[] = $user_can_access ? theme('comment_forbidden', 'post') : theme('comment_forbidden', 'view');
+            //l(t('add new comment'), "comment/reply/$node->nid", array('title' => t('Share your thoughts and opinions related to this posting.')), NULL, 'comment');
         }
         else {
           $links[] = theme('comment_post_forbidden');
@@ -1561,17 +1568,25 @@ function theme_comment_thread_expanded($
   return $output;
 }
 
-function theme_comment_post_forbidden() {
+function theme_comment_forbidden($forbid_action = 'post') {
   global $user;
+  $forbid_action == 'post' ? $forbid_action = t('post') : $forbid_action = t('view');
+
   if ($user->uid) {
-    return t("you can't post comments");
+    return $forbid_action == 'post' ?
+      t("you can't post comments") :
+      t("you can't view comments");
   }
   else {
     if (variable_get('user_register', 1)) {
-      return t('<a href="%login">login</a> or <a href="%register">register</a> to post comments', array('%login' => url('user/login'), '%register' => url('user/register')));
+      return $forbid_action == 'post' ?
+        t('<a href="%login">login</a> or <a href="%register">register</a> to post comments', array('%login' => url('user/login'), '%register' => url('user/register'))) :
+        t('<a href="%login">login</a> or <a href="%register">register</a> to view comments', array('%login' => url('user/login'), '%register' => url('user/register')));
     }
     else {
-      return t('<a href="%login">login</a> to post comments', array('%login' => url('user/login')));
+      return $forbid_action == 'post' ?
+        t('<a href="%login">login</a> to view comments', array('%login' => url('user/login'))) :
+        t('<a href="%login">login</a> to post comments', array('%login' => url('user/login')));
     }
   }
 }
