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

raeburn lon-capa-cvs-allow@mail.lon-capa.org
Fri, 04 Jan 2008 10:17:16 -0000


raeburn		Fri Jan  4 05:17:16 2008 EDT

  Modified files:              
    /loncom/interface	domainprefs.pm 
  Log:
  - Checking $settings is a hash ref to prevents ISEs
  - Display a message if no format rules  have been defined in localenroll::username_rules() or localenroll::id_rules()
  
  
Index: loncom/interface/domainprefs.pm
diff -u loncom/interface/domainprefs.pm:1.38 loncom/interface/domainprefs.pm:1.39
--- loncom/interface/domainprefs.pm:1.38	Tue Jan  1 13:48:17 2008
+++ loncom/interface/domainprefs.pm	Fri Jan  4 05:17:13 2008
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Handler to set domain-wide configuration settings
 #
-# $Id: domainprefs.pm,v 1.38 2008/01/01 18:48:17 raeburn Exp $
+# $Id: domainprefs.pm,v 1.39 2008/01/04 10:17:13 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -1035,6 +1035,10 @@
         }
     }
     my $domform = &Apache::loncommon::select_dom_form($defdom,'sender_domain',1);
+    my $notif_sender;
+    if (ref($settings) eq 'HASH') {
+        $notif_sender = $settings->{'sender_uname'};
+    }
     my $datatable='<tr class="LC_odd_row">'.
                   '<td>'.&mt('Auto-enrollment active?').'</td>'.
                   '<td class="LC_right_item"><span class="LC_nobreak"><label>'.
@@ -1047,8 +1051,7 @@
                   '</td><td class="LC_right_item"><span class="LC_nobreak">'.
                   &mt('username').':&nbsp;'.
                   '<input type="text" name="sender_uname" value="'.
-                  $settings->{'sender_uname'}.
-                  '" size="10" />&nbsp;&nbsp;'.&mt('domain').
+                  $notif_sender.'" size="10" />&nbsp;&nbsp;'.&mt('domain').
                   ':&nbsp;'.$domform.'</span></td></tr>';
     $$rowtotal += 2;
     return $datatable;
@@ -1191,9 +1194,11 @@
     foreach my $title (@{$titleorder}) {
         if (defined($searchtitles->{$title})) {
             my $check = ' ';
-            if (ref($settings->{'searchby'}) eq 'ARRAY') {
-                if (grep(/^\Q$title\E$/,@{$settings->{'searchby'}})) {
-                    $check = ' checked="checked" ';
+            if (ref($settings) eq 'HASH') { 
+                if (ref($settings->{'searchby'}) eq 'ARRAY') {
+                    if (grep(/^\Q$title\E$/,@{$settings->{'searchby'}})) {
+                        $check = ' checked="checked" ';
+                    }
                 }
             }
             $datatable .= '<td class="LC_left_item">'.
@@ -1344,6 +1349,11 @@
                 $rowcount ++;
             }
         }
+        if ($rowcount == 0) {
+            $datatable .= '<tr><td colspan="2">'.&mt('No format rules have been defined for usernames or IDs in this domain.').'</td></tr>';  
+            $$rowtotal ++;
+            $rowcount ++;
+        }
     } elsif ($position eq 'middle') {
         my @creators = ('author','course');
         my ($rules,$ruleorder) =
@@ -1473,9 +1483,11 @@
                     $output .= '<tr>';
                 }
                 my $check = ' ';
-                if (ref($settings->{$type.'_rule'}) eq 'ARRAY') {
-                    if (grep(/^\Q$ruleorder->[$i]\E$/,@{$settings->{$type.'_rule'}})) {
-                        $check = ' checked="checked" ';
+                if (ref($settings) eq 'HASH') {
+                    if (ref($settings->{$type.'_rule'}) eq 'ARRAY') {
+                        if (grep(/^\Q$ruleorder->[$i]\E$/,@{$settings->{$type.'_rule'}})) {
+                            $check = ' checked="checked" ';
+                        }
                     }
                 }
                 $output .= '<td class="LC_left_item">'.
@@ -1730,10 +1742,12 @@
                     $datatable .= '<tr>';
                 }
                 my $check = ' ';
-                if (ref($settings->{'fields'}) eq 'HASH') {
-                    if (ref($settings->{'fields'}{$type}) eq 'ARRAY') {
-                        if (grep(/^\Q$fields->[$i]\E$/,@{$settings->{'fields'}{$type}})) {
-                            $check = ' checked="checked" ';
+                if (ref($settings) eq 'HASH') {
+                    if (ref($settings->{'fields'}) eq 'HASH') {
+                        if (ref($settings->{'fields'}{$type}) eq 'ARRAY') {
+                            if (grep(/^\Q$fields->[$i]\E$/,@{$settings->{'fields'}{$type}})) {
+                                $check = ' checked="checked" ';
+                            }
                         }
                     }
                 }