Jump to:

17452 Posts in 4473 Topics by 1971 members


SilverStripe Forums » Archive » Changing the way the group heirarchy behaves

Our old forums are still available as a read-only archive.

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

Page: 1
Go to End
Author Topic: 1856 Views
  • ScottiouS
    Community Member
    54 Posts

    Changing the way the group heirarchy behaves Link to this post

    Best explained in an example:

    Member A is a member of the Group Y

    Group Y is the child of X and parent of Z

    So folder structure looks like

    | - Y
    | | - Z

    Currently in silverstripe Member A has access to Group Y (of which they are a member) and Group X (of which they inherit) and not group Z.

    What I required was the opposite.. so Member A has access to children rather than parent groups. By changing the code below you get Member A having access to Group Y and Group Z, not Group X.


    Changed one line the Groups() function from:




    I could not see a simpler way of changing this by not editing the core. Hope this helps some people.

  • Ingo
    Forum Moderator
    801 Posts

    Re: Changing the way the group heirarchy behaves Link to this post

    thanks for the good example - yeah, it seems logical that a group inheritance should be toward more specific (=children) rather than more generic (=parents) - it allows for much more finegrained controls.
    although this is a one-line fix, i think we need some unit tests to verify this behaviour (on GroupTest.php), with this hierarchy:

    X (member1)
    --Y1 (member2)
    ----Z1 (member3)
    --Y2 (member4)

    - member1 has access to X, Y1, Z1, Y2
    - member2 has access to Y1, Z1
    - member3 has access to Z1
    - member4 has access to Y2

    Unit tests are fairly easy to write (see http://doc.silverstripe.com/doku.php?id=testing-guide) - ScottiouS, do you want to give it a go?

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.