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