Index: openacs-4/packages/xotcl-core/tcl/context-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/xotcl-core/tcl/context-procs.tcl,v diff -u -r1.75.2.13 -r1.75.2.14 --- openacs-4/packages/xotcl-core/tcl/context-procs.tcl 2 Feb 2020 20:50:09 -0000 1.75.2.13 +++ openacs-4/packages/xotcl-core/tcl/context-procs.tcl 21 Mar 2020 06:18:35 -0000 1.75.2.14 @@ -344,7 +344,31 @@ } return ${:user_id} } + ConnectionContext ad_instproc eval_as_user {-user_id:integer cmd} { + Run a command as the specified different user. Essentially, this + method updates xo::cc and the ad_conn array array with the + specified user, runs the command and resets the user to the + previous value. + + @param user_id switch temporarily to this user + @param cmd command to be exevuted + + } { + #ns_log notice "RUN AS USER $user_id $cmd" + set result "" + set current_user_id [:get_user_id] + try { + :set_user_id $user_id + :uplevel $cmd + } on ok {r} { + set result $r + } finally { + :set_user_id $current_user_id + } + return $result + } + ConnectionContext instproc returnredirect {-allow_complete_url:switch url} { #:log "--rp" set :__continuation [expr {$allow_complete_url @@ -535,7 +559,7 @@ try { nsf::parseargs $name:$constraint [list $value] - + } on error {errorMsg} { if {[ns_conn isconnected]} { ad_return_complaint 1 [ns_quotehtml $errorMsg]