'.&mt('Currently available actions (will open extra window)').': | ');
- my $symb=&Apache::lonnet::symbread($content{'baseurl'});
if (&Apache::lonnet::allowed('vgr',$env{'request.course.id'})) {
$r->print(''.&Apache::loncommon::track_student_link(&mt('View recent activity'),$content{'sendername'},$content{'senderdomain'},'check').' | ');
}
@@ -1916,6 +2019,17 @@ sub displaymessage {
' ('.$content{'recuser'}[$i].' at '.$content{'recdomain'}[$i].') ';
}
$tolist = join(', ',@recipients);
+ my ($restitle,$baseurl,$refers_to);
+ if (defined($content{'resource_title'})) {
+ $restitle = $content{'resource_title'};
+ } else {
+ if (defined($content{'baseurl'})) {
+ $restitle = &Apache::lonnet::gettitle($content{'baseurl'});
+ }
+ }
+ if (defined($content{'baseurl'})) {
+ $baseurl = &Apache::lonenc::check_encrypt($content{'baseurl'});
+ }
$r->print('
'.&mt('Subject').': '.$content{'subject'}.
($folder ne 'sent'?'
'.&mt('From').': '.
&Apache::loncommon::aboutmewrapper(
@@ -1926,13 +2040,46 @@ sub displaymessage {
$tolist).
($content{'courseid'}?'
'.&mt($crstype).': '.$courseinfo{'description'}.
($content{'coursesec'}?' ('.&mt('Section').': '.$content{'coursesec'}.')':''):'').
- '
'.&mt('Time').': '.$content{'time'}.
- ($content{'baseurl'}?'
'.&mt('Refers to').': '.
- $content{'baseurl'}.' ('.&Apache::lonnet::gettitle($content{'baseurl'}).')':'').
- ''.
+ '
'.&mt('Time').': '.$content{'time'});
+ if ($baseurl) {
+ if (defined($content{'courseid'}) && defined($env{'request.course.id'})) {
+ if ($content{'courseid'} eq $env{'request.course.id'}) {
+ my $symblink;
+ if ($symb) {
+ &Apache::lonenc::check_decrypt(\$symb);
+ $symblink = '?symb='.$symb;
+ }
+ &Apache::lonenc::check_decrypt(\$baseurl);
+ $r->print('
'.&mt('Refers to').': '.$restitle.'');
+ $refers_to = 1;
+ }
+ }
+ if (!$refers_to) {
+ if ($baseurl =~ m-^/enc/-) {
+ if (defined($content{'courseid'})) {
+ my $unencurl =
+ &Apache::lonenc::unencrypted($baseurl,
+ $content{'courseid'});
+ if (defined($unencurl)) {
+ if (&Apache::lonnet::allowed('bre',$unencurl)) {
+ $r->print('
'.&mt('Refers to').
+ ': '.$restitle.'');
+ }
+ }
+ }
+ } else {
+ if (&Apache::lonnet::allowed('bre',$baseurl)) {
+ $r->print('
'.&mt('Refers to').
+ ': '.$restitle.'');
+ }
+ }
+ }
+ }
+ $r->print(''.
&Apache::lontexconvert::msgtexconverted($content{'message'},1).
'
'.&displayresource(%content).'');
- return;
+ return;
}
# =========================================================== Show the citation
@@ -1945,7 +2092,12 @@ sub displayresource {
#
if (($env{'request.course.id'} eq $content{'courseid'})
&& (&Apache::lonnet::allowed('vgr',$content{'courseid'}))) {
- my $symb=&Apache::lonnet::symbread($content{'baseurl'});
+ my $symb;
+ if (defined($content{'symb'})) {
+ $symb = $content{'symb'};
+ } else {
+ $symb=&Apache::lonnet::symbread($content{'baseurl'});
+ }
# Could not get a symb, give up
unless ($symb) { return $content{'citation'}; }
# Have a symb, can render
@@ -2047,10 +2199,12 @@ sub sendoffmail {
$cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
}
if ($env{'form.send'}) {
- if ($group eq '') {
- &printheader($r,'','Messages being sent.');
- } else {
- $r->print(&groupmail_header('sending',$group));
+ if (!$env{'form.multiforward'}) {
+ if ($group eq '') {
+ &printheader($r,'','Messages being sent.');
+ } else {
+ $r->print(&groupmail_header('sending',$group));
+ }
}
$r->rflush();
my %content=();
@@ -2228,20 +2382,24 @@ sub sendoffmail {
} else {
&printheader($r,'','No messages sent.');
}
- if ($sendstatus=~/^(\s*(?:ok|con_delayed)\s*)*$/) {
- $r->print('
'.&mt('Completed.').'');
- if ($env{'form.displayedcrit'}) {
- &discrit($r);
- }
- if ($group ne '') {
- $r->print(&groupmail_sent($group,$cdom,$cnum));
- } else {
- &Apache::loncommunicate::menu($r);
- }
- } else {
- $r->print(''.&mt('Could not deliver message').' '.
+ if (!$env{'form.multiforward'}) {
+ if ($sendstatus=~/^(\s*(?:ok|con_delayed)\s*)*$/) {
+ $r->print('
'.&mt('Completed.').
+ '');
+ if ($env{'form.displayedcrit'}) {
+ &discrit($r);
+ }
+ if ($group ne '') {
+ $r->print(&groupmail_sent($group,$cdom,$cnum));
+ } 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 '."($sendstatus)").'
');
+ }
}
+ return $sendstatus;
}
# ===================================================================== Handler
@@ -2261,7 +2419,8 @@ sub handler {
['display','replyto','forward','markread','markdel','markunread',
'sendreply','compose','sendmail','critical','recname','recdom',
'recordftf','sortedby','block','folder','startdis','interdis',
- 'showcommentbaseurl','dismode','group','subject','text','ref']);
+ 'showcommentbaseurl','dismode','group','subject','text','ref',
+ 'msgstatus']);
$sqs='&sortedby='.$env{'form.sortedby'};
# ------------------------------------------------------ They checked for email
@@ -2295,15 +2454,13 @@ sub handler {
}
# --------------------------------------------------------------------- Display
-
+ my $msgstatus = $env{'form.msgstatus'};
$startdis=$env{'form.startdis'};
- $startdis--;
+ if ($startdis ne '') {
+ $startdis--;
+ }
unless ($startdis) { $startdis=0; }
- $interdis=$env{'form.interdis'};
- unless ($interdis) { $interdis=20; }
- $sqs.='&interdis='.$interdis;
-
if ($env{'form.firstview'}) {
$startdis=0;
}
@@ -2322,7 +2479,7 @@ sub handler {
# --------------------------------------------------------------- Render Output
if ($env{'form.display'}) {
- &displaymessage($r,$env{'form.display'},$folder);
+ &displaymessage($r,$env{'form.display'},$folder,$msgstatus);
} elsif ($env{'form.replyto'}) {
&compout($r,'',$env{'form.replyto'},undef,undef,$folder,$dismode);
} elsif ($env{'form.confirm'}) {
@@ -2359,47 +2516,82 @@ sub handler {
''.$msg."
\n");
}
&Apache::loncommunicate::menu($r);
- &disall($r,($folder?$folder:$dismode));
- } elsif ($env{'form.markedmove'}) {
- my ($total,$failed,@failed_msg)=(0,0);
- foreach my $key (keys(%env)) {
- if ($key=~/^form\.delmark_(.*)$/) {
- my ($result,$msg) =
- &movemsg(&unescape($1),$folder,
- $env{'form.movetofolder'});
- if ($result) {
+ &disall($r,($folder?$folder:$dismode),$msgstatus);
+ } elsif ($env{'form.markedaction'} eq 'markedforward') {
+ my $total = 0;
+ my @to_forward = &Apache::loncommon::get_env_multiple('form.delmark');
+ foreach my $msgid (@to_forward) {
+ &statuschange(&unescape($msgid),'forwarded',$folder);
+ $total ++;
+ }
+ if ($total > 0) {
+ &compout($r,undef,undef,undef,undef,$folder,$dismode,$total);
+ }
+ } elsif ($env{'form.markedaction'} eq 'markedread') {
+ my $total = 0;
+ my @to_markread = &Apache::loncommon::get_env_multiple('form.delmark');
+ foreach my $msgid (@to_markread) {
+ &statuschange(&unescape($msgid),'read',$folder);
+ $total ++;
+ }
+ &printheader($r,'','Marked Messages Read');
+ $r->print(&mt('Marked [_1] message(s) read',$total).'');
+ &Apache::loncommunicate::menu($r);
+ &disall($r,($folder?$folder:$dismode),$msgstatus);
+ } elsif ($env{'form.markedaction'} eq 'markedunread') {
+ my $total = 0;
+ my @to_markunread = &Apache::loncommon::get_env_multiple('form.delmark');
+ foreach my $msgid (@to_markunread) {
+ &statuschange(&unescape($msgid),'new',$folder);
+ $total ++;
+ }
+ &printheader($r,'','Marked Messages Unread');
+ $r->print(&mt('Marked [_1] message(s) unread',$total).'
');
+ &Apache::loncommunicate::menu($r);
+ &disall($r,($folder?$folder:$dismode),$msgstatus);
+ } elsif ($env{'form.markedaction'} eq 'markedmove') {
+ my $destfolder = $env{'form.movetofolder'};
+ my %gotfolders = &Apache::lonmsg::get_user_folders();
+ &printheader($r,'','Moved Messages');
+ if (!defined($gotfolders{$destfolder})) {
+ $r->print(&mt('Destination folder [_1] is not a valid folder',
+ $destfolder));
+ } else {
+ my ($total,$failed,@failed_msg)=(0,0);
+ my @to_move = &Apache::loncommon::get_env_multiple('form.delmark');
+ foreach my $msgid (@to_move) {
+ my ($result,$msg) = &movemsg(&unescape($msgid),$folder,
+ $env{'form.movetofolder'});
+ if ($result) {
$total++;
- } else {
+ } else {
$failed++;
push(@failed_msg,$msg);
- }
+ }
}
- }
- &printheader($r,'','Moved Messages');
- if ($failed) {
- $r->print('
+ if ($failed) {
+ $r->print('
'.&mt('Failed to move [_1] message(s)',$failed).
'
');
- $r->print(''.
- join("
\n",@failed_msg).
- "
\n");
- }
- $r->print(&mt('Moved [_1] message(s)',$total).'');
+ $r->print('
'.
+ join("
\n",@failed_msg).
+ "
\n");
+ }
+ $r->print(&mt('Moved [_1] message(s)',$total).'');
+ }
&Apache::loncommunicate::menu($r);
- &disall($r,($folder?$folder:$dismode));
- } elsif ($env{'form.markeddel'}) {
+ &disall($r,($folder?$folder:$dismode),$msgstatus);
+ } elsif ($env{'form.markedaction'} eq 'markeddel') {
my ($total,$failed,@failed_msg)=(0,0);
- foreach my $key (keys(%env)) {
- if ($key=~/^form\.delmark_(.*)$/) {
- my ($result,$msg) =
- &statuschange(&unescape($1),'deleted',
- $folder);
- if ($result) {
- $total++;
- } else {
- $failed++;
- push(@failed_msg,$msg);
- }
+ my @to_delete = &Apache::loncommon::get_env_multiple('form.delmark');
+ foreach my $msgid (@to_delete) {
+ my ($result,$msg) = &statuschange(&unescape($msgid),'deleted',
+ $folder);
+ if ($result) {
+ $total++;
+ } else {
+ $failed++;
+ push(@failed_msg,$msg);
}
}
&printheader($r,'','Deleted Messages');
@@ -2413,12 +2605,12 @@ sub handler {
}
$r->print(&mt('Deleted [_1] message(s)',$total).'
');
&Apache::loncommunicate::menu($r);
- &disall($r,($folder?$folder:$dismode));
+ &disall($r,($folder?$folder:$dismode),$msgstatus);
} elsif ($env{'form.markunread'}) {
&printheader($r,'','Marked Message as Unread');
&statuschange($env{'form.markunread'},'new');
&Apache::loncommunicate::menu($r);
- &disall($r,($folder?$folder:$dismode));
+ &disall($r,($folder?$folder:$dismode),$msgstatus);
} elsif ($env{'form.compose'}) {
&compout($r,'','',$env{'form.compose'});
} elsif ($env{'form.recordftf'}) {
@@ -2426,7 +2618,63 @@ sub handler {
} elsif ($env{'form.block'}) {
&examblock($r,$env{'form.block'});
} elsif ($env{'form.sendmail'}) {
- &sendoffmail($r,$folder);
+ if ($env{'form.multiforward'}) {
+ &printheader($r,'','Messages being sent.');
+ my $fixed_subj = $env{'form.subject'};
+ my $suffix=&Apache::lonmsg::foldersuffix($folder);
+ my (%sendresult,%forwardok,%forwardfail,$fwdcount);
+ my @to_forward = &Apache::loncommon::get_env_multiple('form.delmark');
+ foreach my $item (@to_forward) {
+ my $msgid=&unescape($item);
+ my %message=&Apache::lonnet::get('nohist_email'.$suffix,[$msgid]);
+ my %content=&Apache::lonmsg::unpackagemsg($message{$msgid},1);
+ if ($env{'form.showorigsubj'}) {
+ $env{'form.subject'} = $fixed_subj.$content{'subject'};
+ } else {
+ $env{'form.subject'} = '';
+ }
+ my $uname = $content{'sendername'};
+ my $udom = $content{'senderdomain'};
+ &statuschange($msgid,'forwarded',$folder);
+ if ($env{'form.showorigsender'}) {
+ $env{'form.message'} = $env{'form.msgheader'}.' '.
+ &Apache::loncommon::plainname($uname,$udom).' ('.
+ $uname.':'.$udom.')';
+ }
+ $env{'form.message'} .= "\n\n-- Forwarded message --\n\n".
+ $content{'message'};
+ $fwdcount ++;
+ $r->print($fwdcount.': ');
+ $sendresult{$msgid} = &sendoffmail($r,$folder);
+ $r->print('
');
+ }
+ foreach my $key (keys(%sendresult)) {
+ if ($sendresult{$key} =~/^(\s*(?:ok|con_delayed)\s*)*$/) {
+ $forwardok{$key} = $sendresult{$key};
+ } else {
+ $forwardfail{$key} = $sendresult{$key};
+ }
+ }
+ if (keys(%forwardok) > 0) {
+ my $count = keys(%forwardok);
+ $r->print('
'.
+ &mt('[quant,_1,message] forwarded.',$count).
+ '');
+ }
+ if (keys(%forwardfail) > 0) {
+ my $count = keys(%forwardfail);
+ $r->print('
'.
+ &mt('Could not forward [quant,_1,message].',$count).
+ ' ');
+ foreach my $key (keys(%forwardfail)) {
+ $r->print(&mt('Could not deliver forwarded message.').' '.
+ &mt('The recipient addresses may need to be corrected').' ('.$forwardfail{$key}.').
');
+ }
+ }
+ &Apache::loncommunicate::menu($r);
+ } else {
+ &sendoffmail($r,$folder);
+ }
if ($env{'form.storebasecomment'}) {
&storecomment($r);
}
@@ -2438,7 +2686,7 @@ sub handler {
$env{'form.message'},'/adm/communicate','public');
}
if ((!exists($env{'form.group'})) && (!$env{'form.displayedcrit'})) {
- &disall($r,($folder?$folder:$dismode));
+ &disall($r,($folder?$folder:$dismode),$msgstatus);
}
} elsif ($env{'form.newfolder'}) {
&printheader($r,'','New Folder');
@@ -2452,7 +2700,7 @@ sub handler {
$showfolder = $folder;
}
&Apache::loncommunicate::menu($r);
- &disall($r,$showfolder);
+ &disall($r,$showfolder,$msgstatus);
} elsif ($env{'form.showcommentbaseurl'}) {
&storedcommentlisting($r);
} elsif ($env{'form.folderaction'} eq 'delete') {
@@ -2466,7 +2714,7 @@ sub handler {
$showfolder = $folder;
}
&Apache::loncommunicate::menu($r);
- &disall($r,$showfolder);
+ &disall($r,$showfolder,$msgstatus);
} elsif ($env{'form.folderaction'} eq 'rename') {
&printheader($r,'','Renamed Folder');
my $showfolder = $env{'form.renamed'};
@@ -2478,11 +2726,11 @@ sub handler {
$showfolder = $folder;
}
&Apache::loncommunicate::menu($r);
- &disall($r,$showfolder);
+ &disall($r,$showfolder,$msgstatus);
} else {
&printheader($r,'','Display All Messages');
&Apache::loncommunicate::menu($r);
- &disall($r,($folder?$folder:$dismode));
+ &disall($r,($folder?$folder:$dismode),$msgstatus);
}
$r->print(&Apache::loncommon::end_page());
return OK;