Updated to Drupal 8.5. Core Media not yet in use.
[yaffs-website] / vendor / chi-teck / drupal-code-generator / templates / d7 / hook / node_access.twig
1 /**
2  * Implements hook_node_access().
3  */
4 function {{ machine_name }}_node_access($node, $op, $account) {
5   $type = is_string($node) ? $node : $node->type;
6
7   if (in_array($type, node_permissions_get_configured_types())) {
8     if ($op == 'create' && user_access('create ' . $type . ' content', $account)) {
9       return NODE_ACCESS_ALLOW;
10     }
11
12     if ($op == 'update') {
13       if (user_access('edit any ' . $type . ' content', $account) || (user_access('edit own ' . $type . ' content', $account) && ($account->uid == $node->uid))) {
14         return NODE_ACCESS_ALLOW;
15       }
16     }
17
18     if ($op == 'delete') {
19       if (user_access('delete any ' . $type . ' content', $account) || (user_access('delete own ' . $type . ' content', $account) && ($account->uid == $node->uid))) {
20         return NODE_ACCESS_ALLOW;
21       }
22     }
23   }
24
25   // Returning nothing from this function would have the same effect.
26   return NODE_ACCESS_IGNORE;
27 }