Index: openacs-4/packages/acs-authentication/tcl/local-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-authentication/tcl/local-procs.tcl,v diff -u -N -r1.29 -r1.30 --- openacs-4/packages/acs-authentication/tcl/local-procs.tcl 13 Jan 2005 13:54:42 -0000 1.29 +++ openacs-4/packages/acs-authentication/tcl/local-procs.tcl 4 Jun 2006 00:45:21 -0000 1.30 @@ -83,6 +83,7 @@ name "local" pretty_name "Local" aliases { + MergeUser auth::local::authentication::MergeUser Authenticate auth::local::authentication::Authenticate GetParameters auth::local::authentication::GetParameters } @@ -97,7 +98,41 @@ acs_sc::impl::delete -contract_name "auth_authentication" -impl_name "local" } +ad_proc -private auth::local::authentication::MergeUser { + from_user_id + to_user_id + {authority_id ""} +} { + Merge Implementation of local authentication. This will + merge the names, emails, usernames, permissions, etc + of the two users to merge. +} { + ns_log Notice "Starting auth::local::authentication::MergeUser" + db_transaction { + ns_log Notice " Merging user portraits" + ns_log notice " Merging username, email and basic info in general" + + set new_username "merged_$from_user_id" + append new_username "_$to_user_id" + + # Shall we keep the domain for email? + # Actually, the username 'merged_xxx_yyy' + # won't be an email, so we will keep it without + # domain + set new_email $new_username + + set rel_id [db_string getrelid { *SQL* }] + membership_rel::change_state -rel_id $rel_id -state "merged" + + acs_user::update -user_id $from_user_id -username "$new_username" -screen_name "$new_username" + party::update -party_id $from_user_id -email "$new_email" + + } + ns_log notice "Finishing auth::local::authentication::MergeUser" +} + + ad_proc -private auth::local::authentication::Authenticate { username password @@ -450,22 +485,24 @@ # LARS TODO: Move this out of the local driver and into the auth framework # Send password confirmation email to user - if { $generated_pwd_p || \ - [parameter::get -parameter RegistrationProvidesRandomPasswordP -package_id [ad_conn subsite_id] -default 0] || \ - [parameter::get -parameter EmailRegistrationConfirmationToUserP -package_id [ad_conn subsite_id] -default 0] } { + if { [set email_reg_confirm_p [parameter::get -parameter EmailRegistrationConfirmationToUserP -package_id [ad_conn subsite_id] -default 0]] != -1 } { + if { $generated_pwd_p || \ + [parameter::get -parameter RegistrationProvidesRandomPasswordP -package_id [ad_conn subsite_id] -default 0] || \ + $email_reg_confirm_p } { - with_catch errmsg { - auth::password::email_password \ - -username $username \ - -authority_id $authority_id \ - -password $password \ - -from [parameter::get -parameter NewRegistrationEmailAddress -package_id [ad_conn subsite_id] -default [ad_system_owner]] \ - -subject_msg_key "acs-subsite.email_subject_Registration_password" \ - -body_msg_key "acs-subsite.email_body_Registration_password" - } { - # We don't fail hard here, just log an error - global errorInfo - ns_log Error "Error sending registration confirmation to $email.\n$errorInfo" + with_catch errmsg { + auth::password::email_password \ + -username $username \ + -authority_id $authority_id \ + -password $password \ + -from [parameter::get -parameter NewRegistrationEmailAddress -package_id [ad_conn subsite_id] -default [ad_system_owner]] \ + -subject_msg_key "acs-subsite.email_subject_Registration_password" \ + -body_msg_key "acs-subsite.email_body_Registration_password" + } { + # We don't fail hard here, just log an error + global errorInfo + ns_log Error "Error sending registration confirmation to $email.\n$errorInfo" + } } }