I'm wondering if it's possible to hide folders in the admin if the user who is logged in doesn't have access to the files. Would there be a way to change the root of the files folder according to the group logged in? A folder could be created for each group and this would become the root (instead of 'assets') for that group. The group could not see or edit their folder nor could they access files above their folder.
We've moved the forum!
Please use forum.silverstripe.org for any new questions
(announcement).
The forum archive will stick around, but will be read only.
You can also use our Slack channel
or StackOverflow to ask for help.
Check out our community overview for more options to contribute.
Hamish, when I use $Link in my template to allow registered users to download a file, the filename contains the complete path (e.g. "assets-SecureFiles-SomeFolder-filename.doc"). Is there a way to prevent this from happening so that the filename is just "filename.doc"?
Hi Hamish
I try to extend File as you suggest for granting access, but I'm not sure how to do that. I tried the following in mysite/code/CustomFile.php:
class CustomFile extends File{
function canViewSecured(){
return true;
}
}
Yes, I know, this would grant access to all files. It's not a finished class, but first I need to know whether the direction is right. Anyway. this example doesn't work. Any tipps?
In the end I try to grant access to files that are attached to Pages only if the visitor has the right to view the page. It's for a member area.
Any help is deeply appreciated.
Nicolas
Hi Nicolas
Almost, but instead of subclassing File you need to create a Decorator and apply it to the File object. For example, have a look at SecureFileMemberPermissionDecorator.php and how to apply decorators in _config.php.