--- loncom/interface/lonannounce.pm 2006/06/26 22:31:56 1.55
+++ loncom/interface/lonannounce.pm 2006/11/29 07:46:39 1.62
@@ -1,7 +1,7 @@
# The LearningOnline Network
# Announce
#
-# $Id: lonannounce.pm,v 1.55 2006/06/26 22:31:56 albertel Exp $
+# $Id: lonannounce.pm,v 1.62 2006/11/29 07:46:39 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -80,16 +80,20 @@ 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+)$/);
- my $section=&mt('All Students');
+ my %data = ( 'section' => &mt('All Students'));
if ($middle=~/^\[(.*)\]\./) {
my $sec=$1;
# if we have a section don't show ones that aren't ours
@@ -98,11 +102,11 @@ sub readcalendar {
# 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;
+ $data{'section'}=&mt('Group/Section').': '.$1;
$middle=~s/^\[(.*)\]\.//;
}
$middle=~s/\.$//;
- my $realm=&mt('All Resources');
+ $data{'realm'}=&mt('All Resources');
if ($middle eq '___(all)') {
if (!$can_see_hidden && !$navmap) {
next;
@@ -116,9 +120,8 @@ sub readcalendar {
my $res = $navmap->getResourceByUrl($map_url);
if ($res && $res->randomout()) { next; }
}
- # 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;
+ $data{'realm'}=&mt('Folder/Map');
+ $data{'url'} = $map_url;
} elsif ($middle) {
if (!$can_see_hidden && !$navmap) {
next;
@@ -127,20 +130,26 @@ sub readcalendar {
my $res = $navmap->getBySymb($middle);
if ($res && $res->randomout()) { next; }
}
- #$realm=&mt('Resource').': '.&Apache::lonnet::gettitle($middle);
- $realm=&mt('Resource').': '.$middle;
+ $data{'realm'} = &mt('Resource');
+ $data{'symb'} = $middle;
}
- my $datetype='';
+ $data{'datetype'} = $name;
if ($name eq 'duedate') {
- $datetype=&mt('Due');
+ $data{'datetype'} = &mt('Due');
# see if accidentally answerdate is before duedate
my $answerkey=$thiskey;
$answerkey=~s/duedate$/answerdate/;
if ($resourcedata{$thiskey}>$resourcedata{$answerkey}) {
- $datetype=&mt('Due and Answer Available');
+ $data{'datetype'} = &mt('Due and Answer Available');
}
}
- if ($name eq 'opendate') { $datetype=&mt('Opening'); }
+ if ($name eq 'opendate'
+ || $name eq 'contentopen' ) {
+ $data{'datetype'}=&mt('Opening');
+ }
+ if ($name eq 'contentclose') {
+ $data{'datetype'}=&mt('Closing');
+ }
if ($name eq 'answerdate') {
# see if accidentally answerdate is before duedate
my $duekey=$thiskey;
@@ -149,11 +158,10 @@ sub readcalendar {
# forget it
next;
}
- $datetype=&mt('Answer Available');
+ $data{'datetype'}=&mt('Answer Available');
}
$returnhash{$courseid.'@'.$resourcedata{$thiskey}.'_'.
- $resourcedata{$thiskey}}=
- 'INTERNAL:'.$datetype.': '.$realm.' ('.$section.')';
+ $resourcedata{$thiskey}}=\%data;
}
}
return %returnhash;
@@ -164,23 +172,25 @@ sub emptycell {
}
sub normalcell {
- my ($day,$month,$year,$text)=@_;
+ my ($day,$month,$year,$items_ref)=@_;
my $output;
- my @items=&order($text);
+ my @items=&order($items_ref);
foreach my $item (@items) {
if ($item) {
- my $internalflag=0;
- my ($courseid,$start,$end,$msg)=split(/\@/,$item,4);
- if ($msg=~/INTERNAL\:/) {
- $msg=~s/INTERNAL\://gs;
- $internalflag=1;
- }
+ my ($courseid,$start,$end,$msg)=@$item;
+ my $internalflag= (ref($msg)) ? 1 : 0;
+ $msg = &display_msg($msg);
my $fullmsg=&mt('Calendar Announcement for ').$env{'course.'.$courseid.'.description'}.
'\n'.&Apache::lonlocal::locallocaltime($start);
if ($start!=$end) {
$fullmsg.=' - '.&Apache::lonlocal::locallocaltime($end);
}
$fullmsg.=':\n'.$msg;
+ $fullmsg=~s/[\n\r]/\\n/gs;
+ $fullmsg=&HTML::Entities::encode($fullmsg,'<>&"\'');
+ $fullmsg=~s/&/\\&/g;
+ my $short_msg = substr($msg,0,20).((length($msg) > 20)?'...':'');
+ if (defined($output)) { $output.='
'; }
if ($courseid eq $env{'request.course.id'}) {
if ((&Apache::lonnet::allowed('srm',$env{'request.course.id'}))
&& (!$showedcheck{$start.'_'.$end})
@@ -191,11 +201,6 @@ sub normalcell {
$showedcheck{$start.'_'.$end}=1;
}
}
- $fullmsg=~s/[\n\r]/\\n/gs;
- $fullmsg=&HTML::Entities::encode($fullmsg,'<>&"\'');
- $fullmsg=~s/&/\\&/g;
- my $short_msg = substr($msg,0,20).((length($msg) > 20)?'...':'');
- if (defined($output)) { $output.='
'; }
$output.=''.
$short_msg.'';
}
@@ -208,18 +213,18 @@ sub normalcell {
}
sub plaincell {
- my ($text)=@_;
+ my ($items_ref)=@_;
my $output;
- my @items=&order($text);
+ my @items=&order($items_ref);
foreach my $item (@items) {
- if ($item) {
- my ($courseid,$start,$end,$msg)=split(/\@/,$item,4);
+ if (ref($item)) {
+ my ($courseid,$start,$end,$msg)=@$item;
my $fullmsg=&mt('Calendar Announcement for ').$env{'course.'.$courseid.'.description'}.
'\n'.&Apache::lonlocal::locallocaltime($start);
if ($start!=$end) {
$fullmsg.=' - '.&Apache::lonlocal::locallocaltime($end);
}
- $msg=~s/INTERNAL\://gs;
+ $msg = &display_msg($msg);
$fullmsg.=':\n'.$msg;
$fullmsg=~s/[\n\r]/\\n/gs;
$fullmsg=&HTML::Entities::encode($fullmsg,'<>&"\'');
@@ -234,20 +239,18 @@ sub plaincell {
}
sub listcell {
- my ($text)=@_;
+ my ($items_ref)=@_;
my $output='';
- my @items=&order($text);
+ my @items=&order($items_ref);
foreach my $item (@items) {
- if ($item) {
- my ($courseid,$start,$end,$msg)=split(/\@/,$item,4);
- $msg=~s/INTERNAL\://gs;
- my $fullmsg=&Apache::lonlocal::locallocaltime($start);
+ if (ref($item)) {
+ my ($courseid,$start,$end,$msg)=@$item;
+ my $fullmsg=&Apache::lonlocal::locallocaltime($start);
if ($start!=$end) {
$fullmsg.=&mt(' to ').
&Apache::lonlocal::locallocaltime($end);
}
- $fullmsg.=':
'.
- $msg.'';
+ $fullmsg.=':
'.&display_msg($msg).'';
$output.='