Annotation of loncom/interface/lonannounce.pm, revision 1.32

1.1       www         1: # The LearningOnline Network
1.2       www         2: # Announce
1.1       www         3: #
1.32    ! www         4: # $Id: lonannounce.pm,v 1.31 2004/08/27 21:41:39 albertel Exp $
1.1       www         5: #
1.3       www         6: # Copyright Michigan State University Board of Trustees
1.1       www         7: #
1.3       www         8: # This file is part of the LearningOnline Network with CAPA (LON-CAPA).
1.1       www         9: #
1.3       www        10: # LON-CAPA is free software; you can redistribute it and/or modify
                     11: # it under the terms of the GNU General Public License as published by
                     12: # the Free Software Foundation; either version 2 of the License, or
                     13: # (at your option) any later version.
1.1       www        14: #
1.3       www        15: # LON-CAPA is distributed in the hope that it will be useful,
                     16: # but WITHOUT ANY WARRANTY; without even the implied warranty of
                     17: # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
                     18: # GNU General Public License for more details.
                     19: #
                     20: # You should have received a copy of the GNU General Public License
                     21: # along with LON-CAPA; if not, write to the Free Software
                     22: # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
                     23: #
                     24: # /home/httpd/html/adm/gpl.txt
                     25: #
                     26: # http://www.lon-capa.org/
                     27: #
                     28: 
1.2       www        29: package Apache::lonannounce;
1.1       www        30: 
                     31: use strict;
                     32: use Apache::Constants qw(:common);
1.3       www        33: use Apache::loncommon;
1.8       matthew    34: use Apache::lonhtmlcommon();
1.20      www        35: use Apache::lonlocal;
1.15      www        36: use HTML::Entities();
1.3       www        37: 
1.12      www        38: my %todayhash;
1.16      www        39: my %showedcheck;
1.12      www        40: 
1.10      www        41: sub editfield {
                     42:     my ($r,$start,$end,$text)=@_;
                     43:     # Deal with date forms
                     44:     my $startdateform = &Apache::lonhtmlcommon::date_setter('anno',
                     45:                                                             'startdate',
                     46:                                                             $start);
                     47:     my $enddateform = &Apache::lonhtmlcommon::date_setter('anno',
                     48:                                                           'enddate',
                     49:                                                           $end);
1.29      albertel   50:     my $help=&Apache::loncommon::help_open_menu('','Calendar Add Announcement','Calendar_Add_Announcement','',274,'Communication Tools');
1.10      www        51:     $r->print(<<ENDFORM);
1.25      www        52: $help
1.10      www        53: <form name="anno" method="post">
                     54: <input type="hidden" value=''          name="action"      >
                     55: <table><tr><td>Starting date:</td><td>$startdateform</td></tr>
                     56: <tr><td>Ending date:</td><td>$enddateform</td></tr></table>
                     57: <textarea name="msg" rows="4" cols="60">$text</textarea>
1.25      www        58: <input type="button" onClick="trysubmit()" value="Post Announcement"><hr />
1.10      www        59: ENDFORM
                     60: }
                     61: 
