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

raeburn lon-capa-cvs@mail.lon-capa.org
Thu, 23 Nov 2006 16:40:18 -0000


This is a MIME encoded message

--raeburn1164300018
Content-Type: text/plain

raeburn		Thu Nov 23 11:40:18 2006 EDT

  Modified files:              
    /loncom/interface	lonmsgdisplay.pm 
  Log:
  Eliminate $_
  
  Style
  
  
--raeburn1164300018
Content-Type: text/plain
Content-Disposition: attachment; filename="raeburn-20061123114018.txt"

Index: loncom/interface/lonmsgdisplay.pm
diff -u loncom/interface/lonmsgdisplay.pm:1.41 loncom/interface/lonmsgdisplay.pm:1.42
--- loncom/interface/lonmsgdisplay.pm:1.41	Wed Oct  4 16:26:48 2006
+++ loncom/interface/lonmsgdisplay.pm	Thu Nov 23 11:40:17 2006
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Routines for messaging display
 #
-# $Id: lonmsgdisplay.pm,v 1.41 2006/10/04 20:26:48 albertel Exp $
+# $Id: lonmsgdisplay.pm,v 1.42 2006/11/23 16:40:17 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -486,8 +486,8 @@
         '<input type="hidden" name="confirm" value="true" />';
     my %what=&Apache::lonnet::dump('critical');
     my $result = '';
