--- loncom/interface/domainprefs.pm 2018/11/06 15:37:37 1.340 +++ loncom/interface/domainprefs.pm 2018/12/08 15:03:25 1.344 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Handler to set domain-wide configuration settings # -# $Id: domainprefs.pm,v 1.340 2018/11/06 15:37:37 raeburn Exp $ +# $Id: domainprefs.pm,v 1.344 2018/12/08 15:03:25 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -2842,7 +2842,7 @@ function toggleLTI(form,setting,item) { if (setting == 'user') { radioname = 'lti_mapuser_'+item; divid = 'lti_userfield_'+item; - } else if (settings == 'crs') { + } else if (setting == 'crs') { radioname = 'lti_mapcrs_'+item; divid = 'lti_crsfield_'+item; } else { @@ -3581,7 +3581,7 @@ sub print_contacts { $sysmail = $defaults->{'sysmail'}; } if (ref($lonstatus{'weights'}) eq 'HASH') { - foreach my $type ('E','W','N') { + foreach my $type ('E','W','N','U') { if ($lonstatus{'weights'}{$type} =~ /^\d+$/) { $weights{$type} = $lonstatus{'weights'}{$type}; } else { @@ -3589,7 +3589,7 @@ sub print_contacts { } } } else { - foreach my $type ('E','W','N') { + foreach my $type ('E','W','N','U') { $weights{$type} = $defaults->{$type}; } } @@ -3610,7 +3610,7 @@ sub print_contacts { ''. ''.$titles->{'errorweights'}. ''; - foreach my $type ('E','W','N') { + foreach my $type ('E','W','N','U') { $datatable .= ''; @@ -6339,13 +6339,13 @@ sub print_loadbalancing { my $numinrow = 1; my $datatable; my %servers = &Apache::lonnet::internet_dom_servers($dom); - my (%currbalancer,%currtargets,%currrules,%existing); + my (%currbalancer,%currtargets,%currrules,%existing,%currcookies); if (ref($settings) eq 'HASH') { %existing = %{$settings}; } if ((keys(%servers) > 1) || (keys(%existing) > 0)) { &get_loadbalancers_config(\%servers,\%existing,\%currbalancer, - \%currtargets,\%currrules); + \%currtargets,\%currrules,\%currcookies); } else { return; } @@ -6422,6 +6422,9 @@ sub print_loadbalancing { my %hostherechecked = ( no => ' checked="checked"', ); + my %balcookiechecked = ( + no => ' checked="checked"', + ); foreach my $sparetype (@sparestypes) { my $targettable; for (my $i=0; $i<$numspares; $i++) { @@ -6477,6 +6480,11 @@ sub print_loadbalancing { } } } + if ($currcookies{$lonhost}) { + %balcookiechecked = ( + yes => ' checked="checked"', + ); + } $datatable .= &mt('Hosting on balancer itself').'
'. '
'; @@ -6485,7 +6493,12 @@ sub print_loadbalancing { 'value="'.$sparetype.'"'.$hostherechecked{$sparetype}.' />'.$typetitles{$sparetype}. '
'; } - $datatable .= ''. + $datatable .= &mt('Use balancer cookie').'
'. + '
'. + '
'. + ''. &loadbalancing_rules($dom,$intdom,$currrules{$lonhost}, $othertitle,$usertypes,$types,\%servers, \%currbalancer,$lonhost, @@ -6499,10 +6512,11 @@ sub print_loadbalancing { } sub get_loadbalancers_config { - my ($servers,$existing,$currbalancer,$currtargets,$currrules) = @_; + my ($servers,$existing,$currbalancer,$currtargets,$currrules,$currcookies) = @_; return unless ((ref($servers) eq 'HASH') && (ref($existing) eq 'HASH') && (ref($currbalancer) eq 'HASH') && - (ref($currtargets) eq 'HASH') && (ref($currrules) eq 'HASH')); + (ref($currtargets) eq 'HASH') && (ref($currrules) eq 'HASH') && + (ref($currcookies) eq 'HASH')); if (keys(%{$existing}) > 0) { my $oldlonhost; foreach my $key (sort(keys(%{$existing}))) { @@ -6521,6 +6535,9 @@ sub get_loadbalancers_config { $currbalancer->{$key} = 1; $currtargets->{$key} = $existing->{$key}{'targets'}; $currrules->{$key} = $existing->{$key}{'rules'}; + if ($existing->{$key}{'cookie'}) { + $currcookies->{$key} = 1; + } } } } else { @@ -13019,7 +13036,7 @@ sub modify_contacts { if ((ref($contacts_hash{contacts}{lonstatus}) eq 'HASH') && (ref($contacts_hash{contacts}{lonstatus}{$key}) eq 'HASH')) { if (ref($currsetting{'lonstatus'}{$key}) eq 'HASH') { - foreach my $type ('E','W','N') { + foreach my $type ('E','W','N','U') { unless ($contacts_hash{contacts}{lonstatus}{$key}{$type} eq $currsetting{'lonstatus'}{$key}{$type}) { push(@{$changes{'lonstatus'}},$key); @@ -13027,7 +13044,7 @@ sub modify_contacts { } } } else { - foreach my $type ('E','W','N') { + foreach my $type ('E','W','N','U') { if ($contacts_hash{contacts}{lonstatus}{$key}{$type} ne '') { push(@{$changes{'lonstatus'}},$key); last; @@ -13035,7 +13052,7 @@ sub modify_contacts { } } } elsif (ref($currsetting{'lonstatus'}{$key}) eq 'HASH') { - foreach my $type ('E','W','N') { + foreach my $type ('E','W','N','U') { if ($currsetting{'lonstatus'}{$key}{$type} ne '') { push(@{$changes{'lonstatus'}},$key); last; @@ -13270,7 +13287,7 @@ sub modify_contacts { $defval{'threshold'} = $lonstatus_defs->{'threshold'}; $defval{'sysmail'} = $lonstatus_defs->{'sysmail'}; $defval{'weights'} = - join(', ',map { $lonstatus_names->{$_}.'='.$lonstatus_defs->{$_}; } ('E','W','N')); + join(', ',map { $lonstatus_names->{$_}.'='.$lonstatus_defs->{$_}; } ('E','W','N','U')); $defval{'excluded'} = &mt('None'); if (ref($contacts_hash{'contacts'}{'lonstatus'}) eq 'HASH') { foreach my $item ('threshold','sysmail','weights','excluded') { @@ -13279,7 +13296,7 @@ sub modify_contacts { $shown{$item} = $contacts_hash{'contacts'}{'lonstatus'}{$item}; } elsif ($item eq 'weights') { if (ref($contacts_hash{'contacts'}{'lonstatus'}{$item}) eq 'HASH') { - foreach my $type ('E','W','N') { + foreach my $type ('E','W','N','U') { $shown{$item} .= $lonstatus_names->{$type}.'='; if (exists($contacts_hash{'contacts'}{'lonstatus'}{$item}{$type})) { $shown{$item} .= $contacts_hash{'contacts'}{'lonstatus'}{$item}{$type}; @@ -16625,14 +16642,18 @@ sub modify_usersessions { } else { foreach my $type (@{$types{$prefix}}) { if (defined($changes{$prefix}{$type})) { - my $newvalue; + my ($newvalue,$notinuse); 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 { + if (ref($defaultshash{'usersessions'}{$prefix}{$type}) eq 'ARRAY') { + if (@{$defaultshash{'usersessions'}{$prefix}{$type}} > 0) { + $newvalue = join(', ',@{$defaultshash{'usersessions'}{$prefix}{$type}}); + } + } else { + $notinuse = 1; } } } @@ -16640,12 +16661,14 @@ sub modify_usersessions { if ($newvalue eq '') { if ($type eq 'version') { $resulttext .= '
  • '.&mt('[_1] set to: off',$lt{$type}).'
  • '; + } elsif ($notinuse) { + $resulttext .= '
  • '.&mt('[_1] set to: not in use',$lt{$type}).'
  • '; } else { $resulttext .= '
  • '.&mt('[_1] set to: none',$lt{$type}).'
  • '; } } else { if ($type eq 'version') { - $newvalue .= ' '.&mt('(or later)'); + $newvalue .= ' '.&mt('(or later)'); } $resulttext .= '
  • '.&mt('[_1] set to: [_2].',$lt{$type},$newvalue).'
  • '; } @@ -16833,18 +16856,24 @@ sub modify_ssl { $resulttext .= '
  • '.$titles{$prefix}.'
  • '.$names->{$type}.'
    '. '