Index: openacs-4/packages/acs-subsite/tcl/party-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-subsite/tcl/Attic/party-procs.tcl,v diff -u -r1.5 -r1.6 --- openacs-4/packages/acs-subsite/tcl/party-procs.tcl 29 Jan 2007 12:27:02 -0000 1.5 +++ openacs-4/packages/acs-subsite/tcl/party-procs.tcl 5 Dec 2007 08:23:27 -0000 1.6 @@ -283,5 +283,46 @@ } { return [db_string party_p {} -default 0] } + + ad_proc -private resolve_members { + -party_ids + {-single_p "1"} + } { + Get's a list of party_ids and resolves the groups to + individual parties. This should probably be written in + a recursive manner + + @author Malte Sussdorff + + @param party_ids Party_ids that need to be resolved + @param single_p Should the party only show up once even if it is in multiple groups + + @return list of party_ids where none of them is a group + } { + # Run through the party_ids and check if a group is in there. + set new_party_ids [list] + foreach party_id $party_ids { + if {[group::group_p -group_id $party_id]} { + foreach member_id [group::get_members -group_id $group_id] { + if {[group::group_p -group_id $member_id]} { + # This is a group, resolve it + acs_mail_lite::resolve_member -party_ids $member_id -single_p $single_p + } else { + lappend new_party_ids $member_id + } + } + } else { + lappend new_party_ids $party_id + } + } + + # If we only want to have the items of the list show up once + # We need to weed out duplicates + if {$single_p} { + return [lsort -unique $new_party_ids] + } else { + return $new_party_ids + } + } }