src/Security/Permission.php
public static function get_members_by_permission($code)
    {
        $toplevelGroups = self::get_groups_by_permission($code);
        if (!$toplevelGroups) {
            return new ArrayList();
        }

        $groupIDs = array();
        foreach ($toplevelGroups as $group) {
            $familyIDs = $group->collateFamilyIDs();
            if (is_array($familyIDs)) {
                $groupIDs = array_merge($groupIDs, array_values($familyIDs));
            }
        }

        if (empty($groupIDs)) {
            return new ArrayList();
        }

        $groupClause = DB::placeholders($groupIDs);
        /** @skipUpgrade */
        $members = Member::get()
            ->where(array("\"Group\".\"ID\" IN ($groupClause)" => $groupIDs))
            ->leftJoin("Group_Members", '"Member"."ID" = "Group_Members"."MemberID"')
            ->leftJoin("Group", '"Group_Members"."GroupID" = "Group"."ID"');

        return $members;
    }
public static function get_members_by_permission($code)
    {
        $toplevelGroups = self::get_groups_by_permission($code);
        if (!$toplevelGroups) {
            return new ArrayList();
        }

        $groupIDs = array();
        foreach ($toplevelGroups as $group) {
            $familyIDs = $group->collateFamilyIDs();
            if (is_array($familyIDs)) {
                $groupIDs = array_merge($groupIDs, array_values($familyIDs));
            }
        }

        if (empty($groupIDs)) {
            return new ArrayList();
        }

        $groupClause = DB::placeholders($groupIDs);
        /** @skipUpgrade */
        $members = Member::get()
            ->where(array("\"Group\".\"ID\" IN ($groupClause)" => $groupIDs))
            ->leftJoin("Group_Members", '"Member"."ID" = "Group_Members"."MemberID"')
            ->leftJoin("Group", '"Group_Members"."GroupID" = "Group"."ID"');

        return $members;
    }
public static function get_members_by_permission ( $ code ) { $ toplevelGroups = self :: get_groups_by_permission ( $ code ) ; if ( ! $ toplevelGroups ) { return new ArrayList ( ) ; } $ groupIDs = array ( ) ; foreach ( $ toplevelGroups as $ group ) { $ familyIDs = $ group -> collateFamilyIDs ( ) ; if ( is_array ( $ familyIDs ) ) { $ groupIDs = array_merge ( $ groupIDs , array_values ( $ familyIDs ) ) ; } } if ( empty ( $ groupIDs ) ) { return new ArrayList ( ) ; } $ groupClause = DB :: placeholders ( $ groupIDs ) ; /** @skipUpgrade */ $ members = Member :: get ( ) -> where ( array ( "\"Group\".\"ID\" IN ($groupClause)" => $ groupIDs ) ) -> leftJoin ( "Group_Members" , '"Member"."ID" = "Group_Members"."MemberID"' ) -> leftJoin ( "Group" , '"Group_Members"."GroupID" = "Group"."ID"' ) ; return $ members ; }
Returns all members for a specific permission.

@param string|array $code Either a single permission code, or a list of permission codes
@return SS_List Returns a set of member that have the specified
permission.
Returns all members for a specific permission .