version 1.144, 2011/07/29 14:25:36
|
version 1.145, 2011/07/31 23:05:00
|
Line 352 sub handler {
|
Line 352 sub handler {
|
col2 => 'Value',}], |
col2 => 'Value',}], |
}, |
}, |
'usersessions' => |
'usersessions' => |
{text => 'User session hosting', |
{text => 'User session hosting/offloading', |
help => 'Domain_Configuration_User_Sessions', |
help => 'Domain_Configuration_User_Sessions', |
header => [{col1 => 'Hosting of users from other domains', |
header => [{col1 => 'Domain server', |
|
col2 => 'Servers to offload sessions to when busy'}, |
|
{col1 => 'Hosting of users from other domains', |
col2 => 'Rules'}, |
col2 => 'Rules'}, |
{col1 => "Hosting domain's own users elsewhere", |
{col1 => "Hosting domain's own users elsewhere", |
col2 => 'Rules'}], |
col2 => 'Rules'}], |
Line 488 sub print_config_box {
|
Line 490 sub print_config_box {
|
} |
} |
if ($numheaders > 1) { |
if ($numheaders > 1) { |
my $colspan = ''; |
my $colspan = ''; |
|
my $rightcolspan = ''; |
if (($action eq 'rolecolors') || ($action eq 'coursecategories') || ($action eq 'helpsettings')) { |
if (($action eq 'rolecolors') || ($action eq 'coursecategories') || ($action eq 'helpsettings')) { |
$colspan = ' colspan="2"'; |
$colspan = ' colspan="2"'; |
} |
} |
|
if ($action eq 'usersessions') { |
|
$rightcolspan = ' colspan="3"'; |
|
} |
$output .= ' |
$output .= ' |
<tr> |
<tr> |
<td> |
<td> |
<table class="LC_nested"> |
<table class="LC_nested"> |
<tr class="LC_info_row"> |
<tr class="LC_info_row"> |
<td class="LC_left_item"'.$colspan.'>'.&mt($item->{'header'}->[0]->{'col1'}).'</td> |
<td class="LC_left_item"'.$colspan.'>'.&mt($item->{'header'}->[0]->{'col1'}).'</td> |
<td class="LC_right_item">'.&mt($item->{'header'}->[0]->{'col2'}).'</td> |
<td class="LC_right_item"'.$rightcolspan.'>'.&mt($item->{'header'}->[0]->{'col2'}).'</td> |
</tr>'; |
</tr>'; |
$rowtotal ++; |
$rowtotal ++; |
if ($action eq 'autoupdate') { |
if ($action eq 'autoupdate') { |
Line 583 sub print_config_box {
|
Line 589 sub print_config_box {
|
} elsif ($action eq 'helpsettings') { |
} elsif ($action eq 'helpsettings') { |
$output .= &print_helpsettings('bottom',$dom,$confname,$settings,\$rowtotal); |
$output .= &print_helpsettings('bottom',$dom,$confname,$settings,\$rowtotal); |
} elsif ($action eq 'usersessions') { |
} elsif ($action eq 'usersessions') { |
$output .= &print_usersessions('bottom',$dom,$settings,\$rowtotal); |
$output .= &print_usersessions('middle',$dom,$settings,\$rowtotal).' |
|
</table> |
|
</td> |
|
</tr> |
|
<tr> |
|
<td> |
|
<table class="LC_nested"> |
|
<tr class="LC_info_row"> |
|
<td class="LC_left_item"'.$colspan.'>'.&mt($item->{'header'}->[2]->{'col1'}).'</td> |
|
<td class="LC_right_item">'.&mt($item->{'header'}->[2]->{'col2'}).'</td> </tr>'. |
|
&print_usersessions('bottom',$dom,$settings,\$rowtotal); |
|
$rowtotal ++; |
} elsif ($action eq 'coursedefaults') { |
} elsif ($action eq 'coursedefaults') { |
$output .= &print_coursedefaults('bottom',$dom,$settings,\$rowtotal); |
$output .= &print_coursedefaults('bottom',$dom,$settings,\$rowtotal); |
} elsif ($action eq 'rolecolors') { |
} elsif ($action eq 'rolecolors') { |
Line 2287 sub print_usersessions {
|
Line 2304 sub print_usersessions {
|
my ($css_class,$datatable,%checked,%choices); |
my ($css_class,$datatable,%checked,%choices); |
my (%by_ip,%by_location,@intdoms); |
my (%by_ip,%by_location,@intdoms); |
&build_location_hashes(\@intdoms,\%by_ip,\%by_location); |
&build_location_hashes(\@intdoms,\%by_ip,\%by_location); |
if (keys(%by_location) == 0) { |
|
if ($position eq 'top') { |
my @alldoms = &Apache::lonnet::all_domains(); |
$datatable .= '<tr'.$css_class.'><td colspan="2">'. |
my %uniques = &Apache::lonnet::get_unique_servers(\@alldoms); |
&mt('Nothing to set here, as the cluster to which this domain belongs only contains this institution.'); |
my %servers = &dom_servers($dom); |
} |
|
} |
|
my %lt = &usersession_titles(); |
|
my $itemcount = 1; |
my $itemcount = 1; |
my $numinrow = 5; |
|
my $prefix; |
|
my @types; |
|
if ($position eq 'top') { |
if ($position eq 'top') { |
$prefix = 'hosted'; |
if (keys(%uniques) > 1) { |
@types = ('excludedomain','includedomain'); |
my %spareid = ¤t_offloads_to($dom,$settings,\%servers); |
|
$datatable .= &spares_row(\%servers,\%spareid,\%uniques,$rowtotal); |
|
} else { |
|
$datatable .= '<tr'.$css_class.'><td colspan="2">'. |
|
&mt('Nothing to set here, as the cluster to which this domain belongs only contains this server.'); |
|
} |
} else { |
} else { |
$prefix = 'remote'; |
if (keys(%by_location) == 0) { |
@types = ('version','excludedomain','includedomain'); |
$datatable .= '<tr'.$css_class.'><td colspan="2">'. |
} |
&mt('Nothing to set here, as the cluster to which this domain belongs only contains this institution.'); |
my (%current,%checkedon,%checkedoff); |
} else { |
my @lcversions = &Apache::lonnet::all_loncaparevs(); |
my %lt = &usersession_titles(); |
my @locations = sort(keys(%by_location)); |
my $numinrow = 5; |
foreach my $type (@types) { |
my $prefix; |
$checkedon{$type} = ''; |
my @types; |
$checkedoff{$type} = ' checked="checked"'; |
if ($position eq 'bottom') { |
} |
$prefix = 'remote'; |
if (ref($settings) eq 'HASH') { |
@types = ('version','excludedomain','includedomain'); |
if (ref($settings->{$prefix}) eq 'HASH') { |
} else { |
foreach my $key (keys(%{$settings->{$prefix}})) { |
$prefix = 'hosted'; |
$current{$key} = $settings->{$prefix}{$key}; |
@types = ('excludedomain','includedomain'); |
if ($key eq 'version') { |
|
if ($current{$key} ne '') { |
|
$checkedon{$key} = ' checked="checked"'; |
|
$checkedoff{$key} = ''; |
|
} |
|
} elsif (ref($current{$key}) eq 'ARRAY') { |
|
$checkedon{$key} = ' checked="checked"'; |
|
$checkedoff{$key} = ''; |
|
} |
|
} |
} |
} |
my (%current,%checkedon,%checkedoff); |
} |
my @lcversions = &Apache::lonnet::all_loncaparevs(); |
foreach my $type (@types) { |
my @locations = sort(keys(%by_location)); |
next if ($type ne 'version' && !@locations); |
foreach my $type (@types) { |
$css_class = $itemcount%2 ? ' class="LC_odd_row"' : ''; |
$checkedon{$type} = ''; |
$datatable .= '<tr'.$css_class.'> |
$checkedoff{$type} = ' checked="checked"'; |
<td><span class="LC_nobreak">'.$lt{$type}.'</span><br /> |
} |
<span class="LC_nobreak"> |
if (ref($settings) eq 'HASH') { |
<label><input type="radio" name="'.$prefix.'_'.$type.'_inuse" '.$checkedoff{$type}.' value="0" />'.&mt('Not in use').'</label> |
if (ref($settings->{$prefix}) eq 'HASH') { |
<label><input type="radio" name="'.$prefix.'_'.$type.'_inuse" '.$checkedon{$type}.' value="1" />'.&mt('In use').'</label></span></td><td>'; |
foreach my $key (keys(%{$settings->{$prefix}})) { |
if ($type eq 'version') { |
$current{$key} = $settings->{$prefix}{$key}; |
my $selector = '<select name="'.$prefix.'_version">'; |
if ($key eq 'version') { |
foreach my $version (@lcversions) { |
if ($current{$key} ne '') { |
my $selected = ''; |
$checkedon{$key} = ' checked="checked"'; |
if ($current{'version'} eq $version) { |
$checkedoff{$key} = ''; |
$selected = ' selected="selected"'; |
} |
|
} elsif (ref($current{$key}) eq 'ARRAY') { |
|
$checkedon{$key} = ' checked="checked"'; |
|
$checkedoff{$key} = ''; |
|
} |
|
} |
} |
} |
$selector .= ' <option value="'.$version.'"'. |
|
$selected.'>'.$version.'</option>'; |
|
} |
} |
$selector .= '</select> '; |
foreach my $type (@types) { |
$datatable .= &mt('remote server must be version: [_1] or later',$selector); |
next if ($type ne 'version' && !@locations); |
} else { |
$css_class = $itemcount%2 ? ' class="LC_odd_row"' : ''; |
$datatable.= '<div><input type="button" value="'.&mt('check all').'" '. |
$datatable .= '<tr'.$css_class.'> |
'onclick="javascript:checkAll(document.display.'.$prefix.'_'.$type.')"'. |
<td><span class="LC_nobreak">'.$lt{$type}.'</span><br /> |
' />'.(' 'x2). |
<span class="LC_nobreak"> |
'<input type="button" value="'.&mt('uncheck all').'" '. |
<label><input type="radio" name="'.$prefix.'_'.$type.'_inuse" '.$checkedoff{$type}.' value="0" />'.&mt('Not in use').'</label> |
'onclick="javascript:uncheckAll(document.display.'.$prefix.'_'.$type.')" />'. |
<label><input type="radio" name="'.$prefix.'_'.$type.'_inuse" '.$checkedon{$type}.' value="1" />'.&mt('In use').'</label></span></td><td>'; |
"\n". |
if ($type eq 'version') { |
'</div><div><table>'; |
my $selector = '<select name="'.$prefix.'_version">'; |
my $rem; |
foreach my $version (@lcversions) { |
for (my $i=0; $i<@locations; $i++) { |
my $selected = ''; |
my ($showloc,$value,$checkedtype); |
if ($current{'version'} eq $version) { |
if (ref($by_location{$locations[$i]}) eq 'ARRAY') { |
$selected = ' selected="selected"'; |
my $ip = $by_location{$locations[$i]}->[0]; |
} |
if (ref($by_ip{$ip}) eq 'ARRAY') { |
$selector .= ' <option value="'.$version.'"'. |
$value = join(':',@{$by_ip{$ip}}); |
$selected.'>'.$version.'</option>'; |
$showloc = join(', ',@{$by_ip{$ip}}); |
} |
if (ref($current{$type}) eq 'ARRAY') { |
$selector .= '</select> '; |
foreach my $loc (@{$by_ip{$ip}}) { |
$datatable .= &mt('remote server must be version: [_1] or later',$selector); |
if (grep(/^\Q$loc\E$/,@{$current{$type}})) { |
} else { |
$checkedtype = ' checked="checked"'; |
$datatable.= '<div><input type="button" value="'.&mt('check all').'" '. |
last; |
'onclick="javascript:checkAll(document.display.'.$prefix.'_'.$type.')"'. |
|
' />'.(' 'x2). |
|
'<input type="button" value="'.&mt('uncheck all').'" '. |
|
'onclick="javascript:uncheckAll(document.display.'.$prefix.'_'.$type.')" />'. |
|
"\n". |
|
'</div><div><table>'; |
|
my $rem; |
|
for (my $i=0; $i<@locations; $i++) { |
|
my ($showloc,$value,$checkedtype); |
|
if (ref($by_location{$locations[$i]}) eq 'ARRAY') { |
|
my $ip = $by_location{$locations[$i]}->[0]; |
|
if (ref($by_ip{$ip}) eq 'ARRAY') { |
|
$value = join(':',@{$by_ip{$ip}}); |
|
$showloc = join(', ',@{$by_ip{$ip}}); |
|
if (ref($current{$type}) eq 'ARRAY') { |
|
foreach my $loc (@{$by_ip{$ip}}) { |
|
if (grep(/^\Q$loc\E$/,@{$current{$type}})) { |
|
$checkedtype = ' checked="checked"'; |
|
last; |
|
} |
|
} |
} |
} |
} |
} |
} |
} |
|
$rem = $i%($numinrow); |
|
if ($rem == 0) { |
|
if ($i > 0) { |
|
$datatable .= '</tr>'; |
|
} |
|
$datatable .= '<tr>'; |
|
} |
|
$datatable .= '<td class="LC_left_item">'. |
|
'<span class="LC_nobreak"><label>'. |
|
'<input type="checkbox" name="'.$prefix.'_'.$type. |
|
'" value="'.$value.'"'.$checkedtype.' />'.$showloc. |
|
'</label></span></td>'; |
} |
} |
} |
$rem = @locations%($numinrow); |
$rem = $i%($numinrow); |
my $colsleft = $numinrow - $rem; |
if ($rem == 0) { |
if ($colsleft > 1 ) { |
if ($i > 0) { |
$datatable .= '<td colspan="'.$colsleft.'" class="LC_left_item">'. |
$datatable .= '</tr>'; |
' </td>'; |
|
} elsif ($colsleft == 1) { |
|
$datatable .= '<td class="LC_left_item"> </td>'; |
} |
} |
$datatable .= '<tr>'; |
$datatable .= '</tr></table>'; |
} |
} |
$datatable .= '<td class="LC_left_item">'. |
$datatable .= '</td></tr>'; |
'<span class="LC_nobreak"><label>'. |
$itemcount ++; |
'<input type="checkbox" name="'.$prefix.'_'.$type. |
|
'" value="'.$value.'"'.$checkedtype.' />'.$showloc. |
|
'</label></span></td>'; |
|
} |
|
$rem = @locations%($numinrow); |
|
my $colsleft = $numinrow - $rem; |
|
if ($colsleft > 1 ) { |
|
$datatable .= '<td colspan="'.$colsleft.'" class="LC_left_item">'. |
|
' </td>'; |
|
} elsif ($colsleft == 1) { |
|
$datatable .= '<td class="LC_left_item"> </td>'; |
|
} |
} |
$datatable .= '</tr></table>'; |
|
} |
} |
$datatable .= '</td></tr>'; |
|
$itemcount ++; |
|
} |
} |
$$rowtotal += $itemcount; |
$$rowtotal += $itemcount; |
return $datatable; |
return $datatable; |
Line 2452 sub build_location_hashes {
|
Line 2482 sub build_location_hashes {
|
return; |
return; |
} |
} |
|
|
|
sub current_offloads_to { |
|
my ($dom,$settings,$servers) = @_; |
|
my (%spareid,%otherdomconfigs); |
|
if ((ref($settings) eq 'HASH') && (ref($servers) eq 'HASH')) { |
|
foreach my $lonhost (sort(keys(%{$servers}))) { |
|
my $gotspares; |
|
if (ref($settings->{'spares'}) eq 'HASH') { |
|
if (ref($settings->{'spares'}{$lonhost}) eq 'HASH') { |
|
$spareid{$lonhost}{'primary'} = $settings->{'spares'}{$lonhost}{'primary'}; |
|
$spareid{$lonhost}{'default'} = $settings->{'spares'}{$lonhost}{'default'}; |
|
$gotspares = 1; |
|
} |
|
} |
|
unless ($gotspares) { |
|
my $gotspares; |
|
my $serverhomeID = |
|
&Apache::lonnet::get_server_homeID($servers->{$lonhost}); |
|
my $serverhomedom = |
|
&Apache::lonnet::host_domain($serverhomeID); |
|
if ($serverhomedom ne $dom) { |
|
if (ref($otherdomconfigs{$serverhomedom} eq 'HASH')) { |
|
if (ref($otherdomconfigs{$serverhomedom}{'usersessions'}) eq 'HASH') { |
|
if (ref($otherdomconfigs{$serverhomedom}{'usersessions'}{'spares'}) eq 'HASH') { |
|
$spareid{$lonhost}{'primary'} = $otherdomconfigs{$serverhomedom}{'usersessions'}{'spares'}{'primary'}; |
|
$spareid{$lonhost}{'default'} = $otherdomconfigs{$serverhomedom}{'usersessions'}{'spares'}{'default'}; |
|
$gotspares = 1; |
|
} |
|
} |
|
} else { |
|
$otherdomconfigs{$serverhomedom} = |
|
&Apache::lonnet::get_dom('configuration',['usersessions'],$serverhomedom); |
|
if (ref($otherdomconfigs{$serverhomedom}) eq 'HASH') { |
|
if (ref($otherdomconfigs{$serverhomedom}{'usersessions'}) eq 'HASH') { |
|
if (ref($otherdomconfigs{$serverhomedom}{'usersessions'}{'spares'}) eq 'HASH') { |
|
if (ref($otherdomconfigs{$serverhomedom}{'usersessions'}{'spares'}{$lonhost}) eq 'HASH') { |
|
$spareid{$lonhost}{'primary'} = $otherdomconfigs{$serverhomedom}{'usersessions'}{'spares'}{'primary'}; |
|
$spareid{$lonhost}{'default'} = $otherdomconfigs{$serverhomedom}{'usersessions'}{'spares'}{'default'}; |
|
$gotspares = 1; |
|
} |
|
} |
|
} |
|
} |
|
} |
|
} |
|
} |
|
unless ($gotspares) { |
|
if ($lonhost eq $Apache::lonnet::perlvar{'lonHostID'}) { |
|
$spareid{$lonhost}{'primary'} = $Apache::lonnet::spareid{'primary'}; |
|
$spareid{$lonhost}{'default'} = $Apache::lonnet::spareid{'default'}; |
|
} else { |
|
my $server_hostname = &Apache::lonnet::hostname($lonhost); |
|
my $server_homeID = &Apache::lonnet::get_server_homeID($server_hostname); |
|
if ($server_homeID eq $Apache::lonnet::perlvar{'lonHostID'}) { |
|
$spareid{$lonhost}{'primary'} = $Apache::lonnet::spareid{'primary'}; |
|
$spareid{$lonhost}{'default'} = $Apache::lonnet::spareid{'default'}; |
|
} else { |
|
my %requested; |
|
$requested{'spareid'} = 'HASH'; |
|
my %returnhash = &Apache::lonnet::get_remote_globals($lonhost,\%requested); |
|
my $spareshash = $returnhash{'spareid'}; |
|
if (ref($spareshash) eq 'HASH') { |
|
$spareid{$lonhost}{'primary'} = $spareshash->{'primary'}; |
|
$spareid{$lonhost}{'default'} = $spareshash->{'default'}; |
|
} |
|
} |
|
} |
|
} |
|
} |
|
} |
|
return %spareid; |
|
} |
|
|
|
sub spares_row { |
|
my ($servers,$spareid,$uniques,$rowtotal) = @_; |
|
my $css_class; |
|
my $numinrow = 4; |
|
my $itemcount = 1; |
|
my $datatable; |
|
if ((ref($servers) eq 'HASH') && (ref($spareid) eq 'HASH')) { |
|
foreach my $server (sort(keys(%{$servers}))) { |
|
$css_class = $itemcount%2 ? ' class="LC_odd_row"' : ''; |
|
$datatable .= '<tr'.$css_class.'> |
|
<td rowspan="2"> |
|
<span class="LC_nobreak"><b>'.$server.'</b> when busy, offloads to:</span></td>'; |
|
my (%current,%canselect); |
|
if (ref($spareid->{$server}) eq 'HASH') { |
|
foreach my $type ('primary','default') { |
|
if (ref($spareid->{$server}{$type}) eq 'ARRAY') { |
|
my @spares = @{$spareid->{$server}{$type}}; |
|
if (@spares > 0) { |
|
$current{$type} .= '<table>'; |
|
for (my $i=0; $i<@spares; $i++) { |
|
my $rem = $i%($numinrow); |
|
if ($rem == 0) { |
|
if ($i > 0) { |
|
$current{$type} .= '</tr>'; |
|
} |
|
$current{$type} .= '<tr>'; |
|
} |
|
$current{$type} .= '<td><label><input type="checkbox" name="spare_'.$type.'_'.$server.'" checked="checked" value="'.$spareid->{$server}{$type}[$i].'" /> '. |
|
$spareid->{$server}{$type}[$i]. |
|
'</label></td>'; |
|
} |
|
$current{$type} .= '</tr></table>'; |
|
} |
|
} |
|
if ($current{$type} eq '') { |
|
$current{$type} = &mt('None specified'); |
|
} |
|
$canselect{$type} = |
|
&newspare_select($server,$type,$spareid->{$server}{$type},$uniques); |
|
} |
|
} |
|
$datatable .= '<td><i>'.&mt('primary').'</i><td>'.$current{'primary'}.'</td>'. |
|
'<td>'.&mt('Add new [_1]primary[_2]:','<i>','</i>').' '. |
|
$canselect{'primary'}.'</td></tr>'. |
|
'<tr'.$css_class.'>'. |
|
'<td><i>'.&mt('default').'</i></td>'. |
|
'<td>'.$current{'default'}.'</td>'. |
|
'<td>'.&mt('Add new [_1]default[_2]:','<i>','</i>').' '. |
|
$canselect{'default'}.'</td></tr>'; |
|
$itemcount ++; |
|
} |
|
} |
|
$$rowtotal += $itemcount; |
|
return $datatable; |
|
} |
|
|
|
sub newspare_select { |
|
my ($server,$type,$currspares,$uniques) = @_; |
|
my $output; |
|
if (ref($uniques) eq 'HASH') { |
|
if (keys(%{$uniques}) > 1) { |
|
$output = '<select name="newspare_'.$type.'_'.$server.'">'."\n". |
|
'<option value="" selected ="selected">'.&mt('Select').'</option>'."\n"; |
|
foreach my $lonhost (sort(keys(%{$uniques}))) { |
|
next if ($lonhost eq $server); |
|
if (ref($currspares) eq 'ARRAY') { |
|
if (@{$currspares} > 0) { |
|
next if (grep(/^\Q$lonhost\E$/,@{$currspares})); |
|
} |
|
} |
|
$output .= '<option value="'.$lonhost.'">'.$lonhost.'</option>'."\n"; |
|
} |
|
$output .= '<select>'; |
|
} |
|
} |
|
return $output; |
|
} |
|
|
sub contact_titles { |
sub contact_titles { |
my %titles = &Apache::lonlocal::texthash ( |
my %titles = &Apache::lonlocal::texthash ( |
'supportemail' => 'Support E-mail address', |
'supportemail' => 'Support E-mail address', |
Line 6766 sub modify_coursedefaults {
|
Line 6946 sub modify_coursedefaults {
|
|
|
sub modify_usersessions { |
sub modify_usersessions { |
my ($dom,%domconfig) = @_; |
my ($dom,%domconfig) = @_; |
my @types = ('version','excludedomain','includedomain'); |
my @hostingtypes = ('version','excludedomain','includedomain'); |
my @prefixes = ('remote','hosted'); |
my @offloadtypes = ('primary','default'); |
|
my %types = ( |
|
remote => \@hostingtypes, |
|
hosted => \@hostingtypes, |
|
spares => \@offloadtypes, |
|
); |
|
my @prefixes = ('remote','hosted','spares'); |
my @lcversions = &Apache::lonnet::all_loncaparevs(); |
my @lcversions = &Apache::lonnet::all_loncaparevs(); |
my (%by_ip,%by_location,@intdoms); |
my (%by_ip,%by_location,@intdoms); |
&build_location_hashes(\@intdoms,\%by_ip,\%by_location); |
&build_location_hashes(\@intdoms,\%by_ip,\%by_location); |
Line 6780 sub modify_usersessions {
|
Line 6966 sub modify_usersessions {
|
my $resulttext; |
my $resulttext; |
my %iphost = &Apache::lonnet::get_iphost(); |
my %iphost = &Apache::lonnet::get_iphost(); |
foreach my $prefix (@prefixes) { |
foreach my $prefix (@prefixes) { |
foreach my $type (@types) { |
next if ($prefix eq 'spares'); |
|
foreach my $type (@{$types{$prefix}}) { |
my $inuse = $env{'form.'.$prefix.'_'.$type.'_inuse'}; |
my $inuse = $env{'form.'.$prefix.'_'.$type.'_inuse'}; |
if ($type eq 'version') { |
if ($type eq 'version') { |
my $value = $env{'form.'.$prefix.'_'.$type}; |
my $value = $env{'form.'.$prefix.'_'.$type}; |
Line 6872 sub modify_usersessions {
|
Line 7059 sub modify_usersessions {
|
} |
} |
} |
} |
} |
} |
|
|
|
my @alldoms = &Apache::lonnet::all_domains(); |
|
my %uniques = &Apache::lonnet::get_unique_servers(\@alldoms); |
|
my %servers = &dom_servers($dom); |
|
my %spareid = ¤t_offloads_to($dom,$domconfig{'usersessions'},\%servers); |
|
my $savespares; |
|
|
|
foreach my $lonhost (sort(keys(%servers))) { |
|
my $serverhomeID = |
|
&Apache::lonnet::get_server_homeID($servers{$lonhost}); |
|
$defaultshash{'usersessions'}{'spares'}{$lonhost} = {}; |
|
my %spareschg; |
|
foreach my $type (@{$types{'spares'}}) { |
|
my @okspares; |
|
my @checked = &Apache::loncommon::get_env_multiple('form.spare_'.$type.'_'.$lonhost); |
|
foreach my $server (@checked) { |
|
unless (($server eq $lonhost) || ($server eq $serverhomeID)) { |
|
if ($uniques{$server}) { |
|
push(@okspares,$server); |
|
} |
|
} |
|
} |
|
my $new = $env{'form.newspare_'.$type.'_'.$lonhost}; |
|
my $newspare; |
|
if (($new ne '') && ($uniques{$new})) { |
|
unless (($new eq $lonhost) || ($new eq $serverhomeID)) { |
|
$newspare = $new; |
|
$spareschg{$type} = 1; |
|
} |
|
} |
|
if (ref($spareid{$lonhost}) eq 'HASH') { |
|
if (ref($spareid{$lonhost}{$type}) eq 'ARRAY') { |
|
my @diffs = &Apache::loncommon::compare_arrays($domconfig{'usersessions'}{'spares'}{$lonhost}{$type},\@okspares); |
|
if (@diffs > 0) { |
|
$spareschg{$type} = 1; |
|
} elsif ($new ne '') { |
|
$spareschg{$type} = 1; |
|
} |
|
} |
|
} |
|
my @spares = sort(@okspares,$newspare); |
|
$defaultshash{'usersessions'}{'spares'}{$lonhost}{$type} = \@spares; |
|
} |
|
if (keys(%spareschg) > 0) { |
|
$changes{'spares'}{$lonhost} = \%spareschg; |
|
} |
|
} |
|
|
|
if (ref($domconfig{'usersessions'}) eq 'HASH') { |
|
if (ref($domconfig{'usersessions'}{'spares'}) eq 'HASH') { |
|
if (ref($changes{'spares'}) eq 'HASH') { |
|
if (keys(%{$changes{'spares'}}) > 0) { |
|
$savespares = 1; |
|
} |
|
} |
|
} else { |
|
$savespares = 1; |
|
} |
|
} |
|
|
if (keys(%changes) > 0) { |
if (keys(%changes) > 0) { |
my $putresult = &Apache::lonnet::put_dom('configuration',\%defaultshash, |
my $putresult = &Apache::lonnet::put_dom('configuration',\%defaultshash, |
$dom); |
$dom); |
Line 6891 sub modify_usersessions {
|
Line 7138 sub modify_usersessions {
|
foreach my $prefix (@prefixes) { |
foreach my $prefix (@prefixes) { |
if (ref($changes{$prefix}) eq 'HASH') { |
if (ref($changes{$prefix}) eq 'HASH') { |
$resulttext .= '<li>'.$lt{$prefix}.'<ul>'; |
$resulttext .= '<li>'.$lt{$prefix}.'<ul>'; |
foreach my $type (@types) { |
if ($prefix eq 'spares') { |
if (defined($changes{$prefix}{$type})) { |
if (ref($changes{$prefix}) eq 'HASH') { |
my $newvalue; |
foreach my $lonhost (sort(keys(%{$changes{$prefix}}))) { |
if (ref($defaultshash{'usersessions'}) eq 'HASH') { |
$resulttext .= '<li><b>'.$lonhost.'</b> '; |
if (ref($defaultshash{'usersessions'}{$prefix})) { |
if (ref($changes{$prefix}{$lonhost}) eq 'HASH') { |
if ($type eq 'version') { |
foreach my $type (@{$types{$prefix}}) { |
$newvalue = $defaultshash{'usersessions'}{$prefix}{$type}; |
if ($changes{$prefix}{$lonhost}{$type}) { |
} elsif (ref($defaultshash{'usersessions'}{$prefix}{$type}) eq 'ARRAY') { |
my $offloadto = &mt('None'); |
if (@{$defaultshash{'usersessions'}{$prefix}{$type}} > 0) { |
if (ref($defaultshash{'usersessions'}{'spares'}{$lonhost}{$type}) eq 'ARRAY') { |
$newvalue = join(', ',@{$defaultshash{'usersessions'}{$prefix}{$type}}); |
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 .= '</li>'; |
} |
} |
if ($newvalue eq '') { |
} |
if ($type eq 'version') { |
} else { |
$resulttext .= '<li>'.&mt('[_1] set to: off',$lt{$type}).'</li>'; |
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>'; |
|
} else { |
|
$resulttext .= '<li>'.&mt('[_1] set to: none',$lt{$type}).'</li>'; |
|
} |
} else { |
} else { |
$resulttext .= '<li>'.&mt('[_1] set to: none',$lt{$type}).'</li>'; |
if ($type eq 'version') { |
|
$newvalue .= ' '.&mt('(or later)'); |
|
} |
|
$resulttext .= '<li>'.&mt('[_1] set to: [_2].',$lt{$type},$newvalue).'</li>'; |
} |
} |
} else { |
|
if ($type eq 'version') { |
|
$newvalue .= ' '.&mt('(or later)'); |
|
} |
|
$resulttext .= '<li>'.&mt('[_1] set to: [_2].',$lt{$type},$newvalue).'</li>'; |
|
} |
} |
} |
} |
} |
} |
Line 6928 sub modify_usersessions {
|
Line 7197 sub modify_usersessions {
|
&mt('An error occurred: [_1]',$putresult).'</span>'; |
&mt('An error occurred: [_1]',$putresult).'</span>'; |
} |
} |
} else { |
} else { |
$resulttext = &mt('No changes made to settings for user session hosting.'); |
$resulttext = &mt('No changes made to settings for user session hosting/offloading.'); |
} |
} |
return $resulttext; |
return $resulttext; |
} |
} |
Line 7081 sub usersession_titles {
|
Line 7350 sub usersession_titles {
|
hosted => 'Hosting of sessions for users from other domains on servers in this domain', |
hosted => 'Hosting of sessions for users from other domains on servers in this domain', |
|
|
remote => 'Hosting of sessions for users in this domain on servers in other domains', |
remote => 'Hosting of sessions for users in this domain on servers in other domains', |
|
spares => 'Servers offloaded to, when busy', |
version => 'LON-CAPA version requirement', |
version => 'LON-CAPA version requirement', |
excludedomain => 'Allow all, but exclude specific domains', |
excludedomain => 'Allow all, but exclude specific domains', |
includedomain => 'Deny all, but include specific domains', |
includedomain => 'Deny all, but include specific domains', |
|
primary => 'Primary (checked first)', |
|
default => 'Default', |
); |
); |
} |
} |
|
|