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

raeburn lon-capa-cvs-allow@mail.lon-capa.org
Sun, 29 Jul 2007 04:32:44 -0000


raeburn		Sun Jul 29 00:32:44 2007 EDT

  Modified files:              
    /loncom/interface	loncreateuser.pm 
  Log:
  Populating entry form for a new user with institutional data.
  - check that institutional search is available
  - data returned from lonnet::inst_directory_query() is a hash of a hash.
  - correct username and domain in search when new user is a result of a single match as well as when user was picked from a list of matches. 
  
  
Index: loncom/interface/loncreateuser.pm
diff -u loncom/interface/loncreateuser.pm:1.160 loncom/interface/loncreateuser.pm:1.161
--- loncom/interface/loncreateuser.pm:1.160	Sat Jul 28 17:38:29 2007
+++ loncom/interface/loncreateuser.pm	Sun Jul 29 00:32:44 2007
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Create a user
 #
-# $Id: loncreateuser.pm,v 1.160 2007/07/28 21:38:29 raeburn Exp $
+# $Id: loncreateuser.pm,v 1.161 2007/07/29 04:32:44 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -762,16 +762,30 @@
         }
     }
     if ($uhome eq 'no_host') {
-        my $instsrch = { 
+        my $newuser;
+        my $instsrch = {
                          srchin => 'instd',
-                         srchterm => $env{'form.seluname'},
-                         srchdomain => $env{'form.seludom'},
                          srchby => 'uname',
                          srchtype => 'exact',
                        };
-        my %inst_results;
-        if (directorysrch_check($instsrch) eq 'ok') {
-            %inst_results = &Apache::lonnet::inst_directory_query($instsrch);
+        if ((exists($env{'form.seluname'})) && (exists($env{'form.seludom'}))) {
+            $instsrch->{'srchterm'} = $env{'form.seluname'};
+            $instsrch->{'srchdomain'} = $env{'form.seludom'};
+        } else {
+            $instsrch->{'srchterm'} = $env{'form.srchterm'};
+            $instsrch->{'srchdomain'} = $env{'form.srchdomain'},
+        }
+        if (($instsrch->{'srchterm'} ne '') && ($instsrch->{'srchdomain'} ne '')) {
+            $newuser = $instsrch->{'srchterm'}.':'.$instsrch->{'srchdomain'};
+        }
+        my (%dirsrch_results,%inst_results);
+        if ($newuser) {
+            if (&directorysrch_check($instsrch) eq 'ok') {
+                %dirsrch_results = &Apache::lonnet::inst_directory_query($instsrch);
+                if (ref($dirsrch_results{$newuser}) eq 'HASH') { 
+                    %inst_results = %{$dirsrch_results{$newuser}};
+                } 
+            }
         }
         my $home_server_list=
             '<option value="default" selected>default</option>'."\n".