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

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

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