--- loncom/interface/domainprefs.pm 2021/12/30 02:40:28 1.160.6.118
+++ loncom/interface/domainprefs.pm 2024/12/31 18:56:23 1.160.6.126
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Handler to set domain-wide configuration settings
#
-# $Id: domainprefs.pm,v 1.160.6.118 2021/12/30 02:40:28 raeburn Exp $
+# $Id: domainprefs.pm,v 1.160.6.126 2024/12/31 18:56:23 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -268,7 +268,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,
},
@@ -822,7 +824,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 'contacts') || ($action eq 'passwords')) {
+ ($action eq 'contacts') || ($action eq 'passwords') || ($action eq 'defaults')) {
if ($action eq 'coursecategories') {
$output .= &print_coursecategories('middle',$dom,$item,$settings,\$rowtotal);
$colspan = ' colspan="2"';
@@ -876,8 +878,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);
@@ -1165,6 +1167,7 @@ sub print_login {
}
}
my @images = ('img','logo','domlogo','login');
+ my @alttext = ('img','logo','domlogo');
my @logintext = ('textcol','bgcol');
my @bgs = ('pgbg','mainbg','sidebg');
my @links = ('link','alink','vlink');
@@ -1206,6 +1209,13 @@ sub print_login {
$designs{'showlogo'}{$item} = $settings->{'showlogo'}{$item};
}
}
+ foreach my $item (@alttext) {
+ if (ref($settings->{'alttext'}) eq 'HASH') {
+ if ($settings->{'alttext'}->{$item} ne '') {
+ $designs{'alttext'}{$item} = $settings->{'alttext'}{$item};
+ }
+ }
+ }
foreach my $item (@logintext) {
if ($settings->{$item} ne '') {
$designs{'logintext'}{$item} = $settings->{$item};
@@ -1407,7 +1417,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;
@@ -1515,6 +1525,7 @@ sub login_choices {
current => "Current",
samllanding => "Dual login?",
samloptions => "Options",
+ alttext => "Alt text",
);
return %choices;
}
@@ -1716,7 +1727,7 @@ sub print_rolecolors {
my %choices = &color_font_choices();
my @bgs = ('pgbg','tabbg','sidebg');
my @links = ('link','alink','vlink');
- my @images = ('img');
+ my @images = ();
my %alt_text = &Apache::lonlocal::texthash(img => "Banner for $role role");
my %designhash = &Apache::loncommon::get_domainconf($dom);
my %defaultdesign = %Apache::loncommon::defaultdesign;
@@ -1724,10 +1735,6 @@ sub print_rolecolors {
my %defaults = &role_defaults($role,\@bgs,\@links,\@images);
if (ref($settings) eq 'HASH') {
if (ref($settings->{$role}) eq 'HASH') {
- if ($settings->{$role}->{'img'} ne '') {
- $designs{'img'} = $settings->{$role}->{'img'};
- $is_custom{'img'} = 1;
- }
if ($settings->{$role}->{'font'} ne '') {
$designs{'font'} = $settings->{$role}->{'font'};
$is_custom{'font'} = 1;
@@ -1750,10 +1757,6 @@ sub print_rolecolors {
}
}
} else {
- if ($designhash{$dom.'.'.$role.'.img'} ne '') {
- $designs{img} = $designhash{$dom.'.'.$role.'.img'};
- $is_custom{'img'} = 1;
- }
if ($designhash{$dom.'.'.$role.'.fontmenu'} ne '') {
$designs{fontmenu} = $designhash{$dom.'.'.$role.'.fontmenu'};
$is_custom{'fontmenu'} = 1;
@@ -1803,7 +1806,6 @@ sub role_defaults {
}
} else {
%defaults = (
- img => $defaultdesign{$role.'.img'},
font => $defaultdesign{$role.'.font'},
fontmenu => $defaultdesign{$role.'.fontmenu'},
);
@@ -1860,7 +1862,7 @@ sub display_color_options {
$css_class = $itemcount%2?' class="LC_odd_row"':'';
$datatable .= '
'.
''.$choices->{$img};
- my ($imgfile,$img_import,$login_hdr_pick,$logincolors);
+ my ($imgfile,$img_import,$login_hdr_pick,$logincolors,$alttext);
if ($role eq 'login') {
if ($img eq 'login') {
$login_hdr_pick =
@@ -1868,8 +1870,13 @@ sub display_color_options {
$logincolors =
&login_text_colors($img,$role,$logintext,$phase,$choices,
$designs,$defaults);
- } elsif ($img ne 'domlogo') {
- $datatable.= &logo_display_options($img,$defaults,$designs);
+ } else {
+ if ($img ne 'domlogo') {
+ $datatable.= &logo_display_options($img,$defaults,$designs);
+ }
+ if (ref($designs->{'alttext'}) eq 'HASH') {
+ $alttext = $designs->{'alttext'}{$img};
+ }
}
}
$datatable .= ' | ';
@@ -1961,6 +1968,11 @@ sub display_color_options {
$datatable .=' ';
}
}
+ if (($role eq 'login') && ($img ne 'login')) {
+ $datatable .= (' ' x2).' ';
+ }
$datatable .= '
';
}
$itemcount ++;
@@ -5502,8 +5514,10 @@ sub print_wafproxy {
my $dom_in_effect;
my $aliasrows = ''.
''.
- &mt('Hostname').': '.
- ''.&Apache::lonnet::hostname($server).' | | ';
+ &mt('Hostname').': '.
+ ''.
+ &Apache::lonnet::hostname($server).
+ ' | ';
if ($othercontrol{$server}) {
$dom_in_effect = $othercontrol{$server};
my ($current,$forsaml);
@@ -7405,7 +7419,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 = '
'.
''.
@@ -7460,9 +7474,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;
}
@@ -7603,7 +7617,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')) {
@@ -7653,6 +7667,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;
@@ -9695,7 +9725,6 @@ sub check_exempt_addresses {
sub color_font_choices {
my %choices =
&Apache::lonlocal::texthash (
- img => "Header",
bgs => "Background colors",
links => "Link colors",
images => "Images",
@@ -9750,13 +9779,15 @@ sub modify_ipaccess {
foreach my $idx (@items) {
my $itemid = $itemids{$idx};
next unless ($itemid);
- my %current;
- unless ($idx eq 'add') {
+ my ($position,%current);
+ if ($idx eq 'add') {
+ $position = $env{'form.ipaccess_pos_add'};
+ } else {
+ $position = $env{'form.ipaccess_pos_'.$itemid};
if (ref($domconfig{'ipaccess'}{$itemid}) eq 'HASH') {
%current = %{$domconfig{'ipaccess'}{$itemid}};
}
}
- my $position = $env{'form.ipaccess_pos_'.$itemid};
$position =~ s/\D+//g;
if ($position ne '') {
$allpos[$position] = $itemid;
@@ -10044,11 +10075,15 @@ sub modify_colors {
@images = ('img','logo','domlogo','login');
@bgs = ('pgbg','mainbg','sidebg');
} else {
- @images = ('img');
+ @images = ();
@bgs = ('pgbg','tabbg','sidebg');
}
my %defaults = &role_defaults($role,\@bgs,\@links,\@images,\@logintext);
- unless ($env{'form.'.$role.'_font'} eq $defaults{'font'}) {
+ $env{'form.'.$role.'_font'} = lc($env{'form.'.$role.'_font'});
+ if ($env{'form.'.$role.'_font'} =~ /^\w+/) {
+ $env{'form.'.$role.'_font'} = '#'.$env{'form.'.$role.'_font'};
+ }
+ unless ($env{'form.'.$role.'_font'} eq lc($defaults{'font'})) {
$confhash->{$role}{'font'} = $env{'form.'.$role.'_font'};
}
if ($role eq 'login') {
@@ -10066,7 +10101,7 @@ sub modify_colors {
if ($env{'form.'.$role.'_fontmenu'} =~ /^\w+/) {
$env{'form.'.$role.'_fontmenu'} = '#'.$env{'form.'.$role.'_fontmenu'};
}
- unless($env{'form.'.$role.'_fontmenu'} eq lc($defaults{'fontmenu'})) {
+ unless ($env{'form.'.$role.'_fontmenu'} eq lc($defaults{'fontmenu'})) {
$confhash->{$role}{'fontmenu'} = $env{'form.'.$role.'_fontmenu'};
}
}
@@ -10095,13 +10130,18 @@ sub modify_colors {
$domconfig->{$role} = {};
}
foreach my $img (@images) {
- if (($role eq 'login') && (($img eq 'img') || ($img eq 'logo'))) {
- if (defined($env{'form.login_showlogo_'.$img})) {
- $confhash->{$role}{'showlogo'}{$img} = 1;
- } else {
- $confhash->{$role}{'showlogo'}{$img} = 0;
+ if ($role eq 'login') {
+ if (($img eq 'img') || ($img eq 'logo')) {
+ if (defined($env{'form.login_showlogo_'.$img})) {
+ $confhash->{$role}{'showlogo'}{$img} = 1;
+ } else {
+ $confhash->{$role}{'showlogo'}{$img} = 0;
+ }
}
- }
+ if ($env{'form.login_alt_'.$img} ne '') {
+ $confhash->{$role}{'alttext'}{$img} = $env{'form.login_alt_'.$img};
+ }
+ }
if ( ! $env{'form.'.$role.'_'.$img.'.filename'}
&& !defined($domconfig->{$role}{$img})
&& !$env{'form.'.$role.'_del_'.$img}
@@ -10176,15 +10216,29 @@ sub modify_colors {
$changes{$role}{'images'}{$img} = 1;
}
}
- if (($role eq 'login') && (($img eq 'logo') || ($img eq 'img'))) {
- if (ref($domconfig->{'login'}{'showlogo'}) eq 'HASH') {
- if ($confhash->{$role}{'showlogo'}{$img} ne
- $domconfig->{$role}{'showlogo'}{$img}) {
- $changes{$role}{'showlogo'}{$img} = 1;
+ if ($role eq 'login') {
+ if (($img eq 'logo') || ($img eq 'img')) {
+ if (ref($domconfig->{'login'}{'showlogo'}) eq 'HASH') {
+ if ($confhash->{$role}{'showlogo'}{$img} ne
+ $domconfig->{$role}{'showlogo'}{$img}) {
+ $changes{$role}{'showlogo'}{$img} = 1;
+ }
+ } else {
+ if ($confhash->{$role}{'showlogo'}{$img} == 0) {
+ $changes{$role}{'showlogo'}{$img} = 1;
+ }
}
- } else {
- if ($confhash->{$role}{'showlogo'}{$img} == 0) {
- $changes{$role}{'showlogo'}{$img} = 1;
+ }
+ if ($img ne 'login') {
+ if (ref($domconfig->{$role}{'alttext'}) eq 'HASH') {
+ if ($confhash->{$role}{'alttext'}{$img} ne
+ $domconfig->{$role}{'alttext'}{$img}) {
+ $changes{$role}{'alttext'}{$img} = 1;
+ }
+ } else {
+ if ($confhash->{$role}{'alttext'}{$img} ne '') {
+ $changes{$role}{'alttext'}{$img} = 1;
+ }
}
}
}
@@ -10295,6 +10349,11 @@ sub default_change_checker {
if ($confhash->{$role}{'showlogo'}{$img} == 0) {
$changes->{$role}{'showlogo'}{$img} = 1;
}
+ if (ref($confhash->{$role}{'alttext'}) eq 'HASH') {
+ if ($confhash->{$role}{'alttext'}{$img} ne '') {
+ $changes->{$role}{'alttext'}{$img} = 1;
+ }
+ }
}
}
if ($confhash->{$role}{'font'}) {
@@ -10333,6 +10392,13 @@ sub display_colorchgs {
} else {
$resulttext .= ''.&mt("$choices{$item} set to not be displayed").'';
}
+ } elsif (($role eq 'login') && ($key eq 'alttext')) {
+ if ($confhash->{$role}{$key}{$item} ne '') {
+ $resulttext .= ''.&mt("$choices{$key} for $choices{$item} set to [_1].",
+ $confhash->{$role}{$key}{$item}).'';
+ } else {
+ $resulttext .= ''.&mt("$choices{$key} for $choices{$item} deleted.").'';
+ }
} elsif ($confhash->{$role}{$item} eq '') {
$resulttext .= ''.&mt("$choices{$item} set to default").'';
} else {
@@ -11384,6 +11450,7 @@ sub modify_quotas {
$resulttext .= ''.&mt('Validated course requests identified as processed by: [_1]',
''.$changes{'validation'}{'dc'}.'').'';
}
+ $resulttext .= '';
}
}
}
@@ -14533,6 +14600,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,
);
@@ -14649,6 +14751,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 '') {
@@ -16543,6 +16665,7 @@ sub modify_wafproxy {
}
}
}
+ $output .= '';
} else {
$output = ''.
&mt('An error occurred: [_1]',$putresult).'';