--- loncom/interface/lontiny.pm 2024/11/17 04:48:15 1.23 +++ loncom/interface/lontiny.pm 2025/02/07 20:23:42 1.24 @@ -2,7 +2,7 @@ # Extract domain, courseID, and symb from a shortened URL, # and switch role to a role in designated course. # -# $Id: lontiny.pm,v 1.23 2024/11/17 04:48:15 raeburn Exp $ +# $Id: lontiny.pm,v 1.24 2025/02/07 20:23:42 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -102,11 +102,16 @@ sub handler { my $newlauncher = &launch_check($r->uri,$symb,$cdom,$cnum); my ($map,$resid,$url) = &Apache::lonnet::decode_symb($symb); if (&Apache::lonnet::is_on_map($url)) { - my $realuri; + my ($realuri,$reinitresult,$reinitchecked); if ((&Apache::lonnet::EXT('resource.0.hiddenresource',$symb) =~ /^yes$/i) && (!$env{'request.role.adv'})) { - $env{'user.error.msg'}=$r->uri.':bre:1:1:Access to resource denied'; - return HTTP_NOT_ACCEPTABLE; + my $loncaparev = $r->dir_config('lonVersion'); + ($reinitresult,my @reinit) = &Apache::loncommon::needs_coursereinit($loncaparev); + $reinitchecked = 1; + unless (($reinitresult eq 'main') || ($reinitresult eq 'both')) { + $env{'user.error.msg'}=$r->uri.':bre:1:1:Access to resource denied'; + return HTTP_NOT_ACCEPTABLE; + } } if ((&Apache::lonnet::EXT('resource.0.encrypturl',$symb) =~ /^yes$/i) && (!$env{'request.role.adv'})) { @@ -126,13 +131,17 @@ sub handler { $realuri .= '?symb='.$symb; } } - my ($update,$reinitresult); + my $update; # Check if course needs to be re-initialized if ($newlauncher) { $update = 1; + } elsif (($reinitresult eq 'main') || ($reinitresult eq 'both')) { + $update = 1; } else { - my $loncaparev = $r->dir_config('lonVersion'); - ($reinitresult,my @reinit) = &Apache::loncommon::needs_coursereinit($loncaparev); + if (!$reinitchecked) { + my $loncaparev = $r->dir_config('lonVersion'); + ($reinitresult,my @reinit) = &Apache::loncommon::needs_coursereinit($loncaparev); + } if (($reinitresult eq 'main') || ($reinitresult eq 'both')) { $update = 1; } elsif (!-e $env{'request.course.fn'}.'.db') { @@ -161,6 +170,10 @@ sub handler { $env{'user.error.msg'}=$r->uri.':bre:0:0:Course not initialized'; $env{'user.reinit'} = 1; return HTTP_NOT_ACCEPTABLE; + } elsif ((&Apache::lonnet::EXT('resource.0.hiddenresource',$symb) =~ /^yes$/i) && + (!$env{'request.role.adv'})) { + $env{'user.error.msg'}=$r->uri.':bre:1:1:Access to resource denied'; + return HTTP_NOT_ACCEPTABLE; } } if (($reinitresult eq 'both') || ($reinitresult eq 'supp')) {