[LON-CAPA-cvs] cvs: loncom /interface lonmsg.pm
matthew
lon-capa-cvs@mail.lon-capa.org
Thu, 11 Apr 2002 20:46:21 -0000
matthew Thu Apr 11 16:46:21 2002 EDT
Modified files:
/loncom/interface lonmsg.pm
Log:
Handle case of not having critical messages cleanly.
Index: loncom/interface/lonmsg.pm
diff -u loncom/interface/lonmsg.pm:1.29 loncom/interface/lonmsg.pm:1.30
--- loncom/interface/lonmsg.pm:1.29 Mon Mar 18 13:38:04 2002
+++ loncom/interface/lonmsg.pm Thu Apr 11 16:46:21 2002
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Routines for messaging
#
-# $Id: lonmsg.pm,v 1.29 2002/03/18 18:38:04 www Exp $
+# $Id: lonmsg.pm,v 1.30 2002/04/11 20:46:21 matthew Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -303,21 +303,30 @@
sub discrit {
my $r=shift;
- $r->print('<h1><font color=red>Critical Messages</font></h1>'.
- '<form action=/adm/email method=post>'.
- '<input type=hidden name=confirm value=true>');
- my %what=&Apache::lonnet::dump('critical');
- foreach (sort keys %what) {
- my %content=&unpackagemsg($what{$_});
- $content{'message'}=~s/\n/\<br\>/g;
- $r->print('<hr>From: <b>'.$content{'sendername'}.'@'.
- $content{'senderdomain'}.'</b> ('.$content{'time'}.
- ')<br><blockquote>'.$content{'message'}.'</blockquote>'.
- '<input type=submit name="rec_'.$_.'" value="Confirm Receipt">'.
- '<input type=submit name="reprec_'.$_.'" value="Confirm Receipt and Reply">');
- }
- $r->print(
- '<input type=hidden name="displayedcrit" value="true"></form>');
+ my $header = '<h1><font color=red>Critical Messages</font></h1>'.
+ '<form action=/adm/email method=post>'.
+ '<input type=hidden name=confirm value=true>';
+ my %what=&Apache::lonnet::dump('critical');
+ my $result = '';
+ foreach (sort keys %what) {
+ my %content=&unpackagemsg($what{$_});
+ next if ($content{'senderdomain'} eq '');
+ $content{'message'}=~s/\n/\<br\>/g;
+ $result.='<hr>From: <b>'.$content{'sendername'}.'@'.
+ $content{'senderdomain'}.'</b> ('.$content{'time'}.
+ ')<br><blockquote>'.$content{'message'}.'</blockquote>'.
+ '<input type=submit name="rec_'.$_.'" value="Confirm Receipt">'.
+ '<input type=submit name="reprec_'.$_.'" '.
+ 'value="Confirm Receipt and Reply">';
+ }
+ # Check to see if there were any messages.
+ if ($result eq '') {
+ $result = "<h2>You have no critical messages.</h2>";
+ } else {
+ $r->print($header);
+ }
+ $r->print($result);
+ $r->print('<input type=hidden name="displayedcrit" value="true"></form>');
}
# =============================================================== Compose reply