Annotation of loncom/interface/loncommunicate.pm, revision 1.18

1.1       www         1: # The LearningOnline Network
                      2: # Communicate
                      3: #
1.18    ! www         4: # $Id: loncommunicate.pm,v 1.17 2003/10/04 20:49:40 www Exp $
1.7       albertel    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: #
1.1       www        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: #
1.6       www        36: # 3/1,2/6,7/27,8/3,8/15,
                     37: # 11/5/01 Gerd Kortemeyer
1.1       www        38: #
                     39: package Apache::loncommunicate;
                     40: 
                     41: use strict;
                     42: use Apache::Constants qw(:common);
1.2       www        43: use Apache::lonmsg();
1.11      www        44: use Apache::loncommon;
1.16      www        45: use Apache::lonlocal;
1.1       www        46: 
                     47: sub handler {
                     48:     my $r = shift;
1.16      www        49:     &Apache::loncommon::content_type($r,'text/html');
1.1       www        50:     $r->send_http_header;
                     51:     return OK if $r->header_only;
1.2       www        52: #
                     53: # Start document
                     54: #
1.9       matthew    55:     $r->print(<<END);
1.1       www        56: <html>
                     57: <head>
                     58: <title>The LearningOnline Network with CAPA</title>
                     59: </head>
1.9       matthew    60: END
1.16      www        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: );
1.18    ! www        76:     my %help=();
        !            77:     foreach ('Course_Face_To_Face_Records,Course_Critical_Message',
        !            78: 	     'Course_Broadcast_Message') {
        !            79: 	$help{$_}=&Apache::loncommon::help_open_topic($_);
        !            80:     }
1.16      www        81: 
1.11      www        82:    $r->print(&Apache::loncommon::bodytag("Communication and Messages"));
1.9       matthew    83:    $r->print(<<END);
                     84: <table cellspacing="10" cellpadding="2">
                     85: <tr><td bgcolor="#FFFFAA">
1.16      www        86:   <b><a href="/adm/email/">$lt{'vam'}</a></b>
1.9       matthew    87: </td></tr>
                     88: <tr><td bgcolor="#FFFFAA">
1.16      www        89:   <b><a href="/adm/email?critical=display">$lt{'vcm'}</a></b>
1.9       matthew    90: </td></tr>
                     91: <tr><td bgcolor="#FFFFAA">
1.16      www        92:   <b><a href="/adm/email?compose=individual">$lt{'smu'}</a></b>
1.9       matthew    93: </td></tr>
                     94: END
1.4       www        95:     if (($ENV{'request.course.id'}) && 
                     96:         (&Apache::lonnet::allowed('srm',$ENV{'request.course.id'}))) {
1.9       matthew    97:         $r->print(<<END);
                     98: <tr><td bgcolor="#FFFFAA">
1.18    ! www        99:     <b><a href="/adm/email?compose=group">$lt{'bmc'}</a></b>$help{'Course_Broadcast_Message'}
1.9       matthew   100: </td></tr>
                    101: <tr><td bgcolor="#FFFFAA">
1.16      www       102:   <b><a href="/adm/email?compose=upload">$lt{'dmu'}</a></b>
1.9       matthew   103: </td></tr>
1.13      www       104: <tr><td bgcolor="#FFFFAA">
1.18    ! www       105: <b><a href="/adm/email?recordftf=query">$lt{'unr'}</a></b>$help{'Course_Face_To_Face_Records,Course_Critical_Message'}
1.13      www       106: </td></tr>
                    107: 
1.9       matthew   108: END
1.4       www       109:     }
1.9       matthew   110:     $r->print('</table>');
                    111:     my @msgids = sort split(/\&/,&Apache::lonnet::reply
                    112:                             ('keys:'.$ENV{'user.domain'}.':'.
                    113:                              $ENV{'user.name'}.':nohist_email',
                    114:                              $ENV{'user.home'}));
                    115:     my @newmsgs;
                    116:     foreach (@msgids) {
                    117:         my ($sendtime,$shortsubj,$fromname,$fromdom,$status)=
                    118: 	    &Apache::lonmsg::unpackmsgid($_);
1.12      albertel  119:        if (defined($sendtime) && $sendtime!~/error/) {
1.17      www       120:         $sendtime = &Apache::lonlocal::locallocaltime($sendtime);
1.9       matthew   121:         if ($status eq 'new') {
                    122:             push @newmsgs, { 
                    123:                 msgid    => $_,
                    124:                 sendtime => $sendtime,
                    125:                 shortsub => &Apache::lonnet::unescape($shortsubj),
                    126:                 from     => $fromname,
                    127:                 fromdom  => $fromdom 
                    128:                 }
                    129:         }
1.10      www       130:        }
1.9       matthew   131:     }
                    132:     if ($#newmsgs >= 0) {
                    133:         $r->print(<<TABLEHEAD);
1.16      www       134: <h3>$lt{'nm'}</h3>
1.2       www       135: <table border=2><tr><th>&nbsp</th>
1.16      www       136: <th>$lt{'da'}</th><th>$lt{'us'}</th><th>$lt{'do'}</th><th>$lt{'su'}</th></tr>
1.9       matthew   137: TABLEHEAD
                    138:         foreach my $msg (@newmsgs) {
                    139:             $r->print(<<"ENDLINK");
                    140: <tr bgcolor="#FFBB77">
1.16      www       141: <td><a href="/adm/email?display=$msg->{'msgid'}">$lt{'op'}</a></td>
1.9       matthew   142: ENDLINK
                    143:             foreach ('sendtime','from','fromdom','shortsub') {
                    144:                 $r->print("<td>$msg->{$_}</td>");
                    145:             }
                    146:             $r->print("</td></tr>");
1.2       www       147:         }
1.9       matthew   148:         $r->print('</table></body></html>');
                    149:     } else {
1.16      www       150:         $r->print("<h3>".&mt('You have no unread messages')."</h3>");
1.8       harris41  151:     }
1.1       www       152:     return OK;
1.2       www       153: }
1.1       www       154: 
                    155: 1;
                    156: __END__

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