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.

We're retiring the forums!

The SilverStripe forums have passed their heyday. They'll stick around, but will be read only. We'd encourage you to get involved in the community via the following channels instead:

DataObjectManager Module /

Discuss the DataObjectManager module, and the related ImageGallery module.

Moderators: martimiz, UncleCheese, Sean, Ed, biapar, Willr, Ingo, swaiba

Restrict album view access by user?

Go to End

4 Posts   1390 Views


Community Member, 117 Posts

14 June 2010 at 1:03pm

Edited: 14/06/2010 1:06pm

I would like to create an image gallery, and in it create private albums for individual clients. So any one client would visit the gallery page and be prompted to login before seeing anything. When a client logs in, he/she will then ONLY be able to see an album/s that have specifically been assigned view permission for that client. Can anyone give me some suggestions as to how I might go about this?

Note: From my initial investigation of user permissions it would seem you can only assign permissions by Group. If that's the case then I have no problem creation new group for each client, as there will only ever be a few clients/albums at one time.

Any help/pointers appreciated



Community Member, 117 Posts

16 June 2010 at 1:15am

Hi Uncle Cheese, could you spare a minute to comment on whether this is possible fairly easily or would it require extensive coding?


Community Member, 117 Posts

21 June 2010 at 9:26am

or failing that let me know whether it might be considered a wish list item?


Forum Moderator, 4102 Posts

21 June 2010 at 9:56am

I don't think it would be too hard at all. Just subclass your ImageGalleryPage and ImageGalleryAlbum classses, and set the ImageGalleryPage subclass to have $albumClass = "YourAlbumClass";

in the album subclass, add a has_one for Group, and create a canView() function to check the member's group against that of the album.

and In the image gallery page controller subclasss, overload the album() function

function album() {
if( $this->CurrentAlbum()->canView() )
return Security::permissionFailure($this, "Cannot access that album");
return array();

Probably overload your Albums() method in the model, too, so you can hide ones that can't be viewed from the nav and so forth.. but the canView method might actually be enough, I'm not sure.