';
+
+ }
+
+ return $datatable;
+
}
+
sub radiobutton_prefs {
my ($settings,$toggles,$defaultchecked,$choices,$itemcount) = @_;
return unless ((ref($toggles) eq 'ARRAY') && (ref($defaultchecked) eq 'HASH') &&
@@ -3100,9 +3003,8 @@ sub contact_titles {
sub tool_titles {
my %titles = &Apache::lonlocal::texthash (
- aboutme => 'Personal web page',
+ aboutme => 'Personal Information Page',
blog => 'Blog',
- webdav => 'WebDAV',
portfolio => 'Portfolio',
official => 'Official courses (with institutional codes)',
unofficial => 'Unofficial courses',
@@ -3125,15 +3027,6 @@ sub courserequest_titles {
return %titles;
}
-sub authorrequest_titles {
- my %titles = &Apache::lonlocal::texthash (
- norequest => 'Not allowed',
- approval => 'Approval by Dom. Coord.',
- automatic => 'Automatic approval',
- );
- return %titles;
-}
-
sub courserequest_conditions {
my %conditions = &Apache::lonlocal::texthash (
approval => '(Processing of request subject to approval by Domain Coordinator).',
@@ -3263,20 +3156,18 @@ sub print_usercreation {
}
my ($othertitle,$usertypes,$types) =
&Apache::loncommon::sorted_inst_types($dom);
- my $createsettings;
- if (ref($settings) eq 'HASH') {
- $createsettings = $settings->{cancreate};
- }
if (ref($usertypes) eq 'HASH') {
if (keys(%{$usertypes}) > 0) {
+ my $createsettings;
+ if (ref($settings) eq 'HASH') {
+ $createsettings = $settings->{cancreate};
+ }
$datatable .= &insttypes_row($createsettings,$types,$usertypes,
$dom,$numinrow,$othertitle,
'statustocreate');
$$rowtotal ++;
- $rownum ++;
}
}
- $datatable .= &captcha_choice('cancreate',$createsettings,$rownum);
} else {
my @contexts = ('author','course','domain');
my @authtypes = ('int','krb4','krb5','loc');
@@ -3328,64 +3219,6 @@ sub print_usercreation {
return $datatable;
}
-sub captcha_choice {
- my ($context,$settings,$itemcount) = @_;
- my ($keyentry,$currpub,$currpriv,%checked,$rowname,$pubtext,$privtext);
- my %lt = &captcha_phrases();
- $keyentry = 'hidden';
- if ($context eq 'cancreate') {
- $rowname = &mt('CAPTCHA validation (e-mail as username)');
- } elsif ($context eq 'login') {
- $rowname = &mt('"Contact helpdesk" CAPTCHA validation');
- }
- if (ref($settings) eq 'HASH') {
- if ($settings->{'captcha'}) {
- $checked{$settings->{'captcha'}} = ' checked="checked"';
- } else {
- $checked{'original'} = ' checked="checked"';
- }
- if ($settings->{'captcha'} eq 'recaptcha') {
- $pubtext = $lt{'pub'};
- $privtext = $lt{'priv'};
- $keyentry = 'text';
- }
- if (ref($settings->{'recaptchakeys'}) eq 'HASH') {
- $currpub = $settings->{'recaptchakeys'}{'public'};
- $currpriv = $settings->{'recaptchakeys'}{'private'};
- }
- } else {
- $checked{'original'} = ' checked="checked"';
- }
- my $css_class = $itemcount%2?' class="LC_odd_row"':'';
- my $output = '
'.
- '
'.$rowname.'
'."\n".
- '
'."\n";
- foreach my $option ('original','recaptcha','notused') {
- $output .= '';
- unless ($option eq 'notused') {
- $output .= (' 'x2)."\n";
- }
- }
-#
-# Note: If reCAPTCHA is to be used for LON-CAPA servers in a domain, a domain coordinator should visit:
-# https://www.google.com/recaptcha and generate a Public and Private key. For domains with multiple
-# servers a single key pair will be used for all servers, so the internet domain (e.g., yourcollege.edu)
-# specified for use with the key should be broad enough to accommodate all servers in the LON-CAPA domain.
-#
- $output .= '
';
- return $output;
-}
-
sub user_formats_row {
my ($type,$settings,$rules,$ruleorder,$numinrow,$rowcount) = @_;
my $output;
@@ -3560,12 +3393,6 @@ sub print_defaults {
} elsif ($item eq 'datelocale_def') {
my $includeempty = 1;
$datatable .= &Apache::loncommon::select_datelocale($item,$domdefaults{$item},undef,$includeempty);
- } elsif ($item eq 'lang_def') {
- my %langchoices = &get_languages_hash();
- $langchoices{''} = 'No language preference';
- %langchoices = &Apache::lonlocal::texthash(%langchoices);
- $datatable .= &Apache::loncommon::select_form($domdefaults{$item},$item,
- \%langchoices);
} else {
my $size;
if ($item eq 'portal_def') {
@@ -3581,17 +3408,6 @@ 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 (
@@ -4367,13 +4183,9 @@ sub insttypes_row {
if ($context eq 'cansearch') {
$showdom = ' ('.$dom.')';
}
- my $class = 'LC_left_item';
- if ($context eq 'statustocreate') {
- $class = 'LC_right_item';
- }
my $output = '
'.
'
'.$lt{$context}.$showdom.
- '
';
+ '
';
my $rem;
if (ref($types) eq 'ARRAY') {
for (my $i=0; $i<@{$types}; $i++) {
@@ -4503,13 +4315,13 @@ sub usertype_update_row {
sub modify_login {
my ($r,$dom,$confname,%domconfig) = @_;
- 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');
+ 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;
if (ref($domconfig{login}) eq 'HASH') {
if (ref($domconfig{login}{loginvia}) eq 'HASH') {
foreach my $lonhost (keys(%{$domconfig{login}{loginvia}})) {
@@ -4517,6 +4329,7 @@ sub modify_login {
}
}
}
+ my %loginhash;
($errors,%colchanges) = &modify_colors($r,$dom,$confname,['login'],
\%domconfig,\%loginhash);
my @toggles = ('coursecatalog','adminmail','newuser');
@@ -4589,6 +4402,7 @@ sub modify_login {
$new = '';
}
}
+
$loginhash{login}{loginvia}{$lonhost}{$item} = $new;
}
}
@@ -4614,96 +4428,6 @@ 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.'
';
- }
- }
- &process_captcha('login',\%changes,$loginhash{'login'},$domconfig{'login'});
-
- my $defaulthelpfile = '/adm/loginproblems.html';
- my $defaulttext = &mt('Default in use');
-
my $putresult = &Apache::lonnet::put_dom('configuration',\%loginhash,
$dom);
if ($putresult eq 'ok') {
@@ -4769,68 +4493,6 @@ 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 .= '
';
}
}
- if (($action eq 'requestcourses') || ($action eq 'requestauthor')) {
+ if ($action eq 'requestcourses') {
if (ref($changes{'notify'}) eq 'HASH') {
if ($changes{'notify'}{'approval'}) {
if (ref($confhash{'notify'}) eq 'HASH') {
if ($confhash{'notify'}{'approval'}) {
$resulttext .= '
'.&mt('Notification of requests requiring approval will be sent to: ').$confhash{'notify'}{'approval'}.'
';
} else {
- $resulttext .= '
'.&mt('No Domain Coordinators will receive notification of requests requiring approval.').'
';
+ $resulttext .= '
'.&mt('No Domain Coordinators will receive notification of course requests requiring approval.').'
';
}
}
}
@@ -5849,8 +5468,6 @@ sub modify_quotas {
} else {
if ($context eq 'requestcourses') {
$resulttext = &mt('No changes made to rights to request creation of courses.');
- } elsif ($context eq 'requestauthor') {
- $resulttext = &mt('No changes made to rights to request author space.');
} else {
$resulttext = &mt('No changes made to availability of personal information pages, blogs, portfolios or default quotas');
}
@@ -6545,7 +6162,6 @@ sub modify_usercreation {
}
push(@contexts,'statustocreate');
}
- &process_captcha('cancreate',\%changes,\%cancreate,\%curr_usercreation);
if (ref($curr_usercreation{'cancreate'}) eq 'HASH') {
foreach my $item (@contexts) {
if (($item eq 'selfcreate') || ($item eq 'statustocreate')) {
@@ -6728,7 +6344,7 @@ sub modify_usercreation {
my %lt = &usercreation_types();
foreach my $type (@{$changes{'cancreate'}}) {
my $chgtext;
- unless (($type eq 'statustocreate') || ($type eq 'captcha') || ($type eq 'recaptchakeys')) {
+ unless ($type eq 'statustocreate') {
$chgtext = $lt{$type}.', ';
}
if ($type eq 'selfcreate') {
@@ -6787,35 +6403,6 @@ sub modify_usercreation {
}
}
}
- } elsif ($type eq 'captcha') {
- if ($cancreate{$type} eq 'notused') {
- $chgtext .= &mt('No CAPTCHA validation in use for self-creation screen.');
- } else {
- my %captchas = &captcha_phrases();
- if ($captchas{$cancreate{$type}}) {
- $chgtext .= &mt("Validation for self-creation screen set to $captchas{$cancreate{$type}}.");
- } else {
- $chgtext .= &mt('Validation for self-creation screen set to unknown type.');
- }
- }
- } elsif ($type eq 'recaptchakeys') {
- my ($privkey,$pubkey);
- if (ref($cancreate{$type}) eq 'HASH') {
- $pubkey = $cancreate{$type}{'public'};
- $privkey = $cancreate{$type}{'private'};
- }
- $chgtext .= &mt('ReCAPTCHA keys changes').'
';
- if (!$pubkey) {
- $chgtext .= '
'.&mt('Public key deleted').'
';
- } else {
- $chgtext .= '
'.&mt('Public key set to [_1]',$pubkey).'
';
- }
- if (!$privkey) {
- $chgtext .= '
'.&mt('Private key deleted').'
';
- } else {
- $chgtext .= '
'.&mt('Private key set to [_1]',$pubkey).'
';
- }
- $chgtext .= '
';
} else {
if ($cancreate{$type} eq 'none') {
$chgtext .= &mt('creation of new users is not permitted, except by a Domain Coordinator.');
@@ -6915,57 +6502,6 @@ sub modify_usercreation {
return $resulttext;
}
-sub process_captcha {
- my ($container,$changes,$newsettings,$current) = @_;
- return unless ((ref($changes) eq 'HASH') && (ref($newsettings) eq 'HASH') || (ref($current) eq 'HASH'));
- $newsettings->{'captcha'} = $env{'form.'.$container.'_captcha'};
- unless ($newsettings->{'captcha'} eq 'recaptcha' || $newsettings->{'captcha'} eq 'notused') {
- $newsettings->{'captcha'} = 'original';
- }
- if ($current->{'captcha'} ne $newsettings->{'captcha'}) {
- if ($container eq 'cancreate') {
- if (ref($changes->{'cancreate'}) eq 'ARRAY') {
- push(@{$changes->{'cancreate'}},'captcha');
- } elsif (!defined($changes->{'cancreate'})) {
- $changes->{'cancreate'} = ['captcha'];
- }
- } else {
- $changes->{'captcha'} = 1;
- }
- }
- my ($newpub,$newpriv,$currpub,$currpriv);
- if ($newsettings->{'captcha'} eq 'recaptcha') {
- $newpub = $env{'form.'.$container.'_recaptchapub'};
- $newpriv = $env{'form.'.$container.'_recaptchapriv'};
- $newpub =~ s/\W//g;
- $newpriv =~ s/\W//g;
- $newsettings->{'recaptchakeys'} = {
- public => $newpub,
- private => $newpriv,
- };
- }
- if (ref($current->{'recaptchakeys'}) eq 'HASH') {
- $currpub = $current->{'recaptchakeys'}{'public'};
- $currpriv = $current->{'recaptchakeys'}{'private'};
- $newsettings->{'recaptchakeys'} = {
- public => '',
- private => '',
- }
- }
- if (($newpub ne $currpub) || ($newpriv ne $currpriv)) {
- if ($container eq 'cancreate') {
- if (ref($changes->{'cancreate'}) eq 'ARRAY') {
- push(@{$changes->{'cancreate'}},'recaptchakeys');
- } elsif (!defined($changes->{'cancreate'})) {
- $changes->{'cancreate'} = ['recaptchakeys'];
- }
- } else {
- $changes->{'recaptchakeys'} = 1;
- }
- }
- return;
-}
-
sub modify_usermodification {
my ($dom,%domconfig) = @_;
my ($resulttext,%curr_usermodification,%changes);
@@ -7622,56 +7158,122 @@ sub modify_serverstatuses {
sub modify_helpsettings {
my ($r,$dom,$confname,%domconfig) = @_;
- my ($resulttext,$errors,%changes,%helphash);
- my %defaultchecked = ('submitbugs' => 'on');
- my @offon = ('off','on');
+ 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',
+ 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') {
- if ($domconfig{'helpsettings'}{$item} eq '') {
- if ($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 '') {
- if ($env{'form.'.$item} eq '1') {
- $changes{$item} = 1;
- }
- } elsif ($domconfig{'helpsettings'}{$item} ne $env{'form.'.$item}) {
- $changes{$item} = 1;
- }
- }
- if (($env{'form.'.$item} eq '0') || ($env{'form.'.$item} eq '1')) {
- $helphash{'helpsettings'}{$item} = $env{'form.'.$item};
+
+ 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};
+ }
+
+ 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);
- if ($putresult eq 'ok') {
- $resulttext = &mt('Changes made:').'
';
- foreach my $item (sort(keys(%changes))) {
- if ($item eq 'submitbugs') {
- $resulttext .= '
'.&mt('Display link to: [_1] set to "'.$offon[$env{'form.'.$item}].'".',
- &Apache::loncommon::modal_link('http://bugs.loncapa.org',
- &mt('LON-CAPA bug tracker'),600,500)).'
';
- }
- }
- $resulttext .= '
';
- } else {
- $resulttext = &mt('No changes made to help settings');
- $errors .= '