--- loncom/interface/lonmsg.pm 2004/11/11 20:41:53 1.114
+++ loncom/interface/lonmsg.pm 2004/11/12 21:53:30 1.116
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Routines for messaging
#
-# $Id: lonmsg.pm,v 1.114 2004/11/11 20:41:53 www Exp $
+# $Id: lonmsg.pm,v 1.116 2004/11/12 21:53:30 albertel Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -1028,6 +1028,7 @@ sub compout {
my $dispcrit='';
my $dissub='';
my $dismsg='';
+ my $disbase='';
my $func=&mt('Send New');
my %lt=&Apache::lonlocal::texthash('us' => 'Username',
'do' => 'Domain',
@@ -1057,6 +1058,9 @@ sub compout {
$dissub=&mt('Forwarding').': '.$content{'subject'};
$dismsg=&mt('Forwarded message from').' '.
$content{'sendername'}.' '.&mt('at').' '.$content{'senderdomain'};
+ if ($content{'baseurl'}) {
+ $disbase='';
+ }
}
if ($replying) {
%message=&Apache::lonnet::get('nohist_email',[$replying]);
@@ -1070,6 +1074,12 @@ sub compout {
$dismsg=~s/\r/\n/g;
$dismsg=~s/\f/\n/g;
$dismsg=~s/\n+/\n\> /g;
+ if ($content{'baseurl'}) {
+ $disbase='';
+ if ($ENV{'user.adv'}) {
+ $disbase=''.&mt('Store message for re-use').'
';
+ }
+ }
}
my $citation=&displayresource(%content);
if ($ENV{'form.recdom'}) { $defdom=$ENV{'form.recdom'}; }
@@ -1111,6 +1121,7 @@ $latexHelp
$dispcrit
+$disbase
$citation
@@ -1735,6 +1746,8 @@ sub displaymessage {
($content{'courseid'}?'
'.&mt('Course').': '.$courseinfo{'description'}.
($content{'coursesec'}?' ('.&mt('Group/Section').': '.$content{'coursesec'}.')':''):'').
'
'.&mt('Time').': '.$content{'time'}.
+ ($content{'baseurl'}?'
'.&mt('Refers to').': '.
+ $content{'baseurl'}.' ('.&Apache::lonnet::gettitle($content{'baseurl'}).')':'').
''.
&Apache::lontexconvert::msgtexconverted($content{'message'},1).
'
'.&displayresource(%content).'');
@@ -1800,6 +1813,102 @@ sub printheader {
&header($r,$title,$baseurl);
}
+# ---------------------------------------------------------------- Send an email
+
+sub sendoffmail {
+ my ($r)=@_;
+ my $sendstatus='';
+ if ($ENV{'form.send'}) {
+ &printheader($r,'','Messages being sent.');
+ $r->rflush();
+ my %content=();
+ undef %content;
+ if ($ENV{'form.forwid'}) {
+ my $msgid=$ENV{'form.forwid'};
+ my %message=&Apache::lonnet::get('nohist_email',[$msgid]);
+ %content=&unpackagemsg($message{$msgid},1);
+ &statuschange($msgid,'forwarded');
+ $ENV{'form.message'}.="\n\n-- Forwarded message --\n\n".
+ $content{'message'};
+ }
+ if ($ENV{'form.replyid'}) {
+ my $msgid=$ENV{'form.replyid'};
+ my %message=&Apache::lonnet::get('nohist_email',[$msgid]);
+ %content=&unpackagemsg($message{$msgid},1);
+ &statuschange($msgid,'replied');
+ }
+ my %toaddr=();
+ undef %toaddr;
+ if ($ENV{'form.sendmode'} eq 'group') {
+ foreach (keys %ENV) {
+ if ($_=~/^form\.send\_to\_\&\&\&[^\&]*\&\&\&\_(.+)$/) {
+ $toaddr{$1}='';
+ }
+ }
+ } elsif ($ENV{'form.sendmode'} eq 'upload') {
+ foreach (split(/[\n\r\f]+/,$ENV{'form.upfile'})) {
+ my ($rec,$txt)=split(/\s*\:\s*/,$_);
+ if ($txt) {
+ $rec=~s/\@/\:/;
+ $toaddr{$rec}.=$txt."\n";
+ }
+ }
+ } else {
+ $toaddr{$ENV{'form.recuname'}.':'.$ENV{'form.recdomain'}}='';
+ }
+ if ($ENV{'form.additionalrec'}) {
+ foreach (split(/\,/,$ENV{'form.additionalrec'})) {
+ my ($auname,$audom)=split(/\@/,$_);
+ $toaddr{$auname.':'.$audom}='';
+ }
+ }
+
+ foreach (keys %toaddr) {
+ my ($recuname,$recdomain)=split(/\:/,$_);
+ my $msgtxt=&Apache::lonfeedback::clear_out_html($ENV{'form.message'});
+ if ($toaddr{$_}) { $msgtxt.='
'.$toaddr{$_}; }
+ my $thismsg;
+ if ((($ENV{'form.critmsg'}) || ($ENV{'form.sendbck'})) &&
+ (&Apache::lonnet::allowed('srm',$ENV{'request.course.id'}))) {
+ $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'});
+ } else {
+ $r->print(&mt('Sending').' '.$recuname.'@'.$recdomain.': ');
+ $thismsg=&user_normal_msg($recuname,$recdomain,
+ &Apache::lonfeedback::clear_out_html($ENV{'form.subject'}),
+ $msgtxt,
+ $content{'citation'});
+ if (($ENV{'request.course.id'}) && ($ENV{'form.sendmode'} eq 'group')) {
+ &user_normal_msg_raw(
+ $ENV{'course.'.$ENV{'request.course.id'}.'.num'},
+ $ENV{'course.'.$ENV{'request.course.id'}.'.domain'},
+ 'Broadcast ['.$recuname.':'.$recdomain.']',
+ $msgtxt);
+ }
+ }
+ $r->print($thismsg.'
');
+ $sendstatus.=' '.$thismsg;
+ }
+ } else {
+ &printheader($r,'','No messages sent.');
+ }
+ if ($sendstatus=~/^(\s*(?:ok|con_delayed)\s*)*$/) {
+ $r->print('
'.&mt('Completed.').'');
+ if ($ENV{'form.displayedcrit'}) {
+ &discrit($r);
+ } else {
+ &Apache::loncommunicate::menu($r);
+ }
+ } else {
+ $r->print(
+ ''.&mt('Could not deliver message').'
'.
+ &mt('Please use the browser "Back" button and correct the recipient addresses')
+ );
+ }
+}
# ===================================================================== Handler
@@ -1915,97 +2024,7 @@ sub handler {
} elsif ($ENV{'form.block'}) {
&examblock($r,$ENV{'form.block'});
} elsif ($ENV{'form.sendmail'}) {
- my $sendstatus='';
- if ($ENV{'form.send'}) {
- &printheader($r,'','Messages being sent.');
- $r->rflush();
- my %content=();
- undef %content;
- if ($ENV{'form.forwid'}) {
- my $msgid=$ENV{'form.forwid'};
- my %message=&Apache::lonnet::get('nohist_email',[$msgid]);
- %content=&unpackagemsg($message{$msgid},1);
- &statuschange($msgid,'forwarded');
- $ENV{'form.message'}.="\n\n-- Forwarded message --\n\n".
- $content{'message'};
- }
- if ($ENV{'form.replyid'}) {
- my $msgid=$ENV{'form.replyid'};
- my %message=&Apache::lonnet::get('nohist_email',[$msgid]);
- %content=&unpackagemsg($message{$msgid},1);
- &statuschange($msgid,'replied');
- }
- my %toaddr=();
- undef %toaddr;
- if ($ENV{'form.sendmode'} eq 'group') {
- foreach (keys %ENV) {
- if ($_=~/^form\.send\_to\_\&\&\&[^\&]*\&\&\&\_(.+)$/) {
- $toaddr{$1}='';
- }
- }
- } elsif ($ENV{'form.sendmode'} eq 'upload') {
- foreach (split(/[\n\r\f]+/,$ENV{'form.upfile'})) {
- my ($rec,$txt)=split(/\s*\:\s*/,$_);
- if ($txt) {
- $rec=~s/\@/\:/;
- $toaddr{$rec}.=$txt."\n";
- }
- }
- } else {
- $toaddr{$ENV{'form.recuname'}.':'.$ENV{'form.recdomain'}}='';
- }
- if ($ENV{'form.additionalrec'}) {
- foreach (split(/\,/,$ENV{'form.additionalrec'})) {
- my ($auname,$audom)=split(/\@/,$_);
- $toaddr{$auname.':'.$audom}='';
- }
- }
-
- foreach (keys %toaddr) {
- my ($recuname,$recdomain)=split(/\:/,$_);
- my $msgtxt=&Apache::lonfeedback::clear_out_html($ENV{'form.message'});
- if ($toaddr{$_}) { $msgtxt.='
'.$toaddr{$_}; }
- my $thismsg;
- if ((($ENV{'form.critmsg'}) || ($ENV{'form.sendbck'})) &&
- (&Apache::lonnet::allowed('srm',$ENV{'request.course.id'}))) {
- $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'});
- } else {
- $r->print(&mt('Sending').' '.$recuname.'@'.$recdomain.': ');
- $thismsg=&user_normal_msg($recuname,$recdomain,
- &Apache::lonfeedback::clear_out_html($ENV{'form.subject'}),
- $msgtxt,
- $content{'citation'});
- if (($ENV{'request.course.id'}) && ($ENV{'form.sendmode'} eq 'group')) {
- &user_normal_msg_raw(
- $ENV{'course.'.$ENV{'request.course.id'}.'.num'},
- $ENV{'course.'.$ENV{'request.course.id'}.'.domain'},
- 'Broadcast ['.$recuname.':'.$recdomain.']',
- $msgtxt);
- }
- }
- $r->print($thismsg.'
');
- $sendstatus.=' '.$thismsg;
- }
- } else {
- &printheader($r,'','No messages sent.');
- }
- if ($sendstatus=~/^(\s*(?:ok|con_delayed)\s*)*$/) {
- $r->print('
'.&mt('Completed.').'');
- if ($ENV{'form.displayedcrit'}) {
- &discrit($r);
- } else {
- &Apache::loncommunicate::menu($r);
- }
- } else {
- $r->print(
- ''.&mt('Could not deliver message').'
'.
- &mt('Please use the browser "Back" button and correct the recipient addresses')
- );
- }
+ &sendoffmail($r);
} elsif ($ENV{'form.newfolder'}) {
&printheader($r,'','New Folder');
&makefolder($ENV{'form.newfolder'});