Diff for /loncom/interface/domainprefs.pm between versions 1.340 and 1.343

version 1.340, 2018/11/06 15:37:37 version 1.343, 2018/12/05 21:13:23
Line 2842  function toggleLTI(form,setting,item) { Line 2842  function toggleLTI(form,setting,item) {
         if (setting == 'user') {          if (setting == 'user') {
             radioname = 'lti_mapuser_'+item;              radioname = 'lti_mapuser_'+item;
             divid = 'lti_userfield_'+item;              divid = 'lti_userfield_'+item;
         } else if (settings == 'crs') {          } else if (setting == 'crs') {
             radioname = 'lti_mapcrs_'+item;              radioname = 'lti_mapcrs_'+item;
             divid = 'lti_crsfield_'+item;              divid = 'lti_crsfield_'+item;
         } else {          } else {
Line 3581  sub print_contacts { Line 3581  sub print_contacts {
             $sysmail = $defaults->{'sysmail'};              $sysmail = $defaults->{'sysmail'};
         }          }
         if (ref($lonstatus{'weights'}) eq 'HASH') {          if (ref($lonstatus{'weights'}) eq 'HASH') {
             foreach my $type ('E','W','N') {              foreach my $type ('E','W','N','U') {
                 if ($lonstatus{'weights'}{$type} =~ /^\d+$/) {                  if ($lonstatus{'weights'}{$type} =~ /^\d+$/) {
                     $weights{$type} = $lonstatus{'weights'}{$type};                      $weights{$type} = $lonstatus{'weights'}{$type};
                 } else {                  } else {
Line 3589  sub print_contacts { Line 3589  sub print_contacts {
                 }                  }
             }              }
         } else {          } else {
             foreach my $type ('E','W','N') {              foreach my $type ('E','W','N','U') {
                 $weights{$type} = $defaults->{$type};                  $weights{$type} = $defaults->{$type};
             }              }
         }          }
Line 3610  sub print_contacts { Line 3610  sub print_contacts {
                       '<td class="LC_left_item">'.                        '<td class="LC_left_item">'.
                       '<span class="LC_nobreak">'.$titles->{'errorweights'}.                        '<span class="LC_nobreak">'.$titles->{'errorweights'}.
                       '</span></td><td class="LC_left_item"><table><tr>';                        '</span></td><td class="LC_left_item"><table><tr>';
         foreach my $type ('E','W','N') {          foreach my $type ('E','W','N','U') {
             $datatable .= '<td>'.$names->{$type}.'<br />'.              $datatable .= '<td>'.$names->{$type}.'<br />'.
                           '<input type="text" name="errorweights_'.$type.'" value="'.                            '<input type="text" name="errorweights_'.$type.'" value="'.
                           $weights{$type}.'" size="5" /></td>';                            $weights{$type}.'" size="5" /></td>';
Line 6339  sub print_loadbalancing { Line 6339  sub print_loadbalancing {
     my $numinrow = 1;      my $numinrow = 1;
     my $datatable;      my $datatable;
     my %servers = &Apache::lonnet::internet_dom_servers($dom);      my %servers = &Apache::lonnet::internet_dom_servers($dom);
     my (%currbalancer,%currtargets,%currrules,%existing);      my (%currbalancer,%currtargets,%currrules,%existing,%currcookies);
     if (ref($settings) eq 'HASH') {      if (ref($settings) eq 'HASH') {
         %existing = %{$settings};          %existing = %{$settings};
     }      }
     if ((keys(%servers) > 1) || (keys(%existing) > 0)) {      if ((keys(%servers) > 1) || (keys(%existing) > 0)) {
         &get_loadbalancers_config(\%servers,\%existing,\%currbalancer,          &get_loadbalancers_config(\%servers,\%existing,\%currbalancer,
                                   \%currtargets,\%currrules);                                    \%currtargets,\%currrules,\%currcookies);
     } else {      } else {
         return;          return;
     }      }
Line 6422  sub print_loadbalancing { Line 6422  sub print_loadbalancing {
         my %hostherechecked = (          my %hostherechecked = (
                                   no => ' checked="checked"',                                    no => ' checked="checked"',
                               );                                );
           my %balcookiechecked = (
                                     no => ' checked="checked"', 
                                  );
         foreach my $sparetype (@sparestypes) {          foreach my $sparetype (@sparestypes) {
             my $targettable;              my $targettable;
             for (my $i=0; $i<$numspares; $i++) {              for (my $i=0; $i<$numspares; $i++) {
Line 6477  sub print_loadbalancing { Line 6480  sub print_loadbalancing {
                 }                  }
             }              }
         }          }
           if ($currcookies{$lonhost}) {
               %balcookiechecked = (
                                       yes => ' checked="checked"',
                                   );
           }
         $datatable .= &mt('Hosting on balancer itself').'<br />'.          $datatable .= &mt('Hosting on balancer itself').'<br />'.
                       '<label><input type="radio" name="loadbalancing_target_'.$balnum.'_hosthere" value="no"'.                        '<label><input type="radio" name="loadbalancing_target_'.$balnum.'_hosthere" value="no"'.
                       $hostherechecked{'no'}.' />'.&mt('No').'</label><br />';                        $hostherechecked{'no'}.' />'.&mt('No').'</label><br />';
Line 6485  sub print_loadbalancing { Line 6493  sub print_loadbalancing {
                           'value="'.$sparetype.'"'.$hostherechecked{$sparetype}.' /><i>'.$typetitles{$sparetype}.                            'value="'.$sparetype.'"'.$hostherechecked{$sparetype}.' /><i>'.$typetitles{$sparetype}.
                           '</i></label><br />';                            '</i></label><br />';
         }          }
         $datatable .= '</div></td></tr>'.          $datatable .= &mt('Use balancer cookie').'<br />'.
                         '<label><input type="radio" name="loadbalancing_cookie_'.$balnum.'" value="1"'.
                         $balcookiechecked{'yes'}.' />'.&mt('Yes').'</label><br />'.
                         '<label><input type="radio" name="loadbalancing_cookie_'.$balnum.'" value="0"'.
                         $balcookiechecked{'no'}.' />'.&mt('No').'</label><br />'.
                         '</div></td></tr>'.
                       &loadbalancing_rules($dom,$intdom,$currrules{$lonhost},                        &loadbalancing_rules($dom,$intdom,$currrules{$lonhost},
                                            $othertitle,$usertypes,$types,\%servers,                                             $othertitle,$usertypes,$types,\%servers,
                                            \%currbalancer,$lonhost,                                             \%currbalancer,$lonhost,
Line 6499  sub print_loadbalancing { Line 6512  sub print_loadbalancing {
 }  }
   
 sub get_loadbalancers_config {  sub get_loadbalancers_config {
     my ($servers,$existing,$currbalancer,$currtargets,$currrules) = @_;      my ($servers,$existing,$currbalancer,$currtargets,$currrules,$currcookies) = @_;
     return unless ((ref($servers) eq 'HASH') &&      return unless ((ref($servers) eq 'HASH') &&
                    (ref($existing) eq 'HASH') && (ref($currbalancer) 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) {      if (keys(%{$existing}) > 0) {
         my $oldlonhost;          my $oldlonhost;
         foreach my $key (sort(keys(%{$existing}))) {          foreach my $key (sort(keys(%{$existing}))) {
Line 6521  sub get_loadbalancers_config { Line 6535  sub get_loadbalancers_config {
                 $currbalancer->{$key} = 1;                  $currbalancer->{$key} = 1;
                 $currtargets->{$key} = $existing->{$key}{'targets'};                  $currtargets->{$key} = $existing->{$key}{'targets'};
                 $currrules->{$key} = $existing->{$key}{'rules'};                  $currrules->{$key} = $existing->{$key}{'rules'};
                   if ($existing->{$key}{'cookie'}) {
                       $currcookies->{$key} = 1;
                   }
             }              }
         }          }
     } else {      } else {
Line 13019  sub modify_contacts { Line 13036  sub modify_contacts {
                     if ((ref($contacts_hash{contacts}{lonstatus}) eq 'HASH') &&                      if ((ref($contacts_hash{contacts}{lonstatus}) eq 'HASH') &&
                         (ref($contacts_hash{contacts}{lonstatus}{$key}) eq 'HASH')) {                          (ref($contacts_hash{contacts}{lonstatus}{$key}) eq 'HASH')) {
                         if (ref($currsetting{'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                                  unless ($contacts_hash{contacts}{lonstatus}{$key}{$type} eq
                                         $currsetting{'lonstatus'}{$key}{$type}) {                                          $currsetting{'lonstatus'}{$key}{$type}) {
                                     push(@{$changes{'lonstatus'}},$key);                                      push(@{$changes{'lonstatus'}},$key);
Line 13027  sub modify_contacts { Line 13044  sub modify_contacts {
                                 }                                  }
                             }                              }
                         } else {                          } else {
                             foreach my $type ('E','W','N') {                              foreach my $type ('E','W','N','U') {
                                 if ($contacts_hash{contacts}{lonstatus}{$key}{$type} ne '') {                                  if ($contacts_hash{contacts}{lonstatus}{$key}{$type} ne '') {
                                     push(@{$changes{'lonstatus'}},$key);                                      push(@{$changes{'lonstatus'}},$key);
                                     last;                                      last;
Line 13035  sub modify_contacts { Line 13052  sub modify_contacts {
                             }                              }
                         }                          }
                     } elsif (ref($currsetting{'lonstatus'}{$key}) eq 'HASH') {                      } 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 '') {                              if ($currsetting{'lonstatus'}{$key}{$type} ne '') {
                                 push(@{$changes{'lonstatus'}},$key);                                  push(@{$changes{'lonstatus'}},$key);
                                 last;                                  last;
Line 13270  sub modify_contacts { Line 13287  sub modify_contacts {
                 $defval{'threshold'} = $lonstatus_defs->{'threshold'};                  $defval{'threshold'} = $lonstatus_defs->{'threshold'};
                 $defval{'sysmail'} = $lonstatus_defs->{'sysmail'};                  $defval{'sysmail'} = $lonstatus_defs->{'sysmail'};
                 $defval{'weights'} =                  $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');                  $defval{'excluded'} = &mt('None');
                 if (ref($contacts_hash{'contacts'}{'lonstatus'}) eq 'HASH') {                  if (ref($contacts_hash{'contacts'}{'lonstatus'}) eq 'HASH') {
                     foreach my $item ('threshold','sysmail','weights','excluded') {                      foreach my $item ('threshold','sysmail','weights','excluded') {
Line 13279  sub modify_contacts { Line 13296  sub modify_contacts {
                                 $shown{$item} = $contacts_hash{'contacts'}{'lonstatus'}{$item};                                  $shown{$item} = $contacts_hash{'contacts'}{'lonstatus'}{$item};
                             } elsif ($item eq 'weights') {                              } elsif ($item eq 'weights') {
                                 if (ref($contacts_hash{'contacts'}{'lonstatus'}{$item}) eq 'HASH') {                                  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}.'=';                                          $shown{$item} .= $lonstatus_names->{$type}.'=';
                                         if (exists($contacts_hash{'contacts'}{'lonstatus'}{$item}{$type})) {                                          if (exists($contacts_hash{'contacts'}{'lonstatus'}{$item}{$type})) {
                                             $shown{$item} .= $contacts_hash{'contacts'}{'lonstatus'}{$item}{$type};                                              $shown{$item} .= $contacts_hash{'contacts'}{'lonstatus'}{$item}{$type};
Line 17003  sub modify_loadbalancing { Line 17020  sub modify_loadbalancing {
     my @sparestypes = ('primary','default');      my @sparestypes = ('primary','default');
     my %typetitles = &sparestype_titles();      my %typetitles = &sparestype_titles();
     my $resulttext;      my $resulttext;
     my (%currbalancer,%currtargets,%currrules,%existing);      my (%currbalancer,%currtargets,%currrules,%existing,%currcookies);
     if (ref($domconfig{'loadbalancing'}) eq 'HASH') {      if (ref($domconfig{'loadbalancing'}) eq 'HASH') {
         %existing = %{$domconfig{'loadbalancing'}};          %existing = %{$domconfig{'loadbalancing'}};
     }      }
     &get_loadbalancers_config(\%servers,\%existing,\%currbalancer,      &get_loadbalancers_config(\%servers,\%existing,\%currbalancer,
                               \%currtargets,\%currrules);                                \%currtargets,\%currrules,\%currcookies);
     my ($saveloadbalancing,%defaultshash,%changes);      my ($saveloadbalancing,%defaultshash,%changes);
     my ($alltypes,$othertypes,$titles) =      my ($alltypes,$othertypes,$titles) =
         &loadbalancing_titles($dom,$intdom,$usertypes,$types);          &loadbalancing_titles($dom,$intdom,$usertypes,$types);
Line 17060  sub modify_loadbalancing { Line 17077  sub modify_loadbalancing {
             }              }
             $defaultshash{'loadbalancing'}{$balancer}{'targets'}{$sparetype} = \@offloadto;              $defaultshash{'loadbalancing'}{$balancer}{'targets'}{$sparetype} = \@offloadto;
         }          }
           if ($env{'form.loadbalancing_cookie_'.$i}) {
               $defaultshash{'loadbalancing'}{$balancer}{'cookie'} = 1;
               if (exists($currbalancer{$balancer})) { 
                   unless ($currcookies{$balancer}) {
                       $changes{'curr'}{$balancer}{'cookie'} = 1;
                   }
               }
           } elsif (exists($currbalancer{$balancer})) {
               if ($currcookies{$balancer}) {
                   $changes{'curr'}{$balancer}{'cookie'} = 1;
               }
           }
         if (ref($currtargets{$balancer}) eq 'HASH') {          if (ref($currtargets{$balancer}) eq 'HASH') {
             foreach my $sparetype (@sparestypes) {              foreach my $sparetype (@sparestypes) {
                 if (ref($currtargets{$balancer}{$sparetype}) eq 'ARRAY') {                  if (ref($currtargets{$balancer}{$sparetype}) eq 'ARRAY') {
Line 17213  sub modify_loadbalancing { Line 17242  sub modify_loadbalancing {
                                 }                                  }
                             }                              }
                         }                          }
                           if ($changes{'curr'}{$balancer}{'cookie'}) {
                               $resulttext .= '<li>'.&mt('Load Balancer: [_1] -- cookie use enabled',
                                                         $balancer).'</li>'; 
                           }
                         if (keys(%toupdate)) {                          if (keys(%toupdate)) {
                             my %thismachine;                              my %thismachine;
                             my $updatedhere;                              my $updatedhere;
Line 17442  sub lonbalance_targets_js { Line 17475  sub lonbalance_targets_js {
     }      }
     push(@alltypes,'default','_LC_adv','_LC_author','_LC_internetdom','_LC_external');      push(@alltypes,'default','_LC_adv','_LC_author','_LC_internetdom','_LC_external');
     $allinsttypes = join("','",@alltypes);      $allinsttypes = join("','",@alltypes);
     my (%currbalancer,%currtargets,%currrules,%existing);      my (%currbalancer,%currtargets,%currrules,%existing,%currcookies);
     if (ref($settings) eq 'HASH') {      if (ref($settings) eq 'HASH') {
         %existing = %{$settings};          %existing = %{$settings};
     }      }
     &get_loadbalancers_config($servers,\%existing,\%currbalancer,      &get_loadbalancers_config($servers,\%existing,\%currbalancer,
                               \%currtargets,\%currrules);                                \%currtargets,\%currrules,\%currcookies);
     my $balancers = join("','",sort(keys(%currbalancer)));      my $balancers = join("','",sort(keys(%currbalancer)));
     return <<"END";      return <<"END";
   

Removed from v.1.340  
changed lines
  Added in v.1.343


FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>