--- rat/lonpageflip.pm 2002/08/18 21:45:41 1.29 +++ rat/lonpageflip.pm 2003/01/14 18:47:50 1.34 @@ -2,7 +2,7 @@ # # Page flip handler # -# $Id: lonpageflip.pm,v 1.29 2002/08/18 21:45:41 www Exp $ +# $Id: lonpageflip.pm,v 1.34 2003/01/14 18:47:50 www Exp $ # # Copyright Michigan State University Board of Trustees # @@ -50,6 +50,15 @@ use GDBM_File; my %hash; +sub cleanup { + if (tied(%hash)){ + &Apache::lonnet::logthis('Cleanup pageflip: hash'); + unless (untie(%hash)) { + &Apache::lonnet::logthis('Failed cleanup pageflip: hash'); + } + } +} + sub addrid { my ($current,$new,$condid)=@_; unless ($condid) { $condid=0; } @@ -83,8 +92,8 @@ sub move { my $posnext=''; if ($direction eq 'forward') { # --------------------------------------------------------------------- Forward - if ($hash{'type_'.$rid} eq 'finish') { - $rid=$hash{'ids_'.&Apache::lonnet::clutter($mapurl)}; + while ($hash{'type_'.$rid} eq 'finish') { + $rid=$hash{'ids_'.$hash{'map_id_'.(split(/\./,$rid))[0]}}; } map { my $thiscond= @@ -119,9 +128,9 @@ sub move { } } elsif ($direction eq 'back') { # ------------------------------------------------------------------- Backwards - if ($hash{'type_'.$rid} eq 'start') { - $rid=$hash{'ids_'.&Apache::lonnet::clutter($mapurl)}; - } + while ($hash{'type_'.$rid} eq 'start') { + $rid=$hash{'ids_'.$hash{'map_id_'.(split(/\./,$rid))[0]}}; + } map { my $thiscond= &Apache::lonnet::directcondval($hash{'condid_'.$hash{'undercond_'.$_}}); @@ -202,8 +211,7 @@ 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)) { @@ -262,6 +270,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})} @@ -286,6 +300,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); @@ -309,7 +337,8 @@ ENDSTART foreach (@possibilities) { $r->print( ''. + $multichoicehash{'src_'.$_}.'?symb=' . + Apache::lonnet::escape($multichoicehash{'symb_'.$_}).'">'. $multichoicehash{'title_'.$_}. ''.$multichoicehash{'type_'.$_}. '');