function book_node_presave

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

Implements hook_node_presave().

File

modules/book/book.module, line 919

Code

function book_node_presave($node) {
  // Always save a revision for non-administrators.
  if (!empty($node->book['bid']) && !user_access('administer nodes')) {
    $node->revision = 1;
    // The database schema requires a log message for every revision.
    if (!isset($node->log)) {
      $node->log = '';
    }
  }
  // Make sure a new node gets a new menu link.
  if (empty($node->nid)) {
    $node->book['mlid'] = NULL;
  }
}

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