How to restrict access to private files to members of an organic group?
-
I have an organic group with a file field that stores its files in a private directory (sites/default/files/private/). These files are visible only to members of that group. But, as is commonly known, if someone guesses the Drupal path even if he is not a member of that group or not even logged in, he can access that file by using the correct file link directly. How can I restrict file access to group members?
-
Answer:
OG provides no access control on attached files. I ran into the same situation and came up with two options. The file depot module (https://drupal.org/project/filedepot) integrates nicely with OG and does prevent users who are not members of a group from accessing files that are attached to a group. Another option is writing a custom module that implements hook_file_download. In that module you would have to get the node id of the file attachment then use that to determine what group the node belongs too then from there determine if the logged in user is a member of the group. If they are not a member of the group the module would return -1 which would give them access denied if they try to directly download the file via url.
user5950 at Drupal Answers Visit the source
Other answers
What John said is correct. In open scholar there is an option for private files and groups. We then using hook_file_download and verifying if the user has the privilege for that(in the group level and also site wide level)
Roy Segall
Related Q & A:
- How to restrict access to a sql server database from Azure?Best solution by Stack Overflow
- How do I access a Yahoo group archive?Best solution by Yahoo! Answers
- How can I access my group in Yahoo?Best solution by Yahoo! Answers
- How do I make all messages from my group private so only members can see them?Best solution by Yahoo! Answers
- How can I find a "private" group in Yahoo groups?Best solution by answers.yahoo.com
Just Added Q & A:
- How many active mobile subscribers are there in China?Best solution by Quora
- How to find the right vacation?Best solution by bookit.com
- How To Make Your Own Primer?Best solution by thekrazycouponlady.com
- How do you get the domain & range?Best solution by ChaCha
- How do you open pop up blockers?Best solution by Yahoo! Answers
For every problem there is a solution! Proved by Solucija.
-
Got an issue and looking for advice?
-
Ask Solucija to search every corner of the Web for help.
-
Get workable solutions and helpful tips in a moment.
Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.