[LON-CAPA-cvs] cvs: loncom / lonsql /enrollment localenroll.pm /interface loncreateuser.pm /lonnet/perl lonnet.pm

raeburn lon-capa-cvs-allow@mail.lon-capa.org
Fri, 31 Aug 2007 12:33:35 -0000


This is a MIME encoded message

--raeburn1188563615
Content-Type: text/plain

raeburn		Fri Aug 31 08:33:35 2007 EDT

  Modified files:              
    /loncom	lonsql 
    /loncom/lonnet/perl	lonnet.pm 
    /loncom/interface	loncreateuser.pm 
    /loncom/enrollment	localenroll.pm 
  Log:
  Institutional directory search now reported as unavailable in the case where a DC has enabled directory searching via "Modify domain configuration" but either:
   (a) localenroll::get_userinfo() has not been customized, or 
   (b) an error ioccurred when querying the institutional directory.
  
  lonsql
  - &do_inst_dir_search() returns 'unavailable' if the response from localenroll::get_userinfo() is not 'ok'
  
  lonnet.pm
  - &inst_directory_query() now returns a scalar and a hash.
    - scalar is the outcome of the query: 'unavailable', 'ok' or ''.
    - hash contains the search results (if any matches) 
  
  loncreateuser.pm
  - Report to user that institutional directory search is unavailable if response from &lonnet::inst_directory_query() is not 'ok'.   
  
  localenroll.pm
  - documentation updated
  - &get_userinfo() returns 'unavailable' by default
  
  
--raeburn1188563615
Content-Type: text/plain
Content-Disposition: attachment; filename="raeburn-20070831083335.txt"

Index: loncom/lonsql
diff -u loncom/lonsql:1.86 loncom/lonsql:1.87
--- loncom/lonsql:1.86	Sat Aug 25 15:52:11 2007
+++ loncom/lonsql	Fri Aug 31 08:33:25 2007
@@ -3,7 +3,7 @@
 # The LearningOnline Network
 # lonsql - LON TCP-MySQL-Server Daemon for handling database requests.
 #
-# $Id: lonsql,v 1.86 2007/08/25 19:52:11 raeburn Exp $
+# $Id: lonsql,v 1.87 2007/08/31 12:33:25 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -571,6 +571,8 @@
             }
         }
         $response=~s/\&$//;
+    } else {
+        $response = 'unavailable';
     }
     return $response;
 }
Index: loncom/lonnet/perl/lonnet.pm
diff -u loncom/lonnet/perl/lonnet.pm:1.908 loncom/lonnet/perl/lonnet.pm:1.909
--- loncom/lonnet/perl/lonnet.pm:1.908	Wed Aug 29 18:19:24 2007
+++ loncom/lonnet/perl/lonnet.pm	Fri Aug 31 08:33:29 2007
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # TCP networking package
 #
-# $Id: lonnet.pm,v 1.908 2007/08/29 22:19:24 albertel Exp $
+# $Id: lonnet.pm,v 1.909 2007/08/31 12:33:29 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -861,6 +861,7 @@
     my $udom = $srch->{'srchdomain'};
     my %results;
     my $homeserver = &domain($udom,'primary');
+    my $outcome;
     if ($homeserver ne '') {
 	my $queryid=&reply("querysend:instdirsearch:".
 			   &escape($srch->{'srchby'}).':'.
@@ -880,14 +881,19 @@
 	}
 
         if (!&error($response) && $response ne 'refused') {
-            my @matches = split(/\n/,$response);
-            foreach my $match (@matches) {
-                my ($key,$value) = split(/=/,$match);
-                $results{&unescape($key).':'.$udom} = &thaw_unescape($value);
+            if ($response eq 'unavailable') {
+                $outcome = $response;
+            } else {
+                $outcome = 'ok';
+                my @matches = split(/\n/,$response);
+                foreach my $match (@matches) {
+                    my ($key,$value) = split(/=/,$match);
+                    $results{&unescape($key).':'.$udom} = &thaw_unescape($value);
+                }
             }
         }
     }
-    return %results;
+    return ($outcome,%results);
 }
 
 sub usersearch {
Index: loncom/interface/loncreateuser.pm
diff -u loncom/interface/loncreateuser.pm:1.180 loncom/interface/loncreateuser.pm:1.181
--- loncom/interface/loncreateuser.pm:1.180	Thu Aug 30 23:21:27 2007
+++ loncom/interface/loncreateuser.pm	Fri Aug 31 08:33:32 2007
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Create a user
 #
-# $Id: loncreateuser.pm,v 1.180 2007/08/31 03:21:27 raeburn Exp $
+# $Id: loncreateuser.pm,v 1.181 2007/08/31 12:33:32 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -699,12 +699,14 @@
         if (($instsrch->{'srchterm'} ne '') && ($instsrch->{'srchdomain'} ne '')) {
             $newuser = $instsrch->{'srchterm'}.':'.$instsrch->{'srchdomain'};
         }
-        my (%dirsrch_results,%inst_results);
+        my (%dirsrch_results,%inst_results,$dirsrchres);
         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}};
+                ($dirsrchres,%dirsrch_results) = &Apache::lonnet::inst_directory_query($instsrch);
+                if ($dirsrchres eq 'ok') {
+                    if (ref($dirsrch_results{$newuser}) eq 'HASH') { 
+                        %inst_results = %{$dirsrch_results{$newuser}};
+                    }
                 }
             }
         }
