You are here

function commerce_product_file_download_access in Commerce Core 7

Implements hook_file_download_access().

This hook is grants access to files based on a user's access to the entity a file is attached to. For example, users with access to a product should be allowed to download files attached to that product. Here we do this on a per- field basis for files attached to products.

Parameters

$field: The field to which the file belongs.

$entity_type: The type of $entity; for example, 'node' or 'user' or 'commerce_product'.

$entity: The $entity to which $file is referenced.

Return value

TRUE if access should be allowed by this entity or FALSE if denied. Note that denial may be overridden by another entity controller, making this grant permissive rather than restrictive.

File

modules/product/commerce_product.module, line 200
Defines the core Commerce product entity, including the entity itself, the bundle definitions (product types), and various API functions to manage products and interact with them through forms and autocompletes.

Code

function commerce_product_file_download_access($field, $entity_type, $entity) {
  if ($entity_type == 'commerce_product') {
    return field_access('view', $field, $entity_type, $entity);
  }
}