X-Git-Url: http://www.aleph1.co.uk/gitweb/?p=yaffs-website;a=blobdiff_plain;f=vendor%2Fchi-teck%2Fdrupal-code-generator%2Ftemplates%2Fd7%2Fhook%2Fnode_access_records.twig;fp=vendor%2Fchi-teck%2Fdrupal-code-generator%2Ftemplates%2Fd7%2Fhook%2Fnode_access_records.twig;h=24afad910780135288d6fea421aacea8ea02c94f;hp=0000000000000000000000000000000000000000;hb=af6d1fb995500ae68849458ee10d66abbdcfb252;hpb=680c79a86e3ed402f263faeac92e89fb6d9edcc0 diff --git a/vendor/chi-teck/drupal-code-generator/templates/d7/hook/node_access_records.twig b/vendor/chi-teck/drupal-code-generator/templates/d7/hook/node_access_records.twig new file mode 100644 index 000000000..24afad910 --- /dev/null +++ b/vendor/chi-teck/drupal-code-generator/templates/d7/hook/node_access_records.twig @@ -0,0 +1,36 @@ +/** + * Implements hook_node_access_records(). + */ +function {{ machine_name }}_node_access_records($node) { + // We only care about the node if it has been marked private. If not, it is + // treated just like any other node and we completely ignore it. + if ($node->private) { + $grants = array(); + // Only published nodes should be viewable to all users. If we allow access + // blindly here, then all users could view an unpublished node. + if ($node->status) { + $grants[] = array( + 'realm' => 'example', + 'gid' => 1, + 'grant_view' => 1, + 'grant_update' => 0, + 'grant_delete' => 0, + 'priority' => 0, + ); + } + // For the example_author array, the GID is equivalent to a UID, which + // means there are many groups of just 1 user. + // Note that an author can always view his or her nodes, even if they + // have status unpublished. + $grants[] = array( + 'realm' => 'example_author', + 'gid' => $node->uid, + 'grant_view' => 1, + 'grant_update' => 1, + 'grant_delete' => 1, + 'priority' => 0, + ); + + return $grants; + } +}