From de7a91498ded38553b9a899bc3ef9c11eb4cd024 Mon Sep 17 00:00:00 2001
From: Alex Weber <alexweber15@gmail.com>
Date: Sat, 17 Dec 2011 01:40:52 -0200
Subject: [PATCH] #783230

fixed patch after incorrectly incrementing depth counter
---
 core/modules/forum/forum.admin.inc |    7 +++++++
 core/modules/forum/forum.module    |    7 ++++++-
 2 files changed, 13 insertions(+), 1 deletions(-)

diff --git a/core/modules/forum/forum.admin.inc b/core/modules/forum/forum.admin.inc
index 49c71d9..fbf8f25 100644
--- a/core/modules/forum/forum.admin.inc
+++ b/core/modules/forum/forum.admin.inc
@@ -207,6 +207,13 @@ function forum_confirm_delete_submit($form, &$form_state) {
  * @see system_settings_form()
  */
 function forum_admin_settings($form) {
+  $depths = drupal_map_assoc(range(0, 10));
+  $form['forum_limit_display_depth'] = array('#type' => 'select',
+    '#title' => t('Limit display depth'),
+    '#default_value' => variable_get('forum_limit_display_depth', 0),
+    '#options' => $depths,
+    '#description' => t("Limit depth of forums displayed on each page. This can help improve performance on sites with many sub-forums. Enter 0 if you don't want to impose a limit."),
+  );
   $number = drupal_map_assoc(array(5, 10, 15, 20, 25, 30, 35, 40, 50, 60, 80, 100, 150, 200, 250, 300, 350, 400, 500));
   $form['forum_hot_topic'] = array('#type' => 'select',
     '#title' => t('Hot topic threshold'),
diff --git a/core/modules/forum/forum.module b/core/modules/forum/forum.module
index 3575bfd..afc0221 100644
--- a/core/modules/forum/forum.module
+++ b/core/modules/forum/forum.module
@@ -769,7 +769,12 @@ function forum_forum_load($tid = NULL) {

   // Load the tree below.
   $forums = array();
-  $_forums = taxonomy_get_tree($vid, $tid);
+  if ($max_depth = variable_get('forum_limit_display_depth', 0)) {
+    $_forums = taxonomy_get_tree($vid, $tid, $max_depth);
+  }
+  else {
+    $_forums = taxonomy_get_tree($vid, $tid);
+  }

   if (count($_forums)) {
     $query = db_select('node', 'n');
--
1.7.4.4

