function nodeaccess_set_grants in Nodeaccess 7
Set all grants for a node to nodeaccess table and acquire them.
Parameters
$node: node object the grants are being applied to.
array $grants: array of grants as defined (@see nodeaccess_save_grant).
8 calls to nodeaccess_set_grants()
- NodeaccesssPublishTestCase::testAuthoredView in tests/
nodeaccess_publish.test - Test unpublished node visibility.
- NodeaccesssPublishTestCase::testPublishedView in tests/
nodeaccess_publish.test - Test standard, published node visibility.
- NodeaccesssPublishTestCase::testUnpublishedView in tests/
nodeaccess_publish.test - Test unpublished node visibility.
- NodeaccesssRoleTestCase::testRoleNodeVisibilityAllAuthenticatedOnly in tests/
nodeaccess_role.test - Test node access when authenticated only should have full access.
- NodeaccesssRoleTestCase::testRoleNodeVisibilityFullAccess in tests/
nodeaccess_role.test - Test node access when anon and authenticated users should have full access.
File
- ./
nodeaccess.module, line 992 - Provide per node access control
Code
function nodeaccess_set_grants($node, $grants = array()) {
// Allow other modules to edit all grants for array.
drupal_alter('nodeaccess_grants', $grants, $node);
nodeaccess_delete_grants($node);
if (count($grants)) {
foreach ($grants as $grant) {
// Allow other modules to edit single grants.
drupal_alter('nodeaccess_grant', $grant, $node);
nodeaccess_save_grant($node, $grant);
}
}
node_access_acquire_grants($node);
}