src/Security/Permission.php
public static function groupList($memberID = null)
    {
        // Default to current member, with session-caching
        if (!$memberID) {
            $member = Security::getCurrentUser();
            if ($member && isset($_SESSION['Permission_groupList'][$member->ID])) {
                return $_SESSION['Permission_groupList'][$member->ID];
            }
        } else {
            $member = DataObject::get_by_id("SilverStripe\\Security\\Member", $memberID);
        }

        if ($member) {
            // Build a list of the IDs of the groups.  Most of the heavy lifting
            // is done by Member::Groups
            // NOTE: This isn't effecient; but it's called once per session so
            // it's a low priority to fix.
            $groups = $member->Groups();
            $groupList = array();

            if ($groups) {
                foreach ($groups as $group) {
                    $groupList[] = $group->ID;
                }
            }


            // Session caching
            if (!$memberID) {
                $_SESSION['Permission_groupList'][$member->ID] = $groupList;
            }

            return isset($groupList) ? $groupList : null;
        }
        return null;
    }
public static function groupList($memberID = null)
    {
        // Default to current member, with session-caching
        if (!$memberID) {
            $member = Security::getCurrentUser();
            if ($member && isset($_SESSION['Permission_groupList'][$member->ID])) {
                return $_SESSION['Permission_groupList'][$member->ID];
            }
        } else {
            $member = DataObject::get_by_id("SilverStripe\\Security\\Member", $memberID);
        }

        if ($member) {
            // Build a list of the IDs of the groups.  Most of the heavy lifting
            // is done by Member::Groups
            // NOTE: This isn't effecient; but it's called once per session so
            // it's a low priority to fix.
            $groups = $member->Groups();
            $groupList = array();

            if ($groups) {
                foreach ($groups as $group) {
                    $groupList[] = $group->ID;
                }
            }


            // Session caching
            if (!$memberID) {
                $_SESSION['Permission_groupList'][$member->ID] = $groupList;
            }

            return isset($groupList) ? $groupList : null;
        }
        return null;
    }
public static function groupList ( $ memberID = null ) { // Default to current member, with session-caching if ( ! $ memberID ) { $ member = Security :: getCurrentUser ( ) ; if ( $ member && isset ( $ _SESSION [ 'Permission_groupList' ] [ $ member -> ID ] ) ) { return $ _SESSION [ 'Permission_groupList' ] [ $ member -> ID ] ; } } else { $ member = DataObject :: get_by_id ( "SilverStripe\\Security\\Member" , $ memberID ) ; } if ( $ member ) { // Build a list of the IDs of the groups.  Most of the heavy lifting // is done by Member::Groups // NOTE: This isn't effecient; but it's called once per session so // it's a low priority to fix. $ groups = $ member -> Groups ( ) ; $ groupList = array ( ) ; if ( $ groups ) { foreach ( $ groups as $ group ) { $ groupList [ ] = $ group -> ID ; } } // Session caching if ( ! $ memberID ) { $ _SESSION [ 'Permission_groupList' ] [ $ member -> ID ] = $ groupList ; } return isset ( $ groupList ) ? $ groupList : null ; } return null ; }
Get the list of groups that the given member belongs to.

Call without an argument to get the groups that the current member
belongs to. In this case, the results will be session-cached.

@param int $memberID The ID of the member. Leave blank for the current
member.
@return array Returns a list of group IDs to which the member belongs
to or NULL.
Get the list of groups that the given member belongs to .