File:  [LON-CAPA] / loncom / interface / lonannounce.pm
Revision 1.44: download - view: text, annotated - select for diffs
Fri Jan 13 15:28:36 2006 UTC (18 years, 5 months ago) by albertel
Branches: MAIN
CVS tags: version_2_1_1, HEAD
- check that we got a res first

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

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