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

matthew lon-capa-cvs@mail.lon-capa.org
Fri, 08 Feb 2002 19:40:42 -0000


matthew		Fri Feb  8 14:40:42 2002 EDT

  Modified files:              
    /loncom/interface	loncreateuser.pm 
  Log:
  Replaced 'map' statements with equivalent 'foreach' statements in preperation
  for larger changes.
  
  
Index: loncom/interface/loncreateuser.pm
diff -u loncom/interface/loncreateuser.pm:1.23 loncom/interface/loncreateuser.pm:1.24
--- loncom/interface/loncreateuser.pm:1.23	Sat Jan  5 20:29:52 2002
+++ loncom/interface/loncreateuser.pm	Fri Feb  8 14:40:42 2002
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Create a user
 #
-# $Id: loncreateuser.pm,v 1.23 2002/01/06 01:29:52 harris41 Exp $
+# $Id: loncreateuser.pm,v 1.24 2002/02/08 19:40:42 matthew Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -46,7 +46,7 @@
 # 05/10,10/16 Gerd Kortemeyer 
 # 11/12,11/13,11/15 Scott Harrison
 #
-# $Id: loncreateuser.pm,v 1.23 2002/01/06 01:29:52 harris41 Exp $
+# $Id: loncreateuser.pm,v 1.24 2002/02/08 19:40:42 matthew Exp $
 ###
 
 package Apache::loncreateuser;
@@ -266,14 +266,14 @@
     my $uhome=&Apache::lonnet::homeserver($ccuname,$ccdomain);
     my %incdomains; 
     my %inccourses;
-    map {
+    foreach (%Apache::lonnet::hostdom) {
        $incdomains{$_}=1;
-    } values %Apache::lonnet::hostdom;
-    map {
+    }
+    foreach (keys(%ENV)) {
 	if ($_=~/^user\.priv\.cm\.\/(\w+)\/(\w+)/) {
 	    $inccourses{$1.'_'.$2}=1;
         }
-    } %ENV;
+    }
     if ($uhome eq 'no_host') {
 	$r->print(<<ENDNUSER);
 <h2>New user $ccuname at $ccdomain</h2>
@@ -306,7 +306,7 @@
            $r->print('<h4>Revoke Existing Roles</h4>'.
              '<table border=2><tr><th>Revoke</th><th>Role</th><th>Extent</th>'.
 		     '<th>Start</th><th>End</th>');
-           map {
+	   foreach (split(/&/,$rolesdump)) {
              if ($_!~/^rolesdef\&/) {
 
               my ($area,$role)=split(/=/,$_);
@@ -360,7 +360,7 @@
                         ($tstart?localtime($tstart):'&nbsp;').'</td><td>'.
                         ($tend?localtime($tend):'&nbsp;')."</td></tr>\n");
 	     }
-	   } split(/&/,$rolesdump);
+	   } 
 	   $r->print('</table>');
          }   
 	my $currentauth=&Apache::lonnet::queryauthenticate($ccuname,$ccdomain);
@@ -488,9 +488,9 @@
     $r->print('<h4>Domain Level</h4>'.
     '<table border=2><tr><th>Activate</th><th>Role</th><th>Extent</th>'.
     '<th>Start</th><th>End</th></tr>');
-    map {
+    foreach ( sort( keys(%incdomains))) {
 	my $thisdomain=$_;
-        map {
+        foreach ('dc','li','dg','au') {
             if (&Apache::lonnet::allowed('c'.$_,$thisdomain)) {
                my $plrole=&Apache::lonnet::plaintext($_);
                $r->print(<<ENDDROW);
@@ -507,8 +507,8 @@
 </tr>
 ENDDROW
             }
-        } ('dc','li','dg','au');
-    } sort keys %incdomains;
+        } 
+    }
     $r->print('</table>');
 #
 # Course level
@@ -516,7 +516,7 @@
     $r->print('<h4>Course Level</h4>'.
     '<table border=2><tr><th>Activate</th><th>Role</th><th>Extent</th>'.
     '<th>Group/Section</th><th>Start</th><th>End</th></tr>');
-    map {
+    foreach (sort( keys(%inccourses))) {
 	my $thiscourse=$_;
 	my $protectedcourse=$_;
         $thiscourse=~s:_:/:g;
@@ -525,7 +525,7 @@
         my $bgcol=$thiscourse;
         $bgcol=~s/[^8-9b-e]//g;
         $bgcol=substr($bgcol.$bgcol.$bgcol.'ffffff',0,6);
-        map {
+        foreach  ('st','ta','ep','ad','in','cc') {
             if (&Apache::lonnet::allowed('c'.$_,$thiscourse)) {
                my $plrole=&Apache::lonnet::plaintext($_);
                $r->print("
@@ -547,8 +547,8 @@
 </tr>
 ENDROW
             }
-        } ('st','ta','ep','ad','in','cc');
-    } sort keys %inccourses;
+        }
+    } 
     $r->print('</table>');
     $r->print('<input type=submit value="Modify User">');
     $r->print('</form></body></html>');
@@ -641,7 +641,7 @@
    }
     my $now=time;
     $r->print('<h3>Modifying Roles</h3>');
-    map {
+    foreach (keys (%ENV)) {
 	if (($_=~/^form\.rev\:([^\_]+)\_([^\_]+)$/) && ($ENV{$_})) {
            $r->print('Revoking '.$2.' in '.$1.': '.
           &Apache::lonnet::assignrole($ENV{'form.cdomain'},$ENV{'form.cuname'},
@@ -658,8 +658,8 @@
 	              $ENV{'course.'.$cid.'.home'}).'<br>');
            }
 	}
-    } keys %ENV;
-    map {
+    } 
+    foreach (keys(%ENV)) {
 	if (($_=~/^form\.act\_([^\_]+)\_([^\_]+)\_([^\_]+)$/) && ($ENV{$_})) {
             my $url='/'.$1.'/'.$2;
             if ($ENV{'form.sec_'.$1.'_'.$2.'_'.$3}) {
@@ -701,7 +701,7 @@
           &Apache::lonnet::assignrole($ENV{'form.cdomain'},$ENV{'form.cuname'},
                                       $url,$2,$end,$start).'<br>');
         }
-    } keys %ENV;
+    }
     $r->print('</body></html>');
 }