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