1.3       www        62: sub readcalendar {
                     63:     my $courseid=shift;
                     64:     my $coursenum=$ENV{'course.'.$courseid.'.num'};
                     65:     my $coursedom=$ENV{'course.'.$courseid.'.domain'};
                     66:     my %thiscal=&Apache::lonnet::dump('calendar',$coursedom,$coursenum);
                     67:     my %returnhash=();
                     68:     foreach (keys %thiscal) {
                     69:         unless (($_=~/^error\:/) || ($thiscal{$_}=~/^error\:/)) {
                     70: 	   $returnhash{$courseid.'@'.$_}=$thiscal{$_};
                     71:         }
                     72:     }
1.26      www        73:     if ($courseid eq $ENV{'request.course.id'}) {
                     74: 	my %resourcedata=
                     75: 	    &Apache::lonnet::dump('resourcedata',$coursedom,$coursenum);
                     76: 	foreach my $thiskey (sort keys %resourcedata) {
                     77: 	    if ($resourcedata{$thiskey.'.type'}=~/^date/) {
                     78: 		my ($course,$middle,$part,$name)=
                     79: 		    ($thiskey=~/^(\w+)\.(?:(.+)\.)*([\w\s]+)\.(\w+)$/);
                     80: 		my $section=&mt('All Students');
                     81: 		if ($middle=~/^\[(.*)\]\./) {
1.31      albertel   82: 		    my $sec=$1;
                     83: 		    # if we have a section don't show ones that aren't ours
                     84: 		    if ($ENV{'request.course.sec'} &&
                     85: 			$ENV{'request.course.sec'} ne $sec) { next; }
                     86: 		    # if a student without a section don't show any section ones
                     87: 		    if (!$ENV{'request.role.adv'} &&
                     88: 			!$ENV{'request.course.sec'}) { next; }
1.26      www        89: 		    $section=&mt('Group/Section').': '.$1;
                     90: 		    $middle=~s/^\[(.*)\]\.//;
                     91: 		}
                     92: 		$middle=~s/\.$//;
                     93: 		my $realm=&mt('All Resources');
                     94: 		if ($middle=~/^(.+)\_\_\_\(all\)$/) {
                     95: 		    $realm=&mt('Folder/Map').': '.&Apache::lonnet::gettitle($1);
                     96: 		} elsif ($middle) {
                     97: 		    $realm=&mt('Resource').': '.&Apache::lonnet::gettitle($middle);
                     98: 		}
                     99: 		my $datetype='';
1.28      www       100: 		if ($name eq 'duedate') { 
                    101: 		    $datetype=&mt('Due'); 
                    102: # see if accidentally answerdate is before duedate
                    103: 		    my $answerkey=$thiskey;
                    104: 		    $answerkey=~s/duedate$/answerdate/;
                    105: 		    if ($resourcedata{$thiskey}>$resourcedata{$answerkey}) {
                    106: 			$datetype='Due and Answer Available';
                    107: 		    }
                    108: 		}
1.26      www       109: 		if ($name eq 'opendate') { $datetype=&mt('Opening'); }
1.28      www       110: 		if ($name eq 'answerdate') {
                    111: # see if accidentally answerdate is before duedate
                    112: 		    my $duekey=$thiskey;
                    113: 		    $duekey=~s/answerdate$/duedate/;
                    114: 		    if ($resourcedata{$duekey}>$resourcedata{$thiskey}) {
                    115: # forget it
                    116: 			next;
                    117: 		    } 
                    118: 		    $datetype=&mt('Answer Available'); 
                    119: 		}
1.26      www       120: 		$returnhash{$courseid.'@'.$resourcedata{$thiskey}.'_'.
                    121: 			    $resourcedata{$thiskey}}=
                    122: 			    'INTERNAL:'.$datetype.': '.$realm.' ('.$section.')';
                    123: 	    }
                    124: 	}
                    125:     }
1.3       www       126:     return %returnhash;
                    127: }
                    128: 
                    129: sub emptycell {
                    130:     return '<td bgcolor="#AAAAAA">&nbsp;</td>';
                    131: }
                    132: 
                    133: sub normalcell {
1.12      www       134:     my ($day,$month,$year,$text)=@_;
1.4       www       135:     my $output='';
                    136:     foreach (split(/\_\_\_\&\&\&\_\_\_/,$text)) {
                    137:         if ($_) {
1.26      www       138: 	    my $internalflag=0;
1.5       www       139: 	    my ($courseid,$start,$end,@msg)=split(/\@/,$_);
                    140:             my $msg=join('@',@msg);
1.26      www       141: 	    if ($msg=~/INTERNAL\:/) {
                    142: 		$msg=~s/INTERNAL\://gs;
                    143: 		$internalflag=1;
                    144: 	    }
1.32    ! www       145:             my $fullmsg=&mt('Calendar Announcement for ').$ENV{'course.'.$courseid.'.description'}.
        !           146: 		'\n'.&Apache::lonlocal::locallocaltime($start);
1.26      www       147: 	    if ($start!=$end) {
                    148: 		$fullmsg.=' - '.&Apache::lonlocal::locallocaltime($end);
                    149: 	    }
1.32    ! www       150: 	    $fullmsg.=':\n'.$msg;
1.5       www       151:             if ($courseid eq $ENV{'request.course.id'}) {
1.16      www       152:               if ((&Apache::lonnet::allowed('srm',$ENV{'request.course.id'}))
1.19      www       153:                && (!$showedcheck{$start.'_'.$end})
1.26      www       154: 	       && ($ENV{'form.pickdate'} ne 'yes')
                    155: 	       && (!$internalflag)) {
1.5       www       156:                $output.='<input type="checkbox" name="remove_'.$start.'_'.
                    157: 		   $end.'">';
1.16      www       158:                $showedcheck{$start.'_'.$end}=1;
1.5       www       159: 	      }
                    160: 	    }
1.32    ! www       161: 	    $fullmsg=~s/[\n\r]/\\n/gs;
1.15      www       162:             $fullmsg=&HTML::Entities::encode($fullmsg,'<>&"\'');
                    163:             $fullmsg=~s/&/\\&/g;
1.5       www       164:             $output.='<a href="javascript:alert('."'$fullmsg'".')">'.
1.11      www       165: 	       substr($msg,0,20).'...</a><br />';
1.4       www       166:        }
                    167:     }
1.30      www       168:     return '<td valign="top"'.
1.12      www       169: 	((($day eq $todayhash{'day'}) &&
                    170:           ($month eq $todayhash{'month'}) &&
                    171:           ($year eq $todayhash{'year'}))?' bgcolor="#FFFF00"':'').
1.30      www       172:            '>'.&tfont('<b>'.&picklink($day,$day,$month,$year).'</b><br />'.$output).'</td>';
1.3       www       173: }
                    174: 
