CREATE OR REPLACE FUNCTION
    aus_find_all_user_flags(integer, integer)
RETURNS
    integer
AS '
    DECLARE
        member_of_row RECORD; --
    BEGIN
        FOR member_of_row IN
            SELECT member_of FROM aus_user_membership WHERE user_id = $2
        LOOP
            PERFORM aus_find_all_user_flags($1, member_of_row.member_of); --
        END LOOP; --
        
        PERFORM aus_find_user_flags($1, $2); --

        RETURN 1; --
    END; --
' LANGUAGE plpgsql;
