function tripal_featuremap_node_access

2.x tripal_featuremap.chado_node.inc tripal_featuremap_node_access($node, $op, $account)
3.x tripal_featuremap.chado_node.inc tripal_featuremap_node_access($node, $op, $account)

Implement hook_node_access().

This hook allows node modules to limit access to the node types they define.

Parameters

$node: The node on which the operation is to be performed, or, if it does not yet exist, the type of node to be created

@param $op The operation to be performed

@param $account A user object representing the user for whom the operation is to be performed

@return If the permission for the specified operation is not set then return FALSE. If the permission is set then return NULL as this allows other modules to disable access. The only exception is when the $op == 'create'. We will always return TRUE if the permission is set.

Related topics

File

tripal_featuremap/includes/tripal_featuremap.chado_node.inc, line 224
Hooks implementing the feature map node content type

Code

function tripal_featuremap_node_access($node, $op, $account) {
  $node_type = $node;
  if (is_object($node)) {
    $node_type = $node->type;
  }

  if ($node_type == 'chado_featuremap') {
    if ($op == 'create') {
      if (!user_access('create chado_featuremap content', $account)) {
        return NODE_ACCESS_DENY;
      }
      return NODE_ACCESS_ALLOW;
    }
    if ($op == 'update') {
      if (!user_access('edit chado_featuremap content', $account)) {
        return NODE_ACCESS_DENY;
      }
    }
    if ($op == 'delete') {
      if (!user_access('delete chado_featuremap content', $account)) {
        return NODE_ACCESS_DENY;
      }
    }
    if ($op == 'view') {
      if (!user_access('access chado_featuremap content', $account)) {
        return NODE_ACCESS_DENY;
      }
    }
    return NODE_ACCESS_IGNORE;
  }
}