Index: openacs-4/packages/xotcl-core/xotcl-core.info =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/xotcl-core/xotcl-core.info,v diff -u -r1.106.2.15 -r1.106.2.16 --- openacs-4/packages/xotcl-core/xotcl-core.info 8 Mar 2020 17:01:46 -0000 1.106.2.15 +++ openacs-4/packages/xotcl-core/xotcl-core.info 21 Mar 2020 06:18:35 -0000 1.106.2.16 @@ -10,7 +10,7 @@ t xotcl - + Gustaf Neumann XOTcl library functionality (e.g. thread handling, online documentation, Generic Form and List Classes) 2017-08-06 @@ -43,7 +43,7 @@ BSD-Style 2 - + 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]