/[drupal]/drupal/modules/book/book.install
ViewVC logotype

Contents of /drupal/modules/book/book.install

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.33 - (show annotations) (download) (as text)
Thu Sep 10 06:38:17 2009 UTC (2 months, 2 weeks ago) by dries
Branch: MAIN
CVS Tags: DRUPAL-7-0-UNSTABLE-10, DRUPAL-7-0-UNSTABLE-9, HEAD
Changes since 1.32: +1 -5 lines
File MIME type: text/x-php
- Patch #306151 by agentrickard, David_Rothstein, Dave Reid, dbabbage, moshe weitzman: automatically install/uninstall schema.
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 }

  ViewVC Help
Powered by ViewVC 1.1.2