--- loncom/interface/domainprefs.pm 2010/02/22 18:28:13 1.127
+++ loncom/interface/domainprefs.pm 2010/03/08 14:36:24 1.129
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Handler to set domain-wide configuration settings
#
-# $Id: domainprefs.pm,v 1.127 2010/02/22 18:28:13 raeburn Exp $
+# $Id: domainprefs.pm,v 1.129 2010/03/08 14:36:24 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -664,9 +664,12 @@ sub print_login {
my %servers = &dom_servers($dom);
my $choice = $choices{'disallowlogin'};
$css_class = ' class="LC_odd_row"';
- $datatable .= '
'.$choices{'disallowlogin'}.' | '.
+ $datatable .= '
'.$choice.' | '.
' |
';
return $datatable;
@@ -835,7 +867,10 @@ sub login_choices {
adminmail => "Display Administrator's E-mail Address?",
disallowlogin => "Login page requests redirected",
hostid => "Server",
- serverurl => "Redirect to log-in via:",
+ server => "Redirect to:",
+ serverpath => "Path",
+ custompath => "Custom",
+ exempt => "Exempt IP(s)",
directlogin => "No redirect",
newuser => "Link to create a user account",
img => "Header",
@@ -1657,7 +1692,7 @@ sub print_courserequestmail {
sub print_autoenroll {
my ($dom,$settings,$rowtotal) = @_;
my $autorun = &Apache::lonnet::auto_run(undef,$dom),
- my ($defdom,$runon,$runoff);
+ my ($defdom,$runon,$runoff,$coownerson,$coownersoff);
if (ref($settings) eq 'HASH') {
if (exists($settings->{'run'})) {
if ($settings->{'run'} eq '0') {
@@ -1676,6 +1711,18 @@ sub print_autoenroll {
$runon = ' ';
}
}
+ if (exists($settings->{'co-owners'})) {
+ if ($settings->{'co-owners'} eq '0') {
+ $coownersoff = ' checked="checked" ';
+ $coownerson = ' ';
+ } else {
+ $coownerson = ' checked="checked" ';
+ $coownersoff = ' ';
+ }
+ } else {
+ $coownersoff = ' checked="checked" ';
+ $coownerson = ' ';
+ }
if (exists($settings->{'sender_domain'})) {
$defdom = $settings->{'sender_domain'};
}
@@ -1706,8 +1753,16 @@ sub print_autoenroll {
&mt('username').': '.
' '.&mt('domain').
- ': '.$domform.'';
- $$rowtotal += 2;
+ ': '.$domform.''.
+ ''.
+ ''.&mt('Automatically assign co-ownership').' | '.
+ ' '.
+ ' | '.
+ '
';
+ $$rowtotal += 3;
return $datatable;
}
@@ -3506,19 +3561,86 @@ sub modify_login {
}
my %servers = &dom_servers($dom);
+ my @loginvia_attribs = ('serverpath','custompath','exempt');
if (keys(%servers) > 1) {
foreach my $lonhost (keys(%servers)) {
- next if ($env{'form.'.$lonhost.'_serverurl'} eq $lonhost);
- if ($env{'form.'.$lonhost.'_serverurl'} eq $curr_loginvia{$lonhost}) {
- $loginhash{login}{loginvia}{$lonhost} = $curr_loginvia{$lonhost}; next;
- }
- if ($curr_loginvia{$lonhost} ne '') {
- $loginhash{login}{loginvia}{$lonhost} = $env{'form.'.$lonhost.'_serverurl'};
- $changes{'loginvia'}{$lonhost} = 1;
+ next if ($env{'form.'.$lonhost.'_server'} eq $lonhost);
+ if (ref($curr_loginvia{$lonhost}) eq 'HASH') {
+ if ($env{'form.'.$lonhost.'_server'} eq $curr_loginvia{$lonhost}{'server'}) {
+ $loginhash{login}{loginvia}{$lonhost}{'server'} = $curr_loginvia{$lonhost}{'server'};
+ } elsif ($curr_loginvia{$lonhost}{'server'} ne '') {
+ if (defined($servers{$env{'form.'.$lonhost.'_server'}})) {
+ $loginhash{login}{loginvia}{$lonhost}{'server'} = $env{'form.'.$lonhost.'_server'};
+ $changes{'loginvia'}{$lonhost} = 1;
+ } else {
+ $loginhash{login}{loginvia}{$lonhost}{'server'} = '';
+ $changes{'loginvia'}{$lonhost} = 1;
+ }
+ } else {
+ if (defined($servers{$env{'form.'.$lonhost.'_server'}})) {
+ $loginhash{login}{loginvia}{$lonhost}{'server'} = $env{'form.'.$lonhost.'_server'};
+ $changes{'loginvia'}{$lonhost} = 1;
+ }
+ }
+ if ($loginhash{login}{loginvia}{$lonhost}{'server'} eq '') {
+ foreach my $item (@loginvia_attribs) {
+ $loginhash{login}{loginvia}{$lonhost}{$item} = '';
+ }
+ } else {
+ foreach my $item (@loginvia_attribs) {
+ my $new = $env{'form.'.$lonhost.'_'.$item};
+ if (($item eq 'serverpath') && ($new eq 'custom')) {
+ $env{'form.'.$lonhost.'_custompath'} =~ s/\s+//g;
+ if ($env{'form.'.$lonhost.'_custompath'} eq '') {
+ $new = '/';
+ }
+ }
+ if (($item eq 'custompath') &&
+ ($env{'form.'.$lonhost.'_serverpath'} ne 'custom')) {
+ $new = '';
+ }
+ if ($new ne $curr_loginvia{$lonhost}{$item}) {
+ $changes{'loginvia'}{$lonhost} = 1;
+ }
+ if ($item eq 'exempt') {
+ $new =~ s/^\s+//;
+ $new =~ s/\s+$//;
+ my @poss_ips = split(/\s*[,:]\s*/,$new);
+ my @okips;
+ foreach my $ip (@poss_ips) {
+ if ($ip =~ /^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/) {
+ if (($1 <= 255) && ($2 <= 255) && ($3 <= 255) && ($4 <= 255)) {
+ push(@okips,$ip);
+ }
+ }
+ }
+ if (@okips > 0) {
+ $new = join(',',@okips);
+ } else {
+ $new = '';
+ }
+ }
+
+ $loginhash{login}{loginvia}{$lonhost}{$item} = $new;
+ }
+ }
} else {
- if (defined($servers{$env{'form.'.$lonhost.'_serverurl'}})) {
- $loginhash{login}{loginvia}{$lonhost} = $env{'form.'.$lonhost.'_serverurl'};
+ if (defined($servers{$env{'form.'.$lonhost.'_server'}})) {
+ $loginhash{login}{loginvia}{$lonhost}{'server'} = $env{'form.'.$lonhost.'_server'};
$changes{'loginvia'}{$lonhost} = 1;
+ foreach my $item (@loginvia_attribs) {
+ my $new = $env{'form.'.$lonhost.'_'.$item};
+ if (($item eq 'serverpath') && ($new eq 'custom')) {
+ if ($env{'form.'.$lonhost.'_custompath'} eq '') {
+ $new = '/';
+ }
+ }
+ if (($item eq 'custompath') &&
+ ($env{'form.'.$lonhost.'_serverpath'} ne 'custom')) {
+ $new = '';
+ }
+ $loginhash{login}{loginvia}{$lonhost}{$item} = $new;
+ }
}
}
}
@@ -3574,13 +3696,30 @@ sub modify_login {
if (ref($changes{$item}) eq 'HASH') {
$resulttext .= ''.&mt('Log-in page availability:').'';
foreach my $lonhost (sort(keys(%{$changes{$item}}))) {
- if ($servers{$env{'form.'.$lonhost.'_serverurl'}} ne '') {
- $resulttext .= '- '.&mt('Server: [_1] log-in page now redirects to [_2]',$lonhost,$servers{$env{'form.'.$lonhost.'_serverurl'}}).'
';
+ if (defined($servers{$loginhash{login}{loginvia}{$lonhost}{'server'}})) {
+ if (ref($loginhash{login}{loginvia}{$lonhost}) eq 'HASH') {
+ my $protocol = $Apache::lonnet::protocol{$env{'form.'.$lonhost.'_server'}};
+ $protocol = 'http' if ($protocol ne 'https');
+ my $target = $protocol.'://'.$servers{$env{'form.'.$lonhost.'_server'}};
+
+ if ($loginhash{login}{loginvia}{$lonhost}{'serverpath'} eq 'custom') {
+ $target .= $loginhash{login}{loginvia}{$lonhost}{'custompath'};
+ } else {
+ $target .= $loginhash{login}{loginvia}{$lonhost}{'serverpath'};
+ }
+ $resulttext .= '- '.&mt('Server: [_1] log-in page redirects to [_2].',$servers{$lonhost},''.$target.'');
+ if ($loginhash{login}{loginvia}{$lonhost}{'exempt'} ne '') {
+ $resulttext .= ' '.&mt('No redirection for clients from following IPs:').' '.$loginhash{login}{loginvia}{$lonhost}{'exempt'};
+ }
+ $resulttext .= '
';
+ } else {
+ $resulttext .= '- '.&mt('Server: [_1] has standard log-in page.',$lonhost).'
';
+ }
} else {
- $resulttext .= '- '.&mt('Server: [_1] now has standard log-in page.',$lonhost).'
';
+ $resulttext .= '- '.&mt('Server: [_1] has standard log-in page.',$servers{$lonhost}).'
';
}
}
- $resulttext .= '
';
+ $resulttext .= '';
}
} else {
$resulttext .= ''.&mt("$title{$item} set to $offon[$env{'form.'.$item}]").'';
@@ -4516,7 +4655,8 @@ sub modify_autoenroll {
}
my $autorun = &Apache::lonnet::auto_run(undef,$dom),
my %title = ( run => 'Auto-enrollment active',
- sender => 'Sender for notification messages');
+ sender => 'Sender for notification messages',
+ coowners => 'Automatic assignment of co-ownership to instructors of record (institutional data)');
my @offon = ('off','on');
my $sender_uname = $env{'form.sender_uname'};
my $sender_domain = $env{'form.sender_domain'};
@@ -4525,11 +4665,12 @@ sub modify_autoenroll {
} elsif ($sender_uname eq '') {
$sender_domain = '';
}
+ my $coowners = $env{'form.autoassign_coowners'};
my %autoenrollhash = (
- autoenroll => { run => $env{'form.autoenroll_run'},
- sender_uname => $sender_uname,
- sender_domain => $sender_domain,
-
+ autoenroll => { 'run' => $env{'form.autoenroll_run'},
+ 'sender_uname' => $sender_uname,
+ 'sender_domain' => $sender_domain,
+ 'co-owners' => $coowners,
}
);
my $putresult = &Apache::lonnet::put_dom('configuration',\%autoenrollhash,
@@ -4550,6 +4691,13 @@ sub modify_autoenroll {
if ($currautoenroll{'sender_domain'} ne $sender_domain) {
$changes{'sender'} = 1;
}
+ if ($currautoenroll{'co-owners'} ne '') {
+ if ($currautoenroll{'co-owners'} ne $coowners) {
+ $changes{'coowners'} = 1;
+ }
+ } elsif ($coowners) {
+ $changes{'coowners'} = 1;
+ }
if (keys(%changes) > 0) {
$resulttext = &mt('Changes made:').'';
if ($changes{'run'}) {
@@ -4562,6 +4710,10 @@ sub modify_autoenroll {
$resulttext .= '- '.&mt("$title{'sender'} set to [_1]",$sender_uname.':'.$sender_domain).'
';
}
}
+ if ($changes{'coowners'}) {
+ $resulttext .= '- '.&mt("$title{'coowners'} set to $offon[$env{'form.autoassign_coowners'}]").'
';
+ &Apache::loncommon::devalidate_domconfig_cache($dom);
+ }
$resulttext .= '
';
} else {
$resulttext = &mt('No changes made to auto-enrollment settings');