Newer
Older
Dries Buytaert
committed
<?php
Dries Buytaert
committed
/**
* Implementation of hook_install().
*/
Dries Buytaert
committed
function forum_install() {
Dries Buytaert
committed
// Create tables.
drupal_install_schema('forum');
Dries Buytaert
committed
}
Dries Buytaert
committed
function forum_enable() {
// 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.
$vid = variable_get('forum_nav_vocabulary', 0);
$vocabularies = taxonomy_get_vocabularies();
if (!isset($vocabularies[$vid])) {
$vocabulary = array(
'name' => t('Forums'),
'multiple' => 0,
'required' => 1,
'hierarchy' => 1,
'relations' => 0,
'module' => 'forum',
'weight' => -10,
'nodes' => array('forum' => 1),
);
taxonomy_save_vocabulary($vocabulary);
Dries Buytaert
committed
Dries Buytaert
committed
variable_set('forum_nav_vocabulary', $vocabulary['vid']);
}
}
/**
* Implementation of hook_uninstall().
*/
function forum_uninstall() {
Dries Buytaert
committed
$vid = variable_get('forum_nav_vocabulary', '');
// Delete the vocabulary.
taxonomy_del_vocabulary($vid);
Dries Buytaert
committed
db_query("DELETE FROM {node} WHERE type = 'forum'");
Dries Buytaert
committed
db_query('DROP TABLE {forum}');
variable_del('forum_containers');
variable_del('forum_nav_vocabulary');
variable_del('forum_hot_topic');
variable_del('forum_per_page');
variable_del('forum_order');
variable_del('forum_block_num_0');
variable_del('forum_block_num_1');
}
Dries Buytaert
committed
/**
* Implementation of hook_schema().
*/
function forum_schema() {
$schema['forum'] = array(
'description' => t('Stores the relationship of nodes to forum terms.'),
Dries Buytaert
committed
'fields' => array(
'nid' => array(
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
'description' => t('The {node}.nid of the node.'),
),
'vid' => array(
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
'description' => t('Primary Key: The {node}.vid of the node.'),
),
'tid' => array(
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
'description' => t('The {term_data}.tid of the forum term assigned to the node.'),
),