You are here

function _book_access_user_books_list in Book access 6

1 call to _book_access_user_books_list()
_book_access_options_restrict in ./book_access.module
Restricts the options available to who moves book pages between books.

File

./book_access.module, line 519
Allows access control for book nodes on a per book basis. It is based on forum_access.module and tac_lite.module.

Code

function _book_access_user_books_list($grant) {
  global $user;
  $permitted_bids = array();
  $roles = array_keys($user->roles);
  $query = db_query("SELECT nid FROM {book_access_role} WHERE rid IN (" . db_placeholders($roles) . ") AND grant_{$grant} > 0", $roles);
  while ($result = db_fetch_object($query)) {
    $permitted_bids[$result->nid] = $result->nid;
  }
  $query = db_query("SELECT nid FROM {book_access_user} WHERE uid = %d AND grant_{$grant} > 0", $user->uid);
  while ($result = db_fetch_object($query)) {
    $permitted_bids[$result->nid] = $result->nid;
  }
  return $permitted_bids;
}