Closed (fixed)
Project:
Commerce File
Version:
7.x-1.0-beta3
Component:
Code
Priority:
Normal
Category:
Feature request
Assigned:
Unassigned
Reporter:
Created:
31 Jan 2012 at 22:44 UTC
Updated:
9 Aug 2012 at 19:11 UTC
This is along the lines of #1252758: Allow bypass permission for file download checks but instead of a permission for accessing all files, I need a hook to allow me to override the logic before denying access.
I'm using the same files to be both sold with file licenses or to have other kinds of access allowed via complex logic (e.g. a user can access the file without purchase if it's on a node with a certain field value and the user has a certain corresponding permission). Since hook_file_download implementations blacklist access, a drupal_alter in commerce_file_download_access seems to be the only way to allow this.
| Comment | File | Size | Author |
|---|---|---|---|
| commerce_file.patch | 705 bytes | jody lynn |
Comments
Comment #1
recrit commentedfor license access control ...
the default rule "Control access to licensed file downloads" can be altered for your case to allow under normal circumstances OR if your special case occurs.
If you do not need any file access limit checking, then you could simply disable the default rule and create a similar rule by cloning it.
if no license for the file ...
just noticed you posted for when you do not have a license ... I'll have to review the best approach to this since its an access control bypass.
Comment #2
recrit commentedI've add a hook to allow for granting access to users that do not have a valid license and are not admins.
commit: http://drupalcode.org/project/commerce_file.git/commit/6859ad1
Refer the commerce_file.api.php on how to implement hook_commerce_file_download_unlicensed_access() and hook_commerce_file_download_unlicensed_access_alter()