From 749f15e7c0b55b12e1b95ad3a46e312d0e6c9c38 Mon Sep 17 00:00:00 2001
From: Dries Buytaert <dries@buytaert.net>
Date: Thu, 3 Mar 2005 20:02:07 +0000
Subject: [PATCH] - Modified patch #18328 by Neil: currently the two forum
 topic blocks share a number of topics in block setting. This is a bit
 confusing since configuring one blockshould not affect another block.  Fixed
 some indentation as well.

---
 database/updates.inc       |  9 ++++++++-
 modules/forum.module       | 22 ++++++++++------------
 modules/forum/forum.module | 22 ++++++++++------------
 3 files changed, 28 insertions(+), 25 deletions(-)

diff --git a/database/updates.inc b/database/updates.inc
index d5b9ed5c1b68..fc976c817119 100644
--- a/database/updates.inc
+++ b/database/updates.inc
@@ -101,7 +101,8 @@
   "2005-01-27" => "update_122",
   "2005-01-28" => "update_123",
   "2005-02-11" => "update_124",
-  "2005-02-23" => "update_125"
+  "2005-02-23" => "update_125",
+  "2005-03-03" => "update_126"
 );
 
 function update_32() {
@@ -2303,6 +2304,12 @@ function update_125() {
 
   return $ret;
 }
+
+function update_126() {
+  $ret[] = update_sql("DELETE FROM {variable} WHERE name LIKE 'forum_block_%'");
+  return $ret;
+}
+
 function update_sql($sql) {
   $edit = $_POST["edit"];
   $result = db_query($sql);
diff --git a/modules/forum.module b/modules/forum.module
index c51725530083..77a4d82e5ee8 100644
--- a/modules/forum.module
+++ b/modules/forum.module
@@ -308,29 +308,27 @@ function forum_block($op = 'list', $delta = 0, $edit = array()) {
       return $blocks;
 
     case 'configure':
-      $output = form_select(t('Number of topics in block'), 'forum_block_num', variable_get('forum_block_num', '5'), drupal_map_assoc(array(2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20)));
+      $output = form_select(t('Number of topics'), 'forum_block_num_'. $delta, variable_get('forum_block_num_'. $delta, '5'), drupal_map_assoc(array(2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20)));
       return $output;
 
     case 'save':
-      variable_set('forum_block_num', $edit['forum_block_num']);
+      variable_set('forum_block_num_'. $delta, $edit['forum_block_num_'. $delta]);
       break;
 
     case 'view':
       if (user_access('access content')) {
         switch ($delta) {
           case 0:
-           $title = t('Active forum topics');
-           $sql = "SELECT n.nid, n.title, l.last_comment_timestamp, l.comment_count FROM {node} n INNER JOIN {node_comment_statistics} l ON n.nid = l.nid WHERE n.status = 1 AND n.type='forum' ORDER BY l.last_comment_timestamp DESC";
-           $sql = db_rewrite_sql($sql);
-           $content  = node_title_list(db_query_range($sql, 0, variable_get('forum_block_num', '5')));
-           break;
+            $title = t('Active forum topics');
+            $sql = db_rewrite_sql("SELECT n.nid, n.title, l.last_comment_timestamp, l.comment_count FROM {node} n INNER JOIN {node_comment_statistics} l ON n.nid = l.nid WHERE n.status = 1 AND n.type='forum' ORDER BY l.last_comment_timestamp DESC");
+            $content = node_title_list(db_query_range($sql, 0, variable_get('forum_block_num_0', '5')));
+            break;
 
           case 1:
-           $title = t('New forum topics');
-           $sql = "SELECT n.nid, n.title, l.comment_count FROM {node} n INNER JOIN {node_comment_statistics} l ON n.nid = l.nid WHERE n.type = 'forum' AND n.status = 1 ORDER BY n.nid DESC";
-           $sql = db_rewrite_sql($sql);
-           $content .= node_title_list(db_query_range($sql, 0, variable_get('forum_block_num', '5')));
-           break;
+            $title = t('New forum topics');
+            $sql = db_rewrite_sql("SELECT n.nid, n.title, l.comment_count FROM {node} n INNER JOIN {node_comment_statistics} l ON n.nid = l.nid WHERE n.type = 'forum' AND n.status = 1 ORDER BY n.nid DESC");
+            $content = node_title_list(db_query_range($sql, 0, variable_get('forum_block_num_1', '5')));
+            break;
         }
 
         if ($content) {
diff --git a/modules/forum/forum.module b/modules/forum/forum.module
index c51725530083..77a4d82e5ee8 100644
--- a/modules/forum/forum.module
+++ b/modules/forum/forum.module
@@ -308,29 +308,27 @@ function forum_block($op = 'list', $delta = 0, $edit = array()) {
       return $blocks;
 
     case 'configure':
-      $output = form_select(t('Number of topics in block'), 'forum_block_num', variable_get('forum_block_num', '5'), drupal_map_assoc(array(2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20)));
+      $output = form_select(t('Number of topics'), 'forum_block_num_'. $delta, variable_get('forum_block_num_'. $delta, '5'), drupal_map_assoc(array(2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20)));
       return $output;
 
     case 'save':
-      variable_set('forum_block_num', $edit['forum_block_num']);
+      variable_set('forum_block_num_'. $delta, $edit['forum_block_num_'. $delta]);
       break;
 
     case 'view':
       if (user_access('access content')) {
         switch ($delta) {
           case 0:
-           $title = t('Active forum topics');
-           $sql = "SELECT n.nid, n.title, l.last_comment_timestamp, l.comment_count FROM {node} n INNER JOIN {node_comment_statistics} l ON n.nid = l.nid WHERE n.status = 1 AND n.type='forum' ORDER BY l.last_comment_timestamp DESC";
-           $sql = db_rewrite_sql($sql);
-           $content  = node_title_list(db_query_range($sql, 0, variable_get('forum_block_num', '5')));
-           break;
+            $title = t('Active forum topics');
+            $sql = db_rewrite_sql("SELECT n.nid, n.title, l.last_comment_timestamp, l.comment_count FROM {node} n INNER JOIN {node_comment_statistics} l ON n.nid = l.nid WHERE n.status = 1 AND n.type='forum' ORDER BY l.last_comment_timestamp DESC");
+            $content = node_title_list(db_query_range($sql, 0, variable_get('forum_block_num_0', '5')));
+            break;
 
           case 1:
-           $title = t('New forum topics');
-           $sql = "SELECT n.nid, n.title, l.comment_count FROM {node} n INNER JOIN {node_comment_statistics} l ON n.nid = l.nid WHERE n.type = 'forum' AND n.status = 1 ORDER BY n.nid DESC";
-           $sql = db_rewrite_sql($sql);
-           $content .= node_title_list(db_query_range($sql, 0, variable_get('forum_block_num', '5')));
-           break;
+            $title = t('New forum topics');
+            $sql = db_rewrite_sql("SELECT n.nid, n.title, l.comment_count FROM {node} n INNER JOIN {node_comment_statistics} l ON n.nid = l.nid WHERE n.type = 'forum' AND n.status = 1 ORDER BY n.nid DESC");
+            $content = node_title_list(db_query_range($sql, 0, variable_get('forum_block_num_1', '5')));
+            break;
         }
 
         if ($content) {
-- 
GitLab