summaryrefslogtreecommitdiff
path: root/modules/forum/forum.install
blob: 71f606eb6f3a993c67688c3d43b3d9eb81c5783e (plain)
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
<?php
// $Id$

/**
 * Implementation of hook_install().
 */
function forum_install() {
  // Create tables.
  drupal_install_schema('forum');
}

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);

    variable_set('forum_nav_vocabulary', $vocabulary['vid']);
  }
}

/**
 * Implementation of hook_uninstall().
 */
function forum_uninstall() {
  $vid = variable_get('forum_nav_vocabulary', '');
  // Delete the vocabulary.
  taxonomy_del_vocabulary($vid);

  db_query("DELETE FROM {node} WHERE type = 'forum'");
  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');
}

/**
 * Implementation of hook_schema().
 */
function forum_schema() {
  $schema['forum'] = array(
    'fields' => array(
      'nid' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0),
      'vid' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0),
      'tid' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0)
    ),
    'indexes' => array(
      'nid' => array('nid'),
      'tid' => array('tid')
    ),
    'primary key' => array('vid'),
  );

  return $schema;
}