--- loncom/interface/lonmsg.pm 2006/01/23 23:15:51 1.173
+++ loncom/interface/lonmsg.pm 2006/03/15 21:55:43 1.176
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Routines for messaging
#
-# $Id: lonmsg.pm,v 1.173 2006/01/23 23:15:51 albertel Exp $
+# $Id: lonmsg.pm,v 1.176 2006/03/15 21:55:43 albertel Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -137,7 +137,7 @@ my $interdis;
sub packagemsg {
my ($subject,$message,$citation,$baseurl,$attachmenturl,
- $recuser,$recdomain,$msgid,$type)=@_;
+ $recuser,$recdomain,$msgid,$type,$crsmsgid)=@_;
$message =&HTML::Entities::encode($message,'<>&"');
$citation=&HTML::Entities::encode($citation,'<>&"');
$subject =&HTML::Entities::encode($subject,'<>&"');
@@ -170,11 +170,19 @@ sub packagemsg {
$msgid = &buildmsgid($now,$subject,$env{'user.name'},$env{'user.domain'},
$msgcount,$course_context,$$);
}
- my $result=''.$env{'user.name'}.''.
+ my $result = ''.$env{'user.name'}.''.
''.$env{'user.domain'}.''.
''.$subject.''.
- ''.
- ''.$ENV{'SERVER_NAME'}.''.
+ '';
+ if (defined($crsmsgid)) {
+ $result.= ''.$course_context.''.
+ ''.$env{'request.course.sec'}.''.
+ ''.$msgid.''.
+ ''.$crsmsgid.''.
+ ''.$message.'';
+ return ($msgid,$result);
+ }
+ $result .= ''.$ENV{'SERVER_NAME'}.''.
''.$ENV{'HTTP_HOST'}.''.
''.$ENV{'REMOTE_ADDR'}.''.
''.$env{'browser.type'}.''.
@@ -536,7 +544,7 @@ sub user_crit_received {
sub user_normal_msg_raw {
my ($user,$domain,$subject,$message,$citation,$baseurl,$attachmenturl,
- $toperm,$currid,$newid,$sentmessage)=@_;
+ $toperm,$currid,$newid,$sentmessage,$crsmsgid)=@_;
# Check if allowed missing
my ($status,$packed_message);
my $msgid='undefined';
@@ -546,10 +554,9 @@ sub user_normal_msg_raw {
if ($homeserver ne 'no_host') {
($msgid,$packed_message)=
&packagemsg($subject,$message,$citation,$baseurl,
- $attachmenturl,$user,$domain,$currid);
- (undef, my $packed_message_no_citation)=
- &packagemsg($subject,$message,undef ,$baseurl,
- $attachmenturl,$user,$domain,$currid);
+ $attachmenturl,$user,$domain,$currid,
+ undef,$crsmsgid);
+
# Store in user folder
$status=&Apache::lonnet::critical(
'put:'.$domain.':'.$user.':nohist_email:'.
@@ -565,6 +572,11 @@ sub user_normal_msg_raw {
(&Apache::lonnet::allowed('srm',$env{'request.course.id'})
|| &Apache::lonnet::allowed('srm',$env{'request.course.id'}.
'/'.$env{'request.course.sec'})))) {
+ (undef, my $packed_message_no_citation)=
+ &packagemsg($subject,$message,undef ,$baseurl,
+ $attachmenturl,$user,$domain,$currid,
+ undef,$crsmsgid);
+
$status .= &store_sent_mail($msgid,$packed_message_no_citation);
}
} else {
@@ -762,7 +774,7 @@ sub discourse {
for (i=0; i' . $crithelp .
'
'.
-''; }
+'';
+ }
my %message;
my %content;
my $defdom=$env{'user.domain'};
@@ -1424,17 +1437,29 @@ sub disfacetoface {
} elsif ($content{'subject'}=~/^Broadcast/) {
$result .=''.&mt('Broadcast Message').'
';
if ($content{'subject'}=~/^Broadcast\./) {
- %content=&unpackagemsg($content{'message'});
- $content{'message'}=
+ if (defined($content{'coursemsgid'})) {
+ my $crsmsgid = &Apache::lonnet::escape($content{'coursemsgid'});
+ my $broadcast_message = &general_message($crsmsgid);
+ $content{'message'} = ''.&mt('Subject').': '.$content{'message'}.'
'.$broadcast_message;
+ } else {
+ %content=&unpackagemsg($content{'message'});
+ $content{'message'} =
''.&mt('Subject').': '.$content{'subject'}.'
'.
$content{'message'};
+ }
}
} else {
$result.=''.&mt('Critical Message').'
';
- %content=&unpackagemsg($content{'message'});
- $content{'message'}=
+ if (defined($content{'coursemsgid'})) {
+ my $crsmsgid=&Apache::lonnet::escape($content{'coursemsgid'});
+ my $critical_message = &general_message($crsmsgid);
+ $content{'message'} = ''.&mt('Subject').': '.$content{'message'}.'
'.$critical_message;
+ } else {
+ %content=&unpackagemsg($content{'message'});
+ $content{'message'}=
''.&mt('Subject').': '.$content{'subject'}.'
'.
$content{'message'};
+ }
}
$result.=&mt('By').': '.
&Apache::loncommon::aboutmewrapper(
@@ -1457,6 +1482,18 @@ $content{'sendername'}.'@'.
}
}
+sub general_message {
+ my ($crsmsgid) = @_;
+ my %general_content;
+ if ($crsmsgid) {
+ my %course_content = &Apache::lonnet::get('nohist_email',[$crsmsgid],
+ $env{'course.'.$env{'request.course.id'}.'.domain'},
+ $env{'course.'.$env{'request.course.id'}.'.num'});
+ %general_content = &unpackagemsg($course_content{$crsmsgid});
+ }
+ return $general_content{'message'};
+}
+
# ---------------------------------------------------------------- Face to face
sub facetoface {
@@ -2160,6 +2197,7 @@ sub sendoffmail {
my $savemsg;
my $msgtype;
my %sentmessage;
+ my $msgsubj=&Apache::lonfeedback::clear_out_html($env{'form.subject'});
if ((($env{'form.critmsg'}) || ($env{'form.sendbck'})) &&
(&Apache::lonnet::allowed('srm',$env{'request.course.id'})
|| &Apache::lonnet::allowed('srm',$env{'request.course.id'}.
@@ -2181,15 +2219,12 @@ sub sendoffmail {
|| &Apache::lonnet::allowed('srm',$env{'request.course.id'}.
'/'.$env{'request.course.sec'}))) {
$r->print(&mt('Sending critical message').' '.$recuname.'@'.$recdomain.': ');
- $thismsg=&user_crit_msg($recuname,$recdomain,
- &Apache::lonfeedback::clear_out_html($env{'form.subject'}),
- $msgtxt,
- $env{'form.sendbck'},$env{'form.permanent'},\$sentmessage{$_});
+ $thismsg=&user_crit_msg($recuname,$recdomain,$msgsubj,$msgtxt,
+ $env{'form.sendbck'},$env{'form.permanent'},
+ \$sentmessage{$_});
} else {
$r->print(&mt('Sending').' '.$recuname.'@'.$recdomain.': ');
- $thismsg=&user_normal_msg($recuname,$recdomain,
- &Apache::lonfeedback::clear_out_html($env{'form.subject'}),
- $msgtxt,
+ $thismsg=&user_normal_msg($recuname,$recdomain,$msgsubj,$msgtxt,
$content{'citation'},undef,undef,$env{'form.permanent'},\$sentmessage{$_});
}
if (($env{'request.course.id'}) && (($msgtype eq 'critical') ||
@@ -2225,7 +2260,7 @@ sub sendoffmail {
my $record_sent;
my @recusers = ();
my @recudoms = ();
- my ($stamp,$msgsubj,$msgname,$msgdom,$msgcount,$context,$pid) =
+ my ($stamp,$crssubj,$msgname,$msgdom,$msgcount,$context,$pid) =
split(/\:/,&Apache::lonnet::unescape($specialmsgid));
foreach my $recipient (sort(keys(%toaddr))) {
if ($specialmsg_status{$recipient} eq 'ok') {
@@ -2233,8 +2268,8 @@ sub sendoffmail {
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);
+ ' ['.$recipient.']',$msgsubj,undef,
+ undef,undef,undef,$usermsgid,undef,undef,$specialmsgid);
my ($uname,$udom) = split/:/,$recipient;
push(@recusers,$uname);
push(@recudoms,$udom);
@@ -2243,14 +2278,12 @@ sub sendoffmail {
if (@recusers) {
my $specialmessage;
my $sentsubj = $subj_prefix.' ('.$numspecial.' sent) '.
- &Apache::lonfeedback::clear_out_html($env{'form.subject'});
+ $msgsubj;
$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);
+ ($specialmsgid,$specialmessage) = &packagemsg($msgsubj,$savemsg,
+ undef,undef,undef,\@recusers,\@recudoms,$sentmsgid);
$record_sent = &store_sent_mail($specialmsgid,$specialmessage);
}
} else {