--- loncom/publisher/lonpublisher.pm 2024/12/27 04:01:41 1.306 +++ loncom/publisher/lonpublisher.pm 2025/01/04 21:23:33 1.307 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Publication Handler # -# $Id: lonpublisher.pm,v 1.306 2024/12/27 04:01:41 raeburn Exp $ +# $Id: lonpublisher.pm,v 1.307 2025/01/04 21:23:33 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -2254,6 +2254,18 @@ sub batchpublish { $srcfile=~/\.(\w+)$/; my $thistype=$1; +# +# If lonpublisher::batchpublish() is called directly from another package +# instead of via a call to lonpublisher::handler(), need to set the package +# scalars: $cuname and $cudom, and will unset when done. +# + my $clearvars; + if (($cuname eq '') && ($cudom eq '')) { + ($cuname,$cudom) = &Apache::lonnet::constructaccess($srcfile); + unless (($cuname eq '') && ($cudom eq '')) { + $clearvars = 1; + } + } my $thisembstyle=&Apache::loncommon::fileembstyle($thistype); @@ -2268,7 +2280,7 @@ sub batchpublish { # phase one takes # my ($source,$target,$style,$batch)=@_; my ($outstring,$error)=&publish($srcfile,$targetfile,$thisembstyle,1,$nokeyref); - + if ($usebuffer) { $output .= '

'.$outstring.'

'; } else { @@ -2286,6 +2298,10 @@ sub batchpublish { } } %env=%oldenv; + if ($clearvars) { + undef($cuname); + undef($cudom); + } if ($usebuffer) { return $output; } else {