--- loncom/interface/domainprefs.pm 2014/07/15 21:51:47 1.249 +++ loncom/interface/domainprefs.pm 2014/10/04 02:41:44 1.252 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Handler to set domain-wide configuration settings # -# $Id: domainprefs.pm,v 1.249 2014/07/15 21:51:47 raeburn Exp $ +# $Id: domainprefs.pm,v 1.252 2014/10/04 02:41:44 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -6072,7 +6072,7 @@ sub modify_login { if (!$privkey) { $chgtxt .= '
  • '.&mt('Private key deleted').'
  • '; } else { - $chgtxt .= '
  • '.&mt('Private key set to [_1]',$pubkey).'
  • '; + $chgtxt .= '
  • '.&mt('Private key set to [_1]',$privkey).'
  • '; } $chgtxt .= ''; $resulttext .= '
  • '.$chgtxt.'
  • '; @@ -9076,8 +9076,8 @@ sub process_captcha { if ($newsettings->{'captcha'} eq 'recaptcha') { $newpub = $env{'form.'.$container.'_recaptchapub'}; $newpriv = $env{'form.'.$container.'_recaptchapriv'}; - $newpub =~ s/\W//g; - $newpriv =~ s/\W//g; + $newpub =~ s/[^\w\-]//g; + $newpriv =~ s/[^\w\-]//g; $newsettings->{'recaptchakeys'} = { public => $newpub, private => $newpriv, @@ -10793,16 +10793,17 @@ sub modify_loadbalancing { \%defaultshash,$dom); if ($putresult eq 'ok') { if (keys(%changes) > 0) { + my %toupdate; if (ref($changes{'delete'}) eq 'ARRAY') { foreach my $balancer (sort(@{$changes{'delete'}})) { $resulttext .= '
  • '.&mt('Load Balancing discontinued for: [_1]',$balancer).'
  • '; - my $cachekey = &escape('loadbalancing').':'.&escape($dom); - &Apache::lonnet::remote_devalidate_cache($balancer,[$cachekey]); + $toupdate{$balancer} = 1; } } if (ref($changes{'add'}) eq 'ARRAY') { foreach my $balancer (sort(@{$changes{'add'}})) { $resulttext .= '
  • '.&mt('Load Balancing enabled for: [_1]',$balancer); + $toupdate{$balancer} = 1; } } if (ref($changes{'curr'}) eq 'HASH') { @@ -10845,6 +10846,13 @@ sub modify_loadbalancing { } elsif (($rule eq 'homeserver') || ($rule eq 'externalbalancer') || ($rule eq 'balancer') || ($rule eq 'offloadedto')) { $balancetext = $ruletitles{$rule}; + if (($rule eq 'balancer') || ($rule eq 'offloadedto')) { + foreach my $sparetype (@sparestypes) { + if (ref($defaultshash{'loadbalancing'}{$balancer}{'targets'}{$sparetype}) eq 'ARRAY') { + map { $toupdate{$_} = 1; } (@{$defaultshash{'loadbalancing'}{$balancer}{'targets'}{$sparetype}}); + } + } + } } else { $balancetext = &mt('offload to [_1]',$defaultshash{'loadbalancing'}{$balancer}{'rules'}{$type}); } @@ -10853,8 +10861,25 @@ sub modify_loadbalancing { } } } - my $cachekey = &escape('loadbalancing').':'.&escape($dom); - &Apache::lonnet::remote_devalidate_cache($balancer,[$cachekey]); + if (keys(%toupdate)) { + my %thismachine; + my $updatedhere; + my $cachetime = 60*60*24; + map { $thismachine{$_} = 1; } &Apache::lonnet::current_machine_ids(); + foreach my $lonhost (keys(%toupdate)) { + if ($thismachine{$lonhost}) { + unless ($updatedhere) { + &Apache::lonnet::do_cache_new('loadbalancing',$dom, + $defaultshash{'loadbalancing'}, + $cachetime); + $updatedhere = 1; + } + } else { + my $cachekey = &escape('loadbalancing').':'.&escape($dom); + &Apache::lonnet::remote_devalidate_cache($lonhost,[$cachekey]); + } + } + } } } if ($resulttext ne '') {