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.

General Questions /

General questions about getting started with SilverStripe that don't fit in any of the categories above.

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

Creating a security group


Reply


3 Posts   844 Views

Avatar
Harley

Community Member, 153 Posts

8 September 2009 at 9:39am

Ok, I'm aware that I can go in to the security tab and do this, but here is what I would like to be able to do:

I have a client list, I would like to be able to asign to each client a group of members that belong to each client page.

I would like to create a security group on the fly for each client page and make each member corresponding to their client page a login so they can access the client page.

I know this will be possible, Silverstripe hasn't let me down yet, but does anyone have or know a good tutorial or resource that could explain how this can be done?

Regards

Harley

Avatar
Willr

Forum Moderator, 5513 Posts

8 September 2009 at 5:55pm

I would like to create a security group on the fly for each client page and make each member corresponding to their client page a login so they can access the client page.

I would override the onBeforeWrite() function (or onAfterWrite()) on the client page which created a group if it didn't exist. Heres an outline of what you could do.

// ClientPage.php
function onBeforeWrite() {

// check for existing group (using a DataObject::get('Group');
// if that returns false then do something like $group = new Group();
// $group->Title = $this->Title;
// $group->write();

parent::onBeforeWrite(); // important
}

Avatar
Harley

Community Member, 153 Posts

9 September 2009 at 4:20am

Excellent, this what I need to know.

So I am correct in assuming that doing this would mean that each time I add a new member it will check first to see if that group exists already, if it does then it will just add my new member to that group?

I'm liking Silverstripe more and more by the day. When is the book available in the UK?

Thanks