--- loncom/interface/lonmsgdisplay.pm 2006/04/25 19:45:50 1.12
+++ loncom/interface/lonmsgdisplay.pm 2006/04/25 19:50:09 1.13
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Routines for messaging display
#
-# $Id: lonmsgdisplay.pm,v 1.12 2006/04/25 19:45:50 albertel Exp $
+# $Id: lonmsgdisplay.pm,v 1.13 2006/04/25 19:50:09 albertel Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -1719,17 +1719,17 @@ sub sendoffmail {
%content=&Apache::lonmsg::unpackagemsg($message{$msgid},1);
&statuschange($msgid,'replied',$folder);
}
- my %toaddr=();
- undef %toaddr;
+
+ my %toaddr;
if ($env{'form.sendmode'} eq 'group') {
- foreach (keys %env) {
- if ($_=~/^form\.send\_to\_\&\&\&[^\&]*\&\&\&\_(.+)$/) {
+ foreach $address (keys(%env)) {
+ if ($address=~/^form\.send\_to\_\&\&\&[^\&]*\&\&\&\_(.+)$/) {
$toaddr{$1}='';
}
}
} elsif ($env{'form.sendmode'} eq 'upload') {
- foreach (split(/[\n\r\f]+/,$env{'form.upfile'})) {
- my ($rec,$txt)=split(/\s*\:\s*/,$_);
+ foreach my $line (split(/[\n\r\f]+/,$env{'form.upfile'})) {
+ my ($rec,$txt)=split(/\s*\:\s*/,$line);
if ($txt) {
$rec=~s/\@/\:/;
$toaddr{$rec}.=$txt."\n";
@@ -1761,23 +1761,31 @@ sub sendoffmail {
$savemsg=&Apache::lonfeedback::clear_out_html($env{'form.message'});
}
- foreach (keys %toaddr) {
- my ($recuname,$recdomain)=split(/\:/,$_);
+ foreach my $address (sort(keys(%toaddr))) {
+ my ($recuname,$recdomain)=split(/\:/,$address);
my $msgtxt = $savemsg;
- if ($toaddr{$_}) { $msgtxt.='
'.$toaddr{$_}; }
+ if ($toaddr{$address}) { $msgtxt.='
'.$toaddr{$address}; }
my @thismsg;
if ((($env{'form.critmsg'}) || ($env{'form.sendbck'})) &&
(&Apache::lonnet::allowed('srm',$env{'request.course.id'})
|| &Apache::lonnet::allowed('srm',$env{'request.course.id'}.
'/'.$env{'request.course.sec'}))) {
- $r->print(&mt('Sending critical message').' '.$recuname.'@'.$recdomain.': ');
- @thismsg=&Apache::lonmsg::user_crit_msg($recuname,$recdomain,$msgsubj,$msgtxt,
- $env{'form.sendbck'},$env{'form.permanent'},
- \$sentmessage{$_});
+ $r->print(&mt('Sending critical message').' '.$recuname.':'.$recdomain.': ');
+ @thismsg=
+ &Apache::lonmsg::user_crit_msg($recuname,$recdomain,
+ $msgsubj,$msgtxt,
+ $env{'form.sendbck'},
+ $env{'form.permanent'},
+ \$sentmessage{$address});
} else {
$r->print(&mt('Sending').' '.$recuname.'@'.$recdomain.': ');
- @thismsg=&Apache::lonmsg::user_normal_msg($recuname,$recdomain,$msgsubj,$msgtxt,
- $content{'citation'},undef,undef,$env{'form.permanent'},\$sentmessage{$_});
+ @thismsg=
+ &Apache::lonmsg::user_normal_msg($recuname,$recdomain,
+ $msgsubj,$msgtxt,
+ $content{'citation'},
+ undef,undef,
+ $env{'form.permanent'},
+ \$sentmessage{$address});
}
if (($env{'request.course.id'}) && (($msgtype eq 'critical') ||
($env{'form.sendmode'} eq 'group'))) {
@@ -1789,7 +1797,6 @@ sub sendoffmail {
}
}
}
- $r->print(join(' ',@thismsg).'
');
$sendstatus.=' '.join(' ',@thismsg);
}
if (($env{'request.course.id'}) && (($env{'form.sendmode'} eq 'group')
@@ -1813,10 +1820,11 @@ sub sendoffmail {
}
if ($specialresult eq 'ok') {
my $record_sent;
- my @recusers = ();
- my @recudoms = ();
- my ($stamp,$crssubj,$msgname,$msgdom,$msgcount,$context,$pid) =
- split(/\:/,&Apache::lonnet::unescape($specialmsgid));
+ my @recusers;
+ my @recudoms;
+ my ($stamp,$crssubj,$msgname,$msgdom,$msgcount,$context,$pid) =
+ split(/\:/,&Apache::lonnet::unescape($specialmsgid));
+
foreach my $recipient (sort(keys(%toaddr))) {
if ($specialmsg_status{$recipient} eq 'ok') {
my $usersubj = $subj_prefix.'['.$recipient.']';
@@ -1828,15 +1836,15 @@ sub sendoffmail {
&Apache::lonmsg::user_normal_msg_raw($cnum,$cdom,$subj_prefix.
' ['.$recipient.']',$msgsubj,undef,
undef,undef,undef,$usermsgid,undef,undef,$specialmsgid);
- my ($uname,$udom) = split/:/,$recipient;
+ my ($uname,$udom) = split(/:/,$recipient);
push(@recusers,$uname);
push(@recudoms,$udom);
}
}
if (@recusers) {
my $specialmessage;
- my $sentsubj = $subj_prefix.' ('.$numspecial.' sent) '.
- $msgsubj;
+ my $sentsubj =
+ $subj_prefix.' ('.$numspecial.' sent) '.$msgsubj;
$sentsubj = &HTML::Entities::encode($sentsubj,'<>&"');
my $sentmsgid =
&Apache::lonmsg::buildmsgid($stamp,$sentsubj,$msgname,