'.
@@ -3294,6 +3340,9 @@ sub ltitools_names {
'width' => 'Width',
'passback' => 'Tool can return grades:',
'roster' => 'Tool can retrieve roster:',
+ 'crstarget' => 'Display target',
+ 'crslabel' => 'Course label',
+ 'crstitle' => 'Course title',
);
return %lt;
}
@@ -3761,8 +3810,8 @@ sub print_validation_rows {
sub print_usersessions {
my ($position,$dom,$settings,$rowtotal) = @_;
my ($css_class,$datatable,%checked,%choices);
- my (%by_ip,%by_location,@intdoms);
- &build_location_hashes(\@intdoms,\%by_ip,\%by_location);
+ my (%by_ip,%by_location,@intdoms,@instdoms);
+ &build_location_hashes(\@intdoms,\%by_ip,\%by_location,\@instdoms);
my @alldoms = &Apache::lonnet::all_domains();
my %serverhomes = %Apache::lonnet::serverhomeIDs;
@@ -3900,10 +3949,178 @@ sub print_usersessions {
return $datatable;
}
+sub print_ssl {
+ my ($position,$dom,$settings,$rowtotal) = @_;
+ my ($css_class,$datatable);
+ my $lonhost = '';
+ my $itemcount = 1;
+ if ($position eq 'top') {
+ my %domservers = &Apache::lonnet::get_servers($dom);
+ $css_class = $itemcount%2?' class="LC_odd_row"':'';
+ $datatable .= ''.
+ &LONCAPA::SSL::print_certstatus(\%domservers,'web','domprefs').
+ ' | ';
+ $itemcount ++;
+ } else {
+ my %titles = &ssl_titles();
+ my (%by_ip,%by_location,@intdoms,@instdoms);
+ &build_location_hashes(\@intdoms,\%by_ip,\%by_location,\@instdoms);
+ my @alldoms = &Apache::lonnet::all_domains();
+ my %serverhomes = %Apache::lonnet::serverhomeIDs;
+ my @domservers = &Apache::lonnet::get_servers($dom);
+ my %servers = &Apache::lonnet::internet_dom_servers($dom);
+ my %altids = &id_for_thisdom(%servers);
+ if ($position eq 'middle') {
+ foreach my $type ('dom','intdom','other') {
+ my %checked;
+ $css_class = $itemcount%2?' class="LC_odd_row"':'';
+ $datatable .= ''.$titles{$type}.' | '.
+ '';
+ my $skip;
+ if ($type eq 'dom') {
+ unless (keys(%servers) > 1) {
+ $datatable .= &mt('Nothing to set here, as there are no other servers/VMs');
+ $skip = 1;
+ }
+ }
+ if ($type eq 'intdom') {
+ unless (@instdoms > 1) {
+ $datatable .= &mt('Nothing to set here, as there are no other domains for this institution');
+ $skip = 1;
+ }
+ } elsif ($type eq 'other') {
+ if (keys(%by_location) == 0) {
+ $datatable .= &mt('Nothing to set here, as there are no other institutions');
+ $skip = 1;
+ }
+ }
+ unless ($skip) {
+ $checked{'yes'} = ' checked="checked"';
+ if (ref($settings) eq 'HASH') {
+ if (ref($settings->{'connect'}) eq 'HASH') {
+ if ($settings->{'connect'}->{$type} =~ /^(no|req)$/) {
+ $checked{$1} = $checked{'yes'};
+ delete($checked{'yes'});
+ }
+ }
+ }
+ foreach my $option ('no','yes','req') {
+ $datatable .= ''.(' 'x2);
+ }
+ }
+ $datatable .= ' | ';
+ $itemcount ++;
+ }
+ } else {
+ my $numinrow = 5;
+ my $prefix = 'replication';
+ my @types = ('certreq','nocertreq');
+ my (%current,%checkedon,%checkedoff);
+ my @locations = sort(keys(%by_location));
+ 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 (ref($current{$key}) eq 'ARRAY') {
+ $checkedon{$key} = ' checked="checked"';
+ $checkedoff{$key} = '';
+ }
+ }
+ }
+ }
+ if (@locations > 0) {
+ foreach my $type (@types) {
+ $css_class = $itemcount%2?' class="LC_odd_row"':'';
+ $datatable .= '
+ '.$titles{$type}.'
+
+
+ |
+ '.(' 'x2)."\n".
+ ''.
+ "\n".
+ ' | ';
+ $itemcount ++;
+ }
+ } else {
+ $datatable .= ''.&mt('Nothing to set here, as there are no other institutions').' | ';
+ $itemcount ++;
+ }
+ }
+ }
+ $$rowtotal += $itemcount;
+ return $datatable;
+}
+
+sub ssl_titles {
+ return &Apache::lonlocal::texthash (
+ dom => 'LON-CAPA servers/VMs from same domain',
+ intdom => 'LON-CAPA servers/VMs from same "internet" domain',
+ other => 'External LON-CAPA servers/VMs',
+ connect => 'Connections to other servers',
+ replication => 'Replicating content to other institutions',
+ certreq => 'Client certificate required, but specific domains exempt',
+ nocertreq => 'No client certificate required, except for specific domains',
+ no => 'SSL not used',
+ yes => 'SSL Optional (used if available)',
+ req => 'SSL Required',
+ );
+}
+
sub build_location_hashes {
- my ($intdoms,$by_ip,$by_location) = @_;
+ my ($intdoms,$by_ip,$by_location,$instdoms) = @_;
return unless((ref($intdoms) eq 'ARRAY') && (ref($by_ip) eq 'HASH') &&
- (ref($by_location) eq 'HASH'));
+ (ref($by_location) eq 'HASH') && (ref($instdoms) eq 'ARRAY'));
my %iphost = &Apache::lonnet::get_iphost();
my $primary_id = &Apache::lonnet::domain($env{'request.role.domain'},'primary');
my $primary_ip = &Apache::lonnet::get_host_ip($primary_id);
@@ -3920,7 +4137,13 @@ sub build_location_hashes {
foreach my $id (@{$iphost{$ip}}) {
my $location = &Apache::lonnet::internet_dom($id);
if ($location) {
- next if (grep(/^\Q$location\E$/,@{$intdoms}));
+ if (grep(/^\Q$location\E$/,@{$intdoms})) {
+ my $dom = &Apache::lonnet::host_domain($id);
+ unless (grep(/^\Q$dom\E/,@{$instdoms})) {
+ push(@{$instdoms},$dom);
+ }
+ next;
+ }
if (ref($by_ip->{$ip}) eq 'ARRAY') {
unless(grep(/^\Q$location\E$/,@{$by_ip->{$ip}})) {
push(@{$by_ip->{$ip}},$location);
@@ -5838,9 +6061,9 @@ sub print_serverstatuses {
sub serverstatus_pages {
return ('userstatus','lonstatus','loncron','server-status','codeversions',
- 'checksums','clusterstatus','metadata_keywords','metadata_harvest',
- 'takeoffline','takeonline','showenv','toggledebug','ping','domconf',
- 'uniquecodes','diskusage','coursecatalog');
+ 'checksums','clusterstatus','certstatus','metadata_keywords',
+ 'metadata_harvest','takeoffline','takeonline','showenv','toggledebug',
+ 'ping','domconf','uniquecodes','diskusage','coursecatalog');
}
sub defaults_javascript {
@@ -8435,6 +8658,10 @@ sub modify_ltitools {
}
}
}
+ my @courseconfig = &Apache::loncommon::get_env_multiple('form.ltitools_courseconfig');
+ foreach my $item (@courseconfig) {
+ $confhash{$newid}{'crsconf'}{$item} = 1;
+ }
if ($env{'form.ltitools_add_custom'}) {
my $name = $env{'form.ltitools_add_custom_name'};
my $value = $env{'form.ltitools_add_custom_value'};
@@ -8522,6 +8749,19 @@ sub modify_ltitools {
$changes{$itemid} = 1;
}
}
+ my @courseconfig = &Apache::loncommon::get_env_multiple('form.ltitools_courseconfig_'.$i);
+ foreach my $item ('label','title','target') {
+ if (grep(/^\Q$item\E$/,@courseconfig)) {
+ $confhash{$itemid}{'crsconf'}{$item} = 1;
+ if (ref($domconfig{$action}{$itemid}{'crsconf'}) eq 'HASH') {
+ if ($domconfig{$action}{$itemid}{'crsconf'}{$item} ne $confhash{$itemid}{'crsconf'}{$item}) {
+ $changes{$itemid} = 1;
+ }
+ } else {
+ $changes{$itemid} = 1;
+ }
+ }
+ }
my @fields = &Apache::loncommon::get_env_multiple('form.ltitools_fields_'.$i);
foreach my $field (@fields) {
if ($possfield{$field}) {
@@ -8685,6 +8925,21 @@ sub modify_ltitools {
my $num = length($confhash{$itemid}{'secret'});
$resulttext .= ('*'x$num).'';
}
+ $resulttext .= ''.&mt('Configurable in course:');
+ my @possconfig = ('label','title','target');
+ my $numconfig = 0;
+ if (ref($confhash{$itemid}{'crsconf'}) eq 'HASH') {
+ foreach my $item (@possconfig) {
+ if ($confhash{$itemid}{'crsconf'}{$item}) {
+ $numconfig ++;
+ $resulttext .= ' '.$lt{'crs'.$item};
+ }
+ }
+ }
+ if (!$numconfig) {
+ $resulttext .= &mt('None');
+ }
+ $resulttext .= '';
foreach my $item ('passback','roster') {
$resulttext .= ''.$lt{$item}.' ';
if ($confhash{$itemid}{$item}) {
@@ -8852,7 +9107,8 @@ sub modify_autoenroll {
my $autorun = &Apache::lonnet::auto_run(undef,$dom),
my %title = ( run => 'Auto-enrollment active',
sender => 'Sender for notification messages',
- coowners => 'Automatic assignment of co-ownership to instructors of record (institutional data)');
+ coowners => 'Automatic assignment of co-ownership to instructors of record (institutional data)',
+ failsafe => 'Failsafe for no drops if institutional data missing for a section');
my @offon = ('off','on');
my $sender_uname = $env{'form.sender_uname'};
my $sender_domain = $env{'form.sender_domain'};
@@ -8862,11 +9118,17 @@ sub modify_autoenroll {
$sender_domain = '';
}
my $coowners = $env{'form.autoassign_coowners'};
+ my $failsafe = $env{'form.autoenroll_failsafe'};
+ $failsafe =~ s{^\s+|\s+$}{}g;
+ if ($failsafe =~ /\D/) {
+ undef($failsafe);
+ }
my %autoenrollhash = (
autoenroll => { 'run' => $env{'form.autoenroll_run'},
'sender_uname' => $sender_uname,
'sender_domain' => $sender_domain,
'co-owners' => $coowners,
+ 'autofailsafe' => $failsafe,
}
);
my $putresult = &Apache::lonnet::put_dom('configuration',\%autoenrollhash,
@@ -8893,7 +9155,10 @@ sub modify_autoenroll {
}
} elsif ($coowners) {
$changes{'coowners'} = 1;
- }
+ }
+ if ($currautoenroll{'autofailsafe'} ne $failsafe) {
+ $changes{'autofailsafe'} = 1;
+ }
if (keys(%changes) > 0) {
$resulttext = &mt('Changes made:').'';
if ($changes{'run'}) {
@@ -8913,6 +9178,17 @@ sub modify_autoenroll {
$lastactref->{'domainconfig'} = 1;
}
}
+ if ($changes{'autofailsafe'}) {
+ if ($failsafe ne '') {
+ $resulttext .= '- '.&mt("$title{'failsafe'} set to [_1]",$failsafe).'
';
+ } else {
+ $resulttext .= '- '.&mt("$title{'failsafe'} deleted");
+ }
+ &Apache::lonnet::get_domain_defaults($dom,1);
+ if (ref($lastactref) eq 'HASH') {
+ $lastactref->{'domdefaults'} = 1;
+ }
+ }
$resulttext .= '
';
} else {
$resulttext = &mt('No changes made to auto-enrollment settings');
@@ -11953,8 +12229,8 @@ sub modify_usersessions {
);
my @prefixes = ('remote','hosted','spares');
my @lcversions = &Apache::lonnet::all_loncaparevs();
- my (%by_ip,%by_location,@intdoms);
- &build_location_hashes(\@intdoms,\%by_ip,\%by_location);
+ my (%by_ip,%by_location,@intdoms,@instdoms);
+ &build_location_hashes(\@intdoms,\%by_ip,\%by_location,\@instdoms);
my @locations = sort(keys(%by_location));
my (%defaultshash,%changes);
foreach my $prefix (@prefixes) {
@@ -12258,6 +12534,171 @@ sub modify_usersessions {
} else {
$resulttext = $nochgmsg;
}
+ } else {
+ $resulttext = ''.
+ &mt('An error occurred: [_1]',$putresult).'';
+ }
+ } else {
+ $resulttext = $nochgmsg;
+ }
+ return $resulttext;
+}
+
+sub modify_ssl {
+ my ($dom,$lastactref,%domconfig) = @_;
+ my (%by_ip,%by_location,@intdoms,@instdoms);
+ &build_location_hashes(\@intdoms,\%by_ip,\%by_location,\@instdoms);
+ my @locations = sort(keys(%by_location));
+ my %servers = &Apache::lonnet::internet_dom_servers($dom);
+ my (%defaultshash,%changes);
+ my $action = 'ssl';
+ my @prefixes = ('connect','replication');
+ foreach my $prefix (@prefixes) {
+ $defaultshash{$action}{$prefix} = {};
+ }
+ my %domdefaults = &Apache::lonnet::get_domain_defaults($dom,1);
+ my $resulttext;
+ my %iphost = &Apache::lonnet::get_iphost();
+ my @reptypes = ('certreq','nocertreq');
+ my @connecttypes = ('dom','intdom','other');
+ my %types = (
+ connect => \@connecttypes,
+ replication => \@reptypes,
+ );
+ my $action = 'ssl';
+ foreach my $prefix (sort(keys(%types))) {
+ foreach my $type (@{$types{$prefix}}) {
+ if ($prefix eq 'connect') {
+ my $value = 'yes';
+ if ($env{'form.'.$prefix.'_'.$type} =~ /^(no|req)$/) {
+ $value = $env{'form.'.$prefix.'_'.$type};
+ }
+ if (ref($domconfig{$action}{$prefix}) eq 'HASH') {
+ if ($domconfig{$action}{$prefix}{$type} ne '') {
+ if ($value ne $domconfig{$action}{$prefix}{$type}) {
+ $changes{$prefix}{$type} = 1;
+ }
+ $defaultshash{$action}{$prefix}{$type} = $value;
+ } else {
+ $defaultshash{$action}{$prefix}{$type} = $value;
+ $changes{$prefix}{$type} = 1;
+ }
+ } else {
+ $defaultshash{$action}{$prefix}{$type} = $value;
+ $changes{$prefix}{$type} = 1;
+ }
+ if (($type eq 'dom') && (keys(%servers) == 1)) {
+ delete($changes{$prefix}{$type});
+ } elsif (($type eq 'intdom') && (@instdoms == 1)) {
+ delete($changes{$prefix}{$type});
+ } elsif (($type eq 'other') && (keys(%by_location) == 0)) {
+ delete($changes{$prefix}{$type});
+ }
+ } elsif ($prefix eq 'replication') {
+ if (@locations > 0) {
+ my $inuse = $env{'form.'.$prefix.'_'.$type.'_inuse'};
+ my @vals = &Apache::loncommon::get_env_multiple('form.'.$prefix.'_'.$type);
+ my @okvals;
+ foreach my $val (@vals) {
+ if ($val =~ /:/) {
+ my @items = split(/:/,$val);
+ foreach my $item (@items) {
+ if (ref($by_location{$item}) eq 'ARRAY') {
+ push(@okvals,$item);
+ }
+ }
+ } else {
+ if (ref($by_location{$val}) eq 'ARRAY') {
+ push(@okvals,$val);
+ }
+ }
+ }
+ @okvals = sort(@okvals);
+ if (ref($domconfig{$action}) eq 'HASH') {
+ if (ref($domconfig{$action}{$prefix}) eq 'HASH') {
+ if (ref($domconfig{$action}{$prefix}{$type}) eq 'ARRAY') {
+ if ($inuse == 0) {
+ $changes{$prefix}{$type} = 1;
+ } else {
+ $defaultshash{$action}{$prefix}{$type} = \@okvals;
+ my @changed = &Apache::loncommon::compare_arrays($domconfig{$action}{$prefix}{$type},$defaultshash{$action}{$prefix}{$type});
+ if (@changed > 0) {
+ $changes{$prefix}{$type} = 1;
+ }
+ }
+ } else {
+ if ($inuse == 1) {
+ $defaultshash{$action}{$prefix}{$type} = \@okvals;
+ $changes{$prefix}{$type} = 1;
+ }
+ }
+ } else {
+ if ($inuse == 1) {
+ $defaultshash{$action}{$prefix}{$type} = \@okvals;
+ $changes{$prefix}{$type} = 1;
+ }
+ }
+ } else {
+ if ($inuse == 1) {
+ $defaultshash{$action}{$prefix}{$type} = \@okvals;
+ $changes{$prefix}{$type} = 1;
+ }
+ }
+ }
+ }
+ }
+ }
+ my $nochgmsg = &mt('No changes made to LON-CAPA SSL settings');
+ if (keys(%changes) > 0) {
+ my $putresult = &Apache::lonnet::put_dom('configuration',\%defaultshash,
+ $dom);
+ if ($putresult eq 'ok') {
+ if (ref($defaultshash{$action}) eq 'HASH') {
+ if (ref($defaultshash{$action}{'replication'}) eq 'HASH') {
+ $domdefaults{'replication'} = $defaultshash{$action}{'replication'};
+ }
+ if (ref($defaultshash{$action}{'connect'}) eq 'HASH') {
+ $domdefaults{'connect'} = $domconfig{$action}{'connect'};
+ }
+ }
+ my $cachetime = 24*60*60;
+ &Apache::lonnet::do_cache_new('domdefaults',$dom,\%domdefaults,$cachetime);
+ if (ref($lastactref) eq 'HASH') {
+ $lastactref->{'domdefaults'} = 1;
+ }
+ if (keys(%changes) > 0) {
+ my %titles = &ssl_titles();
+ $resulttext = &mt('Changes made:').'';
+ foreach my $prefix (@prefixes) {
+ if (ref($changes{$prefix}) eq 'HASH') {
+ $resulttext .= '- '.$titles{$prefix}.'
';
+ foreach my $type (@{$types{$prefix}}) {
+ if (defined($changes{$prefix}{$type})) {
+ my $newvalue;
+ if (ref($defaultshash{$action}) eq 'HASH') {
+ if (ref($defaultshash{$action}{$prefix})) {
+ if ($prefix eq 'connect') {
+ $newvalue = $titles{$defaultshash{$action}{$prefix}{$type}};
+ } elsif (ref($defaultshash{$action}{$prefix}{$type}) eq 'ARRAY') {
+ if (@{$defaultshash{$action}{$prefix}{$type}} > 0) {
+ $newvalue = join(', ',@{$defaultshash{$action}{$prefix}{$type}});
+ }
+ }
+ }
+ if ($newvalue eq '') {
+ $resulttext .= '- '.&mt('[_1] set to: none',$titles{$type}).'
';
+ } else {
+ $resulttext .= '- '.&mt('[_1] set to: [_2].',$titles{$type},$newvalue).'
';
+ }
+ }
+ }
+ }
+ $resulttext .= ' ';
+ }
+ }
+ } else {
+ $resulttext = $nochgmsg;
+ }
} else {
$resulttext = ''.
&mt('An error occurred: [_1]',$putresult).'';
|