function tripal_featuremap_map_access

1.x tripal_featuremap.module tripal_featuremap_map_access($op, $node, $account)

Implement hook_access().

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

Parameters

$op: The operation to be performed

@param $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 $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/tripal_featuremap.module, line 300

Code

function tripal_featuremap_map_access($op, $node, $account) {
  if ($op == 'create') {
    if (!user_access('create chado_featuremap content', $account)) {
      return FALSE;
    }
    return TRUE;
  }

  if ($op == 'update') {
    if (!user_access('edit any chado_featuremap content', $account) && 
      !user_access('edit own chado_featuremap content', $account)) {
      return FALSE;
    }
    if (user_access('edit own chado_featuremap content', $account) && 
      $account->uid != $node->uid) {
      return FALSE;
    }
  }

  if ($op == 'delete') {
    if (!user_access('delete any chado_featuremap content', $account) && 
      !user_access('delete own chado_featuremap content', $account)) {
      return FALSE;
    }
    if (user_access('delete own chado_featuremap content', $account) && 
      $account->uid != $node->uid) {
      return FALSE;
    }
  }
  return NULL;
}