function private_content_node_access_records in Private 8
Same name and namespace in other branches
- 8.2 private_content.module \private_content_node_access_records()
Implements hook_node_access_records().
All node access modules must implement this hook. If the module is interested in the privacy of the node passed in, return a list of node access values for each grant ID we offer.
File
- ./
private_content.module, line 101 - 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_access_records(NodeInterface $node) {
if (private_content_disabling()) {
return;
}
// We only care about the node if it's been marked private. If not, it is
// treated just like any other node and we completely ignore it.
if (isset($node->private) && $node->private->value == 1) {
$grants = array();
$grants[] = array(
'realm' => 'private_view',
'gid' => PRIVATE_GRANT_ALL,
'grant_view' => 1,
'grant_update' => 0,
'grant_delete' => 0,
'priority' => 0,
);
$grants[] = array(
'realm' => 'private_edit',
'gid' => PRIVATE_GRANT_ALL,
'grant_view' => 1,
'grant_update' => 1,
'grant_delete' => 1,
'priority' => 0,
);
$grants[] = array(
'realm' => 'private_author',
'gid' => $node
->getOwnerId(),
'grant_view' => 1,
'grant_update' => 1,
'grant_delete' => 1,
'priority' => 0,
);
return $grants;
}
}