--- loncom/interface/lonmsg.pm 2009/01/05 20:04:40 1.221 +++ loncom/interface/lonmsg.pm 2010/03/02 15:10:47 1.225 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Routines for messaging # -# $Id: lonmsg.pm,v 1.221 2009/01/05 20:04:40 raeburn Exp $ +# $Id: lonmsg.pm,v 1.225 2010/03/02 15:10:47 jms Exp $ # # Copyright Michigan State University Board of Trustees # @@ -194,8 +194,6 @@ Returns %to - a hash, which keys are addresses of users to send messages to the keys will look like name:domain -=item user_lang() - =back =cut @@ -455,6 +453,9 @@ 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; + + $body =~ s/ / /g; + my $msg = new Mail::Send; $msg->to($to); $msg->subject('[LON-CAPA] '.$subject); @@ -490,7 +491,7 @@ sub sendnotification { my ($sendtime,$shortsubj,$fromname,$fromdomain,$status,$fromcid, $symb,$error) = &Apache::lonmsg::unpackmsgid($msgid); my ($coursetext,$body,$bodybegin,$bodysubj,$bodyend); - my $user_lh = &user_lang($touname,$toudom,$fromcid); + my $user_lh = &Apache::loncommon::user_lang($touname,$toudom,$fromcid); if ($fromcid ne '') { $coursetext = "\n".&mt_user($user_lh,'Course').': '; if ($env{'course.'.$fromcid.'.description'} ne '') { @@ -562,11 +563,17 @@ to access the full message.',$url); } } +sub mynewmail{ + &newmail(); + return $env{'user.mailcheck.lastnewmassagetime'} > $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.lastnewmassagetime'=> $what{'recnewemail'}}); if ($what{'recnewemail'}>0) { return 1; } } return 0; @@ -1025,28 +1032,6 @@ sub decide_receiver { return ($typestyle,%to); } -sub user_lang { - my ($touname,$toudom,$fromcid) = @_; - my @userlangs; - if (($fromcid ne '') && ($env{'course.'.$fromcid.'.languages'} ne '')) { - @userlangs=(@userlangs,split(/\s*(\,|\;|\:)\s*/, - $env{'course.'.$fromcid.'.languages'})); - } else { - my %langhash = &Apache::loncommon::getlangs($touname,$toudom); - if ($langhash{'languages'} ne '') { - @userlangs = split(/\s*(\,|\;|\:)\s*/,$langhash{'languages'}); - } else { - my %domdefs = &Apache::lonnet::get_domain_defaults($toudom); - if ($domdefs{'lang_def'} ne '') { - @userlangs = ($domdefs{'lang_def'}); - } - } - } - my @languages=&Apache::lonlocal::get_genlanguages(@userlangs); - my $user_lh = Apache::localize->get_handle(@languages); - return $user_lh; -} - 1; __END__