Jump to:

23360 Posts in 18099 Topics by 2862 members

General Questions

SilverStripe Forums » General Questions » Creating a security group

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

Page: 1
Go to End
Author Topic: 789 Views
  • Harley
    Avatar
    Community Member
    153 Posts

    Creating a security group Link to this post

    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

  • Willr
    Avatar
    Forum Moderator
    5483 Posts

    Re: Creating a security group Link to this post

    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
    }

  • Harley
    Avatar
    Community Member
    153 Posts

    Re: Creating a security group Link to this post

    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

    789 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.