function book_node_type_update

Same name in other branches
  1. 9 core/modules/book/book.module \book_node_type_update()
  2. 8.9.x core/modules/book/book.module \book_node_type_update()
  3. 10 core/modules/book/book.module \book_node_type_update()
  4. 11.x core/modules/book/book.module \book_node_type_update()

Implements hook_node_type_update().

Updates the Book module's persistent variables if the machine-readable name of a node type is changed.

File

modules/book/book.module, line 1326

Code

function book_node_type_update($type) {
    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);
        }
    }
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.