--- loncom/interface/domainprefs.pm 2009/08/22 18:48:56 1.106
+++ loncom/interface/domainprefs.pm 2009/11/16 04:03:05 1.119
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Handler to set domain-wide configuration settings
#
-# $Id: domainprefs.pm,v 1.106 2009/08/22 18:48:56 raeburn Exp $
+# $Id: domainprefs.pm,v 1.119 2009/11/16 04:03:05 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -202,11 +202,11 @@ sub handler {
'quotas','autoenroll','autoupdate','directorysrch',
'usercreation','usermodification','contacts','defaults',
'scantron','coursecategories','serverstatuses',
- 'requestcourses'],$dom);
+ 'requestcourses','helpsettings'],$dom);
my @prefs_order = ('rolecolors','login','defaults','quotas','autoenroll',
'autoupdate','directorysrch','contacts',
'usercreation','usermodification','scantron',
- 'requestcourses','coursecategories','serverstatuses');
+ 'requestcourses','coursecategories','serverstatuses','helpsettings');
my %prefs = (
'rolecolors' =>
{ text => 'Default color schemes',
@@ -220,12 +220,13 @@ sub handler {
{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',
@@ -318,7 +319,23 @@ sub handler {
col3 => 'Specific IPs',
}],
},
+ 'helpsettings' =>
+ {text => 'Help page settings',
+ help => 'Domain_Configuration_Help_Settings',
+ header => [{col1 => 'Setting',
+ 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 @actions = &Apache::loncommon::get_env_multiple('form.actions');
&Apache::lonhtmlcommon::add_breadcrumb
@@ -404,6 +421,8 @@ sub process_changes {
$output = &modify_serverstatuses($dom,%domconfig);
} elsif ($action eq 'requestcourses') {
$output = &modify_quotas($dom,$action,%domconfig);
+ } elsif ($action eq 'helpsettings') {
+ $output = &modify_helpsettings($dom,%domconfig);
}
return $output;
}
@@ -423,9 +442,11 @@ sub print_config_box {
&Apache::loncommon::help_open_topic($item->{'help'}).''."\n".
'';
$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,8 +468,13 @@ sub print_config_box {
$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);
+ } elsif ($action eq 'helpsettings') {
+ $output .= &print_helpsettings($dom,$settings,\$rowtotal);
} else {
$output .= &print_rolecolors($phase,'student',$dom,$confname,$settings,\$rowtotal);
}
@@ -496,6 +522,8 @@ sub print_config_box {
$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 +594,8 @@ sub print_config_box {
$output .= '';
$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') {
@@ -581,7 +610,9 @@ sub print_config_box {
$output .= &print_scantronformat($r,$dom,$confname,$settings,\$rowtotal);
} elsif ($action eq 'serverstatuses') {
$output .= &print_serverstatuses($dom,$settings,\$rowtotal);
- }
+ } elsif ($action eq 'helpsettings') {
+ $output .= &print_helpsettings($dom,$settings,\$rowtotal);
+ }
}
$output .= '
@@ -592,8 +623,48 @@ sub print_config_box {
}
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 = &dom_servers($dom);
+ my $choice = $choices{'disallowlogin'};
+ $css_class = ' class="LC_odd_row"';
+ $datatable .= '
'.$choices{'disallowlogin'}.' | '.
+ ''.$choices{'hostid'}.' | '.
+ ''.$choices{'serverurl'}.' | '."\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 .= ''.$servers{$lonhost}.' | '.
+ ' | ';
+ }
+ $datatable .= '
|
';
+ return $datatable;
+ }
+
my %defaultchecked = (
'coursecatalog' => 'on',
'adminmail' => 'off',
@@ -728,24 +799,28 @@ sub print_login {
sub login_choices {
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",
+ coursecatalog => 'Display Course/Community Catalog 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;
}
@@ -849,20 +924,22 @@ sub display_color_options {
' '.
'';
- $datatable .= ''.
- ''.$choices->{'fontmenu'}.' | ';
- if (!$is_custom->{'fontmenu'}) {
- $datatable .= ''.&mt('Default in use:').' '.$defaults->{'fontmenu'}.' | ';
- } else {
- $datatable .= ' | ';
+ unless ($role eq 'login') {
+ $datatable .= '
'.
+ ''.$choices->{'fontmenu'}.' | ';
+ if (!$is_custom->{'fontmenu'}) {
+ $datatable .= ''.&mt('Default in use:').' '.$defaults->{'fontmenu'}.' | ';
+ } else {
+ $datatable .= ' | ';
+ }
+ $fontlink = &color_pick($phase,$role,'fontmenu',$choices->{'fontmenu'},$designs->{'fontmenu'});
+ $datatable .= ''.
+ ' '.$fontlink.
+ ' '.
+ ' |
';
}
- $fontlink = &color_pick($phase,$role,'fontmenu',$choices->{'fontmenu'},$designs->{'fontmenu'});
- $datatable .= ''.
- ' '.$fontlink.
- ' '.
- ' | ';
my $switchserver = &check_switchserver($dom,$confname);
foreach my $img (@{$images}) {
$itemcount ++;
@@ -1371,16 +1448,15 @@ sub print_quotas {
$datatable .= ''.
''.&mt('LON-CAPA Advanced Users').' ';
if ($context eq 'requestcourses') {
- $datatable .= &mt('(overrides affiliation, if set)');
- } else {
- $datatable .= &mt('(overrides affiliation, if checked)');
- }
- $datatable .= ' | '.
- '';
- if ($context eq 'requestcourses') {
- $datatable .= '';
+ $datatable .= &mt('(overrides affiliation, if set)').
+ ''.
+ ''.
+ '';
} else {
- $datatable .= ' ';
+ $datatable .= &mt('(overrides affiliation, if checked)').
+ ''.
+ ''.
+ ' ';
}
my %advcell;
foreach my $item (@usertools) {
@@ -1852,6 +1928,62 @@ sub print_contacts {
return $datatable;
}
+sub print_helpsettings {
+
+ my ($dom,$settings,$rowtotal) = @_;
+ my ($css_class,$datatable);
+ my $itemcount = 1;
+ my (%checkedon,%checkedoff,%choices,%defaultchecked,@toggles);
+
+ %choices =
+ &Apache::lonlocal::texthash (
+ submitbugs => 'Display "Submit a bug" link?',
+ );
+
+ %defaultchecked = ('submitbugs' => 'on');
+
+ @toggles = ('submitbugs',);
+
+ foreach my $item (@toggles) {
+ if ($defaultchecked{$item} eq 'on') {
+ $checkedon{$item} = ' checked="checked" ';
+ $checkedoff{$item} = ' ';
+ } elsif ($defaultchecked{$item} eq 'off') {
+ $checkedoff{$item} = ' checked="checked" ';
+ $checkedon{$item} = ' ';
+ }
+ }
+
+ if (ref($settings) eq 'HASH') {
+ foreach my $item (@toggles) {
+ if ($settings->{$item} eq '1') {
+ $checkedon{$item} = ' checked="checked" ';
+ $checkedoff{$item} = ' ';
+ } elsif ($settings->{$item} eq '0') {
+ $checkedoff{$item} = ' checked="checked" ';
+ $checkedon{$item} = ' ';
+ }
+ }
+ }
+
+ foreach my $item (@toggles) {
+ $css_class = $itemcount%2?' class="LC_odd_row"':'';
+ $datatable .=
+ ' | '.$choices{$item}.
+ ' | '.
+ ''.
+ ' '.
+ ' | '.
+ ' ';
+ $itemcount ++;
+ }
+ return $datatable;
+
+}
+
sub contact_titles {
my %titles = &Apache::lonlocal::texthash (
'supportemail' => 'Support E-mail address',
@@ -2657,7 +2789,7 @@ sub print_serverstatuses {
sub serverstatus_pages {
return ('userstatus','lonstatus','loncron','server-status','codeversions',
'clusterstatus','metadata_keywords','metadata_harvest',
- 'takeoffline','takeonline','showenv');
+ 'takeoffline','takeonline','showenv','toggledebug');
}
sub coursecategories_javascript {
@@ -2684,6 +2816,7 @@ sub coursecategories_javascript {
}
$output = <<"ENDSCRIPT";
ENDSCRIPT
@@ -3073,6 +3207,14 @@ sub modify_login {
newuser => 'Link for visitors to create a user account',
loginheader => 'Log-in box header');
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;
($errors,%colchanges) = &modify_colors($r,$dom,$confname,['login'],
\%domconfig,\%loginhash);
@@ -3085,6 +3227,26 @@ sub modify_login {
$colchgtext = &display_colorchgs($dom,\%colchanges,['login'],
\%loginhash);
}
+
+ my %servers = &dom_servers($dom);
+ 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;
+ } else {
+ if (defined($servers{$env{'form.'.$lonhost.'_serverurl'}})) {
+ $loginhash{login}{loginvia}{$lonhost} = $env{'form.'.$lonhost.'_serverurl'};
+ $changes{'loginvia'}{$lonhost} = 1;
+ }
+ }
+ }
+ }
+
my $putresult = &Apache::lonnet::put_dom('configuration',\%loginhash,
$dom);
if ($putresult eq 'ok') {
@@ -3131,6 +3293,18 @@ sub modify_login {
foreach my $item (sort(keys(%changes))) {
if ($item eq 'loginheader') {
$resulttext .= ''.&mt("$title{$item} set to $env{'form.loginheader'}").'';
+ } elsif ($item eq 'loginvia') {
+ 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'}}).'
';
+ } else {
+ $resulttext .= '- '.&mt('Server: [_1] now has standard log-in page.',$lonhost).'
';
+ }
+ }
+ $resulttext .= ' ';
+ }
} else {
$resulttext .= ''.&mt("$title{$item} set to $offon[$env{'form.'.$item}]").'';
}
@@ -3216,6 +3390,7 @@ sub modify_colors {
@logintext = ('textcol','bgcol');
} else {
%choices = &color_font_choices();
+ $confhash->{$role}{'fontmenu'} = $env{'form.'.$role.'_fontmenu'};
}
if ($role eq 'login') {
@images = ('img','logo','domlogo','login');
@@ -3225,7 +3400,6 @@ sub modify_colors {
@bgs = ('pgbg','tabbg','sidebg');
}
$confhash->{$role}{'font'} = $env{'form.'.$role.'_font'};
- $confhash->{$role}{'fontmenu'} = $env{'form.'.$role.'_fontmenu'};
foreach my $item (@bgs,@links,@logintext) {
$confhash->{$role}{$item} = $env{'form.'.$role.'_'.$item};
}
@@ -3339,13 +3513,15 @@ sub modify_colors {
$changes{$role}{'font'} = 1;
}
}
- if ($domconfig->{$role}{'fontmenu'} ne '') {
- if ($confhash->{$role}{'fontmenu'} ne $domconfig->{$role}{'fontmenu'}) {
- $changes{$role}{'fontmenu'} = 1;
- }
- } else {
- if ($confhash->{$role}{'fontmenu'}) {
- $changes{$role}{'fontmenu'} = 1;
+ if ($role ne 'login') {
+ if ($domconfig->{$role}{'fontmenu'} ne '') {
+ if ($confhash->{$role}{'fontmenu'} ne $domconfig->{$role}{'fontmenu'}) {
+ $changes{$role}{'fontmenu'} = 1;
+ }
+ } else {
+ if ($confhash->{$role}{'fontmenu'}) {
+ $changes{$role}{'fontmenu'} = 1;
+ }
}
}
foreach my $item (@bgs) {
@@ -3972,8 +4148,8 @@ sub modify_quotas {
$env{'user.domain'},
$item,'reload',$context);
if ($context eq 'requestcourses') {
- if ($env{'environment.crsrequest.'.$item} ne $newacc) {
- $newenv{'environment.crsrequest.'.$item} = $newacc;
+ if ($env{'environment.canrequest.'.$item} ne $newacc) {
+ $newenv{'environment.canrequest.'.$item} = $newacc;
}
} else {
if ($env{'environment.availabletools.'.$item} ne $newacc) {
@@ -5516,6 +5692,72 @@ sub modify_serverstatuses {
return $resulttext;
}
+sub modify_helpsettings {
+ my ($dom,%domconfig) = @_;
+ my ($resulttext,$errors,%changes,%helphash);
+
+ my %defaultchecked = ('submitbugs' => 'on');
+ my @offon = ('off','on');
+ my %title = ( submitbugs => 'Display link for users to submit a bug');
+ my @toggles = ('submitbugs');
+
+ $helphash{'helpsettings'} = {};
+
+ if (ref($domconfig{'helpsettings'}) ne 'HASH') {
+ if ($domconfig{'helpsettings'} eq '') {
+ $domconfig{'helpsettings'} = {};
+ }
+ }
+
+ if (ref($domconfig{'helpsettings'}) eq 'HASH') {
+
+ foreach my $item (@toggles) {
+
+ if ($defaultchecked{$item} eq 'on') {
+ if (($domconfig{'helpsettings'}{$item} eq '') &&
+ ($env{'form.'.$item} eq '0')) {
+ $changes{$item} = 1;
+ } elsif ($domconfig{'helpsettings'}{$item} ne $env{'form.'.$item}) {
+ $changes{$item} = 1;
+ }
+ } elsif ($defaultchecked{$item} eq 'off') {
+ if (($domconfig{'helpsettings'}{$item} eq '') &&
+ ($env{'form.'.$item} eq '1')) {
+ $changes{$item} = 1;
+ } elsif ($domconfig{'helpsettings'}{$item} ne $env{'form.'.$item}) {
+ $changes{$item} = 1;
+ }
+ }
+ $helphash{'helpsettings'}{$item} = $env{'form.'.$item};
+ }
+ }
+
+ my $putresult = &Apache::lonnet::put_dom('configuration',\%helphash,
+ $dom);
+
+ if ($putresult eq 'ok') {
+ if (keys(%changes) > 0) {
+ $resulttext = &mt('Changes made:').'';
+ foreach my $item (sort(keys(%changes))) {
+ if ($item eq 'submitbugs') {
+ $resulttext .= '- '.&mt("$title{$item} set to $offon[$env{'form.'.$item}]").'
';
+ }
+ }
+ $resulttext .= ' ';
+ } else {
+ $resulttext = &mt('No changes made to help settings');
+ }
+ } else {
+ $resulttext = ''.
+ &mt('An error occurred: [_1]',$putresult).'';
+ }
+ if ($errors) {
+ $resulttext .= &mt('The following errors occurred: ').'';
+ }
+ return $resulttext;
+}
+
sub recurse_check {
my ($chkcats,$categories,$depth,$name) = @_;
if (ref($chkcats->[$depth]{$name}) eq 'ARRAY') {
@@ -5556,4 +5798,37 @@ sub recurse_cat_deletes {
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;
+}
+
1;
|
|