function private_content_node_grants in Private content 8.2
Implements hook_node_grants().
Tell the node access system what GIDs the user belongs to for each realm.
File
- ./
private_content.module, line 61 - A tremendously simple access control module -- it allows users to mark individual nodes as private; users with 'access private content' perms can read these nodes, while others cannot.
Code
function private_content_node_grants(AccountInterface $account, $op) {
$grants = array();
if ($op == 'view') {
if (!$account
->isAnonymous()) {
// Grant to the author for own content.
$grants['private_author'] = array(
$account
->id(),
);
}
// Grant for private content.
if ($account
->hasPermission('access private content')) {
$grants['private_view'] = array(
PRIVATE_GRANT_ALL,
);
}
}
return $grants;
}