Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

All other Modules /

Discuss all other Modules here.

Moderators: martimiz, Sean, biapar, Willr, Ingo, swaiba, simon_w

SecureFiles 0.21 Released - Testers + Translations please!


Go to End
Reply


44 Posts   6085 Views

Avatar
Derek

Community Member, 6 Posts

2 April 2011 at 7:45am

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.

Avatar
klikhier

Community Member, 150 Posts

6 April 2011 at 4:32am

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"?

Avatar
NicolasLeuenberger

Community Member, 10 Posts

21 July 2011 at 8:06am

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

Avatar
Hamish

Community Member, 712 Posts

22 July 2011 at 12:29pm

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 [url=https://github.com/hamishcampbell/silverstripe-securefiles/blob/master/code/SecureFileMemberPermissionDecorator.php]SecureFileMemberPermissionDecorator.php[/url] and how to apply decorators in [url=https://github.com/hamishcampbell/silverstripe-securefiles/blob/master/_config.php]_config.php[/url].

Go to Top