--- loncom/interface/domainprefs.pm 2025/01/11 16:10:31 1.447.2.1
+++ loncom/interface/domainprefs.pm 2025/01/14 13:38:26 1.447.2.5
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Handler to set domain-wide configuration settings
#
-# $Id: domainprefs.pm,v 1.447.2.1 2025/01/11 16:10:31 raeburn Exp $
+# $Id: domainprefs.pm,v 1.447.2.5 2025/01/14 13:38:26 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -563,11 +563,7 @@ sub handler {
header => [{col1 => 'Role assigned in different domain',
col2 => 'Approval options'},
{col1 => 'Role assigned in different domain to user of type',
- col2 => 'User information available in that domain'},
- {col1 => "Role assigned in user's domain",
- col2 => 'Information viewable by privileged user'},
- {col1 => "Role assigned in user's domain",
- col2 => 'Information viewable by unprivileged user'}],
+ col2 => 'User information available in that domain'}],
print => \&print_privacy,
modify => \&modify_privacy,
},
@@ -1008,8 +1004,8 @@ sub print_config_box {
($action eq 'selfcreation') || ($action eq 'selfenrollment') ||
($action eq 'usersessions') || ($action eq 'coursecategories') ||
($action eq 'trust') || ($action eq 'contacts') || ($action eq 'defaults') ||
- ($action eq 'privacy') || ($action eq 'passwords') || ($action eq 'lti') ||
- ($action eq 'ltitools') || ($action eq 'usermodification')) {
+ ($action eq 'passwords') || ($action eq 'lti') || ($action eq 'ltitools') ||
+ ($action eq 'usermodification')) {
if ($action eq 'coursecategories') {
$output .= &print_coursecategories('middle',$dom,$item,$settings,\$rowtotal);
$colspan = ' colspan="2"';
@@ -1079,8 +1075,8 @@ sub print_config_box {
'."\n";
if ($action eq 'coursecategories') {
$output .= &print_coursecategories('bottom',$dom,$item,$settings,\$rowtotal);
- } elsif (($action eq 'contacts') || ($action eq 'privacy') ||
- ($action eq 'passwords') || ($action eq 'lti')) {
+ } elsif (($action eq 'contacts') || ($action eq 'passwords') ||
+ ($action eq 'lti')) {
if ($action eq 'passwords') {
$output .= $item->{'print'}->('lower',$dom,$confname,$settings,\$rowtotal);
} else {
@@ -1115,7 +1111,7 @@ sub print_config_box {
$rowtotal ++;
} elsif (($action eq 'coursedefaults') || ($action eq 'authordefaults') ||
($action eq 'directorysrch') || ($action eq 'helpsettings') ||
- ($action eq 'wafproxy')) {
+ ($action eq 'wafproxy') || ($action eq 'privacy')) {
$output .= $item->{'print'}->('bottom',$dom,$settings,\$rowtotal);
} elsif ($action eq 'scantron') {
$output .= $item->{'print'}->($r,'bottom',$dom,$confname,$settings,\$rowtotal);
@@ -7789,7 +7785,7 @@ sub print_privacy {
($othertitle,$usertypes,$types) =
&Apache::loncommon::sorted_inst_types($dom);
}
- if (($position eq 'top') || ($position eq 'middle')) {
+ if (($position eq 'top') || ($position eq 'bottom')) {
my (%by_ip,%by_location,@intdoms,@instdoms);
&build_location_hashes(\@intdoms,\%by_ip,\%by_location,\@instdoms);
if ($position eq 'top') {
@@ -7876,7 +7872,7 @@ sub print_privacy {
$datatable .= &mt('Nothing to set here, as there are no other domains');
}
$datatable .='';
- } elsif ($position eq 'middle') {
+ } elsif ($position eq 'bottom') {
if ((@instdoms > 1) || (keys(%by_location) > 0)) {
if ((ref($types) eq 'ARRAY') && (ref($usertypes) eq 'HASH')) {
foreach my $item (@{$types}) {
@@ -7913,19 +7909,6 @@ sub print_privacy {
}
}
}
- } else {
- my $prefix;
- if ($position eq 'lower') {
- $prefix = 'priv';
- } else {
- $prefix = 'unpriv';
- }
- foreach my $item (@items) {
- $datatable .= &modifiable_userdata_row('privacy',$prefix.'_'.$item,$settings,
- $numinrow,$itemcount,'','','','','',
- '',$names{$item});
- $itemcount ++;
- }
}
if (ref($rowtotal)) {
$$rowtotal += $itemcount;
@@ -7954,7 +7937,6 @@ sub print_passwords {
min => 'Minimum password length',
max => 'Maximum password length',
chars => 'Required characters',
- expire => 'Password expiration (days)',
numsaved => 'Number of previous passwords to save and disallow reuse',
);
if ($position eq 'top') {
@@ -8281,7 +8263,7 @@ sub print_passwords {
sub password_rules {
my ($prefix,$itemcountref,$settings) = @_;
- my ($min,$max,%chars,$expire,$numsaved,$numinrow);
+ my ($min,$max,%chars,$numsaved,$numinrow);
my %titles;
if ($prefix eq 'passwords') {
%titles = &Apache::lonlocal::texthash (
@@ -8313,9 +8295,6 @@ sub password_rules {
map { $chars{$_} = 1; } (@{$settings->{chars}});
}
if ($prefix eq 'passwords') {
- if ($settings->{expire}) {
- $expire = $settings->{expire};
- }
if ($settings->{numsaved}) {
$numsaved = $settings->{numsaved};
}
@@ -8377,17 +8356,8 @@ sub password_rules {
$datatable .='';
$itemcount ++;
if ($prefix eq 'passwords') {
- $titles{'expire'} = &mt('Password expiration (days)');
$titles{'numsaved'} = &mt('Number of previous passwords to save and disallow reuse');
$css_class = $itemcount%2?' class="LC_odd_row"':'';
- $datatable .= '
'.$titles{'expire'}.' | '.
- ''.
- ''.
- ' '.&mt('(Leave blank for no expiration)').''.
- ' |
';
- $itemcount ++;
- $css_class = $itemcount%2?' class="LC_odd_row"':'';
$datatable .= ''.$titles{'numsaved'}.' | '.
''.
'{'instdata'};
+ my %instdata;
+ if (ref($settings->{'instdata'}) eq 'ARRAY') {
+ map { $instdata{$_} = 1; } @{$settings->{'instdata'}};
+ }
+ $hashref = \%instdata;
}
} elsif ($context eq 'privacy') {
my ($key,$inner) = split(/_/,$role);
@@ -12127,7 +12087,7 @@ sub modifiable_userdata_row {
}
} elsif (ref($settings->{$context}) eq 'HASH') {
if (ref($settings->{$context}->{$role}) eq 'HASH') {
- $hashref = $settings->{'lti_instdata'};
+ $hashref = $settings->{$context}->{$role};
}
if ($role eq 'emailusername') {
if ($statustype) {
@@ -16063,9 +16023,9 @@ sub modify_lti {
}
my @possinstdata = &Apache::loncommon::get_env_multiple('form.lti_instdata_'.$idx);
if (@possinstdata) {
- foreach my $field (@possinstdata) {
+ foreach my $field (sort(@possinstdata)) {
if (exists($fieldtitles{$field})) {
- push(@{$confhash{$itemid}{'instdata'}});
+ push(@{$confhash{$itemid}{'instdata'}},$field);
}
}
}
@@ -16227,7 +16187,7 @@ sub modify_lti {
}
}
unless ($changes{$itemid}) {
- foreach my $field ('makeuser','lcmenu') {
+ foreach my $field ('makeuser','lcmenu','instdata') {
if (ref($currlti{$field}) eq 'ARRAY') {
if (ref($confhash{$itemid}{$field}) eq 'ARRAY') {
my @diffs = &Apache::loncommon::compare_arrays($currlti{$field},
@@ -16441,8 +16401,10 @@ sub modify_lti {
$resulttext .= ''.&mt('Institutional data will be used when creating a new user for: [_1]',
join(', ',map { $fieldtitles{$_}; } @{$confhash{$itemid}{'instdata'}})).'';
} else {
- $resulttext .= ''.&mt('No institutional data used when creating a new user.').'';
+ $resulttext .= ''.&mt('No institutional data used when creating a new user').'';
}
+ } else {
+ $resulttext .= ''.&mt('No institutional data used when creating a new user').'';
}
foreach my $item ('topmenu','inlinemenu') {
$resulttext .= ''.$lt{$item}.': ';
@@ -17904,8 +17866,6 @@ sub modify_privacy {
extdom => {},
},
'othdom' => {},
- 'priv' => {},
- 'unpriv' => {},
);
foreach my $item (@items) {
if (@instdoms > 1) {
@@ -17936,39 +17896,6 @@ sub modify_privacy {
$changes{'approval'} = 1;
}
}
- foreach my $status ('priv','unpriv') {
- my @possibles = sort(&Apache::loncommon::get_env_multiple('form.privacy_'.$status.'_'.$item));
- my @newvalues;
- foreach my $field (@possibles) {
- if (grep(/^\Q$field\E$/,@fields)) {
- $privacyhash{$status}{$item}{$field} = 1;
- push(@newvalues,$field);
- }
- }
- @newvalues = sort(@newvalues);
- if (ref($current{$status}) eq 'HASH') {
- if (ref($current{$status}{$item}) eq 'HASH') {
- my @currvalues = sort(keys(%{$current{$status}{$item}}));
- my @diffs = &Apache::loncommon::compare_arrays(\@currvalues,\@newvalues);
- if (@diffs > 0) {
- $changes{$status} = 1;
- }
- }
- } else {
- my @stdfields;
- foreach my $field (@fields) {
- if ($field eq 'id') {
- next if ($status eq 'unpriv');
- next if (($status eq 'priv') && ($item eq 'community'));
- }
- push(@stdfields,$field);
- }
- my @diffs = &Apache::loncommon::compare_arrays(\@stdfields,\@newvalues);
- if (@diffs > 0) {
- $changes{$status} = 1;
- }
- }
- }
}
if ((@instdoms > 1) || (keys(%by_location) > 0)) {
my @statuses;
@@ -17992,6 +17919,8 @@ sub modify_privacy {
if (@diffs > 0) {
$changes{'othdom'} = 1;
}
+ } elsif (@newvalues > 0) {
+ $changes{'othdom'} = 1;
}
} else {
my @stdfields = ('lastname','firstname','middlename','generation','permanentemail');
@@ -18021,7 +17950,7 @@ sub modify_privacy {
if ($putresult eq 'ok') {
if (keys(%changes) > 0) {
$resulttext = &mt('Changes made: ').'';
- foreach my $key ('approval','notify','othdom','priv','unpriv') {
+ foreach my $key ('approval','notify','othdom') {
if ($changes{$key}) {
$resulttext .= '- '.$titles{$key}.':
';
if ($key eq 'approval') {
@@ -18072,18 +18001,6 @@ sub modify_privacy {
$resulttext .= ' ';
}
}
- } else {
- foreach my $item (@items) {
- if (ref($privacyhash{$key}{$item}) eq 'HASH') {
- $resulttext .= '- '.$names{$item}.': ';
- if (keys(%{$privacyhash{$key}{$item}})) {
- $resulttext .= join(', ', map { $fieldnames{$_}; } (sort(keys(%{$privacyhash{$key}{$item}}))));
- } else {
- $resulttext .= &mt('none');
- }
- $resulttext .= '
';
- }
- }
}
$resulttext .= ' ';
}
@@ -18146,7 +18063,6 @@ sub modify_passwords {
min => 'Minimum password length',
max => 'Maximum password length',
chars => 'Required characters',
- expire => 'Password expiration (days)',
numsaved => 'Number of previous passwords to save',
reset => 'Resetting Forgotten Password',
intauth => 'Encryption of Stored Passwords (Internal Auth)',
@@ -18530,7 +18446,7 @@ sub modify_passwords {
$resulttext .= ''.&mt('[_1] set to "[_2]"',$titles{$key.'_'.$item},$value).'';
}
} elsif ($key eq 'rules') {
- foreach my $rule ('min','max','expire','numsaved') {
+ foreach my $rule ('min','max','numsaved') {
if ($confighash{'passwords'}{$rule} eq '') {
if ($rule eq 'min') {
$resulttext .= ''.&mt('[_1] not set.',$titles{$rule});
@@ -18625,7 +18541,7 @@ sub password_rule_changes {
(ref($changes) eq 'HASH'));
my (@rules,%staticdefaults);
if ($prefix eq 'passwords') {
- @rules = ('min','max','expire','numsaved');
+ @rules = ('min','max','numsaved');
} elsif (($prefix eq 'ltisecrets') || ($prefix eq 'toolsecrets')) {
@rules = ('min','max');
}
@@ -18633,12 +18549,7 @@ sub password_rule_changes {
foreach my $rule (@rules) {
$env{'form.'.$prefix.'_'.$rule} =~ s/^\s+|\s+$//g;
my $ruleok;
- if ($rule eq 'expire') {
- if (($env{'form.'.$prefix.'_'.$rule} =~ /^\d+(|\.\d*)$/) &&
- ($env{'form.'.$prefix.'_'.$rule} ne '0')) {
- $ruleok = 1;
- }
- } elsif ($rule eq 'min') {
+ if ($rule eq 'min') {
if ($env{'form.'.$prefix.'_'.$rule} =~ /^\d+$/) {
if ($env{'form.'.$prefix.'_'.$rule} >= $staticdefaults{$rule}) {
$ruleok = 1;
|