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