'.&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').' | ');
}
@@ -1501,6 +2049,18 @@ 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(&Apache::loncommon::student_image_tag($content{'senderdomain'},$content{'sendername'}));
$r->print('
'.&mt('Subject').': '.$content{'subject'}.
($folder ne 'sent'?'
'.&mt('From').': '.
&Apache::loncommon::aboutmewrapper(
@@ -1511,13 +2071,57 @@ 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;
+ my $showsymb = &Apache::lonenc::check_decrypt($symb);
+ my $showurl = &Apache::lonenc::check_decrypt($baseurl);
+ my $encrypturl = &Apache::lonnet::EXT('resource.0.encrypturl',
+ $showsymb,$env{'user.domain'},$env{'user.name'});
+ if ($symb) {
+ if ($encrypturl =~ /^yes$/i && !$env{'request.role.adv'}) {
+ $showsymb = &Apache::lonenc::check_encrypt($symb);
+ }
+ $symblink = '?symb='.$showsymb;
+ }
+ if ($encrypturl =~ /^yes$/i && !$env{'request.role.adv'}) {
+ $showurl = $baseurl;
+ }
+ $r->print('
'.&mt('Refers to').': '.$restitle.'');
+ $refers_to = 1;
+ }
+ }
+ if (!$refers_to) {
+ if ($baseurl =~ m-^/enc/-) {
+ if (defined($content{'courseid'})) {
+ if (!$env{'request.course.id'}) {
+ my $unencurl =
+ &Apache::lonenc::unencrypted($baseurl,
+ $content{'courseid'});
+ if ($unencurl ne '') {
+ 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
@@ -1530,7 +2134,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
@@ -1562,13 +2171,12 @@ sub header {
my $extra = &Apache::loncommon::studentbrowser_javascript();
if ($baseurl) {
- $extra .= "";
+ $extra .= "";
}
$r->print(&Apache::loncommon::start_page('Communication and Messages',
- $extra));
+ $extra));
$r->print(&Apache::lonhtmlcommon::breadcrumbs
- (($title?$title:'Communication and Messages')));
-
+ (($title?$title:'Communication and Messages')));
}
# ---------------------------------------------------------------- Print header
@@ -1587,9 +2195,9 @@ sub storecomment {
my ($r)=@_;
my $msgtxt=&Apache::lonfeedback::clear_out_html($env{'form.message'});
my $cleanmsgtxt='';
- foreach (split(/[\n\r]/,$msgtxt)) {
- unless ($_=~/^\s*(\>|\>\;)/) {
- $cleanmsgtxt.=$_."\n";
+ foreach my $line (split(/[\n\r]/,$msgtxt)) {
+ unless ($line=~/^\s*(\>|\>\;)/) {
+ $cleanmsgtxt.=$line."\n";
}
}
my $key=&escape($env{'form.baseurl'}).'___'.time;
@@ -1600,18 +2208,18 @@ sub storedcommentlisting {
my ($r)=@_;
my %msgs=&Apache::lonnet::dump('nohist_stored_comments',undef,undef,
'^'.&escape(&escape($env{'form.showcommentbaseurl'})));
- $r->print(&Apache::loncommon::start_page('Stored Comment Listing',undef,
+ $r->print(&Apache::loncommon::start_page('Saved Comment Listing',undef,
{'onlybody' => 1}));
if ((keys %msgs)[0]=~/^error\:/) {
- $r->print(&mt('No stored comments yet.'));
+ $r->print(&mt('No saved comments yet.'));
} else {
my $found=0;
- foreach (sort keys %msgs) {
- $r->print("\n".$msgs{$_}."
");
+ foreach my $key (sort(keys(%msgs))) {
+ $r->print("\n".$msgs{$key}."
");
$found=1;
}
unless ($found) {
- $r->print(&mt('No stored comments yet for this resource.'));
+ $r->print(&mt('No saved comments yet for this resource.'));
}
}
}
@@ -1622,10 +2230,25 @@ sub sendoffmail {
my ($r,$folder)=@_;
my $suffix=&Apache::lonmsg::foldersuffix($folder);
my $sendstatus='';
- my %specialmsg_status;
- my $numspecial = 0;
+ my %msg_status;
+ my $numsent = 0;
+ my $nosentstore = 1;
+ my ($cdom,$cnum,$group);
+ if (exists($env{'form.group'})) {
+ $group = $env{'form.group'};
+ }
+ if (exists($env{'request.course.id'})) {
+ $cnum = $env{'course.'.$env{'request.course.id'}.'.num'};
+ $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
+ }
if ($env{'form.send'}) {
- &printheader($r,'','Messages being sent.');
+ if (!$env{'form.multiforward'}) {
+ if ($group eq '') {
+ &printheader($r,'','Messages being sent.');
+ } else {
+ $r->print(&groupmail_header('sending',$group));
+ }
+ }
$r->rflush();
my %content=();
undef %content;
@@ -1666,10 +2289,12 @@ sub sendoffmail {
}
}
} elsif ($env{'form.sendmode'} eq 'upload') {
+ $nosentstore = 0;
foreach my $line (split(/[\n\r\f]+/,$env{'form.upfile'})) {
- my ($rec,$txt)=split(/\s*\:\s*/,$line);
+ my ($rec,$txt) = ($line =~ /^([^:]+:[^:]+):(.*)$/);
if ($txt) {
- $rec=~s/\@/\:/;
+ $rec =~ s/^\s+//;
+ $rec =~ s/\s+$//;
$toaddr{$rec}.=$txt."\n";
}
}
@@ -1679,8 +2304,8 @@ sub sendoffmail {
}
}
if ($env{'form.additionalrec'}) {
- foreach (split(/\,/,$env{'form.additionalrec'})) {
- my ($auname,$audom)=split(/\@/,$_);
+ foreach my $rec (split(/\s*,\s*/,$env{'form.additionalrec'})) {
+ my ($auname,$audom)=split(/:/,$rec);
if (($auname ne "") && ($audom ne "")) {
$toaddr{$auname.':'.$audom}='';
}
@@ -1702,23 +2327,23 @@ sub sendoffmail {
} else {
$savemsg=&Apache::lonfeedback::clear_out_html($env{'form.message'});
}
-
+ my @recusers;
+ my @recudoms;
foreach my $address (sort(keys(%toaddr))) {
my ($recuname,$recdomain)=split(/\:/,$address);
my $msgtxt = $savemsg;
if ($toaddr{$address}) { $msgtxt.='
'.$toaddr{$address}; }
my @thismsg;
- if ((($env{'form.critmsg'}) || ($env{'form.sendbck'})) &&
- (&Apache::lonnet::allowed('srm',$env{'request.course.id'})
- || &Apache::lonnet::allowed('srm',$env{'request.course.id'}.
- '/'.$env{'request.course.sec'}))) {
- $r->print(&mt('Sending critical message').' '.$recuname.':'.$recdomain.': ');
+ if ($msgtype eq 'critical') {
+ $r->print(&mt('Sending critical message').' '.
+ $recuname.':'.$recdomain.': ');
@thismsg=
&Apache::lonmsg::user_crit_msg($recuname,$recdomain,
$msgsubj,$msgtxt,
$env{'form.sendbck'},
$env{'form.permanent'},
- \$sentmessage{$address});
+ \$sentmessage{$address},
+ $nosentstore);
} else {
$r->print(&mt('Sending').' '.$recuname.':'.$recdomain.': ');
@thismsg=
@@ -1727,93 +2352,96 @@ sub sendoffmail {
$content{'citation'},
undef,undef,
$env{'form.permanent'},
- \$sentmessage{$address});
+ \$sentmessage{$address},
+ undef,undef,undef,
+ $nosentstore);
}
- if (($env{'request.course.id'}) && (($msgtype eq 'critical') ||
- ($env{'form.sendmode'} eq 'group'))) {
- $specialmsg_status{$recuname.':'.$recdomain} =
- join(' ',@thismsg);
- foreach my $result (@thismsg) {
- if ($result eq 'ok') {
- $numspecial++;
- }
- }
+ $msg_status{$recuname.':'.$recdomain}=join(' ',@thismsg);
+ if ($msg_status{$recuname.':'.$recdomain} =~ /(ok|con_delayed)/) {
+ $numsent++;
+ push(@recusers,$recuname);
+ push(@recudoms,$recdomain);
}
$sendstatus.=' '.join(' ',@thismsg);
}
- if (($env{'request.course.id'}) && (($env{'form.sendmode'} eq 'group')
- || ($msgtype eq 'critical'))) {
- my $subj_prefix;
- if ($msgtype eq 'critical') {
- $subj_prefix = 'Critical.';
- } else {
- $subj_prefix = 'Broadcast.';
- }
- my ($specialmsgid,$specialresult);
- my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'};
- my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
- my $course_str = &escape('['.$cnum.':'.$cdom.']');
-
- if ($numspecial) {
- $specialresult = &Apache::lonmsg::user_normal_msg_raw($cnum,$cdom,$subj_prefix.
- ' '.$course_str,$savemsg,undef,undef,undef,
- undef,undef,\$specialmsgid);
+ my $subj_prefix;
+ if ($numsent > 0) {
+ if (($env{'request.course.id'}) &&
+ (($env{'form.sendmode'} eq 'group') ||
+ ($env{'form.courserecord'}) ||
+ ($msgtype eq 'critical'))) {
+ if ($msgtype eq 'critical') {
+ $subj_prefix = 'Critical.';
+ } elsif ($env{'form.sendmode'} eq 'group') {
+ $subj_prefix = 'Broadcast.';
+ } else {
+ $subj_prefix = 'Archive';
+ }
+ my ($specialmsgid,$specialresult);
+ my $course_str = &escape('['.$cnum.':'.$cdom.']');
+
+ $specialresult =
+ &Apache::lonmsg::user_normal_msg_raw($cnum,$cdom,
+ $subj_prefix.' '.$course_str,$savemsg,undef,undef,
+ undef,undef,undef,\$specialmsgid,undef,undef,undef,
+ undef,undef,1);
$specialmsgid = &unescape($specialmsgid);
- }
- if ($specialresult eq 'ok') {
- my $record_sent;
- my @recusers;
- my @recudoms;
- my ($stamp,$crssubj,$msgname,$msgdom,$msgcount,$context,$pid) =
- split(/\:/,&unescape($specialmsgid));
-
- foreach my $recipient (sort(keys(%toaddr))) {
- if ($specialmsg_status{$recipient} eq 'ok') {
- my $usersubj = $subj_prefix.'['.$recipient.']';
- my $usermsgid =
- &Apache::lonmsg::buildmsgid($stamp,$usersubj,
- $msgname,$msgdom,
- $msgcount,$context,
- $pid);
- &Apache::lonmsg::user_normal_msg_raw($cnum,$cdom,$subj_prefix.
- ' ['.$recipient.']',$msgsubj,undef,
- undef,undef,undef,$usermsgid,undef,undef,$specialmsgid);
- my ($uname,$udom) = split(/:/,$recipient);
- push(@recusers,$uname);
- push(@recudoms,$udom);
+ if ($specialresult eq 'ok') {
+ my ($stamp,$crssubj,$msgname,$msgdom,$msgcount,$context,$pid) =
+ split(/\:/,&unescape($specialmsgid));
+
+ foreach my $recipient (sort(keys(%toaddr))) {
+ if ($msg_status{$recipient} =~ /\s*(ok|con_delayed)\s*/) {
+ my $usersubj = $subj_prefix.'['.$recipient.']';
+ my $usermsgid =
+ &Apache::lonmsg::buildmsgid($stamp,$usersubj,
+ $msgname,$msgdom,
+ $msgcount,$context,
+ $pid);
+ &Apache::lonmsg::user_normal_msg_raw($cnum,$cdom,
+ $subj_prefix.' ['.$recipient.']',$msgsubj,
+ undef,undef,undef,undef,$usermsgid,undef,
+ undef,$specialmsgid,undef,undef,undef,1);
+ }
}
+ if (($env{'form.sendmode'} ne 'upload') && (@recusers > 0)) {
+ &Apache::lonmsg::process_sent_mail($msgsubj,
+ $subj_prefix,$numsent,$stamp,$msgname,$msgdom,
+ $msgcount,$context,$pid,$savemsg,\@recusers,
+ \@recudoms);
+ }
+ } else {
+ &Apache::lonnet::logthis('Failed to create record of critical, broadcast or archived message in '.$env{'course.'.$env{'request.course.id'}.'.num'}.' at '.$env{'course.'.$env{'request.course.id'}.'.domain'}.' - no msgid generated');
}
- if (@recusers) {
- my $specialmessage;
- my $sentsubj =
- $subj_prefix.' ('.$numspecial.' sent) '.$msgsubj;
- $sentsubj = &HTML::Entities::encode($sentsubj,'<>&"');
- my $sentmsgid =
- &Apache::lonmsg::buildmsgid($stamp,$sentsubj,$msgname,
- $msgdom,$msgcount,$context,
- $pid);
- ($specialmsgid,$specialmessage) = &Apache::lonmsg::packagemsg($msgsubj,$savemsg,
- undef,undef,undef,\@recusers,\@recudoms,$sentmsgid);
- $record_sent = &Apache::lonmsg::store_sent_mail($specialmsgid,$specialmessage);
+ } else {
+ my $stamp = time;
+ my $msgcount = &Apache::lonmsg::get_uniq();
+ my $context = &Apache::lonmsg::get_course_context();
+ &Apache::lonmsg::process_sent_mail($msgsubj,$subj_prefix,
+ $numsent,$stamp,$env{'user.name'},
+ $env{'user.domain'},$msgcount,$context,
+ $$,$savemsg,\@recusers,\@recudoms);
+ }
+ }
+ 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 {
- &Apache::lonnet::logthis('Failed to create record of critical message or broadcast in '.$env{'course.'.$env{'request.course.id'}.'.num'}.' at '.$env{'course.'.$env{'request.course.id'}.'.domain'}.' - no msgid generated');
+ $r->print(''.&mt('Could not deliver message').' '.
+ &mt('Please use the browser "Back" button and correct the recipient addresses '."($sendstatus)").'
');
}
}
- } 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 '."($sendstatus)").'
');
}
+ return $sendstatus;
}
# ===================================================================== Handler
@@ -1833,7 +2461,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']);
+ 'showcommentbaseurl','dismode','group','subject','text','ref',
+ 'msgstatus']);
$sqs='&sortedby='.$env{'form.sortedby'};
# ------------------------------------------------------ They checked for email
@@ -1863,19 +2492,17 @@ sub handler {
unless ($dismode) {
$dismode='';
} else {
- $sqs.='&dismode='.&escape($dismode);
+ $sqs.='&dismode='.&escape($dismode);
}
# --------------------------------------------------------------------- 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;
}
@@ -1894,18 +2521,18 @@ 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'}) {
&printheader($r,'','Confirmed Receipt');
my $replying = 0;
- foreach (keys %env) {
- if ($_=~/^form\.rec\_(.*)$/) {
+ foreach my $envkey (keys(%env)) {
+ if ($envkey=~/^form\.rec\_(.*)$/) {
$r->print(''.&mt('Confirming Receipt').': '.
&Apache::lonmsg::user_crit_received($1).'
');
}
- if ($_=~/^form\.reprec\_(.*)$/) {
+ if ($envkey=~/^form\.reprec\_(.*)$/) {
my $msgid=$1;
$r->print(''.&mt('Confirming Receipt').': '.
&Apache::lonmsg::user_crit_received($msgid).'
');
@@ -1931,47 +2558,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');
@@ -1985,12 +2647,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'}) {
@@ -1998,31 +2660,120 @@ 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);
- }
+ }
if (($env{'form.rsspost'}) && ($env{'request.course.id'})) {
- &Apache::lonrss::addentry($env{'course.'.$env{'request.course.id'}.'.num'},
+ &Apache::lonrss::addentry($env{'course.'.$env{'request.course.id'}.'.num'},
$env{'course.'.$env{'request.course.id'}.'.domain'},
'Course_Announcements',
$env{'form.subject'},
$env{'form.message'},'/adm/communicate','public');
}
- if (!$env{'form.displayedcrit'}) {
- &disall($r,($folder?$folder:$dismode));
+ if ((!exists($env{'form.group'})) && (!$env{'form.displayedcrit'})) {
+ &disall($r,($folder?$folder:$dismode),$msgstatus);
}
} elsif ($env{'form.newfolder'}) {
&printheader($r,'','New Folder');
- &makefolder($env{'form.newfolder'});
- &Apache::loncommunicate::menu($r);
- &disall($r,$env{'form.newfolder'});
+ my $showfolder = $env{'form.newfolder'};
+ my ($makeresult,$warning) = &makefolder($env{'form.newfolder'});
+ if ($makeresult eq 'ok') {
+ $r->print(&mt('Mail folder "[_1]" created.',$showfolder).'
');
+ } else {
+ $r->print(&mt('Creation failed.').' '.$makeresult.'
'.
+ $warning);
+ $showfolder = $folder;
+ }
+ &Apache::loncommunicate::menu($r);
+ &disall($r,$showfolder,$msgstatus);
} elsif ($env{'form.showcommentbaseurl'}) {
&storedcommentlisting($r);
+ } elsif ($env{'form.folderaction'} eq 'delete') {
+ &printheader($r,'','Deleted Folder');
+ my $showfolder = '';
+ my $delresult = &deletefolder($folder);
+ if ($delresult eq 'ok') {
+ $r->print(&mt('Mail folder "[_1]" deleted.',$folder).'
');
+ $env{'form.folder'} = '';
+ } else {
+ $r->print(&mt('Deletion failed.').' '.$delresult.'
');
+ $showfolder = $folder;
+ }
+ &Apache::loncommunicate::menu($r);
+ &disall($r,$showfolder,$msgstatus);
+ } elsif ($env{'form.folderaction'} eq 'rename') {
+ &printheader($r,'','Renamed Folder');
+ my $showfolder = $env{'form.renamed'};
+ my $renresult = &renamefolder($folder);
+ if ($renresult eq 'ok') {
+ $r->print(&mt('Mail folder "[_1]" renamed "[_2]".',$folder,$showfolder).'
');
+ } else {
+ $r->print(&mt('Renaming failed.').' '.$renresult.'
');
+ $showfolder = $folder;
+ }
+ &Apache::loncommunicate::menu($r);
+ &disall($r,$showfolder,$msgstatus);
} else {
&printheader($r,'','Display All Messages');
- &Apache::loncommunicate::menu($r);
- &disall($r,($folder?$folder:$dismode));
+ &Apache::loncommunicate::menu($r);
+ &disall($r,($folder?$folder:$dismode),$msgstatus);
}
$r->print(&Apache::loncommon::end_page());
return OK;
@@ -2031,17 +2782,9 @@ sub handler {
=pod
-=back
-
=cut
1;
__END__
-
-
-
-
-
-