[LON-CAPA-cvs] cvs: loncom /interface lonmsgdisplay.pm
raeburn
raeburn@source.lon-capa.org
Thu, 12 May 2011 21:56:13 -0000
raeburn Thu May 12 21:56:13 2011 EDT
Modified files:
/loncom/interface lonmsgdisplay.pm
Log:
- Sanity checking when retrieving course description for inclusion
in message display.
Index: loncom/interface/lonmsgdisplay.pm
diff -u loncom/interface/lonmsgdisplay.pm:1.156 loncom/interface/lonmsgdisplay.pm:1.157
--- loncom/interface/lonmsgdisplay.pm:1.156 Tue May 3 10:37:14 2011
+++ loncom/interface/lonmsgdisplay.pm Thu May 12 21:56:13 2011
@@ -1,7 +1,7 @@
# $textareaclass The LearningOnline Network with CAPA
# Routines for messaging display
#
-# $Id: lonmsgdisplay.pm,v 1.156 2011/05/03 10:37:14 bisitz Exp $
+# $Id: lonmsgdisplay.pm,v 1.157 2011/05/12 21:56:13 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -110,7 +110,7 @@
use Apache::lonrss();
use Apache::lonselstudent();
use lib '/home/httpd/lib/perl/';
-use LONCAPA;
+use LONCAPA qw(:DEFAULT :match);
# Querystring component with sorting type
my $sqs='';
@@ -814,7 +814,15 @@
foreach my $key (sort(keys(%what))) {
my %content=&Apache::lonmsg::unpackagemsg($what{$key});
next if ($content{'senderdomain'} eq '');
- my %courseinfo=&Apache::lonnet::coursedescription($content{'courseid'});
+ my $description;
+ if ($content{'courseid'} ne '') {
+ if ($content{'courseid'} =~ m{/^$match_domain\_$match_courseid$}) {
+ my %courseinfo=&Apache::lonnet::coursedescription($content{'courseid'},{'one_time' => 1});
+ if ($courseinfo{'description'} ne '') {
+ $description = $courseinfo{'description'};
+ }
+ }
+ }
$result .= &Apache::lonhtmlcommon::start_pick_box()
.&Apache::lonhtmlcommon::row_title(&mt('From'),undef,'LC_oddrow_value')
.'<b>'.&Apache::loncommon::aboutmewrapper(
@@ -827,9 +835,9 @@
.&Apache::lonhtmlcommon::row_title(&mt('Subject'),undef,'LC_oddrow_value')
.$content{'subject'}
.&Apache::lonhtmlcommon::row_closure(1);
- if ($courseinfo{'description'}) {
+ if ($description ne '') {
$result .= &Apache::lonhtmlcommon::row_title(&mt('Course'),undef,'LC_oddrow_value')
- .$courseinfo{'description'}
+ .$description
.&Apache::lonhtmlcommon::row_closure(1);
}
$result .= &Apache::lonhtmlcommon::row_title(&mt('Message'),undef,'LC_evenrow_value')
@@ -987,10 +995,15 @@
if (defined($env{'course.'.$fromcid.'.description'})) {
$description = $env{'course.'.$fromcid.'.description'};
} else {
- my %courseinfo=&Apache::lonnet::coursedescription($fromcid);
- $description = $courseinfo{'description'};
+ if ($fromcid =~ m{/^$match_domain\_$match_courseid$}) {
+ my %courseinfo=&Apache::lonnet::coursedescription($fromcid,
+ {'one_time' => 1});
+ $description = $courseinfo{'description'};
+ }
+ }
+ if ($description ne '') {
+ $$descriptions{$fromcid} = $description;
}
- $$descriptions{$fromcid} = $description;
}
return $description;
}
@@ -2408,7 +2421,6 @@
my $number_of_messages = scalar(@messages); #subtract 1 for last index
# start output
&printheader($r,'/adm/email?display='.&escape($msgid),'Display a Message','',$content{'baseurl'});
- my %courseinfo=&Apache::lonnet::coursedescription($content{'courseid'});
# Prepare available functions
my @functionlist;
@@ -2667,14 +2679,22 @@
}
# Course
- if ($content{'courseid'}) {
- $r->print(&Apache::lonhtmlcommon::row_title(&mt($crstype))
- .$courseinfo{'description'}
- );
- if ($content{'coursesec'}) {
- $r->print(' ('.&mt('Section').': '.$content{'coursesec'}.')');
+ if ($content{'courseid'} ne '') {
+ if ($content{'courseid'} =~ m{^$match_domain\_$match_courseid$}) {
+ my %courseinfo;
+ %courseinfo=&Apache::lonnet::coursedescription($content{'courseid'},
+ {'one_time' => 1});
+ my $description = $courseinfo{'description'};
+ if ($description ne '') {
+ $r->print(&Apache::lonhtmlcommon::row_title(&mt($crstype))
+ .$description
+ );
+ if ($content{'coursesec'}) {
+ $r->print(' ('.&mt('Section').': '.$content{'coursesec'}.')');
+ }
+ $r->print(&Apache::lonhtmlcommon::row_closure());
+ }
}
- $r->print(&Apache::lonhtmlcommon::row_closure());
}
$r->print(&Apache::lonhtmlcommon::row_title(&mt('Time'))
.$content{'time'}