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

raeburn raeburn@source.lon-capa.org
Sun, 02 Aug 2009 07:21:18 -0000


raeburn		Sun Aug  2 07:21:18 2009 EDT

  Modified files:              
    /loncom/interface	domainprefs.pm 
  Log:
  - Check $settings really is a reference to a hash to prevent ISE in unconfigured domain. 
  
  
Index: loncom/interface/domainprefs.pm
diff -u loncom/interface/domainprefs.pm:1.98 loncom/interface/domainprefs.pm:1.99
--- loncom/interface/domainprefs.pm:1.98	Sat Jul 25 14:44:50 2009
+++ loncom/interface/domainprefs.pm	Sun Aug  2 07:21:18 2009
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Handler to set domain-wide configuration settings
 #
-# $Id: domainprefs.pm,v 1.98 2009/07/25 14:44:50 raeburn Exp $
+# $Id: domainprefs.pm,v 1.99 2009/08/02 07:21:18 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -1599,7 +1599,11 @@
             &Apache::loncommon::sorted_inst_types($dom);
         if (ref($usertypes) eq 'HASH') {
             if (keys(%{$usertypes}) > 0) {
-                $datatable .= &insttypes_row($settings->{cancreate},$types,$usertypes,
+                my $createsettings;
+                if (ref($settings) eq 'HASH') {
+                    $createsettings = $settings->{cancreate};
+                }
+                $datatable .= &insttypes_row($createsettings,$types,$usertypes,
                                              $dom,$numinrow,$othertitle,
                                              'statustocreate');
                 $$rowtotal ++;
@@ -2520,12 +2524,14 @@
                     $output .= '<tr>';
                 }
                 my $check = ' ';
-                if (ref($settings->{$context}) eq 'ARRAY') {
-                    if (grep(/^\Q$types->[$i]\E$/,@{$settings->{$context}})) {
+                if (ref($settings) eq 'HASH') {
+                    if (ref($settings->{$context}) eq 'ARRAY') {
+                        if (grep(/^\Q$types->[$i]\E$/,@{$settings->{$context}})) {
+                            $check = ' checked="checked" ';
+                        }
+                    } elsif ($context eq 'statustocreate') {
                         $check = ' checked="checked" ';
                     }
-                } elsif ($context eq 'statustocreate') {
-                    $check = ' checked="checked" ';
                 }
                 $output .= '<td class="LC_left_item">'.
                            '<span class="LC_nobreak"><label>'.
@@ -2544,12 +2550,14 @@
         $output .= '<td class="LC_left_item">';
     }
     my $defcheck = ' ';
-    if (ref($settings->{$context}) eq 'ARRAY') {
-        if (grep(/^default$/,@{$settings->{$context}})) {
+    if (ref($settings) eq 'HASH') {  
+        if (ref($settings->{$context}) eq 'ARRAY') {
+            if (grep(/^default$/,@{$settings->{$context}})) {
+                $defcheck = ' checked="checked" ';
+            }
+        } elsif ($context eq 'statustocreate') {
             $defcheck = ' checked="checked" ';
         }
-    } elsif ($context eq 'statustocreate') {
-        $defcheck = ' checked="checked" ';
     }
     $output .= '<span class="LC_nobreak"><label>'.
                '<input type="checkbox" name="'.$context.'" '.