--- loncom/interface/lonnavmaps.pm 2005/04/07 06:56:23 1.320 +++ loncom/interface/lonnavmaps.pm 2005/04/15 21:28:54 1.325 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Navigate Maps Handler # -# $Id: lonnavmaps.pm,v 1.320 2005/04/07 06:56:23 albertel Exp $ +# $Id: lonnavmaps.pm,v 1.325 2005/04/15 21:28:54 albertel Exp $ # # Copyright Michigan State University Board of Trustees # @@ -1588,13 +1588,7 @@ END my @allres=$navmap->retrieveResources(); foreach my $resource (@allres) { if ($resource->hasDiscussion()) { - my $ressymb; - if ($resource->symb() =~ m-(___adm/\w+/\w+)/(\d+)/bulletinboard$-) { - $ressymb = 'bulletin___'.$2.$1.'/'.$2.'/bulletinboard'; - } else { - $ressymb = $resource->symb(); - } - $haveDisc .= $ressymb.':'; + $haveDisc .= $resource->wrap_symb().':'; $totdisc ++; } } @@ -2120,47 +2114,32 @@ sub generate_course_user_opt { my $udom=$env{'user.domain'}; my $uhome=$env{'user.home'}; my $cid=$env{'request.course.id'}; - my $chome=$env{'course.'.$cid.'.home'}; my ($cdom,$cnum)=split(/\_/,$cid); - my $userprefix=$uname.'_'.$udom.'_'; - - my %courserdatas; my %useropt; my %courseopt; my %userrdatas; + my %useropt; my %courseopt; unless ($uhome eq 'no_host') { # ------------------------------------------------- Get coursedata (if present) - unless ((time-$courserdatas{$cid.'.last_cache'})<240) { - my $reply=&Apache::lonnet::reply('dump:'.$cdom.':'.$cnum. - ':resourcedata',$chome); - # Check for network failure - if ( $reply =~ /no.such.host/i || $reply =~ /con_lost/i) { - $self->{NETWORK_FAILURE} = 1; - } elsif ($reply!~/^error\:/) { - $courserdatas{$cid}=$reply; - $courserdatas{$cid.'.last_cache'}=time; - } - } - foreach (split(/\&/,$courserdatas{$cid})) { - my ($name,$value)=split(/\=/,$_); - $courseopt{$userprefix.&Apache::lonnet::unescape($name)}= - &Apache::lonnet::unescape($value); + %courseopt=&Apache::lonnet::dump('resourcedata',$cdom,$cnum); + # Check for network failure + my ($tmp)=keys(%courseopt); + + if ( $tmp =~ /no.such.host/i || $tmp =~ /con_lost/i) { + $self->{NETWORK_FAILURE} = 1; + undef(%courseopt); + } elsif ($tmp=~/^error\:/) { + undef(%courseopt); } + # --------------------------------------------------- Get userdata (if present) - unless ((time-$userrdatas{$uname.'___'.$udom.'.last_cache'})<240) { - my $reply=&Apache::lonnet::reply('dump:'.$udom.':'.$uname.':resourcedata',$uhome); - if ($reply!~/^error\:/) { - $userrdatas{$uname.'___'.$udom}=$reply; - $userrdatas{$uname.'___'.$udom.'.last_cache'}=time; - } + + %useropt=&Apache::lonnet::dump('resourcedata',$udom,$uname); + ($tmp)=keys(%courseopt); + if ($tmp=~/^error\:/) { + undef(%useropt); + } elsif ( $tmp=~/no.such.host/i || $tmp=~/con.lost/i ) { # check to see if network failed - elsif ( $reply=~/no.such.host/i || $reply=~/con.*lost/i ) - { - $self->{NETWORK_FAILURE} = 1; - } - } - foreach (split(/\&/,$userrdatas{$uname.'___'.$udom})) { - my ($name,$value)=split(/\=/,$_); - $useropt{$userprefix.&Apache::lonnet::unescape($name)}= - &Apache::lonnet::unescape($value); + $self->{NETWORK_FAILURE} = 1; + undef(%useropt); } $self->{COURSE_OPT} = \%courseopt; $self->{USER_OPT} = \%useropt; @@ -2197,13 +2176,10 @@ sub generate_email_discuss_status { my %feedback=(); my %error=(); - my $keys = &Apache::lonnet::reply('keys:'. - $env{'user.domain'}.':'. - $env{'user.name'}.':nohist_email', - $env{'user.home'}); + my @keys = &Apache::lonnet::getkeys('nohist_email',$env{'user.domain'}, + $env{'user.name'}); - foreach my $msgid (split(/\&/, $keys)) { - $msgid=&Apache::lonnet::unescape($msgid); + foreach my $msgid (@keys) { if ((!$emailstatus{$msgid}) || ($emailstatus{$msgid} eq 'new')) { my $plain= &Apache::lonnet::unescape(&Apache::lonnet::unescape($msgid)); @@ -2281,21 +2257,14 @@ sub getIterator { sub hasDiscussion { my $self = shift; my $symb = shift; - $self->generate_email_discuss_status(); if (!defined($self->{DISCUSSION_TIME})) { return 0; } #return defined($self->{DISCUSSION_TIME}->{$symb}); -# backward compatibility (bulletin boards used to be 'wrapped') - my $ressymb = $symb; - if ($ressymb =~ m|adm/(\w+)/(\w+)/(\d+)/bulletinboard$|) { - unless ($ressymb =~ m|adm/wrapper/adm|) { - $ressymb = 'bulletin___'.$3.'___adm/wrapper/adm/'.$1.'/'.$2.'/'.$3.'/bulletinboard'; - } - } - + # backward compatibility (bulletin boards used to be 'wrapped') + my $ressymb = $self->wrap_symb($symb); if ( defined ( $self->{LAST_READ}->{$ressymb} ) ) { return $self->{DISCUSSION_TIME}->{$ressymb} > $self->{LAST_READ}->{$ressymb}; } else { @@ -2304,9 +2273,21 @@ sub hasDiscussion { } } +sub wrap_symb { + my $self = shift; + my $symb = shift; + if ($symb =~ m-___(adm/\w+/\w+/)(\d+)(/bulletinboard)$-) { + unless ($symb =~ m|adm/wrapper/adm|) { + $symb = 'bulletin___'.$2.'___adm/wrapper/'.$1.$2.$3; + } + } + return $symb; +} + # Private method: Does the given resource (as a symb string) have # current feedback? Returns the string in the feedback hash, which # will be false if it does not exist. + sub getFeedback { my $self = shift; my $symb = shift; @@ -2462,7 +2443,7 @@ sub parmval_real { my $symbparm=$symb.'.'.$what; my $mapparm=$mapname.'___(all).'.$what; - my $usercourseprefix=$uname.'_'.$udom.'_'.$cid; + my $usercourseprefix=$cid; my $seclevel= $usercourseprefix.'.['.$csec.'].'.$what; my $seclevelr=$usercourseprefix.'.['.$csec.'].'.$symbparm; @@ -3531,6 +3512,10 @@ sub symb { . '___' . $second . '___' . $symbSrc; return &Apache::lonnet::symbclean($symb); } +sub wrap_symb { + my $self = shift; + return $self->{NAV_MAP}->wrap_symb($self->symb()); +} sub title { my $self=shift; if ($self->{ID} eq '0.0') {