--- loncom/interface/lonannounce.pm 2006/04/22 16:32:55 1.49
+++ 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.49 2006/04/22 16:32:55 albertel 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;
@@ -50,7 +51,7 @@ sub editfield {
my $enddateform = &Apache::lonhtmlcommon::date_setter('anno',
'enddate',
$end);
- my $help=&Apache::loncommon::help_open_menu('','Calendar Add Announcement','Calendar_Add_Announcement','',274,'Communication Tools');
+ my $help=&Apache::loncommon::help_open_menu('Calendar Add Announcement','Calendar_Add_Announcement',274,'Communication Tools');
my %lt=&Apache::lonlocal::texthash('post' => 'Post Announcement',
'start' => 'Starting date',
'end' => 'Ending date',
@@ -80,75 +81,88 @@ sub readcalendar {
$returnhash{$courseid.'@'.$item}=$thiscal{$item};
}
}
-
+ my $can_see_hidden = ($env{'request.role.adv'} &&
+ ($courseid eq $env{'request.course.id'}));
+
+ my $navmap;
if ($courseid eq $env{'request.course.id'}) {
- my $can_see_hidden = $env{'request.role.adv'};
- my $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');
- 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/^\[(.*)\]\.//;
+ $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=~/^($match_courseid)\.(?:(.+)\.)*([\w\s]+)\.(\w+)$/);
+ my %data = ( '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; }
+ $data{'section'}=&mt('Group/Section').': '.$1;
+ $middle=~s/^\[(.*)\]\.//;
+ }
+ $middle=~s/\.$//;
+ $data{'realm'}=&mt('All Resources');
+ if ($middle eq '___(all)') {
+ if (!$can_see_hidden && !$navmap) {
+ next;
+ }
+ } elsif ($middle=~/^(.+)\_\_\_\(all\)$/) {
+ my $map_url=$1;
+ if (!$can_see_hidden && !$navmap) {
+ next;
+ }
+ if (!$can_see_hidden) {
+ my $res = $navmap->getResourceByUrl($map_url);
+ if ($res && $res->randomout()) { next; }
+ }
+ $data{'realm'}=&mt('Folder/Map');
+ $data{'url'} = $map_url;
+ } elsif ($middle) {
+ if (!$can_see_hidden && !$navmap) {
+ next;
}
- $middle=~s/\.$//;
- my $realm=&mt('All Resources');
- if ($middle=~/^(.+)\_\_\_\(all\)$/) {
- my $map_url=$1;
- if (!$can_see_hidden && !$navmap) {
- next;
- }
- if (!$can_see_hidden) {
- my $res = $navmap->getResourceByUrl($map_url);
- if ($res && $res->randomout()) { next; }
- }
- $realm=&mt('Folder/Map').': '.&Apache::lonnet::gettitle($map_url);
- } elsif ($middle) {
- if (!$can_see_hidden && !$navmap) {
- next;
- }
- if (!$can_see_hidden) {
- my $res = $navmap->getBySymb($middle);
- if ($res && $res->randomout()) { next; }
- }
- $realm=&mt('Resource').': '.&Apache::lonnet::gettitle($middle);
+ if (!$can_see_hidden) {
+ my $res = $navmap->getBySymb($middle);
+ if ($res && $res->randomout()) { next; }
}
- my $datetype='';
- if ($name eq 'duedate') {
- $datetype=&mt('Due');
+ $data{'realm'} = &mt('Resource');
+ $data{'symb'} = $middle;
+ }
+ $data{'datetype'} = $name;
+ if ($name eq 'duedate') {
+ $data{'datetype'} = &mt('Due');
# see if accidentally answerdate is before duedate
- my $answerkey=$thiskey;
- $answerkey=~s/duedate$/answerdate/;
- if ($resourcedata{$thiskey}>$resourcedata{$answerkey}) {
- $datetype='Due and Answer Available';
- }
+ my $answerkey=$thiskey;
+ $answerkey=~s/duedate$/answerdate/;
+ if ($resourcedata{$thiskey}>$resourcedata{$answerkey}) {
+ $data{'datetype'} = &mt('Due and Answer Available');
}
- if ($name eq 'opendate') { $datetype=&mt('Opening'); }
- if ($name eq 'answerdate') {
+ }
+ 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;
- $duekey=~s/answerdate$/duedate/;
- if ($resourcedata{$duekey}>$resourcedata{$thiskey}) {
+ my $duekey=$thiskey;
+ $duekey=~s/answerdate$/duedate/;
+ if ($resourcedata{$duekey}>$resourcedata{$thiskey}) {
# forget it
- next;
- }
- $datetype=&mt('Answer Available');
- }
- $returnhash{$courseid.'@'.$resourcedata{$thiskey}.'_'.
- $resourcedata{$thiskey}}=
- 'INTERNAL:'.$datetype.': '.$realm.' ('.$section.')';
+ next;
+ }
+ $data{'datetype'}=&mt('Answer Available');
}
+ $returnhash{$courseid.'@'.$resourcedata{$thiskey}.'_'.
+ $resourcedata{$thiskey}}=\%data;
}
}
return %returnhash;
@@ -159,23 +173,25 @@ sub emptycell {
}
sub normalcell {
- my ($day,$month,$year,$text)=@_;
- my $output='';
- my @items=&order($text);
+ my ($day,$month,$year,$items_ref)=@_;
+ my $output;
+ 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})
@@ -186,11 +202,8 @@ sub normalcell {
$showedcheck{$start.'_'.$end}=1;
}
}
- $fullmsg=~s/[\n\r]/\\n/gs;
- $fullmsg=&HTML::Entities::encode($fullmsg,'<>&"\'');
- $fullmsg=~s/&/\\&/g;
$output.=''.
- substr($msg,0,20).'...
';
+ $short_msg.'';
}
}
return '