--- loncom/interface/lonannounce.pm 2006/03/15 21:55:43 1.46 +++ loncom/interface/lonannounce.pm 2006/06/07 22:30:23 1.54 @@ -1,7 +1,7 @@ # The LearningOnline Network # Announce # -# $Id: lonannounce.pm,v 1.46 2006/03/15 21:55:43 albertel Exp $ +# $Id: lonannounce.pm,v 1.54 2006/06/07 22:30:23 albertel Exp $ # # Copyright Michigan State University Board of Trustees # @@ -81,86 +81,91 @@ sub readcalendar { } } - if ($courseid eq $env{'request.course.id'}) { - my $can_see_hidden = $env{'request.role.adv'}; - my $navmap = Apache::lonnavmaps::navmap->new(); - my %resourcedata= - &Apache::lonnet::dump('resourcedata',$coursedom,$coursenum); - foreach my $thiskey (sort keys %resourcedata) { - if ($resourcedata{$thiskey.'.type'}=~/^date/) { - my ($course,$middle,$part,$name)= - ($thiskey=~/^(\w+)\.(?:(.+)\.)*([\w\s]+)\.(\w+)$/); - my $section=&mt('All Students'); - if ($middle=~/^\[(.*)\]\./) { - my $sec=$1; - # if we have a section don't show ones that aren't ours - if ($env{'request.course.sec'} && - $env{'request.course.sec'} ne $sec) { next; } - # if a student without a section don't show any section ones - if (!$env{'request.role.adv'} && - !$env{'request.course.sec'}) { next; } - $section=&mt('Group/Section').': '.$1; - $middle=~s/^\[(.*)\]\.//; + my $can_see_hidden = $env{'request.role.adv'}; + my $navmap;# = Apache::lonnavmaps::navmap->new(); + my %resourcedata= + &Apache::lonnet::dump('resourcedata',$coursedom,$coursenum); + foreach my $thiskey (sort keys %resourcedata) { + if ($resourcedata{$thiskey.'.type'}=~/^date/) { + my ($course,$middle,$part,$name)= + ($thiskey=~/^(\w+)\.(?:(.+)\.)*([\w\s]+)\.(\w+)$/); + my $section=&mt('All Students'); + if ($middle=~/^\[(.*)\]\./) { + my $sec=$1; + # if we have a section don't show ones that aren't ours + if ($env{'request.course.sec'} && + $env{'request.course.sec'} ne $sec) { next; } + # if a student without a section don't show any section ones + if (!$env{'request.role.adv'} && + !$env{'request.course.sec'}) { next; } + $section=&mt('Group/Section').': '.$1; + $middle=~s/^\[(.*)\]\.//; + } + $middle=~s/\.$//; + my $realm=&mt('All Resources'); + if ($middle eq '___(all)') { + if (!$can_see_hidden && !$navmap) { + next; + } + } elsif ($middle=~/^(.+)\_\_\_\(all\)$/) { + my $map_url=$1; + if (!$can_see_hidden && !$navmap) { + next; + } + if (!$can_see_hidden) { + my $res = $navmap->getResourceByUrl($map_url); + if ($res && $res->randomout()) { next; } } - $middle=~s/\.$//; - my $realm=&mt('All Resources'); - if ($middle=~/^(.+)\_\_\_\(all\)$/) { - my $map_url=$1; - if (!$can_see_hidden && !$navmap) { - next; - } - if (!$can_see_hidden) { - my $res = $navmap->getResourceByUrl($map_url); - if ($res && $res->randomout()) { next; } - } - $realm=&mt('Folder/Map').': '.&Apache::lonnet::gettitle($map_url); - } elsif ($middle) { - if (!$can_see_hidden && !$navmap) { - next; - } - if (!$can_see_hidden) { - my $res = $navmap->getBySymb($middle); - if ($res && $res->randomout()) { next; } - } - $realm=&mt('Resource').': '.&Apache::lonnet::gettitle($middle); + # need to do this looks up in showday or /*cell for speed resaons + #$realm=&mt('Folder/Map').': '.&Apache::lonnet::gettitle($map_url); + $realm=&mt('Folder/Map').': '.$map_url; + } elsif ($middle) { + if (!$can_see_hidden && !$navmap) { + next; } - my $datetype=''; - if ($name eq 'duedate') { - $datetype=&mt('Due'); + if (!$can_see_hidden) { + my $res = $navmap->getBySymb($middle); + if ($res && $res->randomout()) { next; } + } + #$realm=&mt('Resource').': '.&Apache::lonnet::gettitle($middle); + $realm=&mt('Resource').': '.$middle; + } + my $datetype=''; + if ($name eq 'duedate') { + $datetype=&mt('Due'); # see if accidentally answerdate is before duedate - my $answerkey=$thiskey; - $answerkey=~s/duedate$/answerdate/; - if ($resourcedata{$thiskey}>$resourcedata{$answerkey}) { - $datetype='Due and Answer Available'; - } + my $answerkey=$thiskey; + $answerkey=~s/duedate$/answerdate/; + if ($resourcedata{$thiskey}>$resourcedata{$answerkey}) { + $datetype=&mt('Due and Answer Available'); } - if ($name eq 'opendate') { $datetype=&mt('Opening'); } - if ($name eq 'answerdate') { + } + if ($name eq 'opendate') { $datetype=&mt('Opening'); } + if ($name eq 'answerdate') { # see if accidentally answerdate is before duedate - my $duekey=$thiskey; - $duekey=~s/answerdate$/duedate/; - if ($resourcedata{$duekey}>$resourcedata{$thiskey}) { + my $duekey=$thiskey; + $duekey=~s/answerdate$/duedate/; + if ($resourcedata{$duekey}>$resourcedata{$thiskey}) { # forget it - next; - } - $datetype=&mt('Answer Available'); - } - $returnhash{$courseid.'@'.$resourcedata{$thiskey}.'_'. + next; + } + $datetype=&mt('Answer Available'); + } + $returnhash{$courseid.'@'.$resourcedata{$thiskey}.'_'. $resourcedata{$thiskey}}= 'INTERNAL:'.$datetype.': '.$realm.' ('.$section.')'; - } } } return %returnhash; } sub emptycell { - return '