Index: modules/forum/forum.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/forum/forum.module,v
retrieving revision 1.572
diff -u -p -r1.572 forum.module
--- modules/forum/forum.module	8 Aug 2010 12:47:00 -0000	1.572
+++ modules/forum/forum.module	13 Aug 2010 05:53:20 -0000
@@ -91,14 +91,14 @@ function forum_menu() {
   $items['forum'] = array(
     'title' => 'Forums',
     'page callback' => 'forum_page',
-    'access arguments' => array('access content'),
+    'access arguments' => array('access forums'),
     'file' => 'forum.pages.inc',
   );
   $items['forum/%forum_forum'] = array(
     'title' => 'Forums',
     'page callback' => 'forum_page',
     'page arguments' => array(1),
-    'access arguments' => array('access content'),
+    'access arguments' => array('access forums'),
     'file' => 'forum.pages.inc',
   );
   $items['admin/structure/forum'] = array(
@@ -166,54 +166,57 @@ function forum_menu() {
  */
 function forum_menu_local_tasks_alter(&$data, $router_item, $root_path) {
   global $user;
-
-  // Add action link to 'node/add/forum' on 'forum' page.
-  if ($root_path == 'forum') {
-    $tid = (isset($router_item['page_arguments'][0]) ? $router_item['page_arguments'][0] : 0);
-    $forum_term = forum_forum_load($tid);
-    if ($forum_term) {
-      $vid = variable_get('forum_nav_vocabulary', 0);
-      $vocabulary = taxonomy_vocabulary_load($vid);
-
-      $links = array();
-      // Loop through all bundles for forum taxonomy vocabulary field.
-      $field = field_info_field('taxonomy_' . $vocabulary->machine_name);
-      foreach ($field['bundles']['node'] as $type) {
-        if (node_access('create', $type)) {
-          $links[$type] = array(
-            '#theme' => 'menu_local_action',
-            '#link' => array(
-              'title' => t('Add new @node_type', array('@node_type' => node_type_get_name($type))),
-              'href' => 'node/add/' . str_replace('_', '-', $type) . '/' . $forum_term->tid,
-            ),
-          );
-        }
-      }
-      if (empty($links)) {
-        // Authenticated user does not have access to create new topics.
-        if ($user->uid) {
-          $links['disallowed'] = array(
-            '#theme' => 'menu_local_action',
-            '#link' => array(
-              'title' => t('You are not allowed to post new content in the forum.'),
-            ),
-          );
+  if (user_access('access forums')) {
+    // Add action link to 'node/add/forum' on 'forum' page.
+    if ($root_path == 'forum') {
+      $tid = (isset($router_item['page_arguments'][0]) ? $router_item['page_arguments'][0] : 0);
+      $forum_term = forum_forum_load($tid);
+      if ($forum_term) {
+        $vid = variable_get('forum_nav_vocabulary', 0);
+        $vocabulary = taxonomy_vocabulary_load($vid);
+
+        $links = array();
+        // Loop through all bundles for forum taxonomy vocabulary field.
+        $field = field_info_field('taxonomy_' . $vocabulary->machine_name);
+        foreach ($field['bundles']['node'] as $type) {
+          if (node_access('create', $type)) {
+            $links[$type] = array(
+              '#theme' => 'menu_local_action',
+              '#link' => array(
+                'title' => t('Add new @node_type', array('@node_type' => node_type_get_name($type))),
+                'href' => 'node/add/' . str_replace('_', '-', $type) . '/' . $forum_term->tid,
+              ),
+            );
+          }
         }
-        // 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 (empty($links)) {
+          // Authenticated user does not have access to create new topics.
+          if ($user->uid) {
+            $links['disallowed'] = array(
+              '#theme' => 'menu_local_action',
+              '#link' => array(
+                'title' => t('You are not allowed to post new content in the forum.'),
+              ),
+            );
+          }
+          // 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),
+              ),
+            );
+          }
         }
+        $data['actions']['output'] = array_merge($data['actions']['output'], $links);
       }
-      $data['actions']['output'] = array_merge($data['actions']['output'], $links);
     }
+  } else {
+    drupal_access_denied();
   }
 }
 
@@ -470,12 +473,14 @@ function forum_node_info() {
  * Implements hook_permission().
  */
 function forum_permission() {
-  $perms = array(
+  return array(
+    'access forums' => array(
+      'title' => t('Access forums'),
+    ),
     'administer forums' => array(
       'title' => t('Administer forums'),
     ),
   );
-  return $perms;
 }
 
 /**
@@ -684,7 +689,7 @@ function forum_block_view($delta = '') {
   $block['subject'] = $title;
   // Cache based on the altered query. Enables us to cache with node access enabled.
   $block['content'] = drupal_render_cache_by_query($query, 'forum_block_view');
-  $block['content']['#access'] = user_access('access content');
+  $block['content']['#access'] = user_access('access forums');
   return $block;
 }
 
@@ -979,43 +984,47 @@ function template_preprocess_forums(&$va
   drupal_set_breadcrumb($breadcrumb);
   drupal_set_title($title);
 
-  if ($variables['forums_defined'] = count($variables['forums']) || count($variables['parents'])) {
-    if (!empty($variables['forums'])) {
-      $variables['forums'] = theme('forum_list', $variables);
-    }
-    else {
-      $variables['forums'] = '';
-    }
+  if (user_access('access forums')) {
+    if ($variables['forums_defined'] = count($variables['forums']) || count($variables['parents'])) {
+      if (!empty($variables['forums'])) {
+        $variables['forums'] = theme('forum_list', $variables);
+      }
+      else {
+        $variables['forums'] = '';
+      }
 
-    if ($variables['tid'] && !in_array($variables['tid'], variable_get('forum_containers', array()))) {
-      $variables['topics'] = theme('forum_topic_list', $variables);
-      drupal_add_feed('taxonomy/term/' . $variables['tid'] . '/0/feed', 'RSS - ' . $title);
-    }
-    else {
-      $variables['topics'] = '';
-    }
+      if ($variables['tid'] && !in_array($variables['tid'], variable_get('forum_containers', array()))) {
+        $variables['topics'] = theme('forum_topic_list', $variables);
+        drupal_add_feed('taxonomy/term/' . $variables['tid'] . '/0/feed', 'RSS - ' . $title);
+      }
+      else {
+        $variables['topics'] = '';
+      }
+
+      // Provide separate template suggestions based on what's being output. Topic id is also accounted for.
+      // Check both variables to be safe then the inverse. Forums with topic ID's take precedence.
+      if ($variables['forums'] && !$variables['topics']) {
+        $variables['theme_hook_suggestions'][] = 'forums__containers';
+        $variables['theme_hook_suggestions'][] = 'forums__' . $variables['tid'];
+        $variables['theme_hook_suggestions'][] = 'forums__containers__' . $variables['tid'];
+      }
+      elseif (!$variables['forums'] && $variables['topics']) {
+        $variables['theme_hook_suggestions'][] = 'forums__topics';
+        $variables['theme_hook_suggestions'][] = 'forums__' . $variables['tid'];
+        $variables['theme_hook_suggestions'][] = 'forums__topics__' . $variables['tid'];
+      }
+      else {
+        $variables['theme_hook_suggestions'][] = 'forums__' . $variables['tid'];
+      }
 
-    // Provide separate template suggestions based on what's being output. Topic id is also accounted for.
-    // Check both variables to be safe then the inverse. Forums with topic ID's take precedence.
-    if ($variables['forums'] && !$variables['topics']) {
-      $variables['theme_hook_suggestions'][] = 'forums__containers';
-      $variables['theme_hook_suggestions'][] = 'forums__' . $variables['tid'];
-      $variables['theme_hook_suggestions'][] = 'forums__containers__' . $variables['tid'];
-    }
-    elseif (!$variables['forums'] && $variables['topics']) {
-      $variables['theme_hook_suggestions'][] = 'forums__topics';
-      $variables['theme_hook_suggestions'][] = 'forums__' . $variables['tid'];
-      $variables['theme_hook_suggestions'][] = 'forums__topics__' . $variables['tid'];
     }
     else {
-      $variables['theme_hook_suggestions'][] = 'forums__' . $variables['tid'];
+      drupal_set_title(t('No forums defined'));
+      $variables['forums'] = '';
+      $variables['topics'] = '';
     }
-
-  }
-  else {
-    drupal_set_title(t('No forums defined'));
-    $variables['forums'] = '';
-    $variables['topics'] = '';
+  } else {
+  drupal_access_denied();
   }
 }
 
Index: modules/forum/forum.test
===================================================================
RCS file: /cvs/drupal/drupal/modules/forum/forum.test,v
retrieving revision 1.61
diff -u -p -r1.61 forum.test
--- modules/forum/forum.test	9 Aug 2010 01:18:46 -0000	1.61
+++ modules/forum/forum.test	13 Aug 2010 05:53:20 -0000
@@ -25,9 +25,9 @@ class ForumTestCase extends DrupalWebTes
   function setUp() {
     parent::setUp('taxonomy', 'comment', 'forum');
     // Create users.
-    $this->admin_user = $this->drupalCreateUser(array('administer blocks', 'administer forums', 'administer menu', 'administer taxonomy', 'create forum content')); // 'access administration pages'));
-    $this->edit_any_topics_user = $this->drupalCreateUser(array('create forum content', 'edit any forum content', 'delete any forum content', 'access administration pages'));
-    $this->edit_own_topics_user = $this->drupalCreateUser(array('create forum content', 'edit own forum content', 'delete own forum content'));
+    $this->admin_user = $this->drupalCreateUser(array('administer blocks', 'administer forums', 'access forums', 'administer menu', 'administer taxonomy', 'create forum content')); // 'access administration pages'));
+    $this->edit_any_topics_user = $this->drupalCreateUser(array('access forums', 'create forum content', 'edit any forum content', 'delete any forum content', 'access administration pages'));
+    $this->edit_own_topics_user = $this->drupalCreateUser(array('access forums', 'create forum content', 'edit own forum content', 'delete own forum content'));
     $this->web_user = $this->drupalCreateUser(array());
   }
