You are here

function hs_book_hierarchical_select_valid_item in Hierarchical Select 5.3

Implementation of hook_hierarchical_select_valid_item().

File

modules/hs_book.module, line 160
Implementation of the Hierarchical Select API for the Book module.

Code

function hs_book_hierarchical_select_valid_item($item, $params) {
  if (!is_numeric($item) || $item < 0) {
    return FALSE;
  }

  // Item 0 corresponds to the special <top-level page> option.
  if ($item == 0) {
    return TRUE;
  }
  $count = db_result(db_query(db_rewrite_sql("SELECT COUNT(n.nid) FROM {book} n WHERE n.nid = %d"), $item));
  return $count == 1;
}