Closed (duplicate)
Project:
Commerce Core
Version:
7.x-1.x-dev
Component:
Product
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Issue tags:
Reporter:
Created:
12 May 2011 at 18:04 UTC
Updated:
9 Aug 2011 at 17:34 UTC
Jump to comment: Most recent file
Comments
Comment #1
mikejoconnor commentedApparently this is controlled via hook_file_download_access.
Here's a patch.
Comment #2
mikejoconnor commentedApparently this is controlled via hook_file_download_access.
Here's a patch.
Comment #3
recrit commentedyes, this is what eventually controls the view of styled image: image_style_deliver() invokes file_download hooks.
The method used in this patch is also how the node module implements the hook.
After applying patch, I was able to see a thumbnail private image in the edit form and on a views list.
Comment #4
rszrama commentedAlrighty, committed. This won't cause any trouble with Commerce File, will it recrit? Like automatically give access to a user to any file attached to a product a user has view access to?
Comment #5
recrit commentedno this will not effect it.
The hook_file_download_access() is called from file's implementation of hook_file_download(). Commerce File also implements hook_file_download().
hook_file_download() is a denial based hook, so even if the file module's hooks grant access to the file then commerce_file can still deny access. Conversely, if commerce_file allows access, then other modules still get a say to deny it.
Comment #6
rszrama commentedExcellent - that's what I was unsure of -> is it denial based or grant based. Thanks for the explanation. : )
Comment #7
davidwhthomas commentedSee http://drupal.org/node/1157266 for a field-level access control option, suitable for that function context.
So, for example a user can view a product, but not download an attached file, honoring the field access control rules.
The alternative patch also includes the standard hook implementation documentation for completeness.
Direct patch link: http://drupal.org/files/issues/commerce_product.module.v2.patch
DT
Comment #8
recrit commentedThe hook_file_download gets called in this case by image module to check download access before creating a new image style.
There is a hook_field_access() where this type of access control should be implemented... however, I'm not convince that a module defining an entity should define this.
Comment #9
davidwhthomas commentedThe current patch fails on existing installs because the entity name has changed from product to commerce_product.
I prefer my other patch on http://drupal.org/node/1157266#comment-4468168 which doesn't have this limitation
Comment #10
rszrama commentedClosing this since we have the other issue.