Index: openacs-4/packages/dotlrn/tcl/dotlrn-callback-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn/tcl/dotlrn-callback-procs.tcl,v diff -u -r1.1.2.1 -r1.1.2.2 --- openacs-4/packages/dotlrn/tcl/dotlrn-callback-procs.tcl 19 Jul 2005 06:49:41 -0000 1.1.2.1 +++ openacs-4/packages/dotlrn/tcl/dotlrn-callback-procs.tcl 19 Jul 2005 22:20:26 -0000 1.1.2.2 @@ -67,3 +67,64 @@ application_data_link::new -this_object_id $contact_id -target_object_id $fs_id } } + +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] + + # 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" + } + + return $result +} \ No newline at end of file