--- loncom/interface/lonmsg.pm 2004/11/17 21:05:26 1.120 +++ loncom/interface/lonmsg.pm 2005/01/01 18:36:13 1.128 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Routines for messaging # -# $Id: lonmsg.pm,v 1.120 2004/11/17 21:05:26 www Exp $ +# $Id: lonmsg.pm,v 1.128 2005/01/01 18:36:13 www Exp $ # # Copyright Michigan State University Board of Trustees # @@ -527,9 +527,11 @@ sub folderlist { 'critical' => &mt('Critical'), 'sent' => &mt('Sent Messages'), map { $_ => $_ } @allfolders)). - ' '.&mt('Show').' '. - &Apache::loncommon::select_form($interdis,'interdis', -(' 10' => '10', ' 20' => '20', ' 50' => '50', '100' => '100', '200' => '200')). + ' '.&mt('Show'). + ''. '
'. ''. ($folder=~/^(new|critical)/?'':''); @@ -537,7 +539,9 @@ sub folderlist { sub scrollbuttons { my ($start,$maxdis,$first,$finish,$total)=@_; + unless ($total>0) { return ''; } $start++; $maxdis++;$first++;$finish++; + return ''. ''. ' of '.$maxdis. @@ -586,7 +590,6 @@ sub makefolder { sub movemsg { my ($msgid,$srcfolder,$trgfolder)=@_; - my $unmsgid=&Apache::lonnet::unescape($msgid); my $srcsuffix=&foldersuffix($srcfolder); my $trgsuffix=&foldersuffix($trgfolder); @@ -595,16 +598,13 @@ sub movemsg { &Apache::lonnet::put('nohist_email'.$trgsuffix,{$msgid => $message{$msgid}}); # Copy status - my %status=&Apache::lonnet::get('email_status'.$srcsuffix,[$unmsgid]); - &Apache::lonnet::put('email_status'.$trgsuffix,{$unmsgid => $status{$unmsgid}}); -# See if was deleted -> becomes "read" in trash - my $currentstatus=(&unpackmsgid($status{$unmsgid}),$srcfolder); - if ($currentstatus eq 'deleted') { - &statuschange($msgid,'read',$trgfolder); + unless ($trgfolder eq 'trash') { + my %status=&Apache::lonnet::get('email_status'.$srcsuffix,[$msgid]); + &Apache::lonnet::put('email_status'.$trgsuffix,{$msgid => $status{$msgid}}); } # Delete orginals &Apache::lonnet::del('nohist_email'.$srcsuffix,[$msgid]); - &Apache::lonnet::del('email_status'.$srcsuffix,[$unmsgid]); + &Apache::lonnet::del('email_status'.$srcsuffix,[$msgid]); } # ======================================================= Display a course list @@ -697,7 +697,6 @@ sub discrit { foreach (sort keys %what) { my %content=&unpackagemsg($what{$_}); next if ($content{'senderdomain'} eq ''); - $content{'message'}=~s/\n/\/g; $result.='
'.&mt('From').': '. &Apache::loncommon::aboutmewrapper( &Apache::loncommon::plainname($content{'sendername'},$content{'senderdomain'}),$content{'sendername'},$content{'senderdomain'}).' ('. @@ -913,6 +912,13 @@ ENDDISHEADER my $fsqs='&folder='.$folder; my @temp=sortedmessages(\%blocked,$startblock,$endblock,\$numblocked,$folder); my $totalnumber=$#temp+1; + unless ($totalnumber>0) { + $r->print('

'.&mt('Empty Folder').'

'); + return; + } + unless ($interdis) { + $interdis=20; + } my $number=int($totalnumber/$interdis); if (($startdis<0) || ($startdis>$number)) { $startdis=$number; } my $firstdis=$interdis*$startdis; @@ -951,7 +957,7 @@ ENDDISHEADER } else { $r->print(''.&mt('Status').''); } - $r->print(''); + $r->print("\n"); for (my $n=$firstdis;$n<=$lastdis;$n++) { my ($sendtime,$shortsubj,$fromname,$fromdomain,$status,$origID)= @{$temp[$n]}; if (($status ne 'deleted') && defined($sendtime) && $sendtime!~/error/) { @@ -971,13 +977,13 @@ ENDDISHEADER ''.&Apache::lonlocal::locallocaltime($sendtime).''. $fromname.''.$fromdomain.''. &Apache::lonnet::unescape($shortsubj).''. - $status.''); + $status."\n"); } elsif ($status eq 'deleted') { # purge &movemsg(&Apache::lonnet::unescape($origID),$folder,'trash'); } } - $r->print('

'. + $r->print("\n

". ''.&mt('Check All').' '. ''.&mt('Uncheck All').'

'. ''); @@ -992,7 +998,8 @@ ENDDISHEADER &Apache::loncommon::select_form('','movetofolder', ( map { $_ => $_ } @allfolders)) ); - $r->print(''); + my $postedstartdis=$startdis+1; + $r->print(''); if ($numblocked > 0) { my $beginblock = &Apache::lonlocal::locallocaltime($startblock); my $finishblock = &Apache::lonlocal::locallocaltime($endblock); @@ -1006,6 +1013,7 @@ ENDDISHEADER sub compout { my ($r,$forwarding,$replying,$broadcast,$replycrit,$folder)=@_; + my $suffix=&foldersuffix($folder); if ($broadcast eq 'individual') { &printheader($r,'/adm/email?compose=individual', @@ -1057,7 +1065,7 @@ sub compout { my %content; my $defdom=$ENV{'user.domain'}; if ($forwarding) { - %message=&Apache::lonnet::get('nohist_email',[$forwarding]); + %message=&Apache::lonnet::get('nohist_email'.$suffix,[$forwarding]); %content=&unpackagemsg($message{$forwarding},$folder); $dispcrit.=''; @@ -1071,7 +1079,7 @@ sub compout { } } if ($replying) { - %message=&Apache::lonnet::get('nohist_email',[$replying]); + %message=&Apache::lonnet::get('nohist_email'.$suffix,[$replying]); %content=&unpackagemsg($message{$replying},$folder); $dispcrit.=''; @@ -1730,9 +1738,8 @@ sub displaymessage { '">'.&mt('Mark Unread').''. 'Delete'. - ''.&mt('Display all Messages').''); + ''.&mt('Back to Folder Display').''); if ($counter > 0){ $r->print(''.&mt('Previous').''); @@ -1911,7 +1918,13 @@ sub sendoffmail { foreach (keys %toaddr) { my ($recuname,$recdomain)=split(/\:/,$_); - my $msgtxt=&Apache::lonfeedback::clear_out_html($ENV{'form.message'}); + my $msgtxt; + if ((($ENV{'form.critmsg'}) || ($ENV{'form.sendbck'})) && + (&Apache::lonnet::allowed('srm',$ENV{'request.course.id'}))) { + $msgtxt=&Apache::lonfeedback::clear_out_html($ENV{'form.message'},1); + } else { + $msgtxt=&Apache::lonfeedback::clear_out_html($ENV{'form.message'}); + } if ($toaddr{$_}) { $msgtxt.='
'.$toaddr{$_}; } my $thismsg; if ((($ENV{'form.critmsg'}) || ($ENV{'form.sendbck'})) && @@ -1974,9 +1987,7 @@ sub handler { 'sendreply','compose','sendmail','critical','recname','recdom', 'recordftf','sortedby','block','folder','startdis','interdis', 'showcommentbaseurl']); - $sqs='&sortedby='.$ENV{'form.sortedby'}. - '&startdis='.$ENV{'form.startdis'}. - '&interdis='.$ENV{'form.interdis'}; + $sqs='&sortedby='.$ENV{'form.sortedby'}; # ------------------------------------------------------ They checked for email unless ($ENV{'form.block'}) { @@ -1997,7 +2008,7 @@ sub handler { unless ($folder) { $folder=''; } else { - $sqs='&folder='.&Apache::lonnet::escape($folder); + $sqs.='&folder='.&Apache::lonnet::escape($folder); } # --------------------------------------------------------------------- Display @@ -2005,8 +2016,11 @@ sub handler { $startdis=$ENV{'form.startdis'}; $startdis--; unless ($startdis) { $startdis=0; } + $interdis=$ENV{'form.interdis'}; unless ($interdis) { $interdis=20; } + $sqs.='&interdis='.$interdis; + if ($ENV{'form.firstview'}) { $startdis=0; } @@ -2019,7 +2033,8 @@ sub handler { if ($ENV{'form.nextview'}) { $startdis++; } - + my $postedstartdis=$startdis+1; + $sqs.='&startdis='.$postedstartdis; # --------------------------------------------------------------- Render Output @@ -2046,7 +2061,7 @@ sub handler { &printheader($r,'','Displaying Critical Messages'); &discrit($r); } elsif ($ENV{'form.forward'}) { - &compout($r,$ENV{'form.forward'},undef,undef,$folder); + &compout($r,$ENV{'form.forward'},undef,undef,undef,$folder); } elsif ($ENV{'form.markdel'}) { &printheader($r,'','Deleted Message'); &statuschange($ENV{'form.markdel'},'deleted',$folder);