1.11      www       175: sub plaincell {
                    176:     my ($text)=@_;
                    177:     my $output='';
                    178:     foreach (split(/\_\_\_\&\&\&\_\_\_/,$text)) {
                    179:         if ($_) {
                    180: 	    my ($courseid,$start,$end,@msg)=split(/\@/,$_);
                    181:             my $msg=join('@',@msg);
1.32    ! www       182:             my $fullmsg=&mt('Calendar Announcement for ').$ENV{'course.'.$courseid.'.description'}.
        !           183: 		'\n'.&Apache::lonlocal::locallocaltime($start);
1.26      www       184: 	    if ($start!=$end) {
                    185: 		$fullmsg.=' - '.&Apache::lonlocal::locallocaltime($end);
                    186: 	    }
1.27      www       187: 	    $msg=~s/INTERNAL\://gs;
1.32    ! www       188: 	    $fullmsg.=':\n'.$msg;
        !           189:  	    $fullmsg=~s/[\n\r]/\\n/gs;
1.15      www       190:             $fullmsg=&HTML::Entities::encode($fullmsg,'<>&"\'');
                    191:             $fullmsg=~s/&/\\&/g;
1.11      www       192:             $output.='<a href="javascript:alert('."'$fullmsg'".')">'.
                    193: 	       substr($msg,0,40).'...</a><br />';
                    194:        }
                    195:     }
                    196:     return $output;
                    197: }
                    198: 
                    199: sub listcell {
                    200:     my ($text)=@_;
                    201:     my $output='';
                    202:     foreach (split(/\_\_\_\&\&\&\_\_\_/,$text)) {
                    203:         if ($_) {
                    204: 	    my ($courseid,$start,$end,@msg)=split(/\@/,$_);
                    205:             my $msg=join('@',@msg);
1.27      www       206: 	    $msg=~s/INTERNAL\://gs;
1.26      www       207:             my $fullmsg=&Apache::lonlocal::locallocaltime($start);
                    208: 	    if ($start!=$end) {
                    209: 		$fullmsg.=&mt(' to ').
                    210: 		    &Apache::lonlocal::locallocaltime($end);
                    211: 	    }
                    212:             $fullmsg.=':<br /><b>'.
1.11      www       213:                $msg.'</b>';
                    214:             $output.='<li>'.$fullmsg.'</li>';
                    215:        }
                    216:     }
                    217:     return $output;
                    218: }
                    219: 
