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'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.

General Questions /

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

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

Creating a security group


Go to End


3 Posts   1213 Views

Avatar
Harley

Community Member, 165 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, 5523 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, 165 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