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

raeburn lon-capa-cvs-allow@mail.lon-capa.org
Fri, 12 Sep 2008 00:55:40 -0000


raeburn		Thu Sep 11 20:55:40 2008 EDT

  Modified files:              
    /loncom/interface	lonuserutils.pm 
  Log:
  - Sanity checking - check you do really have a reference to a hash.
  
  
Index: loncom/interface/lonuserutils.pm
diff -u loncom/interface/lonuserutils.pm:1.65 loncom/interface/lonuserutils.pm:1.66
--- loncom/interface/lonuserutils.pm:1.65	Thu Sep 11 15:42:28 2008
+++ loncom/interface/lonuserutils.pm	Thu Sep 11 20:55:37 2008
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Utility functions for managing LON-CAPA user accounts
 #
-# $Id: lonuserutils.pm,v 1.65 2008/09/11 19:42:28 droeschl Exp $
+# $Id: lonuserutils.pm,v 1.66 2008/09/12 00:55:37 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -1337,7 +1337,9 @@
     if ($context eq 'course') {
         if (($env{'form.showrole'} eq 'st') || ($env{'form.showrole'} eq 'Any')) { 
             my $classlist = &Apache::loncoursedata::get_classlist();
-            %userlist = %{$classlist};
+            if (ref($classlist) eq 'HASH') {
+                %userlist = %{$classlist};
+            }
         }
         if ($env{'form.showrole'} ne 'st') {
             my $showroles;
@@ -3507,7 +3509,9 @@
             if ($context eq 'course') {
                 my ($cnum,$cdom) = &get_course_identity();
                 my $roster = &Apache::loncoursedata::get_classlist();
-                %userlist = %{$roster};
+                if (ref($roster) eq 'HASH') {
+                    %userlist = %{$roster};
+                }
                 my %advrolehash = &Apache::lonnet::get_my_roles($cnum,$cdom,undef,
                                                          \@statuses,\@poss_roles);
                 &gather_userinfo($context,'view',\%userlist,$indexhash,\%info,
@@ -3898,7 +3902,7 @@
                           '<input type="hidden" name="action" value="'.$env{'form.action'}.'" />'.
                           &mt('There are no students with current/future access to the course.').
                           '</form>'."\n");
-            } else {
+            } elsif (ref($classlist) eq 'HASH') {
                 # Remove the students we just added from the list of students.
                 foreach my $line (@userdata) {
                     my %entries=&Apache::loncommon::record_sep($line);