File:  [LON-CAPA] / loncom / interface / lonannounce.pm
Revision 1.46: download - view: text, annotated - select for diffs
Wed Mar 15 21:55:43 2006 UTC (18 years, 2 months ago) by albertel
Branches: MAIN
CVS tags: HEAD
- reeanbling RSS feed

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

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