--- rat/lonpageflip.pm 2003/09/17 17:50:49 1.44 +++ rat/lonpageflip.pm 2004/11/11 19:43:22 1.50 @@ -2,7 +2,7 @@ # # Page flip handler # -# $Id: lonpageflip.pm,v 1.44 2003/09/17 17:50:49 albertel Exp $ +# $Id: lonpageflip.pm,v 1.50 2004/11/11 19:43:22 albertel Exp $ # # Copyright Michigan State University Board of Trustees # @@ -82,6 +82,14 @@ sub fullmove { return($rid,$mapurl); } +sub hash_src { + my ($id)=@_; + if ($hash{'encrypted_'.$id}) { + return &Apache::lonenc::encrypted($hash{'src_'.$id}); + } + return $hash{'src_'.$id}; +} + sub move { my ($rid,$mapurl,$direction)=@_; my $startoutrid=$rid; @@ -120,6 +128,10 @@ sub move { $hash{'map_type_'.$hash{'map_pc_'.$hash{'src_'.$next}}} eq 'sequence') { $mapurl=$hash{'src_'.$next}; $next=$hash{'map_start_'.$hash{'src_'.$next}}; + } elsif ( +# This jumps back up from an empty sequence, to a page up one level + $hash{'map_type_'.$hash{'map_pc_'.$hash{'src_'.$next}}} eq 'page') { + $mapurl=$hash{'map_id_'.(split(/\./,$next))[0]}; } } elsif ((split(/\./,$startoutrid))[0]!=(split(/\./,$next))[0]) { @@ -156,7 +168,11 @@ sub move { $hash{'map_type_'.$hash{'map_pc_'.$hash{'src_'.$next}}} eq 'sequence') { $mapurl=$hash{'src_'.$next}; $next=$hash{'map_finish_'.$hash{'src_'.$next}}; - } + } elsif ( + $hash{'map_type_'.$hash{'map_pc_'.$hash{'src_'.$next}}} eq 'page') { +# This jumps back up from an empty sequence, to a page up one level + $mapurl=$hash{'map_id_'.(split(/\./,$next))[0]}; + } } elsif ((split(/\./,$startoutrid))[0]!=(split(/\./,$next))[0]) { # This comes back up from a map (going up one level); @@ -190,6 +206,10 @@ sub handler { $ENV{'form.postdata'}=~/(\w+)\:(.*)/; my $direction=$1; my $currenturl=$2; + if ($currenturl=~m|^/enc/|) { + $currenturl=&Apache::lonenc::unencrypted($currenturl); + } + $currenturl=~s/\.\d+\.(\w+)$/\.$1/; if ($direction eq 'return') { # -------------------------------------------------------- Return to last known my $last; @@ -204,9 +224,15 @@ sub handler { my ($murl,$fn)=&Apache::lonnet::decode_symb($last); my $id; ($murl,$id,$fn)=&Apache::lonnet::decode_symb(&Apache::lonnet::symbread($fn)); - $newloc=$hash{'src_'. - $hash{'map_pc_'.&Apache::lonnet::clutter($murl)}.'.'.$id}; - unless ($newloc) { $newloc='/adm/noidea.html'; } + $id=$hash{'map_pc_'.&Apache::lonnet::clutter($murl)}.'.'.$id; + $newloc=$hash{'src_'.$id}; + &Apache::lonnet::logthis(" hrrm 1 "); + if ($newloc) { + if ($hash{'encrypted_'.$id}) { $newloc=&Apache::lonenc::encrypted($newloc); } + + } else { + $newloc='/adm/noidea.html'; + } untie %hash; } else { $newloc='/adm/noidea.html'; @@ -259,7 +285,8 @@ sub handler { # -------------------------------------- Do we have one and only one empty URL? my $safecount=0; while (($next) && ($next!~/\,/) && - ((!$hash{'src_'.$next}) || ($hash{'randomout_'.$next})) + ((!$hash{'src_'.$next}) || + ((!$ENV{'request.role.adv'}) && $hash{'randomout_'.$next})) && ($safecount<10000)) { ($next,$endupmap)=&move($next,$endupmap,$direction); $safecount++; @@ -270,7 +297,7 @@ sub handler { @possibilities=split(/\,/,$next); if ($#possibilities==0) { # ---------------------------------------------- Only one possibility, redirect - $redirecturl=$hash{'src_'.$next}; + $redirecturl=&hash_src($next); $cachehash{$endupmap} {&Apache::lonnet::declutter($redirecturl)} =(split(/\./,$next))[1]; @@ -388,7 +415,7 @@ ENDNONE } } else { # ---------------------------------------- No, could not determine where we are - if ( $Apache::lonnet::mod_perl_version() == 2 ) { + if ( &Apache::lonnet::mod_perl_version() == 2 ) { &Apache::lonnet::cleanenv(); } $r->internal_redirect('/adm/ambiguous');