--- loncom/interface/lonmsgdisplay.pm 2007/01/22 21:51:05 1.65
+++ loncom/interface/lonmsgdisplay.pm 2007/04/22 13:41:22 1.70
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Routines for messaging display
#
-# $Id: lonmsgdisplay.pm,v 1.65 2007/01/22 21:51:05 raeburn Exp $
+# $Id: lonmsgdisplay.pm,v 1.70 2007/04/22 13:41:22 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -33,12 +33,13 @@ package Apache::lonmsgdisplay;
=head1 NAME
-Apache::lonmsg: supports internal messaging
+Apache::lonmsgdisplay: supports internal messaging
=head1 SYNOPSIS
-lonmsg provides routines for sending messages, receiving messages, and
-a handler to allow users to read, send, and delete messages.
+lonmsgdisplay provides a handler to allow users to read, send,
+and delete messages, and to create and delete message folders,
+and to move messages between folders.
=head1 OVERVIEW
@@ -93,25 +94,6 @@ addresses on their B screen, but g
are much more useful than traditional email can be made to be, even
with HTML support.
-Right now, this document will cover just how to send a message, since
-it is likely you will not need to programmatically read messages,
-since lonmsg already implements that functionality.
-
-The routines used to package messages and unpackage messages are not
-only used by lonmsg when creating/extracting messages for LON-CAPA's
-internal messaging system, but also by lonnotify.pm which is available
-for use by Domain Coordinators to broadcast standard e-mail to specified
-users in their domain. The XML packaging used in the two cases is very
-similar. The differences are the use of $uname and
-$udom in stored internal messages, compared
-with $email in stored
-Domain Coordinator e-mail for the storage of information about
-recipients of the message/e-mail.
-
-=head1 FUNCTIONS
-
-=over 4
-
=cut
use strict;
@@ -119,6 +101,7 @@ use Apache::lonnet;
use HTML::TokeParser();
use Apache::Constants qw(:common);
use Apache::loncommon();
+use Apache::lonhtmlcommon();
use Apache::lontexconvert();
use HTML::Entities();
use Apache::lonlocal;
@@ -1054,16 +1037,23 @@ ENDDISHEADER
}
my ($dis_name,$dis_domain) = ($fromname,$fromdomain);
if ($folder eq 'sent') {
- if (defined($recv_name) && !defined($recv_domain)) {
- $dis_name = join(' ',@{$recv_name});
- $dis_domain = join(' ',@{$recv_domain});
+ if (defined($recv_name) && defined($recv_domain)) {
+ if (ref($recv_name) eq 'ARRAY' &&
+ ref($recv_domain) eq 'ARRAY') {
+ $dis_name = join(' ',@{$recv_name});
+ $dis_domain = join(' ',@{$recv_domain});
+ }
} else {
my $msg_id = &unescape($origID);
my %message = &Apache::lonnet::get('nohist_email'.$suffix,
[$msg_id]);
my %content = &Apache::lonmsg::unpackagemsg($message{$msg_id});
- $dis_name = join(' ',@{$content{'recuser'}});
- $dis_domain = join(' ',@{$content{'recdomain'}});
+ if (ref($content{'recuser'}) eq 'ARRAY') {
+ $dis_name = join(' ',@{$content{'recuser'}});
+ }
+ if (ref($content{'recdomain'}) eq 'ARRAY') {
+ $dis_domain = join(' ',@{$content{'recdomain'}});
+ }
}
}
my $localsenttime = &Apache::lonlocal::locallocaltime($sendtime);
@@ -1196,7 +1186,13 @@ sub compout {
text=>"Display All Messages"});
&printheader($r,'/adm/email?compose=multiforward',
'Forwarding Multiple Messages');
- $r->print(&mt('Each of the [quant,_1,message] you checked will be forwarded to the recipient(s) you select below.',$multiforward).' ');
+ if ($multiforward > 1) {
+ $r->print(&mt('Each of the [quant,_1,message] you checked
+will be forwarded to the recipient(s) you select below.',$multiforward).' ');
+ } else {
+ $r->print(&mt('The message you checked will be forwarded to the recipient(s) you select below.').' ');
+ }
+
} else {
&printheader($r,'/adm/email?compose=upload',
'Distribute from Uploaded File');
@@ -1232,7 +1228,17 @@ sub compout {
&mt('Send copy to permanent email address (if known)').'
'.
'';
- }
+ }
+ if (&Apache::lonnet::allowed('dff',$env{'request.course.id'}) ||
+ &Apache::lonnet::allowed('dff',$env{'request.course.id'}.
+ '/'.$env{'request.course.sec'})) {
+
+ $dispcrit.='';
+ }
+
my %message;
my %content;
my $defdom=$env{'user.domain'};
@@ -1517,7 +1523,20 @@ sub disfacetoface {
''.&mt('Subject').': '.$content{'subject'}.' '.
$content{'message'};
}
- }
+ }
+ } elsif ($content{'subject'}=~/^Archive/) {
+ $result.='
'.&mt('Archived Message').'
';
+ if (defined($content{'coursemsgid'})) {
+ my $crsmsgid = &escape($content{'coursemsgid'});
+ my $archive_message = &general_message($crsmsgid);
+ $content{'message'} = ''.&mt('Subject').': '.$content{'message'}.' '.$archive_message;
+ } else {
+ %content=&Apache::lonmsg::unpackagemsg($content{'message'});
+ $content{'message'} =
+ ''.&mt('Subject').': '.$content{'subject'}.' '.&mt('Critical Message').'';
if (defined($content{'coursemsgid'})) {
@@ -1580,7 +1599,7 @@ sub facetoface {
: 'faculty and staff';
&printheader($r,
'/adm/email?recordftf=query',
- "User Notes, Face-to-Face, Critical Messages, Broadcast Messages");
+ "User Notes, Face-to-Face, Critical Messages, Broadcast Messages, Archived Messages");
# from query string
if ($env{'form.recname'}) { $env{'form.recuname'}=$env{'form.recname'}; }
@@ -1595,7 +1614,7 @@ sub facetoface {
('stdselect','recuname','recdomain');
my %lt=&Apache::lonlocal::texthash('user' => 'Username',
'dom' => 'Domain',
- 'head' => "User Notes, Records of Face-To-Face Discussions, Critical Messages, and Broadcast Messages in $crstype",
+ 'head' => "User Notes, Records of Face-To-Face Discussions, Critical Messages, Broadcast Messages and Archived Messages in $crstype",
'subm' => 'Retrieve discussion and message records',
'newr' => 'New Record (record is visible to '.lc($crstype).' '.$leaders.')',
'post' => 'Post this Record');
@@ -2039,6 +2058,7 @@ sub displaymessage {
if (defined($content{'baseurl'})) {
$baseurl = &Apache::lonenc::check_encrypt($content{'baseurl'});
}
+ $r->print(&Apache::loncommon::student_image_tag($content{'senderdomain'},$content{'sendername'}));
$r->print(' '.&mt('Subject').': '.$content{'subject'}.
($folder ne 'sent'?' '.&mt('From').': '.
&Apache::loncommon::aboutmewrapper(
@@ -2280,7 +2300,7 @@ sub sendoffmail {
}
}
if ($env{'form.additionalrec'}) {
- foreach my $rec (split(/\,/,$env{'form.additionalrec'})) {
+ foreach my $rec (split(/\s*,\s*/,$env{'form.additionalrec'})) {
my ($auname,$audom)=split(/:/,$rec);
if (($auname ne "") && ($audom ne "")) {
$toaddr{$auname.':'.$audom}='';
@@ -2328,8 +2348,10 @@ sub sendoffmail {
$env{'form.permanent'},
\$sentmessage{$address});
}
- if (($env{'request.course.id'}) && (($msgtype eq 'critical') ||
- ($env{'form.sendmode'} eq 'group'))) {
+ if (($env{'request.course.id'}) &&
+ (($msgtype eq 'critical') ||
+ ($env{'form.sendmode'} eq 'group') ||
+ ($env{'form.courserecord'}))) {
$specialmsg_status{$recuname.':'.$recdomain} =
join(' ',@thismsg);
foreach my $result (@thismsg) {
@@ -2340,13 +2362,17 @@ sub sendoffmail {
}
$sendstatus.=' '.join(' ',@thismsg);
}
- if (($env{'request.course.id'}) && (($env{'form.sendmode'} eq 'group')
- || ($msgtype eq 'critical'))) {
+ if (($env{'request.course.id'}) &&
+ (($env{'form.sendmode'} eq 'group') ||
+ ($env{'form.courserecord'}) ||
+ ($msgtype eq 'critical'))) {
my $subj_prefix;
if ($msgtype eq 'critical') {
$subj_prefix = 'Critical.';
- } else {
+ } elsif ($env{'form.sendmode'} eq 'group') {
$subj_prefix = 'Broadcast.';
+ } else {
+ $subj_prefix = 'Archive';
}
my ($specialmsgid,$specialresult);
my $course_str = &escape('['.$cnum.':'.$cdom.']');
@@ -2365,7 +2391,7 @@ sub sendoffmail {
split(/\:/,&unescape($specialmsgid));
foreach my $recipient (sort(keys(%toaddr))) {
- if ($specialmsg_status{$recipient} eq 'ok') {
+ if ($specialmsg_status{$recipient} =~ /\s*(ok|con_delayed)\s*/) {
my $usersubj = $subj_prefix.'['.$recipient.']';
my $usermsgid =
&Apache::lonmsg::buildmsgid($stamp,$usersubj,
@@ -2758,8 +2784,6 @@ sub handler {
=pod
-=back
-
=cut
1;