You are here

function media_acquiadam_file_entity_access in Media: Acquia DAM 7

Implements hook_file_entity_access().

File

./media_acquiadam.module, line 308

Code

function media_acquiadam_file_entity_access($op, $file, $account) {
  if (empty($file->acquiadam_id)) {
    return FILE_ENTITY_ACCESS_IGNORE;
  }
  $asset = media_acquiadam_file_to_asset($file);

  // We had an asset id linked to the file, but we were not able to load the
  // asset. This can happen when the API user does not have access to the file.
  // We do not IGNORE because this also happens when an asset is expired.
  if (empty($asset)) {
    return FILE_ENTITY_ACCESS_DENY;
  }
  return media_acquiadam_asset_access($op, $asset, $account) ? FILE_ENTITY_ACCESS_ALLOW : FILE_ENTITY_ACCESS_DENY;
}