Index: openacs-4/packages/acs-subsite/tcl/group-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-subsite/tcl/group-procs.tcl,v diff -u -r1.16 -r1.16.2.1 --- openacs-4/packages/acs-subsite/tcl/group-procs.tcl 10 Nov 2003 12:35:39 -0000 1.16 +++ openacs-4/packages/acs-subsite/tcl/group-procs.tcl 27 Nov 2003 13:14:55 -0000 1.16.2.1 @@ -426,7 +426,8 @@ } { Adds a user to a group, checking that the rel_type is permissible given the user's privileges, Can default both the rel_type and the member_state to their relevant values. - Deletes any existing relation of the same rel_type between the same group and the same user. + Deletes any existing membership relation between the same group and the same user, + regardless of the specific rel_type of that membership_relation. } { set admin_p [permission::permission_p -object_id $group_id -privilege "admin"] @@ -450,9 +451,18 @@ -create_p $create_p] } - set existing_rel_id [relation::get_id -object_id_one $group_id -object_id_two $user_id -rel_type $rel_type] - if { ![empty_string_p $existing_rel_id] } { - relation_remove $existing_rel_id + # Find any existing membership_relations and remove them + set existing_rel_ids [db_list select_existing_membership_rel { + select r.rel_id + from acs_rels r, + membership_rels m + where r.object_id_one = :group_id + and r.object_id_two = :user_id + and m.rel_id = r.rel_id + }] + + foreach rel_id $existing_rel_ids { + relation_remove $rel_id } relation_add -member_state $member_state $rel_type $group_id $user_id