Same name and namespace in other branches
  1. 7.x modules/book/book.module \book_update_bid()

Update the bid for a page and its children when it is moved to a new book.

Parameters

$book_link: A fully loaded menu link that is part of the book hierarchy.

File

modules/book/book.module, line 485
Allows users to structure the pages of a site in a hierarchy or outline.

Code

function book_update_bid($book_link) {
  for ($i = 1; $i <= MENU_MAX_DEPTH && $book_link["p{$i}"]; $i++) {
    $match[] = "p{$i} = %d";
    $args[] = $book_link["p{$i}"];
  }
  $result = db_query("SELECT mlid FROM {menu_links} WHERE " . implode(' AND ', $match), $args);
  $mlids = array();
  while ($a = db_fetch_array($result)) {
    $mlids[] = $a['mlid'];
  }
  if ($mlids) {
    db_query("UPDATE {book} SET bid = %d WHERE mlid IN (" . implode(',', $mlids) . ")", $book_link['bid']);
  }
}