--- loncom/interface/domainprefs.pm 2009/11/30 06:23:32 1.121
+++ loncom/interface/domainprefs.pm 2010/01/02 20:26:10 1.124
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Handler to set domain-wide configuration settings
#
-# $Id: domainprefs.pm,v 1.121 2009/11/30 06:23:32 raeburn Exp $
+# $Id: domainprefs.pm,v 1.124 2010/01/02 20:26:10 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -323,8 +323,10 @@ sub handler {
'helpsettings' =>
{text => 'Help page settings',
help => 'Domain_Configuration_Help_Settings',
- header => [{col1 => 'Setting',
- col2 => 'Value',}],
+ header => [{col1 => 'Authenticated Help Settings',
+ col2 => ''},
+ {col1 => 'Unauthenticated Help Settings',
+ col2 => ''}],
},
'coursedefaults' =>
{text => 'Course/Community defaults',
@@ -435,7 +437,7 @@ sub process_changes {
} elsif ($action eq 'requestcourses') {
$output = &modify_quotas($dom,$action,%domconfig);
} elsif ($action eq 'helpsettings') {
- $output = &modify_helpsettings($dom,%domconfig);
+ $output = &modify_helpsettings($r,$dom,$confname,%domconfig);
} elsif ($action eq 'coursedefaults') {
$output = &modify_coursedefaults($dom,%domconfig);
}
@@ -463,7 +465,7 @@ sub print_config_box {
}
if ($numheaders > 1) {
my $colspan = '';
- if (($action eq 'rolecolors') || ($action eq 'coursecategories')) {
+ if (($action eq 'rolecolors') || ($action eq 'coursecategories') || ($action eq 'helpsettings')) {
$colspan = ' colspan="2"';
}
$output .= '
@@ -489,8 +491,8 @@ sub print_config_box {
} elsif ($action eq 'requestcourses') {
$output .= &print_quotas($dom,$settings,\$rowtotal,$action);
} elsif ($action eq 'helpsettings') {
- $output .= &print_helpsettings($dom,$settings,\$rowtotal);
- } else {
+ $output .= &print_helpsettings('top',$dom,$confname,$settings,\$rowtotal);
+ } elsif ($action eq 'rolecolors') {
$output .= &print_rolecolors($phase,'student',$dom,$confname,$settings,\$rowtotal);
}
$output .= '
@@ -541,7 +543,9 @@ sub print_config_box {
$output .= &print_login('bottom',$dom,$confname,$phase,$settings,\$rowtotal);
} elsif ($action eq 'requestcourses') {
$output .= &print_courserequestmail($dom,$settings,\$rowtotal);
- } else {
+ } elsif ($action eq 'helpsettings') {
+ $output .= &print_helpsettings('bottom',$dom,$confname,$settings,\$rowtotal);
+ } elsif ($action eq 'rolecolors') {
$output .= &print_rolecolors($phase,'coordinator',$dom,$confname,$settings,\$rowtotal).'
@@ -626,7 +630,7 @@ sub print_config_box {
} elsif ($action eq 'serverstatuses') {
$output .= &print_serverstatuses($dom,$settings,\$rowtotal);
} elsif ($action eq 'helpsettings') {
- $output .= &print_helpsettings($dom,$settings,\$rowtotal);
+ $output .= &print_helpsettings('top',$dom,$confname,$settings,\$rowtotal);
} elsif ($action eq 'coursedefaults') {
$output .= &print_coursedefaults($dom,$settings,\$rowtotal);
}
@@ -1946,22 +1950,99 @@ sub print_contacts {
}
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',);
- ($datatable,$itemcount) = &radiobutton_prefs($settings,\@toggles,\%defaultchecked,
- \%choices,$itemcount);
- $$rowtotal += $itemcount;
- return $datatable;
+
+ my ($position,$dom,$confname,$settings,$rowtotal) = @_;
+ my ($css_class,$datatable);
+
+ my $switchserver = &check_switchserver($dom,$confname);
+
+ my $itemcount = 1;
+
+ if ($position eq 'top') {
+
+ 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 ++;
+ }
+
+ } else {
+
+ $css_class = $itemcount%2 ? ' class="LC_odd_row"' : '';
+
+ $datatable .= '';
+
+ if (ref($settings) eq 'HASH') {
+ if ($settings->{'loginhelpurl'} ne '') {
+ my($directory, $filename) = $settings->{'loginhelpurl'} =~ m/(.*\/)(.*)$/;
+ $datatable .= ' | ';
+ $datatable .= ' | '
+ } else {
+ $datatable .= ' | ';
+ $datatable .= ' | ';
+ }
+ } else {
+ $datatable .= ' | ';
+ $datatable .= ' | ';
+ }
+
+ $datatable .= '';
+ if ($switchserver) {
+ $datatable .= &mt('Upload to library server: [_1]',$switchserver);
+ } else {
+ $datatable .= &mt('Upload Custom Login Page Help File:');
+ $datatable .='';
+ }
+ $datatable .= ' |
';
+
+ }
+
+ return $datatable;
+
}
+
sub radiobutton_prefs {
my ($settings,$toggles,$defaultchecked,$choices,$itemcount) = @_;
return unless ((ref($toggles) eq 'ARRAY') && (ref($defaultchecked) eq 'HASH') &&
@@ -5543,15 +5624,13 @@ sub modify_coursecategories {
} else {
$changes{'togglecats'} = 1;
$changes{'categorize'} = 1;
- $domconfig{'coursecategories'} = {
- togglecats => $env{'form.togglecats'},
- categorize => $env{'form.categorize'},
- };
$changes{'togglecatscomm'} = 1;
$changes{'categorizecomm'} = 1;
$domconfig{'coursecategories'} = {
- togglecats => $env{'form.togglecatscomm'},
- categorize => $env{'form.categorizecomm'},
+ togglecats => $env{'form.togglecats'},
+ categorize => $env{'form.categorize'},
+ togglecatscomm => $env{'form.togglecatscomm'},
+ categorizecomm => $env{'form.categorizecomm'},
};
}
if (ref($cathash) eq 'HASH') {
@@ -5869,12 +5948,20 @@ sub modify_serverstatuses {
}
sub modify_helpsettings {
- my ($dom,%domconfig) = @_;
+ my ($r,$dom,$confname,%domconfig) = @_;
my ($resulttext,$errors,%changes,%helphash);
+ my $customhelpfile = $env{'form.loginhelpurl.filename'};
+ my $defaulthelpfile = 'defaulthelp.html';
+ my $servadm = $r->dir_config('lonAdmEMail');
+ my ($configuserok,$author_ok,$switchserver) =
+ &config_check($dom,$confname,$servadm);
+
my %defaultchecked = ('submitbugs' => 'on');
my @offon = ('off','on');
- my %title = ( submitbugs => 'Display link for users to submit a bug');
+ my %title = ( submitbugs => 'Display link for users to submit a bug',
+ loginhelpurl => 'Unauthenticated login help page set to custom file');
+
my @toggles = ('submitbugs');
$helphash{'helpsettings'} = {};
@@ -5905,11 +5992,53 @@ sub modify_helpsettings {
}
}
$helphash{'helpsettings'}{$item} = $env{'form.'.$item};
- }
+ }
+
+ if ($customhelpfile ne '') {
+ my $error;
+ if ($configuserok eq 'ok') {
+ if ($switchserver) {
+ $error = &mt("Upload of custom help file is not permitted to this server: [_1]",$switchserver);
+ } else {
+ if ($author_ok eq 'ok') {
+ my ($result,$loginhelpurl) =
+ &publishlogo($r,'upload','loginhelpurl',$dom,
+ $confname,'help','','',$customhelpfile);
+ if ($result eq 'ok') {
+ $helphash{'helpsettings'}{'loginhelpurl'} = $loginhelpurl;
+ $changes{'loginhelpurl'} = 1;
+ } else {
+ $error = &mt("Upload of [_1] failed because an error occurred publishing the file in RES space. Error was: [_2].",$customhelpfile,$result);
+ }
+ } else {
+ $error = &mt("Upload of [_1] failed because an author role could not be assigned to a Domain Configuration user ([_2]) in domain: [_3]. Error was: [_4].",$customhelpfile,$confname,$dom,$author_ok);
+ }
+ }
+ } else {
+ $error = &mt("Upload of [_1] failed because a Domain Configuration user ([_2]) could not be created in domain: [_3]. Error was: [_4].",$customhelpfile,$confname,$dom,$configuserok);
+ }
+ if ($error) {
+ &Apache::lonnet::logthis($error);
+ $errors .= ''.$error.'';
+ }
+ }
+
+ if ($domconfig{'helpsettings'}{'loginhelpurl'} ne '') {
+ if ($env{'form.loginhelpurl_del'}) {
+ $helphash{'helpsettings'}{'loginhelpurl'} = '';
+ $changes{'loginhelpurl'} = 1;
+ }
+ }
}
- my $putresult = &Apache::lonnet::put_dom('configuration',\%helphash,
- $dom);
+
+ my $putresult;
+
+ if (keys(%changes) > 0) {
+ $putresult = &Apache::lonnet::put_dom('configuration',\%helphash,$dom);
+ } else {
+ $putresult = 'ok';
+ }
if ($putresult eq 'ok') {
if (keys(%changes) > 0) {
@@ -5918,6 +6047,13 @@ sub modify_helpsettings {
if ($item eq 'submitbugs') {
$resulttext .= ''.&mt("$title{$item} set to $offon[$env{'form.'.$item}]").'';
}
+ if ($item eq 'loginhelpurl') {
+ if ($helphash{'helpsettings'}{'loginhelpurl'} eq '') {
+ $resulttext .= ''.&mt('[_1] help file removed; [_2] file will be used for the unathorized help page in this domain.',$customhelpfile,$defaulthelpfile).'';
+ } else {
+ $resulttext .= ''.&mt("$title{$item} [_1]",$customhelpfile).'';
+ }
+ }
}
$resulttext .= '';
} else {