1.3       www       220: sub nextday {
                    221:     my %th=@_;
                    222:     $th{'day'}++;
                    223:     return (&Apache::loncommon::maketime(%th),$th{'month'});
                    224: }
                    225: 
                    226: sub showday {
1.11      www       227:     my ($tk,$mode,%allcal)=@_;
1.3       www       228:     my %th=&Apache::loncommon::timehash($tk);
                    229:     my ($nextday,$nextmonth)=&nextday(%th);
                    230:     my $outp='';
1.27      www       231:     if ($mode) {
                    232: 	my $oneday=24*3600;
                    233: 	$tk-=$oneday;
                    234: 	$nextday+=$oneday;
                    235:     }
1.3       www       236:     foreach (keys %allcal) {
                    237: 	my ($course,$startdate,$enddate)=($_=~/^(\w+)\@(\d+)\_(\d+)$/);
1.4       www       238:         if (($startdate<$nextday) && ($enddate>$tk))  {
1.5       www       239: 	    $outp.='___&&&___'.$course.'@'.$startdate.'@'.$enddate.'@'.
                    240:             $allcal{$_};
1.3       www       241:         }
                    242:     }
1.11      www       243:     unless ($mode) {
1.12      www       244:        return ($nextday,$nextmonth,&normalcell(
                    245:                $th{'day'},$th{'month'},$th{'year'},$outp));
1.11      www       246:    } elsif ($outp) {
                    247:        if ($mode==1) {
                    248:           return '<br />'.&plaincell($outp);
                    249:       } else {
                    250:           return '<ul>'.&listcell($outp).'</ul>';
                    251:       }
                    252:    } else {
                    253:        return '';
                    254:    }
1.3       www       255: }
1.1       www       256: 
1.19      www       257: sub tfont {
                    258:     my $text=shift;
                    259:     if ($ENV{'form.pickdate'} eq 'yes') {
                    260: 	return '<font size="1">'.$text.'</font>';
                    261:     } else {
                    262: 	return $text;
                    263:     }
                    264: }
                    265: 
                    266: sub picklink {
                    267:     my ($text,$day,$month,$year)=@_;
                    268:     if ($ENV{'form.pickdate'} eq 'yes') {
                    269: 	return '<a href="javascript:dialin('.$day.','.$month.','.$year.')">'.
                    270: 	    $text.'</a>';
                    271:     } else {
                    272: 	return $text;
                    273:     }
                    274: }
                    275: 
                    276: sub dialscript {
                    277:     return (<<ENDDIA);
                    278: <script language="Javascript">
                    279: function dialin(day,month,year) {
                    280: 	opener.document.$ENV{'form.formname'}.$ENV{'form.element'}\_year.value=year;
                    281:     var slct=opener.document.$ENV{'form.formname'}.$ENV{'form.element'}\_month;
                    282:     var i;
                    283:     for (i=0;i<slct.length;i++) {
                    284:         if (slct.options[i].value==month) { slct.selectedIndex=i; }
                    285:     }
                    286:     opener.document.$ENV{'form.formname'}.$ENV{'form.element'}\_day.value=day;
                    287:     opener.$ENV{'form.element'}\_checkday();
                    288:     self.close();
                    289: }
                    290: </script>
                    291: ENDDIA
                    292: }
                    293: 
1.1       www       294: sub handler {
                    295:     my $r = shift;
1.21      www       296:     &Apache::loncommon::content_type($r,'text/html');
1.1       www       297:     $r->send_http_header;
                    298:     return OK if $r->header_only;
                    299: 
1.3       www       300: # ---------------------------------------------------------- Get time right now
                    301:     my $today=time;
1.12      www       302:     %todayhash=&Apache::loncommon::timehash($today);
1.16      www       303: # ----------------------------------------------------------------- Check marks
                    304:     %showedcheck=();
                    305:     undef %showedcheck;
1.3       www       306: # ---------------------------------------------------------- Get month and year
                    307:     &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},
1.19      www       308:                              ['month','year','pickdate','formname','element']);
1.3       www       309: # --------------------------------------------------- Decide what month to show
                    310:     my $year=$todayhash{'year'};
                    311:     if ($ENV{'form.year'}) { $year=$ENV{'form.year'}; }
                    312:     my $month=$todayhash{'month'};
                    313:     if ($ENV{'form.month'}) { $month=$ENV{'form.month'}; }
