--- loncom/interface/lonannounce.pm 2002/08/08 13:44:17 1.3
+++ loncom/interface/lonannounce.pm 2003/05/21 16:26:46 1.9
@@ -1,7 +1,7 @@
# The LearningOnline Network
# Announce
#
-# $Id: lonannounce.pm,v 1.3 2002/08/08 13:44:17 www Exp $
+# $Id: lonannounce.pm,v 1.9 2003/05/21 16:26:46 www Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -31,6 +31,7 @@ package Apache::lonannounce;
use strict;
use Apache::Constants qw(:common);
use Apache::loncommon;
+use Apache::lonhtmlcommon();
sub readcalendar {
my $courseid=shift;
@@ -52,7 +53,23 @@ sub emptycell {
sub normalcell {
my ($day,$text)=@_;
- return '
'.$day.' '.$text.' | ';
+ my $output='';
+ foreach (split(/\_\_\_\&\&\&\_\_\_/,$text)) {
+ if ($_) {
+ my ($courseid,$start,$end,@msg)=split(/\@/,$_);
+ my $msg=join('@',@msg);
+ my $fullmsg=$ENV{'course.'.$courseid.'.description'}.': '.$msg;
+ if ($courseid eq $ENV{'request.course.id'}) {
+ if (&Apache::lonnet::allowed('srm',$ENV{'request.course.id'})) {
+ $output.='';
+ }
+ }
+ $output.=''.
+ substr($msg,0,20).'...
';
+ }
+ }
+ return ''.$day.' '.$output.' | ';
}
sub nextday {
@@ -66,12 +83,12 @@ sub showday {
my %th=&Apache::loncommon::timehash($tk);
my ($nextday,$nextmonth)=&nextday(%th);
my $outp='';
+ my $oneday=24*3600;
foreach (keys %allcal) {
my ($course,$startdate,$enddate)=($_=~/^(\w+)\@(\d+)\_(\d+)$/);
- print $course.' '.localtime($startdate).' '.localtime($enddate).
- localtime($tk).' '.localtime($nextday).'
';
- if (($startdate>$tk) && ($enddate<$nextday)) {
- $outp.='___&&&___'.$course.'@'.$allcal{$_};
+ if (($startdate<$nextday) && ($enddate>$tk)) {
+ $outp.='___&&&___'.$course.'@'.$startdate.'@'.$enddate.'@'.
+ $allcal{$_};
}
}
return ($nextday,$nextmonth,&normalcell($th{'day'},$outp));
@@ -90,11 +107,6 @@ sub handler {
# ---------------------------------------------------------- Get month and year
&Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},
['month','year']);
-# ----------------------------------------------------- Summarize all calendars
- my %allcal=();
- foreach (&Apache::loncommon::findallcourses()) {
- %allcal=(%allcal,&readcalendar($_));
- }
# --------------------------------------------------- Decide what month to show
my $year=$todayhash{'year'};
if ($ENV{'form.year'}) { $year=$ENV{'form.year'}; }
@@ -109,51 +121,14 @@ sub handler {
'dlsav' => $todayhash{'dlsav'} ));
my $weekday=$firstday{'weekday'};
# ------------------------------------------------------------ Print the screen
+
$r->print(<
The LearningOnline Network with CAPA
-
-Announcements
ENDDOCUMENT
-
+ $r->print(&Apache::loncommon::bodytag("Announcements and Calendar"));
# does this user have privileges to post, etc?
my $allowed=0;
if ($ENV{'request.course.id'}) {
@@ -179,8 +152,19 @@ ENDDOCUMENT
my $coursedom=$ENV{'course.'.$ENV{'request.course.id'}.'.domain'};
# ----------------------------------------------------- Store new submitted one
if ($ENV{'form.action'} eq 'new') {
+ my $startdate =
+ &Apache::lonhtmlcommon::get_date_from_form('startdate');
+ my $enddate =
+ &Apache::lonhtmlcommon::get_date_from_form('enddate');
+ unless ($startdate=~/^\d+$/) { $startdate=time; }
+ unless ($enddate=~/^\d+$/) { $enddate=$startdate+1; }
+ if ($startdate>$enddate) {
+ my $buffer=$startdate;
+ $startdate=$enddate;
+ $enddate=$buffer;
+ }
&Apache::lonnet::put('calendar',{
- $ENV{'form.startdate'}.'_'.$ENV{'form.enddate'} =>
+ $startdate.'_'.$enddate =>
$ENV{'form.msg'} },$coursedom,$coursenum);
}
# ---------------------------------------------------------------- Remove items
@@ -198,26 +182,32 @@ ENDDOCUMENT
$tomorrowhash{'day'}++;
my $tomorrow=&Apache::loncommon::maketime(%tomorrowhash);
+ # Deal with date forms
+ my $startdateform = &Apache::lonhtmlcommon::date_setter('anno',
+ 'startdate',
+ $today);
+ my $enddateform = &Apache::lonhtmlcommon::date_setter('anno',
+ 'enddate',
+ $tomorrow);
+ #
+
$r->print(<
-
-
-
-
-
-Set Starting Date
-Set Ending Date
+
Starting date: | $startdateform |
+Ending date: | $enddateform |
-
ENDFORM
}
+# ----------------------------------------------------- Summarize all calendars
+ my %allcal=();
+ foreach (&Apache::loncommon::findallcourses()) {
+ %allcal=(%allcal,&readcalendar($_));
+ }
+
+# ------------------------------- Initialize table and forward backward buttons
my ($pm,$py,$fm,$fy)=($month-1,$year,$month+1,$year);
if ($pm<1) { ($pm,$py)=(12,$year-1); }
if ($fm>12){ ($fm,$fy)=(1,$year+1); }
@@ -227,7 +217,7 @@ ENDFORM
'Previous Month '.
'Next Month'.
'
Sun | Mon | '.
- 'Tue | Wed | Thu | Fri | Sat | ');
+ 'Tue | Wed | Thu | Fri | Sat |
');
my $tk=&Apache::loncommon::maketime(%firstday);
my $outp;
@@ -252,8 +242,9 @@ ENDFORM
$r->print('');
}
# ------------------------------------------------------------------- End table
- if ($allowed) { $r->print(''); }
- $r->print('
'.
+ $r->print('');
+ if ($allowed) { $r->print(''); }
+ $r->print('
'.
'Previous Month '.
'Next Month
'.
'