diff options
author | Gábor Hojtsy <gabor@hojtsy.hu> | 2008-01-04 11:34:19 +0000 |
---|---|---|
committer | Gábor Hojtsy <gabor@hojtsy.hu> | 2008-01-04 11:34:19 +0000 |
commit | 9bc7c07cb71efcd941489a3fca7564b8f7709619 (patch) | |
tree | d242c1401a4259403adff3170c422a8569319347 /modules | |
parent | 89be29505b1ed6146aef314d5524f46cc289cee3 (diff) | |
download | brdo-9bc7c07cb71efcd941489a3fca7564b8f7709619.tar.gz brdo-9bc7c07cb71efcd941489a3fca7564b8f7709619.tar.bz2 |
#195161 by mcarbone with some modifications: only show 'login to post comments' if logging in actually lets you post comments
Diffstat (limited to 'modules')
-rw-r--r-- | modules/comment/comment.module | 40 |
1 files changed, 25 insertions, 15 deletions
diff --git a/modules/comment/comment.module b/modules/comment/comment.module index 0f820489c..2711bd90d 100644 --- a/modules/comment/comment.module +++ b/modules/comment/comment.module @@ -1757,23 +1757,33 @@ function theme_comment_thread_expanded($comment, $node) { */ function theme_comment_post_forbidden($node) { global $user; - if ($user->uid) { - return t("you can't post comments"); - } - else { - // we cannot use drupal_get_destination() because these links sometimes appear on /node and taxo listing pages - if (variable_get('comment_form_location_'. $node->type, COMMENT_FORM_SEPARATE_PAGE) == COMMENT_FORM_SEPARATE_PAGE) { - $destination = "destination=". drupal_urlencode("comment/reply/$node->nid#comment-form"); - } - else { - $destination = "destination=". drupal_urlencode("node/$node->nid#comment-form"); + static $authenticated_post_comments; + + if (!$user->uid) { + if (!isset($authenticated_post_comments)) { + // We only output any link if we are certain, that users get permission + // to post comments by logging in. We also locally cache this information. + $authenticated_post_comments = array_key_exists(DRUPAL_AUTHENTICATED_RID, user_roles(TRUE, 'post comments') + user_roles(TRUE, 'post comments without approval')); } + + if ($authenticated_post_comments) { + // We cannot use drupal_get_destination() because these links + // sometimes appear on /node and taxonomy listing pages. + if (variable_get('comment_form_location_'. $node->type, COMMENT_FORM_SEPARATE_PAGE) == COMMENT_FORM_SEPARATE_PAGE) { + $destination = 'destination='. drupal_urlencode("comment/reply/$node->nid#comment-form"); + } + else { + $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)))); + if (variable_get('user_register', 1)) { + // Users can register themselfs. + 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 { + // Only admins can add new users, no public registration. + return t('<a href="@login">Login</a> to post comments', array('@login' => url('user/login', array('query' => $destination)))); + } } } } |