Index: modules/comment/comment.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/comment/comment.module,v
retrieving revision 1.604
diff -u -p -r1.604 comment.module
--- modules/comment/comment.module	6 Dec 2007 09:58:30 -0000	1.604
+++ modules/comment/comment.module	7 Dec 2007 01:09:20 -0000
@@ -1639,11 +1639,14 @@ function theme_comment_post_forbidden($n
       $destination = "destination=". drupal_urlencode("node/$node->nid#comment-form");
     }
 
-    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', array('query' => $destination)), '@register' => url('user/register', array('query' => $destination))));
-    }
-    else {
-      return t('<a href="@login">Login</a> to post comments', array('@login' => url('user/login', array('query' => $destination))));
+    $rid = db_result(db_query("SELECT pid FROM {permission} WHERE perm LIKE '%%%s%%'", 'post comments'));
+    if (is_numeric($rid)) {
+      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', array('query' => $destination)), '@register' => url('user/register', array('query' => $destination))));
+      }
+      else {
+        return t('<a href="@login">Login</a> to post comments', array('@login' => url('user/login', array('query' => $destination))));
+      }
     }
   }
 }
