| 1 |
<?php
|
| 2 |
// $Id: book.install,v 1.32 2009/06/27 11:11:53 dries Exp $
|
| 3 |
|
| 4 |
/**
|
| 5 |
* @file
|
| 6 |
* Install, update and uninstall functions for the book module.
|
| 7 |
*/
|
| 8 |
|
| 9 |
/**
|
| 10 |
* Implement hook_install().
|
| 11 |
*/
|
| 12 |
function book_install() {
|
| 13 |
// Add the node type.
|
| 14 |
_book_install_type_create();
|
| 15 |
}
|
| 16 |
|
| 17 |
/**
|
| 18 |
* Implement hook_uninstall().
|
| 19 |
*/
|
| 20 |
function book_uninstall() {
|
| 21 |
// Delete menu links.
|
| 22 |
db_query("DELETE FROM {menu_links} WHERE module = 'book'");
|
| 23 |
menu_cache_clear_all();
|
| 24 |
}
|
| 25 |
|
| 26 |
function _book_install_type_create() {
|
| 27 |
// Create an additional node type.
|
| 28 |
$book_node_type = array(
|
| 29 |
'type' => 'book',
|
| 30 |
'name' => t('Book page'),
|
| 31 |
'base' => 'node_content',
|
| 32 |
'description' => t('<em>Books</em> have a built-in hierarchical navigation. Use for handbooks or tutorials.'),
|
| 33 |
'custom' => 1,
|
| 34 |
'modified' => 1,
|
| 35 |
'locked' => 0,
|
| 36 |
);
|
| 37 |
|
| 38 |
$book_node_type = node_type_set_defaults($book_node_type);
|
| 39 |
node_type_save($book_node_type);
|
| 40 |
// Default to not promoted.
|
| 41 |
variable_set('node_options_book', array('status'));
|
| 42 |
// Use this default type for adding content to books.
|
| 43 |
variable_set('book_allowed_types', array('book'));
|
| 44 |
variable_set('book_child_type', 'book');
|
| 45 |
}
|
| 46 |
|
| 47 |
/**
|
| 48 |
* Implement hook_schema().
|
| 49 |
*/
|
| 50 |
function book_schema() {
|
| 51 |
$schema['book'] = array(
|
| 52 |
'description' => 'Stores book outline information. Uniquely connects each node in the outline to a link in {menu_links}',
|
| 53 |
'fields' => array(
|
| 54 |
'mlid' => array(
|
| 55 |
'type' => 'int',
|
| 56 |
'unsigned' => TRUE,
|
| 57 |
'not null' => TRUE,
|
| 58 |
'default' => 0,
|
| 59 |
'description' => "The book page's {menu_links}.mlid.",
|
| 60 |
),
|
| 61 |
'nid' => array(
|
| 62 |
'type' => 'int',
|
| 63 |
'unsigned' => TRUE,
|
| 64 |
'not null' => TRUE,
|
| 65 |
'default' => 0,
|
| 66 |
'description' => "The book page's {node}.nid.",
|
| 67 |
),
|
| 68 |
'bid' => array(
|
| 69 |
'type' => 'int',
|
| 70 |
'unsigned' => TRUE,
|
| 71 |
'not null' => TRUE,
|
| 72 |
'default' => 0,
|
| 73 |
'description' => "The book ID is the {book}.nid of the top-level page.",
|
| 74 |
),
|
| 75 |
),
|
| 76 |
'primary key' => array('mlid'),
|
| 77 |
'unique keys' => array(
|
| 78 |
'nid' => array('nid'),
|
| 79 |
),
|
| 80 |
'indexes' => array(
|
| 81 |
'bid' => array('bid'),
|
| 82 |
),
|
| 83 |
);
|
| 84 |
|
| 85 |
return $schema;
|
| 86 |
}
|