function book_access_node_update in Book access 1.x
Same name and namespace in other branches
- 7.2 book_access.module \book_access_node_update()
Implements hook_node_update().
Makes sure defaults propagate to pages that have been 'upgraded' to a book.
File
- ./
book_access.module, line 71
Code
function book_access_node_update(NodeInterface $node) {
/* if (isset($node->book['bid']) && $node->book['bid']) {
// Check for existing permissions
// $rowCount = \Drupal::database()->select('book_access_author', 'book_access_author')
// ->condition( 'nid', $node->book['bid'], '=')
// ->condition( 'uid', $node->getOwnerId())
// ->countQuery()
// ->execute()
// ->fetchField();
if ($rowCount == 0) {
// @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);
$roleResultSet = \Drupal::database()->select('book_access_role', 'book_access_role')
->condition('nid', $node->book['bid'], '=')
->condition('rid', $rids, 'IN')
->fields('book_access_role', ['rid'])
->distinct()
->execute();
if ($roleResultSet->rowCount() < count($rids)) {
// Fill in the missing ones.
$existingRids = [];
foreach ($roleResultSet as $row) {
$existingRids[] = $row->rid;
}
$missingRids = array_diff($rids, $existingRids);
foreach ($missingRids as $rid) {
// @FIXME
// // @FIXME
// // The correct configuration object could not be determined. You'll need to
// // rewrite this call manually.
// $defaultToUse = variable_get( "book_access_role_{$rid}_default");
if ($defaultToUse !== NULL) {
$roleDefaults = [];
foreach ($defaultToUse as $grant) {
$roleDefaults[$grant] = $rid;
}
// BookAccess::addRoleGrants( $node->book['bid'], array($rid), $roleDefaults);.
}
}
}
}*/
}