--- loncom/interface/lonmsg.pm 2010/03/02 15:10:47 1.225 +++ loncom/interface/lonmsg.pm 2010/05/29 22:39:52 1.226 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Routines for messaging # -# $Id: lonmsg.pm,v 1.225 2010/03/02 15:10:47 jms Exp $ +# $Id: lonmsg.pm,v 1.226 2010/05/29 22:39:52 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -203,6 +203,8 @@ use Apache::lonnet; use HTML::TokeParser(); use Apache::lonlocal; use Mail::Send; +use HTML::Entities; +use Encode; use LONCAPA qw(:DEFAULT :match); { @@ -454,8 +456,6 @@ sub sendemail { "*** ".($senderaddress?&mt_user($user_lh,'You can reply to this e-mail'):&mt_user($user_lh,'Please do not reply to this address.')."\n*** ". &mt_user($user_lh,'A reply will not be received by the recipient!'))."\n\n".$body; - $body =~ s/ / /g; - my $msg = new Mail::Send; $msg->to($to); $msg->subject('[LON-CAPA] '.$subject); @@ -487,7 +487,8 @@ sub sendnotification { my $protocol = $Apache::lonnet::protocol{$homeserver}; $protocol = 'http' if ($protocol ne 'https'); my $url = $protocol.'://'.&Apache::lonnet::hostname($homeserver). - '/adm/email?username='.$touname.'&domain='.$toudom; + '/adm/email?username='.$touname.'&domain='.$toudom. + '&display='.&escape($msgid); my ($sendtime,$shortsubj,$fromname,$fromdomain,$status,$fromcid, $symb,$error) = &Apache::lonmsg::unpackmsgid($msgid); my ($coursetext,$body,$bodybegin,$bodysubj,$bodyend); @@ -540,13 +541,16 @@ to access the full message.',$url); } if ($userenv{'notifywithhtml'} ne '') { my @htmlexcerpt = split(/,/,$userenv{'notifywithhtml'}); + my $htmlfree = &make_htmlfree($text); foreach my $addr (@recipients) { if ($blocked) { $body = $bodybegin."\n".$blocktext."\n".$bodyend; } else { - my $sendtext = $text; + my $sendtext; if (!grep/^\Q$addr\E/,@htmlexcerpt) { - $sendtext =~ s/\<\/*[^\>]+\>//gs; + $sendtext = &htmlfree; + } else { + $sendtext = $text; } $body = $bodybegin.$bodysubj.$sendtext.$bodyend; } @@ -556,13 +560,21 @@ to access the full message.',$url); if ($blocked) { $body = $bodybegin."\n".$blocktext."\n".$bodyend; } else { - $text =~ s/\<\/*[^\>]+\>//gs; - $body = $bodybegin.$bodysubj.$text.$bodyend; + my $htmlfree = &make_htmlfree($text); + $body = $bodybegin.$bodysubj.$htmlfree.$bodyend; } &sendemail($to,$subject,$body,$touname,$toudom,$user_lh); } } +sub make_htmlfree { + my ($text) = @_; + $text =~ s/\<\/*[^\>]+\>//gs; + $text = &HTML::Entities::decode($text); + $text = &Encode::encode('utf8',$text); + return $text; +} + sub mynewmail{ &newmail(); return $env{'user.mailcheck.lastnewmassagetime'} > $env{'user.mailcheck.lastvisit'};