From 413a5fff4037f86324d9e237060035276446f6f1 Mon Sep 17 00:00:00 2001
From: heddn <lucashedding@1463982.no-reply.drupal.org>
Date: Thu, 7 Nov 2013 08:33:23 -0600
Subject: [PATCH] Issue #953214 by shawngo, mkadin, stevepurkiss, ifux,
 drupal_sensei, joachim, tim.plunkett, chintan.vyas, heddn: Shows 'login to
 post new content in the forum' even when it's not true.

---
 core/modules/comment/comment.module |  3 +--
 core/modules/forum/forum.module     | 21 ++++++++++++---------
 2 files changed, 13 insertions(+), 11 deletions(-)

diff --git a/core/modules/comment/comment.module b/core/modules/comment/comment.module
index f6ab885..4029de9 100644
--- a/core/modules/comment/comment.module
+++ b/core/modules/comment/comment.module
@@ -1536,8 +1536,7 @@ function theme_comment_post_forbidden($variables) {
     if (!isset($authenticated_post_comments)) {
       // We only output a link if we are certain that users will get permission
       // to post comments by logging in.
-      $comment_roles = user_roles(TRUE, 'post comments');
-      $authenticated_post_comments = isset($comment_roles[DRUPAL_AUTHENTICATED_RID]);
+      $authenticated_post_comments = user_role_has_permission(DRUPAL_AUTHENTICATED_RID, 'post comments');
     }
 
     if ($authenticated_post_comments) {
diff --git a/core/modules/forum/forum.module b/core/modules/forum/forum.module
index e860181..ec7f959 100644
--- a/core/modules/forum/forum.module
+++ b/core/modules/forum/forum.module
@@ -176,15 +176,18 @@ function forum_menu_local_tasks(&$data, $route_name) {
       }
       // Anonymous user does not have access to create new topics.
       else {
-        $links['login'] = array(
-          '#theme' => 'menu_local_action',
-          '#link' => array(
-            'title' => t('<a href="@login">Log in</a> to post new content in the forum.', array(
-              '@login' => url('user/login', array('query' => drupal_get_destination())),
-            )),
-            'localized_options' => array('html' => TRUE),
-          ),
-        );
+        // If authenticated users can post new topic, provide a login link.
+        if (user_role_load(DRUPAL_AUTHENTICATED_RID)->hasPermission('create forum content')) {
+          $links['login'] = array(
+            '#theme' => 'menu_local_action',
+            '#link' => array(
+              'title' => t('<a href="@login">Log in</a> to post new content in the forum.', array(
+                '@login' => url('user/login', array('query' => drupal_get_destination())),
+              )),
+              'localized_options' => array('html' => TRUE),
+            ),
+          );
+        }
       }
     }
     $data['actions'] += $links;
-- 
1.8.1.2

