version 1.215, 2008/11/19 17:38:26
|
version 1.221, 2009/01/05 20:04:40
|
Line 224 sub packagemsg {
|
Line 224 sub packagemsg {
|
$citation=&HTML::Entities::encode($citation,'<>&"'); |
$citation=&HTML::Entities::encode($citation,'<>&"'); |
$subject =&HTML::Entities::encode($subject,'<>&"'); |
$subject =&HTML::Entities::encode($subject,'<>&"'); |
#remove machine specification |
#remove machine specification |
$baseurl =~ s|^http://[^/]+/|/|; |
$baseurl =~ s|^https?://[^/]+/|/|; |
$baseurl =&HTML::Entities::encode($baseurl,'<>&"'); |
$baseurl =&HTML::Entities::encode($baseurl,'<>&"'); |
#remove machine specification |
#remove machine specification |
$attachmenturl =~ s|^http://[^/]+/|/|; |
$attachmenturl =~ s|^https?://[^/]+/|/|; |
$attachmenturl =&HTML::Entities::encode($attachmenturl,'<>&"'); |
$attachmenturl =&HTML::Entities::encode($attachmenturl,'<>&"'); |
my $course_context = &get_course_context(); |
my $course_context = &get_course_context(); |
my $now=time; |
my $now=time; |
Line 422 sub unpackmsgid {
|
Line 422 sub unpackmsgid {
|
|
|
sub sendemail { |
sub sendemail { |
my ($to,$subject,$body,$to_uname,$to_udom,$user_lh)=@_; |
my ($to,$subject,$body,$to_uname,$to_udom,$user_lh)=@_; |
my %senderemails=&Apache::loncommon::getemails(); |
|
my $senderaddress=''; |
my $senderaddress=''; |
foreach my $type ('notification','permanentemail','critnotification') { |
my $replytoaddress=''; |
if ($senderemails{$type}) { |
if ($env{'form.can_reply'} eq 'N') { |
$senderaddress=$senderemails{$type}; |
my $lonhost = $Apache::lonnet::perlvar{'lonHostID'}; |
} |
my $hostname = &Apache::lonnet::hostname($lonhost); |
|
$replytoaddress = 'do-not-reply@'.$hostname; |
|
} else { |
|
my %senderemails; |
|
my $have_sender; |
|
if ($env{'form.reply_to_addr'}) { |
|
my ($replytoname,$replytodom) = split(/:/,$env{'form.reply_to_addr'}); |
|
if (!($replytoname eq $env{'user.name'} && $replytodom eq $env{'user.domain'})) { |
|
if (&Apache::lonnet::homeserver($replytoname,$replytodom) ne 'no_host') { |
|
%senderemails = |
|
&Apache::loncommon::getemails($replytoname,$replytodom); |
|
$have_sender = 1; |
|
} |
|
} |
|
} |
|
if (!$have_sender) { |
|
%senderemails=&Apache::loncommon::getemails(); |
|
} |
|
foreach my $type ('permanentemail','critnotification','notification') { |
|
if ($senderemails{$type}) { |
|
($senderaddress) = split(/,/,$senderemails{$type}); |
|
last if ($senderaddress); |
|
} |
|
} |
} |
} |
$body= |
$body= |
"*** ".&mt_user($user_lh,'This is an automatic message 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 message'):&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; |
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); |
if ($senderaddress) { $msg->add('Reply-to',$senderaddress); $msg->add('From',$senderaddress); } |
if ($replytoaddress) { |
|
$msg->add('Reply-to',$replytoaddress); |
|
} |
|
if ($senderaddress) { |
|
$msg->add('From',$senderaddress); |
|
} |
if (my $fh = $msg->open()) { |
if (my $fh = $msg->open()) { |
print $fh $body; |
print $fh $body; |
$fh->close; |
$fh->close; |
Line 455 sub sendnotification {
|
Line 482 sub sendnotification {
|
|
|
$text=~s/\<\;/\</gs; |
$text=~s/\<\;/\</gs; |
$text=~s/\>\;/\>/gs; |
$text=~s/\>\;/\>/gs; |
my $url='http://'. |
my $homeserver = &Apache::lonnet::homeserver($touname,$toudom); |
&Apache::lonnet::hostname(&Apache::lonnet::homeserver($touname,$toudom)). |
my $protocol = $Apache::lonnet::protocol{$homeserver}; |
'/adm/email?username='.$touname.'&domain='.$toudom; |
$protocol = 'http' if ($protocol ne 'https'); |
|
my $url = $protocol.'://'.&Apache::lonnet::hostname($homeserver). |
|
'/adm/email?username='.$touname.'&domain='.$toudom; |
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 1003 sub user_lang {
|
Line 1032 sub user_lang {
|
@userlangs=(@userlangs,split(/\s*(\,|\;|\:)\s*/, |
@userlangs=(@userlangs,split(/\s*(\,|\;|\:)\s*/, |
$env{'course.'.$fromcid.'.languages'})); |
$env{'course.'.$fromcid.'.languages'})); |
} else { |
} else { |
my %langhash = &Apache::lonnet::get('environment',['languages'],$toudom,$touname); |
my %langhash = &Apache::loncommon::getlangs($touname,$toudom); |
if ($langhash{'languages'} ne '') { |
if ($langhash{'languages'} ne '') { |
@userlangs = split(/\s*(\,|\;|\:)\s*/,$langhash{'languages'}); |
@userlangs = split(/\s*(\,|\;|\:)\s*/,$langhash{'languages'}); |
} else { |
} else { |
my %domdefs = &Apache::lonnet::get_domain_defaults($toudom); |
my %domdefs = &Apache::lonnet::get_domain_defaults($toudom); |
if ($domdefs{'lang_def'} ne '') { |
if ($domdefs{'lang_def'} ne '') { |
Line 1013 sub user_lang {
|
Line 1042 sub user_lang {
|
} |
} |
} |
} |
} |
} |
my @languages=&Apache::loncommon::get_genlanguages(@userlangs); |
my @languages=&Apache::lonlocal::get_genlanguages(@userlangs); |
my $user_lh = Apache::localize->get_handle(@languages); |
my $user_lh = Apache::localize->get_handle(@languages); |
return $user_lh; |
return $user_lh; |
} |
} |