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

raeburn raeburn at source.lon-capa.org
Mon Aug 1 19:33:43 EDT 2011


raeburn		Mon Aug  1 23:33:43 2011 EDT

  Modified files:              
    /loncom/interface	domainprefs.pm 
  Log:
  - Servers to offload to.
    - Save to domain's configuration.db file, even in no change, if spares still
      read from spares.tab.
    - Include spares type in change message.
  
  
-------------- next part --------------
Index: loncom/interface/domainprefs.pm
diff -u loncom/interface/domainprefs.pm:1.146 loncom/interface/domainprefs.pm:1.147
--- loncom/interface/domainprefs.pm:1.146	Mon Aug  1 19:46:49 2011
+++ loncom/interface/domainprefs.pm	Mon Aug  1 23:33:43 2011
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Handler to set domain-wide configuration settings
 #
-# $Id: domainprefs.pm,v 1.146 2011/08/01 19:46:49 raeburn Exp $
+# $Id: domainprefs.pm,v 1.147 2011/08/01 23:33:43 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -7124,7 +7124,8 @@
         }
     }
 
-    if (keys(%changes) > 0) {
+    my $nochgmsg = &mt('No changes made to settings for user session hosting/offloading.');
+    if ((keys(%changes) > 0) || ($savespares)) {
         my $putresult = &Apache::lonnet::put_dom('configuration',\%defaultshash,
                                                  $dom);
         if ($putresult eq 'ok') {
@@ -7138,71 +7139,75 @@
             }
             my $cachetime = 24*60*60;
             &Apache::lonnet::do_cache_new('domdefaults',$dom,\%domdefaults,$cachetime);
-            my %lt = &usersession_titles();
-            $resulttext = &mt('Changes made:').'<ul>';
-            foreach my $prefix (@prefixes) {
-                if (ref($changes{$prefix}) eq 'HASH') {
-                    $resulttext .= '<li>'.$lt{$prefix}.'<ul>';
-                    if ($prefix eq 'spares') {
-                        if (ref($changes{$prefix}) eq 'HASH') {
-                            foreach my $lonhost (sort(keys(%{$changes{$prefix}}))) {
-                                $resulttext .= '<li><b>'.$lonhost.'</b> ';
-                                if (ref($changes{$prefix}{$lonhost}) eq 'HASH') {
-                                    foreach my $type (@{$types{$prefix}}) {
-                                        if ($changes{$prefix}{$lonhost}{$type}) {
-                                            my $offloadto = &mt('None');
-                                            if (ref($defaultshash{'usersessions'}{'spares'}{$lonhost}{$type}) eq 'ARRAY') {
-                                                if (@{$defaultshash{'usersessions'}{'spares'}{$lonhost}{$type}} > 0) {   
-                                                    $offloadto = join(', ',@{$defaultshash{'usersessions'}{'spares'}{$lonhost}{$type}});
+            if (keys(%changes) > 0) {
+                my %lt = &usersession_titles();
+                $resulttext = &mt('Changes made:').'<ul>';
+                foreach my $prefix (@prefixes) {
+                    if (ref($changes{$prefix}) eq 'HASH') {
+                        $resulttext .= '<li>'.$lt{$prefix}.'<ul>';
+                        if ($prefix eq 'spares') {
+                            if (ref($changes{$prefix}) eq 'HASH') {
+                                foreach my $lonhost (sort(keys(%{$changes{$prefix}}))) {
+                                    $resulttext .= '<li><b>'.$lonhost.'</b> ';
+                                    if (ref($changes{$prefix}{$lonhost}) eq 'HASH') {
+                                        foreach my $type (@{$types{$prefix}}) {
+                                            if ($changes{$prefix}{$lonhost}{$type}) {
+                                                my $offloadto = &mt('None');
+                                                if (ref($defaultshash{'usersessions'}{'spares'}{$lonhost}{$type}) eq 'ARRAY') {
+                                                    if (@{$defaultshash{'usersessions'}{'spares'}{$lonhost}{$type}} > 0) {   
+                                                        $offloadto = join(', ',@{$defaultshash{'usersessions'}{'spares'}{$lonhost}{$type}});
+                                                    }
                                                 }
+                                                $resulttext .= &mt('[_1] set to: [_2].','<i>'.$lt{$type}.'</i>',$offloadto).(' 'x3);
                                             }
-                                            $resulttext .= &mt('[_1] set to: [_2]','<i>'.$lt{'type'}.'</i>',$offloadto).(' 'x3);
                                         }
                                     }
+                                    $resulttext .= '</li>';
                                 }
-                                $resulttext .= '</li>';
                             }
-                        }
-                    } else {
-                        foreach my $type (@{$types{$prefix}}) {
-                            if (defined($changes{$prefix}{$type})) {
-                                my $newvalue;
-                                if (ref($defaultshash{'usersessions'}) eq 'HASH') {
-                                    if (ref($defaultshash{'usersessions'}{$prefix})) {
-                                        if ($type eq 'version') {
-                                            $newvalue = $defaultshash{'usersessions'}{$prefix}{$type};
-                                        } elsif (ref($defaultshash{'usersessions'}{$prefix}{$type}) eq 'ARRAY') {
-                                            if (@{$defaultshash{'usersessions'}{$prefix}{$type}} > 0) {
-                                                $newvalue = join(', ',@{$defaultshash{'usersessions'}{$prefix}{$type}});
+                        } else {
+                            foreach my $type (@{$types{$prefix}}) {
+                                if (defined($changes{$prefix}{$type})) {
+                                    my $newvalue;
+                                    if (ref($defaultshash{'usersessions'}) eq 'HASH') {
+                                        if (ref($defaultshash{'usersessions'}{$prefix})) {
+                                            if ($type eq 'version') {
+                                                $newvalue = $defaultshash{'usersessions'}{$prefix}{$type};
+                                            } elsif (ref($defaultshash{'usersessions'}{$prefix}{$type}) eq 'ARRAY') {
+                                                if (@{$defaultshash{'usersessions'}{$prefix}{$type}} > 0) {
+                                                    $newvalue = join(', ',@{$defaultshash{'usersessions'}{$prefix}{$type}});
+                                                }
                                             }
                                         }
                                     }
-                                }
-                                if ($newvalue eq '') {
-                                    if ($type eq 'version') {
-                                        $resulttext .= '<li>'.&mt('[_1] set to: off',$lt{$type}).'</li>';
+                                    if ($newvalue eq '') {
+                                        if ($type eq 'version') {
+                                            $resulttext .= '<li>'.&mt('[_1] set to: off',$lt{$type}).'</li>';
+                                        } else {
+                                            $resulttext .= '<li>'.&mt('[_1] set to: none',$lt{$type}).'</li>';
+                                        }
                                     } else {
-                                        $resulttext .= '<li>'.&mt('[_1] set to: none',$lt{$type}).'</li>';
-                                    }
-                                } else {
-                                    if ($type eq 'version') {
-                                        $newvalue .= ' '.&mt('(or later)'); 
+                                        if ($type eq 'version') {
+                                            $newvalue .= ' '.&mt('(or later)'); 
+                                        }
+                                        $resulttext .= '<li>'.&mt('[_1] set to: [_2].',$lt{$type},$newvalue).'</li>';
                                     }
-                                    $resulttext .= '<li>'.&mt('[_1] set to: [_2].',$lt{$type},$newvalue).'</li>';
                                 }
                             }
                         }
+                        $resulttext .= '</ul>';
                     }
-                    $resulttext .= '</ul>';
                 }
+                $resulttext .= '</ul>';
+            } else {
+                $resulttext = $nochgmsg;
             }
-            $resulttext .= '</ul>';
         } else {
             $resulttext = '<span class="LC_error">'.
                           &mt('An error occurred: [_1]',$putresult).'</span>';
         }
     } else {
-        $resulttext =  &mt('No changes made to settings for user session hosting/offloading.');
+        $resulttext = $nochgmsg;
     }
     return $resulttext;
 }


More information about the LON-CAPA-cvs mailing list