Annotation of loncom/interface/lonannounce.pm, revision 1.34

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

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>