1.18      www       314: 
                    315: # ---------------------------------------------- See if we are in pickdate mode
                    316:     my $pickdatemode=($ENV{'form.pickdate'} eq 'yes');
1.19      www       317:     my $pickinfo='&pickdate=yes&formname='.$ENV{'form.formname'}.
                    318: 	'&element='.$ENV{'form.element'};
1.3       www       319: # --------------------------------------------- Find out first day of the month
                    320: 
                    321:     my %firstday=&Apache::loncommon::timehash(
                    322:        &Apache::loncommon::maketime( 'day' => 1, 'month'=> $month,
                    323:                                      'year' => $year, 'hours' => 0,
                    324: 				     'minutes' => 0, 'seconds' => 0,
1.30      www       325:                                      'dlsav' => -1 ));
1.3       www       326:     my $weekday=$firstday{'weekday'};
                    327: # ------------------------------------------------------------ Print the screen
1.9       www       328: 
1.1       www       329:     $r->print(<<ENDDOCUMENT);
                    330: <html>
                    331: <head>
                    332: <title>The LearningOnline Network with CAPA</title>
1.3       www       333: <script>
                    334: 
                    335:     function trysubmit() {
                    336:         document.anno.action.value="new";
                    337: 	document.anno.submit();
                    338:     }
                    339: 
                    340:     function removesub() {
                    341:         document.anno.action.value="del";
                    342: 	document.anno.submit();
                    343:     }
                    344: </script>
1.1       www       345: </head>
                    346: ENDDOCUMENT
1.18      www       347:     if ($pickdatemode) {
                    348: # no big header in pickdate mode
                    349: 	$r->print(&Apache::loncommon::bodytag("Pick a Date",'','',1).
1.19      www       350: 		  &dialscript().
1.18      www       351: 		  '<font size="1">');
                    352:     } else {
                    353:        $r->print(&Apache::loncommon::bodytag("Announcements and Calendar"));
                    354:     }
1.3       www       355: # does this user have privileges to post, etc?
                    356:     my $allowed=0;
                    357:     if ($ENV{'request.course.id'}) {
                    358:        $allowed=&Apache::lonnet::allowed('srm',$ENV{'request.course.id'});
                    359:     }
1.17      www       360: # does this user have privileges to post to servers?
                    361:     my $serverpost=0;
                    362:     if ($ENV{'request.role.domain'}) {
                    363: 	$serverpost=&Apache::lonnet::allowed('psa',
                    364: 					     $ENV{'request.role.domain'});
                    365:     } else {
                    366: 	$serverpost=&Apache::lonnet::allowed('psa','/');
                    367:     }
1.18      www       368: # -------------------------------- BUT: do no fancy stuff when in pickdate mode
                    369:     if ($pickdatemode) { 
                    370: 	$serverpost=0; 
                    371: 	$allowed=0;
                    372:     }
1.17      www       373: # ------------------------------------------------------------ Process commands
                    374:     if ($serverpost) {
                    375: 	if ($ENV{'form.serveraction'}) {
                    376: 	    foreach (keys %ENV) {
                    377: 		if ($_=~/^form\.postto\_(\w+)/) {
                    378: 		    $r->print( 
                    379: 			'<br />Posting '.$1.': '.&Apache::lonnet::postannounce
                    380: 			($1,$ENV{'form.serverannnounce'}));
                    381: 		}
                    382: 	    }
                    383: 	}
                    384: 	$r->print(<<SERVERANNOUNCE);
                    385: <form name="serveranno" method="post">
                    386: <h3>Post Server Announcements</h3>
                    387: Post announcements to the system login and roles screen<br />
                    388: <i>(leave blank to delete announcement)</i><br />
                    389: <textarea name="serverannnounce" cols="60" rows="5"></textarea><br />
                    390: Check machines:<br />
                    391: SERVERANNOUNCE
                    392: # list servers
                    393:     foreach (sort keys %Apache::lonnet::hostname) {
                    394: 	if (&Apache::lonnet::allowed('psa',$Apache::lonnet::hostdom{$_})) {
                    395: 	    $r->print ('<br /><input type="checkbox" name="postto_'.$_.'" /> '.
                    396: 		       $_.' <tt>'.$Apache::lonnet::hostname{$_}.'</tt> '.
                    397: 		       '<a href="http://'.$Apache::lonnet::hostname{$_}.
                    398: 		       '/announcement.txt" target="annowin">current</a>');
                    399: 	}
                    400:     }
                    401:     $r->print(
                    402:   '<br /><input type="submit" name="serveraction" value="Post"></form><hr />');
                    403:     }
