Updated to Drupal 8.5. Core Media not yet in use.
[yaffs-website] / vendor / chi-teck / drupal-code-generator / templates / d7 / hook / node_grants_alter.twig
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 (file)
index 0000000..b766390
--- /dev/null
@@ -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();
+      }
+    }
+  }
+}