You are here

function paymentreference_instance_access in Payment 7

Check if the user has access to add a payment for a field instance.

Parameters

array $instance:

Return value

boolean

1 string reference to 'paymentreference_instance_access'
paymentreference_menu in modules/paymentreference/paymentreference.module
Implements hook_menu().

File

modules/paymentreference/paymentreference.module, line 93
Hook implementations and general functions.

Code

function paymentreference_instance_access(array $instance) {
  global $user;

  // Check field permissions.
  if (!field_access('edit', field_info_field($instance['field_name']), $instance['entity_type'])) {
    return FALSE;
  }

  // Deny access if the user already has a payment available for this instance.
  if (paymentreference_load($instance['entity_type'], $instance['bundle'], $instance['field_name'], $user->uid)) {
    return FALSE;
  }
  return TRUE;
}