[LON-CAPA-cvs] cvs: loncom /interface lonmsg.pm

www lon-capa-cvs@mail.lon-capa.org
Mon, 01 Mar 2004 18:30:50 -0000


www		Mon Mar  1 13:30:50 2004 EDT

  Modified files:              
    /loncom/interface	lonmsg.pm 
  Log:
  New headers and breadcrumbs
  
  
Index: loncom/interface/lonmsg.pm
diff -u loncom/interface/lonmsg.pm:1.89 loncom/interface/lonmsg.pm:1.90
--- loncom/interface/lonmsg.pm:1.89	Mon Mar  1 11:19:45 2004
+++ loncom/interface/lonmsg.pm	Mon Mar  1 13:30:50 2004
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Routines for messaging
 #
-# $Id: lonmsg.pm,v 1.89 2004/03/01 16:19:45 www Exp $
+# $Id: lonmsg.pm,v 1.90 2004/03/01 18:30:50 www Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -944,16 +944,6 @@
     }
 }
 
-# ---------------------------------------------------------------- Print header
-
-sub printheader {
-    my ($r,$url,$desc,$baseurl)=@_;
-    &Apache::lonhtmlcommon::add_breadcrumb
-	({href=>$url,
-	  text=>$desc});
-    &header($r,$baseurl);
-}
-
 # ---------------------------------------------------------------- Face to face
 
 sub facetoface {
@@ -1026,11 +1016,70 @@
 ENDBFORM
     }
 }
+# ----------------------------------------------------------- Display a message
+
+sub displaymessage {
+    my ($r,$msgid)=@_;
+    &statuschange($msgid,'read');
+    my %message=&Apache::lonnet::get('nohist_email',[$msgid]);
+    my %content=&unpackagemsg($message{$msgid});
+# info to generate "next" and "previous" buttons
+    my @messages=&sortedmessages();
+    my $counter=0;
+    $r->print('<pre>');
+    my $escmsgid=&Apache::lonnet::escape($msgid);
+    foreach (@messages) {
+	if ($_->[5] eq $escmsgid){
+	    last;
+	}
+	$counter++;
+    }
+    $r->print('</pre>');
+    my $number_of_messages = scalar(@messages); #subtract 1 for last index
+# start output
+    &printheader($r,'/adm/email?display='.$msgid,'Display a Message','',$content{'baseurl'});
+    my %courseinfo=&Apache::lonnet::coursedescription($content{'courseid'});
+# Functions
+    $r->print('<table border="2" width="100%"><tr bgcolor="#FFFFAA"><td>'.&mt('Functions').':</td>'.
+	      '<td><a href="/adm/email?replyto='.&Apache::lonnet::escape($msgid).$sqs.
+	      '"><b>'.&mt('Reply').'</b></a></td>'.
+	      '<td><a href="/adm/email?forward='.&Apache::lonnet::escape($msgid).$sqs.
+	      '"><b>'.&mt('Forward').'</b></a></td>'.
+	      '<td><a href="/adm/email?markunread='.&Apache::lonnet::escape($msgid).$sqs.
+	      '"><b>'.&mt('Mark Unread').'</b></a></td>'.
+	      '<td><a href="/adm/email?markdel='.&Apache::lonnet::escape($msgid).$sqs.
+	      '"><b>Delete</b></a></td>'.
+	      '<td><a href="/adm/email?sortedby='.$ENV{'form.sortedby'}.
+	      '"><b>'.&mt('Display all Messages').'</b></a></td>');
+    if ($counter > 0){
+	$r->print('<td><a href="/adm/email?display='.$messages[$counter-1]->[5].$sqs.
+		  '"><b>'.&mt('Previous').'</b></a></td>');
+    }
+    if ($counter < $number_of_messages - 1){
+	$r->print('<td><a href="/adm/email?display='.$messages[$counter+1]->[5].$sqs.
+		  '"><b>'.&mt('Next').'</b></a></td>');
+    }
+    $r->print('</tr></table>');
+    $r->print('<br /><b>'.&mt('Subject').':</b> '.$content{'subject'}.
+	      '<br /><b>'.&mt('From').':</b> '.
+	      &Apache::loncommon::aboutmewrapper(
+						 &Apache::loncommon::plainname($content{'sendername'},$content{'senderdomain'}),
+						 $content{'sendername'},$content{'senderdomain'}).' ('.
+	      $content{'sendername'}.' at '.
+	      $content{'senderdomain'}.') '.
+	      ($content{'courseid'}?'<br /><b>'.&mt('Course').':</b> '.$courseinfo{'description'}.
+	       ($content{'coursesec'}?' ('.&mt('Group/Section').': '.$content{'coursesec'}.')':''):'').
+	      '<br /><b>'.&mt('Time').':</b> '.$content{'time'}.
+	      '<p><pre>'.
+	      &Apache::lontexconvert::msgtexconverted($content{'message'},1).
+	      '</pre><hr />'.$content{'citation'}.'</p>');
+    return;   
+}
 
 # ================================================================== The Header
 
 sub header {
-    my ($r,$baseurl)=@_;
+    my ($r,$title,$baseurl)=@_;
     $r->print('<html><head><title>Communication and Messages</title>');
     if ($baseurl) {
 	$r->print("<base href=\"http://$ENV{'SERVER_NAME'}/$baseurl\" />");
@@ -1038,10 +1087,21 @@
     $r->print(&Apache::loncommon::studentbrowser_javascript().'</head>'.
 	      &Apache::loncommon::bodytag('Communication and Messages'));
         $r->print(&Apache::lonhtmlcommon::breadcrumbs
-                  (undef,'Communication and Messages'));
+                  (undef,($title?$title:'Communication and Messages')));
 
 }
 
+# ---------------------------------------------------------------- Print header
+
+sub printheader {
+    my ($r,$url,$desc,$title,$baseurl)=@_;
+    &Apache::lonhtmlcommon::add_breadcrumb
+	({href=>$url,
+	  text=>$desc});
+    &header($r,$title,$baseurl);
+}
+
+
 # ===================================================================== Handler
 
 sub handler {
@@ -1074,64 +1134,7 @@
 # --------------------------------------------------------------- Render Output
 
     if ($ENV{'form.display'}) {
-	my $msgid=$ENV{'form.display'};
-	&statuschange($msgid,'read');
-	my %message=&Apache::lonnet::get('nohist_email',[$msgid]);
-	my %content=&unpackagemsg($message{$msgid});
-# info to generate "next" and "previous" buttons
-	my @messages=&sortedmessages();
-	my $counter=0;
-	$r->print('<pre>');
-	my $escmsgid=&Apache::lonnet::escape($msgid);
-	foreach (@messages) {
-	    if ($_->[5] eq $escmsgid){
-		last;
-	    }
-	    $counter++;
-	}
-	$r->print('</pre>');
-	my $number_of_messages = scalar(@messages); #subtract 1 for last index
-# start output
-	$r->print('<html><head><title>EMail and Messaging</title>');
-	$r->print(&Apache::loncommon::studentbrowser_javascript().
-		  '</head>'.
-		  &Apache::loncommon::bodytag('EMail and Messages').
-		  &Apache::loncommon::help_open_faq(12).
-		  &Apache::loncommon::help_open_bug('Communication Tools'));
-	my %courseinfo=&Apache::lonnet::coursedescription($content{'courseid'});
-	
-	$r->print('<br /><b>'.&mt('Subject').':</b> '.$content{'subject'}.
-		  '<br /><b>'.&mt('From').':</b> '.
-		  &Apache::loncommon::aboutmewrapper(
-						     &Apache::loncommon::plainname($content{'sendername'},$content{'senderdomain'}),
-						     $content{'sendername'},$content{'senderdomain'}).' ('.
-		  $content{'sendername'}.' at '.
-		  $content{'senderdomain'}.') '.
-		  ($content{'courseid'}?'<br /><b>'.&mt('Course').':</b> '.$courseinfo{'description'}.
-		   ($content{'coursesec'}?' ('.&mt('Group/Section').': '.$content{'coursesec'}.')':''):'').
-		  '<br /><b>'.&mt('Time').':</b> '.$content{'time'}.'<p>'.
-		  '<table border=2><tr bgcolor="#FFFFAA"><td>'.&mt('Functions').':</td>'.
-		  '<td><a href="/adm/email?replyto='.&Apache::lonnet::escape($msgid).$sqs.
-		  '"><b>'.&mt('Reply').'</b></a></td>'.
-		  '<td><a href="/adm/email?forward='.&Apache::lonnet::escape($msgid).$sqs.
-		  '"><b>'.&mt('Forward').'</b></a></td>'.
-		  '<td><a href="/adm/email?markunread='.&Apache::lonnet::escape($msgid).$sqs.
-		  '"><b>'.&mt('Mark Unread').'</b></a></td>'.
-		  '<td><a href="/adm/email?markdel='.&Apache::lonnet::escape($msgid).$sqs.
-		  '"><b>Delete</b></a></td>'.
-		  '<td><a href="/adm/email?sortedby='.$ENV{'form.sortedby'}.
-		  '"><b>'.&mt('Display all Messages').'</b></a></td>');
-	if ($counter > 0){
-	    $r->print('<td><a href="/adm/email?display='.$messages[$counter-1]->[5].$sqs.
-		      '"><b>'.&mt('Previous').'</b></a></td>');
-	}
-	if ($counter < $number_of_messages - 1){
-	    $r->print('<td><a href="/adm/email?display='.$messages[$counter+1]->[5].$sqs.
-		      '"><b>'.&mt('Next').'</b></a></td>');
-	}
-	$r->print('</tr></table><p><pre>'.
-		  &Apache::lontexconvert::msgtexconverted($content{'message'},1).
-		  '</pre><hr>'.$content{'citation'});
+	&displaymessage($r,$ENV{'form.display'});
     } elsif ($ENV{'form.replyto'}) {
 	&comprep($r,$ENV{'form.replyto'});
     } elsif ($ENV{'form.sendreply'}) {