You are here

public static function BookAccess::restrictOptions in Book access 1.x

Restricts the options available to who moves book pages between books.

Parameters

$options: The options array used from book_outline_form() and the book edit form for the list of books to which the page can be moved to.

$account: The user account to use; if NULL, the currently logged in user account will be used.

File

src/Access/BookAccess.php, line 581
Allows to set the access control for book nodes on a per book basis.

Class

BookAccess
@file

Namespace

Drupal\book_access\Access

Code

public static function restrictOptions(&$options, $account = NULL) {
  if (!isset($account)) {
    $account = \Drupal::currentUser();
  }
  if (user_access('administer nodes', $account)) {
    return;
  }
  $permitted_bids = self::getBookList(array(
    'update',
  ), $account);
  foreach ($options as $bid => $value) {
    if ($bid > 0 && !isset($permitted_bids[$bid])) {
      unset($options[$bid]);
    }
  }
}