--- loncom/interface/lonannounce.pm 2007/03/02 23:17:58 1.66
+++ loncom/interface/lonannounce.pm 2008/05/18 19:45:46 1.70
@@ -1,7 +1,7 @@
# The LearningOnline Network
# Announce
#
-# $Id: lonannounce.pm,v 1.66 2007/03/02 23:17:58 albertel Exp $
+# $Id: lonannounce.pm,v 1.70 2008/05/18 19:45:46 www Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -74,6 +74,16 @@ sub readcalendar {
my $courseid=shift;
my $coursenum=$env{'course.'.$courseid.'.num'};
my $coursedom=$env{'course.'.$courseid.'.domain'};
+ if ($coursenum eq '' || $coursedom eq '') {
+ my %courseinfo=&Apache::lonnet::coursedescription($courseid);
+ if ($coursenum eq '' && exists($courseinfo{'num'})) {
+ $coursenum = $courseinfo{'num'};
+ }
+ if ($coursedom eq '' && exists($courseinfo{'domain'})) {
+ $coursedom = $courseinfo{'domain'};
+ }
+ }
+
my %thiscal=&Apache::lonnet::dump('calendar',$coursedom,$coursenum);
my %returnhash=();
foreach my $item (keys(%thiscal)) {
@@ -89,12 +99,17 @@ sub readcalendar {
if ($courseid eq $env{'request.course.id'}) {
$navmap = Apache::lonnavmaps::navmap->new();
}
- my %resourcedata=
+
+ my $resourcedata=
&Apache::lonnet::get_courseresdata($coursenum,$coursedom);
- foreach my $thiskey (sort keys %resourcedata) {
- if ($resourcedata{$thiskey.'.type'}=~/^date/) {
+ if (ref($resourcedata) ne 'HASH') {
+ return %returnhash;
+ }
+ foreach my $thiskey (keys(%$resourcedata)) {
+ if ($resourcedata->{$thiskey.'.type'}=~/^date/) {
my ($course,$middle,$part,$name)=
- ($thiskey=~/^($match_courseid)\.(?:(.+)\.)*([\w\s]+)\.(\w+)$/);
+ ($thiskey=~/^(\Q$courseid\E)\.(?:(.+)\.)*([\w\s]+)\.(\w+)$/);
+
my %data = ( 'section' => &mt('All Students'));
if ($middle=~/^\[(.*)\]\./) {
my $sec=$1;
@@ -120,7 +135,9 @@ sub readcalendar {
}
if (!$can_see_hidden) {
my $res = $navmap->getResourceByUrl($map_url);
- if ($res && $res->randomout()) { next; }
+ if ($res && $res->randomout()) {
+ next;
+ }
}
$data{'realm'}=&mt('Folder/Map');
$data{'url'} = $map_url;
@@ -130,7 +147,9 @@ sub readcalendar {
}
if (!$can_see_hidden) {
my $res = $navmap->getBySymb($middle);
- if ($res && $res->randomout()) { next; }
+ if ($res && $res->randomout()) {
+ next;
+ }
}
$data{'realm'} = &mt('Resource');
$data{'symb'} = $middle;
@@ -141,7 +160,7 @@ sub readcalendar {
# see if accidentally answerdate is before duedate
my $answerkey=$thiskey;
$answerkey=~s/duedate$/answerdate/;
- if ($resourcedata{$thiskey}>$resourcedata{$answerkey}) {
+ if ($resourcedata->{$thiskey}>$resourcedata->{$answerkey}) {
$data{'datetype'} = &mt('Due and Answer Available');
}
}
@@ -156,15 +175,15 @@ sub readcalendar {
# see if accidentally answerdate is before duedate
my $duekey=$thiskey;
$duekey=~s/answerdate$/duedate/;
- if ($resourcedata{$duekey}>$resourcedata{$thiskey}) {
+ if ($resourcedata->{$duekey}>$resourcedata->{$thiskey}) {
# forget it
next;
}
$data{'datetype'}=&mt('Answer Available');
}
$returnhash{join("\0",$courseid,
- $resourcedata{$thiskey},
- $resourcedata{$thiskey})}=\%data;
+ $resourcedata->{$thiskey},
+ $resourcedata->{$thiskey})}=\%data;
}
}
return %returnhash;
@@ -499,11 +518,12 @@ SERVERANNOUNCE
# list servers
my %hostname = &Apache::lonnet::all_hostnames();
foreach my $host (sort(keys(%hostname))) {
- if (&Apache::lonnet::allowed('psa',$Apache::lonnet::hostdom{$host})) {
+ if (&Apache::lonnet::allowed('psa',
+ &Apache::lonnet::host_domain($host))) {
$r->print ('
current');
+ '/announcement.txt?time='.time.'" target="annowin">current');
}
}
$r->print(