? .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.483 diff -u -p -r1.483 taxonomy.module --- modules/taxonomy/taxonomy.module 2 Jul 2009 20:23:28 -0000 1.483 +++ modules/taxonomy/taxonomy.module 5 Jul 2009 14:04:06 -0000 @@ -716,6 +716,65 @@ function taxonomy_form_alter(&$form, $fo } /** + * Implement hook_form_FORM_ID_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; + $vocabularyabularies = taxonomy_get_vocabularies(); + // Only show vocabulary fieldset, when vocabularies exist. + if (count($vocabularyabularies)) { + $vocabulary_selected = array(); + $vocabulary_options = array(); + foreach ($vocabularyabularies as $vocabulary) { + $vocabulary_options[$vocabulary->vid] = $vocabulary->name; + if (in_array($node_type, $vocabulary->nodes)) { + $vocabulary_selected[$vocabulary->vid] = $vocabulary->vid; + } + } + $form['taxonomy'] = array( + '#title' => t('Taxonomy'), + '#type' => 'fieldset', + '#collapsible' => TRUE, + '#collapsed' => TRUE, + '#tree' => TRUE, + ); + $form['taxonomy']['vocabularies'] = array( + '#title' => t('Vocabularies enabled on content creation'), + '#type' => 'checkboxes', + '#multiple' => TRUE, + '#default_value' => $vocabulary_selected, + '#options' => $vocabulary_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']; + $vocabulary_selected = $form_state['values']['taxonomy']['vocabularies']; + $vocabularyabularies = taxonomy_get_vocabularies(); + foreach ($vocabularyabularies as $vocabulary) { + // Check for node type as new entry. + if ($vocabulary_selected[$vocabulary->vid] && !in_array($node_type, $vocabulary->nodes)) { + $vocabulary->nodes[$node_type] = $node_type; + taxonomy_vocabulary_save($vocabulary); + } + // Check for node type as entry to remove. + elseif (!$vocabulary_selected[$vocabulary->vid] && in_array($node_type, $vocabulary->nodes)) { + unset($vocabulary->nodes[$node_type]); + taxonomy_vocabulary_save($vocabulary); + } + } +} + +/** * Helper function to convert terms after a preview. * * After preview the tags are an array instead of proper objects. This function