version 1.160.6.104, 2020/02/09 05:18:20
|
version 1.160.6.105, 2020/05/02 18:36:17
|
Line 4653 sub print_usersessions {
|
Line 4653 sub print_usersessions {
|
if ($position eq 'top') { |
if ($position eq 'top') { |
if (keys(%serverhomes) > 1) { |
if (keys(%serverhomes) > 1) { |
my %spareid = ¤t_offloads_to($dom,$settings,\%servers); |
my %spareid = ¤t_offloads_to($dom,$settings,\%servers); |
my $curroffloadnow; |
my ($curroffloadnow,$curroffloadoth); |
if (ref($settings) eq 'HASH') { |
if (ref($settings) eq 'HASH') { |
if (ref($settings->{'offloadnow'}) eq 'HASH') { |
if (ref($settings->{'offloadnow'}) eq 'HASH') { |
$curroffloadnow = $settings->{'offloadnow'}; |
$curroffloadnow = $settings->{'offloadnow'}; |
} |
} |
|
if (ref($settings->{'offloadoth'}) eq 'HASH') { |
|
$curroffloadoth = $settings->{'offloadoth'}; |
|
} |
} |
} |
$datatable .= &spares_row($dom,\%servers,\%spareid,\%serverhomes,\%altids,$curroffloadnow,$rowtotal); |
my $other_insts = scalar(keys(%by_location)); |
|
$datatable .= &spares_row($dom,\%servers,\%spareid,\%serverhomes,\%altids, |
|
$other_insts,$curroffloadnow,$curroffloadoth,$rowtotal); |
} else { |
} else { |
$datatable .= '<tr'.$css_class.'><td colspan="2">'. |
$datatable .= '<tr'.$css_class.'><td colspan="2">'. |
&mt('Nothing to set here, as the cluster to which this domain belongs only contains one server.'); |
&mt('Nothing to set here, as the cluster to which this domain belongs only contains one server.'); |
Line 4909 sub current_offloads_to {
|
Line 4914 sub current_offloads_to {
|
} |
} |
|
|
sub spares_row { |
sub spares_row { |
my ($dom,$servers,$spareid,$serverhomes,$altids,$curroffloadnow,$rowtotal) = @_; |
my ($dom,$servers,$spareid,$serverhomes,$altids,$other_insts, |
|
$curroffloadnow,$curroffloadoth,$rowtotal) = @_; |
my $css_class; |
my $css_class; |
my $numinrow = 4; |
my $numinrow = 4; |
my $itemcount = 1; |
my $itemcount = 1; |
Line 4929 sub spares_row {
|
Line 4935 sub spares_row {
|
} |
} |
} |
} |
next unless (ref($spareid->{$server}) eq 'HASH'); |
next unless (ref($spareid->{$server}) eq 'HASH'); |
my $checkednow; |
my ($checkednow,$checkedoth); |
if (ref($curroffloadnow) eq 'HASH') { |
if (ref($curroffloadnow) eq 'HASH') { |
if ($curroffloadnow->{$server}) { |
if ($curroffloadnow->{$server}) { |
$checkednow = ' checked="checked"'; |
$checkednow = ' checked="checked"'; |
} |
} |
} |
} |
|
if (ref($curroffloadoth) eq 'HASH') { |
|
if ($curroffloadoth->{$server}) { |
|
$checkedoth = ' checked="checked"'; |
|
} |
|
} |
$css_class = $itemcount%2 ? ' class="LC_odd_row"' : ''; |
$css_class = $itemcount%2 ? ' class="LC_odd_row"' : ''; |
$datatable .= '<tr'.$css_class.'> |
$datatable .= '<tr'.$css_class.'> |
<td rowspan="2"> |
<td rowspan="2"> |
Line 4943 sub spares_row {
|
Line 4954 sub spares_row {
|
,'<b>'.$server.'</b>').'</span><br />'. |
,'<b>'.$server.'</b>').'</span><br />'. |
'<span class="LC_nobreak">'."\n". |
'<span class="LC_nobreak">'."\n". |
'<label><input type="checkbox" name="offloadnow" value="'.$server.'"'.$checkednow.' />'. |
'<label><input type="checkbox" name="offloadnow" value="'.$server.'"'.$checkednow.' />'. |
' '.&mt('Switch active users on next access').'</label></span>'. |
' '.&mt('Switch any active user on next access').'</label></span>'. |
"\n"; |
"\n"; |
|
if ($other_insts) { |
|
$datatable .= '<br />'. |
|
'<span class="LC_nobreak">'."\n". |
|
'<label><input type="checkbox" name="offloadoth" value="'.$server.'"'.$checkedoth.' />'. |
|
' '.&mt('Switch other institutions on next access').'</label></span>'. |
|
"\n"; |
|
} |
my (%current,%canselect); |
my (%current,%canselect); |
my @choices = |
my @choices = |
&possible_newspares($server,$spareid->{$server},$serverhomes,$altids); |
&possible_newspares($server,$spareid->{$server},$serverhomes,$altids); |
Line 14621 sub modify_usersessions {
|
Line 14639 sub modify_usersessions {
|
} |
} |
} |
} |
$defaultshash{'usersessions'}{'offloadnow'} = {}; |
$defaultshash{'usersessions'}{'offloadnow'} = {}; |
|
$defaultshash{'usersessions'}{'offloadoth'} = {}; |
my @offloadnow = &Apache::loncommon::get_env_multiple('form.offloadnow'); |
my @offloadnow = &Apache::loncommon::get_env_multiple('form.offloadnow'); |
my @okoffload; |
my @okoffload; |
if (@offloadnow) { |
if (@offloadnow) { |
Line 14637 sub modify_usersessions {
|
Line 14656 sub modify_usersessions {
|
} |
} |
} |
} |
} |
} |
|
my @offloadoth = &Apache::loncommon::get_env_multiple('form.offloadoth'); |
|
my @okoffloadoth; |
|
if (@offloadoth) { |
|
foreach my $server (@offloadoth) { |
|
if (&Apache::lonnet::hostname($server) ne '') { |
|
unless (grep(/^\Q$server\E$/,@okoffloadoth)) { |
|
push(@okoffloadoth,$server); |
|
} |
|
} |
|
} |
|
if (@okoffloadoth) { |
|
foreach my $lonhost (@okoffloadoth) { |
|
$defaultshash{'usersessions'}{'offloadoth'}{$lonhost} = 1; |
|
} |
|
} |
|
} |
if (ref($domconfig{'usersessions'}) eq 'HASH') { |
if (ref($domconfig{'usersessions'}) eq 'HASH') { |
if (ref($domconfig{'usersessions'}{'spares'}) eq 'HASH') { |
if (ref($domconfig{'usersessions'}{'spares'}) eq 'HASH') { |
if (ref($changes{'spares'}) eq 'HASH') { |
if (ref($changes{'spares'}) eq 'HASH') { |
Line 14647 sub modify_usersessions {
|
Line 14682 sub modify_usersessions {
|
} else { |
} else { |
$savespares = 1; |
$savespares = 1; |
} |
} |
if (ref($domconfig{'usersessions'}{'offloadnow'}) eq 'HASH') { |
foreach my $offload ('offloadnow','offloadoth') { |
foreach my $lonhost (keys(%{$domconfig{'usersessions'}{'offloadnow'}})) { |
if (ref($domconfig{'usersessions'}{$offload}) eq 'HASH') { |
unless ($defaultshash{'usersessions'}{'offloadnow'}{$lonhost}) { |
foreach my $lonhost (keys(%{$domconfig{'usersessions'}{$offload}})) { |
$changes{'offloadnow'} = 1; |
unless ($defaultshash{'usersessions'}{$offload}{$lonhost}) { |
last; |
$changes{$offload} = 1; |
} |
|
} |
|
unless ($changes{'offloadnow'}) { |
|
foreach my $lonhost (keys(%{$defaultshash{'usersessions'}{'offloadnow'}})) { |
|
unless ($domconfig{'usersessions'}{'offloadnow'}{$lonhost}) { |
|
$changes{'offloadnow'} = 1; |
|
last; |
last; |
} |
} |
} |
} |
|
unless ($changes{$offload}) { |
|
foreach my $lonhost (keys(%{$defaultshash{'usersessions'}{$offload}})) { |
|
unless ($domconfig{'usersessions'}{$offload}{$lonhost}) { |
|
$changes{$offload} = 1; |
|
last; |
|
} |
|
} |
|
} |
|
} else { |
|
if (($offload eq 'offloadnow') && (@okoffload)) { |
|
$changes{'offloadnow'} = 1; |
|
} |
|
if (($offload eq 'offloadoth') && (@okoffloadoth)) { |
|
$changes{'offloadoth'} = 1; |
|
} |
} |
} |
} elsif (@okoffload) { |
} |
|
} else { |
|
if (@okoffload) { |
$changes{'offloadnow'} = 1; |
$changes{'offloadnow'} = 1; |
} |
} |
} elsif (@okoffload) { |
if (@okoffloadoth) { |
$changes{'offloadnow'} = 1; |
$changes{'offloadoth'} = 1; |
|
} |
} |
} |
my $nochgmsg = &mt('No changes made to settings for user session hosting/offloading.'); |
my $nochgmsg = &mt('No changes made to settings for user session hosting/offloading.'); |
if ((keys(%changes) > 0) || ($savespares)) { |
if ((keys(%changes) > 0) || ($savespares)) { |
Line 14683 sub modify_usersessions {
|
Line 14730 sub modify_usersessions {
|
if (ref($defaultshash{'usersessions'}{'offloadnow'}) eq 'HASH') { |
if (ref($defaultshash{'usersessions'}{'offloadnow'}) eq 'HASH') { |
$domdefaults{'offloadnow'} = $defaultshash{'usersessions'}{'offloadnow'}; |
$domdefaults{'offloadnow'} = $defaultshash{'usersessions'}{'offloadnow'}; |
} |
} |
|
if (ref($defaultshash{'usersessions'}{'offloadoth'}) eq 'HASH') { |
|
$domdefaults{'offloadoth'} = $defaultshash{'usersessions'}{'offloadoth'}; |
|
} |
} |
} |
my $cachetime = 24*60*60; |
my $cachetime = 24*60*60; |
&Apache::lonnet::do_cache_new('domdefaults',$dom,\%domdefaults,$cachetime); |
&Apache::lonnet::do_cache_new('domdefaults',$dom,\%domdefaults,$cachetime); |
Line 14756 sub modify_usersessions {
|
Line 14806 sub modify_usersessions {
|
if ($changes{'offloadnow'}) { |
if ($changes{'offloadnow'}) { |
if (ref($defaultshash{'usersessions'}{'offloadnow'}) eq 'HASH') { |
if (ref($defaultshash{'usersessions'}{'offloadnow'}) eq 'HASH') { |
if (keys(%{$defaultshash{'usersessions'}{'offloadnow'}}) > 0) { |
if (keys(%{$defaultshash{'usersessions'}{'offloadnow'}}) > 0) { |
$resulttext .= '<li>'.&mt('Switch active users on next access, for server(s):').'<ul>'; |
$resulttext .= '<li>'.&mt('Switch any active user on next access, for server(s):').'<ul>'; |
foreach my $lonhost (sort(keys(%{$defaultshash{'usersessions'}{'offloadnow'}}))) { |
foreach my $lonhost (sort(keys(%{$defaultshash{'usersessions'}{'offloadnow'}}))) { |
$resulttext .= '<li>'.$lonhost.'</li>'; |
$resulttext .= '<li>'.$lonhost.'</li>'; |
} |
} |
$resulttext .= '</ul>'; |
$resulttext .= '</ul>'; |
} else { |
} else { |
$resulttext .= '<li>'.&mt('No servers now set to switch active users on next access.'); |
$resulttext .= '<li>'.&mt('No servers now set to switch any active user on next access.'); |
|
} |
|
} else { |
|
$resulttext .= '<li>'.&mt('No servers now set to switch any active user on next access.').'</li>'; |
|
} |
|
} |
|
if ($changes{'offloadoth'}) { |
|
if (ref($defaultshash{'usersessions'}{'offloadoth'}) eq 'HASH') { |
|
if (keys(%{$defaultshash{'usersessions'}{'offloadoth'}}) > 0) { |
|
$resulttext .= '<li>'.&mt('Switch other institutions on next access, for server(s):').'<ul>'; |
|
foreach my $lonhost (sort(keys(%{$defaultshash{'usersessions'}{'offloadoth'}}))) { |
|
$resulttext .= '<li>'.$lonhost.'</li>'; |
|
} |
|
$resulttext .= '</ul>'; |
|
} else { |
|
$resulttext .= '<li>'.&mt('No servers now set to switch other institutions on next access.'); |
} |
} |
} else { |
} else { |
$resulttext .= '<li>'.&mt('No servers now set to switch active users on next access.').'</li>'; |
$resulttext .= '<li>'.&mt('No servers now set to switch other institutions on next access.').'</li>'; |
} |
} |
} |
} |
$resulttext .= '</ul>'; |
$resulttext .= '</ul>'; |