1. 8.3.x core/modules/book/book.install
  2. 8.0.x core/modules/book/book.install
  3. 8.1.x core/modules/book/book.install
  4. 8.2.x core/modules/book/book.install
  5. 8.4.x core/modules/book/book.install
  6. 5.x modules/book/book.install
  7. 6.x modules/book/book.install
  8. 7.x modules/book/book.install

Install, update and uninstall functions for the book module.

File

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

Functions

Namesort descending Description
book_install Implements hook_install().
book_schema Implements hook_schema().
book_uninstall Implements hook_uninstall().
_book_install_type_create Creates the book content type.