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

albertel lon-capa-cvs-allow@mail.lon-capa.org
Thu, 02 Aug 2007 01:04:41 -0000


albertel		Wed Aug  1 21:04:41 2007 EDT

  Modified files:              
    /loncom/interface	loncreateuser.pm 
  Log:
  - gather names for found users
  - users without names where sorting randomly
  
  
Index: loncom/interface/loncreateuser.pm
diff -u loncom/interface/loncreateuser.pm:1.166 loncom/interface/loncreateuser.pm:1.167
--- loncom/interface/loncreateuser.pm:1.166	Wed Aug  1 21:02:56 2007
+++ loncom/interface/loncreateuser.pm	Wed Aug  1 21:04:41 2007
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Create a user
 #
-# $Id: loncreateuser.pm,v 1.166 2007/08/02 01:02:56 albertel Exp $
+# $Id: loncreateuser.pm,v 1.167 2007/08/02 01:04:41 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -360,11 +360,13 @@
     $r->print(&Apache::loncommon::end_data_table_header_row());
 
     my @sorted_users = sort {
-        lc($srch_results->{$a}->{$sortby})  cmp lc($srch_results->{$b}->{$sortby})
+        lc($srch_results->{$a}->{$sortby})   cmp lc($srch_results->{$b}->{$sortby})
             ||
-        lc($srch_results->{$a}->{lastname}) cmp lc($srch_results->{$b}->{lastname})
+        lc($srch_results->{$a}->{lastname})  cmp lc($srch_results->{$b}->{lastname})
             ||
         lc($srch_results->{$a}->{firstname}) cmp lc($srch_results->{$b}->{firstname})
+	    ||
+	lc($a) cmp lc($b)
         } (keys(%$srch_results));
 
     foreach my $user (@sorted_users) {
@@ -2237,20 +2239,24 @@
                             &build_search_response($srch,%srch_results);
                     }
                 } else {
-                    my %courseusers = &get_courseusers();
+                    my $courseusers = &get_courseusers();
                     if ($srch->{'srchtype'} eq 'exact') {
-                        if (exists($courseusers{$srch->{'srchterm'}.':'.$srch->{'srchdomain'}})) {
+                        if (exists($courseusers->{$srch->{'srchterm'}.':'.$srch->{'srchdomain'}})) {
                             $state = 'modify';
                         } else {
                             ($state,$response,$forcenewuser) =
                                 &build_search_response($srch,%srch_results);
                         }
                     } else {
-                        foreach my $user (keys(%courseusers)) {
+                        foreach my $user (keys(%$courseusers)) {
                             my ($cuname,$cudomain) = split(/:/,$user);
                             if ($cudomain eq $srch->{'srchdomain'}) {
                                 if ($cuname =~ /\Q$srch->{'srchterm'}\E/i) {
-                                    $srch_results{$user} = '';
+                                    $srch_results{$user} = 
+					{&Apache::lonnet::get('environment',
+							     ['firstname',
+							      'lastname',
+							      'permanentemail'])};
                                 }
                             }
                         }
@@ -2272,8 +2278,8 @@
             ($state,$response,$forcenewuser) = 
                 &build_search_response($srch,%srch_results); 
         } elsif ($srch->{'srchin'} eq 'crs') {
-            my %courseusers = &get_courseusers(); 
-            foreach my $user (keys(%courseusers)) {
+            my $courseusers = &get_courseusers(); 
+            foreach my $user (keys(%$courseusers)) {
                 my ($uname,$udom) = split(/:/,$user);
                 my %names = &Apache::loncommon::getnames($uname,$udom);
                 my %emails = &Apache::loncommon::getemails($uname,$udom);
@@ -2364,11 +2370,11 @@
         return &mt('Directory search has not been configured for domain: [_1]',$srch->{'srchdomain'});
     }
     my %longtext = &Apache::lonlocal::texthash (
-                       uname => 'username',
+                       uname     => 'username',
                        lastfirst => 'last name, first name',
-                       lastname => 'last name',
-                       contains => 'is contained in',
-                       exact => 'as exact match to'
+                       lastname  => 'last name',
+                       contains  => 'is contained in',
+                       exact     => 'as exact match to'
                    );
     if ($can_search) {
         if (ref($dom_inst_srch{'directorysrch'}{'searchby'}) eq 'ARRAY') {
@@ -2392,15 +2398,16 @@
 
 sub get_courseusers {
     my %advhash;
+    my $classlist = &Apache::loncoursedata::get_classlist();
     my %coursepersonnel=&Apache::lonnet::get_course_adv_roles();
     foreach my $role (sort(keys(%coursepersonnel))) {
         foreach my $user (split(/\,/,$coursepersonnel{$role})) {
-            $advhash{$user} = '';
+	    if (!exists($classlist->{$user})) {
+		$classlist->{$user} = [];
+	    }
         }
     }
-    my $classlist = &Apache::loncoursedata::get_classlist();
-    my %combined = (%advhash, %{$classlist});
-    return %combined;
+    return $classlist;
 }
 
 sub build_search_response {