public static function BookAccess::resetToDefault in Book access 1.x
Resets book permissions to its defaults, ignoring user-specific ones.
File
- src/
Access/ BookAccess.php, line 668 - Allows to set the access control for book nodes on a per book basis.
Class
- BookAccess
- @file
Namespace
Drupal\book_access\AccessCode
public static function resetToDefault($nid) {
$node = node_load($nid);
$roles = user_roles();
$authorDefaults = variable_get('book_access_default_author_access');
BookAccess::setAuthorGrants($nid, $node->uid, drupal_map_assoc($authorDefaults));
// clear out the existing role grants and add on to it
BookAccess::setRoleGrants($nid, array_keys($roles), array());
$roleGrantsToAdd = array();
foreach ($roles as $rid => $rname) {
$roleDefaults = variable_get("book_access_default_role_{$rid}_access");
foreach ($roleDefaults as $grant) {
$roleGrantsToAdd[$grant][$rid] = TRUE;
}
}
BookAccess::addRoleGrants($nid, array_keys($roles), $roleGrantsToAdd);
}