[LON-CAPA-cvs] cvs: loncom /interface lonmsg.pm
raeburn
lon-capa-cvs@mail.lon-capa.org
Tue, 03 Jan 2006 04:17:02 -0000
raeburn Mon Jan 2 23:17:02 2006 EDT
Modified files:
/loncom/interface lonmsg.pm
Log:
When unpacking msgids, explicitly set $fromcid to '' for pre-1.140 msgids where processid is in position used for course context in 1.140 and later. Speed up messages display by storing descriptions in a hash to avoid repeated lonnet::coursedescription() calls.
Index: loncom/interface/lonmsg.pm
diff -u loncom/interface/lonmsg.pm:1.166 loncom/interface/lonmsg.pm:1.167
--- loncom/interface/lonmsg.pm:1.166 Mon Jan 2 22:18:58 2006
+++ loncom/interface/lonmsg.pm Mon Jan 2 23:17:02 2006
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Routines for messaging
#
-# $Id: lonmsg.pm,v 1.166 2006/01/03 03:18:58 raeburn Exp $
+# $Id: lonmsg.pm,v 1.167 2006/01/03 04:17:02 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -268,8 +268,9 @@
sub unpackmsgid {
my ($msgid,$folder,$skipstatus)=@_;
$msgid=&Apache::lonnet::unescape($msgid);
- my ($sendtime,$shortsubj,$fromname,$fromdomain,$count,$fromcid)=split(/\:/,
- &Apache::lonnet::unescape($msgid));
+ 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);
@@ -856,14 +857,12 @@
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;
- if ($fromcid) {
- $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.
@@ -917,16 +916,24 @@
}
sub get_course_desc {
- my ($fromcid) = @_;
+ my ($fromcid,$descriptions) = @_;
my $description;
- if ($fromcid =~ /^\d+$/) { return $description; }
- if (defined($env{'course.'.$fromcid.'.description'})) {
- $description = $env{'course.'.$fromcid.'.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
@@ -955,14 +962,12 @@
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;
- if ($fromcid) {
- $description = &get_course_desc($fromcid);
- }
+ my $description = &get_course_desc($fromcid,\%descriptions);
my $numsendtime = $sendtime;
$sendtime = &Apache::lonlocal::locallocaltime($sendtime);
if ($status eq 'new') {