forum_enable()modules/forum/forum.install, line 22
<?php
function forum_enable() {
// 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',
'description' => t('Forum navigation vocabulary'),
'hierarchy' => 1,
'module' => 'forum',
'weight' => -10,
);
$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,
'object_type' => 'node',
'label' => $vocabulary->name,
'bundle' => 'forum',
'widget' => array(
'type' => 'options_select',
),
);
field_create_instance($instance);
variable_set('forum_nav_vocabulary', $vocabulary->vid);
}
}
?>