diff --git a/security/Group.php b/security/Group.php index 4ca4398a6..b310c562c 100644 --- a/security/Group.php +++ b/security/Group.php @@ -49,6 +49,19 @@ class Group extends DataObject { return $doSet; } + function getAllChildren() { + $doSet = new DataObjectSet(); + + if ($children = DataObject::get('Group', 'ParentID = '.$this->ID)) { + foreach($children as $child) { + $doSet->push($child); + $doSet->merge($child->getAllChildren()); + } + } + + return $doSet; + } + /** * Caution: Only call on instances, not through a singleton. *