version 1.203, 2007/05/02 20:26:08
|
version 1.210, 2007/08/18 00:32:52
|
Line 163 sub packagemsg {
|
Line 163 sub packagemsg {
|
if (defined($recipid)) { |
if (defined($recipid)) { |
$result.= '<recipid>'.$recipid.'</recipid>'; |
$result.= '<recipid>'.$recipid.'</recipid>'; |
} |
} |
|
if ($env{'form.can_reply'} eq 'N') { |
|
$result .= '<noreplies>1</noreplies>'; |
|
} |
|
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') { |
|
$result .= '<replytoaddr>'.$env{'form.reply_to_addr'}.'</replytoaddr>'; |
|
} |
|
} |
|
} |
return ($msgid,$result); |
return ($msgid,$result); |
} |
} |
|
|
Line 288 sub sendnotification {
|
Line 299 sub sendnotification {
|
my ($to,$touname,$toudom,$subj,$crit,$text,$msgid)=@_; |
my ($to,$touname,$toudom,$subj,$crit,$text,$msgid)=@_; |
my $sender=$env{'environment.firstname'}.' '.$env{'environment.lastname'}; |
my $sender=$env{'environment.firstname'}.' '.$env{'environment.lastname'}; |
unless ($sender=~/\w/) { |
unless ($sender=~/\w/) { |
$sender=$env{'user.name'}.'@'.$env{'user.domain'}; |
$sender=$env{'user.name'}.':'.$env{'user.domain'}; |
} |
} |
my $critical=($crit?' critical':''); |
my $critical=($crit?' critical':''); |
|
|
$text=~s/\<\;/\</gs; |
$text=~s/\<\;/\</gs; |
$text=~s/\>\;/\>/gs; |
$text=~s/\>\;/\>/gs; |
$text=~s/\<\/*[^\>]+\>//gs; |
|
my $url='http://'. |
my $url='http://'. |
&Apache::lonnet::hostname(&Apache::lonnet::homeserver($touname,$toudom)). |
&Apache::lonnet::hostname(&Apache::lonnet::homeserver($touname,$toudom)). |
'/adm/email?username='.$touname.'&domain='.$toudom; |
'/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; |
my ($coursetext,$body,$bodybegin,$bodysubj,$bodyend); |
if ($fromcid ne '') { |
if ($fromcid ne '') { |
$coursetext = "\n".&mt('Course').': '; |
$coursetext = "\n".&mt('Course').': '; |
if ($env{'course.'.$fromcid.'.description'} ne '') { |
if ($env{'course.'.$fromcid.'.description'} ne '') { |
Line 312 sub sendnotification {
|
Line 323 sub sendnotification {
|
} |
} |
$coursetext .= "\n\n"; |
$coursetext .= "\n\n"; |
} |
} |
my $body = $coursetext. |
my @recipients = split(/,/,$to); |
&mt('You received a'.$critical.' message from [_1] in LON-CAPA.',$sender).' '.&mt('The subject is |
$bodybegin = $coursetext. |
|
&mt('You received a'.$critical.' message from [_1] in LON-CAPA.',$sender).' '; |
|
$bodysubj = &mt('The subject is |
|
|
[_1] |
[_1] |
|
|
',$subj)."\n". |
',$subj)."\n". |
'=== '.&mt('Excerpt')." ============================================================ |
'=== '.&mt('Excerpt')." ============================================================ |
$text |
"; |
|
$bodyend = " |
======================================================================== |
======================================================================== |
|
|
".&mt('Use |
".&mt('Use |
Line 327 $text
|
Line 341 $text
|
[_1] |
[_1] |
|
|
to access the full message.',$url); |
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; |
|
|
|
my ($blocked,$blocktext); |
|
if (!$crit) { |
|
my %setters; |
|
my ($startblock,$endblock) = |
|
&Apache::loncommon::blockcheck(\%setters,'com',$touname,$toudom); |
|
if ($startblock && $endblock) { |
|
$blocked = 1; |
|
my $showstart = &Apache::lonlocal::locallocaltime($startblock); |
|
my $showend = &Apache::lonlocal::locallocaltime($endblock); |
|
$blocktext = &mt('LON-CAPA messages sent to you between [_1] and [_2] will be inaccessible until the end of this time period, because you are a student in a course with an active communications block.',$showstart,$showend); |
|
} |
|
} |
|
if ($userenv{'notifywithhtml'} ne '') { |
|
my @htmlexcerpt = split(/,/,$userenv{'notifywithhtml'}); |
|
foreach my $addr (@recipients) { |
|
if ($blocked) { |
|
$body = $bodybegin."\n".$blocktext."\n".$bodyend; |
|
} else { |
|
my $sendtext = $text; |
|
if (!grep/^\Q$addr\E/,@htmlexcerpt) { |
|
$sendtext =~ s/\<\/*[^\>]+\>//gs; |
|
} |
|
$body = $bodybegin.$bodysubj.$sendtext.$bodyend; |
|
} |
|
&sendemail($addr,$subject,$body); |
|
} |
|
} else { |
|
if ($blocked) { |
|
$body = $bodybegin."\n".$blocktext."\n".$bodyend; |
|
} else { |
|
$text =~ s/\<\/*[^\>]+\>//gs; |
|
$body = $bodybegin.$bodysubj.$text.$bodyend; |
|
} |
|
&sendemail($to,$subject,$body); |
|
} |
} |
} |
# ============================================================= Check for email |
# ============================================================= Check for email |
|
|
Line 460 sub user_crit_msg_raw {
|
Line 511 sub user_crit_msg_raw {
|
undef,undef,undef,undef,undef,undef,undef, |
undef,undef,undef,undef,undef,undef,undef, |
undef,$recipid); |
undef,$recipid); |
if ($sendback) { $packed_message.='<sendback>true</sendback>'; } |
if ($sendback) { $packed_message.='<sendback>true</sendback>'; } |
$status=&Apache::lonnet::critical( |
$status=&Apache::lonnet::cput('critical', {$msgid => $packed_message}, |
'put:'.$domain.':'.$user.':critical:'. |
$domain,$user); |
&escape($msgid).'='. |
|
&escape($packed_message),$homeserver); |
|
if (defined($sentmessage)) { |
if (defined($sentmessage)) { |
$$sentmessage = $packed_message; |
$$sentmessage = $packed_message; |
} |
} |
Line 551 sub user_crit_received {
|
Line 600 sub user_crit_received {
|
my $msgid=shift; |
my $msgid=shift; |
my %message=&Apache::lonnet::get('critical',[$msgid]); |
my %message=&Apache::lonnet::get('critical',[$msgid]); |
my %contents=&unpackagemsg($message{$msgid},1); |
my %contents=&unpackagemsg($message{$msgid},1); |
|
my $destname = $contents{'sendername'}; |
|
my $destdom = $contents{'senderdomain'}; |
|
if ($contents{'replytoaddr'}) { |
|
my ($repname,$repdom) = split(/:/,$contents{'replytoaddr'}); |
|
if (&Apache::lonnet::homeserver($repname,$repdom) ne 'no_host') { |
|
$destname = $repname; |
|
$destdom = $repdom; |
|
} |
|
} |
my $status='rec: '.($contents{'sendback'}? |
my $status='rec: '.($contents{'sendback'}? |
&user_normal_msg($contents{'sendername'},$contents{'senderdomain'}, |
&user_normal_msg($destname,$destdom,&mt('Receipt').': '.$env{'user.name'}. |
&mt('Receipt').': '.$env{'user.name'}.' '.&mt('at').' '.$env{'user.domain'}.', '.$contents{'subject'}, |
' '.&mt('at').' '.$env{'user.domain'}.', '. |
&mt('User').' '.$env{'user.name'}.' '.&mt('at').' '.$env{'user.domain'}. |
$contents{'subject'},&mt('User').' '.$env{'user.name'}. |
' acknowledged receipt of message'."\n".' "'. |
' '.&mt('at').' '.$env{'user.domain'}. |
$contents{'subject'}.'"'."\n".&mt('dated').' '. |
' acknowledged receipt of message'."\n".' "'. |
$contents{'time'}.".\n" |
$contents{'subject'}.'"'."\n".&mt('dated').' '. |
):'no msg req'); |
$contents{'time'}.".\n" |
|
):'no msg req'); |
$status.=' trans: '. |
$status.=' trans: '. |
&Apache::lonnet::put( |
&Apache::lonnet::put( |
'nohist_email',{$contents{'msgid'} => $message{$msgid}}); |
'nohist_email',{$contents{'msgid'} => $message{$msgid}}); |
Line 590 sub user_normal_msg_raw {
|
Line 649 sub user_normal_msg_raw {
|
undef,$crsmsgid,$symb,$error,$recipid); |
undef,$crsmsgid,$symb,$error,$recipid); |
|
|
# Store in user folder |
# Store in user folder |
$status=&Apache::lonnet::critical( |
$status= |
'put:'.$domain.':'.$user.':nohist_email:'. |
&Apache::lonnet::cput('nohist_email',{$msgid => $packed_message}, |
&escape($msgid).'='. |
$domain,$user); |
&escape($packed_message),$homeserver); |
|
# Save new message received time |
# Save new message received time |
&Apache::lonnet::put |
&Apache::lonnet::put |
('email_status',{'recnewemail'=>time},$domain,$user); |
('email_status',{'recnewemail'=>time},$domain,$user); |
Line 613 sub user_normal_msg_raw {
|
Line 671 sub user_normal_msg_raw {
|
$$sentmessage = $packed_message; |
$$sentmessage = $packed_message; |
} |
} |
# Notifications |
# Notifications |
my %userenv = &Apache::lonnet::get('environment',['notification', |
my %userenv = &Apache::loncommon::getemails($user,$domain); |
'permanentemail'], |
|
$domain,$user); |
|
if ($userenv{'notification'}) { |
if ($userenv{'notification'}) { |
&sendnotification($userenv{'notification'},$user,$domain,$subject,0, |
&sendnotification($userenv{'notification'},$user,$domain,$subject,0, |
$text,$msgid); |
$text,$msgid); |
Line 681 sub user_normal_msg {
|
Line 737 sub user_normal_msg {
|
} |
} |
|
|
sub process_sent_mail { |
sub process_sent_mail { |
my ($msgsubj,$subj_prefix,$numsent,$stamp,$msgname,$msgdom,$msgcount,$context,$pid,$savemsg,$recusers,$recudoms,$baseurl,$attachmenturl,$symb,$error,$senderuname,$senderdom,$senderhome) = @_; |
my ($msgsubj,$subj_prefix,$numsent,$stamp,$msgname,$msgdom,$msgcount,$context,$pid,$savemsg,$recusers,$recudoms,$baseurl,$attachmenturl,$symb,$error,$senderuname,$senderdom) = @_; |
my $sentsubj; |
my $sentsubj; |
if ($numsent > 1) { |
if ($numsent > 1) { |
$sentsubj = $subj_prefix.' ('.$numsent.' sent) '.$msgsubj; |
$sentsubj = $subj_prefix.' ('.$numsent.' sent) '.$msgsubj; |
|
} else { |
|
if ($subj_prefix) { |
|
$sentsubj = $subj_prefix.' '; |
|
} |
|
$sentsubj .= $msgsubj; |
} |
} |
$sentsubj = &HTML::Entities::encode($sentsubj,'<>&"'); |
$sentsubj = &HTML::Entities::encode($sentsubj,'<>&"'); |
my $sentmsgid = |
my $sentmsgid = |
Line 693 sub process_sent_mail {
|
Line 754 sub process_sent_mail {
|
&packagemsg($msgsubj,$savemsg,undef,$baseurl,$attachmenturl,$recusers, |
&packagemsg($msgsubj,$savemsg,undef,$baseurl,$attachmenturl,$recusers, |
$recudoms,$sentmsgid,undef,undef,$symb,$error); |
$recudoms,$sentmsgid,undef,undef,$symb,$error); |
my $status = &store_sent_mail($sentmsgid,$sentmessage,$senderuname, |
my $status = &store_sent_mail($sentmsgid,$sentmessage,$senderuname, |
$senderdom,$senderhome); |
$senderdom); |
return $status; |
return $status; |
} |
} |
|
|
sub store_sent_mail { |
sub store_sent_mail { |
my ($msgid,$message,$senderuname,$senderdom,$senderhome) = @_; |
my ($msgid,$message,$senderuname,$senderdom) = @_; |
if ($senderuname eq '') { |
if ($senderuname eq '') { |
$senderuname = $env{'user.name'}; |
$senderuname = $env{'user.name'}; |
} |
} |
if ($senderdom eq '') { |
if ($senderdom eq '') { |
$senderdom = $env{'user.domain'}; |
$senderdom = $env{'user.domain'}; |
} |
} |
if ($senderhome eq '') { |
my $status =' '.&Apache::lonnet::cput('nohist_email_sent', |
$senderhome = $env{'user.home'}; |
{$msgid => $message}, |
} |
$senderdom,$senderuname); |
my $status =' '.&Apache::lonnet::critical( |
|
'put:'.$senderdom.':'.$senderuname.':nohist_email_sent:'. |
|
&escape($msgid).'='.&escape($message),$senderhome); |
|
return $status; |
return $status; |
} |
} |
|
|