--- loncom/interface/domainprefs.pm 2021/12/28 03:35:34 1.160.6.116
+++ loncom/interface/domainprefs.pm 2023/01/23 03:28:37 1.160.6.118.2.11
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Handler to set domain-wide configuration settings
#
-# $Id: domainprefs.pm,v 1.160.6.116 2021/12/28 03:35:34 raeburn Exp $
+# $Id: domainprefs.pm,v 1.160.6.118.2.11 2023/01/23 03:28:37 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -218,13 +218,43 @@ sub handler {
'serverstatuses','requestcourses','helpsettings',
'coursedefaults','usersessions','loadbalancing',
'requestauthor','selfenrollment','inststatus',
- 'passwords','wafproxy','ipaccess'],$dom);
+ 'passwords','ltitools','ltisec','wafproxy','ipaccess'],$dom);
+ my %encconfig =
+ &Apache::lonnet::get_dom('encconfig',['ltitools','linkprot'],$dom,undef,1);
+ if (ref($domconfig{'ltitools'}) eq 'HASH') {
+ if (ref($encconfig{'ltitools'}) eq 'HASH') {
+ foreach my $id (keys(%{$domconfig{'ltitools'}})) {
+ if (ref($domconfig{'ltitools'}{$id}) eq 'HASH') {
+ foreach my $item ('key','secret') {
+ $domconfig{'ltitools'}{$id}{$item} = $encconfig{'ltitools'}{$id}{$item};
+ }
+ }
+ }
+ }
+ }
+ if (ref($domconfig{'ltisec'}) eq 'HASH') {
+ if (ref($domconfig{'ltisec'}{'linkprot'}) eq 'HASH') {
+ if (ref($encconfig{'linkprot'}) eq 'HASH') {
+ foreach my $id (keys(%{$domconfig{'ltisec'}{'linkprot'}})) {
+ unless ($id =~ /^\d+$/) {
+ delete($domconfig{'ltisec'}{'linkprot'}{$id});
+ }
+ if ((ref($domconfig{'ltisec'}{'linkprot'}{$id}) eq 'HASH') &&
+ (ref($encconfig{'linkprot'}{$id}) eq 'HASH')) {
+ foreach my $item ('key','secret') {
+ $domconfig{'ltisec'}{'linkprot'}{$id}{$item} = $encconfig{'linkprot'}{$id}{$item};
+ }
+ }
+ }
+ }
+ }
+ }
my @prefs_order = ('rolecolors','login','ipaccess','defaults','wafproxy','passwords',
'quotas','autoenroll','autoupdate','autocreate','directorysrch',
'contacts','usercreation','selfcreation','usermodification',
'scantron','requestcourses','requestauthor','coursecategories',
'serverstatuses','helpsettings','coursedefaults',
- 'selfenrollment','usersessions');
+ 'ltitools','selfenrollment','usersessions','lti');
my %existing;
if (ref($domconfig{'loadbalancing'}) eq 'HASH') {
%existing = %{$domconfig{'loadbalancing'}};
@@ -268,7 +298,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,
},
@@ -298,7 +330,7 @@ sub handler {
modify => \&modify_passwords,
},
'quotas' =>
- { text => 'Blogs, personal web pages, webDAV/quotas, portfolios',
+ { text => 'Blogs, personal pages/timezones, webDAV/quotas, portfolio',
help => 'Domain_Configuration_Quotas',
header => [{col1 => 'User affiliation',
col2 => 'Available tools',
@@ -506,6 +538,26 @@ sub handler {
print => \&print_loadbalancing,
modify => \&modify_loadbalancing,
},
+ 'ltitools' =>
+ {text => 'External Tools (LTI)',
+ help => 'Domain_Configuration_LTI_Tools',
+ header => [{col1 => 'Setting',
+ col2 => 'Value',}],
+ print => \&print_ltitools,
+ modify => \&modify_ltitools,
+ },
+ 'lti' =>
+ {text => 'LTI Link Protection and LTI Consumers',
+ help => 'Domain_Configuration_LTI_Provider',
+ header => [{col1 => 'Encryption of shared secrets',
+ col2 => 'Settings'},
+ {col1 => 'Rules for shared secrets',
+ col2 => 'Settings'},
+ {col1 => 'Link Protectors',
+ col2 => 'Settings'},],
+ print => \&print_lti,
+ modify => \&modify_lti,
+ },
'ipaccess' =>
{text => 'IP-based access control',
help => 'Domain_Configuration_IP_Access',
@@ -521,7 +573,7 @@ sub handler {
header => [{col1 => 'Log-in Service',
col2 => 'Server Setting',},
{col1 => 'Log-in Page Items',
- col2 => ''},
+ col2 => 'Settings'},
{col1 => 'Log-in Help',
col2 => 'Value'},
{col1 => 'Custom HTML in document head',
@@ -701,8 +753,12 @@ sub process_changes {
$output = &modify_usersessions($dom,$lastactref,%domconfig);
} elsif ($action eq 'loadbalancing') {
$output = &modify_loadbalancing($dom,%domconfig);
+ } elsif ($action eq 'lti') {
+ $output = &modify_lti($r,$dom,$action,$lastactref,%domconfig);
} elsif ($action eq 'passwords') {
$output = &modify_passwords($r,$dom,$confname,$lastactref,%domconfig);
+ } elsif ($action eq 'ltitools') {
+ $output = &modify_ltitools($r,$dom,$action,$lastactref,%domconfig);
} elsif ($action eq 'wafproxy') {
$output = &modify_wafproxy($dom,$action,$lastactref,%domconfig);
} elsif ($action eq 'ipaccess') {
@@ -720,7 +776,7 @@ sub print_config_box {
} elsif ($action eq 'defaults') {
$output = &defaults_javascript($settings);
} elsif ($action eq 'passwords') {
- $output = &passwords_javascript();
+ $output = &passwords_javascript($action);
} elsif ($action eq 'helpsettings') {
my (%privs,%levelscurrent);
my %full=();
@@ -737,6 +793,11 @@ sub print_config_box {
$output =
&Apache::lonuserutils::custom_roledefs_js($context,$crstype,$formname,\%full,
\@templateroles);
+ } elsif ($action eq 'ltitools') {
+ $output .= <itools_javascript($settings);
+ } elsif ($action eq 'lti') {
+ $output .= &passwords_javascript('secrets')."\n".
+ <i_javascript($dom,$settings);
} elsif ($action eq 'wafproxy') {
$output .= &wafproxy_javascript($dom);
} elsif ($action eq 'autoupdate') {
@@ -787,7 +848,7 @@ sub print_config_box {
if (($action eq 'autoupdate') || ($action eq 'usercreation') || ($action eq 'selfcreation') ||
($action eq 'usermodification') || ($action eq 'defaults') || ($action eq 'coursedefaults') ||
($action eq 'selfenrollment') || ($action eq 'usersessions') || ($action eq 'directorysrch') ||
- ($action eq 'helpsettings') || ($action eq 'contacts') || ($action eq 'wafproxy')) {
+ ($action eq 'helpsettings') || ($action eq 'contacts') || ($action eq 'wafproxy') || ($action eq 'lti')) {
$output .= $item->{'print'}->('top',$dom,$settings,\$rowtotal);
} elsif ($action eq 'passwords') {
$output .= $item->{'print'}->('top',$dom,$confname,$settings,\$rowtotal);
@@ -822,7 +883,8 @@ 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') || ($action eq 'lti')) {
if ($action eq 'coursecategories') {
$output .= &print_coursecategories('middle',$dom,$item,$settings,\$rowtotal);
$colspan = ' colspan="2"';
@@ -876,8 +938,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);
@@ -1058,7 +1120,7 @@ sub print_config_box {
$output .= &print_quotas($dom,$settings,\$rowtotal,$action);
} elsif (($action eq 'autoenroll') || ($action eq 'autocreate') ||
($action eq 'serverstatuses') || ($action eq 'loadbalancing') ||
- ($action eq 'ipaccess')) {
+ ($action eq 'ltitools') || ($action eq 'ipaccess')) {
$output .= $item->{'print'}->($dom,$settings,\$rowtotal);
}
}
@@ -1165,6 +1227,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 +1269,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};
@@ -1401,13 +1471,13 @@ sub print_login {
'
'.$choices{'hostid'}.' | '.
''.$choices{'samllanding'}.' | '.
''.$choices{'samloptions'}.' |
'."\n";
- my (%saml,%samltext,%samlimg,%samlalt,%samlurl,%samltitle,%samlnotsso,%styleon,%styleoff);
+ my (%saml,%samltext,%samlimg,%samlalt,%samlurl,%samltitle,%samlwindow,%samlnotsso,%styleon,%styleoff);
foreach my $lonhost (keys(%domservers)) {
$samlurl{$lonhost} = '/adm/sso';
$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;
@@ -1416,6 +1486,7 @@ sub print_login {
$samlalt{$lonhost} = $settings->{'saml'}{$lonhost}{'alt'};
$samlurl{$lonhost} = $settings->{'saml'}{$lonhost}{'url'};
$samltitle{$lonhost} = $settings->{'saml'}{$lonhost}{'title'};
+ $samlwindow{$lonhost} = $settings->{'saml'}{$lonhost}{'window'};
$samlnotsso{$lonhost} = $settings->{'saml'}{$lonhost}{'notsso'};
$styleon{$lonhost} = '';
$styleoff{$lonhost} = 'display:none';
@@ -1433,6 +1504,12 @@ sub print_login {
$samlon = $samloff;
$samloff = ' ';
}
+ my $samlwinon = '';
+ my $samlwinoff = ' checked="checked"';
+ if ($samlwindow{$lonhost}) {
+ $samlwinon = $samlwinoff;
+ $samlwinoff = '';
+ }
my $css_class = $itemcount%2?' class="LC_odd_row"':'';
$datatable .= ''.$domservers{$lonhost}.' | '.
' | '.
''.
- ''.&mt('SSO').' | '.
- ''.&mt('Non-SSO').' | '.
+ ' '.
+ ''.
' | ';
@@ -1515,6 +1598,7 @@ sub login_choices {
current => "Current",
samllanding => "Dual login?",
samloptions => "Options",
+ alttext => "Alt text",
);
return %choices;
}
@@ -1860,7 +1944,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 +1952,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 +2050,11 @@ sub display_color_options {
$datatable .=' ';
}
}
+ if (($role eq 'login') && ($img ne 'login')) {
+ $datatable .= (' ' x2).' ';
+ }
$datatable .= ' ';
}
$itemcount ++;
@@ -2132,7 +2226,7 @@ sub print_quotas {
@options = ('norequest','approval','automatic');
%titles = &authorrequest_titles();
} else {
- @usertools = ('aboutme','blog','webdav','portfolio');
+ @usertools = ('aboutme','blog','webdav','portfolio','timezone');
%titles = &tool_titles();
}
if (ref($types) eq 'ARRAY') {
@@ -2236,9 +2330,12 @@ sub print_quotas {
}
} else {
my $checked = 'checked="checked" ';
+ if ($item eq 'timezone') {
+ $checked = '';
+ }
if (ref($settings) eq 'HASH') {
if (ref($settings->{$item}) eq 'HASH') {
- if ($settings->{$item}->{$type} == 0) {
+ if (!$settings->{$item}->{$type}) {
$checked = '';
} elsif ($settings->{$item}->{$type} == 1) {
$checked = 'checked="checked" ';
@@ -2837,6 +2934,108 @@ $jstext{'templates'};
ENDSCRIPT
}
+sub ltitools_javascript {
+ my ($settings) = @_;
+ my $togglejs = <itools_toggle_js();
+ unless (ref($settings) eq 'HASH') {
+ return $togglejs;
+ }
+ my (%ordered,$total,%jstext);
+ $total = 0;
+ foreach my $item (keys(%{$settings})) {
+ if (ref($settings->{$item}) eq 'HASH') {
+ my $num = $settings->{$item}{'order'};
+ $ordered{$num} = $item;
+ }
+ }
+ $total = scalar(keys(%{$settings}));
+ my @jsarray = ();
+ foreach my $item (sort {$a <=> $b } (keys(%ordered))) {
+ push(@jsarray,$ordered{$item});
+ }
+ my $jstext = ' var ltitools = Array('."'".join("','",@jsarray)."'".');'."\n";
+ return <<"ENDSCRIPT";
+
+
+$togglejs
+
+ENDSCRIPT
+}
+
+sub ltitools_toggle_js {
+ return <<"ENDSCRIPT";
+
+
+ENDSCRIPT
+}
+
sub wafproxy_javascript {
my ($dom) = @_;
return <<"ENDSCRIPT";
@@ -2952,6 +3151,140 @@ function toggleWAF() {
ENDSCRIPT
}
+sub lti_javascript {
+ my ($dom,$settings) = @_;
+ my $togglejs = <i_toggle_js($dom);
+ my $linkprot_js = &Apache::courseprefs::linkprot_javascript();
+ return <<"ENDSCRIPT";
+
+
+$togglejs
+
+ENDSCRIPT
+}
+
+sub lti_toggle_js {
+ my ($dom) = @_;
+ my %servers = &Apache::lonnet::get_servers($dom,'library');
+ my $primary = &Apache::lonnet::domain($dom,'primary');
+ my $course_servers = "'".join("','",keys(%servers))."'";
+ return <<"ENDSCRIPT";
+
+
+ENDSCRIPT
+}
+
sub autoupdate_javascript {
return <<"ENDSCRIPT";
|