public static function BookAccess::resetToDefault in Book access 7.2
Resets book permissions to its defaults, ignoring user-specific ones.
3 calls to BookAccess::resetToDefault()
- BookAccessTestCase::caseResetToDefaults in ./
book_access_test_case.test - book_access_ui_reset_one_to_defaults_submit in ./
book_access_ui.admin.inc - Form submissions callback for to reset one book node's defaults.
- _book_access_ui_reset_batch_operation in ./
book_access_ui.admin.inc
File
- ./
book_access.module, line 729 - Allows to set the access control for book nodes on a per book basis. Based on forum_access.module and tac_lite.module.
Class
- BookAccess
- @file
Code
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);
}