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

matthew lon-capa-cvs@mail.lon-capa.org
Mon, 22 Apr 2002 18:04:19 -0000


matthew		Mon Apr 22 14:04:19 2002 EDT

  Modified files:              
    /loncom/interface	loncommon.pm loncreateuser.pm 
  Log:
  Moved home server list generating code to loncommon from loncreateuser.
  
  
Index: loncom/interface/loncommon.pm
diff -u loncom/interface/loncommon.pm:1.32 loncom/interface/loncommon.pm:1.33
--- loncom/interface/loncommon.pm:1.32	Mon Apr 22 11:26:46 2002
+++ loncom/interface/loncommon.pm	Mon Apr 22 14:04:19 2002
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # a pile of common routines
 #
-# $Id: loncommon.pm,v 1.32 2002/04/22 15:26:46 matthew Exp $
+# $Id: loncommon.pm,v 1.33 2002/04/22 18:04:19 matthew Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -146,6 +146,33 @@
     
 }
 # ============================================================= END BEGIN BLOCK
+###############################################################
+##        Home server <option> list generating code          ##
+###############################################################
+sub get_home_servers {
+    my $domain = shift;
+    my %home_servers;
+    foreach (keys(%Apache::lonnet::libserv)) {
+        if ($Apache::lonnet::hostdom{$_} eq $domain) {
+            $home_servers{$_} = $Apache::lonnet::hostname{$_};
+        }
+    }
+    return %home_servers;
+}
+
+sub home_server_option_list {
+    my $domain = shift;
+    my %servers = &get_home_servers($domain);
+    my $result = '';
+    foreach (sort keys(%servers)) {
+        $result.=
+            '<option value="'.$_.'">'.$_.' '.$servers{$_}."</option>\n";
+    }
+    return $result;
+}
+###############################################################
+##    End of home server <option> list generating code       ##
+###############################################################
 
 ###############################################################
 ##    Authentication changing form generation subroutines    ##
Index: loncom/interface/loncreateuser.pm
diff -u loncom/interface/loncreateuser.pm:1.31 loncom/interface/loncreateuser.pm:1.32
--- loncom/interface/loncreateuser.pm:1.31	Mon Apr 22 11:26:46 2002
+++ loncom/interface/loncreateuser.pm	Mon Apr 22 14:04:19 2002
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Create a user
 #
-# $Id: loncreateuser.pm,v 1.31 2002/04/22 15:26:46 matthew Exp $
+# $Id: loncreateuser.pm,v 1.32 2002/04/22 18:04:19 matthew Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -47,7 +47,7 @@
 # 11/12,11/13,11/15 Scott Harrison
 # 02/11/02 Matthew Hall
 #
-# $Id: loncreateuser.pm,v 1.31 2002/04/22 15:26:46 matthew Exp $
+# $Id: loncreateuser.pm,v 1.32 2002/04/22 18:04:19 matthew Exp $
 ###
 
 package Apache::loncreateuser;
@@ -165,7 +165,6 @@
     my $uhome=&Apache::lonnet::homeserver($ccuname,$ccdomain);
     my %incdomains; 
     my %inccourses;
-    my %home_servers = &get_home_servers($ccdomain);  
     foreach (%Apache::lonnet::hostdom) {
        $incdomains{$_}=1;
     }
@@ -176,12 +175,9 @@
     }
     if ($uhome eq 'no_host') {
         my $home_server_list=
-            '<option value="default" selected>default</option>'."\n";
-        foreach (sort keys(%home_servers)) {
-            $home_server_list.=
-                '<option value="'.$_.'">'.$_.' '.
-                    $home_servers{$_}."</option>\n";
-        }
+            '<option value="default" selected>default</option>'."\n".
+                &Apache::loncommon::home_server_option_list($ccdomain);
+        
 	$r->print(<<ENDNEWUSER);
 $dochead
 <h1>Create New User</h1>
@@ -552,7 +548,8 @@
         if (lc($desiredhost) eq 'default') {
             $desiredhost = undef;
         } else {
-            my %home_servers = &get_home_servers($ENV{'form.ccdomain'});  
+            my %home_servers = &Apache::loncommon::get_home_servers
+                ($ENV{'form.ccdomain'});  
             if (! exists($home_servers{$desiredhost})) {
                 $r->print($error.'Invalid home server specified');
                 return;
@@ -832,16 +829,6 @@
 #---------------------------------------------- end functions for &phase_two
 
 #--------------------------------- functions for &phase_two and &phase_three
-sub get_home_servers {
-    my $domain = shift;
-    my %home_servers;
-    foreach (keys(%Apache::lonnet::libserv)) {
-        if ($Apache::lonnet::hostdom{$_} eq $domain) {
-            $home_servers{$_} = $Apache::lonnet::hostname{$_};
-        }
-    }
-    return %home_servers;
-}
 
 #--------------------------end of functions for &phase_two and &phase_three