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

1.1       www         1: # The LearningOnline Network
                      2: # Communicate
                      3: #
1.23    ! www         4: # $Id: loncommunicate.pm,v 1.22 2004/05/17 19:00:46 raeburn 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: 
1.21      www        38: sub menu {
                     39:     my $r=shift;
                     40:     my %lt=&Apache::lonlocal::texthash(
1.23    ! www        41: 'mnf' => 'Make New Folder',
1.16      www        42: 'vcm' => 'View Critical Messages',
                     43: 'smu' => 'Send Message to User(s)',
                     44: 'bmc' => 'Broadcast Message to Course',
                     45: 'dmu' => 'Distribute Messages from Uploaded File to Course',
                     46: 'unr' => 
                     47:      'User Notes, Records of Face-to-Face Discussions, and Critical Messages',
                     48: 'nm' => 'New Messages',
                     49: 'su' => 'Subject',
                     50: 'da' => 'Date',
                     51: 'us' => 'Username',
                     52: 'op' => 'Open',
1.22      raeburn    53: 'do' => 'Domain',
                     54: 'cbs' => 'Configure blocking of student communication during exams' 
                     55: 
1.16      www        56: );
1.18      www        57:     my %help=();
                     58:     foreach ('Course_Face_To_Face_Records,Course_Critical_Message',
                     59: 	     'Course_Broadcast_Message') {
                     60: 	$help{$_}=&Apache::loncommon::help_open_topic($_);
                     61:     }
1.23    ! www        62:     my $folderlist=&Apache::lonmsg::folderlist();
1.20      www        63: # ------------------------------------------------------------------------ Menu
1.9       matthew    64:    $r->print(<<END);
1.23    ! www        65: $folderlist
        !            66: <form method="post" action="/adm/email">
        !            67: <input type="submit" value="$lt{'mnf'}" />
        !            68: <input type="text" size="15" name="newfolder" value="" />
        !            69: </form>
1.9       matthew    70: <table cellspacing="10" cellpadding="2">
                     71: <tr><td bgcolor="#FFFFAA">
1.16      www        72:   <b><a href="/adm/email?compose=individual">$lt{'smu'}</a></b>
1.9       matthew    73: </td></tr>
                     74: END
1.4       www        75:     if (($ENV{'request.course.id'}) && 
                     76:         (&Apache::lonnet::allowed('srm',$ENV{'request.course.id'}))) {
1.9       matthew    77:         $r->print(<<END);
                     78: <tr><td bgcolor="#FFFFAA">
1.18      www        79:     <b><a href="/adm/email?compose=group">$lt{'bmc'}</a></b>$help{'Course_Broadcast_Message'}
1.9       matthew    80: </td></tr>
                     81: <tr><td bgcolor="#FFFFAA">
1.16      www        82:   <b><a href="/adm/email?compose=upload">$lt{'dmu'}</a></b>
1.9       matthew    83: </td></tr>
1.13      www        84: <tr><td bgcolor="#FFFFAA">
1.18      www        85: <b><a href="/adm/email?recordftf=query">$lt{'unr'}</a></b>$help{'Course_Face_To_Face_Records,Course_Critical_Message'}
1.13      www        86: </td></tr>
1.22      raeburn    87: <tr><td bgcolor="#FFFFAA">
                     88:   <b><a href="/adm/email?block=display">$lt{'cbs'}</a>
                     89: </td></tr>
1.9       matthew    90: END
1.4       www        91:     }
1.9       matthew    92:     $r->print('</table>');
                     93:     my @msgids = sort split(/\&/,&Apache::lonnet::reply
                     94:                             ('keys:'.$ENV{'user.domain'}.':'.
                     95:                              $ENV{'user.name'}.':nohist_email',
                     96:                              $ENV{'user.home'}));
                     97:     my @newmsgs;
1.22      raeburn    98:     my %setters = ();
                     99:     my $startblock = 0;
                    100:     my $endblock = 0;
                    101:     my %blocked = ();
                    102:     my $numblocked = 0;
                    103:     # Check for blocking of display because of scheduled online exams.
                    104:     &Apache::lonmsg::blockcheck(\%setters,\$startblock,\$endblock);
1.9       matthew   105:     foreach (@msgids) {
                    106:         my ($sendtime,$shortsubj,$fromname,$fromdom,$status)=
                    107: 	    &Apache::lonmsg::unpackmsgid($_);
1.22      raeburn   108:         if (defined($sendtime) && $sendtime!~/error/) {
                    109:             my $numsendtime = $sendtime;
                    110:             $sendtime = &Apache::lonlocal::locallocaltime($sendtime);
                    111:             if ($status eq 'new') {
                    112:                 if ($numsendtime >= $startblock && ($numsendtime <= $endblock && $endblock > 0) ) {
                    113:                     $blocked{$_} = 'ON';
                    114:                     $numblocked ++;
                    115:                 } else {
                    116:                     push @newmsgs, { 
                    117:                         msgid    => $_,
                    118:                         sendtime => $sendtime,
                    119:                         shortsub => &Apache::lonnet::unescape($shortsubj),
                    120:                         from     => $fromname,
                    121:                         fromdom  => $fromdom 
                    122:                         }
1.9       matthew   123:                 }
1.22      raeburn   124:             }
1.9       matthew   125:         }
                    126:     }
                    127:     if ($#newmsgs >= 0) {
                    128:         $r->print(<<TABLEHEAD);
1.20      www       129: <h2>$lt{'nm'}</h2>
1.2       www       130: <table border=2><tr><th>&nbsp</th>
1.16      www       131: <th>$lt{'da'}</th><th>$lt{'us'}</th><th>$lt{'do'}</th><th>$lt{'su'}</th></tr>
1.9       matthew   132: TABLEHEAD
                    133:         foreach my $msg (@newmsgs) {
                    134:             $r->print(<<"ENDLINK");
                    135: <tr bgcolor="#FFBB77">
1.16      www       136: <td><a href="/adm/email?display=$msg->{'msgid'}">$lt{'op'}</a></td>
1.9       matthew   137: ENDLINK
                    138:             foreach ('sendtime','from','fromdom','shortsub') {
                    139:                 $r->print("<td>$msg->{$_}</td>");
                    140:             }
                    141:             $r->print("</td></tr>");
1.2       www       142:         }
1.9       matthew   143:         $r->print('</table></body></html>');
1.22      raeburn   144:     } elsif ($numblocked == 0) {
1.16      www       145:         $r->print("<h3>".&mt('You have no unread messages')."</h3>");
1.22      raeburn   146:     }
                    147:     if ($numblocked > 0) {
                    148:         my $beginblock = &Apache::lonlocal::locallocaltime($startblock);
                    149:         my $finishblock = &Apache::lonlocal::locallocaltime($endblock);
                    150:         if ($numblocked == 1) {
                    151:             $r->print("<h3>".&mt('You have').' '.$numblocked.' '.&mt('blocked unread message').".</h3>");
                    152:             $r->print(&mt('This message is not viewable because').' ');
                    153:         } else {
                    154:             $r->print("<h3>".&mt('You have').' '.$numblocked.' '.&mt('blocked unread messages').".</h3>");
                    155:             $r->print(&mt('These').' '.$numblocked.' '.&mt('messages are not viewable because '));
                    156:         }
                    157:         $r->print(
                    158: &mt('display of LON-CAPA messages sent to you by other students between').' '.$beginblock.' '.&mt('and').' '.$finishblock.' '.&mt('is currently being blocked because of online exams').'.');
                    159:         &Apache::lonmsg::build_block_table($r,$startblock,$endblock,\%setters);
1.8       harris41  160:     }
1.21      www       161: }
                    162: 
                    163: sub handler {
                    164:     my $r = shift;
                    165:     &Apache::loncommon::content_type($r,'text/html');
                    166:     $r->send_http_header;
                    167:     return OK if $r->header_only;
                    168: #
                    169: # Start document
                    170: #
                    171:     $r->print(<<END);
                    172: <html>
                    173: <head>
                    174: <title>The LearningOnline Network with CAPA</title>
                    175: </head>
                    176: END
                    177: 
                    178: # ----------------------------------------------------------------- Breadcrumbs
                    179:     &Apache::lonhtmlcommon::clear_breadcrumbs();
                    180:     &Apache::lonhtmlcommon::add_breadcrumb
                    181:         ({href=>"/adm/communicate",
                    182:           text=>"Communication/Messages",
                    183:           faq=>12,bug=>'Communication Tools',});
                    184: 
                    185: # ---------------------------------------------------------------------- Header
                    186:     &Apache::lonmsg::header($r);
                    187:     &menu($r);
1.1       www       188:     return OK;
1.2       www       189: }
1.1       www       190: 
                    191: 1;
                    192: __END__

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