--- loncom/interface/lonmsg.pm 2003/08/13 15:57:51 1.61 +++ loncom/interface/lonmsg.pm 2003/08/29 20:38:12 1.65 @@ -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.65 2003/08/29 20:38:12 www Exp $ # # Copyright Michigan State University Board of Trustees # @@ -116,6 +116,9 @@ use Apache::lontexconvert(); use HTML::Entities(); use Mail::Send; +# Querystring component with sorting type +my $sqs; + # ===================================================================== Package sub packagemsg { @@ -613,6 +616,53 @@ $dispcrit ENDREPLY } +sub sortedmessages { + my @messages = &Apache::lonnet::getkeys('nohist_email'); + #unpack the varibles and repack into temp for sorting + my @temp; + foreach (@messages) { + my $msgid=&Apache::lonnet::escape($_); + my ($sendtime,$shortsubj,$fromname,$fromdomain,$status)= + &Apache::lonmsg::unpackmsgid($msgid); + my @temp1 = ($sendtime,$shortsubj,$fromname,$fromdomain,$status, + $msgid); + 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; + } + return @temp; +} + # ======================================================== Display all messages sub disall { @@ -638,39 +688,65 @@ sub disall { } ENDDISHEADER - $r->print( - '