[LON-CAPA-cvs] cvs: loncom /lonnet/perl lonnet.pm

matthew lon-capa-cvs@mail.lon-capa.org
Fri, 26 Apr 2002 18:49:10 -0000


matthew		Fri Apr 26 14:49:10 2002 EDT

  Modified files:              
    /loncom/lonnet/perl	lonnet.pm 
  Log:
  &modifyuser now takes a $desiredhost parameter.  &modifyuser logic reworked
  to put a user at a given host even if they are being enrolled in a class.
  
  
Index: loncom/lonnet/perl/lonnet.pm
diff -u loncom/lonnet/perl/lonnet.pm:1.208 loncom/lonnet/perl/lonnet.pm:1.209
--- loncom/lonnet/perl/lonnet.pm:1.208	Wed Apr 10 11:28:45 2002
+++ loncom/lonnet/perl/lonnet.pm	Fri Apr 26 14:49:09 2002
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # TCP networking package
 #
-# $Id: lonnet.pm,v 1.208 2002/04/10 15:28:45 albertel Exp $
+# $Id: lonnet.pm,v 1.209 2002/04/26 18:49:09 matthew Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -1877,11 +1877,11 @@
 # ----------------------------------------------------------------- Create User
     if (($uhome eq 'no_host') && ($umode) && ($upass)) {
         my $unhome='';
-	if ($ENV{'course.'.$ENV{'request.course.id'}.'.domain'} eq $udom) {
-	    $unhome=$ENV{'course.'.$ENV{'request.course.id'}.'.home'};
-        } elsif (defined($desiredhome) && $hostdom{$desiredhome} eq $udom) { 
+        if (defined($desiredhome) && $hostdom{$desiredhome} eq $udom) { 
             $unhome = $desiredhome;
-        } else {
+	} elsif($ENV{'course.'.$ENV{'request.course.id'}.'.domain'} eq $udom) {
+	    $unhome=$ENV{'course.'.$ENV{'request.course.id'}.'.home'};
+        } else { # load balancing routine for determining $unhome
             my $tryserver;
             my $loadm=10000000;
             foreach $tryserver (keys %libserv) {
@@ -1907,7 +1907,7 @@
         if (($uhome eq '') || ($uhome eq 'no_host') || ($uhome ne $unhome)) {
 	    return 'error: verify home';
         }
-    }
+    }   # End of creation of new user
 # ---------------------------------------------------------------------- Add ID
     if ($uid) {
        $uid=~tr/A-Z/a-z/;
@@ -1943,14 +1943,15 @@
 
 sub modifystudent {
     my ($udom,$uname,$uid,$umode,$upass,$first,$middle,$last,$gene,$usec,
-        $end,$start,$forceid)=@_;
+        $end,$start,$forceid,$desiredhome)=@_;
     my $cid='';
     unless ($cid=$ENV{'request.course.id'}) {
 	return 'not_in_class';
     }
 # --------------------------------------------------------------- Make the user
     my $reply=&modifyuser
-	($udom,$uname,$uid,$umode,$upass,$first,$middle,$last,$gene,$forceid);
+	($udom,$uname,$uid,$umode,$upass,$first,$middle,$last,$gene,$forceid,
+         $desiredhome);
     unless ($reply eq 'ok') { return $reply; }
     my $uhome=&homeserver($uname,$udom);
     if (($uhome eq '') || ($uhome eq 'no_host')) {