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_grants_alter.twig;fp=vendor%2Fchi-teck%2Fdrupal-code-generator%2Ftemplates%2Fd7%2Fhook%2Fnode_grants_alter.twig;h=b7663901fa74dd2139e7be0de545214fe6a4ca68;hp=0000000000000000000000000000000000000000;hb=af6d1fb995500ae68849458ee10d66abbdcfb252;hpb=680c79a86e3ed402f263faeac92e89fb6d9edcc0 diff --git a/vendor/chi-teck/drupal-code-generator/templates/d7/hook/node_grants_alter.twig b/vendor/chi-teck/drupal-code-generator/templates/d7/hook/node_grants_alter.twig new file mode 100644 index 000000000..b7663901f --- /dev/null +++ b/vendor/chi-teck/drupal-code-generator/templates/d7/hook/node_grants_alter.twig @@ -0,0 +1,21 @@ +/** + * Implements hook_node_grants_alter(). + */ +function {{ machine_name }}_node_grants_alter(&$grants, $account, $op) { + // Our sample module never allows certain roles to edit or delete + // content. Since some other node access modules might allow this + // permission, we expressly remove it by returning an empty $grants + // array for roles specified in our variable setting. + + // Get our list of banned roles. + $restricted = variable_get('example_restricted_roles', array()); + + if ($op != 'view' && !empty($restricted)) { + // Now check the roles for this account against the restrictions. + foreach ($restricted as $role_id) { + if (isset($account->roles[$role_id])) { + $grants = array(); + } + } + } +}