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

raeburn lon-capa-cvs-allow@mail.lon-capa.org
Sat, 05 Jan 2008 15:19:34 -0000


raeburn		Sat Jan  5 10:19:34 2008 EDT

  Modified files:              
    /loncom/interface	lonuserutils.pm 
  Log:
  - Efficiency improvementsin course context
  - No retrieval of non-student roles if rolefilter is 'st'
  - Delay filter for section-specific viewing until checking of other filters.
  
  
Index: loncom/interface/lonuserutils.pm
diff -u loncom/interface/lonuserutils.pm:1.42 loncom/interface/lonuserutils.pm:1.43
--- loncom/interface/lonuserutils.pm:1.42	Sat Jan  5 00:22:42 2008
+++ loncom/interface/lonuserutils.pm	Sat Jan  5 10:19:32 2008
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Utility functions for managing LON-CAPA user accounts
 #
-# $Id: lonuserutils.pm,v 1.42 2008/01/05 05:22:42 raeburn Exp $
+# $Id: lonuserutils.pm,v 1.43 2008/01/05 15:19:32 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -1308,32 +1308,21 @@
     $r->rflush();
     if ($context eq 'course') {
         my $classlist = &Apache::loncoursedata::get_classlist();
-        my $secidx = &Apache::loncoursedata::CL_SECTION();
-        my $viewablesec = &viewable_section($permission);
-        foreach my $student (keys(%{$classlist})) {
-            my $section = $classlist->{$student}[$secidx];
-            if ($viewablesec ne '') {
-                if ($section ne $viewablesec) {
-                    next;
-                } else {
-                    $userlist{$student} = $classlist->{$student};
-                }
+        %userlist = %{$classlist};
+        if ($env{'form.showrole'} ne 'st') {
+            my $showroles;
+            if ($env{'form.showrole'} ne 'Any') {
+                $showroles = [$env{'form.showrole'}];
             } else {
-                $userlist{$student} = $classlist->{$student};
+                $showroles = undef;
             }
+            my $withsec = 1;
+            my $hidepriv = 1;
+            my %advrolehash = &Apache::lonnet::get_my_roles($cnum,$cdom,undef,
+                              \@statuses,$showroles,undef,$withsec,$hidepriv);
+            &gather_userinfo($context,$format,\%userlist,$indexhash,\%userinfo,
+                             \%advrolehash,$permission);
         }
-        my $showroles;
-        if ($env{'form.showrole'} ne 'Any') {
-            $showroles = [$env{'form.showrole'}];
-        } else {
-            $showroles = undef;
-        }
-        my $withsec = 1;
-        my $hidepriv = 1;
-        my %advrolehash = &Apache::lonnet::get_my_roles($cnum,$cdom,undef,
-                                    \@statuses,$showroles,undef,$withsec,$hidepriv);
-        &gather_userinfo($context,$format,\%userlist,$indexhash,\%userinfo,
-                         \%advrolehash,$permission);
     } else {
         my (%cstr_roles,%dom_roles);
         if ($context eq 'author') {
@@ -2272,6 +2261,10 @@
     # Get groups, role, permanent e-mail so we can sort on them if
     # necessary.
     foreach my $user (keys(%{$userlist})) {
+        if ($user eq '' ) {
+            delete($userlist->{$user});
+            next;
+        }
         if ($context eq 'domain' &&  $user eq $env{'request.role.domain'}.'-domainconfig:'.$env{'request.role.domain'}) {
             delete($userlist->{$user});
             next;
@@ -2317,6 +2310,13 @@
             }
             if ($mode ne 'autoenroll') {
                 my $section = $userlist->{$user}->[$index{'section'}];
+                if (($env{'request.course.sec'} ne '') && 
+                    ($section ne $env{'request.course.sec'})) {
+                    if ($role eq 'st') {
+                        delete($userlist->{$user});
+                        next;
+                    }
+                }
                 if ($secfilter eq 'none') {
                     if ($section ne '') {
                         delete($userlist->{$user});