Index: openacs-4/packages/dotlrn/tcl/dotlrn-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn/tcl/dotlrn-procs.tcl,v diff -u -N -r1.74.8.1 -r1.74.8.2 --- openacs-4/packages/dotlrn/tcl/dotlrn-procs.tcl 16 Jun 2005 22:32:19 -0000 1.74.8.1 +++ openacs-4/packages/dotlrn/tcl/dotlrn-procs.tcl 7 Jul 2005 23:13:26 -0000 1.74.8.2 @@ -412,66 +412,65 @@ } -namespace eval dotlrn::merge { - ad_proc -callback MergeShowUserInfo -impl dotlrn { - -user_id:required - } { - Show dotlrn items - } { - set msg "dotLRN items for $user_id" - ns_log Notice $msg - set result [list $msg] + +ad_proc -callback merge::MergeShowUserInfo -impl dotlrn { + -user_id:required +} { + Show dotlrn items +} { + set msg "dotLRN items for $user_id" + ns_log Notice $msg + set result [list $msg] + + set from_rel_ids [db_list_of_lists get_from_rel_ids { *SQL* } ] + + foreach rel $from_rel_ids { + set l_rel_id [lindex $rel 0] + set l_rel_type [lindex $rel 1] + set l_community_id [lindex $rel 2] + lappend result [list "This user has the rel_type : $l_rel_type in community_id : $l_community_id" ] + } + + return $result +} + +ad_proc -callback merge::MergePackageUser -impl dotlrn { + -from_user_id:required + -to_user_id:required +} { + Merge the dotlrn items of two users. + The from_user_id is the user_id of the user + that will be deleted and all the dotlrn elements + of this user will be mapped to to_user_id. + +} { + ns_log Notice "Merging dotlrn" + + db_transaction { + + # select the communities where from_user_id belongs to and + # to_user_id does not belong. set from_rel_ids [db_list_of_lists get_from_rel_ids { *SQL* } ] foreach rel $from_rel_ids { set l_rel_id [lindex $rel 0] set l_rel_type [lindex $rel 1] set l_community_id [lindex $rel 2] - lappend result [list "This user has the rel_type : $l_rel_type in community_id : $l_community_id" ] + # Add to_user_id to the communities + # where from_user_id is with the same role + # Add the relation + dotlrn_community::add_user -rel_type $l_rel_type $l_community_id $to_user_id + } - - return $result - } - - ad_proc -callback MergePackageUser -impl dotlrn { - -from_user_id:required - -to_user_id:required - } { - Merge the dotlrn items of two users. - The from_user_id is the user_id of the user - that will be deleted and all the dotlrn elements - of this user will be mapped to to_user_id. - - } { - ns_log Notice "Merging dotlrn" - db_transaction { - - # select the communities where from_user_id belongs to and - # to_user_id does not belong. - set from_rel_ids [db_list_of_lists get_from_rel_ids { *SQL* } ] - - foreach rel $from_rel_ids { - set l_rel_id [lindex $rel 0] - set l_rel_type [lindex $rel 1] - set l_community_id [lindex $rel 2] - - # Add to_user_id to the communities - # where from_user_id is with the same role - # Add the relation - dotlrn_community::add_user -rel_type $l_rel_type $l_community_id $to_user_id - - } - - # remove the user - dotlrn::user_remove -user_id $from_user_id - - set result ".LRN merge is done" - } + # remove the user + dotlrn::user_remove -user_id $from_user_id - return $result - } -} \ No newline at end of file + set result ".LRN merge is done" + } + + return $result +}