src/Security/Member_GroupSet.php
public function foreignIDFilter($id = null)
    {
        if ($id === null) {
            $id = $this->getForeignID();
        }

        // Find directly applied groups
        $manyManyFilter = parent::foreignIDFilter($id);
        $query = SQLSelect::create('"Group_Members"."GroupID"', '"Group_Members"', $manyManyFilter);
        $groupIDs = $query->execute()->column();

        // Get all ancestors, iteratively merging these into the master set
        $allGroupIDs = [];
        while ($groupIDs) {
            $allGroupIDs = array_merge($allGroupIDs, $groupIDs);
            $groupIDs = DataObject::get(Group::class)->byIDs($groupIDs)->column("ParentID");
            $groupIDs = array_filter($groupIDs);
        }

        // Add a filter to this DataList
        if (!empty($allGroupIDs)) {
            $allGroupIDsPlaceholders = DB::placeholders($allGroupIDs);
            return ["\"Group\".\"ID\" IN ($allGroupIDsPlaceholders)" => $allGroupIDs];
        }

        return ['"Group"."ID"' => 0];
    }
public function foreignIDFilter($id = null)
    {
        if ($id === null) {
            $id = $this->getForeignID();
        }

        // Find directly applied groups
        $manyManyFilter = parent::foreignIDFilter($id);
        $query = SQLSelect::create('"Group_Members"."GroupID"', '"Group_Members"', $manyManyFilter);
        $groupIDs = $query->execute()->column();

        // Get all ancestors, iteratively merging these into the master set
        $allGroupIDs = [];
        while ($groupIDs) {
            $allGroupIDs = array_merge($allGroupIDs, $groupIDs);
            $groupIDs = DataObject::get(Group::class)->byIDs($groupIDs)->column("ParentID");
            $groupIDs = array_filter($groupIDs);
        }

        // Add a filter to this DataList
        if (!empty($allGroupIDs)) {
            $allGroupIDsPlaceholders = DB::placeholders($allGroupIDs);
            return ["\"Group\".\"ID\" IN ($allGroupIDsPlaceholders)" => $allGroupIDs];
        }

        return ['"Group"."ID"' => 0];
    }
public function foreignIDFilter ( $ id = null ) { if ( $ id === null ) { $ id = $ this -> getForeignID ( ) ; } // Find directly applied groups $ manyManyFilter = parent :: foreignIDFilter ( $ id ) ; $ query = SQLSelect :: create ( '"Group_Members"."GroupID"' , '"Group_Members"' , $ manyManyFilter ) ; $ groupIDs = $ query -> execute ( ) -> column ( ) ; // Get all ancestors, iteratively merging these into the master set $ allGroupIDs = [ ] ; while ( $ groupIDs ) { $ allGroupIDs = array_merge ( $ allGroupIDs , $ groupIDs ) ; $ groupIDs = DataObject :: get ( Group :: class ) -> byIDs ( $ groupIDs ) -> column ( "ParentID" ) ; $ groupIDs = array_filter ( $ groupIDs ) ; } // Add a filter to this DataList if ( ! empty ( $ allGroupIDs ) ) { $ allGroupIDsPlaceholders = DB :: placeholders ( $ allGroupIDs ) ; return [ "\"Group\".\"ID\" IN ($allGroupIDsPlaceholders)" => $ allGroupIDs ] ; } return [ '"Group"."ID"' => 0 ] ; }
Link this group set to a specific member.

Recursively selects all groups applied to this member, as well as any
parent groups of any applied groups

@param array|int|string|null $id (optional) An ID or an array of IDs - if not provided, will use the current
ids as per getForeignID
@return array Condition In array(SQL => parameters format)
Link this group set to a specific member .