version 1.201, 2007/05/01 18:40:57
|
version 1.205, 2007/05/08 16:50:02
|
Line 78 use LONCAPA qw(:DEFAULT :match);
|
Line 78 use LONCAPA qw(:DEFAULT :match);
|
|
|
sub packagemsg { |
sub packagemsg { |
my ($subject,$message,$citation,$baseurl,$attachmenturl, |
my ($subject,$message,$citation,$baseurl,$attachmenturl, |
$recuser,$recdomain,$msgid,$type,$crsmsgid,$symb,$error)=@_; |
$recuser,$recdomain,$msgid,$type,$crsmsgid,$symb,$error,$recipid)=@_; |
$message =&HTML::Entities::encode($message,'<>&"'); |
$message =&HTML::Entities::encode($message,'<>&"'); |
$citation=&HTML::Entities::encode($citation,'<>&"'); |
$citation=&HTML::Entities::encode($citation,'<>&"'); |
$subject =&HTML::Entities::encode($subject,'<>&"'); |
$subject =&HTML::Entities::encode($subject,'<>&"'); |
Line 160 sub packagemsg {
|
Line 160 sub packagemsg {
|
} |
} |
} |
} |
} |
} |
|
if (defined($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 445 sub store_instructor_comment {
|
Line 459 sub store_instructor_comment {
|
|
|
sub user_crit_msg_raw { |
sub user_crit_msg_raw { |
my ($user,$domain,$subject,$message,$sendback,$toperm,$sentmessage, |
my ($user,$domain,$subject,$message,$sendback,$toperm,$sentmessage, |
$nosentstore)=@_; |
$nosentstore,$recipid)=@_; |
# Check if allowed missing |
# Check if allowed missing |
my ($status,$packed_message); |
my ($status,$packed_message); |
my $msgid='undefined'; |
my $msgid='undefined'; |
Line 453 sub user_crit_msg_raw {
|
Line 467 sub user_crit_msg_raw {
|
my $text=$message; |
my $text=$message; |
my $homeserver=&Apache::lonnet::homeserver($user,$domain); |
my $homeserver=&Apache::lonnet::homeserver($user,$domain); |
if ($homeserver ne 'no_host') { |
if ($homeserver ne 'no_host') { |
($msgid,$packed_message)=&packagemsg($subject,$message); |
($msgid,$packed_message)=&packagemsg($subject,$message,undef,undef, |
|
undef,undef,undef,undef,undef,undef,undef, |
|
undef,$recipid); |
if ($sendback) { $packed_message.='<sendback>true</sendback>'; } |
if ($sendback) { $packed_message.='<sendback>true</sendback>'; } |
$status=&Apache::lonnet::critical( |
$status=&Apache::lonnet::critical( |
'put:'.$domain.':'.$user.':critical:'. |
'put:'.$domain.':'.$user.':critical:'. |
Line 499 sub user_crit_msg_raw {
|
Line 515 sub user_crit_msg_raw {
|
|
|
=pod |
=pod |
|
|
=item * B<user_crit_msg($user, $domain, $subject, $message, $sendback, $nosentstore)>: |
=item * B<user_crit_msg($user, $domain, $subject, $message, $sendback, $nosentstore,$recipid)>: |
Sends a critical message $message to the $user at $domain. If $sendback |
Sends a critical message $message to the $user at $domain. If $sendback |
is true, a receipt will be sent to the current user when $user receives |
is true, a receipt will be sent to the current user when $user receives |
the message. |
the message. |
Line 516 sub user_crit_msg_raw {
|
Line 532 sub user_crit_msg_raw {
|
|
|
sub user_crit_msg { |
sub user_crit_msg { |
my ($user,$domain,$subject,$message,$sendback,$toperm,$sentmessage, |
my ($user,$domain,$subject,$message,$sendback,$toperm,$sentmessage, |
$nosentstore)=@_; |
$nosentstore,$recipid)=@_; |
my @status; |
my @status; |
my %userenv = &Apache::lonnet::get('environment',['msgforward'], |
my %userenv = &Apache::lonnet::get('environment',['msgforward'], |
$domain,$user); |
$domain,$user); |
Line 526 sub user_crit_msg {
|
Line 542 sub user_crit_msg {
|
my ($forwuser,$forwdomain)=split(/\:/,$addr); |
my ($forwuser,$forwdomain)=split(/\:/,$addr); |
push(@status, |
push(@status, |
&user_crit_msg_raw($forwuser,$forwdomain,$subject,$message, |
&user_crit_msg_raw($forwuser,$forwdomain,$subject,$message, |
$sendback,$toperm,$sentmessage,$nosentstore)); |
$sendback,$toperm,$sentmessage,$nosentstore, |
|
$recipid)); |
} |
} |
} else { |
} else { |
push(@status, |
push(@status, |
&user_crit_msg_raw($user,$domain,$subject,$message,$sendback, |
&user_crit_msg_raw($user,$domain,$subject,$message,$sendback, |
$toperm,$sentmessage,$nosentstore)); |
$toperm,$sentmessage,$nosentstore,$recipid)); |
} |
} |
if (wantarray) { |
if (wantarray) { |
return @status; |
return @status; |
Line 545 sub user_crit_received {
|
Line 562 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 570 sub user_crit_received {
|
Line 597 sub user_crit_received {
|
sub user_normal_msg_raw { |
sub user_normal_msg_raw { |
my ($user,$domain,$subject,$message,$citation,$baseurl,$attachmenturl, |
my ($user,$domain,$subject,$message,$citation,$baseurl,$attachmenturl, |
$toperm,$currid,$newid,$sentmessage,$crsmsgid,$symb,$restitle, |
$toperm,$currid,$newid,$sentmessage,$crsmsgid,$symb,$restitle, |
$error,$nosentstore)=@_; |
$error,$nosentstore,$recipid)=@_; |
# Check if allowed missing |
# Check if allowed missing |
my ($status,$packed_message); |
my ($status,$packed_message); |
my $msgid='undefined'; |
my $msgid='undefined'; |
Line 581 sub user_normal_msg_raw {
|
Line 608 sub user_normal_msg_raw {
|
($msgid,$packed_message)= |
($msgid,$packed_message)= |
&packagemsg($subject,$message,$citation,$baseurl, |
&packagemsg($subject,$message,$citation,$baseurl, |
$attachmenturl,$user,$domain,$currid, |
$attachmenturl,$user,$domain,$currid, |
undef,$crsmsgid,$symb,$error); |
undef,$crsmsgid,$symb,$error,$recipid); |
|
|
# Store in user folder |
# Store in user folder |
$status=&Apache::lonnet::critical( |
$status=&Apache::lonnet::critical( |
Line 633 sub user_normal_msg_raw {
|
Line 660 sub user_normal_msg_raw {
|
|
|
=item * B<user_normal_msg($user, $domain, $subject, $message, $citation, |
=item * B<user_normal_msg($user, $domain, $subject, $message, $citation, |
$baseurl, $attachmenturl, $toperm, $sentmessage, $symb, $restitle, |
$baseurl, $attachmenturl, $toperm, $sentmessage, $symb, $restitle, |
$error,$nosentstore)>: |
$error,$nosentstore,$recipid)>: |
Sends a message to the $user at $domain, with subject $subject and message $message. |
Sends a message to the $user at $domain, with subject $subject and message $message. |
|
|
Additionally it will check if the user has a Forwarding address |
Additionally it will check if the user has a Forwarding address |
Line 648 sub user_normal_msg_raw {
|
Line 675 sub user_normal_msg_raw {
|
|
|
sub user_normal_msg { |
sub user_normal_msg { |
my ($user,$domain,$subject,$message,$citation,$baseurl,$attachmenturl, |
my ($user,$domain,$subject,$message,$citation,$baseurl,$attachmenturl, |
$toperm,$sentmessage,$symb,$restitle,$error,$nosentstore)=@_; |
$toperm,$sentmessage,$symb,$restitle,$error,$nosentstore,$recipid)=@_; |
my @status; |
my @status; |
my %userenv = &Apache::lonnet::get('environment',['msgforward'], |
my %userenv = &Apache::lonnet::get('environment',['msgforward'], |
$domain,$user); |
$domain,$user); |
Line 660 sub user_normal_msg {
|
Line 687 sub user_normal_msg {
|
&user_normal_msg_raw($forwuser,$forwdomain,$subject,$message, |
&user_normal_msg_raw($forwuser,$forwdomain,$subject,$message, |
$citation,$baseurl,$attachmenturl,$toperm, |
$citation,$baseurl,$attachmenturl,$toperm, |
undef,undef,$sentmessage,undef,$symb, |
undef,undef,$sentmessage,undef,$symb, |
$restitle,$error,$nosentstore)); |
$restitle,$error,$nosentstore,$recipid)); |
} |
} |
} else { |
} else { |
push(@status,&user_normal_msg_raw($user,$domain,$subject,$message, |
push(@status,&user_normal_msg_raw($user,$domain,$subject,$message, |
$citation,$baseurl,$attachmenturl,$toperm, |
$citation,$baseurl,$attachmenturl,$toperm, |
undef,undef,$sentmessage,undef,$symb, |
undef,undef,$sentmessage,undef,$symb, |
$restitle,$error,$nosentstore)); |
$restitle,$error,$nosentstore,$recipid)); |
} |
} |
if (wantarray) { |
if (wantarray) { |
return @status; |
return @status; |
Line 679 sub process_sent_mail {
|
Line 706 sub process_sent_mail {
|
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 708 sub store_sent_mail {
|
Line 740 sub store_sent_mail {
|
return $status; |
return $status; |
} |
} |
|
|
|
sub store_recipients { |
|
my ($subject,$sendername,$senderdom,$reciphash) = @_; |
|
my $context = &get_course_context(); |
|
my $now = time(); |
|
my $msgcount = &get_uniq(); |
|
my $recipid = |
|
&buildmsgid($now,$subject,$sendername,$senderdom,$msgcount,$context,$$); |
|
my %recipinfo = ( |
|
$recipid => $reciphash, |
|
); |
|
my $status = &Apache::lonnet::put('nohist_emailrecip',\%recipinfo, |
|
$senderdom,$sendername); |
|
if ($status eq 'ok') { |
|
return ($recipid,$status); |
|
} else { |
|
return (undef,$status); |
|
} |
|
} |
|
|
# =============================================================== Folder suffix |
# =============================================================== Folder suffix |
|
|
sub foldersuffix { |
sub foldersuffix { |