--- loncom/publisher/lonpublisher.pm 2024/12/20 00:13:52 1.305 +++ 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.305 2024/12/20 00:13:52 raeburn Exp $ +# $Id: lonpublisher.pm,v 1.307 2025/01/04 21:23:33 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -428,7 +428,7 @@ sub common_access { } my %lt = &Apache::lonlocal::texthash( 'default' => 'System wide - can be used for any courses system wide', - 'domain' => 'Domain only - use limited to courses in the domai', + 'domain' => 'Domain only - use limited to courses in the domain', 'custom' => 'Customized right of use ...', 'public' => 'Public - no authentication or authorization required for use', 'closed' => 'Closed - XML source is closed to everyone', @@ -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 {