--- rat/lonpageflip.pm 2021/04/29 17:45:25 1.103 +++ rat/lonpageflip.pm 2021/07/19 14:26:40 1.105 @@ -2,7 +2,7 @@ # # Page flip handler # -# $Id: lonpageflip.pm,v 1.103 2021/04/29 17:45:25 raeburn Exp $ +# $Id: lonpageflip.pm,v 1.105 2021/07/19 14:26:40 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -99,7 +99,7 @@ sub hash_src { } sub move { - my ($next,$endupmap,$direction) = @_; + my ($next,$endupmap,$direction,$firstres) = @_; my $safecount=0; my $allowed=0; my $deeplinkonly=0; @@ -116,7 +116,7 @@ sub move { $allowed = 0; } else { my $priv = &Apache::lonnet::allowed('bre',$url,$symb); - $allowed = (($priv eq 'F') || ($priv eq '2')); + $allowed = (($priv eq 'F') || ($priv eq '2') || ($priv eq 'A')); } $deeplinkonly = 0; if ($hash{'deeplinkonly_'.$next}) { @@ -128,7 +128,7 @@ sub move { $deeplinkonly = 1; } } - } elsif ($hash{'deeplinkonly_'.$prev}) { + } elsif (($hash{'deeplinkonly_'.$prev}) && (!$firstres)) { my ($value,$level) = split(/:/,$hash{'deeplinkonly_'.$prev}); if ($level eq 'resource') { $deeplinkonly = 1; @@ -256,23 +256,33 @@ sub first_accessible_resource { if (tie(%hash,'GDBM_File',$env{'request.course.fn'}.'.db', &GDBM_READER(),0640)) { $furl=$hash{'first_url'}; - my %args; - my ($url,$args) = split(/\?/,$furl); - foreach my $pair (split(/\&/,$args)) { + my (%args,$url,$argstr); + if ($furl =~ m{^/enc/}) { + ($url,$argstr) = split(/\?/,&Apache::lonenc::unencrypted($furl)); + } else { + ($url,$argstr) = split(/\?/,$furl); + } + foreach my $pair (split(/\&/,$argstr)) { my ($name,$value) = split(/=/,$pair); $args{&unescape($name)} = &unescape($value); } - if (!&Apache::lonnet::allowed('bre',$url,$args{'symb'})) { + my $priv = &Apache::lonnet::allowed('bre',$url,$args{'symb'}); + my $allowed = (($priv eq 'F') || ($priv eq '2') || ($priv eq 'A')); + if (!$allowed) { # Wow, we cannot see this ... move forward to the next one that we can see - my ($newrid,$newmap)=&move($hash{'first_rid'},$hash{'first_mapurl'},'forward'); + my ($newrid,$newmap)=&move($hash{'first_rid'},$hash{'first_mapurl'},'forward',1); # Build the new URL - my ($newmapid,$newresid)=split(/\./,$newrid); - my $symb=&Apache::lonnet::encode_symb($newmap,$newresid,$hash{'src_'.$newrid}); - $furl=&add_get_param($hash{'src_'.$newrid},{ 'symb' => $symb }); - if ($hash{'encrypted_'.$newrid}) { - $furl=&Apache::lonenc::encrypted($furl); + if ($newrid eq '') { + $furl = '/adm/navmaps'; + } else { + my ($newmapid,$newresid)=split(/\./,$newrid); + my $symb=&Apache::lonnet::encode_symb($newmap,$newresid,$hash{'src_'.$newrid}); + $furl=&add_get_param($hash{'src_'.$newrid},{ 'symb' => $symb }); + if ($hash{'encrypted_'.$newrid}) { + $furl=&Apache::lonenc::encrypted($furl); + } } - } + } untie(%hash); return $furl; } else {