version 1.206, 2007/05/08 17:23:10
|
version 1.211, 2008/03/12 02:45:07
|
Line 299 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; |
my $url='http://'. |
my $url='http://'. |
Line 309 sub sendnotification {
|
Line 310 sub sendnotification {
|
'/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,$body,$bodystart,$bodyend); |
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 323 sub sendnotification {
|
Line 324 sub sendnotification {
|
$coursetext .= "\n\n"; |
$coursetext .= "\n\n"; |
} |
} |
my @recipients = split(/,/,$to); |
my @recipients = split(/,/,$to); |
$bodystart = $coursetext. |
$bodybegin = $coursetext. |
&mt('You received a'.$critical.' message from [_1] in LON-CAPA.',$sender).' '.&mt('The subject is |
&mt('You received a'.$critical.' message from [_1] in LON-CAPA.',$sender).' '; |
|
$bodysubj = &mt('The subject is |
|
|
[_1] |
[_1] |
|
|
Line 341 sub sendnotification {
|
Line 343 sub sendnotification {
|
to access the full message.',$url); |
to access the full message.',$url); |
my %userenv = &Apache::lonnet::get('environment',['notifywithhtml'],$toudom,$touname); |
my %userenv = &Apache::lonnet::get('environment',['notifywithhtml'],$toudom,$touname); |
my $subject = &mt("'New' $critical message from ").$sender; |
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 '') { |
if ($userenv{'notifywithhtml'} ne '') { |
my @htmlexcerpt = split(/,/,$userenv{'notifywithhtml'}); |
my @htmlexcerpt = split(/,/,$userenv{'notifywithhtml'}); |
foreach my $addr (@recipients) { |
foreach my $addr (@recipients) { |
my $sendtext = $text; |
if ($blocked) { |
if (!grep/^\Q$addr\E/,@htmlexcerpt) { |
$body = $bodybegin."\n".$blocktext."\n".$bodyend; |
$sendtext =~ s/\<\/*[^\>]+\>//gs; |
} else { |
|
my $sendtext = $text; |
|
if (!grep/^\Q$addr\E/,@htmlexcerpt) { |
|
$sendtext =~ s/\<\/*[^\>]+\>//gs; |
|
} |
|
$body = $bodybegin.$bodysubj.$sendtext.$bodyend; |
} |
} |
$body = $bodystart.$sendtext.$bodyend; |
|
&sendemail($addr,$subject,$body); |
&sendemail($addr,$subject,$body); |
} |
} |
} else { |
} else { |
$body = $bodystart.$text.$bodyend; |
if ($blocked) { |
$text =~ s/\<\/*[^\>]+\>//gs; |
$body = $bodybegin."\n".$blocktext."\n".$bodyend; |
|
} else { |
|
$text =~ s/\<\/*[^\>]+\>//gs; |
|
$body = $bodybegin.$bodysubj.$text.$bodyend; |
|
} |
&sendemail($to,$subject,$body); |
&sendemail($to,$subject,$body); |
} |
} |
} |
} |
Line 362 to access the full message.',$url);
|
Line 385 to access the full message.',$url);
|
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}); |
if ($what{'recnewemail'}>0) { return 1; } |
if ($what{'recnewemail'}>0) { return 1; } |
} |
} |
return 0; |
return 0; |
Line 488 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 628 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 717 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; |
Line 734 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; |
} |
} |
|
|