@@ -2211,7 +2213,7 @@
     my %allhomes;
     my %inst_matches;
     my %srch_results;
-    my ($response,$currstate,$forcenewuser);
+    my ($response,$currstate,$forcenewuser,$dirsrchres);
     $srch->{'srchterm'} =~ s/^\s+//;
     $srch->{'srchterm'} =~ s/\s+$//;
 
@@ -2324,9 +2326,18 @@
         } elsif ($srch->{'srchin'} eq 'alc') {
             $currstate = 'query';
         } elsif ($srch->{'srchin'} eq 'instd') {
-            %srch_results = &Apache::lonnet::inst_directory_query($srch);
-            ($currstate,$response,$forcenewuser) = 
-                &build_search_response($srch,%srch_results); 
+            ($dirsrchres,%srch_results) = &Apache::lonnet::inst_directory_query($srch);
+            if ($dirsrchres eq 'ok') {
+                ($currstate,$response,$forcenewuser) = 
+                    &build_search_response($srch,%srch_results);
+            } else {
+                my $showdom = &display_domain_info($srch->{'srchdomain'});
+                $response = '<span class="LC_warning">'.
+                    &mt('Institutional directory search is not available in domain: [_1]',$showdom).
+                    '</span><br />'.
+                    &mt('You may want to search in the LON-CAPA domain instead of the institutional directory.').
+                    '<br /><br />'; 
+            }
         }
     } else {
         if ($srch->{'srchin'} eq 'dom') {
@@ -2388,9 +2399,17 @@
         } elsif ($srch->{'srchin'} eq 'alc') {
             $currstate = 'query';
         } elsif ($srch->{'srchin'} eq 'instd') {
-            %srch_results = &Apache::lonnet::inst_directory_query($srch); 
-            ($currstate,$response,$forcenewuser) = 
-                &build_search_response($srch,%srch_results);
+            ($dirsrchres,%srch_results) = &Apache::lonnet::inst_directory_query($srch); 
+            if ($dirsrchres eq 'ok') {
+                ($currstate,$response,$forcenewuser) = 
+                    &build_search_response($srch,%srch_results);
+            } else {
+                my $showdom = &display_domain_info($srch->{'srchdomain'});                $response = '<span class="LC_warning">'.
+                    &mt('Institutional directory search is not available in domain: [_1]',$showdom).
+                    '</span><br />'.
+                    &mt('You may want to search in the LON-CAPA domain instead of the institutional directory.').
+                    '<br /><br />';
+            }
         }
     }
     return ($currstate,$response,$forcenewuser,\%srch_results);
Index: loncom/enrollment/localenroll.pm
diff -u loncom/enrollment/localenroll.pm:1.23 loncom/enrollment/localenroll.pm:1.24
--- loncom/enrollment/localenroll.pm:1.23	Tue Aug 28 16:04:50 2007
+++ loncom/enrollment/localenroll.pm	Fri Aug 31 08:33:35 2007
@@ -1,6 +1,6 @@
 # functions to glue school database system into Lon-CAPA for 
 # automated enrollment
-# $Id: localenroll.pm,v 1.23 2007/08/28 20:04:50 albertel Exp $
+# $Id: localenroll.pm,v 1.24 2007/08/31 12:33:35 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -496,7 +496,8 @@
 #                keys will be unique IDs (student or faculty/staff ID)
 #                values will be either: scalar (username) or an array 
 #                if a single ID matches multiple usernames.
-# returns 1 parameter - ('ok' or other value).
+# returns 1 parameter - 'ok' if no processing error, or other value 
+#                       if an error occurred.
 # side effects - populates the $instusers and $instids refs to hashes.
 #                with information for all users from all available 
 #                institutional datafeeds.
@@ -546,18 +547,26 @@
 # (i) $srchtype - optional. Allowed values: contains, begins (defaults
 #                to exact match otherwise).
 #
-# returns 1 parameter - ('ok' or other value).
+# returns 1 parameter - 'ok' if no processing error, or other value 
+#                       if an error occurred.
 # side effects - populates the $instusers and $instids refs to hashes.
 #                with information for specified username, or specified
 #                id, if fifth argument provided, from all available, or 
 #                specified (e.g., faculty only) institutional datafeeds,
 #                if sixth argument provided.
+#
+# WARNING: You need to set $outcome to 'ok' once you have customized
+#          this routine to communicate with an instititional 
+#          directory data source, otherwise institutional directory 
+#          searches will always be reported as being unavailable
+#          in domain $dom.
+#
 ###############################
 
 sub get_userinfo {
     my ($dom,$uname,$id,$instusers,$instids,$types,
         $srchby,$srchterm,$srchtype) = @_;
-    my $outcome = 'ok';
+    my $outcome = 'unavailable';
     return $outcome;
 }
 
@@ -574,7 +583,8 @@
 #              which institutional types should be shown
 #              when displaying data tables (e.g., default quotas    
 #              or updateable user fields (see domainprefs.pm) 
-# returns 1 parameter - ('ok' or other value).
+# returns 1 parameter - 'ok' if no processing error, or other value 
+#                        if an error occurred.
 #
 ###############################
 

--raeburn1188563615--