[LON-CAPA-cvs] cvs: loncom /interface domainprefs.pm
jms
jms@source.lon-capa.org
Fri, 04 Dec 2009 14:17:39 -0000
This is a MIME encoded message
--jms1259936259
Content-Type: text/plain
jms Fri Dec 4 14:17:39 2009 EDT
Modified files:
/loncom/interface domainprefs.pm
Log:
Added ability to customize Log-in Help link
--jms1259936259
Content-Type: text/plain
Content-Disposition: attachment; filename="jms-20091204141739.txt"
Index: loncom/interface/domainprefs.pm
diff -u loncom/interface/domainprefs.pm:1.121 loncom/interface/domainprefs.pm:1.122
--- loncom/interface/domainprefs.pm:1.121 Mon Nov 30 06:23:32 2009
+++ loncom/interface/domainprefs.pm Fri Dec 4 14:17:38 2009
@@ -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.122 2009/12/04 14:17:38 jms Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -323,8 +323,10 @@
'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 @@
} 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 @@
}
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 @@
} 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 @@
$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).'
</table>
</td>
@@ -626,7 +630,7 @@
} 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_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 .=
+ '<tr'.$css_class.'>
+ <td><span class="LC_nobreak">'.$choices{$item}.'</span></td>
+ <td><span class="LC_nobreak"> </span></td>
+ <td class="LC_right_item"><span class="LC_nobreak">
+ <label><input type="radio" name="'.$item.'" '.$checkedon{$item}.' value="1" />'.&mt('Yes').'</label>
+ <label><input type="radio" name="'.$item.'" '.$checkedoff{$item}.' value="0" />'.&mt('No').'</label>'.
+ '</span></td>'.
+ '</tr>';
+ $itemcount ++;
+ }
+
+ } else {
+
+ $css_class = $itemcount%2 ? ' class="LC_odd_row"' : '';
+
+ $datatable .= '<tr'.$css_class.'>';
+
+ if (ref($settings) eq 'HASH') {
+ if ($settings->{'loginhelpurl'} ne '') {
+ my($directory, $filename) = $settings->{'loginhelpurl'} =~ m/(.*\/)(.*)$/;
+ $datatable .= '<td width="33%"><span class="LC_left_item"><label><a href="'.$settings->{'loginhelpurl'}.'" target="_blank">'.&mt('Custom Login Page Help File In Use').'</a></label></span></td>';
+ $datatable .= '<td width="33%"><span class="LC_right_item"><label><input type="checkbox" name="loginhelpurl_del" value="1" />'.&mt('Delete?').'</label></span></td>'
+ } else {
+ $datatable .= '<td width="33%"><span class="LC_left_item"><label>'.&mt('Default Login Page Help File In Use').'</label></span></td>';
+ $datatable .= '<td width="33%"><span class="LC_right_item"> </span></td>';
+ }
+ } else {
+ $datatable .= '<td><span class="LC_left_item"> </span></td>';
+ $datatable .= '<td><span class="LC_right_item"> </span></td>';
+ }
+
+ $datatable .= '<td width="33%"><span class="LC_right_item">';
+ if ($switchserver) {
+ $datatable .= &mt('Upload to library server: [_1]',$switchserver);
+ } else {
+ $datatable .= &mt('Upload Custom Login Page Help File:');
+ $datatable .='<input type="file" name="loginhelpurl" />';
+ }
+ $datatable .= '</span></td></tr>';
+
+ }
+
+ return $datatable;
+
}
+
sub radiobutton_prefs {
my ($settings,$toggles,$defaultchecked,$choices,$itemcount) = @_;
return unless ((ref($toggles) eq 'ARRAY') && (ref($defaultchecked) eq 'HASH') &&
@@ -5869,12 +5950,20 @@
}
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 +5994,46 @@
}
}
$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 .= '<li><span class="LC_error">'.$error.'</span></li>';
+ }
+ }
+
+ 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 = &Apache::lonnet::put_dom('configuration',\%helphash,$dom);
if ($putresult eq 'ok') {
if (keys(%changes) > 0) {
@@ -5918,6 +6042,13 @@
if ($item eq 'submitbugs') {
$resulttext .= '<li>'.&mt("$title{$item} set to $offon[$env{'form.'.$item}]").'</li>';
}
+ if ($item eq 'loginhelpurl') {
+ if ($helphash{'helpsettings'}{'loginhelpurl'} eq '') {
+ $resulttext .= '<li>'.&mt('[_1] help file removed; [_2] file will be used for the unathorized help page in this domain.',$customhelpfile,$defaulthelpfile).'</li>';
+ } else {
+ $resulttext .= '<li>'.&mt("$title{$item} [_1]",$customhelpfile).'</li>';
+ }
+ }
}
$resulttext .= '</ul>';
} else {
--jms1259936259--