--- loncom/interface/lonmsg.pm 2005/12/09 20:54:26 1.162 +++ loncom/interface/lonmsg.pm 2006/01/03 04:17:02 1.167 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Routines for messaging # -# $Id: lonmsg.pm,v 1.162 2005/12/09 20:54:26 raeburn Exp $ +# $Id: lonmsg.pm,v 1.167 2006/01/03 04:17:02 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -105,7 +105,7 @@ users in their domain. The XML packagin similar. The differences are the use of $uname and $udom in stored internal messages, compared with $email in stored -Domain Coordinator e-mail for teh storage of information about +Domain Coordinator e-mail for the storage of information about recipients of the message/e-mail. =head1 FUNCTIONS @@ -266,14 +266,18 @@ sub buildmsgid { } sub unpackmsgid { - my ($msgid,$folder)=@_; + my ($msgid,$folder,$skipstatus)=@_; $msgid=&Apache::lonnet::unescape($msgid); - my $suffix=&foldersuffix($folder); - my ($sendtime,$shortsubj,$fromname,$fromdomain,$count,$fromcid)=split(/\:/, - &Apache::lonnet::unescape($msgid)); - my %status=&Apache::lonnet::get('email_status'.$suffix,[$msgid]); - if ($status{$msgid}=~/^error\:/) { $status{$msgid}=''; } - unless ($status{$msgid}) { $status{$msgid}='new'; } + my ($sendtime,$shortsubj,$fromname,$fromdomain,$count,$fromcid, + $processid)=split(/\:/,&Apache::lonnet::unescape($msgid)); + if (!defined($processid)) { $fromcid = ''; } + my %status=(); + unless ($skipstatus) { + my $suffix=&foldersuffix($folder); + %status=&Apache::lonnet::get('email_status'.$suffix,[$msgid]); + if ($status{$msgid}=~/^error\:/) { $status{$msgid}=''; } + unless ($status{$msgid}) { $status{$msgid}='new'; } + } return ($sendtime,$shortsubj,$fromname,$fromdomain,$status{$msgid},$fromcid); } @@ -853,11 +857,12 @@ sub sortedmessages { my @messages = &Apache::lonnet::getkeys('nohist_email'.$suffix); #unpack the varibles and repack into temp for sorting my @temp; + my %descriptions; foreach (@messages) { my $msgid=&Apache::lonnet::escape($_); my ($sendtime,$shortsubj,$fromname,$fromdomain,$status,$fromcid)= &Apache::lonmsg::unpackmsgid($msgid,$folder); - my $description = &get_course_desc($fromcid); + my $description = &get_course_desc($fromcid,\%descriptions); my @temp1 = ($sendtime,$shortsubj,$fromname,$fromdomain,$status, $msgid,$description); # Check whether message was sent during blocking period. @@ -911,15 +916,24 @@ sub sortedmessages { } sub get_course_desc { - my ($fromcid) = @_; - my $description; - if (defined($env{'course.'.$fromcid.'.description'})) { - $description = $env{'course.'.$fromcid.'.description'}; + my ($fromcid,$descriptions) = @_; + my $description; + if (!$fromcid) { + return $description; } else { - my %courseinfo=&Apache::lonnet::coursedescription($fromcid); - $description = $courseinfo{'description'}; + if (defined($$descriptions{$fromcid})) { + $description = $$descriptions{$fromcid}; + } else { + if (defined($env{'course.'.$fromcid.'.description'})) { + $description = $env{'course.'.$fromcid.'.description'}; + } else { + my %courseinfo=&Apache::lonnet::coursedescription($fromcid); $description = $courseinfo{'description'}; + $description = $courseinfo{'description'}; + } + $$descriptions{$fromcid} = $description; + } + return $description; } - return $description; } # ======================================================== Display new messages @@ -948,11 +962,12 @@ sub disnew { my $numblocked = 0; # Check for blocking of display because of scheduled online exams. &blockcheck(\%setters,\$startblock,\$endblock); + my %descriptions; foreach (@msgids) { my ($sendtime,$shortsubj,$fromname,$fromdom,$status,$fromcid)= &Apache::lonmsg::unpackmsgid($_); if (defined($sendtime) && $sendtime!~/error/) { - my $description = &get_course_desc($fromcid); + my $description = &get_course_desc($fromcid,\%descriptions); my $numsendtime = $sendtime; $sendtime = &Apache::lonlocal::locallocaltime($sendtime); if ($status eq 'new') {