Index: openacs-4/packages/dotlrn-ecommerce/www/admin/process-purchase-course.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-ecommerce/www/admin/process-purchase-course.tcl,v diff -u -r1.6 -r1.7 --- openacs-4/packages/dotlrn-ecommerce/www/admin/process-purchase-course.tcl 28 Jun 2005 22:44:26 -0000 1.6 +++ openacs-4/packages/dotlrn-ecommerce/www/admin/process-purchase-course.tcl 28 Jun 2005 23:14:13 -0000 1.7 @@ -325,9 +325,6 @@ lappend validate {name { ! [empty_string_p $name] || [template::element::get_value participant related_user] != -1 } "Please enter a name for the group" - } {name - { [db_string group {select 1 from groups where group_name = :name} -default 0] } - "Group name already exists" } {num_members { ! [empty_string_p $num_members] || [template::element::get_value participant related_user] != -1 } "Please enter the number of attendees" @@ -467,25 +464,31 @@ set item_count 1 if { $related_user == -1 && ! [empty_string_p $name] && ! [empty_string_p $num_members] } { set group_id [db_nextval acs_object_id_seq] - set unique_group_name "${name}_${group_id}" + + # Test once then give up + if { [db_string group {select 1 from groups where group_name = :unique_group_name} -default 0] } { + set group_id [db_nextval acs_object_id_seq] + set unique_group_name "${name}_${group_id}" + } + group::new -group_id $group_id -group_name $unique_group_name set section_community_id [db_string get_community_id "select community_id from dotlrn_ecommerce_section where section_id=:section_id" -default ""] if {[string equal "" $section_community_id]} { # FIXME error, do something clever here } for { set i 1 } { $i <= $num_members } { incr i } { array set new_user [auth::create_user \ - -username "${name} Attendee $i" \ - -email "[util_text_to_url -text ${name}-attendee-${i}]@example.com" \ + -username "${name} ${group_id} Attendee $i" \ + -email "[util_text_to_url -text ${name}-${group_id}-attendee-${i}]@mos.zill.net" \ -first_names "$name" \ -last_name "Attendee $i" \ -nologin] if { [info exists new_user(user_id)] } { relation_add -member_state approved membership_rel $group_id $new_user(user_id) } else { - ad_return_complaint 1 "There was a problem creating the account \"$name Attendee $i\"." + ad_return_complaint 1 "There was a problem creating the account \"$name $group_id Attendee $i\"." ad_script_abort } }