version 1.102.2.9, 2010/02/22 18:39:13
|
version 1.102.2.10, 2010/03/10 17:26:05
|
Line 332 sub handler {
|
Line 332 sub handler {
|
col2 => 'Value',}], |
col2 => 'Value',}], |
}, |
}, |
); |
); |
|
my %servers = &dom_servers($dom); |
|
if (keys(%servers) > 1) { |
|
$prefs{'login'} = { text => 'Log-in page options', |
|
help => 'Domain_Configuration_Login_Page', |
|
header => [{col1 => 'Log-in Service', |
|
col2 => 'Server Setting',}, |
|
{col1 => 'Log-in Page Items', |
|
col2 => ''}], |
|
}; |
|
} |
my @roles = ('student','coordinator','author','admin'); |
my @roles = ('student','coordinator','author','admin'); |
my @actions = &Apache::loncommon::get_env_multiple('form.actions'); |
my @actions = &Apache::loncommon::get_env_multiple('form.actions'); |
&Apache::lonhtmlcommon::add_breadcrumb |
&Apache::lonhtmlcommon::add_breadcrumb |
Line 466 sub print_config_box {
|
Line 476 sub print_config_box {
|
$output .= &print_usermodification('top',$dom,$settings,\$rowtotal); |
$output .= &print_usermodification('top',$dom,$settings,\$rowtotal); |
} elsif ($action eq 'coursecategories') { |
} elsif ($action eq 'coursecategories') { |
$output .= &print_coursecategories('top',$dom,$item,$settings,\$rowtotal); |
$output .= &print_coursecategories('top',$dom,$item,$settings,\$rowtotal); |
|
} elsif ($action eq 'login') { |
|
$output .= &print_login('top',$dom,$confname,$phase,$settings,\$rowtotal); |
|
$colspan = ' colspan="2"'; |
} elsif ($action eq 'requestcourses') { |
} elsif ($action eq 'requestcourses') { |
$output .= &print_quotas($dom,$settings,\$rowtotal,$action); |
$output .= &print_quotas($dom,$settings,\$rowtotal,$action); |
} else { |
} else { |
Line 515 sub print_config_box {
|
Line 528 sub print_config_box {
|
$rowtotal ++; |
$rowtotal ++; |
} elsif ($action eq 'coursecategories') { |
} elsif ($action eq 'coursecategories') { |
$output .= &print_coursecategories('bottom',$dom,$item,$settings,\$rowtotal); |
$output .= &print_coursecategories('bottom',$dom,$item,$settings,\$rowtotal); |
|
} elsif ($action eq 'login') { |
|
$output .= &print_login('bottom',$dom,$confname,$phase,$settings,\$rowtotal); |
} elsif ($action eq 'requestcourses') { |
} elsif ($action eq 'requestcourses') { |
$output .= &print_courserequestmail($dom,$settings,\$rowtotal); |
$output .= &print_courserequestmail($dom,$settings,\$rowtotal); |
} else { |
} else { |
Line 585 sub print_config_box {
|
Line 600 sub print_config_box {
|
$output .= '</tr>'; |
$output .= '</tr>'; |
$rowtotal ++; |
$rowtotal ++; |
if ($action eq 'login') { |
if ($action eq 'login') { |
$output .= &print_login($dom,$confname,$phase,$settings,\$rowtotal); |
$output .= &print_login('bottom',$dom,$confname,$phase,$settings, |
|
\$rowtotal); |
} elsif ($action eq 'quotas') { |
} elsif ($action eq 'quotas') { |
$output .= &print_quotas($dom,$settings,\$rowtotal,$action); |
$output .= &print_quotas($dom,$settings,\$rowtotal,$action); |
} elsif ($action eq 'autoenroll') { |
} elsif ($action eq 'autoenroll') { |
Line 615 sub print_config_box {
|
Line 631 sub print_config_box {
|
} |
} |
|
|
sub print_login { |
sub print_login { |
my ($dom,$confname,$phase,$settings,$rowtotal) = @_; |
my ($position,$dom,$confname,$phase,$settings,$rowtotal) = @_; |
|
my ($css_class,$datatable); |
my %choices = &login_choices(); |
my %choices = &login_choices(); |
|
|
|
if ($position eq 'top') { |
|
my %servers = &dom_servers($dom); |
|
my $choice = $choices{'disallowlogin'}; |
|
$css_class = ' class="LC_odd_row"'; |
|
$datatable .= '<tr'.$css_class.'><td>'.$choice.'</td>'. |
|
'<td align="right"><table><tr><th>'.$choices{'hostid'}.'</th>'. |
|
'<th>'.$choices{'server'}.'</th>'. |
|
'<th>'.$choices{'serverpath'}.'</th>'. |
|
'<th>'.$choices{'custompath'}.'</th>'. |
|
'<th><span class="LC_nobreak">'.$choices{'exempt'}.'</span></th></tr>'."\n"; |
|
my %disallowed; |
|
if (ref($settings) eq 'HASH') { |
|
if (ref($settings->{'loginvia'}) eq 'HASH') { |
|
%disallowed = %{$settings->{'loginvia'}}; |
|
} |
|
} |
|
foreach my $lonhost (sort(keys(%servers))) { |
|
my $direct = 'selected="selected"'; |
|
if (ref($disallowed{$lonhost}) eq 'HASH') { |
|
if ($disallowed{$lonhost}{'server'} ne '') { |
|
$direct = ''; |
|
} |
|
} |
|
$datatable .= '<tr><td>'.$servers{$lonhost}.'</td>'. |
|
'<td><select name="'.$lonhost.'_server">'. |
|
'<option value=""'.$direct.'>'.$choices{'directlogin'}. |
|
'</option>'; |
|
foreach my $hostid (keys(%servers)) { |
|
next if ($servers{$hostid} eq $servers{$lonhost}); |
|
my $selected = ''; |
|
if (ref($disallowed{$lonhost}) eq 'HASH') { |
|
if ($hostid eq $disallowed{$lonhost}{'server'}) { |
|
$selected = 'selected="selected"'; |
|
} |
|
} |
|
$datatable .= '<option value="'.$hostid.'"'.$selected.'>'. |
|
$servers{$hostid}.'</option>'; |
|
} |
|
$datatable .= '</select></td>'. |
|
'<td><select name="'.$lonhost.'_serverpath">'; |
|
foreach my $path ('','/','/adm/login','/adm/roles','custom') { |
|
my $pathname = $path; |
|
if ($path eq 'custom') { |
|
$pathname = &mt('Custom Path').' ->'; |
|
} |
|
my $selected = ''; |
|
if (ref($disallowed{$lonhost}) eq 'HASH') { |
|
if ($path eq $disallowed{$lonhost}{'serverpath'}) { |
|
$selected = 'selected="selected"'; |
|
} |
|
} elsif ($path eq '') { |
|
$selected = 'selected="selected"'; |
|
} |
|
$datatable .= '<option value="'.$path.'"'.$selected.'>'.$pathname.'</option>'; |
|
} |
|
$datatable .= '</select></td>'; |
|
my ($custom,$exempt); |
|
if (ref($disallowed{$lonhost}) eq 'HASH') { |
|
$custom = $disallowed{$lonhost}{'custompath'}; |
|
$exempt = $disallowed{$lonhost}{'exempt'}; |
|
} |
|
$datatable .= '<td><input type="text" name="'.$lonhost.'_custompath" size="6" value="'.$custom.'" /></td>'. |
|
'<td><input type="text" name="'.$lonhost.'_exempt" size="8" value="'.$exempt.'" /></td>'. |
|
'</tr>'; |
|
} |
|
$datatable .= '</table></td></tr>'; |
|
return $datatable; |
|
} |
|
|
my %defaultchecked = ( |
my %defaultchecked = ( |
'coursecatalog' => 'on', |
'coursecatalog' => 'on', |
'adminmail' => 'off', |
'adminmail' => 'off', |
Line 753 sub login_choices {
|
Line 840 sub login_choices {
|
&Apache::lonlocal::texthash ( |
&Apache::lonlocal::texthash ( |
coursecatalog => 'Display Course/Community Catalog link?', |
coursecatalog => 'Display Course/Community Catalog link?', |
adminmail => "Display Administrator's E-mail Address?", |
adminmail => "Display Administrator's E-mail Address?", |
|
disallowlogin => "Login page requests redirected", |
|
hostid => "Server", |
|
server => "Redirect to:", |
|
serverpath => "Path", |
|
custompath => "Custom", |
|
exempt => "Exempt IP(s)", |
|
directlogin => "No redirect", |
newuser => "Link to create a user account", |
newuser => "Link to create a user account", |
img => "Header", |
img => "Header", |
logo => "Main Logo", |
logo => "Main Logo", |
Line 3281 sub modify_login {
|
Line 3375 sub modify_login {
|
newuser => 'Link for visitors to create a user account', |
newuser => 'Link for visitors to create a user account', |
loginheader => 'Log-in box header'); |
loginheader => 'Log-in box header'); |
my @offon = ('off','on'); |
my @offon = ('off','on'); |
|
my %curr_loginvia; |
|
if (ref($domconfig{login}) eq 'HASH') { |
|
if (ref($domconfig{login}{loginvia}) eq 'HASH') { |
|
foreach my $lonhost (keys(%{$domconfig{login}{loginvia}})) { |
|
$curr_loginvia{$lonhost} = $domconfig{login}{loginvia}{$lonhost}; |
|
} |
|
} |
|
} |
my %loginhash; |
my %loginhash; |
($errors,%colchanges) = &modify_colors($r,$dom,$confname,['login'], |
($errors,%colchanges) = &modify_colors($r,$dom,$confname,['login'], |
\%domconfig,\%loginhash); |
\%domconfig,\%loginhash); |
Line 3293 sub modify_login {
|
Line 3395 sub modify_login {
|
$colchgtext = &display_colorchgs($dom,\%colchanges,['login'], |
$colchgtext = &display_colorchgs($dom,\%colchanges,['login'], |
\%loginhash); |
\%loginhash); |
} |
} |
|
|
|
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.'_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.'_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; |
|
} |
|
} |
|
} |
|
} |
|
} |
|
|
my $putresult = &Apache::lonnet::put_dom('configuration',\%loginhash, |
my $putresult = &Apache::lonnet::put_dom('configuration',\%loginhash, |
$dom); |
$dom); |
if ($putresult eq 'ok') { |
if ($putresult eq 'ok') { |
Line 3339 sub modify_login {
|
Line 3528 sub modify_login {
|
foreach my $item (sort(keys(%changes))) { |
foreach my $item (sort(keys(%changes))) { |
if ($item eq 'loginheader') { |
if ($item eq 'loginheader') { |
$resulttext .= '<li>'.&mt("$title{$item} set to $env{'form.loginheader'}").'</li>'; |
$resulttext .= '<li>'.&mt("$title{$item} set to $env{'form.loginheader'}").'</li>'; |
|
} elsif ($item eq 'loginvia') { |
|
if (ref($changes{$item}) eq 'HASH') { |
|
$resulttext .= '<li>'.&mt('Log-in page availability:').'<ul>'; |
|
foreach my $lonhost (sort(keys(%{$changes{$item}}))) { |
|
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 .= '<li>'.&mt('Server: [_1] log-in page redirects to [_2].',$servers{$lonhost},'<a href="'.$target.'">'.$target.'</a>'); |
|
if ($loginhash{login}{loginvia}{$lonhost}{'exempt'} ne '') { |
|
$resulttext .= ' '.&mt('No redirection for clients from following IPs:').' '.$loginhash{login}{loginvia}{$lonhost}{'exempt'}; |
|
} |
|
$resulttext .= '</li>'; |
|
} else { |
|
$resulttext .= '<li>'.&mt('Server: [_1] has standard log-in page.',$lonhost).'</li>'; |
|
} |
|
} else { |
|
$resulttext .= '<li>'.&mt('Server: [_1] has standard log-in page.',$servers{$lonhost}).'</li>'; |
|
} |
|
} |
|
$resulttext .= '</ul></li>'; |
|
} |
} else { |
} else { |
$resulttext .= '<li>'.&mt("$title{$item} set to $offon[$env{'form.'.$item}]").'</li>'; |
$resulttext .= '<li>'.&mt("$title{$item} set to $offon[$env{'form.'.$item}]").'</li>'; |
} |
} |
Line 5931 sub recurse_cat_deletes {
|
Line 6149 sub recurse_cat_deletes {
|
return; |
return; |
} |
} |
|
|
|
sub dom_servers { |
|
my ($dom) = @_; |
|
my (%uniqservers,%servers); |
|
my $primaryserver = &Apache::lonnet::hostname(&Apache::lonnet::domain($dom,'primary')); |
|
my @machinedoms = &Apache::lonnet::machine_domains($primaryserver); |
|
foreach my $mdom (@machinedoms) { |
|
my %currservers = %servers; |
|
my %server = &Apache::lonnet::get_servers($mdom); |
|
%servers = (%currservers,%server); |
|
} |
|
my %by_hostname; |
|
foreach my $id (keys(%servers)) { |
|
push(@{$by_hostname{$servers{$id}}},$id); |
|
} |
|
foreach my $hostname (sort(keys(%by_hostname))) { |
|
if (@{$by_hostname{$hostname}} > 1) { |
|
my $match = 0; |
|
foreach my $id (@{$by_hostname{$hostname}}) { |
|
if (&Apache::lonnet::host_domain($id) eq $dom) { |
|
$uniqservers{$id} = $hostname; |
|
$match = 1; |
|
} |
|
} |
|
unless ($match) { |
|
$uniqservers{$by_hostname{$hostname}[0]} = $hostname; |
|
} |
|
} else { |
|
$uniqservers{$by_hostname{$hostname}[0]} = $hostname; |
|
} |
|
} |
|
return %uniqservers; |
|
} |
|
|
sub get_active_dcs { |
sub get_active_dcs { |
my ($dom) = @_; |
my ($dom) = @_; |
my %dompersonnel = &Apache::lonnet::get_domain_roles($dom,['dc']); |
my %dompersonnel = &Apache::lonnet::get_domain_roles($dom,['dc']); |