--- loncom/interface/domainprefs.pm 2022/02/15 04:28:01 1.406
+++ loncom/interface/domainprefs.pm 2022/07/26 01:11:43 1.411
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Handler to set domain-wide configuration settings
#
-# $Id: domainprefs.pm,v 1.406 2022/02/15 04:28:01 raeburn Exp $
+# $Id: domainprefs.pm,v 1.411 2022/07/26 01:11:43 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -327,7 +327,9 @@ sub handler {
header => [{col1 => 'Setting',
col2 => 'Value'},
{col1 => 'Institutional user types',
- col2 => 'Name displayed'}],
+ col2 => 'Name displayed'},
+ {col1 => 'Mapping for missing usernames via standard log-in',
+ col2 => 'Rules in use'}],
print => \&print_defaults,
modify => \&modify_defaults,
},
@@ -983,7 +985,7 @@ sub print_config_box {
if (($action eq 'autoupdate') || ($action eq 'usercreation') ||
($action eq 'selfcreation') || ($action eq 'selfenrollment') ||
($action eq 'usersessions') || ($action eq 'coursecategories') ||
- ($action eq 'trust') || ($action eq 'contacts') ||
+ ($action eq 'trust') || ($action eq 'contacts') || ($action eq 'defaults') ||
($action eq 'privacy') || ($action eq 'passwords') || ($action eq 'lti')) {
if ($action eq 'coursecategories') {
$output .= &print_coursecategories('middle',$dom,$item,$settings,\$rowtotal);
@@ -1071,8 +1073,8 @@ sub print_config_box {
}
$rowtotal ++;
} elsif (($action eq 'usermodification') || ($action eq 'coursedefaults') ||
- ($action eq 'defaults') || ($action eq 'directorysrch') ||
- ($action eq 'helpsettings') || ($action eq 'wafproxy')) {
+ ($action eq 'directorysrch') || ($action eq 'helpsettings') ||
+ ($action eq 'wafproxy')) {
$output .= $item->{'print'}->('bottom',$dom,$settings,\$rowtotal);
} elsif ($action eq 'scantron') {
$output .= $item->{'print'}->($r,'bottom',$dom,$confname,$settings,\$rowtotal);
@@ -1632,7 +1634,7 @@ sub print_login {
$styleon{$lonhost} = 'display:none';
$styleoff{$lonhost} = '';
}
- if (ref($settings->{'saml'}) eq 'HASH') {
+ if ((ref($settings) eq 'HASH') && (ref($settings->{'saml'}) eq 'HASH')) {
foreach my $lonhost (keys(%{$settings->{'saml'}})) {
if (ref($settings->{'saml'}{$lonhost}) eq 'HASH') {
$saml{$lonhost} = 1;
@@ -10467,7 +10469,7 @@ sub user_formats_row {
'username' => 'new usernames',
'id' => 'IDs',
);
- unless ($type eq 'email') {
+ unless (($type eq 'email') || ($type eq 'unamemap')) {
my $css_class = $rowcount%2?' class="LC_odd_row"':'';
$output = '
'.
''.
@@ -10522,9 +10524,9 @@ sub user_formats_row {
} elsif ($colsleft == 1) {
$output .= ' | | ';
}
- $output .= '
';
- unless ($type eq 'email') {
- $output .= '';
+ $output .= '';
+ unless (($type eq 'email') || ($type eq 'unamemap')) {
+ $output .= '';
}
return $output;
}
@@ -10667,7 +10669,7 @@ sub print_defaults {
$datatable .= '';
$rownum ++;
}
- } else {
+ } elsif ($position eq 'middle') {
my %defaults;
if (ref($settings) eq 'HASH') {
if ((ref($settings->{'inststatusorder'}) eq 'ARRAY') && (ref($settings->{'inststatustypes'}) eq 'HASH')) {
@@ -10717,6 +10719,22 @@ sub print_defaults {
$rownum ++;
}
}
+ } else {
+ my ($unamemaprules,$ruleorder) =
+ &Apache::lonnet::inst_userrules($dom,'unamemap');
+ $css_class = $rownum%2?' class="LC_odd_row"':'';
+ if ((ref($unamemaprules) eq 'HASH') && (ref($ruleorder) eq 'ARRAY')) {
+ my $numinrow = 2;
+ $datatable .= ''.&mt('Available conversions').' | '.
+ &user_formats_row('unamemap',$settings,$unamemaprules,
+ $ruleorder,$numinrow).
+ ' |
';
+ }
+ if ($datatable eq '') {
+ $datatable .= ''.
+ &mt('No rules set for domain in customized localenroll.pm').
+ ' |
';
+ }
}
$$rowtotal += $rownum;
return $datatable;
@@ -11568,7 +11586,7 @@ function warnInt$prefix(field) {
field.value.replace(/^\s+/,'');
field.value.replace(/\s+\$/,'');
var regexdigit=/^\\d+\$/;
- if (field.name == '$prefix\_min') {
+ if (field.name == '${prefix}_min') {
if (field.value == '') {
alert('$intalert{passmin}');
field.value = '$defmin';
@@ -11588,7 +11606,7 @@ function warnInt$prefix(field) {
field.value = '';
}
if (field.value != '') {
- if (field.name == '$prefix\_expire') {
+ if (field.name == '${prefix}_expire') {
var regexpposnum=/^\\d+(|\\.\\d*)\$/;
if (!regexpposnum.test(field.value)) {
alert('$intalert{passexp}');
@@ -11602,10 +11620,10 @@ function warnInt$prefix(field) {
}
} else {
if (!regexdigit.test(field.value)) {
- if (field.name == '$prefix\_max') {
+ if (field.name == '${prefix}_max') {
alert('$intalert{passmax}');
} else {
- if (field.name == '$prefix\_numsaved') {
+ if (field.name == '${prefix}_numsaved') {
alert('$intalert{passnum}');
}
}
@@ -16301,6 +16319,11 @@ sub modify_lti {
$dom,$hostid);
}
}
+ if (ref($lastactref) eq 'HASH') {
+ if (($secchanges{'encrypt'}) || ($secchanges{'private'})) {
+ $lastactref->{'domdefaults'} = 1;
+ }
+ }
}
&Apache::lonnet::put_dom('encconfig',\%ltienchash,$dom,undef,1);
if ((keys(%changes) == 0) && (keys(%secchanges) == 0)) {
@@ -19967,6 +19990,41 @@ sub modify_defaults {
$newvalues{$item} = $staticdefaults{$item};
}
}
+ my ($unamemaprules,$ruleorder);
+ my @possunamemaprules = &Apache::loncommon::get_env_multiple('form.unamemap_rule');
+ if (@possunamemaprules) {
+ ($unamemaprules,$ruleorder) =
+ &Apache::lonnet::inst_userrules($dom,'unamemap');
+ if ((ref($unamemaprules) eq 'HASH') && (ref($ruleorder) eq 'ARRAY')) {
+ if (@{$ruleorder} > 0) {
+ my %possrules;
+ map { $possrules{$_} = 1; } @possunamemaprules;
+ foreach my $rule (@{$ruleorder}) {
+ if ($possrules{$rule}) {
+ push(@{$newvalues{'unamemap_rule'}},$rule);
+ }
+ }
+ }
+ }
+ }
+ if (ref($domdefaults{'unamemap_rule'}) eq 'ARRAY') {
+ if (ref($newvalues{'unamemap_rule'}) eq 'ARRAY') {
+ my @rulediffs = &Apache::loncommon::compare_arrays($domdefaults{'unamemap_rule'},
+ $newvalues{'unamemap_rule'});
+ if (@rulediffs) {
+ $changes{'unamemap_rule'} = 1;
+ $domdefaults{'unamemap_rule'} = $newvalues{'unamemap_rule'};
+ }
+ } elsif (@{$domdefaults{'unamemap_rule'}} > 0) {
+ $changes{'unamemap_rule'} = 1;
+ delete($domdefaults{'unamemap_rule'});
+ }
+ } elsif (ref($newvalues{'unamemap_rule'}) eq 'ARRAY') {
+ if (@{$newvalues{'unamemap_rule'}} > 0) {
+ $changes{'unamemap_rule'} = 1;
+ $domdefaults{'unamemap_rule'} = $newvalues{'unamemap_rule'};
+ }
+ }
my %defaults_hash = (
defaults => \%newvalues,
);
@@ -20081,6 +20139,26 @@ sub modify_defaults {
$resulttext .= ''.&mt('Institutional user status types deleted').'';
}
}
+ } elsif ($item eq 'unamemap_rule') {
+ if (ref($newvalues{'unamemap_rule'}) eq 'ARRAY') {
+ my @rulenames;
+ if (ref($unamemaprules) eq 'HASH') {
+ foreach my $rule (@{$newvalues{'unamemap_rule'}}) {
+ if (ref($unamemaprules->{$rule}) eq 'HASH') {
+ push(@rulenames,$unamemaprules->{$rule}->{'name'});
+ }
+ }
+ }
+ if (@rulenames) {
+ $resulttext .= ''.&mt('Mapping for missing usernames includes: [_1]',
+ '').
+ '';
+ } else {
+ $resulttext .= ''.&mt('No mapping for missing usernames via standard log-in').'';
+ }
+ } else {
+ $resulttext .= ''.&mt('Mapping for missing usernames via standard log-in deleted').'';
+ }
} else {
my $value = $env{'form.'.$item};
if ($value eq '') {
@@ -22706,8 +22784,10 @@ sub modify_trust {
}
my $cachetime = 24*60*60;
&Apache::lonnet::do_cache_new('domdefaults',$dom,\%domdefaults,$cachetime);
+ &Apache::lonnet::do_cache_new('trust',$dom,$defaultshash{'trust'},3600);
if (ref($lastactref) eq 'HASH') {
$lastactref->{'domdefaults'} = 1;
+ $lastactref->{'trust'} = 1;
}
if (keys(%changes) > 0) {
my %lt = &trust_titles();
@@ -23776,7 +23856,7 @@ sub devalidate_remote_domconfs {
map { $thismachine{$_} = 1; } &Apache::lonnet::current_machine_ids();
my @posscached = ('domainconfig','domdefaults','ltitools','usersessions',
'directorysrch','passwdconf','cats','proxyalias','proxysaml',
- 'ipaccess');
+ 'ipaccess','trust');
my %cache_by_lonhost;
if (exists($cachekeys->{'samllanding'})) {
if (ref($cachekeys->{'samllanding'}) eq 'HASH') {