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