? .project
? sites/all/modules/coder
? sites/all/modules/devel
? 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 22:28:32 -0000
@@ -715,6 +715,66 @@ function taxonomy_form_alter(&$form, $fo
 }
 
 /**
+ * Implemantation of hook_form_FORMID_alter().
+ *
+ * Adds vocabulary selection to node type settings.
+ */
+function taxonomy_form_node_type_form_alter(&$form, $form_state) {
+  if (isset($form_state['args'][0]->type)) {
+    $node_type = $form_state['args'][0]->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;
+        if (in_array($node_type, $voc->nodes)) {
+        	$voc_selected[$voc->vid] = $voc->vid;
+        }
+      }
+      $form['taxonomy'] = array(
+        '#title' => t('Taxonomy'),
+        '#type' => 'fieldset',
+        '#collapsible' => TRUE,
+        '#collapsed' => TRUE,
+        '#tree' => TRUE,
+      );
+      $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_selected = $form_state['values']['taxonomy']['vocabularies'];
+  $vocabularies = taxonomy_get_vocabularies();
+  foreach ($vocabularies as $voc) {
+    // Check for node type as new entry.
+    if ($voc_selected[$voc->vid] && !in_array($node_type, $voc->nodes)) {
+      $voc->nodes[$node_type] = $node_type;
+      taxonomy_vocabulary_save($voc);
+    }
+    // Check for node type as entry to remove.
+    elseif (!$voc_selected[$voc->vid] && in_array($node_type, $voc->nodes)) {
+      unset($voc->nodes[$node_type]);
+      taxonomy_vocabulary_save($voc);
+    }
+  }
+}
+
+/**
  * Helper function to convert terms after a preview.
  *
  * After preview the tags are an array instead of proper objects. This function