1.3       www       404:     if ($allowed) {
                    405:         my $coursenum=$ENV{'course.'.$ENV{'request.course.id'}.'.num'};
                    406:         my $coursedom=$ENV{'course.'.$ENV{'request.course.id'}.'.domain'};
                    407: # ----------------------------------------------------- Store new submitted one
                    408:         if ($ENV{'form.action'} eq 'new') {
1.9       www       409: 	    my $startdate = 
                    410: 		&Apache::lonhtmlcommon::get_date_from_form('startdate');
                    411: 	    my $enddate   = 
                    412: 		&Apache::lonhtmlcommon::get_date_from_form('enddate');
                    413: 	    unless ($startdate=~/^\d+$/) { $startdate=time; }
                    414:             unless ($enddate=~/^\d+$/) { $enddate=$startdate+1; }
                    415:             if ($startdate>$enddate) {
                    416: 		my $buffer=$startdate;
                    417: 		$startdate=$enddate;
                    418: 		$enddate=$buffer;
                    419:             }
1.3       www       420: 	    &Apache::lonnet::put('calendar',{ 
1.9       www       421: 		$startdate.'_'.$enddate => 
1.3       www       422: 		    $ENV{'form.msg'} },$coursedom,$coursenum);
                    423:         }
                    424: # ---------------------------------------------------------------- Remove items
                    425:         if ($ENV{'form.action'} eq 'del') {
                    426: 	    my @delwhich=();
                    427:             foreach (keys %ENV) {
                    428: 		if ($_=~/^form\.remove\_(.+)$/) {
                    429: 		    push(@delwhich,$1);
                    430:                 }
                    431:             }
                    432:             &Apache::lonnet::del('calendar',\@delwhich,$coursedom,$coursenum);
                    433:         }
                    434: # -------------------------------------------------------- Form to post new one
                    435:         my %tomorrowhash=%todayhash;
                    436:         $tomorrowhash{'day'}++;
                    437:         my $tomorrow=&Apache::loncommon::maketime(%tomorrowhash);
                    438:         
1.10      www       439:         &editfield($r,$today,$tomorrow,'');
1.3       www       440:     }
1.5       www       441: # ----------------------------------------------------- Summarize all calendars
                    442:     my %allcal=();
                    443:     foreach (&Apache::loncommon::findallcourses()) {
                    444: 	%allcal=(%allcal,&readcalendar($_));
                    445:     }
                    446: 
                    447: # ------------------------------- Initialize table and forward backward buttons
1.3       www       448:     my ($pm,$py,$fm,$fy)=($month-1,$year,$month+1,$year);
                    449:     if ($pm<1) { ($pm,$py)=(12,$year-1); }
                    450:     if ($fm>12){ ($fm,$fy)=(1,$year+1); }
1.14      www       451: 
1.20      www       452:     $r->print('<h1>'.('',&mt('January'),&mt('February'),&mt('March'),
                    453: 		      &mt('April'),&mt('May'),
                    454: 		      &mt('June'),&mt('July'),&mt('August'),
                    455:                       &mt('September'),&mt('October'),
                    456:                       &mt('November'),&mt('December'))[$month].' '.
                    457: 	              $year.'</h1>');
