--- loncom/interface/domainprefs.pm 2023/04/11 20:35:19 1.422
+++ loncom/interface/domainprefs.pm 2023/11/03 01:12:15 1.430
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Handler to set domain-wide configuration settings
#
-# $Id: domainprefs.pm,v 1.422 2023/04/11 20:35:19 raeburn Exp $
+# $Id: domainprefs.pm,v 1.430 2023/11/03 01:12:15 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -95,8 +95,7 @@ about default quota sizes for portfolio
institutional affiliation in the domain (e.g., Faculty, Staff, Student etc.),
but is now also used to manage availability of user tools:
i.e., blogs, aboutme page, and portfolios, and the course request tool,
-used by course owners to request creation of a course, and to display/store
-default quota sizes for Authoring Spaces.
+used by course owners to request creation of a course.
Outputs: 1
@@ -105,7 +104,7 @@ $datatable - HTML containing form eleme
In the case of course requests, radio buttons are displayed for each institutional
affiliate type (and also default, and _LC_adv) for each of the course types
(official, unofficial, community, textbook, placement, and lti).
-In each case the radio buttons allow the selection of one of four values:
+In each case the radio buttons allow the selection of one of four values:
0, approval, validate, autolimit=N (where N is blank, or a positive integer).
which have the following effects:
@@ -178,6 +177,7 @@ use DateTime::TimeZone;
use DateTime::Locale;
use Time::HiRes qw( sleep );
use Net::CIDR;
+use Crypt::CBC;
my $registered_cleanup;
my $modified_urls;
@@ -222,26 +222,50 @@ sub handler {
'coursedefaults','usersessions','loadbalancing',
'requestauthor','selfenrollment','inststatus',
'ltitools','toolsec','ssl','trust','lti','ltisec',
- 'privacy','passwords','proctoring','wafproxy','ipaccess'],$dom);
+ 'privacy','passwords','proctoring','wafproxy',
+ 'ipaccess','authordefaults'],$dom);
my %encconfig =
&Apache::lonnet::get_dom('encconfig',['ltitools','lti','proctoring','linkprot'],$dom,undef,1);
+ my ($checked_is_home,$is_home);
if (ref($domconfig{'ltitools'}) eq 'HASH') {
if (ref($encconfig{'ltitools'}) eq 'HASH') {
+ my $home = &Apache::lonnet::domain($dom,'primary');
+ unless (($home eq 'no_host') || ($home eq '')) {
+ my @ids=&Apache::lonnet::current_machine_ids();
+ if (grep(/^\Q$home\E$/,@ids)) {
+ $is_home = 1;
+ }
+ }
+ $checked_is_home = 1;
foreach my $id (keys(%{$domconfig{'ltitools'}})) {
if ((ref($domconfig{'ltitools'}{$id}) eq 'HASH') &&
(ref($encconfig{'ltitools'}{$id}) eq 'HASH')) {
$domconfig{'ltitools'}{$id}{'key'} = $encconfig{'ltitools'}{$id}{'key'};
+ if (($is_home) && ($phase eq 'process')) {
+ $domconfig{'ltitools'}{$id}{'secret'} = $encconfig{'ltitools'}{$id}{'secret'};
+ }
}
}
}
}
if (ref($domconfig{'lti'}) eq 'HASH') {
if (ref($encconfig{'lti'}) eq 'HASH') {
+ unless ($checked_is_home) {
+ my $home = &Apache::lonnet::domain($dom,'primary');
+ unless (($home eq 'no_host') || ($home eq '')) {
+ my @ids=&Apache::lonnet::current_machine_ids();
+ if (grep(/^\Q$home\E$/,@ids)) {
+ $is_home = 1;
+ }
+ }
+ $checked_is_home = 1;
+ }
foreach my $id (keys(%{$domconfig{'lti'}})) {
if ((ref($domconfig{'lti'}{$id}) eq 'HASH') &&
(ref($encconfig{'lti'}{$id}) eq 'HASH')) {
- foreach my $item ('key','secret') {
- $domconfig{'lti'}{$id}{$item} = $encconfig{'lti'}{$id}{$item};
+ $domconfig{'lti'}{$id}{'key'} = $encconfig{'lti'}{$id}{'key'};
+ if (($is_home) && ($phase eq 'process')) {
+ $domconfig{'lti'}{$id}{'secret'} = $encconfig{'lti'}{$id}{'secret'};
}
}
}
@@ -281,8 +305,8 @@ sub handler {
'contacts','privacy','usercreation','selfcreation',
'usermodification','scantron','requestcourses','requestauthor',
'coursecategories','serverstatuses','helpsettings','coursedefaults',
- 'ltitools','proctoring','selfenrollment','usersessions','ssl',
- 'trust','lti');
+ 'authordefaults','ltitools','proctoring','selfenrollment',
+ 'usersessions','ssl','trust','lti');
my %existing;
if (ref($domconfig{'loadbalancing'}) eq 'HASH') {
%existing = %{$domconfig{'loadbalancing'}};
@@ -358,11 +382,11 @@ sub handler {
modify => \&modify_passwords,
},
'quotas' =>
- { text => 'Blogs, personal pages/timezones, webDAV/quotas, portfolio',
+ { text => 'Blogs, personal pages/timezones, portfolio/quotas',
help => 'Domain_Configuration_Quotas',
header => [{col1 => 'User affiliation',
col2 => 'Available tools',
- col3 => 'Quotas, MB; (Authoring requires role)',}],
+ col3 => 'Portfilo quota (MB)',}],
print => \&print_quotas,
modify => \&modify_quotas,
},
@@ -544,7 +568,7 @@ sub handler {
modify => \&modify_selfenrollment,
},
'privacy' =>
- {text => 'Availability of User Information',
+ {text => 'Role assignments and user privacy',
help => 'Domain_Configuration_User_Privacy',
header => [{col1 => 'Role assigned in different domain',
col2 => 'Approval options'},
@@ -580,7 +604,7 @@ sub handler {
print => \&print_loadbalancing,
modify => \&modify_loadbalancing,
},
- 'ltitools' =>
+ 'ltitools' =>
{text => 'External Tools (LTI)',
help => 'Domain_Configuration_LTI_Tools',
header => [{col1 => 'Encryption of shared secrets',
@@ -638,12 +662,12 @@ sub handler {
print => \&print_trust,
modify => \&modify_trust,
},
- 'lti' =>
+ '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',
+ {col1 => 'Rules for shared secrets',
col2 => 'Settings'},
{col1 => 'Link Protectors',
col2 => 'Settings'},
@@ -652,7 +676,7 @@ sub handler {
print => \&print_lti,
modify => \&modify_lti,
},
- 'ipaccess' =>
+ 'ipaccess' =>
{text => 'IP-based access control',
help => 'Domain_Configuration_IP_Access',
header => [{col1 => 'Setting',
@@ -660,6 +684,16 @@ sub handler {
print => \&print_ipaccess,
modify => \&modify_ipaccess,
},
+ 'authordefaults' =>
+ {text => 'Authoring Space defaults',
+ help => 'Domain_Configuration_Author_Defaults',
+ header => [{col1 => 'Defaults which can be overridden by Author',
+ col2 => 'Settings',},
+ {col1 => 'Defaults which can be overridden by a Dom. Coord.',
+ col2 => 'Settings',},],
+ print => \&print_authordefaults,
+ modify => \&modify_authordefaults,
+ },
);
if (keys(%servers) > 1) {
$prefs{'login'} = { text => 'Log-in page options',
@@ -858,13 +892,15 @@ sub process_changes {
} elsif ($action eq 'lti') {
$output = &modify_lti($r,$dom,$action,$lastactref,%domconfig);
} elsif ($action eq 'privacy') {
- $output = &modify_privacy($dom,%domconfig);
+ $output = &modify_privacy($dom,$lastactref,%domconfig);
} elsif ($action eq 'passwords') {
$output = &modify_passwords($r,$dom,$confname,$lastactref,%domconfig);
} elsif ($action eq 'wafproxy') {
$output = &modify_wafproxy($dom,$action,$lastactref,%domconfig);
} elsif ($action eq 'ipaccess') {
$output = &modify_ipaccess($dom,$lastactref,%domconfig);
+ } elsif ($action eq 'authordefaults') {
+ $output = &modify_authordefaults($dom,$lastactref,%domconfig);
}
return $output;
}
@@ -893,7 +929,7 @@ sub print_config_box {
&Apache::lonuserutils::custom_role_privs(\%privs,\%full,\%levels,\%levelscurrent);
my @templateroles = &Apache::lonuserutils::custom_template_roles($context,$crstype);
$output =
- &Apache::lonuserutils::custom_roledefs_js($context,$crstype,$formname,\%full,
+ &Apache::lonuserutils::custom_roledefs_js($context,$crstype,$formname,\%full,
\@templateroles);
} elsif ($action eq 'ltitools') {
$output .= &Apache::lonconfigsettings::ltitools_javascript($settings);
@@ -912,6 +948,8 @@ sub print_config_box {
$output .= &saml_javascript();
} elsif ($action eq 'ipaccess') {
$output .= &ipaccess_javascript($settings);
+ } elsif ($action eq 'authordefaults') {
+ $output .= &authordefaults_javascript();
}
$output .=
'
'.
- "$description \n".
+ "$description \n".
''.
'';
- my %headers = &Apache::lonlocal::texthash(
+ my %headers = &Apache::lonlocal::texthash(
approve => 'Processing',
email => 'E-mail',
username => 'Username',
@@ -10001,7 +10319,7 @@ sub noninst_users {
my $value;
if (ref($emaildomain) eq 'HASH') {
if (ref($emaildomain->{$type}) eq 'HASH') {
- $value = $emaildomain->{$type}->{$option};
+ $value = $emaildomain->{$type}->{$option};
}
}
if ($value eq '') {
@@ -10319,7 +10637,7 @@ sub print_defaults {
if ($defaults{$item.'_'.$field}) {
$checkedon = $checkedoff;
$checkedoff = '';
- }
+ }
$datatable .= ''.
'
'.$titles->{$field}.' '.
' '.&mt('Yes').' '.
@@ -11148,7 +11466,7 @@ sub defaults_javascript {
function portalExtras(caller) {
var x = caller.value;
var y = new Array('email','web');
- for (var i=0; i 0) {
@@ -11252,7 +11570,7 @@ sub passwords_javascript {
}
&js_escape(\%intalert);
my $defmin = $Apache::lonnet::passwdmin;
- my $intauthjs;
+ my $intauthjs;
if ($prefix eq 'passwords') { $intauthjs = <<"ENDSCRIPT";
function warnIntAuth(field) {
@@ -11646,7 +11964,6 @@ sub modifiable_userdata_row {
'';
my $rem;
my %checks;
- my %current;
if (ref($settings) eq 'HASH') {
my $hashref;
if ($context eq 'lti') {
@@ -11672,7 +11989,7 @@ sub modifiable_userdata_row {
}
}
}
- if (ref($hashref) eq 'HASH') {
+ if (ref($hashref) eq 'HASH') {
foreach my $field (@fields) {
if ($hashref->{$field}) {
if ($role eq 'emailusername') {
@@ -11684,7 +12001,6 @@ sub modifiable_userdata_row {
}
}
}
-
my $total = scalar(@fields);
for (my $i=0; $i<$total; $i++) {
$rem = $i%($numinrow);
@@ -11773,15 +12089,19 @@ sub insttypes_row {
my ($settings,$types,$usertypes,$dom,$numinrow,$othertitle,$context,$rowtotal,$onclick,
$customcss,$rowstyle) = @_;
my %lt = &Apache::lonlocal::texthash (
- cansearch => 'Users allowed to search',
+ cansearch => 'Users allowed to search',
statustocreate => 'Institutional affiliation(s) able to create own account (login/SSO)',
- lockablenames => 'User preference to lock name',
- selfassign => 'Self-reportable affiliations',
- overrides => "Override domain's helpdesk settings based on requester's affiliation",
+ lockablenames => 'User preference to lock name',
+ selfassign => 'Self-reportable affiliations',
+ overrides => "Override domain's helpdesk settings based on requester's affiliation",
+ webdav => 'WebDAV access available',
+ authorquota => 'Authoring Space quota (MB)',
);
- my $showdom;
+ my ($showdom,$defaultquota);
if ($context eq 'cansearch') {
$showdom = ' ('.$dom.')';
+ } elsif ($context eq 'authorquota') {
+ $defaultquota = 500;
}
my $class = 'LC_left_item';
if ($context eq 'statustocreate') {
@@ -11818,25 +12138,44 @@ sub insttypes_row {
}
$output .= '';
}
- my $check = ' ';
- if (ref($settings) eq 'HASH') {
- if (ref($settings->{$context}) eq 'ARRAY') {
- if (grep(/^\Q$types->[$i]\E$/,@{$settings->{$context}})) {
- $check = ' checked="checked" ';
- }
- } elsif (ref($settings->{$context}) eq 'HASH') {
- if (ref($settings->{$context}->{$types->[$i]}) eq 'HASH') {
+ if ($context eq 'authorquota') {
+ my $currquota;
+ if ($settings->{$context}->{$types->[$i]} =~ /^\d+$/) {
+ $currquota = $settings->{$context}->{$types->[$i]};
+ } else {
+ $currquota = $defaultquota;
+ }
+ $output .= ''."\n".
+ ''."\n".
+ $usertypes->{$types->[$i]}.' '."\n".
+ ' '."\n".
+ ' ';
+ } else {
+ my $check = ' ';
+ if (ref($settings) eq 'HASH') {
+ if (ref($settings->{$context}) eq 'ARRAY') {
+ if (grep(/^\Q$types->[$i]\E$/,@{$settings->{$context}})) {
+ $check = ' checked="checked" ';
+ }
+ } elsif (ref($settings->{$context}) eq 'HASH') {
+ if (ref($settings->{$context}->{$types->[$i]}) eq 'HASH') {
+ $check = ' checked="checked" ';
+ } elsif ($context eq 'webdav') {
+ if ($settings->{$context}->{$types->[$i]}) {
+ $check = ' checked="checked" ';
+ }
+ }
+ } elsif ($context eq 'statustocreate') {
$check = ' checked="checked" ';
}
- } elsif ($context eq 'statustocreate') {
- $check = ' checked="checked" ';
}
+ $output .= ''.
+ ''.
+ ' [$i].'"'.$check.$onclick.'/>'.
+ $usertypes->{$types->[$i]}.' ';
}
- $output .= ''.
- ''.
- ' [$i].'"'.$check.$onclick.' />'.
- $usertypes->{$types->[$i]}.' ';
}
}
$rem = @{$types}%($numinrow);
@@ -11848,7 +12187,7 @@ sub insttypes_row {
} else {
$output .= '';
}
- $output .= ' ';
+ $output .= ' ';
} else {
if ($rem == 0) {
$output .= ' ';
@@ -11858,20 +12197,41 @@ sub insttypes_row {
} else {
$output .= '';
}
- my $defcheck = ' ';
- if (ref($settings) eq 'HASH') {
- if (ref($settings->{$context}) eq 'ARRAY') {
- if (grep(/^default$/,@{$settings->{$context}})) {
+ if ($context eq 'authorquota') {
+ my $currquota = 500;
+ if ((ref($settings) eq 'HASH') && (ref($settings->{$context}) eq 'HASH')) {
+ if ($settings->{$context}{'default'} =~ /^\d+$/) {
+ $currquota = $settings->{$context}{'default'};
+ }
+ }
+ $output .= ''.$othertitle.' '."\n".
+ ' '."\n".
+ ' ';
+ } else {
+ my $defcheck = ' ';
+ if (ref($settings) eq 'HASH') {
+ if (ref($settings->{$context}) eq 'ARRAY') {
+ if (grep(/^default$/,@{$settings->{$context}})) {
+ $defcheck = ' checked="checked" ';
+ }
+ } elsif (ref($settings->{$context}) eq 'HASH') {
+ if (ref($settings->{$context}->{'default'}) eq 'HASH') {
+ $defcheck = ' checked="checked" ';
+ } elsif ($context eq 'webdav') {
+ if ($settings->{$context}->{'default'}) {
+ $defcheck = ' checked="checked" ';
+ }
+ }
+ } elsif ($context eq 'statustocreate') {
$defcheck = ' checked="checked" ';
}
- } elsif ($context eq 'statustocreate') {
- $defcheck = ' checked="checked" ';
}
+ $output .= ''.
+ ' '.
+ $othertitle.' ';
}
- $output .= ''.
- ' '.
- $othertitle.' ';
}
$output .= '
';
return $output;
@@ -12124,7 +12484,7 @@ sub modify_login {
if ($lang eq $env{'form.loginhelpurl_add_lang'}) {
$formelem = 'loginhelpurl_add_file';
}
- (my $result,$newurl{$lang}) =
+ (my $result,$newurl{$lang}) =
&Apache::lonconfigsettings::publishlogo($r,'upload',$formelem,$dom,$confname,
"help/$lang",'','',$newfile{$lang},
$modified);
@@ -12201,7 +12561,7 @@ sub modify_login {
my $modified = [];
foreach my $lonhost (@newhosts) {
my $formelem = 'loginheadtag_'.$lonhost;
- (my $result,$newheadtagurls{$lonhost}) =
+ (my $result,$newheadtagurls{$lonhost}) =
&Apache::lonconfigsettings::publishlogo($r,'upload',$formelem,$dom,$confname,
"login/headtag/$lonhost",'','',
$env{'form.loginheadtag_'.$lonhost.'.filename'},
@@ -12278,15 +12638,15 @@ sub modify_login {
$currsaml{$lonhost}{$item} = $env{'form.saml_'.$item.'_'.$lonhost};
}
} else {
- if ($saml{$lonhost}) {
+ if ($saml{$lonhost}) {
$changes{'saml'}{$lonhost} = 1;
delete($currsaml{$lonhost});
}
}
}
foreach my $posshost (keys(%currsaml)) {
- unless (exists($domservers{$posshost})) {
- delete($currsaml{$posshost});
+ unless (exists($domservers{$posshost})) {
+ delete($currsaml{$posshost});
}
}
%{$loginhash{'login'}{'saml'}} = %currsaml;
@@ -12300,7 +12660,7 @@ sub modify_login {
my $modified = [];
foreach my $lonhost (@newsamlimgs) {
my $formelem = 'saml_img_'.$lonhost;
- my ($result,$imgurl) =
+ my ($result,$imgurl) =
&Apache::lonconfigsettings::publishlogo($r,'upload',$formelem,$dom,$confname,
"login/saml/$lonhost",'','',
$env{'form.saml_img_'.$lonhost.'.filename'},
@@ -12670,7 +13030,7 @@ sub modify_ipaccess {
$possrange =~ s/,+/,/g;
if ($possrange ne '') {
my (@ok,$count);
- $count = 0;
+ $count = 0;
foreach my $poss (split(/\,/,$possrange)) {
$count ++;
$poss = &validate_ip_pattern($poss);
@@ -12703,9 +13063,9 @@ sub modify_ipaccess {
}
}
$confhash{$itemid}{'commblocks'} = {};
-
+
my %commblocks;
- map { $commblocks{$_} = 1; } &Apache::loncommon::get_env_multiple('form.ipaccess_block_'.$idx);
+ map { $commblocks{$_} = 1; } &Apache::loncommon::get_env_multiple('form.ipaccess_block_'.$idx);
foreach my $type (@{$typeorder}) {
if ($commblocks{$type}) {
$confhash{$itemid}{'commblocks'}{$type} = 'on';
@@ -12737,7 +13097,7 @@ sub modify_ipaccess {
}
$env{'form.ipaccess_cnum_'.$idx} =~ s/^\s+|\s+$//g;
$env{'form.ipaccess_cdom_'.$idx} =~ s/^\s+|\s+$//g;
- if (($env{'form.ipaccess_cnum_'.$idx} =~ /^$match_courseid$/) &&
+ if (($env{'form.ipaccess_cnum_'.$idx} =~ /^$match_courseid$/) &&
($env{'form.ipaccess_cdom_'.$idx} =~ /^$match_domain$/)) {
if (&Apache::lonnet::homeserver($env{'form.ipaccess_cnum_'.$idx},
$env{'form.ipaccess_cdom_'.$idx}) eq 'no_host') {
@@ -12817,7 +13177,7 @@ sub modify_ipaccess {
if (keys(%{$confhash{$itemid}{'courses'}})) {
my @courses;
foreach my $cid (sort(keys(%{$confhash{$itemid}{'courses'}}))) {
- my %courseinfo = &Apache::lonnet::coursedescription($cid,{'one_time' => 1});
+ my %courseinfo = &Apache::lonnet::coursedescription($cid,{'one_time' => 1});
push(@courses,$courseinfo{'description'}.' ('.$cid.')');
}
$resulttext .= ''.&mt('Courses/Communities allowed').':'.
@@ -12885,6 +13245,235 @@ sub get_ipaccess_id {
return ($id,$error);
}
+sub modify_authordefaults {
+ my ($dom,$lastactref,%domconfig) = @_;
+#
+# Retrieve current domain configuration for webDAV and Authoring Space quotas from $domconfig{'quotas'}.
+#
+ my (%curr_quotas,%save_quotas,%confhash,%changes,%newvalues);
+ if (ref($domconfig{'quotas'}) eq 'HASH') {
+ foreach my $key (keys(%{$domconfig{'quotas'}})) {
+ if ($key =~ /^webdav|authorquota$/) {
+ $curr_quotas{$key} = $domconfig{'quotas'}{$key};
+ } else {
+ $save_quotas{$key} = $domconfig{'quotas'}{$key};
+ }
+ }
+ }
+ my %staticdefaults = (
+ 'copyright' => 'default',
+ 'sourceavail' => 'closed',
+ 'nocodemirror' => 'off',
+ 'domcoordacc' => 'on',
+ 'editors' => ['edit','xml'].
+ 'authorquota' => 500,
+ 'webdav' => 0,
+ );
+ my %titles = &authordefaults_titles();
+ foreach my $item ('nocodemirror','domcoordacc') {
+ if ($env{'form.'.$item} =~ /^(0|1)$/) {
+ $confhash{$item} = $env{'form.'.$item};
+ }
+ }
+ if ($env{'form.copyright'} =~ /^(default|domain|public)$/) {
+ $confhash{'copyright'} = $1;
+ }
+ if ($env{'form.sourceavail'} =~ /^(closed|open)$/) {
+ $confhash{'sourceavail'} = $1;
+ }
+ my @posseditors = &Apache::loncommon::get_env_multiple('form.author_editors');
+ my @okeditors = ('edit','xml','daxe');
+ my @editors;
+ foreach my $item (@posseditors) {
+ if (grep(/^\Q$item\E$/,@okeditors)) {
+ push(@editors,$item);
+ }
+ }
+ $confhash{'editors'} = \@editors;
+
+ my ($othertitle,$usertypes,$types) = &Apache::loncommon::sorted_inst_types($dom);
+ my @insttypes;
+ if (ref($types) eq 'ARRAY') {
+ @insttypes = @{$types};
+ }
+ my @webdavon = &Apache::loncommon::get_env_multiple('form.webdav');
+ my %webdav;
+ map { $webdav{$_} = 1; } @webdavon;
+ foreach my $type (@insttypes,'default') {
+ my $possquota = $env{'form.authorquota_'.$type};
+ if ($possquota =~ /^\d+$/) {
+ $save_quotas{'authorquota'}{$type} = $possquota;
+ }
+ if ($webdav{$type}) {
+ $save_quotas{'webdav'}{$type} = 1;
+ } else {
+ $save_quotas{'webdav'}{$type} = 0;
+ }
+ }
+ if ($env{'form.webdav_LC_adv'} =~ /^(0|1)$/) {
+ $save_quotas{'webdav'}{'_LC_adv'} = $env{'form.webdav_LC_adv'};
+ }
+ if (ref($domconfig{'authordefaults'}) eq 'HASH') {
+ foreach my $item ('nocodemirror','domcoordacc','copyright','sourceavail') {
+ if ($domconfig{'authordefaults'}{$item} ne $confhash{$item}) {
+ $changes{$item} = 1;
+ }
+ }
+ if (ref($domconfig{'authordefaults'}{'editors'}) eq 'ARRAY') {
+ my @diffs =
+ &Apache::loncommon::compare_arrays($confhash{'editors'},
+ $domconfig{'authordefaults'}{'editors'});
+ unless (@diffs == 0) {
+ $changes{'editors'} = 1;
+ }
+ } else {
+ my @diffs =
+ &Apache::loncommon::compare_arrays($confhash{'editors'},
+ $staticdefaults{'editors'});
+ unless (@diffs == 0) {
+ $changes{'editors'} = 1;
+ }
+ }
+ } else {
+ my @offon = ('off','on');
+ foreach my $item ('nocodemirror','domcoordacc') {
+ if ($offon[$confhash{$item}] ne $staticdefaults{$item}) {
+ $changes{$item} = 1;
+ }
+ }
+ foreach my $item ('copyright','sourceavail') {
+ if ($confhash{$item} ne $staticdefaults{$item}) {
+ $changes{$item} = 1;
+ }
+ }
+ }
+ foreach my $key ('authorquota','webdav') {
+ if (ref($curr_quotas{$key}) eq 'HASH') {
+ foreach my $type (@insttypes,'default') {
+ if (exists($save_quotas{$key}{$type})) {
+ if ($save_quotas{$key}{$type} ne $curr_quotas{$key}{$type}) {
+ $changes{$key}{$type} = 1;
+ }
+ } elsif (exists($curr_quotas{$key}{$type})) {
+ $save_quotas{$key}{$type} = $curr_quotas{$key}{$type};
+ } else {
+ $save_quotas{$key}{$type} = $staticdefaults{$key};
+ }
+ }
+ } else {
+ foreach my $type (@insttypes,'default') {
+ if (exists($save_quotas{$key}{$type})) {
+ unless ($save_quotas{$key}{$type} eq $staticdefaults{$key}) {
+ $changes{$key}{$type} = 1;
+ }
+ } else {
+ $save_quotas{$key}{$type} = $staticdefaults{$key};
+ }
+ }
+ }
+ }
+ if (ref($curr_quotas{'webdav'}) eq 'HASH') {
+ if (exists($save_quotas{'webdav'}{'_LC_adv'})) {
+ if ($save_quotas{'webdav'}{'_LC_adv'} ne $curr_quotas{'webdav'}{'_LC_adv'}) {
+ $changes{'webdav_LC_adv'} = 1;
+ }
+ } elsif (exists($curr_quotas{'webdav'}{'_LC_adv'})) {
+ $changes{'webdav_LC_adv'} = 1;
+ }
+ } elsif (exists($save_quotas{'webdav'}{'_LC_adv'})) {
+ $changes{'webdav_LC_adv'} = 1;
+ }
+ my %confighash = (
+ quotas => \%save_quotas,
+ authordefaults => \%confhash,
+ );
+ my $putresult = &Apache::lonnet::put_dom('configuration',\%confighash,
+ $dom);
+ my $resulttext;
+ if ($putresult eq 'ok') {
+ if (keys(%changes)) {
+ if ((exists($changes{'authorquota'})) || (exists($changes{'webdav'})) ||
+ ($changes{'webdav_LC_adv'})) {
+ my %domdefaults = &Apache::lonnet::get_domain_defaults($dom,1);
+ if ((exists($changes{'authorquota'})) && (ref($save_quotas{'authorquota'}) eq 'HASH')) {
+ $domdefaults{'authorquota'} = $save_quotas{'authorquota'};
+ }
+ if (((exists($changes{'webdav'})) || ($changes{'webdav_LC_adv'})) &&
+ (ref($save_quotas{'webdav'}) eq 'HASH')) {
+ $domdefaults{'webdav'} = $save_quotas{'webdav'};
+ }
+ my $cachetime = 24*60*60;
+ &Apache::lonnet::do_cache_new('domdefaults',$dom,\%domdefaults,$cachetime);
+ if (ref($lastactref) eq 'HASH') {
+ $lastactref->{'domdefaults'} = 1;
+ }
+ }
+ $resulttext = &mt('Changes made:').'';
+ my $authoroverride;
+ foreach my $key ('nocodemirror','domcoordacc','copyright','sourceavail') {
+ if (exists($changes{$key})) {
+ my $shown;
+ unless ($authoroverride) {
+ $resulttext .= ''.&mt('Defaults which can be overridden by Author').'';
+ $authoroverride = 1;
+ }
+ if (($key eq 'nocodemirror') || ($key eq 'domcoordacc')) {
+ $shown = ($confhash{$key} ? &mt('Yes') : &mt('No'));
+ } elsif ($key eq 'copyright') {
+ $shown = &Apache::loncommon::copyrightdescription($confhash{$key});
+ } elsif ($key eq 'sourceavail') {
+ $shown = &Apache::loncommon::source_copyrightdescription($confhash{$key});
+ }
+ $resulttext .= ''.&mt('[_1] set to: [_2]',$titles{$key},$shown).' ';
+ }
+ }
+ if ($authoroverride) {
+ $resulttext .= ' ';
+ }
+ my $domcoordoverride;
+ foreach my $key ('editors','authorquota','webdav','webdav_LC_adv') {
+ if (exists($changes{$key})) {
+ my $shown;
+ unless ($domcoordoverride) {
+ $resulttext .= ''.&mt('Defaults which can be overridden by a Domain Coodinator').'';
+ $domcoordoverride = 1;
+ }
+ if ($key eq 'editors') {
+ if (@{$confhash{'editors'}}) {
+ $shown = join(', ', map { $titles{$_} } @{$confhash{'editors'}});
+ } else {
+ $shown = &mt('None');
+ }
+ } elsif ($key eq 'authorquota') {
+ foreach my $type (@insttypes) {
+ $shown .= $usertypes->{$type}.' -- '.$save_quotas{$key}{$type}.', ';
+ }
+ $shown .= $othertitle.' -- '.$save_quotas{$key}{'default'};
+ } elsif ($key eq 'webdav') {
+ foreach my $type (@insttypes) {
+ $shown .= $usertypes->{$type}.' -- '. ($save_quotas{$key}{$type} ? &mt('Yes') : &mt('No')).', ';
+ }
+ $shown .= $othertitle.' -- '. ($save_quotas{$key}{'default'} ? &mt('Yes') : &mt('No'));
+ } elsif ($key eq 'webdav_LC_adv') {
+ if (exists($save_quotas{'webdav'}{'_LC_adv'})) {
+ $shown = ($save_quotas{'webdav'}{'_LC_adv'} ? $titles{'overon'} : $titles{'overoff'});
+ } else {
+ $shown = $titles{'none'};
+ }
+ }
+ $resulttext .= ''.&mt('[_1] set to: [_2]',$titles{$key},$shown).' ';
+ }
+ }
+ if ($domcoordoverride) {
+ $resulttext .= ' ';
+ }
+ } else {
+ $resulttext = &mt('No changes made to Authoring Space defaults');
+ }
+ }
+ return $resulttext;
+}
+
sub modify_rolecolors {
my ($r,$dom,$confname,$roles,$lastactref,%domconfig) = @_;
my ($resulttext,%rolehash);
@@ -13412,15 +14001,21 @@ sub subscribed_hosts {
sub check_switchserver {
my ($dom,$confname) = @_;
- my ($allowed,$switchserver);
- my $home = &Apache::lonnet::homeserver($confname,$dom);
- if ($home eq 'no_host') {
+ my ($allowed,$switchserver,$home);
+ if ($confname eq '') {
$home = &Apache::lonnet::domain($dom,'primary');
+ } else {
+ $home = &Apache::lonnet::homeserver($confname,$dom);
+ if ($home eq 'no_host') {
+ $home = &Apache::lonnet::domain($dom,'primary');
+ }
}
my @ids=&Apache::lonnet::current_machine_ids();
foreach my $id (@ids) { if ($id eq $home) { $allowed=1; } }
if (!$allowed) {
- $switchserver=''.&mt('Switch Server').' ';
+ $switchserver=''.&mt('Switch Server').' ';
}
return $switchserver;
}
@@ -13432,7 +14027,7 @@ sub modify_quotas {
$author_ok,$switchserver,$errors,$validationitemsref,$validationnamesref,
$validationfieldsref);
if ($action eq 'quotas') {
- $context = 'tools';
+ $context = 'tools';
} else {
$context = $action;
}
@@ -13452,7 +14047,7 @@ sub modify_quotas {
@usertools = ('author');
%titles = &authorrequest_titles();
} else {
- @usertools = ('aboutme','blog','webdav','portfolio','timezone');
+ @usertools = ('aboutme','blog','portfolio','portaccess','timezone');
%titles = &tool_titles();
}
my %domdefaults = &Apache::lonnet::get_domain_defaults($dom,1);
@@ -13475,8 +14070,6 @@ sub modify_quotas {
} else {
if ($key =~ /^form\.quota_(.+)$/) {
$confhash{'defaultquota'}{$1} = $env{$key};
- } elsif ($key =~ /^form\.authorquota_(.+)$/) {
- $confhash{'authorquota'}{$1} = $env{$key};
} elsif ($key =~ /^form\.\Q$context\E_(.+)$/) {
@{$toolshash{$1}} = &Apache::loncommon::get_env_multiple($key);
}
@@ -13770,7 +14363,6 @@ sub modify_quotas {
}
} else {
$confhash{'defaultquota'}{'default'} = $env{'form.defaultquota'};
- $confhash{'authorquota'}{'default'} = $env{'form.authorquota'};
}
foreach my $item (@usertools) {
foreach my $type (@{$types},'default','_LC_adv') {
@@ -13859,15 +14451,10 @@ sub modify_quotas {
}
}
if (ref($domconfig{'quotas'}{'authorquota'}) eq 'HASH') {
- foreach my $key (keys(%{$domconfig{'quotas'}{'authorquota'}})) {
- if (exists($confhash{'authorquota'}{$key})) {
- if ($confhash{'authorquota'}{$key} ne $domconfig{'quotas'}{'authorquota'}{$key}) {
- $changes{'authorquota'}{$key} = 1;
- }
- } else {
- $confhash{'authorquota'}{$key} = $domconfig{'quotas'}{'authorquota'}{$key};
- }
- }
+ $confhash{'authorquota'} = $domconfig{'quotas'}{'authorquota'};
+ }
+ if (ref($domconfig{'quotas'}{'webdav'}) eq 'HASH') {
+ $confhash{'webdav'} = $domconfig{'quotas'}{'webdav'};
}
}
if (ref($confhash{'defaultquota'}) eq 'HASH') {
@@ -13887,21 +14474,6 @@ sub modify_quotas {
}
}
}
- if (ref($confhash{'authorquota'}) eq 'HASH') {
- foreach my $key (keys(%{$confhash{'authorquota'}})) {
- if (ref($domconfig{'quotas'}) eq 'HASH') {
- if (ref($domconfig{'quotas'}{'authorquota'}) eq 'HASH') {
- if (!exists($domconfig{'quotas'}{'authorquota'}{$key})) {
- $changes{'authorquota'}{$key} = 1;
- }
- } else {
- $changes{'authorquota'}{$key} = 1;
- }
- } else {
- $changes{'authorquota'}{$key} = 1;
- }
- }
- }
}
if ($context eq 'requestauthor') {
@@ -13942,19 +14514,6 @@ sub modify_quotas {
}
$resulttext .= ' ';
}
- if (ref($changes{'authorquota'}) eq 'HASH') {
- $resulttext .= ''.&mt('Authoring Space default quotas').'';
- foreach my $type (@{$types},'default') {
- if (defined($changes{'authorquota'}{$type})) {
- my $typetitle = $usertypes->{$type};
- if ($type eq 'default') {
- $typetitle = $othertitle;
- }
- $resulttext .= ''.&mt('[_1] set to [_2] MB',$typetitle,$confhash{'authorquota'}{$type}).' ';
- }
- }
- $resulttext .= ' ';
- }
}
my %newenv;
foreach my $item (@usertools) {
@@ -14245,15 +14804,22 @@ sub modify_ltitools {
$action => { %newtoolsenc }
);
&Apache::lonnet::put_dom('encconfig',\%toolsenchash,$dom,undef,1);
+ my $cachetime = 24*60*60;
+ &Apache::lonnet::do_cache_new('ltitoolsenc',$dom,\%newtoolsenc,$cachetime);
&store_security($dom,'ltitools',\%secchanges,\%newkeyset,\%keystore,$lastactref);
}
$resulttext = &mt('Changes made:').'';
if (keys(%secchanges) > 0) {
- $resulttext .= <i_security_results('ltitools',\%secchanges,\%newtoolsec,\%newkeyset,\%keystore);
+ $resulttext .= <i_security_results($dom,'ltitools',\%secchanges,\%newtoolsec,\%newkeyset,\%keystore);
}
if (keys(%ltitoolschg) > 0) {
$resulttext .= $ltitoolsoutput;
}
+ my $cachetime = 24*60*60;
+ &Apache::lonnet::do_cache_new('ltitools',$dom,\%newltitools,$cachetime);
+ if (ref($lastactref) eq 'HASH') {
+ $lastactref->{'ltitools'} = 1;
+ }
} else {
$errors .= ''.&mt('Failed to save changes').' ';
}
@@ -14334,7 +14900,6 @@ sub fetch_secrets {
foreach my $hostid (keys(%servers)) {
if (($hostid ne '') && (grep(/^\Q$hostid\E$/,@ids))) {
- my $newkey;
my $keyitem = 'form.'.$context.'_privkey_'.$hostid;
if (exists($env{$keyitem})) {
$env{$keyitem} =~ s/(`)/'/g;
@@ -14358,7 +14923,7 @@ sub fetch_secrets {
}
sub store_security {
- my ($dom,$context,$secchanges,$newkeyset,$keystore,$lastactref) = @_;
+ my ($dom,$context,$secchanges,$newkeyset,$keystore) = @_;
return unless ((ref($secchanges) eq 'HASH') && (ref($newkeyset) eq 'HASH') &&
(ref($keystore) eq 'HASH'));
if (keys(%{$secchanges})) {
@@ -14373,19 +14938,17 @@ sub store_security {
$dom,$hostid);
}
}
- if (ref($lastactref) eq 'HASH') {
- if (($secchanges->{'encrypt'}) || ($secchanges->{'private'})) {
- $lastactref->{'domdefaults'} = 1;
- }
- }
}
}
sub lti_security_results {
- my ($context,$secchanges,$newsec,$newkeyset,$keystore) = @_;
+ my ($dom,$context,$secchanges,$newsec,$newkeyset,$keystore) = @_;
my $output;
+ my %domdefaults = &Apache::lonnet::get_domain_defaults($dom);
+ my $needs_update;
foreach my $item (keys(%{$secchanges})) {
if ($item eq 'encrypt') {
+ $needs_update = 1;
my %encrypted;
if ($context eq 'lti') {
%encrypted = (
@@ -14417,12 +14980,29 @@ sub lti_security_results {
}
my @types= ('crs','dom');
if ($context eq 'lti') {
+ foreach my $type (@types) {
+ undef($domdefaults{'linkprotenc_'.$type});
+ }
push(@types,'consumers');
+ undef($domdefaults{'ltienc_consumers'});
+ } elsif ($context eq 'ltitools') {
+ foreach my $type (@types) {
+ undef($domdefaults{'toolenc_'.$type});
+ }
}
foreach my $type (@types) {
my $shown = $encrypted{$type}{'off'};
if (ref($newsec->{$item}) eq 'HASH') {
if ($newsec->{$item}{$type}) {
+ if ($context eq 'lti') {
+ if ($type eq 'consumers') {
+ $domdefaults{'ltienc_consumers'} = 1;
+ } else {
+ $domdefaults{'linkprotenc_'.$type} = 1;
+ }
+ } elsif ($context eq 'ltitools') {
+ $domdefaults{'toolenc_'.$type} = 1;
+ }
$shown = $encrypted{$type}{'on'};
}
}
@@ -14466,10 +15046,27 @@ sub lti_security_results {
$output .= ''.&mt('[_1] set to none',$titles{'chars'}).' ';
}
} elsif ($item eq 'private') {
+ $needs_update = 1;
+ if ($context eq 'lti') {
+ undef($domdefaults{'ltiprivhosts'});
+ } elsif ($context eq 'ltitools') {
+ undef($domdefaults{'toolprivhosts'});
+ }
if (keys(%{$newkeyset})) {
+ my @privhosts;
foreach my $hostid (sort(keys(%{$newkeyset}))) {
if ($keystore->{$hostid} eq 'ok') {
$output .= ''.&mt('Encryption key for storage of shared secrets saved for [_1]',$hostid).' ';
+ unless (grep(/^\Q$hostid\E$/,@privhosts)) {
+ push(@privhosts,$hostid);
+ }
+ }
+ }
+ if (@privhosts) {
+ if ($context eq 'lti') {
+ $domdefaults{'ltiprivhosts'} = \@privhosts;
+ } elsif ($context eq 'ltitools') {
+ $domdefaults{'toolprivhosts'} = \@privhosts;
}
}
}
@@ -14477,6 +15074,10 @@ sub lti_security_results {
next;
}
}
+ if ($needs_update) {
+ my $cachetime = 24*60*60;
+ &Apache::lonnet::do_cache_new('domdefaults',$dom,\%domdefaults,$cachetime);
+ }
return $output;
}
@@ -15016,7 +15617,7 @@ sub process_proctoring_image {
sub modify_lti {
my ($r,$dom,$action,$lastactref,%domconfig) = @_;
my %domdefaults = &Apache::lonnet::get_domain_defaults($dom,1);
- my ($newid,@allpos,%changes,%confhash,%encconfig,$errors,$resulttext);
+ my ($newid,@allpos,%changes,%confhash,%ltienc,$errors,$resulttext);
my (%posslti,%posslticrs,%posscrstype);
my @courseroles = ('cc','in','ta','ep','st');
my @ltiroles = qw(Learner Instructor ContentDeveloper TeachingAssistant Mentor Member Manager Administrator);
@@ -15130,29 +15731,43 @@ sub modify_lti {
}
}
}
+ my (%keystore,$secstored);
+ if ($is_home) {
+ &store_security($dom,'lti',\%secchanges,\%newkeyset,\%keystore);
+ }
+
+ my ($cipher,$privnum);
+ if ((@items > 0) && ($is_home)) {
+ ($cipher,$privnum) = &get_priv_creds($dom,$home,$secchanges{'encrypt'},
+ $newltisec{'encrypt'},$keystore{$home});
+ }
foreach my $idx (@items) {
my $itemid = $itemids{$idx};
next unless ($itemid);
+ my %currlti;
+ unless ($idx eq 'add') {
+ if (ref($domconfig{$action}) eq 'HASH') {
+ if (ref($domconfig{$action}{$itemid}) eq 'HASH') {
+ %currlti = %{$domconfig{$action}{$itemid}};
+ }
+ }
+ }
my $position = $env{'form.lti_pos_'.$itemid};
$position =~ s/\D+//g;
if ($position ne '') {
$allpos[$position] = $itemid;
}
- foreach my $item ('consumer','key','secret','lifetime','requser','crsinc') {
+ foreach my $item ('consumer','lifetime','requser','crsinc') {
my $formitem = 'form.lti_'.$item.'_'.$idx;
$env{$formitem} =~ s/(`)/'/g;
if ($item eq 'lifetime') {
$env{$formitem} =~ s/[^\d.]//g;
}
if ($env{$formitem} ne '') {
- if (($item eq 'key') || ($item eq 'secret')) {
- $encconfig{$itemid}{$item} = $env{$formitem};
- } else {
- $confhash{$itemid}{$item} = $env{$formitem};
- unless (($idx eq 'add') || ($changes{$itemid})) {
- if ($domconfig{$action}{$itemid}{$item} ne $confhash{$itemid}{$item}) {
- $changes{$itemid} = 1;
- }
+ $confhash{$itemid}{$item} = $env{$formitem};
+ unless (($idx eq 'add') || ($changes{$itemid})) {
+ if ($currlti{$item} ne $confhash{$itemid}{$item}) {
+ $changes{$itemid} = 1;
}
}
}
@@ -15293,27 +15908,27 @@ sub modify_lti {
unless (($idx eq 'add') || ($changes{$itemid})) {
if ($confhash{$itemid}{'crsinc'}) {
foreach my $field ('mapcrs','storecrs','makecrs','section','passback','roster') {
- if ($domconfig{$action}{$itemid}{$field} ne $confhash{$itemid}{$field}) {
+ if ($currlti{$field} ne $confhash{$itemid}{$field}) {
$changes{$itemid} = 1;
}
}
unless ($changes{$itemid}) {
- if ($domconfig{$action}{$itemid}{'passback'} eq $confhash{$itemid}{'passback'}) {
- if ($domconfig{$action}{$itemid}{'passbackformat'} ne $confhash{$itemid}{'passbackformat'}) {
+ if ($currlti{'passback'} eq $confhash{$itemid}{'passback'}) {
+ if ($currlti{'passbackformat'} ne $confhash{$itemid}{'passbackformat'}) {
$changes{$itemid} = 1;
}
}
}
foreach my $field ('mapcrstype','selfenroll') {
unless ($changes{$itemid}) {
- if (ref($domconfig{$action}{$itemid}{$field}) eq 'ARRAY') {
+ if (ref($currlti{$field}) eq 'ARRAY') {
if (ref($confhash{$itemid}{$field}) eq 'ARRAY') {
- my @diffs = &Apache::loncommon::compare_arrays($domconfig{$action}{$itemid}{$field},
+ my @diffs = &Apache::loncommon::compare_arrays($currlti{$field},
$confhash{$itemid}{$field});
if (@diffs) {
$changes{$itemid} = 1;
}
- } elsif (@{$domconfig{$action}{$itemid}{$field}} > 0) {
+ } elsif (@{$currlti{$field}} > 0) {
$changes{$itemid} = 1;
}
} elsif (ref($confhash{$itemid}{$field}) eq 'ARRAY') {
@@ -15324,10 +15939,10 @@ sub modify_lti {
}
}
unless ($changes{$itemid}) {
- if (ref($domconfig{$action}{$itemid}{'maproles'}) eq 'HASH') {
+ if (ref($currlti{'maproles'}) eq 'HASH') {
if (ref($confhash{$itemid}{'maproles'}) eq 'HASH') {
- foreach my $ltirole (keys(%{$domconfig{$action}{$itemid}{'maproles'}})) {
- if ($domconfig{$action}{$itemid}{'maproles'}{$ltirole} ne
+ foreach my $ltirole (keys(%{$currlti{'maproles'}})) {
+ if ($currlti{'maproles'}{$ltirole} ne
$confhash{$itemid}{'maproles'}{$ltirole}) {
$changes{$itemid} = 1;
last;
@@ -15336,13 +15951,13 @@ sub modify_lti {
unless ($changes{$itemid}) {
foreach my $ltirole (keys(%{$confhash{$itemid}{'maproles'}})) {
if ($confhash{$itemid}{'maproles'}{$ltirole} ne
- $domconfig{$action}{$itemid}{'maproles'}{$ltirole}) {
+ $currlti{'maproles'}{$ltirole}) {
$changes{$itemid} = 1;
last;
}
}
}
- } elsif (keys(%{$domconfig{$action}{$itemid}{'maproles'}}) > 0) {
+ } elsif (keys(%{$currlti{'maproles'}}) > 0) {
$changes{$itemid} = 1;
}
} elsif (ref($confhash{$itemid}{'maproles'}) eq 'HASH') {
@@ -15356,20 +15971,20 @@ sub modify_lti {
}
unless ($changes{$itemid}) {
foreach my $field ('mapuser','lcauth','lcauthparm','topmenu','inlinemenu','callback') {
- if ($domconfig{$action}{$itemid}{$field} ne $confhash{$itemid}{$field}) {
+ if ($currlti{$field} ne $confhash{$itemid}{$field}) {
$changes{$itemid} = 1;
}
}
unless ($changes{$itemid}) {
foreach my $field ('makeuser','lcmenu') {
- if (ref($domconfig{$action}{$itemid}{$field}) eq 'ARRAY') {
+ if (ref($currlti{$field}) eq 'ARRAY') {
if (ref($confhash{$itemid}{$field}) eq 'ARRAY') {
- my @diffs = &Apache::loncommon::compare_arrays($domconfig{$action}{$itemid}{$field},
+ my @diffs = &Apache::loncommon::compare_arrays($currlti{$field},
$confhash{$itemid}{$field});
if (@diffs) {
$changes{$itemid} = 1;
}
- } elsif (@{$domconfig{$action}{$itemid}{$field}} > 0) {
+ } elsif (@{$currlti{$field}} > 0) {
$changes{$itemid} = 1;
}
} elsif (ref($confhash{$itemid}{$field}) eq 'ARRAY') {
@@ -15382,6 +15997,71 @@ sub modify_lti {
}
}
}
+ if ($is_home) {
+ my $keyitem = 'form.lti_key_'.$idx;
+ $env{$keyitem} =~ s/(`)/'/g;
+ if ($env{$keyitem} ne '') {
+ $ltienc{$itemid}{'key'} = $env{$keyitem};
+ unless ($changes{$itemid}) {
+ if ($currlti{'key'} ne $env{$keyitem}) {
+ $changes{$itemid} = 1;
+ }
+ }
+ }
+ my $secretitem = 'form.lti_secret_'.$idx;
+ $env{$secretitem} =~ s/(`)/'/g;
+ if ($currlti{'usable'}) {
+ if ($env{'form.lti_changesecret_'.$idx}) {
+ if ($env{$secretitem} ne '') {
+ if ($privnum && $cipher) {
+ $ltienc{$itemid}{'secret'} = $cipher->encrypt_hex($env{$secretitem});
+ $confhash{$itemid}{'cipher'} = $privnum;
+ } else {
+ $ltienc{$itemid}{'secret'} = $env{$secretitem};
+ }
+ $changes{$itemid} = 1;
+ }
+ } else {
+ $ltienc{$itemid}{'secret'} = $currlti{'secret'};
+ $confhash{$itemid}{'cipher'} = $currlti{'cipher'};
+ }
+ if (ref($ltienc{$itemid}) eq 'HASH') {
+ if (($ltienc{$itemid}{'key'} ne '') && ($ltienc{$itemid}{'secret'} ne '')) {
+ $confhash{$itemid}{'usable'} = 1;
+ }
+ }
+ } elsif ($env{$secretitem} ne '') {
+ if ($privnum && $cipher) {
+ $ltienc{$itemid}{'secret'} = $cipher->encrypt_hex($env{$secretitem});
+ $confhash{$itemid}{'cipher'} = $privnum;
+ } else {
+ $ltienc{$itemid}{'secret'} = $env{$secretitem};
+ }
+ if (ref($ltienc{$itemid}) eq 'HASH') {
+ if (($ltienc{$itemid}{'key'} ne '') && ($ltienc{$itemid}{'key'} ne '')) {
+ $confhash{$itemid}{'usable'} = 1;
+ }
+ }
+ $changes{$itemid} = 1;
+ }
+ }
+ unless ($changes{$itemid}) {
+ foreach my $key (keys(%currlti)) {
+ if (ref($currlti{$key}) eq 'HASH') {
+ if (ref($confhash{$itemid}{$key}) eq 'HASH') {
+ foreach my $innerkey (keys(%{$currlti{$key}})) {
+ unless (exists($confhash{$itemid}{$key}{$innerkey})) {
+ $changes{$itemid} = 1;
+ last;
+ }
+ }
+ } elsif (keys(%{$currlti{$key}}) > 0) {
+ $changes{$itemid} = 1;
+ }
+ }
+ last if ($changes{$itemid});
+ }
+ }
}
if (@allpos > 0) {
my $idx = 0;
@@ -15399,12 +16079,21 @@ sub modify_lti {
}
}
}
+
+ if ((keys(%changes) == 0) && (keys(%secchanges) == 0)) {
+ return &mt('No changes made.');
+ }
+
my %ltihash = (
$action => { %confhash }
);
- my %ltienchash = (
- $action => { %encconfig }
- );
+ my %ltienchash;
+
+ if ($is_home) {
+ %ltienchash = (
+ $action => { %ltienc }
+ );
+ }
if (keys(%secchanges)) {
$ltihash{'ltisec'} = \%newltisec;
if ($secchanges{'linkprot'}) {
@@ -15415,43 +16104,32 @@ sub modify_lti {
}
my $putresult = &Apache::lonnet::put_dom('configuration',\%ltihash,$dom);
if ($putresult eq 'ok') {
- my %keystore;
- &store_security($dom,'lti',\%secchanges,\%newkeyset,\%keystore,$lastactref);
- &Apache::lonnet::put_dom('encconfig',\%ltienchash,$dom,undef,1);
- if ((keys(%changes) == 0) && (keys(%secchanges) == 0)) {
- return &mt('No changes made.');
+ if (keys(%ltienchash)) {
+ &Apache::lonnet::put_dom('encconfig',\%ltienchash,$dom,undef,1);
}
$resulttext = &mt('Changes made:').'';
if (keys(%secchanges) > 0) {
- $resulttext .= <i_security_results('lti',\%secchanges,\%newltisec,\%newkeyset,\%keystore);
+ $resulttext .= <i_security_results($dom,'lti',\%secchanges,\%newltisec,\%newkeyset,\%keystore);
if (exists($secchanges{'linkprot'})) {
$resulttext .= $linkprotoutput;
}
}
if (keys(%changes) > 0) {
my $cachetime = 24*60*60;
- my %ltiall = %confhash;
- foreach my $id (keys(%ltiall)) {
- if (ref($encconfig{$id}) eq 'HASH') {
- foreach my $item ('key','secret') {
- $ltiall{$id}{$item} = $encconfig{$id}{$item};
- }
- }
- }
- &Apache::lonnet::do_cache_new('lti',$dom,\%ltiall,$cachetime);
+ &Apache::lonnet::do_cache_new('lti',$dom,\%confhash,$cachetime);
if (ref($lastactref) eq 'HASH') {
$lastactref->{'lti'} = 1;
}
my %bynum;
foreach my $itemid (sort(keys(%changes))) {
- my $position = $confhash{$itemid}{'order'};
- $bynum{$position} = $itemid;
+ if (ref($confhash{$itemid}) eq 'HASH') {
+ my $position = $confhash{$itemid}{'order'};
+ $bynum{$position} = $itemid;
+ }
}
foreach my $pos (sort { $a <=> $b } keys(%bynum)) {
my $itemid = $bynum{$pos};
- if (ref($confhash{$itemid}) ne 'HASH') {
- $resulttext .= ''.&mt('Deleted: [_1]',$changes{$itemid}).' ';
- } else {
+ if (ref($confhash{$itemid}) eq 'HASH') {
$resulttext .= ''.$confhash{$itemid}{'consumer'}.' ';
my $position = $pos + 1;
$resulttext .= ''.&mt('Order: [_1]',$position).' ';
@@ -15460,13 +16138,11 @@ sub modify_lti {
$resulttext .= ''.$lt{$item}.': '.$confhash{$itemid}{$item}.' ';
}
}
- if ($encconfig{$itemid}{'key'} ne '') {
- $resulttext .= ''.$lt{'key'}.': '.$encconfig{$itemid}{'key'}.' ';
+ if ($ltienc{$itemid}{'key'} ne '') {
+ $resulttext .= ''.$lt{'key'}.': '.$ltienc{$itemid}{'key'}.' ';
}
- if ($encconfig{$itemid}{'secret'} ne '') {
- $resulttext .= ''.$lt{'secret'}.': ';
- my $num = length($encconfig{$itemid}{'secret'});
- $resulttext .= ('*'x$num).' ';
+ if ($ltienc{$itemid}{'secret'} ne '') {
+ $resulttext .= ''.$lt{'secret'}.': ['.&mt('not shown').'] ';
}
if ($confhash{$itemid}{'requser'}) {
if ($confhash{$itemid}{'callback'}) {
@@ -15618,8 +16294,18 @@ sub modify_lti {
$resulttext .= ' ';
}
}
+ if (keys(%deletions)) {
+ foreach my $itemid (sort { $a <=> $b } keys(%deletions)) {
+ $resulttext .= ''.&mt('Deleted: [_1]',$changes{$itemid}).' ';
+ }
+ }
}
$resulttext .= ' ';
+ if (ref($lastactref) eq 'HASH') {
+ if (($secchanges{'encrypt'}) || ($secchanges{'private'})) {
+ $lastactref->{'domdefaults'} = 1;
+ }
+ }
} else {
$errors .= ''.&mt('Failed to save changes').' ';
}
@@ -15630,6 +16316,30 @@ sub modify_lti {
return $resulttext;
}
+sub get_priv_creds {
+ my ($dom,$home,$encchg,$encrypt,$storedsec) = @_;
+ my ($needenc,$cipher,$privnum);
+ my %domdefs = &Apache::lonnet::get_domain_defaults($dom);
+ if (($encchg) && (ref($encrypt) eq 'HASH')) {
+ $needenc = $encrypt->{'consumers'}
+ } else {
+ $needenc = $domdefs{'ltienc_consumers'};
+ }
+ if ($needenc) {
+ if (($storedsec eq 'ok') || ((ref($domdefs{'ltiprivhosts'}) eq 'ARRAY') &&
+ (grep(/^\Q$home\E$/,@{$domdefs{'ltiprivhosts'}})))) {
+ my %privhash = &Apache::lonnet::restore_dom('lti','private',$dom,$home,1);
+ my $privkey = $privhash{'key'};
+ $privnum = $privhash{'version'};
+ if (($privnum) && ($privkey ne '')) {
+ $cipher = Crypt::CBC->new({'key' => $privkey,
+ 'cipher' => 'DES'});
+ }
+ }
+ }
+ return ($cipher,$privnum);
+}
+
sub get_lti_id {
my ($domain,$consumer) = @_;
# get lock on lti db
@@ -16432,7 +17142,7 @@ sub modify_contacts {
$contacts_hash{'contacts'}{'overrides'}{$type}{'include'} = $includeloc{$type}.':'.&escape($includestr{$type});
$newsetting{'override_'.$type}{'include'} = $contacts_hash{'contacts'}{'overrides'}{$type}{'include'};
}
- }
+ }
}
}
if (keys(%currsetting) > 0) {
@@ -16490,12 +17200,12 @@ sub modify_contacts {
}
}
if (@statuses) {
- if (ref($currsetting{'overrides'}) eq 'HASH') {
+ if (ref($currsetting{'overrides'}) eq 'HASH') {
foreach my $key (keys(%{$currsetting{'overrides'}})) {
if (ref($currsetting{'overrides'}{$key}) eq 'HASH') {
if (ref($newsetting{'override_'.$key}) eq 'HASH') {
foreach my $item (@contacts,'bcc','others','include') {
- if ($currsetting{'overrides'}{$key}{$item} ne $newsetting{'override_'.$key}{$item}) {
+ if ($currsetting{'overrides'}{$key}{$item} ne $newsetting{'override_'.$key}{$item}) {
push(@{$changes{'overrides'}},$key);
last;
}
@@ -16512,7 +17222,7 @@ sub modify_contacts {
}
} else {
foreach my $key (@overrides) {
- push(@{$changes{'overrides'}},$key);
+ push(@{$changes{'overrides'}},$key);
}
}
}
@@ -16694,7 +17404,7 @@ sub modify_contacts {
$resulttext .= $bcctext.': '.$bcc{$type}.' ';
} elsif (!@text) {
$resulttext .= &mt('No one');
- }
+ }
if ($includestr{$type} ne '') {
if ($includeloc{$type} eq 'b') {
$resulttext .= ' '.&mt('Text automatically added to e-mail body:').' '.$includestr{$type};
@@ -16718,14 +17428,14 @@ sub modify_contacts {
if (ref($newsetting{'override_'.$type}) eq 'HASH') {
my @text;
foreach my $item (@contacts) {
- if ($newsetting{'override_'.$type}{$item}) {
+ if ($newsetting{'override_'.$type}{$item}) {
push(@text,$short_titles->{$item});
}
}
if ($newsetting{'override_'.$type}{'others'} ne '') {
push(@text,$newsetting{'override_'.$type}{'others'});
}
-
+
if (@text) {
$resulttext .= &mt('Helpdesk e-mail sent to: [_1]',
''.join(', ',@text).' ');
@@ -16888,7 +17598,7 @@ sub modify_contacts {
}
sub modify_privacy {
- my ($dom,%domconfig) = @_;
+ my ($dom,$lastactref,%domconfig) = @_;
my ($resulttext,%current,%changes);
if (ref($domconfig{'privacy'}) eq 'HASH') {
%current = %{$domconfig{'privacy'}};
@@ -17124,6 +17834,28 @@ sub modify_privacy {
}
}
$resulttext .= ' ';
+ if ($changes{'approval'}) {
+ my %domdefaults = &Apache::lonnet::get_domain_defaults($dom);
+ delete($domdefaults{'userapprovals'});
+ if (ref($privacyhash{'approval'}) eq 'HASH') {
+ foreach my $domtype ('instdom','extdom') {
+ if (ref($privacyhash{'approval'}{$domtype}) eq 'HASH') {
+ foreach my $roletype ('domain','author','course','community') {
+ if ($privacyhash{'approval'}{$domtype}{$roletype} eq 'user') {
+ $domdefaults{'userapprovals'} = 1;
+ last;
+ }
+ }
+ }
+ last if ($domdefaults{'userapprovals'});
+ }
+ }
+ my $cachetime = 24*60*60;
+ &Apache::lonnet::do_cache_new('domdefaults',$dom,\%domdefaults,$cachetime);
+ if (ref($lastactref) eq 'HASH') {
+ $lastactref->{'domdefaults'} = 1;
+ }
+ }
} else {
$resulttext = &mt('No changes made to user information settings');
}
@@ -17566,7 +18298,7 @@ sub modify_passwords {
);
my $needed = ''.
join(' ',map {$rulenames{$_} } @{$confighash{'passwords'}{'chars'}}).
- ' ';
+ ' ';
$resulttext .= ''.&mt('[_1] set to: [_2]',$titles{'chars'},$needed).' ';
} else {
$resulttext .= ''.&mt('[_1] set to none',$titles{'chars'}).' ';
@@ -18049,7 +18781,7 @@ sub modify_selfcreation {
if (($chosen eq 'inst') || ($chosen eq 'noninst')) {
my $emaildom;
if ($env{'form.cancreate_emaildomain_'.$chosen.'_'.$type} =~ /^\@[^\@]+$/) {
- $emaildom = $env{'form.cancreate_emaildomain_'.$chosen.'_'.$type};
+ $emaildom = $env{'form.cancreate_emaildomain_'.$chosen.'_'.$type};
$cancreate{'emaildomain'}{$type}{$chosen} = $emaildom;
if (ref($curremaildom{$type}) eq 'HASH') {
if (exists($curremaildom{$type}{$chosen})) {
@@ -18061,7 +18793,7 @@ sub modify_selfcreation {
}
} elsif ($emaildom ne '') {
push(@{$changes{'cancreate'}},'emaildomain');
- }
+ }
}
$cancreate{'emailoptions'}{$type} = $env{'form.cancreate_emailoptions_'.$type};
} elsif ($chosen eq 'custom') {
@@ -18488,7 +19220,7 @@ sub modify_selfcreation {
);
if (@types) {
if (@statuses) {
- $chgtext .= &mt('Processing of requests to create account with e-mail verification set as follows:').
+ $chgtext .= &mt('Processing of requests to create account with e-mail verification set as follows:').
'';
foreach my $status (@statuses) {
if ($status eq 'default') {
@@ -18696,7 +19428,7 @@ sub modify_selfcreation {
$typename = $othertitle;
} else {
$typename = $usertypes{$type};
- }
+ }
$chgtext .= &mt('(Affiliation: [_1])',$typename);
}
if (@{$email_rule{$type}} > 0) {
@@ -19041,7 +19773,7 @@ sub modify_defaults {
}
if ($item eq 'portal_def') {
unless (grep(/^\Q$item\E$/,@errors)) {
- if ($newvalues{$item} eq '') {
+ if ($newvalues{$item} eq '') {
foreach my $field ('email','web') {
if (exists($domdefaults{$item.'_'.$field})) {
delete($domdefaults{$item.'_'.$field});
@@ -19226,7 +19958,7 @@ sub modify_defaults {
$resulttext =~ s/, $//;
$resulttext .= '';
} else {
- $resulttext .= ''.&mt('Institutional user status types deleted').' ';
+ $resulttext .= ''.&mt('Institutional user status types deleted').' ';
}
}
} elsif ($item eq 'unamemap_rule') {
@@ -20261,12 +20993,15 @@ sub modify_coursedefaults {
my @toggles = ('canuse_pdfforms','uselcmath','usejsme','inline_chem','ltiauth');
my @numbers = ('anonsurvey_threshold','uploadquota_official','uploadquota_unofficial',
'uploadquota_community','uploadquota_textbook','uploadquota_placement',
- 'mysqltables_official','mysqltables_unofficial','mysqltables_community',
- 'mysqltables_textbook','mysqltables_placement');
+ 'coursequota_official','coursequota_unofficial','coursequota_community',
+ 'coursequota_textbook','coursequota_placement','mysqltables_official',
+ 'mysqltables_unofficial','mysqltables_community','mysqltables_textbook',
+ 'mysqltables_placement');
my @types = ('official','unofficial','community','textbook','placement');
my %staticdefaults = (
anonsurvey_threshold => 10,
uploadquota => 500,
+ coursequota => 20,
postsubmit => 60,
mysqltables => 172800,
domexttool => 1,
@@ -20314,7 +21049,7 @@ sub modify_coursedefaults {
}
$defaultshash{'coursedefaults'}{$item} = $newdef;
} else {
- my ($setting,$type) = ($item =~ /^(uploadquota|mysqltables)_(\w+)$/);
+ my ($setting,$type) = ($item =~ /^(uploadquota|coursequota|mysqltables)_(\w+)$/);
if (ref($domconfig{'coursedefaults'}{$setting}) eq 'HASH') {
$currdef = $domconfig{'coursedefaults'}{$setting}{$type};
}
@@ -20326,7 +21061,7 @@ sub modify_coursedefaults {
unless (($currdef eq '') && ($newdef == $staticdefaults{$item})) {
$changes{$item} = 1;
}
- } elsif ($item =~ /^(uploadquota|mysqltables)_/) {
+ } elsif ($item =~ /^(uploadquota|coursequota|mysqltables)_/) {
my $setting = $1;
unless (($currdef eq '') && ($newdef == $staticdefaults{$setting})) {
$changes{$setting} = 1;
@@ -20463,7 +21198,7 @@ sub modify_coursedefaults {
}
my (%newdomexttool,%newexttool,%olddomexttool,%oldexttool);
map { $newdomexttool{$_} = 1; } &Apache::loncommon::get_env_multiple('form.domexttool');
- map { $newexttool{$_} = 1; } &Apache::loncommon::get_env_multiple('form.exttool');
+ map { $newexttool{$_} = 1; } &Apache::loncommon::get_env_multiple('form.exttool');
if (ref($domconfig{'coursedefaults'}{'domexttool'}) eq 'HASH') {
%olddomexttool = %{$domconfig{'coursedefaults'}{'domexttool'}};
} else {
@@ -20476,7 +21211,7 @@ sub modify_coursedefaults {
}
}
if (ref($domconfig{'coursedefaults'}{'exttool'}) eq 'HASH') {
- %oldexttool = %{$domconfig{'coursedefaults'}{'exttool'}};
+ %oldexttool = %{$domconfig{'coursedefaults'}{'exttool'}};
} else {
foreach my $type (@types) {
if ($staticdefaults{'exttool'}) {
@@ -20512,7 +21247,7 @@ sub modify_coursedefaults {
($changes{'coursecredits'}) || ($changes{'uselcmath'}) || ($changes{'usejsme'}) ||
($changes{'canclone'}) || ($changes{'mysqltables'}) || ($changes{'texengine'}) ||
($changes{'inline_chem'}) || ($changes{'ltiauth'}) || ($changes{'domexttool'}) ||
- ($changes{'exttool'}) ) {
+ ($changes{'exttool'}) || ($changes{'coursequota'})) {
foreach my $item ('canuse_pdfforms','uselcmath','usejsme','inline_chem','texengine',
'ltiauth') {
if ($changes{$item}) {
@@ -20545,6 +21280,13 @@ sub modify_coursedefaults {
}
}
}
+ if ($changes{'coursequota'}) {
+ if (ref($defaultshash{'coursedefaults'}{'coursequota'}) eq 'HASH') {
+ foreach my $type (@types) {
+ $domdefaults{$type.'coursequota'}=$defaultshash{'coursedefaults'}{'coursequota'}{$type};
+ }
+ }
+ }
if ($changes{'canclone'}) {
if (ref($defaultshash{'coursedefaults'}{'canclone'}) eq 'HASH') {
if (ref($defaultshash{'coursedefaults'}{'canclone'}{'instcode'}) eq 'ARRAY') {
@@ -20623,6 +21365,19 @@ sub modify_coursedefaults {
} else {
$resulttext .= ''.&mt('Default quota for content uploaded via Course Editor remains default: [_1] MB',$staticdefaults{'uploadquota'}).' ';
}
+ } elsif ($item eq 'coursequota') {
+ if (ref($defaultshash{'coursedefaults'}{'coursequota'}) eq 'HASH') {
+ $resulttext .= ''.&mt('Default cumulative quota for all group portfolio spaces in course set as follows:').''.
+ ''.&mt('Official courses: [_1] MB',''.$defaultshash{'coursedefaults'}{'coursequota'}{'official'}.' ').' '.
+ ''.&mt('Unofficial courses: [_1] MB',''.$defaultshash{'coursedefaults'}{'coursequota'}{'unofficial'}.' ').' '.
+ ''.&mt('Textbook courses: [_1] MB',''.$defaultshash{'coursedefaults'}{'coursequota'}{'textbook'}.' ').' '.
+ ''.&mt('Placement tests: [_1] MB',''.$defaultshash{'coursedefaults'}{'coursequota'}{'placement'}.' ').' '.
+ ''.&mt('Communities: [_1] MB',''.$defaultshash{'coursedefaults'}{'coursequota'}{'community'}.' ').' '.
+ ' '.
+ ' ';
+ } else {
+ $resulttext .= ''.&mt('Default cumulative quota for all group portfolio spaces in course remains default: [_1] MB',$staticdefaults{'coursequota'}).' ';
+ }
} elsif ($item eq 'mysqltables') {
if (ref($defaultshash{'coursedefaults'}{'mysqltables'}) eq 'HASH') {
$resulttext .= ''.&mt('Lifetime of "Temporary" MySQL tables (student performance data) on homeserver').''.
@@ -21129,7 +21884,7 @@ sub modify_wafproxy {
}
} elsif ($currvalue{$item}) {
$changes{$item} = 1;
- }
+ }
}
} else {
if (keys(%curralias)) {
@@ -21137,7 +21892,7 @@ sub modify_wafproxy {
}
if (keys(%currsaml)) {
$changes{'saml'} = 1;
- }
+ }
if (keys(%currvalue)) {
foreach my $key (keys(%currvalue)) {
$changes{$key} = 1;
@@ -21147,7 +21902,7 @@ sub modify_wafproxy {
if (keys(%changes)) {
my %defaultshash = (
wafproxy => \%wafproxy,
- );
+ );
my $putresult = &Apache::lonnet::put_dom('configuration',\%defaultshash,
$dom);
if ($putresult eq 'ok') {
@@ -21163,7 +21918,7 @@ sub modify_wafproxy {
$domdefaults{'waf_'.$item} = $wafproxy{$item};
} elsif (exists($domdefaults{'waf_'.$item})) {
delete($domdefaults{'waf_'.$item});
- }
+ }
}
}
if ($updatedomdefs) {
@@ -21230,7 +21985,7 @@ sub modify_wafproxy {
$output .= ''.&mt('Aliases deleted for hostnames').' ';
}
} elsif ($item eq 'saml') {
- my $shown;
+ my $shown;
if (ref($wafproxy{'saml'}) eq 'HASH') {
if (keys(%{$wafproxy{'saml'}})) {
$shown = join(', ',sort(keys(%{$wafproxy{'saml'}})));
@@ -21560,7 +22315,7 @@ sub modify_usersessions {
if (($offload eq 'offloadoth') && (@okoffloadoth)) {
$changes{'offloadoth'} = 1;
}
- }
+ }
}
} else {
if (@okoffload) {
@@ -22098,7 +22853,7 @@ sub modify_loadbalancing {
}
if ($env{'form.loadbalancing_cookie_'.$i}) {
$defaultshash{'loadbalancing'}{$balancer}{'cookie'} = 1;
- if (exists($currbalancer{$balancer})) {
+ if (exists($currbalancer{$balancer})) {
unless ($currcookies{$balancer}) {
$changes{'curr'}{$balancer}{'cookie'} = 1;
}
@@ -22784,7 +23539,6 @@ function balancerChange(balnum,baltotal,
END
}
-
sub new_spares_js {
my @sparestypes = ('primary','default');
my $types = join("','",@sparestypes);