--- loncom/interface/lonannounce.pm 2006/06/29 16:44:49 1.57 +++ loncom/interface/lonannounce.pm 2007/03/02 23:17:58 1.66 @@ -1,7 +1,7 @@ # The LearningOnline Network # Announce # -# $Id: lonannounce.pm,v 1.57 2006/06/29 16:44:49 albertel Exp $ +# $Id: lonannounce.pm,v 1.66 2007/03/02 23:17:58 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; @@ -77,18 +78,23 @@ sub readcalendar { my %returnhash=(); foreach my $item (keys(%thiscal)) { unless (($item=~/^error\:/) || ($thiscal{$item}=~/^error\:/)) { - $returnhash{$courseid.'@'.$item}=$thiscal{$item}; + my ($start,$end)=split('_',$item); + $returnhash{join("\0",$courseid,$start,$end)}=$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); + &Apache::lonnet::get_courseresdata($coursenum,$coursedom); 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; @@ -156,8 +162,9 @@ sub readcalendar { } $data{'datetype'}=&mt('Answer Available'); } - $returnhash{$courseid.'@'.$resourcedata{$thiskey}.'_'. - $resourcedata{$thiskey}}=\%data; + $returnhash{join("\0",$courseid, + $resourcedata{$thiskey}, + $resourcedata{$thiskey})}=\%data; } } return %returnhash; @@ -279,10 +286,16 @@ sub display_msg { my $output = $msg->{'datetype'}. ': '.$msg->{'realm'}; if (exists($msg->{'url'})) { - $output .= ': '.&Apache::lonnet::gettitle($msg->{'url'}); + my $displayurl=&Apache::lonnet::gettitle($msg->{'url'}); + if ($msg->{'url'}!~/\Q$displayurl\E$/) { + $output .= ' - '.$displayurl; + } } if (exists($msg->{'symb'})) { - $output .= ': '.&Apache::lonnet::gettitle($msg->{'symb'}); + my $displaysymb=&Apache::lonnet::gettitle($msg->{'symb'}); + if ($msg->{'symb'}!~/\Q$displaysymb\E$/) { + $output .= ' - '.$displaysymb; + } } $output .= ' ('.$msg->{'section'}.') '; return $output; @@ -299,9 +312,9 @@ sub showday { $nextday+=$oneday; } foreach my $item (keys(%allcal)) { - my ($course,$startdate,$enddate)=($item=~/^(\w+)\@(\d+)\_(\d+)$/); - if (($startdate<$nextday) && ($enddate>=$tk)) { - push(@outp,[$course,$startdate,$enddate,$allcal{$item}]); + my ($courseid,$startdate,$enddate)= split("\0",$item); + if (($startdate<$nextday) && ($enddate>=$tk)) { + push(@outp,[$courseid,$startdate,$enddate,$allcal{$item}]); } } unless ($mode) { @@ -348,7 +361,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; @@ -364,7 +378,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)= split('\0',$event); my $uid=$event; $uid=~s/[\W\_]/-/gs; $uid.='@loncapa'; @@ -483,11 +497,12 @@ Post announcements to the system login a Check machines:
SERVERANNOUNCE # list servers - foreach my $host (sort(keys(%Apache::lonnet::hostname))) { + my %hostname = &Apache::lonnet::all_hostnames(); + foreach my $host (sort(keys(%hostname))) { if (&Apache::lonnet::allowed('psa',$Apache::lonnet::hostdom{$host})) { - $r->print ('
'. - $host.' '.$Apache::lonnet::hostname{$host}.' '. - ' '. + $host.' '.$hostname{$host}.' '. + 'current'); } }