--- loncom/interface/lonnavmaps.pm 2003/02/01 19:55:00 1.129.2.1 +++ loncom/interface/lonnavmaps.pm 2003/01/14 18:47:50 1.130 @@ -2,7 +2,7 @@ # The LearningOnline Network with CAPA # Navigate Maps Handler # -# $Id: lonnavmaps.pm,v 1.129.2.1 2003/02/01 19:55:00 albertel Exp $ +# $Id: lonnavmaps.pm,v 1.130 2003/01/14 18:47:50 www Exp $ # # Copyright Michigan State University Board of Trustees # @@ -46,6 +46,24 @@ use Apache::Constants qw(:common :http); use Apache::loncommon(); use POSIX qw (floor strftime); +my %navmaphash; +my %parmhash; + +sub cleanup { + if (tied(%navmaphash)){ + &Apache::lonnet::logthis('Cleanup navmaps: navmaphash'); + unless (untie(%navmaphash)) { + &Apache::lonnet::logthis('Failed cleanup navmaps: navmaphash'); + } + } + if (tied(%parmhash)){ + &Apache::lonnet::logthis('Cleanup navmaps: parmhash'); + unless (untie(%parmhash)) { + &Apache::lonnet::logthis('Failed cleanup navmaps: parmhash'); + } + } +} + sub handler { my $r = shift; real_handler($r); @@ -985,13 +1003,12 @@ sub new { $self->{NETWORK_FAILURE} = 0; # tie the nav hash - my %navmaphash; + if (!(tie(%navmaphash, 'GDBM_File', $self->{NAV_HASH_FILE}, &GDBM_READER(), 0640))) { return undef; } - my %parmhash; if (!(tie(%parmhash, 'GDBM_File', $self->{PARM_HASH_FILE}, &GDBM_READER(), 0640))) { @@ -1679,7 +1696,7 @@ sub next { # If this is a blank resource, don't actually return it. # Should you ever find you need it, make sure to add an option to the code # that you can use; other things depend on this behavior. - if (!$self->{HERE}->src() || !$self->{HERE}->browsePriv()) { + if (!$self->{HERE}->src()) { return $self->next(); } @@ -2618,7 +2635,16 @@ sub getNext { my $next = $choice->goesto(); $next = $self->{NAV_MAP}->getById($next); - push @branches, $next; + # Don't remember it if the student doesn't have browse priviledges + # future note: this may properly belong in the client of the resource + my $browsePriv = $self->{BROWSE_PRIV}; + if (!defined($browsePriv)) { + $browsePriv = &Apache::lonnet::allowed('bre', $self->src); + $self->{BROWSE_PRIV} = $browsePriv; + } + if (!($browsePriv ne '2' && $browsePriv ne 'F')) { + push @branches, $next; + } } return \@branches; } @@ -2632,20 +2658,20 @@ sub getPrevious { my $prev = $choice->comesfrom(); $prev = $self->{NAV_MAP}->getById($prev); - push @branches, $prev; + # Don't remember it if the student doesn't have browse priviledges + # future note: this may properly belong in the client of the resource + my $browsePriv = $self->{BROWSE_PRIV}; + if (!defined($browsePriv)) { + $browsePriv = &Apache::lonnet::allowed('bre', $self->src); + $self->{BROWSE_PRIV} = $browsePriv; + } + if (!($browsePriv ne '2' && $browsePriv ne 'F')) { + push @branches, $prev; + } } return \@branches; } -sub browsePriv { - my $self = shift; - if (defined($self->{BROWSE_PRIV})) { - return $self->{BROWSE_PRIV}; - } - - $self->{BROWSE_PRIV} = &Apache::lonnet::allowed('bre', $self->src()); -} - =pod =back