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