--- loncom/interface/lonmsg.pm 2007/05/08 16:50:02 1.205 +++ loncom/interface/lonmsg.pm 2007/05/08 17:23:10 1.206 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Routines for messaging # -# $Id: lonmsg.pm,v 1.205 2007/05/08 16:50:02 raeburn Exp $ +# $Id: lonmsg.pm,v 1.206 2007/05/08 17:23:10 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -304,13 +304,12 @@ sub sendnotification { my $critical=($crit?' critical':''); $text=~s/\<\;/\/gs; - $text=~s/\<\/*[^\>]+\>//gs; my $url='http://'. &Apache::lonnet::hostname(&Apache::lonnet::homeserver($touname,$toudom)). '/adm/email?username='.$touname.'&domain='.$toudom; my ($sendtime,$shortsubj,$fromname,$fromdomain,$status,$fromcid, $symb,$error) = &Apache::lonmsg::unpackmsgid($msgid); - my $coursetext; + my ($coursetext,$body,$bodystart,$bodyend); if ($fromcid ne '') { $coursetext = "\n".&mt('Course').': '; if ($env{'course.'.$fromcid.'.description'} ne '') { @@ -323,14 +322,16 @@ sub sendnotification { } $coursetext .= "\n\n"; } - my $body = $coursetext. + my @recipients = split(/,/,$to); + $bodystart = $coursetext. &mt('You received a'.$critical.' message from [_1] in LON-CAPA.',$sender).' '.&mt('The subject is [_1] ',$subj)."\n". '=== '.&mt('Excerpt')." ============================================================ -$text +"; + $bodyend = " ======================================================================== ".&mt('Use @@ -338,7 +339,23 @@ $text [_1] to access the full message.',$url); - &sendemail($to,'New'.$critical.' message from '.$sender,$body); + my %userenv = &Apache::lonnet::get('environment',['notifywithhtml'],$toudom,$touname); + my $subject = &mt("'New' $critical message from ").$sender; + if ($userenv{'notifywithhtml'} ne '') { + my @htmlexcerpt = split(/,/,$userenv{'notifywithhtml'}); + foreach my $addr (@recipients) { + my $sendtext = $text; + if (!grep/^\Q$addr\E/,@htmlexcerpt) { + $sendtext =~ s/\<\/*[^\>]+\>//gs; + } + $body = $bodystart.$sendtext.$bodyend; + &sendemail($addr,$subject,$body); + } + } else { + $body = $bodystart.$text.$bodyend; + $text =~ s/\<\/*[^\>]+\>//gs; + &sendemail($to,$subject,$body); + } } # ============================================================= Check for email @@ -634,9 +651,7 @@ sub user_normal_msg_raw { $$sentmessage = $packed_message; } # Notifications - my %userenv = &Apache::lonnet::get('environment',['notification', - 'permanentemail'], - $domain,$user); + my %userenv = &Apache::loncommon::getemails($user,$domain); if ($userenv{'notification'}) { &sendnotification($userenv{'notification'},$user,$domain,$subject,0, $text,$msgid);