You are here

public static function BookAccess::getUserGrants in Book access 6.2

Same name and namespace in other branches
  1. 7.2 book_access.module \BookAccess::getUserGrants()

Returns the user book grants.

Parameters

$bid: The book ID.

$uids: The variables where to store the user IDs.

$defaults: An array containing the default values for the grants.

Return value

An array of grants, in the format

$grants[$grant][$uid];

, where

$grant;

is a string between 'grant_view', 'grant_update', 'grant_delete', 'grant_admin_access', 'grant_add_child', 'grant_edit_outline', and

$uid;

is the user ID.

1 call to BookAccess::getUserGrants()
book_access_ui_grants_form in ./book_access_ui.admin.inc
Form builder for the book access configuration page.

File

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

Class

BookAccess
@file

Code

public static function getUserGrants($bid, &$uids) {
  $grants = array(
    'grant_view' => array(),
    'grant_update' => array(),
    'grant_delete' => array(),
    'grant_admin_access' => array(),
    'grant_add_child' => array(),
    'grant_edit_outline' => array(),
  );
  $uids = array();
  $result = db_query("SELECT * FROM {book_access_user} bau INNER JOIN {users} u ON u.uid = bau.uid WHERE bau.nid = %d", $bid);
  while ($access = db_fetch_object($result)) {
    $uid = $access->uid;
    $uids[$uid] = $uid;
    foreach (self::grantIDs() as $id) {
      $grants[$id][$uid] = !empty($access->{$id});
    }
  }
  return $grants;
}