Mercurial > hg > cmmr2012-drupal-site
annotate vendor/chi-teck/drupal-code-generator/templates/d7/hook/node_access.twig @ 0:c75dbcec494b
Initial commit from drush-created site
author | Chris Cannam |
---|---|
date | Thu, 05 Jul 2018 14:24:15 +0000 |
parents | |
children |
rev | line source |
---|---|
Chris@0 | 1 /** |
Chris@0 | 2 * Implements hook_node_access(). |
Chris@0 | 3 */ |
Chris@0 | 4 function {{ machine_name }}_node_access($node, $op, $account) { |
Chris@0 | 5 $type = is_string($node) ? $node : $node->type; |
Chris@0 | 6 |
Chris@0 | 7 if (in_array($type, node_permissions_get_configured_types())) { |
Chris@0 | 8 if ($op == 'create' && user_access('create ' . $type . ' content', $account)) { |
Chris@0 | 9 return NODE_ACCESS_ALLOW; |
Chris@0 | 10 } |
Chris@0 | 11 |
Chris@0 | 12 if ($op == 'update') { |
Chris@0 | 13 if (user_access('edit any ' . $type . ' content', $account) || (user_access('edit own ' . $type . ' content', $account) && ($account->uid == $node->uid))) { |
Chris@0 | 14 return NODE_ACCESS_ALLOW; |
Chris@0 | 15 } |
Chris@0 | 16 } |
Chris@0 | 17 |
Chris@0 | 18 if ($op == 'delete') { |
Chris@0 | 19 if (user_access('delete any ' . $type . ' content', $account) || (user_access('delete own ' . $type . ' content', $account) && ($account->uid == $node->uid))) { |
Chris@0 | 20 return NODE_ACCESS_ALLOW; |
Chris@0 | 21 } |
Chris@0 | 22 } |
Chris@0 | 23 } |
Chris@0 | 24 |
Chris@0 | 25 // Returning nothing from this function would have the same effect. |
Chris@0 | 26 return NODE_ACCESS_IGNORE; |
Chris@0 | 27 } |