? .project
? sites/all/modules/.cvsignore
? sites/default/.DS_Store
? sites/default/files
? sites/default/settings.php
Index: modules/taxonomy/taxonomy.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/taxonomy/taxonomy.module,v
retrieving revision 1.481
diff -u -p -r1.481 taxonomy.module
--- modules/taxonomy/taxonomy.module	27 Jun 2009 19:49:07 -0000	1.481
+++ modules/taxonomy/taxonomy.module	28 Jun 2009 10:44:13 -0000
@@ -712,6 +712,69 @@ function taxonomy_form_alter(&$form, $fo
       $form['taxonomy']['#tree'] = TRUE;
     }
   }
+  if ($form_id == 'node_type_form' && isset($form_state['args'][0]->type)) {
+    $node_type = $form_state['args'][0]->type;
+    taxonomy_node_type_form($form, $form_state, $node_type);
+  }
+}
+
+/**
+ * Form for configuring available vocabularies for node type.
+ * @param $form
+ * @param $form_state
+ * @param $node_type
+ *   machine readable node type string
+ */
+function taxonomy_node_type_form(&$form, $form_state, $node_type) {
+  $vocabularies = taxonomy_get_vocabularies();
+  // Only show vocabulary fieldset, when vocabularies exist.
+  if (count($vocabularies)) {
+    $voc_selected = array();
+    $voc_options = array();
+    foreach ($vocabularies as $voc) {
+      $voc_options[$voc->vid] = $voc->name;
+      $voc_selected[$voc->vid] = (int) in_array($node_type, $voc->nodes);
+    }
+    $form['taxonomy'] = array(
+      '#title' => t('Taxonomy'),
+      '#type' => 'fieldset',
+      '#collapsible' => TRUE,
+      '#collapsed' => TRUE,
+      '#tree' => TRUE,
+    );
+    $form['taxonomy']['vocabularies_old'] = array(
+      '#type' => 'value',
+      '#value' => $voc_selected,
+    );
+    $form['taxonomy']['vocabularies'] = array(
+      '#title' => t('Vocabularies'),
+      '#type' => 'checkboxes',
+      '#multiple' => TRUE,
+      '#description' => t('Select vocabularies to categorize this node type.'),
+      '#default_value' => $voc_selected,
+      '#options' => $voc_options,
+    );
+    $form['#submit'][] = 'taxonomy_node_type_form_submit';
+  }
+}
+
+/**
+ * Submit function for managing vocabularies on node type form.
+ */
+function taxonomy_node_type_form_submit($form, &$form_state) {
+  $node_type = $form_state['values']['type'];
+  $voc_new = $form_state['values']['taxonomy']['vocabularies'];
+  $voc_old = $form_state['values']['taxonomy']['vocabularies_old'];
+  $vocabularies = taxonomy_get_vocabularies();
+  foreach ($vocabularies as $voc) {
+    if ($voc_new[$voc->vid]) {
+      $voc->nodes[$node_type] = $node_type;
+    }
+    else {
+      unset($voc->nodes[$node_type]);
+    }
+    taxonomy_vocabulary_save($voc);
+  }
 }
 
 /**
