';
- }
+ ($datatable,$itemcount) = &radiobutton_prefs($settings,\@toggles,\%defaultchecked,
+ \%choices,$itemcount);
return $datatable;
}
@@ -3527,13 +3585,8 @@ sub print_defaults {
my $includeempty = 1;
$datatable .= &Apache::loncommon::select_datelocale($item,$domdefaults{$item},undef,$includeempty);
} elsif ($item eq 'lang_def') {
- my %langchoices=('' => 'No language preference');
- foreach my $id (&Apache::loncommon::languageids()) {
- my $code = &Apache::loncommon::supportedlanguagecode($id);
- if ($code ne '') {
- $langchoices{$code} = &Apache::loncommon::plainlanguagedescription($id);
- }
- }
+ my %langchoices = &get_languages_hash();
+ $langchoices{''} = 'No language preference';
%langchoices = &Apache::lonlocal::texthash(%langchoices);
$datatable .= &Apache::loncommon::select_form($domdefaults{$item},$item,
\%langchoices);
@@ -3552,6 +3605,17 @@ sub print_defaults {
return $datatable;
}
+sub get_languages_hash {
+ my %langchoices;
+ foreach my $id (&Apache::loncommon::languageids()) {
+ my $code = &Apache::loncommon::supportedlanguagecode($id);
+ if ($code ne '') {
+ $langchoices{$code} = &Apache::loncommon::plainlanguagedescription($id);
+ }
+ }
+ return %langchoices;
+}
+
sub defaults_titles {
my ($dom) = @_;
my %titles = &Apache::lonlocal::texthash (
@@ -4463,13 +4527,13 @@ sub usertype_update_row {
sub modify_login {
my ($r,$dom,$confname,%domconfig) = @_;
- my ($resulttext,$errors,$colchgtext,%changes,%colchanges);
- my %title = ( coursecatalog => 'Display course catalog',
- adminmail => 'Display administrator E-mail address',
- newuser => 'Link for visitors to create a user account',
- loginheader => 'Log-in box header');
- my @offon = ('off','on');
- my %curr_loginvia;
+ my ($resulttext,$errors,$colchgtext,%changes,%colchanges,%newfile,%newurl,
+ %curr_loginvia,%loginhash,@currlangs,@newlangs,$addedfile,%title,@offon);
+ %title = ( coursecatalog => 'Display course catalog',
+ adminmail => 'Display administrator E-mail address',
+ newuser => 'Link for visitors to create a user account',
+ loginheader => 'Log-in box header');
+ @offon = ('off','on');
if (ref($domconfig{login}) eq 'HASH') {
if (ref($domconfig{login}{loginvia}) eq 'HASH') {
foreach my $lonhost (keys(%{$domconfig{login}{loginvia}})) {
@@ -4477,7 +4541,6 @@ sub modify_login {
}
}
}
- my %loginhash;
($errors,%colchanges) = &modify_colors($r,$dom,$confname,['login'],
\%domconfig,\%loginhash);
my @toggles = ('coursecatalog','adminmail','newuser');
@@ -4576,6 +4639,95 @@ sub modify_login {
}
}
+ my $servadm = $r->dir_config('lonAdmEMail');
+ my %langchoices = &Apache::lonlocal::texthash(&get_languages_hash());
+ if (ref($domconfig{'login'}) eq 'HASH') {
+ if (ref($domconfig{'login'}{'helpurl'}) eq 'HASH') {
+ foreach my $lang (sort(keys(%{$domconfig{'login'}{'helpurl'}}))) {
+ if ($lang eq 'nolang') {
+ push(@currlangs,$lang);
+ } elsif (defined($langchoices{$lang})) {
+ push(@currlangs,$lang);
+ } else {
+ next;
+ }
+ }
+ }
+ }
+ my @delurls = &Apache::loncommon::get_env_multiple('form.loginhelpurl_del');
+ if (@currlangs > 0) {
+ foreach my $lang (@currlangs) {
+ if (grep(/^\Q$lang\E$/,@delurls)) {
+ $changes{'helpurl'}{$lang} = 1;
+ } elsif ($env{'form.loginhelpurl_'.$lang.'.filename'}) {
+ $changes{'helpurl'}{$lang} = 1;
+ $newfile{$lang} = $env{'form.loginhelpurl_'.$lang.'.filename'};
+ push(@newlangs,$lang);
+ } else {
+ $loginhash{'login'}{'helpurl'}{$lang} = $domconfig{'login'}{'helpurl'}{$lang};
+ }
+ }
+ }
+ unless (grep(/^nolang$/,@currlangs)) {
+ if ($env{'form.loginhelpurl_nolang.filename'}) {
+ $changes{'helpurl'}{'nolang'} = 1;
+ $newfile{'nolang'} = $env{'form.loginhelpurl_nolang.filename'};
+ push(@newlangs,'nolang');
+ }
+ }
+ if ($env{'form.loginhelpurl_add_lang'}) {
+ if ((defined($langchoices{$env{'form.loginhelpurl_add_lang'}})) &&
+ ($env{'form.loginhelpurl_add_file.filename'})) {
+ $newfile{$env{'form.loginhelpurl_add_lang'}} = $env{'form.loginhelpurl_add_file.filename'};
+ $addedfile = $env{'form.loginhelpurl_add_lang'};
+ }
+ }
+ if ((@newlangs > 0) || ($addedfile)) {
+ my $error;
+ my ($configuserok,$author_ok,$switchserver) = &config_check($dom,$confname,$servadm);
+ if ($configuserok eq 'ok') {
+ if ($switchserver) {
+ $error = &mt("Upload of custom help file is not permitted to this server: [_1]",$switchserver);
+ } elsif ($author_ok eq 'ok') {
+ my @allnew = @newlangs;
+ if ($addedfile ne '') {
+ push(@allnew,$addedfile);
+ }
+ foreach my $lang (@allnew) {
+ my $formelem = 'loginhelpurl_'.$lang;
+ if ($lang eq $env{'form.loginhelpurl_add_lang'}) {
+ $formelem = 'loginhelpurl_add_file';
+ }
+ (my $result,$newurl{$lang}) = &publishlogo($r,'upload',$formelem,$dom,$confname,
+ "help/$lang",'','',$newfile{$lang});
+ if ($result eq 'ok') {
+ $loginhash{'login'}{'helpurl'}{$lang} = $newurl{$lang};
+ $changes{'helpurl'}{$lang} = 1;
+ } else {
+ my $puberror = &mt("Upload of [_1] failed because an error occurred publishing the file in RES space. Error was: [_2].",$newfile{$lang},$result);
+ $errors .= '
'.$puberror.'
';
+ if ((grep(/^\Q$lang\E$/,@currlangs)) &&
+ (!grep(/^\Q$lang\E$/,@delurls))) {
+
+ $loginhash{'login'}{'helpurl'}{$lang} = $domconfig{'login'}{'helpurl'}{$lang};
+ }
+ }
+ }
+ } else {
+ $error = &mt("Upload of custom log-in help file(s) failed because an author role could not be assigned to a Domain Configuration user ([_1]) in domain: [_2]. Error was: [_3].",$confname,$dom,$author_ok);
+ }
+ } else {
+ $error = &mt("Upload of custom log-in help file(s) failed because a Domain Configuration user ([_1]) could not be created in domain: [_2]. Error was: [_3].",$confname,$dom,$configuserok);
+ }
+ if ($error) {
+ &Apache::lonnet::logthis($error);
+ $errors .= '
'.$error.'
';
+ }
+ }
+
+ my $defaulthelpfile = '/adm/loginproblems.html';
+ my $defaulttext = &mt('Default in use');
+
my $putresult = &Apache::lonnet::put_dom('configuration',\%loginhash,
$dom);
if ($putresult eq 'ok') {
@@ -4641,6 +4793,32 @@ sub modify_login {
}
$resulttext .= '';
}
+ } elsif ($item eq 'helpurl') {
+ if (ref($changes{$item}) eq 'HASH') {
+ foreach my $lang (sort(keys(%{$changes{$item}}))) {
+ if (grep(/^\Q$lang\E$/,@delurls)) {
+ my ($chg,$link);
+ $link = &Apache::loncommon::modal_link($defaulthelpfile,$defaulttext,600,500);
+ if ($lang eq 'nolang') {
+ $chg = &mt('custom log-in help file removed for no preferred language; [_1]',$link);
+ } else {
+ $chg = &mt('custom log-in help file removed for specific language: [_1]; [_2]',$langchoices{$lang},$link);
+ }
+ $resulttext .= '
'.$chg.'
';
+ } else {
+ my $chg;
+ if ($lang eq 'nolang') {
+ $chg = &mt('custom log-in help file for no preferred language');
+ } else {
+ $chg = &mt('custom log-in help file for specific language: [_1]',$langchoices{$lang});
+ }
+ $resulttext .= '
'.&mt("$title{$item} set to $offon[$env{'form.'.$item}]").'
';
}
@@ -7419,24 +7597,9 @@ sub modify_serverstatuses {
sub modify_helpsettings {
my ($r,$dom,$confname,%domconfig) = @_;
my ($resulttext,$errors,%changes,%helphash);
- my $customhelpfile = $env{'form.loginhelpurl.filename'};
- my $defaulthelpfile = '/adm/loginproblems.html';
- my $defaulttext = &mt('Default in use');
- 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',
- loginhelpurl => 'Unauthenticated login help page set to custom file'
- );
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') {
@@ -7460,48 +7623,11 @@ 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;
if (keys(%changes) > 0) {
$putresult = &Apache::lonnet::put_dom('configuration',\%helphash,$dom);
- } else {
- $putresult = 'ok';
- }
- if ($putresult eq 'ok') {
- if (keys(%changes) > 0) {
+ if ($putresult eq 'ok') {
$resulttext = &mt('Changes made:').'
';
foreach my $item (sort(keys(%changes))) {
if ($item eq 'submitbugs') {
@@ -7509,30 +7635,17 @@ sub modify_helpsettings {
&Apache::loncommon::modal_link('http://bugs.loncapa.org',
&mt('LON-CAPA bug tracker'),600,500)).'';
}
- if ($item eq 'loginhelpurl') {
- if ($helphash{'helpsettings'}{'loginhelpurl'} eq '') {
- $resulttext .= '
'.&mt('custom log-in help file removed.').' '.
- &Apache::loncommon::modal_link($defaulthelpfile,
- $defaulttext,600,500).'