24afad910780135288d6fea421aacea8ea02c94f
[yaffs-website] / vendor / chi-teck / drupal-code-generator / templates / d7 / hook / node_access_records.twig
1 /**
2  * Implements hook_node_access_records().
3  */
4 function {{ machine_name }}_node_access_records($node) {
5   // We only care about the node if it has been marked private. If not, it is
6   // treated just like any other node and we completely ignore it.
7   if ($node->private) {
8     $grants = array();
9     // Only published nodes should be viewable to all users. If we allow access
10     // blindly here, then all users could view an unpublished node.
11     if ($node->status) {
12       $grants[] = array(
13         'realm' => 'example',
14         'gid' => 1,
15         'grant_view' => 1,
16         'grant_update' => 0,
17         'grant_delete' => 0,
18         'priority' => 0,
19       );
20     }
21     // For the example_author array, the GID is equivalent to a UID, which
22     // means there are many groups of just 1 user.
23     // Note that an author can always view his or her nodes, even if they
24     // have status unpublished.
25     $grants[] = array(
26       'realm' => 'example_author',
27       'gid' => $node->uid,
28       'grant_view' => 1,
29       'grant_update' => 1,
30       'grant_delete' => 1,
31       'priority' => 0,
32     );
33
34     return $grants;
35   }
36 }