You are here

function book_access_node_insert in Book access 1.x

Same name and namespace in other branches
  1. 7.2 book_access.module \book_access_node_insert()

Implements hook_node_insert().

Specifically targets creation of book nodes to set some default permissions.

File

./book_access.module, line 31

Code

function book_access_node_insert(NodeInterface $node) {

  /*  if (isset( $node->book['bid'])
    && $node->book['bid']
    && $node->id() == $node->book['bid']) {
    // @FIXME
    // Could not extract the default value because it is either indeterminate, or
    // not scalar. You'll need to provide a default value in
    // config/install/book_access.settings.yml and config/schema/book_access.schema.yml.
    // @FIXME
    // Could not extract the default value because it is either indeterminate, or
    // not scalar. You'll need to provide a default value in
    // config/install/book_access.settings.yml and config/schema/book_access.schema.yml.
    BookAccess::setAuthorGrants(
    $node->book['bid'],
    $node->getOwnerId(),
    array_combine($node->getOwnerId() == 0 ? BookAccess::defaultGrants() : \Drupal::config('book_access.settings')->get("book_access_default_author_access"), $node->getOwnerId() == 0 ? BookAccess::defaultGrants() : \Drupal::config('book_access.settings')->get("book_access_default_author_access"))
    );

    $roles = user_roles();
    $rids = array_keys( $roles);
    foreach ($rids as $rid) {
    // @FIXME
    // // @FIXME
    // // The correct configuration object could not be determined. You'll need to
    // // rewrite this call manually.
    // $roleDefaults = variable_get( "book_access_default_role_{$rid}_access", array());

    foreach ($roleDefaults as $default) {
    $roleGrants[$default][$rid] = TRUE;
    }
    }
    BookAccess::setRoleGrants( $node->book['bid'], $rids, $roleGrants);
    }*/
}