Index: developer/hooks/node.php
===================================================================
RCS file: /cvs/drupal-contrib/contributions/docs/developer/hooks/Attic/node.php,v
retrieving revision 1.41.2.7
diff -u -p -r1.41.2.7 node.php
--- developer/hooks/node.php	18 May 2010 16:12:29 -0000	1.41.2.7
+++ developer/hooks/node.php	14 Aug 2010 21:59:17 -0000
@@ -86,6 +86,15 @@ function hook_node_info() {
  *   - "delete"
  *   - "insert"
  *   - "update"
+ *
+ * Most modules will not need the update or insert operations, because form
+ * fields you add to the node type editing form will be automatically saved as
+ * variables. For instance, if you add a field called 'my_module_foo' to
+ * content type 'machine_name', its value will be saved as variable
+ * 'my_module_foo_machine_name' (and if the machine name is updated, the
+ * variables will be updated appropriately). Here is an example where you do
+ * need an update operation (from the book module), because the simple default
+ * case doesn't cover what needs to be done.
  * @param $info
  *   The node type object on which $op is being performed.
  * @return
@@ -94,14 +103,25 @@ function hook_node_info() {
 function hook_node_type($op, $info) {

   switch ($op){
+    // comment.module.
     case 'delete':
       variable_del('comment_'. $info->type);
       break;
+    // book.module.
     case 'update':
-      if (!empty($info->old_type) && $info->old_type != $info->type) {
-        $setting = variable_get('comment_'. $info->old_type, COMMENT_NODE_READ_WRITE);
-        variable_del('comment_'. $info->old_type);
-        variable_set('comment_'. $info->type, $setting);
+      if (!empty($type->old_type) && $type->old_type != $type->type) {
+        // Update the list of node types that are allowed to be added to books.
+        $allowed_types = variable_get('book_allowed_types', array('book'));
+        $key = array_search($type->old_type, $allowed_types);
+        if ($key !== FALSE) {
+          $allowed_types[$type->type] = $allowed_types[$key] ? $type->type : 0;
+          unset($allowed_types[$key]);
+          variable_set('book_allowed_types', $allowed_types);
+        }
+        // Update the setting for the "Add child page" link.
+        if (variable_get('book_child_type', 'book') == $type->old_type) {
+          variable_set('book_child_type', $type->type);
+        }
       }
       break;
   }
