--- loncom/interface/domainprefs.pm 2022/09/08 01:41:13 1.413
+++ loncom/interface/domainprefs.pm 2022/09/18 22:33:45 1.414
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Handler to set domain-wide configuration settings
#
-# $Id: domainprefs.pm,v 1.413 2022/09/08 01:41:13 raeburn Exp $
+# $Id: domainprefs.pm,v 1.414 2022/09/18 22:33:45 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -10675,13 +10675,29 @@ sub print_defaults {
} elsif ($item eq 'lang_def') {
my $includeempty = 1;
$datatable .= &Apache::loncommon::select_language($item,$defaults{$item},$includeempty);
- } else {
- my $size;
- if ($item eq 'portal_def') {
- $size = ' size="25"';
- }
+ } elsif ($item eq 'portal_def') {
$datatable .= '';
+ $defaults{$item}.'" size="25" onkeyup="portalExtras(this);" />';
+ my $portalsty = 'none';
+ if ($defaults{$item}) {
+ $portalsty = 'block';
+ }
+ foreach my $field ('email','web') {
+ my $checkedoff = ' checked="checked"';
+ my $checkedon;
+ if ($defaults{$item.'_'.$field}) {
+ $checkedon = $checkedoff;
+ $checkedoff = '';
+ }
+ $datatable .= '
'.
+ ''.$titles->{$field}.' '.
+ ''.
+ (' 'x2).
+ ''.
+ '
';
+ }
+ } else {
+ $datatable .= '';
}
$datatable .= '';
$rownum ++;
@@ -10777,6 +10793,8 @@ sub defaults_titles {
'timezone_def' => 'Default timezone',
'datelocale_def' => 'Default locale for dates',
'portal_def' => 'Portal/Default URL',
+ 'email' => 'Email links use portal URL',
+ 'web' => 'Public web links use portal URL',
'intauth_cost' => 'Encryption cost for bcrypt (positive integer)',
'intauth_check' => 'Check bcrypt cost if authenticated',
'intauth_switch' => 'Existing crypt-based switched to bcrypt on authentication',
@@ -11491,6 +11509,23 @@ sub serverstatus_pages {
sub defaults_javascript {
my ($settings) = @_;
return unless (ref($settings) eq 'HASH');
+ my $portal_js = <<"ENDPORTAL";
+
+function portalExtras(caller) {
+ var x = caller.value;
+ var y = new Array('email','web');
+ for (var i=0; i 0) {
+ z.style.display = 'block';
+ } else {
+ z.style.display = 'none';
+ }
+ }
+ }
+}
+ENDPORTAL
if ((ref($settings->{'inststatusorder'}) eq 'ARRAY') && (ref($settings->{'inststatustypes'}) eq 'HASH')) {
my $maxnum = scalar(@{$settings->{'inststatusorder'}});
if ($maxnum eq '') {
@@ -11544,6 +11579,17 @@ $jstext
return;
}
+$portal_js
+
+// ]]>
+
+
+ENDSCRIPT
+ } else {
+return <<"ENDSCRIPT";
+
@@ -19993,16 +20039,58 @@ sub modify_defaults {
}
} elsif ($item eq 'portal_def') {
if ($newvalues{$item} ne '') {
- unless ($newvalues{$item} =~ /^https?\:\/\/(([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9\-]*[a-zA-Z0-9])\.)*([A-Za-z]|[A-Za-z][A-Za-z0-9\-]*[A-Za-z0-9])\/?$/) {
+ if ($newvalues{$item} =~ /^https?\:\/\/(([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9\-]*[a-zA-Z0-9])\.)*([A-Za-z]|[A-Za-z][A-Za-z0-9\-]*[A-Za-z0-9])\/?$/) {
+ foreach my $field ('email','web') {
+ if ($env{'form.'.$item.'_'.$field}) {
+ $newvalues{$item.'_'.$field} = $env{'form.'.$item.'_'.$field};
+ }
+ }
+ } else {
push(@errors,$item);
}
}
}
if (grep(/^\Q$item\E$/,@errors)) {
$newvalues{$item} = $domdefaults{$item};
+ if ($item eq 'portal_def') {
+ if ($domdefaults{$item}) {
+ foreach my $field ('email','web') {
+ if (exists($domdefaults{$item.'_'.$field})) {
+ $newvalues{$item.'_'.$field} = $domdefaults{$item.'_'.$field};
+ }
+ }
+ }
+ }
} elsif ($domdefaults{$item} ne $newvalues{$item}) {
$changes{$item} = 1;
}
+ if ($item eq 'portal_def') {
+ unless (grep(/^\Q$item\E$/,@errors)) {
+ if ($newvalues{$item} eq '') {
+ foreach my $field ('email','web') {
+ if (exists($domdefaults{$item.'_'.$field})) {
+ delete($domdefaults{$item.'_'.$field});
+ }
+ }
+ } else {
+ unless ($changes{$item}) {
+ foreach my $field ('email','web') {
+ if ($domdefaults{$item.'_'.$field} ne $newvalues{$item.'_'.$field}) {
+ $changes{$item} = 1;
+ last;
+ }
+ }
+ }
+ foreach my $field ('email','web') {
+ if ($newvalues{$item.'_'.$field}) {
+ $domdefaults{$item.'_'.$field} = $newvalues{$item.'_'.$field};
+ } elsif (exists($domdefaults{$item.'_'.$field})) {
+ delete($domdefaults{$item.'_'.$field});
+ }
+ }
+ }
+ }
+ }
$domdefaults{$item} = $newvalues{$item};
}
my %staticdefaults = (
@@ -20202,7 +20290,20 @@ sub modify_defaults {
$value = $authnames{$shortauth{$value}};
}
$resulttext .= ''.&mt('[_1] set to "[_2]"',$title->{$item},$value).'';
- $mailmsgtext .= "$title->{$item} set to $value\n";
+ $mailmsgtext .= "$title->{$item} set to $value\n";
+ if ($item eq 'portal_def') {
+ if ($env{'form.'.$item} ne '') {
+ foreach my $field ('email','web') {
+ $value = $env{'form.'.$item.'_'.$field};
+ if ($value) {
+ $value = &mt('Yes');
+ } else {
+ $value = &mt('No');
+ }
+ $resulttext .= ''.&mt('[_1] set to "[_2]"',$title->{$field},$value).'';
+ }
+ }
+ }
}
}
$resulttext .= '';