--- loncom/interface/lonmsg.pm 2006/01/09 20:07:27 1.170
+++ loncom/interface/lonmsg.pm 2006/03/16 22:12:17 1.178
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Routines for messaging
#
-# $Id: lonmsg.pm,v 1.170 2006/01/09 20:07:27 albertel Exp $
+# $Id: lonmsg.pm,v 1.178 2006/03/16 22:12:17 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,21 +544,24 @@ 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='';
+ my ($status,$packed_message);
my $msgid='undefined';
my $text=$message;
unless (($message)&&($user)&&($domain)) { $status='empty'; };
my $homeserver=&Apache::lonnet::homeserver($user,$domain);
if ($homeserver ne 'no_host') {
- ($msgid,$message)=&packagemsg($subject,$message,$citation,$baseurl,
- $attachmenturl,$user,$domain,$currid);
+ ($msgid,$packed_message)=
+ &packagemsg($subject,$message,$citation,$baseurl,
+ $attachmenturl,$user,$domain,$currid,
+ undef,$crsmsgid);
+
# Store in user folder
$status=&Apache::lonnet::critical(
'put:'.$domain.':'.$user.':nohist_email:'.
&Apache::lonnet::escape($msgid).'='.
- &Apache::lonnet::escape($message),$homeserver);
+ &Apache::lonnet::escape($packed_message),$homeserver);
# Save new message received time
&Apache::lonnet::put
('email_status',{'recnewemail'=>time},$domain,$user);
@@ -561,7 +572,12 @@ 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'})))) {
- $status .= &store_sent_mail($msgid,$message);
+ (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 {
$status='no_host';
@@ -570,7 +586,7 @@ sub user_normal_msg_raw {
$$newid = $msgid;
}
if (defined($sentmessage)) {
- $$sentmessage = $message;
+ $$sentmessage = $packed_message;
}
# Notifications
@@ -609,26 +625,28 @@ sub user_normal_msg {
$domain,$user);
my $msgforward=$userenv{'msgforward'};
if ($msgforward) {
- foreach (split(/\,/,$msgforward)) {
- my ($forwuser,$forwdomain)=split(/\:/,$_);
- $status.=
- &user_normal_msg_raw($forwuser,$forwdomain,$subject,$message,
- $citation,$baseurl,$attachmenturl,$toperm,undef,undef,$sentmessage).' ';
- }
+ foreach (split(/\,/,$msgforward)) {
+ my ($forwuser,$forwdomain)=split(/\:/,$_);
+ $status.=
+ &user_normal_msg_raw($forwuser,$forwdomain,$subject,$message,
+ $citation,$baseurl,$attachmenturl,$toperm,
+ undef,undef,$sentmessage).' ';
+ }
} else {
$status=&user_normal_msg_raw($user,$domain,$subject,$message,
- $citation,$baseurl,$attachmenturl,$toperm,undef,undef,$sentmessage);
+ $citation,$baseurl,$attachmenturl,$toperm,
+ undef,undef,$sentmessage);
}
return $status;
}
sub store_sent_mail {
my ($msgid,$message) = @_;
- my $status =' '.&Apache::lonnet::critical(
- 'put:'.$env{'user.domain'}.':'.$env{'user.name'}.
- ':nohist_email_sent:'.
- &Apache::lonnet::escape($msgid).'='.
- &Apache::lonnet::escape($message),$env{'user.home'});
+ my $status =' '.&Apache::lonnet::critical(
+ 'put:'.$env{'user.domain'}.':'.$env{'user.name'}.
+ ':nohist_email_sent:'.
+ &Apache::lonnet::escape($msgid).'='.
+ &Apache::lonnet::escape($message),$env{'user.home'});
return $status;
}
@@ -756,7 +774,7 @@ sub discourse {
for (i=0; iprint("");
}
- $r->print(''.&Apache::loncommon::endbodytag().'