-    foreach (sort keys %what) {
-        my %content=&Apache::lonmsg::unpackagemsg($what{$_});
+    foreach my $key (sort(keys(%what))) {
+        my %content=&Apache::lonmsg::unpackagemsg($what{$key});
         next if ($content{'senderdomain'} eq '');
         $result.='<hr />'.&mt('From').': <b>'.
 &Apache::loncommon::aboutmewrapper(
@@ -500,8 +500,8 @@
             '</pre><small>'.
 &mt('You have to confirm that you received this message. After confirmation, this message will be moved to your regular inbox').
             '</small><br />'.
-            '<input type="submit" name="rec_'.$_.'" value="'.&mt('Confirm Receipt').'" />'.
-            '<input type="submit" name="reprec_'.$_.'" '.
+            '<input type="submit" name="rec_'.$key.'" value="'.&mt('Confirm Receipt').'" />'.
+            '<input type="submit" name="reprec_'.$key.'" '.
                   'value="'.&mt('Confirm Receipt and Reply').'" />';
     }
     # Check to see if there were any messages.
@@ -658,8 +658,8 @@
     my %status_cache = 
 	&Apache::lonnet::get('email_status',\@msgids);
     my %descriptions;
-    foreach (@msgids) {
-	my $msgid=&escape($_);
+    foreach my $id (@msgids) {
+	my $msgid=&escape($id);
         my ($sendtime,$shortsubj,$fromname,$fromdom,$status,$fromcid)=
 	    &Apache::lonmsg::unpackmsgid($msgid,undef,undef,\%status_cache);
         if (defined($sendtime) && $sendtime!~/error/) {
@@ -668,7 +668,7 @@
             $sendtime = &Apache::lonlocal::locallocaltime($sendtime);
             if ($status eq 'new') {
                 if ($numsendtime >= $startblock && ($numsendtime <= $endblock && $endblock > 0) ) {
-                    $blocked{$_} = 'ON';
+                    $blocked{$id} = 'ON';
                     $numblocked ++;
                 } else {
                     push @newmsgs, { 
@@ -694,8 +694,8 @@
 <tr class="LC_mail_new">
 <td><a href="/adm/email?dismode=new&display=$msg->{'msgid'}">$lt{'op'}</a></td>
 ENDLINK
-            foreach ('sendtime','from','fromdom','shortsub','course') {
-                $r->print("<td>$msg->{$_}</td>");
+            foreach my $item ('sendtime','from','fromdom','shortsub','course') {
+                $r->print("<td>$msg->{$item}</td>");
             }
             $r->print("</td></tr>");
         }
@@ -766,7 +766,7 @@
 </script>
 ENDDISHEADER
     my $fsqs='&folder='.$folder;
-    my @temp=sortedmessages(\%blocked,$startblock,$endblock,\$numblocked,$folder);
+    my @temp=&sortedmessages(\%blocked,$startblock,$endblock,\$numblocked,$folder);
     my $totalnumber=$#temp+1;
     unless ($totalnumber>0) {
 	$r->print('<h2>'.&mt('Empty Folder').'</h2>');
@@ -1135,8 +1135,8 @@
 			 $env{'course.'.$env{'request.course.id'}.'.num'},
                          '%255b'.$user.'%253a'.$domain.'%255d');
     my $result='';
-    foreach (sort(keys(%records))) {
-        my %content=&Apache::lonmsg::unpackagemsg($records{$_});
+    foreach my $key (sort(keys(%records))) {
+        my %content=&Apache::lonmsg::unpackagemsg($records{$key});
         next if ($content{'senderdomain'} eq '');
         next if ($content{'subject'} !~ /^Record/);
 	# &Apache::lonfeedback::newline_to_br(\$content{'message'});
@@ -1163,8 +1163,8 @@
 			 $env{'course.'.$env{'request.course.id'}.'.num'},
                          '%255b'.$user.'%253a'.$domain.'%255d');
     my $result='';
-    foreach (sort keys %records) {
-        my %content=&Apache::lonmsg::unpackagemsg($records{$_});
+    foreach my $key (sort(keys(%records))) {
+        my %content=&Apache::lonmsg::unpackagemsg($records{$key});
         next if ($content{'senderdomain'} eq '');
 	&Apache::lonfeedback::newline_to_br(\$content{'message'});
         if ($content{'subject'}=~/^Record/) {
@@ -1387,35 +1387,35 @@
     my $addtotal = 0;
     my %blocking = ();
     $r->print('<h3>'.$lt{'head'}.'</h3>');
-    foreach (keys %env) {
-        if ($_ =~ m/^form\.modify_(\w+)$/) {
+    foreach my $envkey (keys(%env)) {
+        if ($envkey =~ m/^form\.modify_(\w+)$/) {
             $adds{$1} = $1;
             $removals{$1} = $1;
             $modtotal ++;
-        } elsif ($_ =~ m/^form\.cancel_(\d+)$/) {
+        } elsif ($envkey =~ m/^form\.cancel_(\d+)$/) {
             $cancels{$1} = $1;
             unless ( defined($removals{$1}) ) {
                 $removals{$1} = $1;
                 $canceltotal ++;
             }
-        } elsif ($_ =~ m/^form\.add_(\d+)$/) {
+        } elsif ($envkey =~ m/^form\.add_(\d+)$/) {
             $adds{$1} = $1;
             $addtotal ++;
         }
     }
 
-    foreach (keys %removals) {
-        my $hashkey = $env{'form.key_'.$_};
+    foreach my $key (keys(%removals)) {
+        my $hashkey = $env{'form.key_'.$key};
         &Apache::lonnet::del('comm_block',["$hashkey"],
                          $env{'course.'.$env{'request.course.id'}.'.domain'},
                          $env{'course.'.$env{'request.course.id'}.'.num'}
                          );
     }
-    foreach (keys %adds) {
-        unless ( defined($cancels{$_}) ) {
-            my ($newstart,$newend) = &get_dates_from_form($_);
+    foreach my $key (keys(%adds)) {
+        unless ( defined($cancels{$key}) ) {
+            my ($newstart,$newend) = &get_dates_from_form($key);
             my $newkey = $newstart.'____'.$newend;
-            $blocking{$newkey} = $env{'user.name'}.':'.$env{'user.domain'}.':'.$env{'form.title_'.$_};
+            $blocking{$newkey} = $env{'user.name'}.':'.$env{'user.domain'}.':'.$env{'form.title_'.$key};
         }
     }
     if ($addtotal + $modtotal > 0) {
@@ -1588,7 +1588,7 @@
 	$setters->{$course}{'staff'} = [];
 	$setters->{$course}{'times'} = [];
 	my %records = &Apache::lonnet::dump('comm_block',$cdom,$cnum);
-	foreach my $record (keys %records) {
+	foreach my $record (keys(%records)) {
 	    my ($start,$end) = ($record =~ m/^(\d+)____(\d+)$/);
 	    if ($start <= time && $end >= time) {
 		my ($staff_name,$staff_dom,$title) = 
@@ -1814,9 +1814,9 @@
     my ($r)=@_;
     my $msgtxt=&Apache::lonfeedback::clear_out_html($env{'form.message'});
     my $cleanmsgtxt='';
-    foreach (split(/[\n\r]/,$msgtxt)) {
-	unless ($_=~/^\s*(\>|\&gt\;)/) {
-	    $cleanmsgtxt.=$_."\n";
+    foreach my $line (split(/[\n\r]/,$msgtxt)) {
+	unless ($line=~/^\s*(\>|\&gt\;)/) {
+	    $cleanmsgtxt.=$line."\n";
 	}
     }
     my $key=&escape($env{'form.baseurl'}).'___'.time;
@@ -1833,8 +1833,8 @@
 	$r->print(&mt('No stored comments yet.'));
     } else {
 	my $found=0;
-	foreach (sort keys %msgs) {
-	    $r->print("\n".$msgs{$_}."<hr />");
+	foreach my $key (sort(keys(%msgs))) {
+	    $r->print("\n".$msgs{$key}."<hr />");
 	    $found=1;
 	}
 	unless ($found) {
@@ -1918,8 +1918,8 @@
 	    }
 	}
 	if ($env{'form.additionalrec'}) {
-	    foreach (split(/\,/,$env{'form.additionalrec'})) {
-		my ($auname,$audom)=split(/\@/,$_);
+	    foreach my $rec (split(/\,/,$env{'form.additionalrec'})) {
+		my ($auname,$audom)=split(/\@/,$rec);
 		if (($auname ne "") && ($audom ne "")) {
 		    $toaddr{$auname.':'.$audom}='';
 		}
@@ -2140,12 +2140,12 @@
     } elsif ($env{'form.confirm'}) {
 	&printheader($r,'','Confirmed Receipt');
 	my $replying = 0;
-	foreach (keys %env) {
-	    if ($_=~/^form\.rec\_(.*)$/) {
+	foreach my $envkey (keys(%env)) {
+	    if ($envkey=~/^form\.rec\_(.*)$/) {
 		$r->print('<b>'.&mt('Confirming Receipt').':</b> '.
 			  &Apache::lonmsg::user_crit_received($1).'<br>');
 	    }
-	    if ($_=~/^form\.reprec\_(.*)$/) {
+	    if ($envkey=~/^form\.reprec\_(.*)$/) {
 		my $msgid=$1;
 		$r->print('<b>'.&mt('Confirming Receipt').':</b> '.
 			  &Apache::lonmsg::user_crit_received($msgid).'<br>');

--raeburn1164300018--