1: # The LearningOnline Network
2: # Announce
3: #
4: # $Id: lonannounce.pm,v 1.61 2006/10/10 01:52:45 albertel Exp $
5: #
6: # Copyright Michigan State University Board of Trustees
7: #
8: # This file is part of the LearningOnline Network with CAPA (LON-CAPA).
9: #
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.
14: #
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:
29: package Apache::lonannounce;
30:
31: use strict;
32: use Apache::Constants qw(:common);
33: use Apache::loncommon;
34: use Apache::lonhtmlcommon();
35: use Apache::lonlocal;
36: use Apache::lonnavmaps();
37: use Apache::lonrss();
38: use Apache::lonnet;
39: use HTML::Entities();
40:
41: my %todayhash;
42: my %showedcheck;
43:
44: sub editfield {
45: my ($r,$start,$end,$text)=@_;
46: # Deal with date forms
47: my $startdateform = &Apache::lonhtmlcommon::date_setter('anno',
48: 'startdate',
49: $start);
50: my $enddateform = &Apache::lonhtmlcommon::date_setter('anno',
51: 'enddate',
52: $end);
53: my $help=&Apache::loncommon::help_open_menu('Calendar Add Announcement','Calendar_Add_Announcement',274,'Communication Tools');
54: my %lt=&Apache::lonlocal::texthash('post' => 'Post Announcement',
55: 'start' => 'Starting date',
56: 'end' => 'Ending date',
57: 'incrss' => 'Include in course RSS newsfeed');
58:
59: $r->print(<<ENDFORM);
60: $help
61: <form name="anno" method="post">
62: <input type="hidden" value='' name="action" />
63: <table><tr><td>$lt{'start'}:</td><td>$startdateform</td></tr>
64: <tr><td>$lt{'end'}:</td><td>$enddateform</td></tr></table>
65: <textarea name="msg" rows="4" cols="60">$text</textarea>
66: <br />
67: <label><input type="checkbox" name="rsspost" /> $lt{'incrss'}</label>
68: <br /><input type="button" onClick="trysubmit()" value="$lt{'post'}" /><hr />
69: ENDFORM
70: }
71:
72: sub readcalendar {
73: my $courseid=shift;
74: my $coursenum=$env{'course.'.$courseid.'.num'};
75: my $coursedom=$env{'course.'.$courseid.'.domain'};
76: my %thiscal=&Apache::lonnet::dump('calendar',$coursedom,$coursenum);
77: my %returnhash=();
78: foreach my $item (keys(%thiscal)) {
79: unless (($item=~/^error\:/) || ($thiscal{$item}=~/^error\:/)) {
80: $returnhash{$courseid.'@'.$item}=$thiscal{$item};
81: }
82: }
83: my $can_see_hidden = ($env{'request.role.adv'} &&
84: ($courseid eq $env{'request.course.id'}));
85:
86: my $navmap;
87: if ($courseid eq $env{'request.course.id'}) {
88: $navmap = Apache::lonnavmaps::navmap->new();
89: }
90: my %resourcedata=
91: &Apache::lonnet::dump('resourcedata',$coursedom,$coursenum);
92: foreach my $thiskey (sort keys %resourcedata) {
93: if ($resourcedata{$thiskey.'.type'}=~/^date/) {
94: my ($course,$middle,$part,$name)=
95: ($thiskey=~/^(\w+)\.(?:(.+)\.)*([\w\s]+)\.(\w+)$/);
96: my %data = ( 'section' => &mt('All Students'));
97: if ($middle=~/^\[(.*)\]\./) {
98: my $sec=$1;
99: # if we have a section don't show ones that aren't ours
100: if ($env{'request.course.sec'} &&
101: $env{'request.course.sec'} ne $sec) { next; }
102: # if a student without a section don't show any section ones
103: if (!$env{'request.role.adv'} &&
104: !$env{'request.course.sec'}) { next; }
105: $data{'section'}=&mt('Group/Section').': '.$1;
106: $middle=~s/^\[(.*)\]\.//;
107: }
108: $middle=~s/\.$//;
109: $data{'realm'}=&mt('All Resources');
110: if ($middle eq '___(all)') {
111: if (!$can_see_hidden && !$navmap) {
112: next;
113: }
114: } elsif ($middle=~/^(.+)\_\_\_\(all\)$/) {
115: my $map_url=$1;
116: if (!$can_see_hidden && !$navmap) {
117: next;
118: }
119: if (!$can_see_hidden) {
120: my $res = $navmap->getResourceByUrl($map_url);
121: if ($res && $res->randomout()) { next; }
122: }
123: $data{'realm'}=&mt('Folder/Map');
124: $data{'url'} = $map_url;
125: } elsif ($middle) {
126: if (!$can_see_hidden && !$navmap) {
127: next;
128: }
129: if (!$can_see_hidden) {
130: my $res = $navmap->getBySymb($middle);
131: if ($res && $res->randomout()) { next; }
132: }
133: $data{'realm'} = &mt('Resource');
134: $data{'symb'} = $middle;
135: }
136: $data{'datetype'} = $name;
137: if ($name eq 'duedate') {
138: $data{'datetype'} = &mt('Due');
139: # see if accidentally answerdate is before duedate
140: my $answerkey=$thiskey;
141: $answerkey=~s/duedate$/answerdate/;
142: if ($resourcedata{$thiskey}>$resourcedata{$answerkey}) {
143: $data{'datetype'} = &mt('Due and Answer Available');
144: }
145: }
146: if ($name eq 'opendate'
147: || $name eq 'contentopen' ) {
148: $data{'datetype'}=&mt('Opening');
149: }
150: if ($name eq 'contentclose') {
151: $data{'datetype'}=&mt('Closing');
152: }
153: if ($name eq 'answerdate') {
154: # see if accidentally answerdate is before duedate
155: my $duekey=$thiskey;
156: $duekey=~s/answerdate$/duedate/;
157: if ($resourcedata{$duekey}>$resourcedata{$thiskey}) {
158: # forget it
159: next;
160: }
161: $data{'datetype'}=&mt('Answer Available');
162: }
163: $returnhash{$courseid.'@'.$resourcedata{$thiskey}.'_'.
164: $resourcedata{$thiskey}}=\%data;
165: }
166: }
167: return %returnhash;
168: }
169:
170: sub emptycell {
171: return '<td class="LC_calendar_day_empty"> </td>';
172: }
173:
174: sub normalcell {
175: my ($day,$month,$year,$items_ref)=@_;
176: my $output;
177: my @items=&order($items_ref);
178: foreach my $item (@items) {
179: if ($item) {
180: my ($courseid,$start,$end,$msg)=@$item;
181: my $internalflag= (ref($msg)) ? 1 : 0;
182: $msg = &display_msg($msg);
183: my $fullmsg=&mt('Calendar Announcement for ').$env{'course.'.$courseid.'.description'}.
184: '\n'.&Apache::lonlocal::locallocaltime($start);
185: if ($start!=$end) {
186: $fullmsg.=' - '.&Apache::lonlocal::locallocaltime($end);
187: }
188: $fullmsg.=':\n'.$msg;
189: $fullmsg=~s/[\n\r]/\\n/gs;
190: $fullmsg=&HTML::Entities::encode($fullmsg,'<>&"\'');
191: $fullmsg=~s/&/\\&/g;
192: my $short_msg = substr($msg,0,20).((length($msg) > 20)?'...':'');
193: if (defined($output)) { $output.='<br />'; }
194: if ($courseid eq $env{'request.course.id'}) {
195: if ((&Apache::lonnet::allowed('srm',$env{'request.course.id'}))
196: && (!$showedcheck{$start.'_'.$end})
197: && ($env{'form.pickdate'} ne 'yes')
198: && (!$internalflag)) {
199: $output.='<input type="checkbox" name="remove_'.$start.'_'.
200: $end.'">';
201: $showedcheck{$start.'_'.$end}=1;
202: }
203: }
204: $output.='<a href="javascript:alert('."'$fullmsg'".')">'.
205: $short_msg.'</a>';
206: }
207: }
208: return '<td class="LC_calendar_day'.
209: ((($day eq $todayhash{'day'}) &&
210: ($month eq $todayhash{'month'}) &&
211: ($year eq $todayhash{'year'}))?'_current':'').
212: '" ><b>'.&picklink($day,$day,$month,$year).'</b><br />'.$output.'</td>';
213: }
214:
215: sub plaincell {
216: my ($items_ref)=@_;
217: my $output;
218: my @items=&order($items_ref);
219: foreach my $item (@items) {
220: if (ref($item)) {
221: my ($courseid,$start,$end,$msg)=@$item;
222: my $fullmsg=&mt('Calendar Announcement for ').$env{'course.'.$courseid.'.description'}.
223: '\n'.&Apache::lonlocal::locallocaltime($start);
224: if ($start!=$end) {
225: $fullmsg.=' - '.&Apache::lonlocal::locallocaltime($end);
226: }
227: $msg = &display_msg($msg);
228: $fullmsg.=':\n'.$msg;
229: $fullmsg=~s/[\n\r]/\\n/gs;
230: $fullmsg=&HTML::Entities::encode($fullmsg,'<>&"\'');
231: $fullmsg=~s/&/\\&/g;
232: my $short_msg = substr($msg,0,80).((length($msg) > 80)?'...':'');
233: if (defined($output)) { $output.='<br />'; }
234: $output.='<a href="javascript:alert('."'$fullmsg'".')">'.
235: $short_msg.'</a>';
236: }
237: }
238: return $output;
239: }
240:
241: sub listcell {
242: my ($items_ref)=@_;
243: my $output='';
244: my @items=&order($items_ref);
245: foreach my $item (@items) {
246: if (ref($item)) {
247: my ($courseid,$start,$end,$msg)=@$item;
248: my $fullmsg=&Apache::lonlocal::locallocaltime($start);
249: if ($start!=$end) {
250: $fullmsg.=&mt(' to ').
251: &Apache::lonlocal::locallocaltime($end);
252: }
253: $fullmsg.=':<br /><b>'.&display_msg($msg).'</b>';
254: $output.='<li>'.$fullmsg.'</li>';
255: }
256: }
257: return $output;
258: }
259:
260: sub order {
261: my ($items)=@_;
262: return sort {
263: my ($astart,$aend)=$a->[1,2];
264: my ($bstart,$bend)=$b->[1,2];
265: if ($astart != $bstart) {
266: return $astart <=> $bstart;
267: }
268: return $aend <=> $bend;
269: } @$items;
270: }
271:
272: sub nextday {
273: my %th=@_;
274: $th{'day'}++;
275: return (&Apache::loncommon::maketime(%th),$th{'month'});
276: }
277:
278: sub display_msg {
279: my ($msg) = @_;
280:
281: # if it's not a ref, it's an instructor provided message
282: return $msg if (!ref($msg));
283:
284: my $output = $msg->{'datetype'}. ': '.$msg->{'realm'};
285: if (exists($msg->{'url'})) {
286: my $displayurl=&Apache::lonnet::gettitle($msg->{'url'});
287: if ($msg->{'url'}!~/\Q$displayurl\E$/) {
288: $output .= ' - '.$displayurl;
289: }
290: }
291: if (exists($msg->{'symb'})) {
292: my $displaysymb=&Apache::lonnet::gettitle($msg->{'symb'});
293: if ($msg->{'symb'}!~/\Q$displaysymb\E$/) {
294: $output .= ' - '.$displaysymb;
295: }
296: }
297: $output .= ' ('.$msg->{'section'}.') ';
298: return $output;
299: }
300:
301: sub showday {
302: my ($tk,$mode,%allcal)=@_;
303: my %th=&Apache::loncommon::timehash($tk);
304: my ($nextday,$nextmonth)=&nextday(%th);
305: my @outp;
306: if ($mode) {
307: my $oneday=24*3600;
308: $tk-=$oneday;
309: $nextday+=$oneday;
310: }
311: foreach my $item (keys(%allcal)) {
312: my ($course,$startdate,$enddate)=($item=~/^(\w+)\@(\d+)\_(\d+)$/);
313: if (($startdate<$nextday) && ($enddate>=$tk)) {
314: push(@outp,[$course,$startdate,$enddate,$allcal{$item}]);
315: }
316: }
317: unless ($mode) {
318: return ($nextday,$nextmonth,&normalcell(
319: $th{'day'},$th{'month'},$th{'year'},\@outp));
320: } elsif (@outp) {
321: if ($mode==1) {
322: return '<br />'.&plaincell(\@outp);
323: } else {
324: return '<ul>'.&listcell(\@outp).'</ul>';
325: }
326: } else {
327: return '';
328: }
329: }
330:
331: sub picklink {
332: my ($text,$day,$month,$year)=@_;
333: if ($env{'form.pickdate'} eq 'yes') {
334: return '<a href="javascript:dialin('.$day.','.$month.','.$year.')">'.
335: $text.'</a>';
336: } else {
337: return $text;
338: }
339: }
340:
341: sub dialscript {
342: return (<<ENDDIA);
343: <script language="Javascript">
344: function dialin(day,month,year) {
345: opener.document.$env{'form.formname'}.$env{'form.element'}\_year.value=year;
346: var slct=opener.document.$env{'form.formname'}.$env{'form.element'}\_month;
347: var i;
348: for (i=0;i<slct.length;i++) {
349: if (slct.options[i].value==month) { slct.selectedIndex=i; }
350: }
351: opener.document.$env{'form.formname'}.$env{'form.element'}\_day.value=day;
352: opener.$env{'form.element'}\_checkday();
353: self.close();
354: }
355: </script>
356: ENDDIA
357: }
358: # ----------------------------------------------------- Summarize all calendars
359: sub get_all_calendars {
360: my %allcal=();
361: foreach my $course (sort(&Apache::loncommon::findallcourses())) {
362: %allcal=(%allcal,&readcalendar($course));
363: }
364: return %allcal;
365: }
366:
367: sub output_ics_file {
368: my ($r)=@_;
369: # RFC 2445 wants CRLF
370: my $crlf="\015\012";
371: # Header
372: $r->print("BEGIN:VCALENDAR$crlf");
373: $r->print("VERSION:2.0$crlf");
374: $r->print("PRODID:-//LONCAPA//LONCAPA Calendar Output//EN$crlf");
375: my %allcal=&get_all_calendars();
376: foreach my $event (keys(%allcal)) {
377: my ($courseid,$startdate,$enddate)=($event=~/^(\w+)\@(\d+)\_(\d+)$/);
378: my $uid=$event;
379: $uid=~s/[\W\_]/-/gs;
380: $uid.='@loncapa';
381: my $summary=&display_msg($allcal{$event});
382: $summary=~s/\s+/ /gs;
383: $summary=$env{'course.'.$courseid.'.description'}.': '.$summary;
384: $r->print("BEGIN:VEVENT$crlf");
385: $r->print("DTSTART:".&Apache::loncommon::utc_string($startdate).$crlf);
386: $r->print("DTEND:".&Apache::loncommon::utc_string($enddate).$crlf);
387: $r->print("SUMMARY:$summary$crlf");
388: $r->print("UID:$uid$crlf");
389: $r->print("END:VEVENT$crlf");
390: }
391: # Footer
392: $r->print("END:VCALENDAR$crlf");
393: }
394:
395: sub handler {
396: my $r = shift;
397: if ($r->uri=~/\.(ics|ical)$/) {
398: &Apache::loncommon::content_type($r,'text/calendar');
399: &output_ics_file($r);
400: return OK;
401: }
402: &Apache::loncommon::content_type($r,'text/html');
403: $r->send_http_header;
404: return OK if $r->header_only;
405:
406: # ---------------------------------------------------------- Get time right now
407: my $today=time;
408: %todayhash=&Apache::loncommon::timehash($today);
409: # ----------------------------------------------------------------- Check marks
410: undef(%showedcheck);
411: # ---------------------------------------------------------- Get month and year
412: &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},
413: ['month','year','pickdate','formname','element']);
414: # --------------------------------------------------- Decide what month to show
415: my $year=$todayhash{'year'};
416: if ($env{'form.year'}) { $year=$env{'form.year'}; }
417: my $month=$todayhash{'month'};
418: if ($env{'form.month'}) { $month=$env{'form.month'}; }
419:
420: # ---------------------------------------------- See if we are in pickdate mode
421: my $pickdatemode=($env{'form.pickdate'} eq 'yes');
422: my $pickinfo='&pickdate=yes&formname='.$env{'form.formname'}.
423: '&element='.$env{'form.element'};
424: # --------------------------------------------- Find out first day of the month
425:
426: my %firstday=&Apache::loncommon::timehash(
427: &Apache::loncommon::maketime( 'day' => 1, 'month'=> $month,
428: 'year' => $year, 'hours' => 0,
429: 'minutes' => 0, 'seconds' => 0,
430: 'dlsav' => -1 ));
431: my $weekday=$firstday{'weekday'};
432: # ------------------------------------------------------------ Print the screen
433: my $js = <<ENDDOCUMENT;
434: <script type="text/javascript">
435:
436: function trysubmit() {
437: document.anno.action.value="new";
438: document.anno.submit();
439: }
440:
441: function removesub() {
442: document.anno.action.value="del";
443: document.anno.submit();
444: }
445: </script>
446: ENDDOCUMENT
447:
448: if ($pickdatemode) {
449: # no big header in pickdate mode
450: $r->print(&Apache::loncommon::start_page("Pick a Date",$js,
451: {'only_body' => 1,}).
452: &dialscript().
453: '<font size="1">');
454: } else {
455: $r->print(&Apache::loncommon::start_page("Announcements and Calendar",
456: $js));
457: }
458: # does this user have privileges to post, etc?
459: my $allowed=0;
460: if ($env{'request.course.id'}) {
461: $allowed=&Apache::lonnet::allowed('srm',$env{'request.course.id'});
462: }
463: # does this user have privileges to post to servers?
464: my $serverpost=0;
465: if ($env{'request.role.domain'}) {
466: $serverpost=&Apache::lonnet::allowed('psa',
467: $env{'request.role.domain'});
468: } else {
469: $serverpost=&Apache::lonnet::allowed('psa','/');
470: }
471: # -------------------------------- BUT: do no fancy stuff when in pickdate mode
472: if ($pickdatemode) {
473: $serverpost=0;
474: $allowed=0;
475: }
476: # ------------------------------------------------------------ Process commands
477: if ($serverpost) {
478: if ($env{'form.serveraction'}) {
479: foreach my $key (keys(%env)) {
480: if ($key=~/^form\.postto\_(\w+)/) {
481: $r->print(
482: '<br />Posting '.$1.': '.&Apache::lonnet::postannounce
483: ($1,$env{'form.serverannnounce'}));
484: }
485: }
486: }
487: $r->print(<<SERVERANNOUNCE);
488: <form name="serveranno" method="post">
489: <h3>Post Server Announcements</h3>
490: Post announcements to the system login and roles screen<br />
491: <i>(leave blank to delete announcement)</i><br />
492: <textarea name="serverannnounce" cols="60" rows="5"></textarea><br />
493: Check machines:<br />
494: SERVERANNOUNCE
495: # list servers
496: foreach my $host (sort(keys(%Apache::lonnet::hostname))) {
497: if (&Apache::lonnet::allowed('psa',$Apache::lonnet::hostdom{$host})) {
498: $r->print ('<br /><label><input type="checkbox" name="postto_'.$host.'" /> '.
499: $host.' <tt>'.$Apache::lonnet::hostname{$host}.'</tt> '.
500: '</label><a href="http://'.$Apache::lonnet::hostname{$host}.
501: '/announcement.txt" target="annowin">current</a>');
502: }
503: }
504: $r->print(
505: '<br /><input type="submit" name="serveraction" value="Post"></form><hr />');
506: }
507: if ($allowed) {
508: my $coursenum=$env{'course.'.$env{'request.course.id'}.'.num'};
509: my $coursedom=$env{'course.'.$env{'request.course.id'}.'.domain'};
510: # ----------------------------------------------------- Store new submitted one
511: if ($env{'form.action'} eq 'new') {
512: my $startdate =
513: &Apache::lonhtmlcommon::get_date_from_form('startdate');
514: my $enddate =
515: &Apache::lonhtmlcommon::get_date_from_form('enddate');
516: unless ($startdate=~/^\d+$/) { $startdate=time; }
517: unless ($enddate=~/^\d+$/) { $enddate=$startdate+1; }
518: if ($startdate>$enddate) {
519: my $buffer=$startdate;
520: $startdate=$enddate;
521: $enddate=$buffer;
522: }
523: &Apache::lonnet::put('calendar',{
524: $startdate.'_'.$enddate =>
525: $env{'form.msg'} },$coursedom,$coursenum);
526: if ($env{'form.rsspost'}) {
527: &Apache::lonrss::addentry($coursenum,$coursedom,'Course_Announcements',
528: &mt('Event from [_1] to [_2]',
529: &Apache::lonlocal::locallocaltime($startdate),
530: &Apache::lonlocal::locallocaltime($enddate)),
531: $env{'form.msg'},'/adm/announcements','public');
532: }
533: }
534: # ---------------------------------------------------------------- Remove items
535: if ($env{'form.action'} eq 'del') {
536: my @delwhich=();
537: foreach my $key (keys(%env)) {
538: if ($key=~/^form\.remove\_(.+)$/) {
539: push(@delwhich,$1);
540: }
541: }
542: &Apache::lonnet::del('calendar',\@delwhich,$coursedom,$coursenum);
543: }
544: # -------------------------------------------------------- Form to post new one
545: my %tomorrowhash=%todayhash;
546: $tomorrowhash{'day'}++;
547: my $tomorrow=&Apache::loncommon::maketime(%tomorrowhash);
548:
549: &editfield($r,$today,$tomorrow,'');
550: }
551: # ----------------------------------------------------- Summarize all calendars
552: my %allcal=&get_all_calendars();
553: # ------------------------------- Initialize table and forward backward buttons
554: my ($pm,$py,$fm,$fy)=($month-1,$year,$month+1,$year);
555: if ($pm<1) { ($pm,$py)=(12,$year-1); }
556: if ($fm>12){ ($fm,$fy)=(1,$year+1); }
557:
558: $r->print('<h1>'.('',&mt('January'),&mt('February'),&mt('March'),
559: &mt('April'),&mt('May'),
560: &mt('June'),&mt('July'),&mt('August'),
561: &mt('September'),&mt('October'),
562: &mt('November'),&mt('December'))[$month].' '.
563: $year.'</h1>');
564: # Reached the end of times, give up
565: if (($year<1970) || ($year>2037)) {
566: $r->print('<h3>No calendar available for this date.</h3>'.
567: '<a href="/adm/announcements?month='.$todayhash{'month'}.
568: '&year='.$todayhash{'year'}.'">Current Month</a>'.
569: &Apache::loncommon::end_page());
570: return OK;
571: }
572:
573: my $class = "LC_calendar";
574: if ($env{'form.pickdate'} eq 'yes') {
575: $class .= " LC_calendar_pickdate";
576: }
577: $r->print(
578: '<a href="/adm/announcements?month='.$pm.'&year='.$py.
579: ($pickdatemode?$pickinfo:'').'">'.&mt('Previous Month').'</a> '.
580: '<a href="/adm/announcements?month='.$fm.'&year='.$fy.
581: ($pickdatemode?$pickinfo:'').'">'.&mt('Next Month').'</a>'.
582: ' <a href="/adm/announcements?month='.$todayhash{'month'}.
583: '&year='.$todayhash{'year'}.
584: ($pickdatemode?$pickinfo:'').'">'.&mt('Current Month').'</a><p>'.
585: '<table class="'.$class.'" cols="7" rows="5"><tr>
586: <th>'.&mt('Sun').'</th>
587: <th>'.&mt('Mon').'</th>
588: <th>'.&mt('Tue').'</th>
589: <th>'.&mt('Wed').'</th>
590: <th>'.&mt('Thu').'</th>
591: <th>'.&mt('Fri').'</th>
592: <th>'.&mt('Sat').'</th></tr>');
593:
594: my $tk=&Apache::loncommon::maketime(%firstday);
595: my $outp;
596: my $nm;
597:
598: # ---------------------------------------------------------------- Actual table
599: $r->print('<tr>');
600: for (my $i=0;$i<$weekday;$i++) { $r->print(&emptycell); }
601: for (my $i=$weekday;$i<=6;$i++) {
602: ($tk,$nm,$outp)=&showday($tk,0,%allcal);
603: $r->print($outp);
604: }
605: $r->print('</tr>');
606:
607: for (my $k=0;$k<=4;$k++) {
608: $r->print('<tr>');
609: for (my $i=0;$i<=6;$i++) {
610: ($tk,$nm,$outp)=&showday($tk,0,%allcal);
611: if ($month!=$nm) { $outp=&emptycell; }
612: $r->print($outp);
613: }
614: $r->print('</tr>');
615: }
616: # ------------------------------------------------------------------- End table
617: $r->print('</table>');
618: # ----------------------------------------------------------------- Check marks
619: undef(%showedcheck);
620: # --------------------------------------------------------------- Remove button
621: if ($allowed) { $r->print('<input type="button" onClick="removesub()" value="Remove Checked Entries">'.
622: &Apache::loncommon::help_open_topic('Calendar_Remove_Announcement').'</form>'); }
623: $r->print('<p>'.
624: '<a href="/adm/announcements?month='.$pm.'&year='.$py.
625: ($pickdatemode?$pickinfo:'').'">'.&mt('Previous Month').'</a> '.
626: '<a href="/adm/announcements?month='.$fm.'&year='.$fy.
627: ($pickdatemode?$pickinfo:'').'">'.&mt('Next Month').'</a>'.
628: ' <a href="/adm/announcements?month='.$todayhash{'month'}.
629: '&year='.$todayhash{'year'}.
630: ($pickdatemode?$pickinfo:'').'">'.&mt('Current Month').'</a></p>'.
631: ($pickdatemode?'</font>':'').&Apache::loncommon::end_page());
632: $r->print('<a href="/adm/announcements.ics">'.&mt('Download your Calendar as iCalendar File').'</a>');
633: return OK;
634: }
635:
636: 1;
637: __END__
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>