function tripal_example_node_access

2.x tripal_example.chado_node.inc tripal_example_node_access($node, $op, $account)

Implement hook_access(). This hook provides instructions to Drupal for which users can access the custom content types created in the function above. The available permissions are set in the chado_example_permissions() hook in the tripal_example.module file. This hook is not needed if no node types were defined in the hook_node_info() hook.

Return value

This function should return null if it does not specifically deny access. This allows for other mechanisms to to deny or reject access. If the return value is TRUE then access is granted regardless of any other rules that might be implemented by other modules.

File

tripal_example/includes/tripal_example.chado_node.inc, line 73
This file should contain all Drupal hooks for interacting with nodes.

Code

function tripal_example_node_access($node, $op, $account) {
  $node_type = $node;
  if (is_object($node)) {
    $node_type = $node->type;
  }
  // EXPLANATION:  in the tripal_example_permissions() function we created the
  // permission types that are used here to check for access permissions to the
  // 'chado_exmaple' node type.
  if ($node_type == 'chado_example') {
    if ($op == 'create') {
      if (!user_access('create chado_example content', $account)) {
        return NODE_ACCESS_DENY;
      }
      return NODE_ACCESS_ALLOW;
    }
    if ($op == 'update') {
      if (!user_access('edit chado_example content', $account)) {
        return NODE_ACCESS_DENY;
      }
    }
    if ($op == 'delete') {
      if (!user_access('delete chado_example content', $account)) {
        return NODE_ACCESS_DENY;
      }
    }
    if ($op == 'view') {
      if (!user_access('access chado_example content', $account)) {
        return NODE_ACCESS_DENY;
      }
    }
  }
  return NODE_ACCESS_IGNORE;
}