Defined image cck in product
if the image is private the image uploads ok, we can see the thumbnail but when saved the image is not accesible.
if the image is set to public it work ok

CommentFileSizeAuthor
#2 1155682.patch742 bytesmikejoconnor
#1 1155682.patch742 bytesmikejoconnor

Comments

mikejoconnor’s picture

Version: 7.x-1.0-beta3 » 7.x-1.x-dev
Status: Active » Needs review
StatusFileSize
new742 bytes

Apparently this is controlled via hook_file_download_access.

Here's a patch.

mikejoconnor’s picture

StatusFileSize
new742 bytes

Apparently this is controlled via hook_file_download_access.

Here's a patch.

recrit’s picture

Status: Needs review » Reviewed & tested by the community

yes, 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.

rszrama’s picture

Status: Reviewed & tested by the community » Fixed
Issue tags: +dcsprint6

Alrighty, 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?

recrit’s picture

no 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.

rszrama’s picture

Excellent - that's what I was unsure of -> is it denial based or grant based. Thanks for the explanation. : )

davidwhthomas’s picture

See 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

recrit’s picture

The 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.

davidwhthomas’s picture

Status: Fixed » Needs work

The 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

rszrama’s picture

Priority: Major » Normal
Status: Needs work » Closed (duplicate)

Closing this since we have the other issue.