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