Index: modules/forum/forum.install
===================================================================
RCS file: /cvs/drupal/drupal/modules/forum/forum.install,v
retrieving revision 1.11
diff -u -p -r1.11 forum.install
--- modules/forum/forum.install	10 Oct 2007 11:39:33 -0000	1.11
+++ modules/forum/forum.install	14 Nov 2007 19:06:05 -0000
@@ -19,7 +19,7 @@ function forum_enable() {
     $vocabulary = array(
       'name' => t('Forums'),
       'multiple' => 0,
-      'required' => 1,
+      'required' => 0,
       'hierarchy' => 1,
       'relations' => 0,
       'module' => 'forum',
Index: modules/forum/forum.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/forum/forum.module,v
retrieving revision 1.425
diff -u -p -r1.425 forum.module
--- modules/forum/forum.module	25 Oct 2007 15:32:55 -0000	1.425
+++ modules/forum/forum.module	14 Nov 2007 19:06:06 -0000
@@ -78,10 +78,6 @@ function forum_term_load($tid) {
  * Implementation of hook_menu().
  */
 function forum_menu() {
-  $items['node/add/forum'] = array(
-    'title' => 'Forum topic',
-    'access arguments' => array('create forum topics'),
-  );
   $items['forum'] = array(
     'title' => 'Forums',
     'page callback' => 'forum_page',
@@ -164,116 +160,114 @@ function forum_nodeapi(&$node, $op, $tea
   $vocabulary = taxonomy_vocabulary_load($vid);
 
   // Operate only on node types assigned for the forum vocabulary.
-  if (!in_array($node->type, $vocabulary->nodes)) {
-    return;
-  }
-
-  switch ($op) {
-    case 'view':
-      if ($page && $node->taxonomy) {
-        // Get the forum terms from the (cached) tree
-        $tree = taxonomy_get_tree($vid);
-        if ($tree) {
+  if (in_array($node->type, $vocabulary->nodes)) {
+    switch ($op) {
+      case 'view':
+        if ($page && taxonomy_node_get_terms_by_vocabulary($node, $vid) && $tree = taxonomy_get_tree($vid)) {
+          // Get the forum terms from the (cached) tree
           foreach ($tree as $term) {
             $forum_terms[] = $term->tid;
           }
-        }
-        foreach ($node->taxonomy as $term_id => $term) {
-          if (in_array($term_id, $forum_terms)) {
-            $node->tid = $term_id;
+          foreach ($node->taxonomy as $term_id => $term) {
+            if (in_array($term_id, $forum_terms)) {
+              $node->tid = $term_id;
+            }
           }
-        }
-        // Breadcrumb navigation
-        $breadcrumb[] = l(t('Home'), NULL);
-        $breadcrumb[] = l($vocabulary->name, 'forum');
-        if ($parents = taxonomy_get_parents_all($node->tid)) {
-          $parents = array_reverse($parents);
-          foreach ($parents as $p) {
-            $breadcrumb[] = l($p->name, 'forum/'.$p->tid);
+          // Breadcrumb navigation
+          $breadcrumb[] = l(t('Home'), NULL);
+          $breadcrumb[] = l($vocabulary->name, 'forum');
+          if ($parents = taxonomy_get_parents_all($node->tid)) {
+            $parents = array_reverse($parents);
+            foreach ($parents as $p) {
+              $breadcrumb[] = l($p->name, 'forum/'.$p->tid);
+            }
+          }
+          drupal_set_breadcrumb($breadcrumb);
+  
+          if (!$teaser) {
+            $node->content['forum_navigation'] = array(
+              '#value' => theme('forum_topic_navigation', $node),
+              '#weight' => 100,
+            );
           }
         }
-        drupal_set_breadcrumb($breadcrumb);
-
-        if (!$teaser) {
-          $node->content['forum_navigation'] = array(
-            '#value' => theme('forum_topic_navigation', $node),
-            '#weight' => 100,
-          );
+        return $node;
+        break;
+  
+      case 'prepare':
+        if (empty($node->nid)) {
+          // New topic
+          $node->taxonomy[arg(3)]->vid = $vid;
+          $node->taxonomy[arg(3)]->tid = arg(3);
         }
-      }
-      return $node;
-      break;
-
-    case 'prepare':
-      if (empty($node->nid)) {
-        // New topic
-        $node->taxonomy[arg(3)]->vid = $vid;
-        $node->taxonomy[arg(3)]->tid = arg(3);
-      }
-      return $node;
-      break;
-
-    // Check in particular that only a "leaf" term in the associated taxonomy
-    // vocabulary is selected, not a "container" term.
-    case 'validate':
-      if ($node->taxonomy) {
-        // Extract the node's proper topic ID.
-        $vocabulary = $vid;
-        $containers = variable_get('forum_containers', array());
-        foreach ($node->taxonomy as $term) {
-          if (db_result(db_query('SELECT COUNT(*) FROM {term_data} WHERE tid = %d AND vid = %d', $term, $vocabulary))) {
-            if (in_array($term, $containers)) {
+        return $node;
+        break;
+  
+      // Check in particular that only a "leaf" term in the associated taxonomy
+      // vocabulary is selected, not a "container" term.
+      case 'validate':
+        if ($node->taxonomy) {
+          // Extract the node's proper topic ID.
+          $vocabulary = $vid;
+          $containers = variable_get('forum_containers', array());
+          foreach ($node->taxonomy as $term) {
+            if (db_result(db_query('SELECT COUNT(*) FROM {term_data} WHERE tid = %d AND vid = %d', $term, $vocabulary)) && in_array($term, $containers)) {
               $term = taxonomy_get_term($term);
               form_set_error('taxonomy', t('The item %forum is only a container for forums. Please select one of the forums below it.', array('%forum' => $term->name)));
             }
           }
         }
-      }
-      break;
-
-    // Assign forum taxonomy when adding a topic from within a forum.
-    case 'presave':
-      // Make sure all fields are set properly:
-      $node->icon = !empty($node->icon) ? $node->icon : '';
-
-      if ($node->taxonomy) {
-        // Get the forum terms from the (cached) tree
-        $tree = taxonomy_get_tree($vid);
-        if ($tree) {
+        break;
+  
+      // Assign forum taxonomy when adding a topic from within a forum.
+      case 'presave':
+        // Make sure all fields are set properly:
+        $node->icon = !empty($node->icon) ? $node->icon : '';
+        // Get the forum terms from the (cached) tree if we have a taxonomy.
+        if ($node->taxonomy && $tree = taxonomy_get_tree($vid)) {
           foreach ($tree as $term) {
             $forum_terms[] = $term->tid;
           }
-        }
-        foreach ($node->taxonomy as $term_id) {
-          if (in_array($term_id, $forum_terms)) {
-            $node->tid = $term_id;
+          foreach ($node->taxonomy as $term_id) {
+            if (in_array($term_id, $forum_terms)) {
+              $node->tid = $term_id;
+            }
           }
-        }
-        $old_tid = db_result(db_query_range("SELECT t.tid FROM {term_node} t INNER JOIN {node} n ON t.vid = n.vid WHERE n.nid = %d ORDER BY t.vid DESC", $node->nid, 0, 1));
-        if ($old_tid) {
-          if (($node->tid != $old_tid) && $node->shadow) {
+          $old_tid = db_result(db_query_range("SELECT t.tid FROM {term_node} t INNER JOIN {node} n ON t.vid = n.vid WHERE n.nid = %d ORDER BY t.vid DESC", $node->nid, 0, 1));
+          if ($old_tid && isset($node->tid) && ($node->tid != $old_tid) && !empty($node->shadow)) {
             // A shadow copy needs to be created. Retain new term and add old term.
             $node->taxonomy[] = $old_tid;
           }
         }
-      }
-      break;
-    case 'update':
-      if (!$node->revision) {
-        db_query('UPDATE {forum} SET tid = %d WHERE vid = %d', $node->tid, $node->vid);
         break;
-      }
-      // Deliberate no break -- for new revisions we need an insert.
-    case 'insert':
-      db_query('INSERT INTO {forum} (tid, vid, nid) VALUES (%d, %d, %d)', $node->tid, $node->vid, $node->nid);
-      break;
-    case 'delete':
-      db_query('DELETE FROM {forum} WHERE nid = %d', $node->nid);
-      break;
-    case 'load':
-      return db_fetch_object(db_query('SELECT tid AS forum_tid FROM {forum} WHERE vid = %d', $node->vid));
-  }
 
+      case 'update':
+        if (!$node->revision && db_result(db_query('SELECT tid FROM {forum} WHERE nid=%d', $node->nid))) {
+          if (!empty($node->tid)) {
+            db_query('UPDATE {forum} SET tid = %d WHERE vid = %d', $node->tid, $node->vid);
+          }
+          // The node is removed from the forum.
+          else {
+            db_query('DELETE FROM {forum} WHERE nid = %d', $node->nid);
+          }
+          break;
+        }
+        // Deliberate no break -- for new revisions and for previously unassigned terms we need an insert.
+
+      case 'insert':
+        if (!empty($node->tid)) {
+          db_query('INSERT INTO {forum} (tid, vid, nid) VALUES (%d, %d, %d)', $node->tid, $node->vid, $node->nid);
+        }
+        break;
+
+      case 'delete':
+        db_query('DELETE FROM {forum} WHERE nid = %d', $node->nid);
+        break;
+
+      case 'load':
+        return db_fetch_object(db_query('SELECT tid AS forum_tid FROM {forum} WHERE vid = %d', $node->vid));
+    }
+  }
   return;
 }
 
@@ -354,13 +348,33 @@ function forum_form_alter(&$form, $form_
       );
       $form['nodes']['#required'] = TRUE;
       $form['hierarchy'] = array('#type' => 'value', '#value' => 1);
-      unset($form['relations']);
-      unset($form['tags']);
-      unset($form['multiple']);
-      unset($form['delete']);
-      $form['required'] = array('#type' => 'value', '#value' => 1);
+      $form['required'] = array('#type' => 'value', '#value' => FALSE);
+      $form['relations'] = array('#type' => 'value', '#value' => FALSE);
+      $form['tags'] = array('#type' => 'value', '#value' => FALSE);
+      $form['multiple'] = array('#type' => 'value', '#value' => FALSE);
+      unset($form['delete']);    
     }
   }
+  if ($form_id == 'forum_node_form') {
+    // Make the vocabulary required for 'real' forum-nodes.
+    // We use #process to rename the first option from the vocabulary.
+    $vid = variable_get('forum_nav_vocabulary', '');
+    $form['taxonomy'][$vid] = array(
+      '#required' => TRUE,
+      '#process' => array('_forum_require_vocabulary'));
+  }
+}
+
+/**
+ * Helper function for forum_form_alter().
+ *
+ * All types of nodes can be added to the forum, but in case of a 'real' forum-node
+ * the selection of a topic is required. This function replace '- None selected -' as option 
+ * for '- Please choose -' when creating a 'real' forum node.
+ */
+function _forum_require_vocabulary($element) {
+  $element['#options'][''] = t('- Please choose -');
+  return $element;
 }
 
 /**
Index: modules/system/system.install
===================================================================
RCS file: /cvs/drupal/drupal/modules/system/system.install,v
retrieving revision 1.180
diff -u -p -r1.180 system.install
--- modules/system/system.install	14 Nov 2007 15:24:16 -0000	1.180
+++ modules/system/system.install	14 Nov 2007 19:06:08 -0000
@@ -4539,6 +4539,18 @@ function system_update_6037() {
 }
 
 /**
+ * Change forum vocabulary not to be required by default.
+ */
+function system_update_6037() {
+  $ret = array();
+  $vid = intval(variable_get('forum_nav_vocabulary', ''));
+  if (db_table_exists('vocabulary') && $vid) {
+    $ret[] = update_sql("UPDATE {vocabulary} SET required = 0 WHERE vid = " . $vid);
+  }
+  return $ret;
+}
+
+/**
  * @} End of "defgroup updates-5.x-to-6.x"
  * The next series of updates should start at 7000.
  */
Index: modules/taxonomy/taxonomy.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/taxonomy/taxonomy.module,v
retrieving revision 1.391
diff -u -p -r1.391 taxonomy.module
--- modules/taxonomy/taxonomy.module	14 Nov 2007 13:39:58 -0000	1.391
+++ modules/taxonomy/taxonomy.module	14 Nov 2007 19:06:08 -0000
@@ -481,9 +481,17 @@ function taxonomy_form_alter(&$form, $fo
             $default_terms[$term->tid] = $term;
           }
         }
-        $form['taxonomy'][$vocabulary->vid] = taxonomy_form($vocabulary->vid, array_keys($default_terms), $vocabulary->help);
-        $form['taxonomy'][$vocabulary->vid]['#weight'] = $vocabulary->weight;
-        $form['taxonomy'][$vocabulary->vid]['#required'] = $vocabulary->required;
+        // Modules can already create this form before we alter it here. If so, we already have an array.
+        // If not, we have to declare it as an array or else we will get a fatal error' because we
+        // use '+=' to avoid overwriting previous values.
+        if (!isset($form['taxonomy'][$vocabulary->vid])) {
+          $form['taxonomy'][$vocabulary->vid] = array();
+        }
+        $form['taxonomy'][$vocabulary->vid] += taxonomy_form($vocabulary->vid, array_keys($default_terms), $vocabulary->help);
+        $form['taxonomy'][$vocabulary->vid] += array(
+          '#required' => $vocabulary->required,
+          '#weight' => $vocabulary->weight,
+        );
       }
     }
     if (!empty($form['taxonomy']) && is_array($form['taxonomy'])) {
@@ -977,7 +985,6 @@ function _taxonomy_term_select($title, $
     '#description' => $description,
     '#multiple' => $multiple,
     '#size' => $multiple ? min(9, count($options)) : 0,
-    '#weight' => -15,
     '#theme' => 'taxonomy_term_select',
   );
 }
