Closed (fixed)
Project:
Commerce File
Version:
7.x-2.0-alpha1
Component:
Access Control
Priority:
Normal
Category:
Feature request
Assigned:
Unassigned
Reporter:
Created:
27 Jul 2013 at 00:58 UTC
Updated:
29 Aug 2013 at 16:41 UTC
I'm trying to create a hook for a role to be able to download all files but also enforce the download per file limits.
I have noticed that now the admin cannot download either now. The links do show as for other people they are hidden, but they show as plain text.
I'm hoping that the "check access" checkbox on the formatter would just open it up and allow anyone to download with the limits still enforcing.
Any suggestions?
Thanks
Comments
Comment #1
bojanz commentedRight now the admin user (or user with the "administer licenses" permission) can always download, it's never a plaintext link.
The user can access any files that he has licenses for.
I am assuming you want a role to access files that are licensable, but for which the user has no license?
This is not currently possible. Even if we made it possible, you wouldn't be able to track the file downloads (and limit them), because
that requires a license.
So it seems a hook won't help you much.
What's your use case?
Comment #2
surfkid commentedI ended up creating a new formatter to control the download links on a different site.
On my install of commerce file though, administrator has that permission and it shows plain text for all files for the admin.
I won't really download from those links, but was just wondering why it was plain text though.
Comment #3
bojanz commentedAs I said, it's not something I can reproduce, and it doesn't look possible from the code.
Every access / download check checks for user_access("administer licenses") and returns TRUE immediately if found.
Check if your admin user actually has that perm.
Comment #4
surfkid commentedThanks bojanz for the quick reply.
I checked the permission and the admin has the 'administer licenses' and it still shows plain text when showing file under the "add to cart"
Is there anything else I should check?
When a user purchases, and acquires a license, the link works great.
Comment #5
bojanz commentedAh, it's before license purchase.
As I said, a license is always needed for download.
I can add a hook for granting access before that, but the download limits will never work since they are keyed by license id.
Comment #6
surfkid commentedOh ok. So it works as designed.
I ended up hooking the "download link" from file entity to use alongside commerce file for this site.
Thank you for the info.
Keep up the good work!
Comment #7
bojanz commentedActually, let's do this properly.
Added a permission that allows license control to be bypassed:
http://drupalcode.org/project/commerce_file.git/commitdiff/221357c?hp=24...
So just grant your role the "bypass license control" permission and you're good to go.