--- loncom/interface/lonannounce.pm 2004/07/03 20:45:23 1.29
+++ loncom/interface/lonannounce.pm 2005/04/07 06:56:22 1.34
@@ -1,7 +1,7 @@
# The LearningOnline Network
# Announce
#
-# $Id: lonannounce.pm,v 1.29 2004/07/03 20:45:23 albertel Exp $
+# $Id: lonannounce.pm,v 1.34 2005/04/07 06:56:22 albertel Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -33,6 +33,7 @@ use Apache::Constants qw(:common);
use Apache::loncommon;
use Apache::lonhtmlcommon();
use Apache::lonlocal;
+use Apache::lonnet;
use HTML::Entities();
my %todayhash;
@@ -61,8 +62,8 @@ ENDFORM
sub readcalendar {
my $courseid=shift;
- my $coursenum=$ENV{'course.'.$courseid.'.num'};
- my $coursedom=$ENV{'course.'.$courseid.'.domain'};
+ my $coursenum=$env{'course.'.$courseid.'.num'};
+ my $coursedom=$env{'course.'.$courseid.'.domain'};
my %thiscal=&Apache::lonnet::dump('calendar',$coursedom,$coursenum);
my %returnhash=();
foreach (keys %thiscal) {
@@ -70,7 +71,7 @@ sub readcalendar {
$returnhash{$courseid.'@'.$_}=$thiscal{$_};
}
}
- if ($courseid eq $ENV{'request.course.id'}) {
+ if ($courseid eq $env{'request.course.id'}) {
my %resourcedata=
&Apache::lonnet::dump('resourcedata',$coursedom,$coursenum);
foreach my $thiskey (sort keys %resourcedata) {
@@ -79,6 +80,13 @@ sub readcalendar {
($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/^\[(.*)\]\.//;
}
@@ -135,33 +143,34 @@ sub normalcell {
$msg=~s/INTERNAL\://gs;
$internalflag=1;
}
- my $fullmsg=$ENV{'course.'.$courseid.'.description'}.
- ', '.&Apache::lonlocal::locallocaltime($start);
+ my $fullmsg=&mt('Calendar Announcement for ').$env{'course.'.$courseid.'.description'}.
+ '\n'.&Apache::lonlocal::locallocaltime($start);
if ($start!=$end) {
$fullmsg.=' - '.&Apache::lonlocal::locallocaltime($end);
}
- $fullmsg.=': '.$msg;
- if ($courseid eq $ENV{'request.course.id'}) {
- if ((&Apache::lonnet::allowed('srm',$ENV{'request.course.id'}))
+ $fullmsg.=':\n'.$msg;
+ if ($courseid eq $env{'request.course.id'}) {
+ if ((&Apache::lonnet::allowed('srm',$env{'request.course.id'}))
&& (!$showedcheck{$start.'_'.$end})
- && ($ENV{'form.pickdate'} ne 'yes')
+ && ($env{'form.pickdate'} ne 'yes')
&& (!$internalflag)) {
$output.='';
$showedcheck{$start.'_'.$end}=1;
}
}
+ $fullmsg=~s/[\n\r]/\\n/gs;
$fullmsg=&HTML::Entities::encode($fullmsg,'<>&"\'');
$fullmsg=~s/&/\\&/g;
$output.=''.
substr($msg,0,20).'...
';
}
}
- return '