--- loncom/interface/lonannounce.pm 2006/07/03 15:30:52 1.59 +++ loncom/interface/lonannounce.pm 2006/12/05 02:55:51 1.63 @@ -1,7 +1,7 @@ # The LearningOnline Network # Announce # -# $Id: lonannounce.pm,v 1.59 2006/07/03 15:30:52 www Exp $ +# $Id: lonannounce.pm,v 1.63 2006/12/05 02:55:51 albertel Exp $ # # Copyright Michigan State University Board of Trustees # @@ -37,6 +37,7 @@ use Apache::lonnavmaps(); use Apache::lonrss(); use Apache::lonnet; use HTML::Entities(); +use LONCAPA qw(:match); my %todayhash; my %showedcheck; @@ -80,14 +81,19 @@ sub readcalendar { $returnhash{$courseid.'@'.$item}=$thiscal{$item}; } } - my $can_see_hidden = $env{'request.role.adv'}; - my $navmap;# = Apache::lonnavmaps::navmap->new(); + my $can_see_hidden = ($env{'request.role.adv'} && + ($courseid eq $env{'request.course.id'})); + + my $navmap; + if ($courseid eq $env{'request.course.id'}) { + $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+)$/); + ($thiskey=~/^($match_courseid)\.(?:(.+)\.)*([\w\s]+)\.(\w+)$/); my %data = ( 'section' => &mt('All Students')); if ($middle=~/^\[(.*)\]\./) { my $sec=$1; @@ -304,7 +310,7 @@ sub showday { $nextday+=$oneday; } foreach my $item (keys(%allcal)) { - my ($course,$startdate,$enddate)=($item=~/^(\w+)\@(\d+)\_(\d+)$/); + my ($course,$startdate,$enddate)=($item=~/^($match_courseid)\@(\d+)\_(\d+)$/); if (($startdate<$nextday) && ($enddate>=$tk)) { push(@outp,[$course,$startdate,$enddate,$allcal{$item}]); } @@ -353,7 +359,8 @@ ENDDIA # ----------------------------------------------------- Summarize all calendars sub get_all_calendars { my %allcal=(); - foreach my $course (sort(&Apache::loncommon::findallcourses())) { + my %courses = &Apache::loncommon::findallcourses(); + foreach my $course (sort(keys(%courses))) { %allcal=(%allcal,&readcalendar($course)); } return %allcal; @@ -369,7 +376,7 @@ sub output_ics_file { $r->print("PRODID:-//LONCAPA//LONCAPA Calendar Output//EN$crlf"); my %allcal=&get_all_calendars(); foreach my $event (keys(%allcal)) { - my ($courseid,$startdate,$enddate)=($event=~/^(\w+)\@(\d+)\_(\d+)$/); + my ($courseid,$startdate,$enddate)=($event=~/^($match_courseid)\@(\d+)\_(\d+)$/); my $uid=$event; $uid=~s/[\W\_]/-/gs; $uid.='@loncapa'; @@ -490,9 +497,9 @@ SERVERANNOUNCE # list servers foreach my $host (sort(keys(%Apache::lonnet::hostname))) { if (&Apache::lonnet::allowed('psa',$Apache::lonnet::hostdom{$host})) { - $r->print ('
'. + $r->print ('