1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
|
<?php
// $Id$
/**
* @file
* Install, update and uninstall functions for the forum module.
*/
/**
* Implement hook_install().
*/
function forum_install() {
// Create tables.
drupal_install_schema('forum');
// Set the weight of the forum.module to 1 so it is loaded after the taxonomy.module.
db_update('system')
->fields(array('weight' => 1))
->condition('name', 'forum')
->execute();
}
function forum_enable() {
if ($vocabulary = taxonomy_vocabulary_load(variable_get('forum_nav_vocabulary', 0))) {
// Existing install. Add back forum node type, if the forums
// vocabulary still exists. Keep all other node types intact there.
$vocabulary->nodes['forum'] = 1;
taxonomy_vocabulary_save($vocabulary);
}
else {
// 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.
$edit = array(
'name' => t('Forums'),
'multiple' => 0,
'required' => 0,
'hierarchy' => 1,
'relations' => 0,
'module' => 'forum',
'weight' => -10,
'nodes' => array('forum' => 1),
);
$vocabulary = (object) $edit;
taxonomy_vocabulary_save($vocabulary);
variable_set('forum_nav_vocabulary', $vocabulary->vid);
}
}
/**
* Implement hook_uninstall().
*/
function forum_uninstall() {
// Load the dependent Taxonomy module, in case it has been disabled.
drupal_load('module', 'taxonomy');
// Delete the vocabulary.
$vid = variable_get('forum_nav_vocabulary', 0);
taxonomy_vocabulary_delete($vid);
drupal_uninstall_schema('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_active');
variable_del('forum_block_num_new');
}
/**
* Implement hook_schema().
*/
function forum_schema() {
$schema['forum'] = array(
'description' => 'Stores the relationship of nodes to forum terms.',
'fields' => array(
'nid' => array(
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
'description' => 'The {node}.nid of the node.',
),
'vid' => array(
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
'description' => 'Primary Key: The {node}.vid of the node.',
),
'tid' => array(
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
'description' => 'The {taxonomy_term_data}.tid of the forum term assigned to the node.',
),
),
'indexes' => array(
'nid' => array('nid'),
'tid' => array('tid'),
),
'primary key' => array('vid'),
'foreign keys' => array(
'nid' => array('node' => 'nid'),
'vid' => array('node' => 'vid'),
),
);
return $schema;
}
|