--- loncom/interface/lonmsg.pm 2010/08/20 18:45:20 1.222.2.1 +++ loncom/interface/lonmsg.pm 2012/05/07 17:34:11 1.233 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Routines for messaging # -# $Id: lonmsg.pm,v 1.222.2.1 2010/08/20 18:45:20 raeburn Exp $ +# $Id: lonmsg.pm,v 1.233 2012/05/07 17:34:11 bisitz Exp $ # # Copyright Michigan State University Board of Trustees # @@ -455,6 +455,7 @@ sub sendemail { "*** ".&mt_user($user_lh,'This is an automatic e-mail generated by the LON-CAPA system.')."\n". "*** ".($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; + my $msg = new Mail::Send; $msg->to($to); $msg->subject('[LON-CAPA] '.$subject); @@ -464,6 +465,7 @@ sub sendemail { if ($senderaddress) { $msg->add('From',$senderaddress); } + $msg->add('Content-type','text/plain; charset=UTF-8'); if (my $fh = $msg->open()) { print $fh $body; $fh->close; @@ -525,6 +527,9 @@ sub sendnotification { to access the full message.',$url); my %userenv = &Apache::lonnet::get('environment',['notifywithhtml'],$toudom,$touname); my $subject = &mt_user($user_lh,"'New' $critical message from ").$sender; + unless ($subj eq '') { + $subject = $subj; + } my ($blocked,$blocktext); if (!$crit) { @@ -547,7 +552,7 @@ to access the full message.',$url); } else { my $sendtext; if (!grep/^\Q$addr\E/,@htmlexcerpt) { - $sendtext = &htmlfree; + $sendtext = $htmlfree; } else { $sendtext = $text; } @@ -574,10 +579,17 @@ sub make_htmlfree { return $text; } +sub mynewmail{ + &newmail(); + return $env{'user.mailcheck.lastnewmessagetime'} > $env{'user.mailcheck.lastvisit'}; +} + + sub newmail { if ((time-$env{'user.mailcheck.time'})>300) { my %what=&Apache::lonnet::get('email_status',['recnewemail']); &Apache::lonnet::appenv({'user.mailcheck.time'=>time}); + &Apache::lonnet::appenv({'user.mailcheck.lastnewmessagetime'=> $what{'recnewemail'}}); if ($what{'recnewemail'}>0) { return 1; } } return 0; @@ -610,6 +622,7 @@ sub author_res_msg { sub retrieve_author_res_msg { my $url=shift; $url=&Apache::lonnet::declutter($url); + $url=~s/^priv\///; # Respect new authorspace path (BZ 1320) my ($domain,$author)=($url=~/^($match_domain)\/($match_username)\//); my %errormsgs=&Apache::lonnet::dump('nohist_res_msgs',$domain,$author); my $msgs=''; @@ -977,7 +990,9 @@ sub secapply { my $rec=shift; my $defaultflag=shift; $rec=~s/\s+//g; - $rec=~s/\@/\:/g; + unless ($rec =~ /\:/) { + $rec=~s/\@/\:/g; + } my ($adr,$sections_or_groups)=($rec=~/^([^\(]+)\(([^\)]+)\)/); if ($sections_or_groups) { foreach my $item (split(/\;/,$sections_or_groups)) {