Commit 6652a47d authored by drumm's avatar drumm

#195161 by mcarbone with some modifications: only show 'login to post...

#195161 by mcarbone with some modifications: only show 'login to post comments' if logging in actually lets you post comments. Backport by salvis.
parent 00601140
......@@ -1809,23 +1809,33 @@ function theme_comment_thread_expanded($comment) {
function theme_comment_post_forbidden($nid) {
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', COMMENT_FORM_SEPARATE_PAGE) == COMMENT_FORM_SEPARATE_PAGE) {
$destination = "destination=". drupal_urlencode("comment/reply/$nid#comment-form");
}
else {
$destination = "destination=". drupal_urlencode("node/$nid#comment-form");
}
static $authenticated_post_comments;
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', $destination), '@register' => url('user/register', $destination)));
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'));
}
else {
return t('<a href="@login">Login</a> to post comments', array('@login' => url('user/login', $destination)));
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', COMMENT_FORM_SEPARATE_PAGE) == COMMENT_FORM_SEPARATE_PAGE) {
$destination = 'destination='. drupal_urlencode("comment/reply/$nid#comment-form");
}
else {
$destination = 'destination='. drupal_urlencode("node/$nid#comment-form");
}
if (variable_get('user_register', 1)) {
// Users can register themselves.
return t('<a href="@login">Login</a> or <a href="@register">register</a> to post comments', array('@login' => url('user/login', $destination), '@register' => url('user/register', $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', $destination)));
}
}
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment