book_get_books

Versions
6 – 7
book_get_books()

Returns an array of all books.

This list may be used for generating a list of all the books, or for building the options for a form select.

▾ 4 functions call book_get_books()

book_admin_overview in modules/book/book.admin.inc
Returns an administrative overview of all books.
book_block in modules/book/book.module
Implementation of hook_block().
book_render in modules/book/book.pages.inc
Menu callback; prints a listing of all books.
_book_add_form_elements in modules/book/book.module
Build the common elements of the book form for the node and outline forms.

Code

modules/book/book.module, line 255

<?php
function book_get_books() {
  static $all_books;

  if (!isset($all_books)) {
    $all_books = array();
    $result = db_query("SELECT DISTINCT(bid) FROM {book}");
    $nids = array();
    while ($book = db_fetch_array($result)) {
      $nids[] = $book['bid'];
    }
    if ($nids) {
      $result2 = db_query(db_rewrite_sql("SELECT n.type, n.title, b.*, ml.* FROM {book} b INNER JOIN {node} n on b.nid = n.nid INNER JOIN {menu_links} ml ON b.mlid = ml.mlid WHERE n.nid IN (". implode(',', $nids) .") AND n.status = 1 ORDER BY ml.weight, ml.link_title"));
      while ($link = db_fetch_array($result2)) {
        $link['href'] = $link['link_path'];
        $link['options'] = unserialize($link['options']);
        $all_books[$link['bid']] = $link;
      }
    }
  }
  return $all_books;
}
?>
Login or register to post comments
 
 

All source code and documentation on this site is released under the terms of the GNU General Public License, version 2 and later. Drupal is a registered trademark of Dries Buytaert.