2006-07-13 13:14:25 +00:00
<?php
2006-07-14 01:05:10 +00:00
// $Id$
2006-07-13 13:14:25 +00:00
2009-05-13 19:42:18 +00:00
/**
* @file
* Install, update and uninstall functions for the book module.
*/
2006-09-01 07:40:08 +00:00
/**
2009-05-27 18:34:03 +00:00
* Implement hook_install().
2006-09-01 07:40:08 +00:00
*/
2006-07-13 13:14:25 +00:00
function book_install() {
2007-05-25 12:46:46 +00:00
// Create tables.
drupal_install_schema('book');
2007-07-30 18:20:21 +00:00
// Add the node type.
_book_install_type_create();
2006-08-04 06:58:44 +00:00
}
2006-09-01 07:40:08 +00:00
/**
2009-05-27 18:34:03 +00:00
* Implement hook_uninstall().
2006-09-01 07:40:08 +00:00
*/
function book_uninstall() {
2007-07-30 18:20:21 +00:00
// Delete menu links.
db_query("DELETE FROM {menu_links} WHERE module = 'book'");
menu_cache_clear_all();
2007-05-25 12:46:46 +00:00
// Remove tables.
drupal_uninstall_schema('book');
2006-09-01 07:40:08 +00:00
}
2007-07-30 18:20:21 +00:00
function _book_install_type_create() {
2008-05-15 21:19:24 +00:00
// Create an additional node type.
2007-07-30 18:20:21 +00:00
$book_node_type = array(
'type' => 'book',
'name' => t('Book page'),
2008-10-08 03:27:56 +00:00
'base' => 'node_content',
2007-10-25 15:32:56 +00:00
'description' => t('A <em>book page</em> is a page of content, organized into a collection of related entries collectively known as a <em>book</em>. A <em>book page</em> automatically displays links to adjacent pages, providing a simple navigation system for organizing and reviewing structured content.'),
2008-10-08 03:27:56 +00:00
'custom' => 1,
'modified' => 1,
'locked' => 0,
2007-07-30 18:20:21 +00:00
);
2008-10-08 03:27:56 +00:00
$book_node_type = node_type_set_defaults($book_node_type);
2007-07-30 18:20:21 +00:00
node_type_save($book_node_type);
// Default to not promoted.
variable_set('node_options_book', array('status'));
// Use this default type for adding content to books.
variable_set('book_allowed_types', array('book'));
variable_set('book_child_type', 'book');
}
2007-10-05 14:43:26 +00:00
/**
2009-05-27 18:34:03 +00:00
* Implement hook_schema().
2007-10-05 14:43:26 +00:00
*/
function book_schema() {
$schema['book'] = array(
2008-11-15 13:01:11 +00:00
'description' => 'Stores book outline information. Uniquely connects each node in the outline to a link in {menu_links}',
2007-10-05 14:43:26 +00:00
'fields' => array(
2007-10-10 11:39:35 +00:00
'mlid' => array(
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
2008-11-15 13:01:11 +00:00
'description' => "The book page's {menu_links}.mlid.",
2007-10-10 11:39:35 +00:00
),
'nid' => array(
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
2008-11-15 13:01:11 +00:00
'description' => "The book page's {node}.nid.",
2007-10-10 11:39:35 +00:00
),
'bid' => array(
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
2008-11-15 13:01:11 +00:00
'description' => "The book ID is the {book}.nid of the top-level page.",
2007-10-10 11:39:35 +00:00
),
2007-10-05 14:43:26 +00:00
),
2007-12-18 12:59:22 +00:00
'primary key' => array('mlid'),
'unique keys' => array(
'nid' => array('nid'),
),
2007-10-05 14:43:26 +00:00
'indexes' => array(
2007-12-18 12:59:22 +00:00
'bid' => array('bid'),
2007-10-05 14:43:26 +00:00
),
);
return $schema;
}