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.

CommentFileSizeAuthor
commerce_file.patch705 bytesjody lynn

Comments

recrit’s picture

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

recrit’s picture

Status: Needs review » Fixed

I'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()

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.