File:  [LON-CAPA] / loncom / interface / lonmsg.pm
Revision 1.58: download - view: text, annotated - select for diffs
Fri Jul 25 01:18:04 2003 UTC (20 years, 11 months ago) by bowersj2
Branches: MAIN
CVS tags: HEAD
Documentation updates

    1: # The LearningOnline Network with CAPA
    2: # Routines for messaging
    3: #
    4: # $Id: lonmsg.pm,v 1.58 2003/07/25 01:18:04 bowersj2 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: # (Routines to control the menu
   30: #
   31: # (TeX Conversion Module
   32: #
   33: # 05/29/00,05/30 Gerd Kortemeyer)
   34: #
   35: # 10/05 Gerd Kortemeyer)
   36: #
   37: # 10/19,10/20,10/30,
   38: # 02/06/01 Gerd Kortemeyer
   39: # 07/27 Guy Albertelli
   40: # 07/27,07/28,07/30,08/03,08/06,08/08,08/09,08/10,8/13,8/15,
   41: # 10/1,11/5 Gerd Kortemeyer
   42: # YEAR=2002
   43: # 1/1,3/18 Gerd Kortemeyer
   44: #
   45: package Apache::lonmsg;
   46: 
   47: =pod
   48: 
   49: =head1 NAME
   50: 
   51: Apache::lonmsg: supports internal messaging
   52: 
   53: =head1 SYNOPSIS
   54: 
   55: lonmsg provides routines for sending messages, receiving messages, and
   56: a handler to allow users to read, send, and delete messages.
   57: 
   58: =head1 OVERVIEW
   59: 
   60: =head2 Messaging Overview
   61: 
   62: X<messages>LON-CAPA provides an internal messaging system similar to
   63: email, but customized for LON-CAPA's usage. LON-CAPA implements its
   64: own messaging system, rather then building on top of email, because of
   65: the features LON-CAPA messages can offer that conventional e-mail can
   66: not:
   67: 
   68: =over 4
   69: 
   70: =item * B<Critical messages>: A message the recipient B<must>
   71: acknowlegde receipt of before they are allowed to continue using the
   72: system, preventing a user from claiming they never got a message
   73: 
   74: =item * B<Receipts>: LON-CAPA can reliably send reciepts informing the
   75: sender that it has been read; again, useful for preventing students
   76: from claiming they did not see a message. (While conventional e-mail
   77: has some reciept support, it's sporadic, e-mail client-specific, and
   78: generally the receiver can opt to not send one, making it useless in
   79: this case.)
   80: 
   81: =item * B<Context>: LON-CAPA knows about the sender, such as where
   82: they are in a course. When a student mails an instructor asking for
   83: help on the problem, the instructor receives not just the student's
   84: question, but all submissions the student has made up to that point,
   85: the user's rendering of the problem, and the complete view the student
   86: saw of the resource, including discussion up to that point. Finally,
   87: the instructor is reading all of this inside of LON-CAPA, not their
   88: email program, so they have full access to LON-CAPA's grading
   89: interface, or other features they may wish to use in response to the
   90: student's query.
   91: 
   92: =back
   93: 
   94: Users can ask LON-CAPA to forward messages to conventional e-mail
   95: addresses on their B<PREF> screen, but generally, LON-CAPA messages
   96: are much more useful then traditional email can be made to be, even
   97: with HTML support.
   98: 
   99: Right now, this document will cover just how to send a message, since
  100: it is likely you will not need to programmatically read messages,
  101: since lonmsg already implements that functionality.
  102: 
  103: =head1 FUNCTIONS
  104: 
  105: =over 4
  106: 
  107: =cut
  108: 
  109: use strict;
  110: use Apache::lonnet();
  111: use vars qw($msgcount);
  112: use HTML::TokeParser();
  113: use Apache::Constants qw(:common);
  114: use Apache::loncommon();
  115: use Apache::lontexconvert();
  116: use HTML::Entities();
  117: use Mail::Send;
  118: 
  119: # ===================================================================== Package
  120: 
  121: sub packagemsg {
  122:     my ($subject,$message,$citation,$baseurl,$attachmenturl)=@_;
  123:     $message =&HTML::Entities::encode($message);
  124:     $citation=&HTML::Entities::encode($citation);
  125:     $subject =&HTML::Entities::encode($subject);
  126:     #remove machine specification
  127:     $baseurl =~ s|^http://[^/]+/|/|;
  128:     $baseurl =&HTML::Entities::encode($baseurl);
  129:     #remove machine specification
  130:     $attachmenturl =~ s|^http://[^/]+/|/|;
  131:     $attachmenturl =&HTML::Entities::encode($attachmenturl);
  132: 
  133:     my $now=time;
  134:     $msgcount++;
  135:     my $partsubj=$subject;
  136:     $partsubj=&Apache::lonnet::escape($partsubj);
  137:     my $msgid=&Apache::lonnet::escape(
  138:            $now.':'.$partsubj.':'.$ENV{'user.name'}.':'.
  139:            $ENV{'user.domain'}.':'.$msgcount.':'.$$);
  140:     my $result='<sendername>'.$ENV{'user.name'}.'</sendername>'.
  141:            '<senderdomain>'.$ENV{'user.domain'}.'</senderdomain>'.
  142:            '<subject>'.$subject.'</subject>'.
  143: 	   '<time>'.localtime($now).'</time>'.
  144: 	   '<servername>'.$ENV{'SERVER_NAME'}.'</servername>'.
  145:            '<host>'.$ENV{'HTTP_HOST'}.'</host>'.
  146: 	   '<client>'.$ENV{'REMOTE_ADDR'}.'</client>'.
  147: 	   '<browsertype>'.$ENV{'browser.type'}.'</browsertype>'.
  148: 	   '<browseros>'.$ENV{'browser.os'}.'</browseros>'.
  149: 	   '<browserversion>'.$ENV{'browser.version'}.'</browserversion>'.
  150:            '<browsermathml>'.$ENV{'browser.mathml'}.'</browsermathml>'.
  151: 	   '<browserraw>'.$ENV{'HTTP_USER_AGENT'}.'</browserraw>'.
  152: 	   '<courseid>'.$ENV{'request.course.id'}.'</courseid>'.
  153: 	   '<role>'.$ENV{'request.role'}.'</role>'.
  154: 	   '<resource>'.$ENV{'request.filename'}.'</resource>'.
  155:            '<msgid>'.$msgid.'</msgid>'.
  156: 	   '<message>'.$message.'</message>';
  157:     if (defined($citation)) {
  158: 	$result.='<citation>'.$citation.'</citation>';
  159:     }
  160:     if (defined($baseurl)) {
  161: 	$result.= '<baseurl>'.$baseurl.'</baseurl>';
  162:     }
  163:     if (defined($attachmenturl)) {
  164: 	$result.= '<attachmenturl>'.$attachmenturl.'</attachmenturl>';
  165:     }
  166:     return $msgid,$result;
  167: }
  168: 
  169: # ================================================== Unpack message into a hash
  170: 
  171: sub unpackagemsg {
  172:     my ($message,$notoken)=@_;
  173:     my %content=();
  174:     my $parser=HTML::TokeParser->new(\$message);
  175:     my $token;
  176:     while ($token=$parser->get_token) {
  177:        if ($token->[0] eq 'S') {
  178: 	   my $entry=$token->[1];
  179:            my $value=$parser->get_text('/'.$entry);
  180:            $content{$entry}=$value;
  181:        }
  182:     }
  183:     if ($content{'attachmenturl'}) {
  184:        my ($fname,$ft)=($content{'attachmenturl'}=~/\/(\w+)\.(\w+)$/);
  185:        if ($notoken) {
  186: 	   $content{'message'}.='<p>Attachment: <tt>'.$fname.'.'.$ft.'</tt>';
  187:        } else {
  188: 	   $content{'message'}.='<p>Attachment: <a href="'.
  189: 	       &Apache::lonnet::tokenwrapper($content{'attachmenturl'}).
  190: 	       '"><tt>'.$fname.'.'.$ft.'</tt></a>';
  191:        }
  192:     }
  193:     return %content;
  194: }
  195: 
  196: # ======================================================= Get info out of msgid
  197: 
  198: sub unpackmsgid {
  199:     my $msgid=&Apache::lonnet::unescape(shift);
  200:     my ($sendtime,$shortsubj,$fromname,$fromdomain)=split(/\:/,
  201:                           &Apache::lonnet::unescape($msgid));
  202:     my %status=&Apache::lonnet::get('email_status',[$msgid]);
  203:     if ($status{$msgid}=~/^error\:/) { $status{$msgid}=''; }
  204:     unless ($status{$msgid}) { $status{$msgid}='new'; }
  205:     return ($sendtime,$shortsubj,$fromname,$fromdomain,$status{$msgid});
  206: } 
  207: 
  208: 
  209: sub sendemail {
  210:     my ($to,$subject,$body)=@_;
  211:     $body=
  212:     "*** This is an automatic message generated by the LON-CAPA system.\n".
  213:     "*** Please do not reply to this address.\n\n".$body;
  214:     my $msg = new Mail::Send;
  215:     $msg->to($to);
  216:     $msg->subject('[LON-CAPA] '.$subject);
  217:     my $fh = $msg->open('smtp',Server => 'localhost');
  218:     print $fh $body;
  219:     $fh->close;
  220: }
  221: 
  222: # ==================================================== Send notification emails
  223: 
  224: sub sendnotification {
  225:     my ($to,$touname,$toudom,$subj,$crit)=@_;
  226:     my $sender=$ENV{'environment.firstname'}.' '.$ENV{'environment.lastname'};
  227:     my $critical=($crit?' critical':'');
  228:     my $url='http://'.
  229:       $Apache::lonnet::hostname{&Apache::lonnet::homeserver($touname,$toudom)}.
  230:       '/adm/email?username='.$touname.'&domain='.$toudom;
  231:     my $body=(<<ENDMSG);
  232: You received a$critical message from $sender in LON-CAPA. The subject is
  233: 
  234:  $subj
  235: 
  236: Use
  237: 
  238:  $url
  239: 
  240: to access this message.
  241: ENDMSG
  242:     &sendemail($to,'New'.$critical.' message from '.$sender,$body);
  243: }
  244: # ============================================================= Check for email
  245: 
  246: sub newmail {
  247:     if ((time-$ENV{'user.mailcheck.time'})>300) {
  248:         my %what=&Apache::lonnet::get('email_status',['recnewemail']);
  249:         &Apache::lonnet::appenv('user.mailcheck.time'=>time);
  250:         if ($what{'recnewemail'}>0) { return 1; }
  251:     }
  252:     return 0;
  253: }
  254: 
  255: # =============================== Automated message to the author of a resource
  256: 
  257: =pod
  258: 
  259: =item * B<author_res_msg($filename, $message)>: Sends message $message to the owner
  260:     of the resource with the URI $filename.
  261: 
  262: =cut
  263: 
  264: sub author_res_msg {
  265:     my ($filename,$message)=@_;
  266:     unless ($message) { return 'empty'; }
  267:     $filename=&Apache::lonnet::declutter($filename);
  268:     my ($domain,$author,@dummy)=split(/\//,$filename);
  269:     my $homeserver=&Apache::lonnet::homeserver($author,$domain);
  270:     if ($homeserver ne 'no_host') {
  271:        my $id=unpack("%32C*",$message);
  272:        my $msgid;
  273:        ($msgid,$message)=&packagemsg($filename,$message);
  274:        return &Apache::lonnet::reply('put:'.$domain.':'.$author.
  275:          ':nohist_res_msgs:'.
  276:           &Apache::lonnet::escape($filename.'_'.$id).'='.
  277:           &Apache::lonnet::escape($message),$homeserver);
  278:     }
  279:     return 'no_host';
  280: }
  281: 
  282: # ================================================== Critical message to a user
  283: 
  284: sub user_crit_msg_raw {
  285:     my ($user,$domain,$subject,$message,$sendback)=@_;
  286: # Check if allowed missing
  287:     my $status='';
  288:     my $msgid='undefined';
  289:     unless (($message)&&($user)&&($domain)) { $status='empty'; };
  290:     my $homeserver=&Apache::lonnet::homeserver($user,$domain);
  291:     if ($homeserver ne 'no_host') {
  292:        ($msgid,$message)=&packagemsg($subject,$message);
  293:        if ($sendback) { $message.='<sendback>true</sendback>'; }
  294:        $status=&Apache::lonnet::critical(
  295:            'put:'.$domain.':'.$user.':critical:'.
  296:            &Apache::lonnet::escape($msgid).'='.
  297:            &Apache::lonnet::escape($message),$homeserver);
  298:        if ($ENV{'request.course.id'}) {
  299:           &user_normal_msg_raw(
  300:             $ENV{'course.'.$ENV{'request.course.id'}.'.num'},
  301:             $ENV{'course.'.$ENV{'request.course.id'}.'.domain'},
  302:             'Critical ['.$user.':'.$domain.']',
  303: 	    $message);
  304:        }
  305:     } else {
  306:        $status='no_host';
  307:     }
  308: # Notifications
  309:     my %userenv = &Apache::lonnet::get('environment',['critnotification'],
  310:                                        $domain,$user);
  311:     if ($userenv{'critnotification'}) {
  312:       &sendnotification($userenv{'critnotification'},$user,$domain,$subject,1);
  313:     }
  314: # Log this
  315:     &Apache::lonnet::logthis(
  316:       'Sending critical email '.$msgid.
  317:       ', log status: '.
  318:       &Apache::lonnet::log($ENV{'user.domain'},$ENV{'user.name'},
  319:                          $ENV{'user.home'},
  320:       'Sending critical '.$msgid.' to '.$user.' at '.$domain.' with status: '
  321:       .$status));
  322:     return $status;
  323: }
  324: 
  325: # New routine that respects "forward" and calls old routine
  326: 
  327: =pod
  328: 
  329: =item * B<user_crit_msg($user, $domain, $subject, $message, $sendback)>: Sends
  330:     a critical message $message to the $user at $domain. If $sendback is true,
  331:     a reciept will be sent to the current user when $user recieves the message.
  332: 
  333: =cut
  334: 
  335: sub user_crit_msg {
  336:     my ($user,$domain,$subject,$message,$sendback)=@_;
  337:     my $status='';
  338:     my %userenv = &Apache::lonnet::get('environment',['msgforward'],
  339:                                        $domain,$user);
  340:     my $msgforward=$userenv{'msgforward'};
  341:     if ($msgforward) {
  342:        foreach (split(/\,/,$msgforward)) {
  343: 	 my ($forwuser,$forwdomain)=split(/\:/,$_);
  344:          $status.=
  345: 	   &user_crit_msg_raw($forwuser,$forwdomain,$subject,$message,
  346:                 $sendback).' ';
  347:        }
  348:     } else { 
  349: 	$status=&user_crit_msg_raw($user,$domain,$subject,$message,$sendback);
  350:     }
  351:     return $status;
  352: }
  353: 
  354: # =================================================== Critical message received
  355: 
  356: sub user_crit_received {
  357:     my $msgid=shift;
  358:     my %message=&Apache::lonnet::get('critical',[$msgid]);
  359:     my %contents=&unpackagemsg($message{$msgid},1);
  360:     my $status='rec: '.($contents{'sendback'}?
  361:      &user_normal_msg($contents{'sendername'},$contents{'senderdomain'},
  362:                      'Receipt: '.$ENV{'user.name'}.' at '.$ENV{'user.domain'},
  363:                      'User '.$ENV{'user.name'}.' at '.$ENV{'user.domain'}.
  364:                      ' acknowledged receipt of message'."\n".'   "'.
  365:                      $contents{'subject'}.'"'."\n".'dated '.
  366:                      $contents{'time'}.".\n"
  367:                      ):'no msg req');
  368:     $status.=' trans: '.
  369:      &Apache::lonnet::put(
  370:      'nohist_email',{$contents{'msgid'} => $message{$msgid}});
  371:     $status.=' del: '.
  372:      &Apache::lonnet::del('critical',[$contents{'msgid'}]);
  373:     &Apache::lonnet::log($ENV{'user.domain'},$ENV{'user.name'},
  374:                          $ENV{'user.home'},'Received critical message '.
  375:                          $contents{'msgid'}.
  376:                          ', '.$status);
  377:     return $status;
  378: }
  379: 
  380: # ======================================================== Normal communication
  381: 
  382: sub user_normal_msg_raw {
  383:     my ($user,$domain,$subject,$message,$citation,$baseurl,$attachmenturl)=@_;
  384: # Check if allowed missing
  385:     my $status='';
  386:     my $msgid='undefined';
  387:     unless (($message)&&($user)&&($domain)) { $status='empty'; };
  388:     my $homeserver=&Apache::lonnet::homeserver($user,$domain);
  389:     if ($homeserver ne 'no_host') {
  390:        ($msgid,$message)=&packagemsg($subject,$message,$citation,$baseurl,
  391:                                      $attachmenturl);
  392:        $status=&Apache::lonnet::critical(
  393:            'put:'.$domain.':'.$user.':nohist_email:'.
  394:            &Apache::lonnet::escape($msgid).'='.
  395:            &Apache::lonnet::escape($message),$homeserver);
  396:        &Apache::lonnet::put
  397:                          ('email_status',{'recnewemail'=>time},$domain,$user);
  398:     } else {
  399:        $status='no_host';
  400:     }
  401: # Notifications
  402:     my %userenv = &Apache::lonnet::get('environment',['notification'],
  403:                                        $domain,$user);
  404:     if ($userenv{'notification'}) {
  405: 	&sendnotification($userenv{'notification'},$user,$domain,$subject,0);
  406:     }
  407:     &Apache::lonnet::log($ENV{'user.domain'},$ENV{'user.name'},
  408:                          $ENV{'user.home'},
  409:       'Sending '.$msgid.' to '.$user.' at '.$domain.' with status: '.$status);
  410:     return $status;
  411: }
  412: 
  413: # New routine that respects "forward" and calls old routine
  414: 
  415: =pod
  416: 
  417: =item * B<user_normal_msg($user, $domain, $subject, $message,
  418:     $citation, $baseurl, $attachmenturl)>: Sends a message to the
  419:     $user at $domain, with subject $subject and message $message.
  420: 
  421: =cut
  422: 
  423: sub user_normal_msg {
  424:     my ($user,$domain,$subject,$message,$citation,$baseurl,$attachmenturl)=@_;
  425:     my $status='';
  426:     my %userenv = &Apache::lonnet::get('environment',['msgforward'],
  427:                                        $domain,$user);
  428:     my $msgforward=$userenv{'msgforward'};
  429:     if ($msgforward) {
  430:        foreach (split(/\,/,$msgforward)) {
  431: 	 my ($forwuser,$forwdomain)=split(/\:/,$_);
  432:          $status.=
  433: 	  &user_normal_msg_raw($forwuser,$forwdomain,$subject,$message,
  434: 			       $citation,$baseurl,$attachmenturl).' ';
  435:        }
  436:     } else { 
  437: 	$status=&user_normal_msg_raw($user,$domain,$subject,$message,
  438: 				     $citation,$baseurl,$attachmenturl);
  439:     }
  440:     return $status;
  441: }
  442: 
  443: 
  444: # =============================================================== Status Change
  445: 
  446: sub statuschange {
  447:     my ($msgid,$newstatus)=@_;
  448:     my %status=&Apache::lonnet::get('email_status',[$msgid]);
  449:     if ($status{$msgid}=~/^error\:/) { $status{$msgid}=''; }
  450:     unless ($status{$msgid}) { $status{$msgid}='new'; }
  451:     unless (($status{$msgid} eq 'replied') || 
  452:             ($status{$msgid} eq 'forwarded')) {
  453: 	&Apache::lonnet::put('email_status',{$msgid => $newstatus});
  454:     }
  455:     if (($newstatus eq 'deleted') || ($newstatus eq 'new')) {
  456: 	&Apache::lonnet::put('email_status',{$msgid => $newstatus});
  457:     }
  458: }
  459: 
  460: # ======================================================= Display a course list
  461: 
  462: sub discourse {
  463:     my $r=shift;
  464:     my %courselist=&Apache::lonnet::dump(
  465:                    'classlist',
  466: 		   $ENV{'course.'.$ENV{'request.course.id'}.'.domain'},
  467: 		   $ENV{'course.'.$ENV{'request.course.id'}.'.num'});
  468:     my $now=time;
  469:     $r->print(<<ENDDISHEADER);
  470: <input type=hidden name=sendmode value=group>
  471: <script>
  472:     function checkall() {
  473: 	for (i=0; i<document.forms.compemail.elements.length; i++) {
  474:             if 
  475:           (document.forms.compemail.elements[i].name.indexOf('send_to_')==0) {
  476: 	      document.forms.compemail.elements[i].checked=true;
  477:             }
  478:         }
  479:     }
  480: 
  481:     function checksec() {
  482: 	for (i=0; i<document.forms.compemail.elements.length; i++) {
  483:             if 
  484:           (document.forms.compemail.elements[i].name.indexOf
  485:            ('send_to_&&&'+document.forms.compemail.chksec.value)==0) {
  486: 	      document.forms.compemail.elements[i].checked=true;
  487:             }
  488:         }
  489:     }
  490: 
  491:     function uncheckall() {
  492: 	for (i=0; i<document.forms.compemail.elements.length; i++) {
  493:             if 
  494:           (document.forms.compemail.elements[i].name.indexOf('send_to_')==0) {
  495: 	      document.forms.compemail.elements[i].checked=false;
  496:             }
  497:         }
  498:     }
  499: </script>
  500: <input type=button onClick="checkall()" value="Check for All">&nbsp;
  501: <input type=button onClick="checksec()" value="Check for Section/Group">
  502: <input type=text size=5 name=chksec>&nbsp;
  503: <input type=button onClick="uncheckall()" value="Check for None">
  504: <p>
  505: ENDDISHEADER
  506:     foreach (sort keys %courselist) {
  507:         my ($end,$start)=split(/\:/,$courselist{$_});
  508:         my $active=1;
  509:         if (($end) && ($now>$end)) { $active=0; }
  510:         if ($active) {
  511:            my ($sname,$sdom)=split(/\:/,$_);
  512:            my %reply=&Apache::lonnet::get('environment',
  513:               ['firstname','middlename','lastname','generation'],
  514:               $sdom,$sname);
  515:            my $section=&Apache::lonnet::usection
  516: 	       ($sdom,$sname,$ENV{'request.course.id'});
  517:            $r->print(
  518:         '<br><input type=checkbox name="send_to_&&&'.$section.'&&&_'.$_.'"> '.
  519: 		      $reply{'firstname'}.' '. 
  520:                       $reply{'middlename'}.' '.
  521:                       $reply{'lastname'}.' '.
  522:                       $reply{'generation'}.
  523:                       ' ('.$_.') '.$section);
  524:         } 
  525:     }
  526: }
  527: 
  528: # ==================================================== Display Critical Message
  529: 
  530: sub discrit {
  531:     my $r=shift;
  532:     my $header = '<h1><font color=red>Critical Messages</font></h1>'.
  533:         '<form action=/adm/email method=post>'.
  534:         '<input type=hidden name=confirm value=true>';
  535:     my %what=&Apache::lonnet::dump('critical');
  536:     my $result = '';
  537:     foreach (sort keys %what) {
  538:         my %content=&unpackagemsg($what{$_});
  539:         next if ($content{'senderdomain'} eq '');
  540:         $content{'message'}=~s/\n/\<br\>/g;
  541:         $result.='<hr>From: <b>'.
  542: &Apache::loncommon::aboutmewrapper(
  543:  &Apache::loncommon::plainname($content{'sendername'},$content{'senderdomain'}),$content{'sendername'},$content{'senderdomain'}).'</b> ('.
  544: $content{'sendername'}.'@'.
  545:             $content{'senderdomain'}.') '.$content{'time'}.
  546:             '<br>Subject: '.$content{'subject'}.
  547:             '<br><blockquote>'.
  548:               &Apache::lontexconvert::msgtexconverted($content{'message'}).
  549:             '</blockquote>'.
  550:             '<input type=submit name="rec_'.$_.'" value="Confirm Receipt">'.
  551:             '<input type=submit name="reprec_'.$_.'" '.
  552:                   'value="Confirm Receipt and Reply">';
  553:     }
  554:     # Check to see if there were any messages.
  555:     if ($result eq '') {
  556:         $result = "<h2>You have no critical messages.</h2>";
  557:     } else {
  558:         $r->print($header);
  559:     }
  560:     $r->print($result);
  561:     $r->print('<input type=hidden name="displayedcrit" value="true"></form>');
  562: }
  563: 
  564: # =============================================================== Compose reply
  565: 
  566: sub comprep {
  567:     my ($r,$msgid)=@_;
  568:       my %message=&Apache::lonnet::get('nohist_email',[$msgid]);
  569:       my %content=&unpackagemsg($message{$msgid},1);
  570:       my $quotemsg='> '.$content{'message'};
  571:       $quotemsg=~s/\r/\n/g;
  572:       $quotemsg=~s/\f/\n/g;
  573:       $quotemsg=~s/\n+/\n\> /g;
  574:       my $torepl=&Apache::loncommon::aboutmewrapper(
  575:  &Apache::loncommon::plainname($content{'sendername'},$content{'senderdomain'}),$content{'sendername'},$content{'senderdomain'}).' ('.
  576: $content{'sendername'}.'@'.
  577:             $content{'senderdomain'}.')';
  578:       my $subject='Re: '.$content{'subject'};
  579:       my $dispcrit='';
  580:       if (&Apache::lonnet::allowed('srm',$ENV{'request.course.id'})) {
  581: 	 my $crithelp = Apache::loncommon::help_open_topic("Course_Critical_Message");
  582:          $dispcrit=
  583:  '<input type=checkbox name=critmsg> Send as critical message ' . $crithelp . 
  584:  '<br>'.
  585:  '<input type=checkbox name=sendbck> Send as critical message ' .
  586:  ' and return receipt' . $crithelp . '<p>';
  587:       }
  588:       $r->print(<<"ENDREPLY");
  589: <form action="/adm/email" method=post>
  590: <input type=hidden name=sendreply value="$msgid">
  591: To: $torepl<br />
  592: Subject: <input type=text size=50 name=subject value="$subject"><p>
  593: <textarea name=message cols=84 rows=10 wrap=hard>
  594: $quotemsg
  595: </textarea><p>
  596: $dispcrit
  597: <input type=submit value="Send Reply">
  598: </form>
  599: ENDREPLY
  600: }
  601: 
  602: # ======================================================== Display all messages
  603: 
  604: sub disall {
  605:     my $r=shift;
  606:      $r->print(<<ENDDISHEADER);
  607: <script>
  608:     function checkall() {
  609: 	for (i=0; i<document.forms.disall.elements.length; i++) {
  610:             if 
  611:           (document.forms.disall.elements[i].name.indexOf('delmark_')==0) {
  612: 	      document.forms.disall.elements[i].checked=true;
  613:             }
  614:         }
  615:     }
  616: 
  617:     function uncheckall() {
  618: 	for (i=0; i<document.forms.disall.elements.length; i++) {
  619:             if 
  620:           (document.forms.disall.elements[i].name.indexOf('delmark_')==0) {
  621: 	      document.forms.disall.elements[i].checked=false;
  622:             }
  623:         }
  624:     }
  625: </script>
  626: ENDDISHEADER
  627:    $r->print(
  628:  '<h1>Display All Messages</h1><form method=post name=disall '.
  629:  'action="/adm/email">'.
  630:      '<table border=2><tr><th colspan=2>&nbsp</th><th>Date</th>'.
  631:      '<th>Username</th><th>Domain</th><th>Subject</th><th>Status</th></tr>');
  632:     foreach (sort split(/\&/,&Apache::lonnet::reply('keys:'.
  633: 					$ENV{'user.domain'}.':'.
  634:                                         $ENV{'user.name'}.':nohist_email',
  635:                                         $ENV{'user.home'}))) {
  636:         my ($sendtime,$shortsubj,$fromname,$fromdomain,$status)=
  637: 	    &Apache::lonmsg::unpackmsgid($_);
  638: 	if (($status ne 'deleted') && defined($sendtime) && $sendtime!~/error/) {
  639: 	    if ($status eq 'new') {
  640: 		$r->print('<tr bgcolor="#FFBB77">');
  641: 	    } elsif ($status eq 'read') {
  642: 		$r->print('<tr bgcolor="#BBBB77">');
  643: 	    } elsif ($status eq 'replied') {
  644: 		$r->print('<tr bgcolor="#AAAA88">');
  645: 	    } else {
  646: 		$r->print('<tr bgcolor="#99BBBB">');
  647: 	    }
  648: 	    $r->print('<td><a href="/adm/email?display='.$_.
  649: 		      '">Open</a></td><td><a href="/adm/email?markdel='.$_.
  650: 		      '">Delete</a><input type=checkbox name="delmark_'.$_.'"></td>'.
  651: 		      '<td>'.localtime($sendtime).'</td><td>'.
  652: 		      $fromname.'</td><td>'.$fromdomain.'</td><td>'.
  653: 		      &Apache::lonnet::unescape($shortsubj).'</td><td>'.
  654:                       $status.'</td></tr>');
  655: 	}
  656:     }
  657:     $r->print('</table><p>'.
  658:               '<a href="javascript:checkall()">Check All</a>&nbsp;'.
  659:               '<a href="javascript:uncheckall()">Uncheck All</a><p>'.
  660:               '<input type=submit name="markeddel" value="Delete Checked">'.
  661:               '</form></body></html>');
  662: }
  663: 
  664: # ============================================================== Compose output
  665: 
  666: sub compout {
  667:     my ($r,$forwarding,$broadcast)=@_;
  668:       my $dispcrit='';
  669:     my $dissub='';
  670:     my $dismsg='';
  671:     my $func='Send New';
  672:       if (&Apache::lonnet::allowed('srm',$ENV{'request.course.id'})) {
  673: 	 my $crithelp = Apache::loncommon::help_open_topic("Course_Critical_Message");
  674:          $dispcrit=
  675:  '<input type=checkbox name=critmsg> Send as critical message ' . $crithelp . 
  676:  '<br>'.
  677:  '<input type=checkbox name=sendbck> Send as critical message ' .
  678:  ' and return receipt' . $crithelp . '<p>';
  679:       }
  680:     if ($forwarding) {
  681:        $dispcrit.='<input type=hidden name=forwid value="'.
  682: 	   $forwarding.'">';
  683:        $func='Forward';
  684:       my %message=&Apache::lonnet::get('nohist_email',[$forwarding]);
  685:       my %content=&unpackagemsg($message{$forwarding});
  686: 
  687:        $dissub='Forwarding: '.$content{'subject'};
  688:        $dismsg='Forwarded message from '.
  689: 	   $content{'sendername'}.' at '.$content{'senderdomain'};
  690:     }
  691:     my $defdom=$ENV{'user.domain'};
  692:     if ($ENV{'form.recdom'}) { $defdom=$ENV{'form.recdom'}; }
  693:       $r->print(
  694:                 '<form action="/adm/email"  name="compemail" method="post"'.
  695:                 ' enctype="multipart/form-data">'."\n".
  696:                 '<input type="hidden" name="sendmail" value="on">'."\n".
  697:                 '<table>');
  698:     unless (($broadcast eq 'group') || ($broadcast eq 'upload')) {
  699:         my $domform = &Apache::loncommon::select_dom_form($defdom,'recdomain');
  700:         my $selectlink=&Apache::loncommon::selectstudent_link
  701: 	    ('compemail','recuname','recdomain');
  702:        $r->print(<<"ENDREC");
  703: <table>
  704: <tr><td>Username:</td><td><input type=text size=12 name=recuname value="$ENV{'form.recname'}"></td><td rowspan="2">$selectlink</td></tr>
  705: <tr><td>Domain:</td>
  706: <td>$domform</td></tr>
  707: ENDREC
  708:     }
  709:     my $latexHelp = Apache::loncommon::helpLatexCheatsheet();
  710:     if ($broadcast ne 'upload') {
  711:        $r->print(<<"ENDCOMP");
  712: <tr><td>Additional Recipients<br><tt>username\@domain,username\@domain, ...
  713: </tt></td><td>
  714: <input type=text size=50 name=additionalrec></td></tr>
  715: <tr><td>Subject:</td><td><input type=text size=50 name=subject value="$dissub">
  716: </td></tr></table>
  717: $latexHelp
  718: <textarea name=message cols=80 rows=10 wrap=hard>$dismsg
  719: </textarea><p>
  720: $dispcrit
  721: <input type=submit value="$func Mail">
  722: ENDCOMP
  723:     } else { # $broadcast is 'upload'
  724: 	$r->print(<<ENDUPLOAD);
  725: <input type=hidden name=sendmode value=upload>
  726: <h3>Generate messages from a file</h3>
  727: <p>
  728: Subject: <input type=text size=50 name=subject>
  729: </p>
  730: <p>General message text<br />
  731: <textarea name=message cols=60 rows=10 wrap=hard>$dismsg
  732: </textarea></p>
  733: <p>
  734: The file format for the uploaded portion of the message is:
  735: <pre>
  736: username1\@domain1: text
  737: username2\@domain2: text
  738: username3\@domain1: text
  739: </pre>
  740: </p>
  741: <p>
  742: The messages will be assembled from all lines with the respective 
  743: <tt>username\@domain</tt>, and appended to the general message text.</p>
  744: <p>
  745: <input type=file name=upfile size=20><p>
  746: $dispcrit
  747: <input type=submit value="Upload and send">
  748: ENDUPLOAD
  749:     }
  750:     if ($broadcast eq 'group') {
  751:        &discourse;
  752:     }
  753:     $r->print('</form>');
  754: }
  755: 
  756: # ---------------------------------------------------- Display all face to face
  757: 
  758: sub disfacetoface {
  759:     my ($r,$user,$domain)=@_;
  760:     unless ($ENV{'request.course.id'}) { return; }
  761:     unless (&Apache::lonnet::allowed('srm',$ENV{'request.course.id'})) {
  762: 	return;
  763:     }
  764:     my %records=&Apache::lonnet::dump('nohist_email',
  765: 			 $ENV{'course.'.$ENV{'request.course.id'}.'.domain'},
  766: 			 $ENV{'course.'.$ENV{'request.course.id'}.'.num'},
  767:                          '%255b'.$user.'%253a'.$domain.'%255d');
  768:     my $result='';
  769:     foreach (sort keys %records) {
  770:         my %content=&unpackagemsg($records{$_});
  771:         next if ($content{'senderdomain'} eq '');
  772:         $content{'message'}=~s/\n/\<br\>/g;
  773:         if ($content{'subject'}=~/^Record/) {
  774: 	    $result.='<h3>Record</h3>';
  775:         } else {
  776:             $result.='<h3>Sent Message</h3>';
  777:             %content=&unpackagemsg($content{'message'});
  778:             $content{'message'}=
  779:                 '<b>Subject: '.$content{'subject'}.'</b><br />'.
  780: 		$content{'message'};
  781:         }
  782:         $result.='By: <b>'.
  783: &Apache::loncommon::aboutmewrapper(
  784:  &Apache::loncommon::plainname($content{'sendername'},$content{'senderdomain'}),$content{'sendername'},$content{'senderdomain'}).'</b> ('.
  785: $content{'sendername'}.'@'.
  786:             $content{'senderdomain'}.') '.$content{'time'}.
  787:             '<br><blockquote>'.
  788:               &Apache::lontexconvert::msgtexconverted($content{'message'}).
  789: 	      '</blockquote>';
  790:      }
  791:     # Check to see if there were any messages.
  792:     if ($result eq '') {
  793:         $r->print("<p><b>No notes, face-to-face discussion records, or critical messages in this course.</b></p>");
  794:     } else {
  795:        $r->print($result);
  796:     }
  797: }
  798: 
  799: # ---------------------------------------------------------------- Face to face
  800: 
  801: sub facetoface {
  802:     my ($r,$stage)=@_;
  803:     unless (&Apache::lonnet::allowed('srm',$ENV{'request.course.id'})) {
  804: 	return;
  805:     }
  806: # from query string
  807:     if ($ENV{'form.recname'}) { $ENV{'form.recuname'}=$ENV{'form.recname'}; }
  808:     if ($ENV{'form.recdom'}) { $ENV{'form.recdomain'}=$ENV{'form.recdom'}; }
  809: 
  810:     my $defdom=$ENV{'user.domain'};
  811: # already filled in
  812:     if ($ENV{'form.recdomain'}) { $defdom=$ENV{'form.recdomain'}; }
  813: # generate output
  814:     my $domform = &Apache::loncommon::select_dom_form($defdom,'recdomain');
  815:     my $stdbrws = &Apache::loncommon::selectstudent_link
  816: 	('stdselect','recuname','recdomain');
  817:     $r->print(<<"ENDTREC");
  818: <h3>User Notes, Records of Face-To-Face Discussions, and Critical Messages in Course</h3>
  819: <form method="post" action="/adm/email" name="stdselect">
  820: <input type="hidden" name="recordftf" value="retrieve" />
  821: <table>
  822: <tr><td>Username:</td><td><input type=text size=12 name=recuname value="$ENV{'form.recuname'}"></td>
  823: <td rowspan="2">
  824: $stdbrws
  825: <input type="submit" value="Retrieve discussion and message records"></td>
  826: </tr>
  827: <tr><td>Domain:</td>
  828: <td>$domform</td></tr>
  829: </table>
  830: </form>
  831: ENDTREC
  832:     if (($stage ne 'query') &&
  833:         ($ENV{'form.recdomain'}) && ($ENV{'form.recuname'})) {
  834:         chomp($ENV{'form.newrecord'});
  835:         if ($ENV{'form.newrecord'}) {
  836:            &user_normal_msg_raw(
  837:             $ENV{'course.'.$ENV{'request.course.id'}.'.num'},
  838:             $ENV{'course.'.$ENV{'request.course.id'}.'.domain'},
  839:             'Record ['.$ENV{'form.recuname'}.':'.$ENV{'form.recdomain'}.']',
  840: 	    $ENV{'form.newrecord'});
  841:         }
  842:         $r->print('<h3>'.&Apache::loncommon::plainname($ENV{'form.recuname'},
  843: 				     $ENV{'form.recdomain'}).'</h3>');
  844:         &disfacetoface($r,$ENV{'form.recuname'},$ENV{'form.recdomain'});
  845: 	$r->print(<<ENDRHEAD);
  846: <form method="post" action="/adm/email">
  847: <input name="recdomain" value="$ENV{'form.recdomain'}" type="hidden" />
  848: <input name="recuname" value="$ENV{'form.recuname'}" type="hidden" />
  849: ENDRHEAD
  850:         $r->print(<<ENDBFORM);
  851: <hr />New Record (record is visible to course faculty and staff)<br />
  852: <textarea name="newrecord" cols="80" rows="10" wrap="hard"></textarea>
  853: <br />
  854: <input type="hidden" name="recordftf" value="post" />
  855: <input type="submit" value="Post this record" />
  856: </form>
  857: ENDBFORM
  858:     }
  859: }
  860: 
  861: # ===================================================================== Handler
  862: 
  863: sub handler {
  864:     my $r=shift;
  865: 
  866: # ----------------------------------------------------------- Set document type
  867: 
  868:   $r->content_type('text/html');
  869:   $r->send_http_header;
  870: 
  871:   return OK if $r->header_only;
  872: 
  873: # --------------------------- Get query string for limited number of parameters
  874:     &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},
  875:         ['display','replyto','forward','markread','markdel','markunread',
  876:          'sendreply','compose','sendmail','critical','recname','recdom',
  877:          'recordftf']);
  878: 
  879: # ------------------------------------------------------ They checked for email
  880:   &Apache::lonnet::put('email_status',{'recnewemail'=>0});
  881: # --------------------------------------------------------------- Render Output
  882:   if (!$ENV{'form.display'}) {
  883:       $r->print('<html><head><title>EMail and Messaging</title>'.
  884: 		&Apache::loncommon::studentbrowser_javascript().'</head>'.
  885: 		&Apache::loncommon::bodytag('EMail and Messages'));
  886:   }
  887:   if ($ENV{'form.display'}) {
  888:       my $msgid=$ENV{'form.display'};
  889:       &statuschange($msgid,'read');
  890:       my %message=&Apache::lonnet::get('nohist_email',[$msgid]);
  891:       my %content=&unpackagemsg($message{$msgid});
  892:       $r->print('<html><head><title>EMail and Messaging</title>');
  893:       if (defined($content{'baseurl'})) {
  894: 	  $r->print("<base href=\"http://$ENV{'SERVER_NAME'}/$content{'baseurl'}\" />");
  895:       }
  896:       $r->print(&Apache::loncommon::studentbrowser_javascript().
  897: 		'</head>'.
  898: 		&Apache::loncommon::bodytag('EMail and Messages'));
  899:       $r->print('<b>Subject:</b> '.$content{'subject'}.
  900:              '<br><b>From:</b> '.
  901: &Apache::loncommon::aboutmewrapper(
  902: &Apache::loncommon::plainname($content{'sendername'},$content{'senderdomain'}),
  903: $content{'sendername'},$content{'senderdomain'}).' ('.
  904:                                  $content{'sendername'}.' at '.
  905:                                  $content{'senderdomain'}.') '.
  906:              '<br><b>Time:</b> '.$content{'time'}.'<p>'.
  907:              '<table border=2><tr bgcolor="#FFFFAA"><td>Functions:</td>'.
  908:            '<td><a href="/adm/email?replyto='.&Apache::lonnet::escape($msgid).
  909:              '"><b>Reply</b></a></td>'.
  910:            '<td><a href="/adm/email?forward='.&Apache::lonnet::escape($msgid).
  911:              '"><b>Forward</b></a></td>'.
  912:         '<td><a href="/adm/email?markunread='.&Apache::lonnet::escape($msgid).
  913:              '"><b>Mark Unread</b></a></td>'.
  914:         '<td><a href="/adm/email?markdel='.&Apache::lonnet::escape($msgid).
  915:              '"><b>Delete</b></a></td>'.
  916:         '<td><a href="/adm/email"><b>Display all Messages</b></a></td>'.
  917:              '</tr></table><p><pre>'.
  918:              &Apache::lontexconvert::msgtexconverted($content{'message'}).
  919:              '</pre><hr>'.$content{'citation'});
  920:   } elsif ($ENV{'form.replyto'}) {
  921:       &comprep($r,$ENV{'form.replyto'});
  922:   } elsif ($ENV{'form.sendreply'}) {
  923:       my $msgid=$ENV{'form.sendreply'};
  924:       my %message=&Apache::lonnet::get('nohist_email',[$msgid]);
  925:       my %content=&unpackagemsg($message{$msgid},1);
  926:       &statuschange($msgid,'replied');
  927:       if ((($ENV{'form.critmsg'}) || ($ENV{'form.sendbck'})) && 
  928:           (&Apache::lonnet::allowed('srm',$ENV{'request.course.id'}))) {
  929:          $r->print('Sending critical: '.
  930:                 &user_crit_msg($content{'sendername'},
  931:                                  $content{'senderdomain'},
  932:                                  &Apache::lonfeedback::clear_out_html($ENV{'form.subject'}),
  933:                                  &Apache::lonfeedback::clear_out_html($ENV{'form.message'}),
  934:                                  $ENV{'form.sendbck'}));
  935:       } else {
  936:          $r->print('Sending: '.&user_normal_msg($content{'sendername'},
  937:                                  $content{'senderdomain'},
  938:                                  &Apache::lonfeedback::clear_out_html($ENV{'form.subject'}),
  939:                                  &Apache::lonfeedback::clear_out_html($ENV{'form.message'})));
  940:       }
  941:       if ($ENV{'form.displayedcrit'}) {
  942:           &discrit($r);
  943:       } else {
  944: 	  &disall($r);
  945:       }
  946:   } elsif ($ENV{'form.confirm'}) {
  947:       foreach (keys %ENV) {
  948:           if ($_=~/^form\.rec\_(.*)$/) {
  949: 	      $r->print('<b>Confirming Receipt:</b> '.
  950:                         &user_crit_received($1).'<br>');
  951:           }
  952:           if ($_=~/^form\.reprec\_(.*)$/) {
  953:               my $msgid=$1;
  954: 	      $r->print('<b>Confirming Receipt:</b> '.
  955:                         &user_crit_received($msgid).'<br>');
  956:               &comprep($r,$msgid);
  957:           }
  958:       }
  959:       &discrit($r);
  960:   } elsif ($ENV{'form.critical'}) {
  961:       &discrit($r);
  962:   } elsif ($ENV{'form.forward'}) {
  963:       &compout($r,$ENV{'form.forward'});
  964:   } elsif ($ENV{'form.markread'}) {
  965:   } elsif ($ENV{'form.markdel'}) {
  966:       &statuschange($ENV{'form.markdel'},'deleted');
  967:       &disall($r);
  968:   } elsif ($ENV{'form.markeddel'}) {
  969:       my $total=0;
  970:       foreach (keys %ENV) {
  971:           if ($_=~/^form\.delmark_(.*)$/) {
  972: 	      &statuschange(&Apache::lonnet::unescape($1),'deleted');
  973:               $total++;
  974:           }
  975:       }
  976:       $r->print('Deleted '.$total.' message(s)<p>');
  977:       &disall($r);
  978:   } elsif ($ENV{'form.markunread'}) {
  979:       &statuschange($ENV{'form.markunread'},'new');
  980:       &disall($r);
  981:   } elsif ($ENV{'form.compose'}) {
  982:       &compout($r,'',$ENV{'form.compose'});
  983:   } elsif ($ENV{'form.recordftf'}) {
  984:       &facetoface($r,$ENV{'form.recordftf'});
  985:   } elsif ($ENV{'form.sendmail'}) {
  986:       my %content=();
  987:       undef %content;
  988:       if ($ENV{'form.forwid'}) {
  989:         my $msgid=$ENV{'form.forwid'};
  990:         my %message=&Apache::lonnet::get('nohist_email',[$msgid]);
  991:         %content=&unpackagemsg($message{$msgid},1);
  992:         &statuschange($msgid,'forwarded');
  993:         $ENV{'form.message'}.="\n\n-- Forwarded message --\n\n".
  994: 	                       $content{'message'};
  995:       }
  996:       my %toaddr=();
  997:       undef %toaddr;
  998:       if ($ENV{'form.sendmode'} eq 'group') {
  999:           foreach (keys %ENV) {
 1000: 	      if ($_=~/^form\.send\_to\_\&\&\&[^\&]*\&\&\&\_(.+)$/) {
 1001: 		  $toaddr{$1}='';
 1002:               }
 1003:           }
 1004:       } elsif ($ENV{'form.sendmode'} eq 'upload') {
 1005:           foreach (split(/[\n\r\f]+/,$ENV{'form.upfile'})) {
 1006:               my ($rec,$txt)=split(/\s*\:\s*/,$_);
 1007:               if ($txt) {
 1008: 		  $rec=~s/\@/\:/;
 1009:                   $toaddr{$rec}.=$txt."\n";
 1010:               }
 1011:           }
 1012:       } else {
 1013: 	  $toaddr{$ENV{'form.recuname'}.':'.$ENV{'form.recdomain'}}='';
 1014:       }
 1015:       if ($ENV{'form.additionalrec'}) {
 1016: 	  foreach (split(/\,/,$ENV{'form.additionalrec'})) {
 1017:               my ($auname,$audom)=split(/\@/,$_);
 1018:               $toaddr{$auname.':'.$audom}='';
 1019:           }
 1020:       }
 1021:     foreach (keys %toaddr) {
 1022:       my ($recuname,$recdomain)=split(/\:/,$_);
 1023:       my $msgtxt=&Apache::lonfeedback::clear_out_html($ENV{'form.message'});
 1024:       if ($toaddr{$_}) { $msgtxt.='<hr>'.$toaddr{$_}; }    
 1025:       if ((($ENV{'form.critmsg'}) || ($ENV{'form.sendbck'})) && 
 1026:           (&Apache::lonnet::allowed('srm',$ENV{'request.course.id'}))) {
 1027:          $r->print('Sending critical: '.
 1028:                 &user_crit_msg($recuname,$recdomain,
 1029:                &Apache::lonfeedback::clear_out_html($ENV{'form.subject'}),
 1030:                                  $msgtxt,
 1031:                                  $ENV{'form.sendbck'}));
 1032:       } else {
 1033:          $r->print('Sending: '.&user_normal_msg($recuname,$recdomain,
 1034:               &Apache::lonfeedback::clear_out_html($ENV{'form.subject'}),
 1035:                                  $msgtxt,
 1036:                                  $content{'citation'}));
 1037:       }
 1038:       $r->print('<br>');
 1039:     }
 1040:       if ($ENV{'form.displayedcrit'}) {
 1041:           &discrit($r);
 1042:       } else {
 1043: 	  &disall($r);
 1044:       }
 1045:   } else {
 1046:       &disall($r);
 1047:   }
 1048:   $r->print('</body></html>');
 1049:   return OK;
 1050: 
 1051: }
 1052: # ================================================= Main program, reset counter
 1053: 
 1054: BEGIN {
 1055:     $msgcount=0;
 1056: }
 1057: 
 1058: =pod
 1059: 
 1060: =back
 1061: 
 1062: =end
 1063: 
 1064: 1;
 1065: __END__
 1066: 
 1067: 
 1068: 
 1069: 
 1070: 
 1071: 
 1072: 

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