--- loncom/interface/lonmsg.pm 2003/08/13 15:57:51 1.61 +++ loncom/interface/lonmsg.pm 2003/08/15 17:57:57 1.62 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Routines for messaging # -# $Id: lonmsg.pm,v 1.61 2003/08/13 15:57:51 www Exp $ +# $Id: lonmsg.pm,v 1.62 2003/08/15 17:57:57 www Exp $ # # Copyright Michigan State University Board of Trustees # @@ -638,24 +638,91 @@ sub disall { } ENDDISHEADER - $r->print( - '

Display All Messages

'. - ''. - ''); - foreach (sort split(/\&/,&Apache::lonnet::reply('keys:'. - $ENV{'user.domain'}.':'. - $ENV{'user.name'}.':nohist_email', - $ENV{'user.home'}))) { - my ($sendtime,$shortsubj,$fromname,$fromdomain,$status)= + $r->print('

Display All Messages

'. + '
 DateUsernameDomainSubjectStatus
'); + } else { + $r->print('Date'); + } + $r->print(''); + } else { + $r->print('Status'); + } + $r->print(''); +my @messages = split(/\&/,&Apache::lonnet::reply('keys:'.$ENV{'user.domain'}.':'.$ENV{'user.name'}.':nohist_email',$ENV{'user.home'})); +#unpack the varibles and repack into temp for sorting +my @temp; +foreach (@messages) +{ + my ($sendtime,$shortsubj,$fromname,$fromdomain,$status)= &Apache::lonmsg::unpackmsgid($_); - if (($status ne 'deleted') && defined($sendtime) && $sendtime!~/error/) { +my @temp1 = ($sendtime,$shortsubj,$fromname,$fromdomain,$status); + push @temp ,\@temp1; +} +#default sort + @temp = sort {$a->[0] <=> $b->[0]} @temp; +if ($ENV{'form.sortedby'} eq "date"){ + @temp = sort {$a->[0] <=> $b->[0]} @temp; +} +if ($ENV{'form.sortedby'} eq "revdate"){ + @temp = sort {$b->[0] <=> $a->[0]} @temp; +} +if ($ENV{'form.sortedby'} eq "user"){ + @temp = sort {lc($a->[2]) cmp lc($b->[2])} @temp; +} +if ($ENV{'form.sortedby'} eq "revuser"){ + @temp = sort {lc($b->[2]) cmp lc($a->[2])} @temp; +} +if ($ENV{'form.sortedby'} eq "domain"){ + @temp = sort {$a->[3] cmp $b->[3]} @temp; +} +if ($ENV{'form.sortedby'} eq "revdomain"){ + @temp = sort {$b->[3] cmp $a->[3]} @temp; +} +if ($ENV{'form.sortedby'} eq "subject"){ + @temp = sort {lc($a->[1]) cmp lc($b->[1])} @temp; +} +if ($ENV{'form.sortedby'} eq "revsubject"){ + @temp = sort {lc($b->[1]) cmp lc($a->[1])} @temp; +} +if ($ENV{'form.sortedby'} eq "status"){ + @temp = sort {$a->[4] cmp $b->[4]} @temp; +} +if ($ENV{'form.sortedby'} eq "revstatus"){ + @temp = sort {$b->[4] cmp $a->[4]} @temp; +} + foreach (@temp){ + my ($sendtime,$shortsubj,$fromname,$fromdomain,$status)= @$_; + if (($status ne 'deleted') && defined($sendtime) && $sendtime!~/error/) { if ($status eq 'new') { $r->print(''); } elsif ($status eq 'read') { $r->print(''); } elsif ($status eq 'replied') { - $r->print(''); + $r->print(''); + } else { $r->print(''); } @@ -666,9 +733,9 @@ ENDDISHEADER $fromname.''); - } - } - $r->print('
 '); + if ($ENV{'form.sortedby'} eq "revdate") { + $r->print('Date'); + if ($ENV{'form.sortedby'} eq "revuser") { + $r->print('Username'); + } else { + $r->print('Username'); + } + $r->print(''); + if ($ENV{'form.sortedby'} eq "revdomain") { + $r->print('Domain'); + } else { + $r->print('Domain'); + } + $r->print(''); + if ($ENV{'form.sortedby'} eq "revsubject") { + $r->print('Subject'); + } else { + $r->print('Subject'); + } + $r->print(''); + if ($ENV{'form.sortedby'} eq "revstatus") { + $r->print('Status
'.$fromdomain.''. &Apache::lonnet::unescape($shortsubj).''. $status.'

'. + } + } + $r->print('

'. 'Check All '. 'Uncheck All

'. ''. @@ -888,7 +955,7 @@ sub handler { &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'}, ['display','replyto','forward','markread','markdel','markunread', 'sendreply','compose','sendmail','critical','recname','recdom', - 'recordftf']); + 'recordftf','sortedby']); # ------------------------------------------------------ They checked for email &Apache::lonnet::put('email_status',{'recnewemail'=>0});