[LON-CAPA-cvs] cvs: loncom /interface lonmsgdisplay.pm
albertel
lon-capa-cvs@mail.lon-capa.org
Sun, 23 Apr 2006 07:13:21 -0000
albertel Sun Apr 23 03:13:21 2006 EDT
Modified files:
/loncom/interface lonmsgdisplay.pm
Log:
- sort the username doamin based on the reiever address when in the sent folder
Index: loncom/interface/lonmsgdisplay.pm
diff -u loncom/interface/lonmsgdisplay.pm:1.10 loncom/interface/lonmsgdisplay.pm:1.11
--- loncom/interface/lonmsgdisplay.pm:1.10 Sun Apr 23 01:49:57 2006
+++ loncom/interface/lonmsgdisplay.pm Sun Apr 23 03:13:21 2006
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Routines for messaging display
#
-# $Id: lonmsgdisplay.pm,v 1.10 2006/04/23 05:49:57 albertel Exp $
+# $Id: lonmsgdisplay.pm,v 1.11 2006/04/23 07:13:21 albertel Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -392,18 +392,30 @@
my %descriptions;
my %status_cache =
&Apache::lonnet::get('email_status'.&Apache::lonmsg::foldersuffix($folder),\@messages);
- foreach (@messages) {
- my $msgid=&Apache::lonnet::escape($_);
+
+ my $get_received;
+ if ($folder eq 'sent'
+ && ($env{'form.sortedby'} =~ m/^(rev)?(user|domain)$/)) {
+ $get_received = 1;
+ }
+
+ foreach my $msgid (@messages) {
+ my $esc_msgid=&Apache::lonnet::escape($msgid);
my ($sendtime,$shortsubj,$fromname,$fromdomain,$status,$fromcid)=
- &Apache::lonmsg::unpackmsgid($msgid,$folder,undef,
+ &Apache::lonmsg::unpackmsgid($esc_msgid,$folder,undef,
\%status_cache);
my $description = &get_course_desc($fromcid,\%descriptions);
my @temp1 = ($sendtime,$shortsubj,$fromname,$fromdomain,$status,
- $msgid,$description);
+ $esc_msgid,$description);
+ if ($get_received) {
+ my %message = &Apache::lonnet::get('nohist_email'.$suffix,
+ [$msgid]);
+ my %content = &Apache::lonmsg::unpackagemsg($message{$msgid});
+ push(@temp1,$content{'recuser'},$content{'recdomain'});
+ }
# Check whether message was sent during blocking period.
if ($sendtime >= $startblock && ($sendtime <= $endblock && $endblock > 0) ) {
- my $escid = &Apache::lonnet::unescape($msgid);
- $$blocked{$escid} = 'ON';
+ $$blocked{$msgid} = 'ON';
$$numblocked ++;
} else {
push @temp ,\@temp1;
@@ -418,16 +430,32 @@
@temp = sort {$b->[0] <=> $a->[0]} @temp;
}
if ($env{'form.sortedby'} eq "user"){
- @temp = sort {lc($a->[2]) cmp lc($b->[2])} @temp;
+ if ($get_received) {
+ @temp = sort {lc($a->[7][0]) cmp lc($b->[7][0])} @temp;
+ } else {
+ @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 ($get_received) {
+ @temp = sort {lc($b->[7][0]) cmp lc($a->[7][0])} @temp;
+ } else {
+ @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 ($get_received) {
+ @temp = sort {$a->[8][0] cmp $b->[8][0]} @temp;
+ } else {
+ @temp = sort {$a->[3] cmp $b->[3]} @temp;
+ }
}
if ($env{'form.sortedby'} eq "revdomain"){
- @temp = sort {$b->[3] cmp $a->[3]} @temp;
+ if ($get_received) {
+ @temp = sort {$b->[8][0] cmp $a->[8][0]} @temp;
+ } else {
+ @temp = sort {$b->[3] cmp $a->[3]} @temp;
+ }
}
if ($env{'form.sortedby'} eq "subject"){
@temp = sort {lc($a->[1]) cmp lc($b->[1])} @temp;
@@ -662,7 +690,9 @@
my $suffix = &Apache::lonmsg::foldersuffix($folder);
for (my $n=$firstdis;$n<=$lastdis;$n++) {
- my ($sendtime,$shortsubj,$fromname,$fromdomain,$status,$origID,$description)= @{$temp[$n]};
+ my ($sendtime,$shortsubj,$fromname,$fromdomain,$status,$origID,
+ $description,$recv_name,$recv_domain)=
+ @{$temp[$n]};
if (($status ne 'deleted') && defined($sendtime) && $sendtime!~/error/) {
if ($status eq 'new') {
$r->print('<tr class="LC_mail_new">');
@@ -675,12 +705,17 @@
}
my ($dis_name,$dis_domain) = ($fromname,$fromdomain);
if ($folder eq 'sent') {
- my $msg_id = &Apache::lonnet::unescape($origID);
- my %message=&Apache::lonnet::get('nohist_email'.$suffix,
- [$msg_id]);
- my %content=&Apache::lonmsg::unpackagemsg($message{$msg_id});
- $dis_name = join('<br />',@{$content{'recuser'}});
- $dis_domain = join('<br />',@{$content{'recdomain'}});
+ if (defined($recv_name) && !defined($recv_domain)) {
+ $dis_name = join('<br />',@{$recv_name});
+ $dis_domain = join('<br />',@{$recv_domain});
+ } else {
+ my $msg_id = &Apache::lonnet::unescape($origID);
+ my %message = &Apache::lonnet::get('nohist_email'.$suffix,
+ [$msg_id]);
+ my %content = &Apache::lonmsg::unpackagemsg($message{$msg_id});
+ $dis_name = join('<br />',@{$content{'recuser'}});
+ $dis_domain = join('<br />',@{$content{'recdomain'}});
+ }
}
$r->print('<td><input type="checkbox" name="delmark_'.$origID.'" /></td><td><a href="/adm/email?display='.$origID.$sqs.
'">'.&mt('Open').'</a></td><td>'.