Index: openacs-4/packages/dotlrn/tcl/dotlrn-security-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn/tcl/dotlrn-security-procs.tcl,v diff -u -N -r1.58 -r1.58.2.1 --- openacs-4/packages/dotlrn/tcl/dotlrn-security-procs.tcl 13 Jan 2005 13:57:20 -0000 1.58 +++ openacs-4/packages/dotlrn/tcl/dotlrn-security-procs.tcl 31 May 2005 23:13:05 -0000 1.58.2.1 @@ -191,28 +191,41 @@ ad_proc -public remove_user_completely { {-user_id:required} + {-on_fail soft_delete} } { - Remove the user from ACS as well + Remove the user from ACS as well. Chances are pretty good that + this will fail because it's hard to chase down every piece + of content the user has ever put into the system. The net result is + that there may be stray referential integrity contraints that + will throw errors when we try to remove the user record permanently. + + @param on_fail indicates what we do if the permanent removal fails. Setting to + soft_delete will result in a repeat call to acs_user::delete + but this time without the -permanent flag. Setting to error + (or anything else) will result in re-throwing the original error. } { - # DEDS: for now let us not remove users with historical data. - # we assume this by looking at last_visit which is lame but - # the safest for now. the consortium might want to decide on - # whether we also want nuking of users with data present - set last_visit [acs_user::get_element -user_id $user_id -element last_visit] - if {[empty_string_p $last_visit]} { - if {[user_p -user_id $user_id]} { - user_remove -user_id $user_id - } - - # cycle through the applets and invoke their RemoveUser procs - foreach applet_key [dotlrn_applet::list_mounted_applets] { - dotlrn_community::applet_call \ - $applet_key \ - RemoveUser \ - [list $user_id] - } - + if {[user_p -user_id $user_id]} { + user_remove -user_id $user_id + } + + # cycle through the applets and invoke their RemoveUser procs + foreach applet_key [dotlrn_applet::list_mounted_applets] { + ns_log Debug "dotlrn::remove_user_completely: invoking RemoveUser for applet $applet_key" + dotlrn_community::applet_call \ + $applet_key \ + RemoveUser \ + [list $user_id] + } + + if { [catch { acs_user::delete -user_id $user_id -permanent + } errMsg] } { + ns_log Notice "dotlrn::remove_user_completely: permanent removal failed for user $user_id. Invoking on_fail option '$on_fail'" + if { [string equal $on_fail soft_delete] } { + acs_user::delete -user_id $user_id + } else { + error $errMsg + } } }