1.13      www       458: # Reached the end of times, give up
                    459:     if (($year<1970) || ($year>2037)) {
                    460: 	$r->print('<h3>No calendar available for this date.</h3>'.
                    461:  '<a href="/adm/announcements?month='.$todayhash{'month'}.
                    462:  '&year='.$todayhash{'year'}.'">Current Month</a></body></html>');
                    463: 	return OK;
                    464:     }
                    465:     $r->print(
1.18      www       466:  '<a href="/adm/announcements?month='.$pm.'&year='.$py.
1.20      www       467:  ($pickdatemode?$pickinfo:'').'">'.&mt('Previous Month').'</a> '.
1.18      www       468:  '<a href="/adm/announcements?month='.$fm.'&year='.$fy.
1.20      www       469:  ($pickdatemode?$pickinfo:'').'">'.&mt('Next Month').'</a>'.
1.12      www       470:  '&nbsp;&nbsp;&nbsp;<a href="/adm/announcements?month='.$todayhash{'month'}.
1.18      www       471:  '&year='.$todayhash{'year'}.
1.20      www       472:  ($pickdatemode?$pickinfo:'').'">'.&mt('Current Month').'</a><p>'.
1.19      www       473:         '<table border="2" cols="7" rows="5"><tr><th>'.
1.20      www       474: &tfont(&mt('Sun'))
1.19      www       475: .'</th><th>'.
1.20      www       476: &tfont(&mt('Mon'))
1.19      www       477: .'</th><th>'.
1.20      www       478: &tfont(&mt('Tue'))
1.19      www       479: .'</th><th>'.
1.20      www       480: &tfont(&mt('Wed'))
1.19      www       481: .'</th><th>'.
1.20      www       482: &tfont(&mt('Thu'))
1.19      www       483: .'</th><th>'.
1.20      www       484: &tfont(&mt('Fri'))
1.19      www       485: .'</th><th>'.
1.20      www       486: &tfont(&mt('Sat'))
1.19      www       487: .'</th></tr>');
1.3       www       488: 
                    489:     my $tk=&Apache::loncommon::maketime(%firstday);
                    490:     my $outp;
                    491:     my $nm;
                    492: 
                    493: # ---------------------------------------------------------------- Actual table
                    494:     $r->print('<tr>');
                    495:     for (my $i=0;$i<$weekday;$i++) { $r->print(&emptycell); }
                    496:     for (my $i=$weekday;$i<=6;$i++) { 
1.11      www       497:         ($tk,$nm,$outp)=&showday($tk,0,%allcal);
1.3       www       498:         $r->print($outp);
                    499:     }
                    500:     $r->print('</tr>');
                    501: 
1.23      www       502:     for (my $k=0;$k<=4;$k++) {
1.3       www       503:         $r->print('<tr>');
                    504:         for (my $i=0;$i<=6;$i++) {
1.11      www       505:             ($tk,$nm,$outp)=&showday($tk,0,%allcal);
1.3       www       506:             if ($month!=$nm) { $outp=&emptycell; }
                    507:             $r->print($outp);
                    508:         }
                    509:         $r->print('</tr>');
                    510:     }
                    511: # ------------------------------------------------------------------- End table
1.7       matthew   512:     $r->print('</table>');
1.16      www       513: # ----------------------------------------------------------------- Check marks
                    514:     %showedcheck=();
                    515:     undef %showedcheck;
                    516: # --------------------------------------------------------------- Remove button
1.24      www       517:     if ($allowed) { $r->print('<input type="button" onClick="removesub()" value="Remove Checked Entries">'.
                    518: 			      &Apache::loncommon::help_open_topic('Calendar_Remove_Announcement').'</form>'); }
1.7       matthew   519:     $r->print('<p>'.
1.18      www       520:  '<a href="/adm/announcements?month='.$pm.'&year='.$py.
1.20      www       521:  ($pickdatemode?$pickinfo:'').'">'.&mt('Previous Month').'</a> '.
1.18      www       522:  '<a href="/adm/announcements?month='.$fm.'&year='.$fy.
1.20      www       523:  ($pickdatemode?$pickinfo:'').'">'.&mt('Next Month').'</a>'.
1.12      www       524:  '&nbsp;&nbsp;&nbsp;<a href="/adm/announcements?month='.$todayhash{'month'}.
1.18      www       525:  '&year='.$todayhash{'year'}.
1.20      www       526:  ($pickdatemode?$pickinfo:'').'">'.&mt('Current Month').'</a></p>'.
1.18      www       527:  ($pickdatemode?'</font>':'').
1.3       www       528:  '</body></html>');
1.1       www       529:     return OK;
                    530: } 
                    531: 
                    532: 1;
                    533: __END__

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>