[LON-CAPA-cvs] cvs: loncom /interface domainprefs.pm
raeburn
raeburn@source.lon-capa.org
Tue, 06 Oct 2009 18:10:25 -0000
This is a MIME encoded message
--raeburn1254852625
Content-Type: text/plain
raeburn Tue Oct 6 18:10:25 2009 EDT
Modified files:
/loncom/interface domainprefs.pm
Log:
- Log-in page option.
- If domain has more than one server, can choose to replace
log-in page on one or more servers with redirect to a different server in the domain.
e.g., redirect s1-s8 at msu to lonbalancer server (s9).
- default is to show regular log-in page.
--raeburn1254852625
Content-Type: text/plain
Content-Disposition: attachment; filename="raeburn-20091006181025.txt"
Index: loncom/interface/domainprefs.pm
diff -u loncom/interface/domainprefs.pm:1.109 loncom/interface/domainprefs.pm:1.110
--- loncom/interface/domainprefs.pm:1.109 Sun Aug 23 17:22:54 2009
+++ loncom/interface/domainprefs.pm Tue Oct 6 18:10:25 2009
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Handler to set domain-wide configuration settings
#
-# $Id: domainprefs.pm,v 1.109 2009/08/23 17:22:54 raeburn Exp $
+# $Id: domainprefs.pm,v 1.110 2009/10/06 18:10:25 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -220,12 +220,13 @@
{col1 => 'Administrator Settings',
col2 => '',}],
},
- 'login' =>
+ 'login' =>
{ text => 'Log-in page options',
help => 'Domain_Configuration_Login_Page',
header => [{col1 => 'Item',
col2 => '',}],
},
+
'defaults' =>
{ text => 'Default authentication/language/timezone',
help => 'Domain_Configuration_LangTZAuth',
@@ -319,6 +320,16 @@
}],
},
);
+ my %servers = &Apache::lonnet::get_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 @actions = &Apache::loncommon::get_env_multiple('form.actions');
&Apache::lonhtmlcommon::add_breadcrumb
@@ -423,9 +434,11 @@
&Apache::loncommon::help_open_topic($item->{'help'}).'</span></th>'."\n".
'</tr>';
$rowtotal ++;
- if (($action eq 'autoupdate') || ($action eq 'rolecolors') ||
- ($action eq 'usercreation') || ($action eq 'usermodification') ||
- ($action eq 'coursecategories') || ($action eq 'requestcourses')) {
+ my $numheaders = 1;
+ if (ref($item->{'header'}) eq 'ARRAY') {
+ $numheaders = scalar(@{$item->{'header'}});
+ }
+ if ($numheaders > 1) {
my $colspan = '';
if (($action eq 'rolecolors') || ($action eq 'coursecategories')) {
$colspan = ' colspan="2"';
@@ -447,6 +460,9 @@
$output .= &print_usermodification('top',$dom,$settings,\$rowtotal);
} elsif ($action eq 'coursecategories') {
$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') {
$output .= &print_quotas($dom,$settings,\$rowtotal,$action);
} else {
@@ -496,6 +512,8 @@
$rowtotal ++;
} elsif ($action eq 'coursecategories') {
$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') {
$output .= &print_courserequestmail($dom,$settings,\$rowtotal);
} else {
@@ -566,7 +584,8 @@
$output .= '</tr>';
$rowtotal ++;
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') {
$output .= &print_quotas($dom,$settings,\$rowtotal,$action);
} elsif ($action eq 'autoenroll') {
@@ -592,8 +611,48 @@
}
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 $itemcount = 1;
+
+ if ($position eq 'top') {
+ my %servers = &Apache::lonnet::get_servers($dom);
+ my $choice = $choices{'disallowlogin'};
+ $css_class = ' class="LC_odd_row"';
+ $datatable .= '<tr'.$css_class.'><td>'.$choices{'disallowlogin'}.'</td>'.
+ '<td align="right"><table><tr><th>'.$choices{'hostid'}.'</th>'.
+ '<th>'.$choices{'serverurl'}.'</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 ($disallowed{$lonhost} eq '') {
+ $direct = '';
+ }
+ $datatable .= '<tr><td>'.$lonhost.'</td>'.
+ '<td><select name="'.$lonhost.'_serverurl">'.
+ '<option value=""'.$direct.'>'.$choices{'directlogin'}.
+ '</option>';
+ foreach my $hostid (keys(%servers)) {
+ next if ($hostid eq $lonhost);
+ my $selected = '';
+ if ($hostid eq $disallowed{$lonhost}) {
+ $selected = 'selected="selected"';
+ }
+ $datatable .= '<option value="'.$hostid.'"'.$selected.'>'.
+ $servers{$hostid}.'</option>';
+ }
+ $datatable .= '</select></td></tr>';
+ }
+ $datatable .= '</table></td></tr>';
+ return $datatable;
+ }
+
my %defaultchecked = (
'coursecatalog' => 'on',
'adminmail' => 'off',
@@ -729,23 +788,27 @@
my %choices =
&Apache::lonlocal::texthash (
coursecatalog => 'Display Course Catalog link?',
- adminmail => "Display Administrator's E-mail Address?",
- newuser => "Link to create a user account",
- img => "Header",
- logo => "Main Logo",
- domlogo => "Domain Logo",
- login => "Log-in Header",
- textcol => "Text color",
- bgcol => "Box color",
- bgs => "Background colors",
- links => "Link colors",
- font => "Font color",
- pgbg => "Header",
- mainbg => "Page",
- sidebg => "Login box",
- link => "Link",
- alink => "Active link",
- vlink => "Visited link",
+ adminmail => "Display Administrator's E-mail Address?",
+ disallowlogin => "Login page requests redirected",
+ hostid => "Server",
+ serverurl => "Redirect to log-in via:",
+ directlogin => "No redirect",
+ newuser => "Link to create a user account",
+ img => "Header",
+ logo => "Main Logo",
+ domlogo => "Domain Logo",
+ login => "Log-in Header",
+ textcol => "Text color",
+ bgcol => "Box color",
+ bgs => "Background colors",
+ links => "Link colors",
+ font => "Font color",
+ pgbg => "Header",
+ mainbg => "Page",
+ sidebg => "Login box",
+ link => "Link",
+ alink => "Active link",
+ vlink => "Visited link",
);
return %choices;
}
@@ -3088,6 +3151,18 @@
$colchgtext = &display_colorchgs($dom,\%colchanges,['login'],
\%loginhash);
}
+
+ my %servers = &Apache::lonnet::get_servers($dom);
+ if (keys(%servers) > 1) {
+ foreach my $lonhost (keys(%servers)) {
+ if ($env{'form.'.$lonhost.'_serverurl'} ne '') {
+ if (defined($servers{$env{'form.'.$lonhost.'_serverurl'}})) {
+ $loginhash{login}{loginvia}{$lonhost} = $env{'form.'.$lonhost.'_serverurl'};
+ }
+ }
+ }
+ }
+
my $putresult = &Apache::lonnet::put_dom('configuration',\%loginhash,
$dom);
if ($putresult eq 'ok') {
--raeburn1254852625--