--- loncom/interface/lonmsg.pm 2005/12/05 22:16:52 1.161 +++ loncom/interface/lonmsg.pm 2005/12/09 20:54:26 1.162 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Routines for messaging # -# $Id: lonmsg.pm,v 1.161 2005/12/05 22:16:52 albertel Exp $ +# $Id: lonmsg.pm,v 1.162 2005/12/09 20:54:26 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -97,6 +97,17 @@ Right now, this document will cover just 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 teh storage of information about +recipients of the message/e-mail. + =head1 FUNCTIONS =over 4 @@ -126,7 +137,7 @@ my $interdis; sub packagemsg { my ($subject,$message,$citation,$baseurl,$attachmenturl, - $recuser,$recdomain,$msgid)=@_; + $recuser,$recdomain,$msgid,$type)=@_; $message =&HTML::Entities::encode($message,'<>&"'); $citation=&HTML::Entities::encode($citation,'<>&"'); $subject =&HTML::Entities::encode($subject,'<>&"'); @@ -178,8 +189,18 @@ sub packagemsg { ''.$msgid.''; if (ref($recuser) eq 'ARRAY') { for (my $i=0; $i<@{$recuser}; $i++) { - $result .= ''.$$recuser[$i].''. - ''.$$recdomain[$i].''; + if ($type eq 'dcmail') { + my ($username,$email) = split(/:/,$$recuser[$i]); + $username = &Apache::lonnet::unescape($username); + $email = &Apache::lonnet::unescape($email); + $username = &HTML::Entities::encode($username,'<>&"'); + $email = &HTML::Entities::encode($email,'<>&"'); + $result .= ''. + $email.''; + } else { + $result .= ''.$$recuser[$i].''. + ''.$$recdomain[$i].''; + } } } else { $result .= ''.$recuser.''. @@ -211,6 +232,10 @@ sub unpackagemsg { my $value=$parser->get_text('/'.$entry); if (($entry eq 'recuser') || ($entry eq 'recdomain')) { push(@{$content{$entry}},$value); + } elsif ($entry eq 'recipient') { + my $username = $token->[2]{'username'}; + $username = &HTML::Entities::decode($username,'<>&"'); + $content{$entry}{$username} = $value; } else { $content{$entry}=$value; }