You are here

function token_book_link_load in Token 6

Same name and namespace in other branches
  1. 7 token.module \token_book_link_load()

Get a translated book menu link by its mlid, without access checking.

This function is a copy of book_link_load() but with its own cache and a simpler query to load the link. This also skips normal menu link access checking by using _token_menu_link_translate().

Parameters

$mlid: The mlid of the book menu item.

Return value

A book menu link translated for rendering.

See also

book_link_load()

_token_menu_link_translate()

File

./token.module, line 872
The Token API module.

Code

function token_book_link_load($mlid) {
  static $cache = array();
  if (!is_numeric($mlid)) {
    return FALSE;
  }
  if (!isset($cache[$mlid])) {
    $item = db_fetch_array(db_query("SELECT * FROM {menu_links} ml INNER JOIN {book} b ON b.mlid = ml.mlid LEFT JOIN {menu_router} m ON m.path = ml.router_path WHERE ml.mlid = %d", $mlid));
    if (!empty($item)) {
      _token_menu_link_translate($item);
    }
    $cache[$mlid] = $item;
  }
  return $cache[$mlid];
}