File:  [LON-CAPA] / loncom / interface / loncommunicate.pm
Revision 1.17: download - view: text, annotated - select for diffs
Sat Oct 4 20:49:40 2003 UTC (20 years, 8 months ago) by www
Branches: MAIN
CVS tags: version_1_1_X, version_1_1_3, version_1_1_2, version_1_1_1, version_1_1_0, version_1_0_99_3, version_1_0_99_2, version_1_0_99_1, version_1_0_99, HEAD
Internationalization, and in particular, lonlocal:locallocaltime and
Japanese dates.

    1: # The LearningOnline Network
    2: # Communicate
    3: #
    4: # $Id: loncommunicate.pm,v 1.17 2003/10/04 20:49:40 www 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: # (Internal Server Error Handler
   29: #
   30: # (Login Screen
   31: # 5/21/99,5/22,5/25,5/26,5/31,6/2,6/10,7/12,7/14,
   32: # 1/14/00,5/29,5/30,6/1,6/29,7/1,11/9 Gerd Kortemeyer)
   33: #
   34: # 3/1/1 Gerd Kortemeyer)
   35: #
   36: # 3/1,2/6,7/27,8/3,8/15,
   37: # 11/5/01 Gerd Kortemeyer
   38: #
   39: package Apache::loncommunicate;
   40: 
   41: use strict;
   42: use Apache::Constants qw(:common);
   43: use Apache::lonmsg();
   44: use Apache::loncommon;
   45: use Apache::lonlocal;
   46: 
   47: sub handler {
   48:     my $r = shift;
   49:     &Apache::loncommon::content_type($r,'text/html');
   50:     $r->send_http_header;
   51:     return OK if $r->header_only;
   52: #
   53: # Start document
   54: #
   55:     $r->print(<<END);
   56: <html>
   57: <head>
   58: <title>The LearningOnline Network with CAPA</title>
   59: </head>
   60: END
   61:    my %lt=&Apache::lonlocal::texthash(
   62: 'vam' => 'View All Messages',
   63: 'vcm' => 'View Critical Messages',
   64: 'smu' => 'Send Message to User(s)',
   65: 'bmc' => 'Broadcast Message to Course',
   66: 'dmu' => 'Distribute Messages from Uploaded File to Course',
   67: 'unr' => 
   68:      'User Notes, Records of Face-to-Face Discussions, and Critical Messages',
   69: 'nm' => 'New Messages',
   70: 'su' => 'Subject',
   71: 'da' => 'Date',
   72: 'us' => 'Username',
   73: 'op' => 'Open',
   74: 'do' => 'Domain'
   75: );
   76: 
   77:    $r->print(&Apache::loncommon::bodytag("Communication and Messages"));
   78:    $r->print(<<END);
   79: <table cellspacing="10" cellpadding="2">
   80: <tr><td bgcolor="#FFFFAA">
   81:   <b><a href="/adm/email/">$lt{'vam'}</a></b>
   82: </td></tr>
   83: <tr><td bgcolor="#FFFFAA">
   84:   <b><a href="/adm/email?critical=display">$lt{'vcm'}</a></b>
   85: </td></tr>
   86: <tr><td bgcolor="#FFFFAA">
   87:   <b><a href="/adm/email?compose=individual">$lt{'smu'}</a></b>
   88: </td></tr>
   89: END
   90:     if (($ENV{'request.course.id'}) && 
   91:         (&Apache::lonnet::allowed('srm',$ENV{'request.course.id'}))) {
   92:         $r->print(<<END);
   93: <tr><td bgcolor="#FFFFAA">
   94:   <b><a href="/adm/email?compose=group">$lt{'bmc'}</a></b>
   95: </td></tr>
   96: <tr><td bgcolor="#FFFFAA">
   97:   <b><a href="/adm/email?compose=upload">$lt{'dmu'}</a></b>
   98: </td></tr>
   99: <tr><td bgcolor="#FFFFAA">
  100:   <b><a href="/adm/email?recordftf=query">$lt{'unr'}</a></b>
  101: </td></tr>
  102: 
  103: END
  104:     }
  105:     $r->print('</table>');
  106:     my @msgids = sort split(/\&/,&Apache::lonnet::reply
  107:                             ('keys:'.$ENV{'user.domain'}.':'.
  108:                              $ENV{'user.name'}.':nohist_email',
  109:                              $ENV{'user.home'}));
  110:     my @newmsgs;
  111:     foreach (@msgids) {
  112:         my ($sendtime,$shortsubj,$fromname,$fromdom,$status)=
  113: 	    &Apache::lonmsg::unpackmsgid($_);
  114:        if (defined($sendtime) && $sendtime!~/error/) {
  115:         $sendtime = &Apache::lonlocal::locallocaltime($sendtime);
  116:         if ($status eq 'new') {
  117:             push @newmsgs, { 
  118:                 msgid    => $_,
  119:                 sendtime => $sendtime,
  120:                 shortsub => &Apache::lonnet::unescape($shortsubj),
  121:                 from     => $fromname,
  122:                 fromdom  => $fromdom 
  123:                 }
  124:         }
  125:        }
  126:     }
  127:     if ($#newmsgs >= 0) {
  128:         $r->print(<<TABLEHEAD);
  129: <h3>$lt{'nm'}</h3>
  130: <table border=2><tr><th>&nbsp</th>
  131: <th>$lt{'da'}</th><th>$lt{'us'}</th><th>$lt{'do'}</th><th>$lt{'su'}</th></tr>
  132: TABLEHEAD
  133:         foreach my $msg (@newmsgs) {
  134:             $r->print(<<"ENDLINK");
  135: <tr bgcolor="#FFBB77">
  136: <td><a href="/adm/email?display=$msg->{'msgid'}">$lt{'op'}</a></td>
  137: ENDLINK
  138:             foreach ('sendtime','from','fromdom','shortsub') {
  139:                 $r->print("<td>$msg->{$_}</td>");
  140:             }
  141:             $r->print("</td></tr>");
  142:         }
  143:         $r->print('</table></body></html>');
  144:     } else {
  145:         $r->print("<h3>".&mt('You have no unread messages')."</h3>");
  146:     }
  147:     return OK;
  148: }
  149: 
  150: 1;
  151: __END__

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