From 91ccdda421835fe3091c9204d912a6dbd1a5d57a Mon Sep 17 00:00:00 2001 From: Angie Byron Date: Thu, 11 Feb 2010 03:29:22 +0000 Subject: #628244 by catch, bangpound, and yched: Remove magic taxonomy field creation in favour of consistency. --- modules/forum/forum.install | 32 +++++++++++++++++++++----------- 1 file changed, 21 insertions(+), 11 deletions(-) (limited to 'modules/forum') diff --git a/modules/forum/forum.install b/modules/forum/forum.install index 979acacc5..5fb0cc9e8 100644 --- a/modules/forum/forum.install +++ b/modules/forum/forum.install @@ -21,17 +21,9 @@ function forum_install() { } function forum_enable() { - // Get info on the field "taxonomy_forums". - $field_check = field_info_field("taxonomy_forums"); - if ($vocabulary = taxonomy_vocabulary_load(variable_get('forum_nav_vocabulary', 0))) { - // Save the vocabulary to create the default field instance. - taxonomy_vocabulary_save($vocabulary); - } - // Create fields if info on "taxonomy_forums" field turns out empty. - elseif (empty($field_check)) { - // Create the forum vocabulary if it does not exist. Assign the vocabulary - // a low weight so it will appear first in forum topic create and edit - // forms. + // Create the forum vocabulary if it does not exist. + $vocabulary = taxonomy_vocabulary_load(variable_get('forum_nav_vocabulary', 0)); + if (!$vocabulary) { $edit = array( 'name' => t('Forums'), 'machine_name' => 'forums', @@ -42,6 +34,24 @@ function forum_enable() { ); $vocabulary = (object) $edit; taxonomy_vocabulary_save($vocabulary); + variable_set('forum_nav_vocabulary', $vocabulary->vid); + } + + // Create the 'taxonomy_forums' field if it doesn't already exist. + if (!field_info_field('taxonomy_forums')) { + $field = array( + 'field_name' => 'taxonomy_' . $vocabulary->machine_name, + 'type' => 'taxonomy_term_reference', + 'settings' => array( + 'allowed_values' => array( + array( + 'vid' => $vocabulary->vid, + 'parent' => 0, + ), + ), + ), + ); + field_create_field($field); $instance = array( 'field_name' => 'taxonomy_' . $vocabulary->machine_name, -- cgit v1.2.3