It would be nice if this module would check view permissions for the content type the file is attached to (via filefield).
In my use case I have two different roles and two different content types. Each role has access to one of these types. However, both roles have access to all uploaded private files. So it would be nice if the files would additionaly be protected by the "view content type" permission.
Comments
Comment #1
johnhanley commentedThis is an interesting request. However, does this assume the CCK "Content Permissions" module is enabled and the user has "view" permission for the particular field?
Comment #2
haggins commentedGood point. I don't know how ccks field permissions are implemented. But it should not be that hard to check if "Content Permissions" module is enabled and if it is, respect its permissons, too.
If a role has view access to a particular field but not to the content type the role is not able to see just this field at node/xy. So in this case the role shouldn't have access to a file even if access to the field is granted.
I think the hierarchy of permissions is as followed:
1. check private download permission
(check if file is associated with a field (if not return the file))
2. check view content type permission
3. check view field permission
Comment #3
johnhanley commentedYeah, I think your analysis is correct and this should be perfectly doable.
I have some professional and personal obligations that come first, but I will try and get to this within the next couple of weeks.
Thanks again for your suggestion.
John
Comment #4
ikeigenwijs commentedThis sounds ideal.
subscribe
Comment #5
johnhanley commentedI was attempting to implement this idea today, but then became stumped on exactly how to determine the file-node relationship. It's easy when the user is accessing the node itself, but it's more difficult to ascertain the nid when the file is accessed directly. I'll need some constructive input before continuing to spend anymore time on it.
Comment #6
haggins commentedFor me it looks as the main problem is, that you don't know the fields name and according to that you also don't know the content type, do you? In that case searching for your fid <-> nid relationship over all {content_type_*} tables seems to be a solution.
Another one:
Catch all field names of type "filefield" out of {content_node_field} and filter for each filefield its table ( {content_%fieldname} ) for your fid (which is always in the column "%fieldname_fid").
Comment #7
marcvangendIt's been a while since this issue was started, but I'll share my code anyway :-)
I had to solve a similar problem today, so this is what I put in a custom module:
As you probably can see in the code, the file-node relationship as mentioned in #5 is determined by loading the file object and calling the filefield_get_file_references() function.
Hope this helps anyone - all feedback is welcome!
Comment #8
johnhanley commented@marcvangend,
Thanks for sharing your code! I like the looks of it, very clean and efficient.
I'd curious to hear from the community whether this is a viable solution to the problem the OP presented and whether or not it makes sense to roll it into the Private Download and keep it as an external custom module if/when the needed arises.
All comments welcome.
Thanks,
John
Comment #9
marcvangendThanks for the feedback John. I'm curious to see what others think.
Comment #10
johnhanley commentedClosing due to Drupal 6 end-of-life cycle.