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

albertel lon-capa-cvs@mail.lon-capa.org
Tue, 25 Apr 2006 19:50:11 -0000


albertel		Tue Apr 25 15:50:11 2006 EDT

  Modified files:              
    /loncom/interface	lonmsgdisplay.pm 
  Log:
  - some random cleanups to the code
  
  
Index: loncom/interface/lonmsgdisplay.pm
diff -u loncom/interface/lonmsgdisplay.pm:1.12 loncom/interface/lonmsgdisplay.pm:1.13
--- loncom/interface/lonmsgdisplay.pm:1.12	Tue Apr 25 15:45:50 2006
+++ loncom/interface/lonmsgdisplay.pm	Tue Apr 25 15:50:09 2006
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Routines for messaging display
 #
-# $Id: lonmsgdisplay.pm,v 1.12 2006/04/25 19:45:50 albertel Exp $
+# $Id: lonmsgdisplay.pm,v 1.13 2006/04/25 19:50:09 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -1719,17 +1719,17 @@
 	    %content=&Apache::lonmsg::unpackagemsg($message{$msgid},1);
 	    &statuschange($msgid,'replied',$folder);
 	}
-	my %toaddr=();
-	undef %toaddr;
+
+	my %toaddr;
 	if ($env{'form.sendmode'} eq 'group') {
-	    foreach (keys %env) {
-		if ($_=~/^form\.send\_to\_\&\&\&[^\&]*\&\&\&\_(.+)$/) {
+	    foreach $address (keys(%env)) {
+		if ($address=~/^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*/,$_);
+	    foreach my $line (split(/[\n\r\f]+/,$env{'form.upfile'})) {
+		my ($rec,$txt)=split(/\s*\:\s*/,$line);
 		if ($txt) {
 		    $rec=~s/\@/\:/;
 		    $toaddr{$rec}.=$txt."\n";
@@ -1761,23 +1761,31 @@
             $savemsg=&Apache::lonfeedback::clear_out_html($env{'form.message'});
         }
 	
-	foreach (keys %toaddr) {
-	    my ($recuname,$recdomain)=split(/\:/,$_);
+	foreach my $address (sort(keys(%toaddr))) {
+	    my ($recuname,$recdomain)=split(/\:/,$address);
             my $msgtxt = $savemsg;
-	    if ($toaddr{$_}) { $msgtxt.='<hr />'.$toaddr{$_}; }
+	    if ($toaddr{$address}) { $msgtxt.='<hr />'.$toaddr{$address}; }
 	    my @thismsg;
 	    if ((($env{'form.critmsg'}) || ($env{'form.sendbck'})) && 
 		(&Apache::lonnet::allowed('srm',$env{'request.course.id'})
 		 || &Apache::lonnet::allowed('srm',$env{'request.course.id'}.
 					     '/'.$env{'request.course.sec'}))) {
-		$r->print(&mt('Sending critical message').' '.$recuname.'@'.$recdomain.': ');
-		@thismsg=&Apache::lonmsg::user_crit_msg($recuname,$recdomain,$msgsubj,$msgtxt,
-				$env{'form.sendbck'},$env{'form.permanent'},
-                                                             \$sentmessage{$_});
+		$r->print(&mt('Sending critical message').' '.$recuname.':'.$recdomain.': ');
+		@thismsg=
+		    &Apache::lonmsg::user_crit_msg($recuname,$recdomain,
+						   $msgsubj,$msgtxt,
+						   $env{'form.sendbck'},
+						   $env{'form.permanent'},
+						   \$sentmessage{$address});
 	    } else {
 		$r->print(&mt('Sending').' '.$recuname.'@'.$recdomain.': ');
-		@thismsg=&Apache::lonmsg::user_normal_msg($recuname,$recdomain,$msgsubj,$msgtxt,
-					  $content{'citation'},undef,undef,$env{'form.permanent'},\$sentmessage{$_});
+		@thismsg=
+		    &Apache::lonmsg::user_normal_msg($recuname,$recdomain,
+						     $msgsubj,$msgtxt,
+						     $content{'citation'},
+						     undef,undef,
+						     $env{'form.permanent'},
+						     \$sentmessage{$address});
             }
 	    if (($env{'request.course.id'}) && (($msgtype eq 'critical') || 
                                          ($env{'form.sendmode'} eq 'group'))) {
@@ -1789,7 +1797,6 @@
 		    }
 		}
 	    }
-	    $r->print(join(' ',@thismsg).'<br />');
 	    $sendstatus.=' '.join(' ',@thismsg);
 	}
         if (($env{'request.course.id'}) && (($env{'form.sendmode'} eq 'group')
@@ -1813,10 +1820,11 @@
             }
             if ($specialresult eq 'ok') {
                 my $record_sent;
-                my @recusers = ();
-                my @recudoms = ();
-                my ($stamp,$crssubj,$msgname,$msgdom,$msgcount,$context,$pid) = 
-                            split(/\:/,&Apache::lonnet::unescape($specialmsgid));
+                my @recusers;
+                my @recudoms;
+                my ($stamp,$crssubj,$msgname,$msgdom,$msgcount,$context,$pid) =
+		    split(/\:/,&Apache::lonnet::unescape($specialmsgid));
+
                 foreach my $recipient (sort(keys(%toaddr))) {
                     if ($specialmsg_status{$recipient} eq 'ok') {
                         my $usersubj = $subj_prefix.'['.$recipient.']';
@@ -1828,15 +1836,15 @@
                         &Apache::lonmsg::user_normal_msg_raw($cnum,$cdom,$subj_prefix.
                                              ' ['.$recipient.']',$msgsubj,undef,
                         undef,undef,undef,$usermsgid,undef,undef,$specialmsgid);
-                        my ($uname,$udom) = split/:/,$recipient;
+                        my ($uname,$udom) = split(/:/,$recipient);
                         push(@recusers,$uname);
                         push(@recudoms,$udom);
                     }
                 }
                 if (@recusers) {
                     my $specialmessage;
-                    my $sentsubj = $subj_prefix.' ('.$numspecial.' sent) '.
-                                                                       $msgsubj;
+                    my $sentsubj = 
+			$subj_prefix.' ('.$numspecial.' sent) '.$msgsubj;
                     $sentsubj = &HTML::Entities::encode($sentsubj,'<>&"');
                     my $sentmsgid = 
 			&Apache::lonmsg::buildmsgid($stamp,$sentsubj,$msgname,