--- loncom/interface/lonmsg.pm 2004/11/11 18:24:44 1.113
+++ loncom/interface/lonmsg.pm 2004/11/13 14:45:57 1.117
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Routines for messaging
#
-# $Id: lonmsg.pm,v 1.113 2004/11/11 18:24:44 www Exp $
+# $Id: lonmsg.pm,v 1.117 2004/11/13 14:45:57 www Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -523,6 +523,7 @@ sub folderlist {
&mt('Folder').': '.
&Apache::loncommon::select_form($folder,'folder',
('' => &mt('INBOX'),'trash' => &mt('TRASH'),
+ 'new' => &mt('New Messages Only'),
'critical' => &mt('Critical'),
'sent' => &mt('Sent Messages'),
map { $_ => $_ } @allfolders)).
@@ -530,13 +531,12 @@ sub folderlist {
&Apache::loncommon::select_form($interdis,'interdis',
(' 10' => '10', ' 20' => '20', ' 50' => '50', '100' => '100', '200' => '200')).
'
'.
+ ($folder!~/^(new|critical)/?
''.
''.
- ''.
+ ''.
''.
- ''.
- ''.
- &mt('View Critical Messages').''.
+ '':'').
'';
}
@@ -571,7 +571,8 @@ sub makefolder {
my ($newfolder)=@_;
if (($newfolder eq 'sent')
|| ($newfolder eq 'critical')
- || ($newfolder eq 'trash')) { return; }
+ || ($newfolder eq 'trash')
+ || ($newfolder eq 'new')) { return; }
&Apache::lonnet::put('email_folders',{$newfolder => time});
}
@@ -863,13 +864,19 @@ ENDLINK
sub disall {
my ($r,$folder)=@_;
$r->print(&folderlist($folder));
- unless ($folder) {
- &disnew();
- return;
- }
- if ($folder eq 'critical') {
- &discrit();
+ if ($folder eq 'new') {
+ &disnew($r);
+ } elsif ($folder eq 'critical') {
+ &discrit($r);
+ } else {
+ &disfolder($r,$folder);
}
+}
+
+# ============================================================ Display a folder
+
+sub disfolder {
+ my ($r,$folder)=@_;
my %blocked = ();
my %setters = ();
my $startblock;
@@ -1021,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',
@@ -1050,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]);
@@ -1063,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'}; }
@@ -1104,6 +1121,7 @@ $latexHelp
$dispcrit
+$disbase
$citation
@@ -1728,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).'');
@@ -1793,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
@@ -1843,6 +1959,19 @@ sub handler {
unless ($startdis) { $startdis=0; }
$interdis=$ENV{'form.interdis'};
unless ($interdis) { $interdis=20; }
+ if ($ENV{'form.firstview'}) {
+ $startdis=0;
+ }
+ if ($ENV{'form.lastview'}) {
+ $startdis=-1;
+ }
+ if ($ENV{'form.prevview'}) {
+ $startdis--;
+ }
+ if ($ENV{'form.nextview'}) {
+ $startdis++;
+ }
+
# --------------------------------------------------------------- Render Output
@@ -1908,97 +2037,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'});