--- rat/lonpageflip.pm 2002/04/11 19:21:52 1.22 +++ rat/lonpageflip.pm 2002/12/02 14:39:02 1.32 @@ -2,7 +2,7 @@ # # Page flip handler # -# $Id: lonpageflip.pm,v 1.22 2002/04/11 19:21:52 www Exp $ +# $Id: lonpageflip.pm,v 1.32 2002/12/02 14:39:02 bowersj2 Exp $ # # Copyright Michigan State University Board of Trustees # @@ -53,18 +53,29 @@ my %hash; sub addrid { my ($current,$new,$condid)=@_; unless ($condid) { $condid=0; } - if (&Apache::lonnet::allowed('bre',$hash{'src_'.$new})) { + if ($current) { $current.=','.$new; } else { $current=''.$new; } - } + return $current; } +sub fullmove { + my ($rid,$mapurl,$direction)=@_; + if (tie(%hash,'GDBM_File',$ENV{'request.course.fn'}.'.db', + &GDBM_READER(),0640)) { + ($rid,$mapurl)=&move($rid,$mapurl,$direction); + untie(%hash); + } + return($rid,$mapurl); +} + sub move { my ($rid,$mapurl,$direction)=@_; + my $startoutrid=$rid; my $next=''; @@ -73,7 +84,7 @@ sub move { if ($direction eq 'forward') { # --------------------------------------------------------------------- Forward if ($hash{'type_'.$rid} eq 'finish') { - $rid=$hash{'ids_/res/'.$mapurl}; + $rid=$hash{'ids_'.&Apache::lonnet::clutter($mapurl)}; } map { my $thiscond= @@ -95,16 +106,21 @@ sub move { } } split(/\,/,$posnext); if ($hash{'is_map_'.$next}) { +# This jumps to the beginning of a new map (going down level) if ( $hash{'map_type_'.$hash{'map_pc_'.$hash{'src_'.$next}}} eq 'sequence') { $mapurl=$hash{'src_'.$next}; $next=$hash{'map_start_'.$hash{'src_'.$next}}; } + } elsif + ((split(/\./,$startoutrid))[0]!=(split(/\./,$next))[0]) { +# This comes up from a map (coming up one level); + $mapurl=$hash{'map_id_'.(split(/\./,$next))[0]}; } } elsif ($direction eq 'back') { # ------------------------------------------------------------------- Backwards if ($hash{'type_'.$rid} eq 'start') { - $rid=$hash{'ids_/res/'.$mapurl}; + $rid=$hash{'ids_'.&Apache::lonnet::clutter($mapurl)}; } map { my $thiscond= @@ -126,14 +142,18 @@ sub move { } } split(/\,/,$posnext); if ($hash{'is_map_'.$next}) { +# This jumps to the end of a new map (going down one level) if ( $hash{'map_type_'.$hash{'map_pc_'.$hash{'src_'.$next}}} eq 'sequence') { $mapurl=$hash{'src_'.$next}; $next=$hash{'map_finish_'.$hash{'src_'.$next}}; } + } elsif + ((split(/\./,$startoutrid))[0]!=(split(/\./,$next))[0]) { +# This comes back up from a map (going up one level); + $mapurl=$hash{'map_id_'.(split(/\./,$next))[0]}; } } - return ($next,$mapurl); } @@ -164,13 +184,13 @@ sub handler { # -------------------------------------------------------- Return to last known my $last; if (tie(%hash,'GDBM_File',$ENV{'request.course.fn'}.'_symb.db', - &GDBM_READER,0640)) { + &GDBM_READER(),0640)) { $last=$hash{'last_known'}; untie(%hash); } my $newloc; if ($last) { - $newloc='/res/'.(split(/\_\_\_/,$last))[1]; + $newloc=&Apache::lonnet::clutter((split(/\_\_\_/,$last))[1]); } else { $newloc='/adm/noidea.html'; } @@ -182,16 +202,15 @@ sub handler { } $currenturl=~s/^http\:\/\///; $currenturl=~s/^[^\/]+//; - unless (($currenturl=~/^\/res\//) || - ($currenturl=~/^\/adm\/wrapper\//)) { + unless ($currenturl=~/^\/(res|adm\/wrapper|public|adm\/coursedocs)\//) { my $last; if (tie(%hash,'GDBM_File',$ENV{'request.course.fn'}.'_symb.db', - &GDBM_READER,0640)) { + &GDBM_READER(),0640)) { $last=$hash{'last_known'}; untie(%hash); } if ($last) { - $currenturl='/res/'.(split(/\_\_\_/,$last))[1]; + $currenturl=&Apache::lonnet::clutter((split(/\_\_\_/,$last))[1]); } else { $r->content_type('text/html'); $r->header_out(Location => @@ -205,20 +224,23 @@ sub handler { # ------------------------------------------------------------------------- Yes my ($startoutmap,$mapnum,$thisurl)=split(/\_\_\_/,$position); $cachehash{$startoutmap}{$thisurl}=$mapnum; - $cachehash{$startoutmap}{'last_known'}=&Apache::lonnet::declutter($currenturl); + $cachehash{$startoutmap}{'last_known'}= + &Apache::lonnet::declutter($currenturl); # ============================================================ Tie the big hash if (tie(%hash,'GDBM_File',$ENV{'request.course.fn'}.'.db', - &GDBM_READER,0640)) { - my $rid=$hash{'map_pc_/res/'.$startoutmap}.'.'.$mapnum; + &GDBM_READER(),0640)) { + my $rid=$hash{'map_pc_'.&Apache::lonnet::clutter($startoutmap)}. + '.'.$mapnum; # ------------------------------------------------- Move forward, backward, etc my $endupmap; ($next,$endupmap)=&move($rid,$startoutmap,$direction); # -------------------------------------- Do we have one and only one empty URL? my $safecount=0; - while (($next) && ($next!~/\,/) && (!$hash{'src_'.$next}) - && ($safecount<25)) { + while (($next) && ($next!~/\,/) && + ((!$hash{'src_'.$next}) || ($hash{'randomout_'.$next})) + && ($safecount<10000)) { ($next,$endupmap)=&move($next,$endupmap,$direction); $safecount++; } @@ -239,6 +261,12 @@ sub handler { $multichoicehash{'src_'.$_}=$hash{'src_'.$_}; $multichoicehash{'title_'.$_}=$hash{'title_'.$_}; $multichoicehash{'type_'.$_}=$hash{'type_'.$_}; + (my $first, my $second) = $_ =~ /(\d+).(\d+)/; + my $symbSrc = Apache::lonnet::declutter($hash{'src_'.$_}); + $multichoicehash{'symb_'.$_} = + Apache::lonnet::declutter($hash{'map_id_'.$first}.'___'. + $second.'___'.$symbSrc); + my ($choicemap,$choiceres)=split(/\./,$_); $cachehash {&Apache::lonnet::declutter($hash{'src_'.$choicemap})} @@ -263,6 +291,20 @@ sub handler { # ============================================== Do not return before this line if ($redirecturl) { # ----------------------------------------------------- There is a URL to go to +# ------------------------------------------------- Check for critical messages + if ((time-$ENV{'user.criticalcheck.time'})>300) { + my @what=&Apache::lonnet::dump + ('critical',$ENV{'user.domain'}, + $ENV{'user.name'}); + if ($what[0]) { + if (($what[0] ne 'con_lost') && + ($what[0]!~/^error\:/)) { + $redirecturl='/adm/email?critical=display'; + } + } + &Apache::lonnet::appenv('user.criticalcheck.time'=>time); + } + $r->content_type('text/html'); $r->header_out(Location => 'http://'.$ENV{'HTTP_HOST'}.$redirecturl); @@ -283,14 +325,15 @@ Please click on the the resource you int ENDSTART - map { + foreach (@possibilities) { $r->print( ''); - } @possibilities; + } $r->print('
TitleType
'. + $multichoicehash{'src_'.$_}.'?symb=' . + Apache::lonnet::escape($multichoicehash{'symb_'.$_}).'">'. $multichoicehash{'title_'.$_}. ''.$multichoicehash{'type_'.$_}. '
'); return OK; } else {