version 1.136, 2010/06/21 06:23:24
|
version 1.137, 2010/07/17 20:02:07
|
Line 203 sub handler {
|
Line 203 sub handler {
|
'directorysrch','usercreation','usermodification', |
'directorysrch','usercreation','usermodification', |
'contacts','defaults','scantron','coursecategories', |
'contacts','defaults','scantron','coursecategories', |
'serverstatuses','requestcourses','helpsettings', |
'serverstatuses','requestcourses','helpsettings', |
'coursedefaults'],$dom); |
'coursedefaults','usersessions'],$dom); |
my @prefs_order = ('rolecolors','login','defaults','quotas','autoenroll', |
my @prefs_order = ('rolecolors','login','defaults','quotas','autoenroll', |
'autoupdate','autocreate','directorysrch','contacts', |
'autoupdate','autocreate','directorysrch','contacts', |
'usercreation','usermodification','scantron', |
'usercreation','usermodification','scantron', |
'requestcourses','coursecategories','serverstatuses','helpsettings', |
'requestcourses','coursecategories','serverstatuses','helpsettings', |
'coursedefaults'); |
'coursedefaults','usersessions'); |
my %prefs = ( |
my %prefs = ( |
'rolecolors' => |
'rolecolors' => |
{ text => 'Default color schemes', |
{ text => 'Default color schemes', |
Line 349 sub handler {
|
Line 349 sub handler {
|
header => [{col1 => 'Setting', |
header => [{col1 => 'Setting', |
col2 => 'Value',}], |
col2 => 'Value',}], |
}, |
}, |
|
'usersessions' => |
|
{text => 'User session hosting', |
|
help => 'Domain_Configuration_User_Sessions', |
|
header => [{col1 => 'Hosting of users from other domains', |
|
col2 => 'Rules'}, |
|
{col1 => "Hosting domain's own users elsewhere", |
|
col2 => 'Rules'}], |
|
}, |
); |
); |
my %servers = &dom_servers($dom); |
my %servers = &dom_servers($dom); |
if (keys(%servers) > 1) { |
if (keys(%servers) > 1) { |
Line 451 sub process_changes {
|
Line 459 sub process_changes {
|
$output = &modify_helpsettings($r,$dom,$confname,%domconfig); |
$output = &modify_helpsettings($r,$dom,$confname,%domconfig); |
} elsif ($action eq 'coursedefaults') { |
} elsif ($action eq 'coursedefaults') { |
$output = &modify_coursedefaults($dom,%domconfig); |
$output = &modify_coursedefaults($dom,%domconfig); |
|
} elsif ($action eq 'usersessions') { |
|
$output = &modify_usersessions($dom,%domconfig); |
} |
} |
return $output; |
return $output; |
} |
} |
Line 503 sub print_config_box {
|
Line 513 sub print_config_box {
|
$output .= &print_quotas($dom,$settings,\$rowtotal,$action); |
$output .= &print_quotas($dom,$settings,\$rowtotal,$action); |
} elsif ($action eq 'helpsettings') { |
} elsif ($action eq 'helpsettings') { |
$output .= &print_helpsettings('top',$dom,$confname,$settings,\$rowtotal); |
$output .= &print_helpsettings('top',$dom,$confname,$settings,\$rowtotal); |
|
} elsif ($action eq 'usersessions') { |
|
$output .= &print_usersessions('top',$dom,$settings,\$rowtotal); |
} elsif ($action eq 'rolecolors') { |
} elsif ($action eq 'rolecolors') { |
$output .= &print_rolecolors($phase,'student',$dom,$confname,$settings,\$rowtotal); |
$output .= &print_rolecolors($phase,'student',$dom,$confname,$settings,\$rowtotal); |
} |
} |
Line 566 sub print_config_box {
|
Line 578 sub print_config_box {
|
$output .= &print_courserequestmail($dom,$settings,\$rowtotal); |
$output .= &print_courserequestmail($dom,$settings,\$rowtotal); |
} 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') { |
|
$output .= &print_usersessions('bottom',$dom,$settings,\$rowtotal); |
} elsif ($action eq 'rolecolors') { |
} elsif ($action eq 'rolecolors') { |
$output .= &print_rolecolors($phase,'coordinator',$dom,$confname,$settings,\$rowtotal).' |
$output .= &print_rolecolors($phase,'coordinator',$dom,$confname,$settings,\$rowtotal).' |
</table> |
</table> |
Line 2242 sub print_coursedefaults {
|
Line 2256 sub print_coursedefaults {
|
return $datatable; |
return $datatable; |
} |
} |
|
|
|
sub print_usersessions { |
|
my ($position,$dom,$settings,$rowtotal) = @_; |
|
my ($css_class,$datatable,%checked,%choices); |
|
my %lt = &usersession_titles(); |
|
my $itemcount = 1; |
|
my $numinrow = 6; |
|
my $prefix; |
|
my @types; |
|
if ($position eq 'top') { |
|
$prefix = 'hosted'; |
|
@types = ('excludedomain','includedomain'); |
|
} else { |
|
$prefix = 'remote'; |
|
@types = ('version','excludedomain','includedomain'); |
|
} |
|
my (%current,%checkedon,%checkedoff); |
|
my @lcversions = &Apache::lonnet::all_loncaparevs(); |
|
my @alldoms = sort(&Apache::lonnet::all_domains()); |
|
foreach my $type (@types) { |
|
$checkedon{$type} = ''; |
|
$checkedoff{$type} = ' checked="checked"'; |
|
} |
|
if (ref($settings) eq 'HASH') { |
|
if (ref($settings->{$prefix}) eq 'HASH') { |
|
foreach my $key (keys(%{$settings->{$prefix}})) { |
|
$current{$key} = $settings->{$prefix}{$key}; |
|
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} = ''; |
|
} |
|
} |
|
} |
|
} |
|
foreach my $type (@types) { |
|
$css_class = $itemcount%2 ? ' class="LC_odd_row"' : ''; |
|
$datatable .= '<tr'.$css_class.'> |
|
<td><span class="LC_nobreak">'.$lt{$type}.'</span><br /> |
|
<span class="LC_nobreak"> |
|
<label><input type="radio" name="'.$prefix.'_'.$type.'_inuse" '.$checkedoff{$type}.' value="0" />'.&mt('Not in use').'</label> |
|
<label><input type="radio" name="'.$prefix.'_'.$type.'_inuse" '.$checkedon{$type}.' value="1" />'.&mt('In use').'</label></span></td><td>'; |
|
if ($type eq 'version') { |
|
my $selector = '<select name="'.$prefix.'_version">'; |
|
foreach my $version (@lcversions) { |
|
my $selected = ''; |
|
if ($current{'version'} eq $version) { |
|
$selected = ' selected="selected"'; |
|
} |
|
$selector .= ' <option value="'.$version.'"'. |
|
$selected.'>'.$version.'</option>'; |
|
} |
|
$selector .= '</select> '; |
|
$datatable .= &mt('remote server must be version: [_1] or later',$selector); |
|
} else { |
|
$datatable.= '<div><input type="button" value="'.&mt('check all').'" '. |
|
'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<@alldoms; $i++) { |
|
next if ($alldoms[$i] eq $dom); |
|
my $checkedtype; |
|
if (ref($current{$type}) eq 'ARRAY') { |
|
if (grep(/^\Q$alldoms[$i]\E$/,@{$current{$type}})) { |
|
$checkedtype = ' checked="checked"'; |
|
} |
|
} |
|
$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="'.$alldoms[$i].'"'.$checkedtype.' />'.$alldoms[$i]. |
|
'</label></span></td>'; |
|
} |
|
$rem = @alldoms%($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; |
|
return $datatable; |
|
} |
|
|
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 6519 sub modify_coursedefaults {
|
Line 6637 sub modify_coursedefaults {
|
return $resulttext; |
return $resulttext; |
} |
} |
|
|
|
sub modify_usersessions { |
|
my ($dom,%domconfig) = @_; |
|
my @types = ('version','excludedomain','includedomain'); |
|
my @prefixes = ('remote','hosted'); |
|
my @lcversions = &Apache::lonnet::all_loncaparevs(); |
|
my (%defaultshash,%changes); |
|
foreach my $prefix (@prefixes) { |
|
$defaultshash{'usersessions'}{$prefix} = {}; |
|
} |
|
my %domdefaults = &Apache::lonnet::get_domain_defaults($dom); |
|
my $resulttext; |
|
foreach my $prefix (@prefixes) { |
|
foreach my $type (@types) { |
|
my $inuse = $env{'form.'.$prefix.'_'.$type.'_inuse'}; |
|
if ($type eq 'version') { |
|
my $value = $env{'form.'.$prefix.'_'.$type}; |
|
my $okvalue; |
|
if ($value ne '') { |
|
if (grep(/^\Q$value\E$/,@lcversions)) { |
|
$okvalue = $value; |
|
} |
|
} |
|
if (ref($domconfig{'usersessions'}) eq 'HASH') { |
|
if (ref($domconfig{'usersessions'}{$prefix}) eq 'HASH') { |
|
if ($domconfig{'usersessions'}{$prefix}{$type} ne '') { |
|
if ($inuse == 0) { |
|
$changes{$prefix}{$type} = 1; |
|
} else { |
|
if ($okvalue ne $domconfig{'usersessions'}{$prefix}{$type}) { |
|
$changes{$prefix}{$type} = 1; |
|
} |
|
if ($okvalue ne '') { |
|
$defaultshash{'usersessions'}{$prefix}{$type} = $okvalue; |
|
} |
|
} |
|
} else { |
|
if (($inuse == 1) && ($okvalue ne '')) { |
|
$defaultshash{'usersessions'}{$prefix}{$type} = $okvalue; |
|
$changes{$prefix}{$type} = 1; |
|
} |
|
} |
|
} else { |
|
if (($inuse == 1) && ($okvalue ne '')) { |
|
$defaultshash{'usersessions'}{$prefix}{$type} = $okvalue; |
|
$changes{$prefix}{$type} = 1; |
|
} |
|
} |
|
} else { |
|
if (($inuse == 1) && ($okvalue ne '')) { |
|
$defaultshash{'usersessions'}{$prefix}{$type} = $okvalue; |
|
$changes{$prefix}{$type} = 1; |
|
} |
|
} |
|
} else { |
|
my @vals = &Apache::loncommon::get_env_multiple('form.'.$prefix.'_'.$type); |
|
my @okvals; |
|
foreach my $val (@vals) { |
|
if (&Apache::lonnet::domain($val) ne '') { |
|
push(@okvals,$val); |
|
} |
|
} |
|
@okvals = sort(@okvals); |
|
if (ref($domconfig{'usersessions'}) eq 'HASH') { |
|
if (ref($domconfig{'usersessions'}{$prefix}) eq 'HASH') { |
|
if (ref($domconfig{'usersessions'}{$prefix}{$type}) eq 'ARRAY') { |
|
if ($inuse == 0) { |
|
$changes{$prefix}{$type} = 1; |
|
} else { |
|
$defaultshash{'usersessions'}{$prefix}{$type} = \@okvals; |
|
my @changed = &Apache::loncommon::compare_arrays($domconfig{'usersessions'}{$prefix}{$type},$defaultshash{'usersessions'}{$prefix}{$type}); |
|
if (@changed > 0) { |
|
$changes{$prefix}{$type} = 1; |
|
} |
|
} |
|
} else { |
|
if ($inuse == 1) { |
|
$defaultshash{'usersessions'}{$prefix}{$type} = \@okvals; |
|
$changes{$prefix}{$type} = 1; |
|
} |
|
} |
|
} else { |
|
if ($inuse == 1) { |
|
$defaultshash{'usersessions'}{$prefix}{$type} = \@okvals; |
|
$changes{$prefix}{$type} = 1; |
|
} |
|
} |
|
} else { |
|
if ($inuse == 1) { |
|
$defaultshash{'usersessions'}{$prefix}{$type} = \@okvals; |
|
$changes{$prefix}{$type} = 1; |
|
} |
|
} |
|
} |
|
} |
|
} |
|
if (keys(%changes) > 0) { |
|
my $putresult = &Apache::lonnet::put_dom('configuration',\%defaultshash, |
|
$dom); |
|
if ($putresult eq 'ok') { |
|
if (ref($defaultshash{'usersessions'}) eq 'HASH') { |
|
if (ref($defaultshash{'usersessions'}{'remote'}) eq 'HASH') { |
|
$domdefaults{'remotesessions'} = $defaultshash{'usersessions'}{'remote'}; |
|
} |
|
if (ref($defaultshash{'usersessions'}{'hosted'}) eq 'HASH') { |
|
$domdefaults{'hostedsessions'} = $defaultshash{'usersessions'}{'hosted'}; |
|
} |
|
} |
|
my $cachetime = 24*60*60; |
|
&Apache::lonnet::do_cache_new('domdefaults',$dom,\%domdefaults,$cachetime); |
|
my %lt = &usersession_titles(); |
|
$resulttext = &mt('Changes made:').'<ul>'; |
|
foreach my $prefix (@prefixes) { |
|
if (ref($changes{$prefix}) eq 'HASH') { |
|
$resulttext .= '<li>'.$lt{$prefix}.'<ul>'; |
|
foreach my $type (@types) { |
|
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 { |
|
if ($type eq 'version') { |
|
$newvalue .= ' '.&mt('(or later)'); |
|
} |
|
$resulttext .= '<li>'.&mt('[_1] set to: [_2].',$lt{$type},$newvalue).'</li>'; |
|
} |
|
} |
|
} |
|
$resulttext .= '</ul>'; |
|
} |
|
} |
|
$resulttext .= '</ul>'; |
|
} else { |
|
$resulttext = '<span class="LC_error">'. |
|
&mt('An error occurred: [_1]',$putresult).'</span>'; |
|
} |
|
} else { |
|
$resulttext = &mt('No changes made to settings for user session hosting.'); |
|
} |
|
return $resulttext; |
|
} |
|
|
sub recurse_check { |
sub recurse_check { |
my ($chkcats,$categories,$depth,$name) = @_; |
my ($chkcats,$categories,$depth,$name) = @_; |
if (ref($chkcats->[$depth]{$name}) eq 'ARRAY') { |
if (ref($chkcats->[$depth]{$name}) eq 'ARRAY') { |
Line 6662 sub active_dc_picker {
|
Line 6936 sub active_dc_picker {
|
return ($numdcs,$datatable); |
return ($numdcs,$datatable); |
} |
} |
|
|
|
sub usersession_titles { |
|
return &Apache::lonlocal::texthash( |
|
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', |
|
version => 'LON-CAPA version requirement', |
|
excludedomain => 'Specific domains excluded', |
|
includedomain => 'Specific domains included', |
|
); |
|
} |
|
|
1; |
1; |