This bug may be related to the changes to the code caused by #1395488: Create a 7.x-2.x branch based on commerce_license.
Roles with the permission "Create Commerce File Licenses" cannot upload files as part of a commerce product. The role must be assigned the "Administer Commerce File" or the "Administer Commerce File field type" permissions to be able to upload files. This limits the creation of download products to administrators only.
This problem seems to reside in the function commerce_file_field_access(). Initial investigation suggests that the module expects $entity_type (which is always "product_type" when updating/creating a product) to be "commerce_file_license". This whole access function probably needs to be rewritten.
Let me know if I am correct in my thinking. Thanks.
| Comment | File | Size | Author |
|---|---|---|---|
| #6 | Access_Limits-1406874-6.patch | 2.43 KB | tommy kaneko |
Comments
Comment #1
recrit commentedthe field on the product is the commerce_file field type so they need - "Administer Commerce File field type" permission. The other permissions are for the license entity that gets created after purchase.
Comment #2
tommy kaneko commentedAh yes, apologies.
I guess what I am looking for is a way to restrict the "Access Limits" options to certain roles only. I don't think there is a way to do this yet. If there isn't, then I can try to make a patch to make this happen. Let me know.
Comment #3
recrit commentedthere is not... the limit settings are part of the field. You might be able to disable the settings inputs by implementing hook_field_widget_form_alter()
Comment #4
tommy kaneko commentedI have done exactly that. Here is the code I used to hack a sensible solution:
Create a new module with the following code:
I still think there should be a feature that allows this part of the field to be hidden and only use default values. I suggest the permission "Administer Commerce File field type" should be split into "Upload Commerce File field" and "Administer Commerce File Access Limits". What do you think? I may be able to make a patch for this if you think it worthwhile.
Comment #5
recrit commentedupdated the title to reflect the feature request.
Yes, submit a patch and I can review it.
Comment #6
tommy kaneko commentedPatch attached adds new permission: "Administer Commerce File Access Limits" which allows users to change the Access Limits for a Commerce File Field only if they have the permission.
Comment #7
batigol commentededited
Comment #8
recrit commentedThe field access and download access has bee revamped per #1467796: Administrator should have access to aall files. Please review that issue for the changes and test the latest dev.
Commerce File will not natively handle the 'access limits' permission as s requested. There are numerous admin permissions already:
"administer commerce file", "administer commerce_file_license", "access any commerce_file_license", "administer commerce_file field type"
This should be handled by implementing a hook_field_widget_form_alter (http://api.drupal.org/api/drupal/modules%21field%21field.api.php/functio...)
Example: