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

www lon-capa-cvs@mail.lon-capa.org
Mon, 01 Mar 2004 01:19:51 -0000


This is a MIME encoded message

--www1078103991
Content-Type: text/plain

www		Sun Feb 29 20:19:51 2004 EDT

  Modified files:              
    /loncom/interface	lonmsg.pm 
  Log:
  Re-tabinate.
  
  
--www1078103991
Content-Type: text/plain
Content-Disposition: attachment; filename="www-20040229201951.txt"

Index: loncom/interface/lonmsg.pm
diff -u loncom/interface/lonmsg.pm:1.86 loncom/interface/lonmsg.pm:1.87
--- loncom/interface/lonmsg.pm:1.86	Sun Feb 29 20:06:10 2004
+++ loncom/interface/lonmsg.pm	Sun Feb 29 20:19:51 2004
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Routines for messaging
 #
-# $Id: lonmsg.pm,v 1.86 2004/03/01 01:06:10 www Exp $
+# $Id: lonmsg.pm,v 1.87 2004/03/01 01:19:51 www Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -1010,12 +1010,12 @@
     my $r=shift;
 
 # ----------------------------------------------------------- Set document type
-
-  &Apache::loncommon::content_type($r,'text/html');
-  $r->send_http_header;
-
-  return OK if $r->header_only;
-
+    
+    &Apache::loncommon::content_type($r,'text/html');
+    $r->send_http_header;
+    
+    return OK if $r->header_only;
+    
 # --------------------------- Get query string for limited number of parameters
     &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},
         ['display','replyto','forward','markread','markdel','markunread',
@@ -1023,222 +1023,221 @@
          'recordftf','sortedby']);
     $sqs='&sortedby='.$ENV{'form.sortedby'};
 # ------------------------------------------------------ They checked for email
-  &Apache::lonnet::put('email_status',{'recnewemail'=>0});
+    &Apache::lonnet::put('email_status',{'recnewemail'=>0});
 # --------------------------------------------------------------- Render Output
-  if (!$ENV{'form.display'}) {
-      $r->print('<html><head><title>EMail and Messaging</title>'.
-		&Apache::loncommon::studentbrowser_javascript().'</head>'.
-		&Apache::loncommon::bodytag('EMail and Messages').
-	     &Apache::loncommon::help_open_faq(12).
-	     &Apache::loncommon::help_open_bug('Communication Tools'));
-  }
-  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});
+    if (!$ENV{'form.display'}) {
+	$r->print('<html><head><title>EMail and Messaging</title>'.
+		  &Apache::loncommon::studentbrowser_javascript().'</head>'.
+		  &Apache::loncommon::bodytag('EMail and Messages').
+		  &Apache::loncommon::help_open_faq(12).
+		  &Apache::loncommon::help_open_bug('Communication Tools'));
+    }
+    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
+	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>');
-      if (defined($content{'baseurl'})) {
-	  $r->print("<base href=\"http://$ENV{'SERVER_NAME'}/$content{'baseurl'}\" />");
-      }
-      $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'});
-  } elsif ($ENV{'form.replyto'}) {
-      &comprep($r,$ENV{'form.replyto'});
-  } elsif ($ENV{'form.sendreply'}) {
-      if ($ENV{'form.send'}) {
-	  my $msgid=$ENV{'form.sendreply'};
-	  my %message=&Apache::lonnet::get('nohist_email',[$msgid]);
-	  my %content=&unpackagemsg($message{$msgid},1);
-	  &statuschange($msgid,'replied');
-	  if ((($ENV{'form.critmsg'}) || ($ENV{'form.sendbck'})) && 
-	      (&Apache::lonnet::allowed('srm',$ENV{'request.course.id'}))) {
-	      $r->print(&mt('Sending critical message').': '.
-			&user_crit_msg($content{'sendername'},
-				       $content{'senderdomain'},
-				       &Apache::lonfeedback::clear_out_html($ENV{'form.subject'}),
-				       &Apache::lonfeedback::clear_out_html($ENV{'form.message'}),
-				       $ENV{'form.sendbck'}));
-	  } else {
-	      $r->print(&mt('Sending').': '.&user_normal_msg($content{'sendername'},
-							     $content{'senderdomain'},
-							     &Apache::lonfeedback::clear_out_html($ENV{'form.subject'}),
-							     &Apache::lonfeedback::clear_out_html($ENV{'form.message'})));
-	  }
-      }
-      if ($ENV{'form.displayedcrit'}) {
-          &discrit($r);
-      } else {
-	  &disall($r);
-      }
-  } elsif ($ENV{'form.confirm'}) {
-      foreach (keys %ENV) {
-          if ($_=~/^form\.rec\_(.*)$/) {
-	      $r->print('<b>Confirming Receipt:</b> '.
-                        &user_crit_received($1).'<br>');
-          }
-          if ($_=~/^form\.reprec\_(.*)$/) {
-              my $msgid=$1;
-	      $r->print('<b>Confirming Receipt:</b> '.
-                        &user_crit_received($msgid).'<br>');
-              &comprep($r,$msgid);
-          }
-      }
-      &discrit($r);
-  } elsif ($ENV{'form.critical'}) {
-      &discrit($r);
-  } elsif ($ENV{'form.forward'}) {
-      &compout($r,$ENV{'form.forward'});
-  } elsif ($ENV{'form.markread'}) {
-  } elsif ($ENV{'form.markdel'}) {
-      &statuschange($ENV{'form.markdel'},'deleted');
-      &disall($r);
-  } elsif ($ENV{'form.markeddel'}) {
-      my $total=0;
-      foreach (keys %ENV) {
-          if ($_=~/^form\.delmark_(.*)$/) {
-	      &statuschange(&Apache::lonnet::unescape($1),'deleted');
-              $total++;
-          }
-      }
-      $r->print('Deleted '.$total.' message(s)<p>');
-      &disall($r);
-  } elsif ($ENV{'form.markunread'}) {
-      &statuschange($ENV{'form.markunread'},'new');
-      &disall($r);
-  } elsif ($ENV{'form.compose'}) {
-      &compout($r,'',$ENV{'form.compose'});
-  } elsif ($ENV{'form.recordftf'}) {
-      &facetoface($r,$ENV{'form.recordftf'});
-  } elsif ($ENV{'form.sendmail'}) {
-      my $sendstatus='';
-      if ($ENV{'form.send'}) {
-	  my %content=();
-	  undef %content;
-	  if ($ENV{'form.forwid'}) {
-	      my $msgid=$ENV{'form.forwid'};
-	      my %message=&Apache::lonnet::get('nohist_email',[$msgid]);
-	      %content=&unpackagemsg($message{$msgid},1);
-	      &statuschange($msgid,'forwarded');
-	      $ENV{'form.message'}.="\n\n-- Forwarded message --\n\n".
-		  $content{'message'};
-	  }
-	  my %toaddr=();
-	  undef %toaddr;
-	  if ($ENV{'form.sendmode'} eq 'group') {
-	      foreach (keys %ENV) {
-		  if ($_=~/^form\.send\_to\_\&\&\&[^\&]*\&\&\&\_(.+)$/) {
-		      $toaddr{$1}='';
-		  }
-	      }
-	  } elsif ($ENV{'form.sendmode'} eq 'upload') {
-	      foreach (split(/[\n\r\f]+/,$ENV{'form.upfile'})) {
-		  my ($rec,$txt)=split(/\s*\:\s*/,$_);
-		  if ($txt) {
-		      $rec=~s/\@/\:/;
-		      $toaddr{$rec}.=$txt."\n";
-		  }
-	      }
-	  } else {
-	      $toaddr{$ENV{'form.recuname'}.':'.$ENV{'form.recdomain'}}='';
-	  }
-	  if ($ENV{'form.additionalrec'}) {
-	      foreach (split(/\,/,$ENV{'form.additionalrec'})) {
-		  my ($auname,$audom)=split(/\@/,$_);
-		  $toaddr{$auname.':'.$audom}='';
-	      }
-	  }
-	  foreach (keys %toaddr) {
-	      my ($recuname,$recdomain)=split(/\:/,$_);
-	      my $msgtxt=&Apache::lonfeedback::clear_out_html($ENV{'form.message'});
-	      if ($toaddr{$_}) { $msgtxt.='<hr>'.$toaddr{$_}; }    
-	      if ((($ENV{'form.critmsg'}) || ($ENV{'form.sendbck'})) && 
-		  (&Apache::lonnet::allowed('srm',$ENV{'request.course.id'}))) {
-		  $r->print(&mt('Sending critical message').' ...');
-                  $sendstatus.=' '.&user_crit_msg($recuname,$recdomain,
-					   &Apache::lonfeedback::clear_out_html($ENV{'form.subject'}),
-					   $msgtxt,
-					   $ENV{'form.sendbck'});
-	      } else {
-		  $r->print(&mt('Sending').' ...');
-                  $sendstatus.=' '.&user_normal_msg($recuname,$recdomain,
-				                         &Apache::lonfeedback::clear_out_html($ENV{'form.subject'}),
-							 $msgtxt,
-							 $content{'citation'});
-	      }
-	      $r->print('<br />');
-	  }
-      }
-      if ($sendstatus=~/^(\s*(?:ok|con_delayed)\s*)*$/) {
-	  $r->print('<br /><font color="green">'.&mt('Completed.').'</font>');
-	  if ($ENV{'form.displayedcrit'}) {
-	      &discrit($r);
-	  } else {
-	      &disall($r);
-	  }
-      } else {
-	  $r->print(
-  '<h2><font color="red">'.&mt('Could not deliver message').'</font></h2>'.
-  &mt('Please use the browser "Back" button and correct the recipient addresses')
-		    );
-      }
-  } else {
-      &disall($r);
-  }
-  $r->print('</body></html>');
-  return OK;
-
+	$r->print('<html><head><title>EMail and Messaging</title>');
+	if (defined($content{'baseurl'})) {
+	    $r->print("<base href=\"http://$ENV{'SERVER_NAME'}/$content{'baseurl'}\" />");
+	}
+	$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'});
+    } elsif ($ENV{'form.replyto'}) {
+	&comprep($r,$ENV{'form.replyto'});
+    } elsif ($ENV{'form.sendreply'}) {
+	if ($ENV{'form.send'}) {
+	    my $msgid=$ENV{'form.sendreply'};
+	    my %message=&Apache::lonnet::get('nohist_email',[$msgid]);
+	    my %content=&unpackagemsg($message{$msgid},1);
+	    &statuschange($msgid,'replied');
+	    if ((($ENV{'form.critmsg'}) || ($ENV{'form.sendbck'})) && 
+		(&Apache::lonnet::allowed('srm',$ENV{'request.course.id'}))) {
+		$r->print(&mt('Sending critical message').': '.
+			  &user_crit_msg($content{'sendername'},
+					 $content{'senderdomain'},
+					 &Apache::lonfeedback::clear_out_html($ENV{'form.subject'}),
+					 &Apache::lonfeedback::clear_out_html($ENV{'form.message'}),
+					 $ENV{'form.sendbck'}));
+	    } else {
+		$r->print(&mt('Sending').': '.&user_normal_msg($content{'sendername'},
+							       $content{'senderdomain'},
+							       &Apache::lonfeedback::clear_out_html($ENV{'form.subject'}),
+							       &Apache::lonfeedback::clear_out_html($ENV{'form.message'})));
+	    }
+	}
+	if ($ENV{'form.displayedcrit'}) {
+	    &discrit($r);
+	} else {
+	    &disall($r);
+	}
+    } elsif ($ENV{'form.confirm'}) {
+	foreach (keys %ENV) {
+	    if ($_=~/^form\.rec\_(.*)$/) {
+		$r->print('<b>Confirming Receipt:</b> '.
+			  &user_crit_received($1).'<br>');
+	    }
+	    if ($_=~/^form\.reprec\_(.*)$/) {
+		my $msgid=$1;
+		$r->print('<b>Confirming Receipt:</b> '.
+			  &user_crit_received($msgid).'<br>');
+		&comprep($r,$msgid);
+	    }
+	}
+	&discrit($r);
+    } elsif ($ENV{'form.critical'}) {
+	&discrit($r);
+    } elsif ($ENV{'form.forward'}) {
+	&compout($r,$ENV{'form.forward'});
+    } elsif ($ENV{'form.markread'}) {
+    } elsif ($ENV{'form.markdel'}) {
+	&statuschange($ENV{'form.markdel'},'deleted');
+	&disall($r);
+    } elsif ($ENV{'form.markeddel'}) {
+	my $total=0;
+	foreach (keys %ENV) {
+	    if ($_=~/^form\.delmark_(.*)$/) {
+		&statuschange(&Apache::lonnet::unescape($1),'deleted');
+		$total++;
+	    }
+	}
+	$r->print('Deleted '.$total.' message(s)<p>');
+	&disall($r);
+    } elsif ($ENV{'form.markunread'}) {
+	&statuschange($ENV{'form.markunread'},'new');
+	&disall($r);
+    } elsif ($ENV{'form.compose'}) {
+	&compout($r,'',$ENV{'form.compose'});
+    } elsif ($ENV{'form.recordftf'}) {
+	&facetoface($r,$ENV{'form.recordftf'});
+    } elsif ($ENV{'form.sendmail'}) {
+	my $sendstatus='';
+	if ($ENV{'form.send'}) {
+	    my %content=();
+	    undef %content;
+	    if ($ENV{'form.forwid'}) {
+		my $msgid=$ENV{'form.forwid'};
+		my %message=&Apache::lonnet::get('nohist_email',[$msgid]);
+		%content=&unpackagemsg($message{$msgid},1);
+		&statuschange($msgid,'forwarded');
+		$ENV{'form.message'}.="\n\n-- Forwarded message --\n\n".
+		    $content{'message'};
+	    }
+	    my %toaddr=();
+	    undef %toaddr;
+	    if ($ENV{'form.sendmode'} eq 'group') {
+		foreach (keys %ENV) {
+		    if ($_=~/^form\.send\_to\_\&\&\&[^\&]*\&\&\&\_(.+)$/) {
+			$toaddr{$1}='';
+		    }
+		}
+	    } elsif ($ENV{'form.sendmode'} eq 'upload') {
+		foreach (split(/[\n\r\f]+/,$ENV{'form.upfile'})) {
+		    my ($rec,$txt)=split(/\s*\:\s*/,$_);
+		    if ($txt) {
+			$rec=~s/\@/\:/;
+			$toaddr{$rec}.=$txt."\n";
+		    }
+		}
+	    } else {
+		$toaddr{$ENV{'form.recuname'}.':'.$ENV{'form.recdomain'}}='';
+	    }
+	    if ($ENV{'form.additionalrec'}) {
+		foreach (split(/\,/,$ENV{'form.additionalrec'})) {
+		    my ($auname,$audom)=split(/\@/,$_);
+		    $toaddr{$auname.':'.$audom}='';
+		}
+	    }
+	    foreach (keys %toaddr) {
+		my ($recuname,$recdomain)=split(/\:/,$_);
+		my $msgtxt=&Apache::lonfeedback::clear_out_html($ENV{'form.message'});
+		if ($toaddr{$_}) { $msgtxt.='<hr>'.$toaddr{$_}; }    
+		if ((($ENV{'form.critmsg'}) || ($ENV{'form.sendbck'})) && 
+		    (&Apache::lonnet::allowed('srm',$ENV{'request.course.id'}))) {
+		    $r->print(&mt('Sending critical message').' ...');
+		    $sendstatus.=' '.&user_crit_msg($recuname,$recdomain,
+						    &Apache::lonfeedback::clear_out_html($ENV{'form.subject'}),
+						    $msgtxt,
+						    $ENV{'form.sendbck'});
+		} else {
+		    $r->print(&mt('Sending').' ...');
+		    $sendstatus.=' '.&user_normal_msg($recuname,$recdomain,
+						      &Apache::lonfeedback::clear_out_html($ENV{'form.subject'}),
+						      $msgtxt,
+						      $content{'citation'});
+		}
+		$r->print('<br />');
+	    }
+	}
+	if ($sendstatus=~/^(\s*(?:ok|con_delayed)\s*)*$/) {
+	    $r->print('<br /><font color="green">'.&mt('Completed.').'</font>');
+	    if ($ENV{'form.displayedcrit'}) {
+		&discrit($r);
+	    } else {
+		&disall($r);
+	    }
+	} else {
+	    $r->print(
+		      '<h2><font color="red">'.&mt('Could not deliver message').'</font></h2>'.
+		      &mt('Please use the browser "Back" button and correct the recipient addresses')
+		      );
+	}
+    } else {
+	&disall($r);
+    }
+    $r->print('</body></html>');
+    return OK;
 }
 # ================================================= Main program, reset counter
 

--www1078103991--