version 1.222.2.1, 2010/08/20 18:45:20
|
version 1.225, 2010/03/02 15:10:47
|
Line 203 use Apache::lonnet;
|
Line 203 use Apache::lonnet;
|
use HTML::TokeParser(); |
use HTML::TokeParser(); |
use Apache::lonlocal; |
use Apache::lonlocal; |
use Mail::Send; |
use Mail::Send; |
use HTML::Entities; |
|
use Encode; |
|
use LONCAPA qw(:DEFAULT :match); |
use LONCAPA qw(:DEFAULT :match); |
|
|
{ |
{ |
Line 455 sub sendemail {
|
Line 453 sub sendemail {
|
"*** ".&mt_user($user_lh,'This is an automatic e-mail generated by the LON-CAPA system.')."\n". |
"*** ".&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*** ". |
"*** ".($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; |
&mt_user($user_lh,'A reply will not be received by the recipient!'))."\n\n".$body; |
|
|
|
$body =~ s/ / /g; |
|
|
my $msg = new Mail::Send; |
my $msg = new Mail::Send; |
$msg->to($to); |
$msg->to($to); |
$msg->subject('[LON-CAPA] '.$subject); |
$msg->subject('[LON-CAPA] '.$subject); |
Line 486 sub sendnotification {
|
Line 487 sub sendnotification {
|
my $protocol = $Apache::lonnet::protocol{$homeserver}; |
my $protocol = $Apache::lonnet::protocol{$homeserver}; |
$protocol = 'http' if ($protocol ne 'https'); |
$protocol = 'http' if ($protocol ne 'https'); |
my $url = $protocol.'://'.&Apache::lonnet::hostname($homeserver). |
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, |
my ($sendtime,$shortsubj,$fromname,$fromdomain,$status,$fromcid, |
$symb,$error) = &Apache::lonmsg::unpackmsgid($msgid); |
$symb,$error) = &Apache::lonmsg::unpackmsgid($msgid); |
my ($coursetext,$body,$bodybegin,$bodysubj,$bodyend); |
my ($coursetext,$body,$bodybegin,$bodysubj,$bodyend); |
Line 540 to access the full message.',$url);
|
Line 540 to access the full message.',$url);
|
} |
} |
if ($userenv{'notifywithhtml'} ne '') { |
if ($userenv{'notifywithhtml'} ne '') { |
my @htmlexcerpt = split(/,/,$userenv{'notifywithhtml'}); |
my @htmlexcerpt = split(/,/,$userenv{'notifywithhtml'}); |
my $htmlfree = &make_htmlfree($text); |
|
foreach my $addr (@recipients) { |
foreach my $addr (@recipients) { |
if ($blocked) { |
if ($blocked) { |
$body = $bodybegin."\n".$blocktext."\n".$bodyend; |
$body = $bodybegin."\n".$blocktext."\n".$bodyend; |
} else { |
} else { |
my $sendtext; |
my $sendtext = $text; |
if (!grep/^\Q$addr\E/,@htmlexcerpt) { |
if (!grep/^\Q$addr\E/,@htmlexcerpt) { |
$sendtext = &htmlfree; |
$sendtext =~ s/\<\/*[^\>]+\>//gs; |
} else { |
|
$sendtext = $text; |
|
} |
} |
$body = $bodybegin.$bodysubj.$sendtext.$bodyend; |
$body = $bodybegin.$bodysubj.$sendtext.$bodyend; |
} |
} |
Line 559 to access the full message.',$url);
|
Line 556 to access the full message.',$url);
|
if ($blocked) { |
if ($blocked) { |
$body = $bodybegin."\n".$blocktext."\n".$bodyend; |
$body = $bodybegin."\n".$blocktext."\n".$bodyend; |
} else { |
} else { |
my $htmlfree = &make_htmlfree($text); |
$text =~ s/\<\/*[^\>]+\>//gs; |
$body = $bodybegin.$bodysubj.$htmlfree.$bodyend; |
$body = $bodybegin.$bodysubj.$text.$bodyend; |
} |
} |
&sendemail($to,$subject,$body,$touname,$toudom,$user_lh); |
&sendemail($to,$subject,$body,$touname,$toudom,$user_lh); |
} |
} |
} |
} |
|
|
sub make_htmlfree { |
sub mynewmail{ |
my ($text) = @_; |
&newmail(); |
$text =~ s/\<\/*[^\>]+\>//gs; |
return $env{'user.mailcheck.lastnewmassagetime'} > $env{'user.mailcheck.lastvisit'}; |
$text = &HTML::Entities::decode($text); |
|
$text = &Encode::encode('utf8',$text); |
|
return $text; |
|
} |
} |
|
|
|
|
sub newmail { |
sub newmail { |
if ((time-$env{'user.mailcheck.time'})>300) { |
if ((time-$env{'user.mailcheck.time'})>300) { |
my %what=&Apache::lonnet::get('email_status',['recnewemail']); |
my %what=&Apache::lonnet::get('email_status',['recnewemail']); |
&Apache::lonnet::appenv({'user.mailcheck.time'=>time}); |
&Apache::lonnet::appenv({'user.mailcheck.time'=>time}); |
|
&Apache::lonnet::appenv({'user.mailcheck.lastnewmassagetime'=> $what{'recnewemail'}}); |
if ($what{'recnewemail'}>0) { return 1; } |
if ($what{'recnewemail'}>0) { return 1; } |
} |
} |
return 0; |
return 0; |