version 1.158, 2005/11/28 20:14:43
|
version 1.161, 2005/12/05 22:16:52
|
Line 142 sub packagemsg {
|
Line 142 sub packagemsg {
|
split(/\:/,&Apache::lonnet::unescape($env{'form.replyid'})); |
split(/\:/,&Apache::lonnet::unescape($env{'form.replyid'})); |
$course_context = $origcid; |
$course_context = $origcid; |
} |
} |
|
foreach my $key (keys(%env)) { |
|
if ($key=~/^form\.(rep)?rec\_(.*)$/) { |
|
my ($sendtime,$shortsubj,$fromname,$fromdomain,$count,$origcid) = |
|
split(/\:/,&Apache::lonnet::unescape($2)); |
|
$course_context = $origcid; |
|
last; |
|
} |
|
} |
unless(defined($course_context)) { |
unless(defined($course_context)) { |
$course_context = $env{'request.course.id'}; |
$course_context = $env{'request.course.id'}; |
} |
} |
my $now=time; |
my $now=time; |
$msgcount++; |
$msgcount++; |
my $partsubj=$subject; |
|
$partsubj=&Apache::lonnet::escape($partsubj); |
|
unless(defined($msgid)) { |
unless(defined($msgid)) { |
$msgid=&Apache::lonnet::escape( |
$msgid = &buildmsgid($now,$subject,$env{'user.name'},$env{'user.domain'}, |
$now.':'.$partsubj.':'.$env{'user.name'}.':'. |
$msgcount,$course_context,$$); |
$env{'user.domain'}.':'.$msgcount.':'. |
|
$course_context.':'.$$); |
|
} |
} |
my $result='<sendername>'.$env{'user.name'}.'</sendername>'. |
my $result='<sendername>'.$env{'user.name'}.'</sendername>'. |
'<senderdomain>'.$env{'user.domain'}.'</senderdomain>'. |
'<senderdomain>'.$env{'user.domain'}.'</senderdomain>'. |
Line 229 sub unpackagemsg {
|
Line 233 sub unpackagemsg {
|
|
|
# ======================================================= Get info out of msgid |
# ======================================================= Get info out of msgid |
|
|
|
sub buildmsgid { |
|
my ($now,$subject,$uname,$udom,$msgcount,$course_context,$pid) = @_; |
|
$subject=&Apache::lonnet::escape($subject); |
|
return(&Apache::lonnet::escape($now.':'.$subject.':'.$uname.':'. |
|
$udom.':'.$msgcount.':'.$course_context.':'.$pid)); |
|
} |
|
|
sub unpackmsgid { |
sub unpackmsgid { |
my ($msgid,$folder)=@_; |
my ($msgid,$folder)=@_; |
$msgid=&Apache::lonnet::unescape($msgid); |
$msgid=&Apache::lonnet::unescape($msgid); |
Line 389 sub all_url_author_res_msg {
|
Line 400 sub all_url_author_res_msg {
|
# ================================================== Critical message to a user |
# ================================================== Critical message to a user |
|
|
sub user_crit_msg_raw { |
sub user_crit_msg_raw { |
my ($user,$domain,$subject,$message,$sendback,$toperm)=@_; |
my ($user,$domain,$subject,$message,$sendback,$toperm,$sentmessage)=@_; |
# Check if allowed missing |
# Check if allowed missing |
my $status=''; |
my $status=''; |
my $msgid='undefined'; |
my $msgid='undefined'; |
Line 403 sub user_crit_msg_raw {
|
Line 414 sub user_crit_msg_raw {
|
'put:'.$domain.':'.$user.':critical:'. |
'put:'.$domain.':'.$user.':critical:'. |
&Apache::lonnet::escape($msgid).'='. |
&Apache::lonnet::escape($msgid).'='. |
&Apache::lonnet::escape($message),$homeserver); |
&Apache::lonnet::escape($message),$homeserver); |
if ($env{'request.course.id'}) { |
if (defined($sentmessage)) { |
&user_normal_msg_raw( |
$$sentmessage = $message; |
$env{'course.'.$env{'request.course.id'}.'.num'}, |
} |
$env{'course.'.$env{'request.course.id'}.'.domain'}, |
|
'Critical ['.$user.':'.$domain.']', |
|
$message); |
|
} |
|
} else { |
} else { |
$status='no_host'; |
$status='no_host'; |
} |
} |
Line 447 sub user_crit_msg_raw {
|
Line 454 sub user_crit_msg_raw {
|
=cut |
=cut |
|
|
sub user_crit_msg { |
sub user_crit_msg { |
my ($user,$domain,$subject,$message,$sendback,$toperm)=@_; |
my ($user,$domain,$subject,$message,$sendback,$toperm,$sentmessage)=@_; |
my $status=''; |
my $status=''; |
my %userenv = &Apache::lonnet::get('environment',['msgforward'], |
my %userenv = &Apache::lonnet::get('environment',['msgforward'], |
$domain,$user); |
$domain,$user); |
Line 457 sub user_crit_msg {
|
Line 464 sub user_crit_msg {
|
my ($forwuser,$forwdomain)=split(/\:/,$_); |
my ($forwuser,$forwdomain)=split(/\:/,$_); |
$status.= |
$status.= |
&user_crit_msg_raw($forwuser,$forwdomain,$subject,$message, |
&user_crit_msg_raw($forwuser,$forwdomain,$subject,$message, |
$sendback,$toperm).' '; |
$sendback,$toperm,$sentmessage).' '; |
} |
} |
} else { |
} else { |
$status=&user_crit_msg_raw($user,$domain,$subject,$message,$sendback,$toperm); |
$status=&user_crit_msg_raw($user,$domain,$subject,$message,$sendback,$toperm,$sentmessage); |
} |
} |
return $status; |
return $status; |
} |
} |
Line 495 sub user_crit_received {
|
Line 502 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,$newid)=@_; |
$toperm,$currid,$newid,$sentmessage)=@_; |
# Check if allowed missing |
# Check if allowed missing |
my $status=''; |
my $status=''; |
my $msgid='undefined'; |
my $msgid='undefined'; |
Line 504 sub user_normal_msg_raw {
|
Line 511 sub user_normal_msg_raw {
|
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,$message)=&packagemsg($subject,$message,$citation,$baseurl, |
($msgid,$message)=&packagemsg($subject,$message,$citation,$baseurl, |
$attachmenturl,$user,$domain); |
$attachmenturl,$user,$domain,$currid); |
# Store in user folder |
# Store in user folder |
$status=&Apache::lonnet::critical( |
$status=&Apache::lonnet::critical( |
'put:'.$domain.':'.$user.':nohist_email:'. |
'put:'.$domain.':'.$user.':nohist_email:'. |
Line 513 sub user_normal_msg_raw {
|
Line 520 sub user_normal_msg_raw {
|
# 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); |
# Into sent-mail folder unless a broadcast message |
# Into sent-mail folder unless a broadcast message or critical message |
unless (($env{'request.course.id'}) && ($env{'form.sendmode'} eq 'group')) { |
unless (($env{'request.course.id'}) && |
|
(($env{'form.sendmode'} eq 'group') || |
|
(($env{'form.critmsg'}) || ($env{'form.sendbck'})) && |
|
(&Apache::lonnet::allowed('srm',$env{'request.course.id'})))) { |
$status .= &store_sent_mail($msgid,$message); |
$status .= &store_sent_mail($msgid,$message); |
} |
} |
} else { |
} else { |
Line 523 sub user_normal_msg_raw {
|
Line 533 sub user_normal_msg_raw {
|
if (defined($newid)) { |
if (defined($newid)) { |
$$newid = $msgid; |
$$newid = $msgid; |
} |
} |
|
if (defined($sentmessage)) { |
|
$$sentmessage = $message; |
|
} |
|
|
# Notifications |
# Notifications |
my %userenv = &Apache::lonnet::get('environment',['notification', |
my %userenv = &Apache::lonnet::get('environment',['notification', |
'permanentemail'], |
'permanentemail'], |
Line 553 sub user_normal_msg_raw {
|
Line 567 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)=@_; |
$toperm,$sentmessage)=@_; |
my $status=''; |
my $status=''; |
my %userenv = &Apache::lonnet::get('environment',['msgforward'], |
my %userenv = &Apache::lonnet::get('environment',['msgforward'], |
$domain,$user); |
$domain,$user); |
Line 563 sub user_normal_msg {
|
Line 577 sub user_normal_msg {
|
my ($forwuser,$forwdomain)=split(/\:/,$_); |
my ($forwuser,$forwdomain)=split(/\:/,$_); |
$status.= |
$status.= |
&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).' '; |
} |
} |
} else { |
} else { |
$status=&user_normal_msg_raw($user,$domain,$subject,$message, |
$status=&user_normal_msg_raw($user,$domain,$subject,$message, |
$citation,$baseurl,$attachmenturl,$toperm); |
$citation,$baseurl,$attachmenturl,$toperm,undef,undef,$sentmessage); |
} |
} |
return $status; |
return $status; |
} |
} |
Line 1175 sub compout {
|
Line 1189 sub compout {
|
&mt('and return receipt') . '</label>' . $crithelp . |
&mt('and return receipt') . '</label>' . $crithelp . |
'</p><p><label><input type="checkbox" name="permanent" /> '. |
'</p><p><label><input type="checkbox" name="permanent" /> '. |
&mt('Send copy to permanent email address (if known)').'</label></p>'. |
&mt('Send copy to permanent email address (if known)').'</label></p>'. |
'<p><label><input type="checkbox" name="rsspost" /> '. |
'<!-- <p><label><input type="checkbox" name="rsspost" /> '. |
&mt('Include in course RSS newsfeed').'</label></p>'; } |
&mt('Include in course RSS newsfeed').'</label></p>-->'; } |
my %message; |
my %message; |
my %content; |
my %content; |
my $defdom=$env{'user.domain'}; |
my $defdom=$env{'user.domain'}; |
Line 1346 sub disfacetoface {
|
Line 1360 sub disfacetoface {
|
$result.='<h3>'.&mt('Record').'</h3>'; |
$result.='<h3>'.&mt('Record').'</h3>'; |
} elsif ($content{'subject'}=~/^Broadcast/) { |
} elsif ($content{'subject'}=~/^Broadcast/) { |
$result .='<h3>'.&mt('Broadcast Message').'</h3>'; |
$result .='<h3>'.&mt('Broadcast Message').'</h3>'; |
|
if ($content{'subject'}=~/^Broadcast\./) { |
|
%content=&unpackagemsg($content{'message'}); |
|
$content{'message'}= |
|
'<b>'.&mt('Subject').': '.$content{'subject'}.'</b><br />'. |
|
$content{'message'}; |
|
} |
} else { |
} else { |
$result.='<h3>'.&mt('Critical Message').'</h3>'; |
$result.='<h3>'.&mt('Critical Message').'</h3>'; |
%content=&unpackagemsg($content{'message'}); |
%content=&unpackagemsg($content{'message'}); |
Line 1421 ENDTREC
|
Line 1441 ENDTREC
|
($env{'form.recdomain'}) && ($env{'form.recuname'})) { |
($env{'form.recdomain'}) && ($env{'form.recuname'})) { |
chomp($env{'form.newrecord'}); |
chomp($env{'form.newrecord'}); |
if ($env{'form.newrecord'}) { |
if ($env{'form.newrecord'}) { |
|
my $recordtxt = $env{'form.newrecord'}; |
&user_normal_msg_raw( |
&user_normal_msg_raw( |
$env{'course.'.$env{'request.course.id'}.'.num'}, |
$env{'course.'.$env{'request.course.id'}.'.num'}, |
$env{'course.'.$env{'request.course.id'}.'.domain'}, |
$env{'course.'.$env{'request.course.id'}.'.domain'}, |
&mt('Record'). |
&mt('Record'). |
' ['.$env{'form.recuname'}.':'.$env{'form.recdomain'}.']', |
' ['.$env{'form.recuname'}.':'.$env{'form.recdomain'}.']', |
$env{'form.newrecord'}); |
$recordtxt); |
} |
} |
$r->print('<h3>'.&Apache::loncommon::plainname($env{'form.recuname'}, |
$r->print('<h3>'.&Apache::loncommon::plainname($env{'form.recuname'}, |
$env{'form.recdomain'}).'</h3>'); |
$env{'form.recdomain'}).'</h3>'); |
Line 2017 sub sendoffmail {
|
Line 2038 sub sendoffmail {
|
my ($r,$folder)=@_; |
my ($r,$folder)=@_; |
my $suffix=&foldersuffix($folder); |
my $suffix=&foldersuffix($folder); |
my $sendstatus=''; |
my $sendstatus=''; |
my %broadcast_status; |
my %specialmsg_status; |
my $numbroadcast = 0; |
my $numspecial = 0; |
if ($env{'form.send'}) { |
if ($env{'form.send'}) { |
&printheader($r,'','Messages being sent.'); |
&printheader($r,'','Messages being sent.'); |
$r->rflush(); |
$r->rflush(); |
Line 2064 sub sendoffmail {
|
Line 2085 sub sendoffmail {
|
} |
} |
} |
} |
|
|
my $basicmsg; |
my $savemsg; |
my $msgtype; |
my $msgtype; |
|
my %sentmessage; |
if ((($env{'form.critmsg'}) || ($env{'form.sendbck'})) && |
if ((($env{'form.critmsg'}) || ($env{'form.sendbck'})) && |
(&Apache::lonnet::allowed('srm',$env{'request.course.id'}))) { |
(&Apache::lonnet::allowed('srm',$env{'request.course.id'}))) { |
$basicmsg=&Apache::lonfeedback::clear_out_html($env{'form.message'},1); |
$savemsg=&Apache::lonfeedback::clear_out_html($env{'form.message'},1); |
$msgtype = '(critical)'; |
$msgtype = 'critical'; |
} else { |
} else { |
$basicmsg=&Apache::lonfeedback::clear_out_html($env{'form.message'}); |
$savemsg=&Apache::lonfeedback::clear_out_html($env{'form.message'}); |
} |
} |
|
|
foreach (keys %toaddr) { |
foreach (keys %toaddr) { |
my ($recuname,$recdomain)=split(/\:/,$_); |
my ($recuname,$recdomain)=split(/\:/,$_); |
my $msgtxt = $basicmsg; |
my $msgtxt = $savemsg; |
if ($toaddr{$_}) { $msgtxt.='<hr />'.$toaddr{$_}; } |
if ($toaddr{$_}) { $msgtxt.='<hr />'.$toaddr{$_}; } |
my $thismsg; |
my $thismsg; |
if ((($env{'form.critmsg'}) || ($env{'form.sendbck'})) && |
if ((($env{'form.critmsg'}) || ($env{'form.sendbck'})) && |
Line 2085 sub sendoffmail {
|
Line 2107 sub sendoffmail {
|
$thismsg=&user_crit_msg($recuname,$recdomain, |
$thismsg=&user_crit_msg($recuname,$recdomain, |
&Apache::lonfeedback::clear_out_html($env{'form.subject'}), |
&Apache::lonfeedback::clear_out_html($env{'form.subject'}), |
$msgtxt, |
$msgtxt, |
$env{'form.sendbck'},$env{'form.permanent'}); |
$env{'form.sendbck'},$env{'form.permanent'},\$sentmessage{$_}); |
} else { |
} else { |
$r->print(&mt('Sending').' '.$recuname.'@'.$recdomain.': '); |
$r->print(&mt('Sending').' '.$recuname.'@'.$recdomain.': '); |
$thismsg=&user_normal_msg($recuname,$recdomain, |
$thismsg=&user_normal_msg($recuname,$recdomain, |
&Apache::lonfeedback::clear_out_html($env{'form.subject'}), |
&Apache::lonfeedback::clear_out_html($env{'form.subject'}), |
$msgtxt, |
$msgtxt, |
$content{'citation'},undef,undef,$env{'form.permanent'}); |
$content{'citation'},undef,undef,$env{'form.permanent'},\$sentmessage{$_}); |
} |
} |
if (($env{'request.course.id'}) && |
if (($env{'request.course.id'}) && (($msgtype eq 'critical') || |
($env{'form.sendmode'} eq 'group')) { |
($env{'form.sendmode'} eq 'group'))) { |
$broadcast_status{$recuname.':'.$recdomain} = $thismsg; |
$specialmsg_status{$recuname.':'.$recdomain} = $thismsg; |
if ($thismsg eq 'ok') { |
if ($thismsg eq 'ok') { |
$numbroadcast ++; |
$numspecial ++; |
} |
} |
} |
} |
$r->print($thismsg.'<br />'); |
$r->print($thismsg.'<br />'); |
$sendstatus.=' '.$thismsg; |
$sendstatus.=' '.$thismsg; |
} |
} |
if (($env{'request.course.id'}) && ($env{'form.sendmode'} eq 'group')) { |
if (($env{'request.course.id'}) && (($env{'form.sendmode'} eq 'group') |
|
|| ($msgtype eq 'critical'))) { |
my $subj_prefix; |
my $subj_prefix; |
if ($msgtype eq 'critical') { |
if ($msgtype eq 'critical') { |
$subj_prefix = 'Critical broadcast'; |
$subj_prefix = 'Critical.'; |
} else { |
} else { |
$subj_prefix = 'Broadcast'; |
$subj_prefix = 'Broadcast.'; |
} |
} |
my ($broadmsgid,$broadresult); |
my ($specialmsgid,$specialresult); |
if ($numbroadcast) { |
my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'}; |
$broadresult = &user_normal_msg_raw( |
my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'}; |
$env{'course.'.$env{'request.course.id'}.'.num'}, |
my $course_str = &Apache::lonnet::escape('['.$cnum.':'.$cdom.']'); |
$env{'course.'.$env{'request.course.id'}.'.domain'}, $subj_prefix.' to: '.$env{'course.'.$env{'request.course.id'}.'.description'}. |
|
' ('.$numbroadcast.' sent)',$basicmsg,undef,undef,undef, |
if ($numspecial) { |
undef,\$broadmsgid); |
$specialresult = &user_normal_msg_raw($cnum,$cdom,$subj_prefix. |
|
' '.$course_str,$savemsg,undef,undef,undef, |
|
undef,undef,\$specialmsgid); |
|
$specialmsgid = &Apache::lonnet::unescape($specialmsgid); |
} |
} |
if ($broadresult eq 'ok') { |
if ($specialresult eq 'ok') { |
my $record_sent; |
my $record_sent; |
my @recusers = (); |
my @recusers = (); |
my @recudoms = (); |
my @recudoms = (); |
|
my ($stamp,$msgsubj,$msgname,$msgdom,$msgcount,$context,$pid) = |
|
split(/\:/,&Apache::lonnet::unescape($specialmsgid)); |
foreach my $recipient (sort(keys(%toaddr))) { |
foreach my $recipient (sort(keys(%toaddr))) { |
if ($broadcast_status{$recipient} eq 'ok') { |
if ($specialmsg_status{$recipient} eq 'ok') { |
|
my $usersubj = $subj_prefix.'['.$recipient.']'; |
|
my $usermsgid = &buildmsgid($stamp,$usersubj,$msgname, |
|
$msgdom,$msgcount,$context,$pid); |
|
&user_normal_msg_raw($cnum,$cdom,$subj_prefix. |
|
' ['.$recipient.']',$sentmessage{$recipient}, |
|
undef,undef,undef,undef,$usermsgid); |
my ($uname,$udom) = split/:/,$recipient; |
my ($uname,$udom) = split/:/,$recipient; |
push(@recusers,$uname); |
push(@recusers,$uname); |
push(@recudoms,$udom); |
push(@recudoms,$udom); |
} |
} |
} |
} |
if (@recusers) { |
if (@recusers) { |
my $broadmessage; |
my $specialmessage; |
($broadmsgid,$broadmessage)=&packagemsg(&Apache::lonfeedback::clear_out_html($env{'form.subject'}),$basicmsg,undef,undef,undef,\@recusers,\@recudoms,$broadmsgid); |
my $sentsubj = $subj_prefix.' ('.$numspecial.' sent) '. |
$record_sent = &store_sent_mail($broadmsgid,$broadmessage); |
&Apache::lonfeedback::clear_out_html($env{'form.subject'}); |
|
$sentsubj = &HTML::Entities::encode($sentsubj,'<>&"'); |
|
my $sentmsgid = &buildmsgid($stamp,$sentsubj,$msgname, |
|
$msgdom,$msgcount,$context,$pid); |
|
($specialmsgid,$specialmessage) = |
|
&packagemsg(&Apache::lonfeedback::clear_out_html( |
|
$env{'form.subject'}),$savemsg,undef,undef,undef, |
|
\@recusers,\@recudoms,$sentmsgid); |
|
$record_sent = &store_sent_mail($specialmsgid,$specialmessage); |
} |
} |
} else { |
} else { |
&Apache::lonnet::logthis('Failed to create record of broadcast in '.$env{'course.'.$env{'request.course.id'}.'.num'}.' at '.$env{'course.'.$env{'request.course.id'}.'.domain'}.' - no msgid generated'); |
&Apache::lonnet::logthis('Failed to create record of critical message or broadcast in '.$env{'course.'.$env{'request.course.id'}.'.num'}.' at '.$env{'course.'.$env{'request.course.id'}.'.domain'}.' - no msgid generated'); |
} |
} |
} |
} |
} else { |
} else { |