book.install 1.87 KB
Newer Older
1 2
<?php

3 4 5 6 7
/**
 * @file
 * Install, update and uninstall functions for the book module.
 */

8
/**
9
 * Implements hook_uninstall().
10 11
 */
function book_uninstall() {
Dries's avatar
Dries committed
12
  // Delete menu links.
13 14 15
  db_delete('menu_links')
    ->condition('module', 'book')
    ->execute();
Dries's avatar
Dries committed
16
  menu_cache_clear_all();
17
}
Dries's avatar
Dries committed
18

19
/**
20
 * Implements hook_schema().
21 22 23
 */
function book_schema() {
  $schema['book'] = array(
24
  'description' => 'Stores book outline information. Uniquely connects each node in the outline to a link in {menu_links}',
25
    'fields' => array(
26 27 28 29 30
      'mlid' => array(
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
31
        'description' => "The book page's {menu_links}.mlid.",
32 33 34 35 36 37
      ),
      'nid' => array(
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
38
        'description' => "The book page's {node}.nid.",
39 40 41 42 43 44
      ),
      'bid' => array(
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
45
        'description' => "The book ID is the {book}.nid of the top-level page.",
46
      ),
47
    ),
48 49 50 51
    'primary key' => array('mlid'),
    'unique keys' => array(
      'nid' => array('nid'),
    ),
52
    'indexes' => array(
53
      'bid' => array('bid'),
54 55 56 57 58
    ),
  );

  return $schema;
}
59 60

/**
61
 * Move the Book module settings from variables to config.
62 63 64 65 66 67 68 69
 *
 * @ingroup config_upgrade
 */
function book_update_8000() {
  update_variables_to_config('book.settings', array(
    'book_child_type' => 'child_type',
    'book_block_mode' => 'block.navigation.mode',
  ));
70 71
  $allowed_types = update_variable_get('book_allowed_types', FALSE);
  if ($allowed_types) {
72 73 74 75
    // Ensure consistent ordering of allowed_types.
    // @see book_admin_settings_submit()
    sort($allowed_types);

76
    Drupal::config('book.settings')
77
      ->set('allowed_types', $allowed_types)
78 79 80
      ->save();
  }

81
}