'.
- "$description | \n".
+ "$description | \n".
''.
'';
- my %headers = &Apache::lonlocal::texthash(
+ my %headers = &Apache::lonlocal::texthash(
approve => 'Processing',
email => 'E-mail',
username => 'Username',
@@ -10404,7 +10078,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 '') {
@@ -10722,7 +10396,7 @@ sub print_defaults {
if ($defaults{$item.'_'.$field}) {
$checkedon = $checkedoff;
$checkedoff = '';
- }
+ }
$datatable .= ''.
' '.$titles->{$field}.' '.
''.
@@ -11061,10 +10735,13 @@ sub legacy_scantronformat {
my ($url,$error);
my @statinfo = &Apache::lonnet::stat_file($newurl);
if ((!@statinfo) || ($statinfo[0] eq 'no_such_dir')) {
+ my $modified = [];
(my $result,$url) =
- &publishlogo($r,'copy',$legacyfile,$dom,$confname,'scantron',
- '','',$newfile);
- if ($result ne 'ok') {
+ &Apache::lonconfigsettings::publishlogo($r,'copy',$legacyfile,$dom,$confname,
+ 'scantron','','',$newfile,$modified);
+ if ($result eq 'ok') {
+ &update_modify_urls($r,$modified);
+ } else {
$error = &mt("An error occurred publishing the [_1] bubblesheet format file in RES space. Error was: [_2].",$newfile,$result);
}
}
@@ -11548,7 +11225,7 @@ sub defaults_javascript {
function portalExtras(caller) {
var x = caller.value;
var y = new Array('email','web');
- for (var i=0; i 0) {
@@ -11644,7 +11321,7 @@ sub passwords_javascript {
passexp => 'Warning: days before password expiration must be a positive integer (or blank).',
passnum => 'Warning: number of previous passwords to save must be a positive integer (or blank).',
);
- } elsif ($prefix eq 'secrets') {
+ } elsif (($prefix eq 'ltisecrets') || ($prefix eq 'toolsecrets')) {
%intalert = &Apache::lonlocal::texthash (
passmin => 'Warning: minimum secret length must be a positive integer greater than 6.',
passmax => 'Warning: maximum secret length must be a positive integer (or blank).',
@@ -11652,7 +11329,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) {
@@ -12046,7 +11723,6 @@ sub modifiable_userdata_row {
'';
my $rem;
my %checks;
- my %current;
if (ref($settings) eq 'HASH') {
my $hashref;
if ($context eq 'lti') {
@@ -12072,7 +11748,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') {
@@ -12084,7 +11760,6 @@ sub modifiable_userdata_row {
}
}
}
-
my $total = scalar(@fields);
for (my $i=0; $i<$total; $i++) {
$rem = $i%($numinrow);
@@ -12248,7 +11923,7 @@ sub insttypes_row {
} else {
$output .= '';
}
- $output .= ' ';
+ $output .= ' ';
} else {
if ($rem == 0) {
$output .= ' | ';
@@ -12518,13 +12193,16 @@ sub modify_login {
if ($addedfile ne '') {
push(@allnew,$addedfile);
}
+ my $modified = [];
foreach my $lang (@allnew) {
my $formelem = 'loginhelpurl_'.$lang;
if ($lang eq $env{'form.loginhelpurl_add_lang'}) {
$formelem = 'loginhelpurl_add_file';
}
- (my $result,$newurl{$lang}) = &publishlogo($r,'upload',$formelem,$dom,$confname,
- "help/$lang",'','',$newfile{$lang});
+ (my $result,$newurl{$lang}) =
+ &Apache::lonconfigsettings::publishlogo($r,'upload',$formelem,$dom,$confname,
+ "help/$lang",'','',$newfile{$lang},
+ $modified);
if ($result eq 'ok') {
$loginhash{'login'}{'helpurl'}{$lang} = $newurl{$lang};
$changes{'helpurl'}{$lang} = 1;
@@ -12537,6 +12215,7 @@ sub modify_login {
}
}
}
+ &update_modify_urls($r,$modified);
} else {
$error = &mt("Upload of custom log-in help file(s) failed because an author role could not be assigned to a Domain Configuration user ([_1]) in domain: [_2]. Error was: [_3].",$confname,$dom,$author_ok);
}
@@ -12594,11 +12273,14 @@ sub modify_login {
if ($switchserver) {
$error = &mt("Upload of custom markup is not permitted to this server: [_1]",$switchserver);
} elsif ($author_ok eq 'ok') {
+ my $modified = [];
foreach my $lonhost (@newhosts) {
my $formelem = 'loginheadtag_'.$lonhost;
- (my $result,$newheadtagurls{$lonhost}) = &publishlogo($r,'upload',$formelem,$dom,$confname,
- "login/headtag/$lonhost",'','',
- $env{'form.loginheadtag_'.$lonhost.'.filename'});
+ (my $result,$newheadtagurls{$lonhost}) =
+ &Apache::lonconfigsettings::publishlogo($r,'upload',$formelem,$dom,$confname,
+ "login/headtag/$lonhost",'','',
+ $env{'form.loginheadtag_'.$lonhost.'.filename'},
+ $modified);
if ($result eq 'ok') {
$loginhash{'login'}{'headtag'}{$lonhost}{'url'} = $newheadtagurls{$lonhost};
$changes{'headtag'}{$lonhost} = 1;
@@ -12615,6 +12297,7 @@ sub modify_login {
}
}
}
+ &update_modify_urls($r,$modified);
} else {
$error = &mt("Upload of custom markup file(s) failed because an author role could not be assigned to a Domain Configuration user ([_1]) in domain: [_2]. Error was: [_3].",$confname,$dom,$author_ok);
}
@@ -12670,15 +12353,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;
@@ -12689,11 +12372,14 @@ sub modify_login {
if ($switchserver) {
$error = &mt("Upload of SSO Button Image is not permitted to this server: [_1].",$switchserver);
} elsif ($author_ok eq 'ok') {
+ my $modified = [];
foreach my $lonhost (@newsamlimgs) {
my $formelem = 'saml_img_'.$lonhost;
- my ($result,$imgurl) = &publishlogo($r,'upload',$formelem,$dom,$confname,
- "login/saml/$lonhost",'','',
- $env{'form.saml_img_'.$lonhost.'.filename'});
+ my ($result,$imgurl) =
+ &Apache::lonconfigsettings::publishlogo($r,'upload',$formelem,$dom,$confname,
+ "login/saml/$lonhost",'','',
+ $env{'form.saml_img_'.$lonhost.'.filename'},
+ $modified);
if ($result eq 'ok') {
$currsaml{$lonhost}{'img'} = $imgurl;
$loginhash{'login'}{'saml'}{$lonhost}{'img'} = $imgurl;
@@ -12704,6 +12390,7 @@ sub modify_login {
$errors .= ''.$puberror.'';
}
}
+ &update_modify_urls($r,$modified);
} else {
$error = &mt("Upload of SSO button image file(s) failed because an author role could not be assigned to a Domain Configuration user ([_1]) in domain: [_2]. Error was: [_3].",$confname,$dom,$author_ok);
}
@@ -13058,7 +12745,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);
@@ -13091,9 +12778,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';
@@ -13125,7 +12812,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') {
@@ -13205,7 +12892,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').':';
+ $secchanges->{'private'} = 1;
+ $newkeyset->{$hostid} = $env{$keyitem};
}
}
- $resulttext .= '';
- } else {
- $resulttext = &mt('No changes made.');
}
- } else {
- $errors .= ''.&mt('Failed to save changes').'';
- }
- if ($errors) {
- $resulttext .= &mt('The following errors occurred: ').'';
}
- return $resulttext;
}
-sub process_ltitools_image {
- my ($r,$dom,$confname,$caller,$itemid,$configuserok,$switchserver,$author_ok) = @_;
- my $filename = $env{'form.'.$caller.'.filename'};
- my ($error,$url);
- my ($width,$height) = (21,21);
- if ($configuserok eq 'ok') {
- if ($switchserver) {
- $error = &mt('Upload of Tool Provider (LTI) icon is not permitted to this server: [_1]',
- $switchserver);
- } elsif ($author_ok eq 'ok') {
- my ($result,$imageurl,$madethumb) =
- &publishlogo($r,'upload',$caller,$dom,$confname,
- "ltitools/$itemid/icon",$width,$height);
- if ($result eq 'ok') {
- if ($madethumb) {
- my ($path,$imagefile) = ($imageurl =~ m{^(.+)/([^/]+)$});
- my $imagethumb = "$path/tn-".$imagefile;
- $url = $imagethumb;
- } else {
- $url = $imageurl;
- }
- } else {
- $error = &mt("Upload of [_1] failed because an error occurred publishing the file in RES space. Error was: [_2].",$filename,$result);
+sub store_security {
+ my ($dom,$context,$secchanges,$newkeyset,$keystore) = @_;
+ return unless ((ref($secchanges) eq 'HASH') && (ref($newkeyset) eq 'HASH') &&
+ (ref($keystore) eq 'HASH'));
+ if (keys(%{$secchanges})) {
+ if ($secchanges->{'private'}) {
+ my $who = &escape($env{'user.name'}.':'.$env{'user.domain'});
+ foreach my $hostid (keys(%{$newkeyset})) {
+ my $storehash = {
+ key => $newkeyset->{$hostid},
+ who => $env{'user.name'}.':'.$env{'user.domain'},
+ };
+ $keystore->{$hostid} = &Apache::lonnet::store_dom($storehash,$context,'private',
+ $dom,$hostid);
}
- } else {
- $error = &mt("Upload of [_1] failed because an author role could not be assigned to a Domain Configuration user ([_2]) in domain: [_3]. Error was: [_4].",$filename,$confname,$dom,$author_ok);
}
- } else {
- $error = &mt("Upload of [_1] failed because a Domain Configuration user ([_2]) could not be created in domain: [_3]. Error was: [_4].",$filename,$confname,$dom,$configuserok);
}
- return ($url,$error);
}
-sub get_ltitools_id {
- my ($cdom,$title) = @_;
- # get lock on ltitools db
- my $lockhash = {
- lock => $env{'user.name'}.
- ':'.$env{'user.domain'},
- };
- my $tries = 0;
- my $gotlock = &Apache::lonnet::newput_dom('ltitools',$lockhash,$cdom);
- my ($id,$error);
-
- while (($gotlock ne 'ok') && ($tries<10)) {
- $tries ++;
- sleep (0.1);
- $gotlock = &Apache::lonnet::newput_dom('ltitools',$lockhash,$cdom);
- }
- if ($gotlock eq 'ok') {
- my %currids = &Apache::lonnet::dump_dom('ltitools',$cdom);
- if ($currids{'lock'}) {
- delete($currids{'lock'});
- if (keys(%currids)) {
- my @curr = sort { $a <=> $b } keys(%currids);
- if ($curr[-1] =~ /^\d+$/) {
- $id = 1 + $curr[-1];
- }
+sub lti_security_results {
+ 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 = (
+ crs => {
+ on => &mt('Encryption of stored link protection secrets defined in courses enabled'),
+ off => &mt('Encryption of stored link protection secrets defined in courses disabled'),
+ },
+ dom => {
+ on => &mt('Encryption of stored link protection secrets defined in domain enabled'),
+ off => &mt('Encryption of stored link protection secrets defined in domain disabled'),
+ },
+ consumers => {
+ on => &mt('Encryption of stored consumer secrets defined in domain enabled'),
+ off => &mt('Encryption of stored consumer secrets defined in domain disabled'),
+ },
+ );
} else {
- $id = 1;
+ %encrypted = (
+ crs => {
+ on => &mt('Encryption of stored external tool secrets defined in courses enabled'),
+ off => &mt('Encryption of stored external tool secrets defined in courses disabled'),
+ },
+ dom => {
+ on => &mt('Encryption of stored external tool secrets defined in domain enabled'),
+ off => &mt('Encryption of stored external tool secrets defined in domain disabled'),
+ },
+ );
+
}
- if ($id) {
- unless (&Apache::lonnet::newput_dom('ltitools',{ $id => $title },$cdom) eq 'ok') {
- $error = 'nostore';
+ 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'};
+ }
+ }
+ $output .= ''.$shown.'';
+ }
+ } elsif ($item eq 'rules') {
+ my %titles = &Apache::lonlocal::texthash(
+ min => 'Minimum password length',
+ max => 'Maximum password length',
+ chars => 'Required characters',
+ );
+ foreach my $rule ('min','max') {
+ if ($newsec->{rules}{$rule} eq '') {
+ if ($rule eq 'min') {
+ $output .= ''.&mt('[_1] not set.',$titles{$rule});
+ ' '.&mt('Default of [_1] will be used',
+ $Apache::lonnet::passwdmin).'';
+ } else {
+ $output .= ''.&mt('[_1] set to none',$titles{$rule}).'';
+ }
+ } else {
+ $output .= ''.&mt('[_1] set to [_2]',$titles{$rule},$newsec->{rules}{$rule}).'';
+ }
+ }
+ if (ref($newsec->{'rules'}{'chars'}) eq 'ARRAY') {
+ if (@{$newsec->{'rules'}{'chars'}} > 0) {
+ my %rulenames = &Apache::lonlocal::texthash(
+ uc => 'At least one upper case letter',
+ lc => 'At least one lower case letter',
+ num => 'At least one number',
+ spec => 'At least one non-alphanumeric',
+ );
+ my $needed = '- '.
+ join('
- ',map {$rulenames{$_} } @{$newsec->{'rules'}{'chars'}}).
+ '
';
+ $output .= ''.&mt('[_1] set to: [_2]',$titles{'chars'},$needed).'';
+ } else {
+ $output .= ''.&mt('[_1] set to none',$titles{'chars'}).'';
}
} else {
- $error = 'nonumber';
+ $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;
+ }
+ }
}
+ } elsif ($item eq 'linkprot') {
+ next;
}
- my $dellockoutcome = &Apache::lonnet::del_dom('ltitools',['lock'],$cdom);
- } else {
- $error = 'nolock';
}
- return ($id,$error);
+ if ($needs_update) {
+ my $cachetime = 24*60*60;
+ &Apache::lonnet::do_cache_new('domdefaults',$dom,\%domdefaults,$cachetime);
+ }
+ return $output;
}
sub modify_proctoring {
@@ -15916,9 +15110,11 @@ sub process_proctoring_image {
$error = &mt('Upload of Remote Proctoring Provider icon is not permitted to this server: [_1]',
$switchserver);
} elsif ($author_ok eq 'ok') {
+ my $modified = [];
my ($result,$imageurl,$madethumb) =
- &publishlogo($r,'upload',$caller,$dom,$confname,
- "proctoring/$provider/icon",$width,$height);
+ &Apache::lonconfigsettings::publishlogo($r,'upload',$caller,$dom,$confname,
+ "proctoring/$provider/icon",$width,$height,
+ '',$modified);
if ($result eq 'ok') {
if ($madethumb) {
my ($path,$imagefile) = ($imageurl =~ m{^(.+)/([^/]+)$});
@@ -15927,6 +15123,7 @@ sub process_proctoring_image {
} else {
$url = $imageurl;
}
+ &update_modify_urls($r,$modified);
} else {
$error = &mt("Upload of [_1] failed because an error occurred publishing the file in RES space. Error was: [_2].",$filename,$result);
}
@@ -15942,7 +15139,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);
@@ -15963,81 +15160,9 @@ sub modify_lti {
map { $posscrstype{$_} = 1; } @coursetypes;
my %menutitles = <imenu_titles();
+ my (%currltisec,%secchanges,%newltisec,%newltienc,%newkeyset);
- my (%currltisec,%secchanges,%newltisec,%newltienc,%keyset,%newkeyset);
- $newltisec{'private'}{'keys'} = [];
- $newltisec{'encrypt'} = {};
- $newltisec{'rules'} = {};
- $newltisec{'linkprot'} = {};
- if (ref($domconfig{'ltisec'}) eq 'HASH') {
- %currltisec = %{$domconfig{'ltisec'}};
- if (ref($currltisec{'linkprot'}) eq 'HASH') {
- foreach my $id (keys(%{$currltisec{'linkprot'}})) {
- unless ($id =~ /^\d+$/) {
- delete($currltisec{'linkprot'}{$id});
- }
- }
- }
- if (ref($currltisec{'private'}) eq 'HASH') {
- if (ref($currltisec{'private'}{'keys'}) eq 'ARRAY') {
- $newltisec{'private'}{'keys'} = $currltisec{'private'}{'keys'};
- map { $keyset{$_} = 1; } @{$currltisec{'private'}{'keys'}};
- }
- }
- }
- foreach my $item ('crs','dom','consumers') {
- my $formelement;
- if ($item eq 'consumers') {
- $formelement = 'form.ltisec_'.$item;
- } else {
- $formelement = 'form.ltisec_'.$item.'linkprot';
- }
- if ($env{$formelement}) {
- $newltisec{'encrypt'}{$item} = 1;
- if (ref($currltisec{'encrypt'}) eq 'HASH') {
- unless ($currltisec{'encrypt'}{$item}) {
- $secchanges{'encrypt'} = 1;
- }
- } else {
- $secchanges{'encrypt'} = 1;
- }
- } elsif (ref($currltisec{'encrypt'}) eq 'HASH') {
- if ($currltisec{'encrypt'}{$item}) {
- $secchanges{'encrypt'} = 1;
- }
- }
- }
- unless (exists($currltisec{'rules'})) {
- $currltisec{'rules'} = {};
- }
- &password_rule_changes('secrets',$newltisec{'rules'},$currltisec{'rules'},\%secchanges);
-
- my @ids=&Apache::lonnet::current_machine_ids();
- my %servers = &Apache::lonnet::get_servers($dom,'library');
-
- foreach my $hostid (keys(%servers)) {
- if (($hostid ne '') && (grep(/^\Q$hostid\E$/,@ids))) {
- my $newkey;
- my $keyitem = 'form.ltisec_privkey_'.$hostid;
- if (exists($env{$keyitem})) {
- $env{$keyitem} =~ s/(`)/'/g;
- if ($keyset{$hostid}) {
- if ($env{'form.ltisec_changeprivkey_'.$hostid}) {
- if ($env{$keyitem} ne '') {
- $secchanges{'private'} = 1;
- $newkeyset{$hostid} = $env{$keyitem};
- }
- }
- } elsif ($env{$keyitem} ne '') {
- unless (grep(/^\Q$hostid\E$/,@{$newltisec{'private'}{'keys'}})) {
- push(@{$newltisec{'private'}{'keys'}},$hostid);
- }
- $secchanges{'private'} = 1;
- $newkeyset{$hostid} = $env{$keyitem};
- }
- }
- }
- }
+ &fetch_secrets($dom,'ltisec',\%domconfig,\%currltisec,\%secchanges,\%newltisec,\%newkeyset);
my (%linkprotchg,$linkprotoutput,$is_home);
my $proterror = &Apache::courseprefs::process_linkprot($dom,'',$currltisec{'linkprot'},
@@ -16128,29 +15253,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;
}
}
}
@@ -16291,27 +15430,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') {
@@ -16322,10 +15461,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;
@@ -16334,13 +15473,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') {
@@ -16354,20 +15493,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') {
@@ -16380,6 +15519,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;
@@ -16397,12 +15601,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'}) {
@@ -16413,130 +15626,32 @@ sub modify_lti {
}
my $putresult = &Apache::lonnet::put_dom('configuration',\%ltihash,$dom);
if ($putresult eq 'ok') {
- my %keystore;
- if (keys(%secchanges)) {
- if ($secchanges{'private'}) {
- my $who = &escape($env{'user.name'}.':'.$env{'user.domain'});
- foreach my $hostid (keys(%newkeyset)) {
- my $storehash = {
- key => $newkeyset{$hostid},
- who => $env{'user.name'}.':'.$env{'user.domain'},
- };
- $keystore{$hostid} = &Apache::lonnet::store_dom($storehash,'lti','private',
- $dom,$hostid);
- }
- }
- if (ref($lastactref) eq 'HASH') {
- if (($secchanges{'encrypt'}) || ($secchanges{'private'})) {
- $lastactref->{'domdefaults'} = 1;
- }
- }
- }
- &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) {
- foreach my $item (keys(%secchanges)) {
- if ($item eq 'encrypt') {
- my %encrypted = (
- crs => {
- on => &mt('Encryption of stored link protection secrets defined in courses enabled'),
- off => &mt('Encryption of stored link protection secrets defined in courses disabled'),
- },
- dom => {
- on => &mt('Encryption of stored link protection secrets defined in domain enabled'),
- off => &mt('Encryption of stored link protection secrets defined in domain disabled'),
- },
- consumers => {
- on => &mt('Encryption of stored consumer secrets defined in domain enabled'),
- off => &mt('Encryption of stored consumer secrets defined in domain disabled'),
- },
- );
- foreach my $type ('crs','dom','consumers') {
- my $shown = $encrypted{$type}{'off'};
- if (ref($newltisec{$item}) eq 'HASH') {
- if ($newltisec{$item}{$type}) {
- $shown = $encrypted{$type}{'on'};
- }
- }
- $resulttext .= '- '.$shown.'
';
- }
- } elsif ($item eq 'rules') {
- my %titles = &Apache::lonlocal::texthash(
- min => 'Minimum password length',
- max => 'Maximum password length',
- chars => 'Required characters',
- );
- foreach my $rule ('min','max') {
- if ($newltisec{rules}{$rule} eq '') {
- if ($rule eq 'min') {
- $resulttext .= '- '.&mt('[_1] not set.',$titles{$rule});
- ' '.&mt('Default of [_1] will be used',
- $Apache::lonnet::passwdmin).'
';
- } else {
- $resulttext .= '- '.&mt('[_1] set to none',$titles{$rule}).'
';
- }
- } else {
- $resulttext .= '- '.&mt('[_1] set to [_2]',$titles{$rule},$newltisec{rules}{$rule}).'
';
- }
- }
- if (ref($newltisec{'rules'}{'chars'}) eq 'ARRAY') {
- if (@{$newltisec{'rules'}{'chars'}} > 0) {
- my %rulenames = &Apache::lonlocal::texthash(
- uc => 'At least one upper case letter',
- lc => 'At least one lower case letter',
- num => 'At least one number',
- spec => 'At least one non-alphanumeric',
- );
- my $needed = '- '.
- join('
- ',map {$rulenames{$_} } @{$newltisec{'rules'}{'chars'}}).
- '
';
- $resulttext .= '- '.&mt('[_1] set to: [_2]',$titles{'chars'},$needed).'
';
- } else {
- $resulttext .= '- '.&mt('[_1] set to none',$titles{'chars'}).'
';
- }
- } else {
- $resulttext .= '- '.&mt('[_1] set to none',$titles{'chars'}).'
';
- }
- } elsif ($item eq 'private') {
- if (keys(%newkeyset)) {
- foreach my $hostid (sort(keys(%newkeyset))) {
- if ($keystore{$hostid} eq 'ok') {
- $resulttext .= '- '.&mt('Encryption key for storage of shared secrets saved for [_1]',$hostid).'
';
- }
- }
- }
- } elsif ($item eq 'linkprot') {
- $resulttext .= $linkprotoutput;
- }
+ $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).'
';
@@ -16545,13 +15660,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'}) {
@@ -16703,8 +15816,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').'';
}
@@ -16715,6 +15838,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
@@ -17517,7 +16664,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) {
@@ -17575,12 +16722,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;
}
@@ -17597,7 +16744,7 @@ sub modify_contacts {
}
} else {
foreach my $key (@overrides) {
- push(@{$changes{'overrides'}},$key);
+ push(@{$changes{'overrides'}},$key);
}
}
}
@@ -17779,7 +16926,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};
@@ -17803,14 +16950,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).'');
@@ -17973,7 +17120,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'}};
@@ -18208,7 +17355,29 @@ sub modify_privacy {
$resulttext .= '';
}
}
- $resulttext .= '';
+ $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');
}
@@ -18395,12 +17564,15 @@ sub modify_passwords {
$error = &mt("Upload of file containing domain-specific text is not permitted to this server: [_1]",$switchserver);
} else {
if ($author_ok eq 'ok') {
+ my $modified = [];
my ($result,$customurl) =
- &publishlogo($r,'upload','passwords_customfile',$dom,
- $confname,'customtext/resetpw','','',$customfn);
+ &Apache::lonconfigsettings::publishlogo($r,'upload','passwords_customfile',$dom,
+ $confname,'customtext/resetpw','','',$customfn,
+ $modified);
if ($result eq 'ok') {
$newvalues{'resetcustom'} = $customurl;
$changes{'reset'} = 1;
+ &update_modify_urls($r,$modified);
} else {
$error = &mt("Upload of [_1] failed because an error occurred publishing the file in RES space. Error was: [_2].",$customfn,$result);
}
@@ -18648,7 +17820,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'}).'';
@@ -18721,7 +17893,7 @@ sub password_rule_changes {
my (@rules,%staticdefaults);
if ($prefix eq 'passwords') {
@rules = ('min','max','expire','numsaved');
- } elsif ($prefix eq 'secrets') {
+ } elsif (($prefix eq 'ltisecrets') || ($prefix eq 'toolsecrets')) {
@rules = ('min','max');
}
$staticdefaults{'min'} = $Apache::lonnet::passwdmin;
@@ -19131,7 +18303,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})) {
@@ -19143,7 +18315,7 @@ sub modify_selfcreation {
}
} elsif ($emaildom ne '') {
push(@{$changes{'cancreate'}},'emaildomain');
- }
+ }
}
$cancreate{'emailoptions'}{$type} = $env{'form.cancreate_emailoptions_'.$type};
} elsif ($chosen eq 'custom') {
@@ -19570,7 +18742,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') {
@@ -19656,7 +18828,7 @@ sub modify_selfcreation {
$output = '- '.$usertypes{$type}.' -- '.&mt('No restriction on e-mail domain').'
';
} else {
$output = '- '.$usertypes{$type}.' -- '.&mt("User's e-mail address needs to end: [_1]",
- $cancreate{'emaildomain'}{$type}{'inst'}).'
';
+ $cancreate{'emaildomain'}{$type}{'inst'}).'';
}
}
} elsif ($cancreate{'emailoptions'}{$type} eq 'noninst') {
@@ -19674,7 +18846,7 @@ sub modify_selfcreation {
$output = '- '.$usertypes{$type}.' -- '.&mt('No restriction on e-mail domain').'
';
} else {
$output = '- '.$usertypes{$type}.' -- '.&mt("User's e-mail address must not end: [_1]",
- $cancreate{'emaildomain'}{$type}{'noninst'}).'
';
+ $cancreate{'emaildomain'}{$type}{'noninst'}).'';
}
}
}
@@ -19778,7 +18950,7 @@ sub modify_selfcreation {
$typename = $othertitle;
} else {
$typename = $usertypes{$type};
- }
+ }
$chgtext .= &mt('(Affiliation: [_1])',$typename);
}
if (@{$email_rule{$type}} > 0) {
@@ -20123,7 +19295,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});
@@ -20308,7 +19480,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') {
@@ -20415,12 +19587,15 @@ sub modify_scantron {
$error = &mt("Upload of bubblesheet format file is not permitted to this server: [_1]",$switchserver);
} else {
if ($author_ok eq 'ok') {
+ my $modified = [];
my ($result,$scantronurl) =
- &publishlogo($r,'upload','scantronformat',$dom,
- $confname,'scantron','','',$custom);
+ &Apache::lonconfigsettings::publishlogo($r,'upload','scantronformat',$dom,
+ $confname,'scantron','','',$custom,
+ $modified);
if ($result eq 'ok') {
$confhash{'scantron'}{'scantronformat'} = $scantronurl;
$changes{'scantronformat'} = 1;
+ &update_modify_urls($r,$modified);
} else {
$error = &mt("Upload of [_1] failed because an error occurred publishing the file in RES space. Error was: [_2].",$custom,$result);
}
@@ -21340,14 +20515,18 @@ 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,
);
my %texoptions = (
MathJax => 'MathJax',
@@ -21392,7 +20571,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};
}
@@ -21404,7 +20583,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;
@@ -21539,6 +20718,47 @@ sub modify_coursedefaults {
$changes{'postsubmit'} = 1;
}
}
+ 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');
+ if (ref($domconfig{'coursedefaults'}{'domexttool'}) eq 'HASH') {
+ %olddomexttool = %{$domconfig{'coursedefaults'}{'domexttool'}};
+ } else {
+ foreach my $type (@types) {
+ if ($staticdefaults{'domexttool'}) {
+ $olddomexttool{$type} = 1;
+ } else {
+ $olddomexttool{$type} = 0;
+ }
+ }
+ }
+ if (ref($domconfig{'coursedefaults'}{'exttool'}) eq 'HASH') {
+ %oldexttool = %{$domconfig{'coursedefaults'}{'exttool'}};
+ } else {
+ foreach my $type (@types) {
+ if ($staticdefaults{'exttool'}) {
+ $oldexttool{$type} = 1;
+ } else {
+ $oldexttool{$type} = 0;
+ }
+ }
+ }
+ foreach my $type (@types) {
+ unless ($newdomexttool{$type}) {
+ $newdomexttool{$type} = 0;
+ }
+ unless ($newexttool{$type}) {
+ $newexttool{$type} = 0;
+ }
+ if ($newdomexttool{$type} != $olddomexttool{$type}) {
+ $changes{'domexttool'} = 1;
+ }
+ if ($newexttool{$type} != $oldexttool{$type}) {
+ $changes{'exttool'} = 1;
+ }
+ }
+ $defaultshash{'coursedefaults'}{'domexttool'} = \%newdomexttool;
+ $defaultshash{'coursedefaults'}{'exttool'} = \%newexttool;
}
my $putresult = &Apache::lonnet::put_dom('configuration',\%defaultshash,
$dom);
@@ -21548,8 +20768,10 @@ sub modify_coursedefaults {
if (($changes{'canuse_pdfforms'}) || ($changes{'uploadquota'}) || ($changes{'postsubmit'}) ||
($changes{'coursecredits'}) || ($changes{'uselcmath'}) || ($changes{'usejsme'}) ||
($changes{'canclone'}) || ($changes{'mysqltables'}) || ($changes{'texengine'}) ||
- ($changes{'inline_chem'}) || ($changes{'ltiauth'})) {
- foreach my $item ('canuse_pdfforms','uselcmath','usejsme','inline_chem','texengine','ltiauth') {
+ ($changes{'inline_chem'}) || ($changes{'ltiauth'}) || ($changes{'domexttool'}) ||
+ ($changes{'exttool'}) || ($changes{'coursequota'})) {
+ foreach my $item ('canuse_pdfforms','uselcmath','usejsme','inline_chem','texengine',
+ 'ltiauth') {
if ($changes{$item}) {
$domdefaults{$item}=$defaultshash{'coursedefaults'}{$item};
}
@@ -21580,6 +20802,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') {
@@ -21592,6 +20821,20 @@ sub modify_coursedefaults {
$domdefaults{'canclone'}=$defaultshash{'coursedefaults'}{'canclone'};
}
}
+ if ($changes{'domexttool'}) {
+ if (ref($defaultshash{'coursedefaults'}{'domexttool'}) eq 'HASH') {
+ foreach my $type (@types) {
+ $domdefaults{$type.'domexttool'}=$defaultshash{'coursedefaults'}{'domexttool'}{$type};
+ }
+ }
+ }
+ if ($changes{'exttool'}) {
+ if (ref($defaultshash{'coursedefaults'}{'exttool'}) eq 'HASH') {
+ foreach my $type (@types) {
+ $domdefaults{$type.'exttool'}=$defaultshash{'coursedefaults'}{'exttool'}{$type};
+ }
+ }
+ }
my $cachetime = 24*60*60;
&Apache::lonnet::do_cache_new('domdefaults',$dom,\%domdefaults,$cachetime);
if (ref($lastactref) eq 'HASH') {
@@ -21644,6 +20887,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').'
'.
@@ -21729,6 +20985,34 @@ sub modify_coursedefaults {
} else {
$resulttext .= '- '.&mt('LTI launch of deep-linked URL will require re-authentication').'
';
}
+ } elsif ($item eq 'domexttool') {
+ my @noyes = (&mt('no'),&mt('yes'));
+ if (ref($defaultshash{'coursedefaults'}{'domexttool'}) eq 'HASH') {
+ $resulttext .= '- '.&mt('External Tools defined in the domain may be used as follows:').'
'.
+ '- '.&mt('Official courses: [_1]',''.$noyes[$defaultshash{'coursedefaults'}{'domexttool'}{'official'}].'').'
'.
+ '- '.&mt('Unofficial courses: [_1]',''.$noyes[$defaultshash{'coursedefaults'}{'domexttool'}{'unofficial'}].'').'
'.
+ '- '.&mt('Textbook courses: [_1]',''.$noyes[$defaultshash{'coursedefaults'}{'domexttool'}{'textbook'}].'').'
'.
+ '- '.&mt('Placement tests: [_1]',''.$noyes[$defaultshash{'coursedefaults'}{'domexttool'}{'placement'}].'').'
'.
+ '- '.&mt('Communities: [_1]',''.$noyes[$defaultshash{'coursedefaults'}{'domexttool'}{'community'}].'').'
'.
+ ' '.
+ ' ';
+ } else {
+ $resulttext .= '- '.&mt('External Tools defined in the domain may be used in all course types, by default').'
';
+ }
+ } elsif ($item eq 'exttool') {
+ my @noyes = (&mt('no'),&mt('yes'));
+ if (ref($defaultshash{'coursedefaults'}{'exttool'}) eq 'HASH') {
+ $resulttext .= '- '.&mt('External Tools can be defined and configured in course containers as follows:').'
'.
+ '- '.&mt('Official courses: [_1]',''.$noyes[$defaultshash{'coursedefaults'}{'exttool'}{'official'}].'').'
'.
+ '- '.&mt('Unofficial courses: [_1]',''.$noyes[$defaultshash{'coursedefaults'}{'exttool'}{'unofficial'}].'').'
'.
+ '- '.&mt('Textbook courses: [_1]',''.$noyes[$defaultshash{'coursedefaults'}{'exttool'}{'textbook'}].'').'
'.
+ '- '.&mt('Placement tests: [_1]',''.$noyes[$defaultshash{'coursedefaults'}{'exttool'}{'placement'}].'').'
'.
+ '- '.&mt('Communities: [_1]',''.$noyes[$defaultshash{'coursedefaults'}{'exttool'}{'community'}].'').'
'.
+ ' '.
+ ' ';
+ } else {
+ $resulttext .= '- '.&mt('External Tools can not be defined in any course types, by default').'
';
+ }
}
}
$resulttext .= ' ';
@@ -22122,7 +21406,7 @@ sub modify_wafproxy {
}
} elsif ($currvalue{$item}) {
$changes{$item} = 1;
- }
+ }
}
} else {
if (keys(%curralias)) {
@@ -22130,7 +21414,7 @@ sub modify_wafproxy {
}
if (keys(%currsaml)) {
$changes{'saml'} = 1;
- }
+ }
if (keys(%currvalue)) {
foreach my $key (keys(%currvalue)) {
$changes{$key} = 1;
@@ -22140,7 +21424,7 @@ sub modify_wafproxy {
if (keys(%changes)) {
my %defaultshash = (
wafproxy => \%wafproxy,
- );
+ );
my $putresult = &Apache::lonnet::put_dom('configuration',\%defaultshash,
$dom);
if ($putresult eq 'ok') {
@@ -22156,7 +21440,7 @@ sub modify_wafproxy {
$domdefaults{'waf_'.$item} = $wafproxy{$item};
} elsif (exists($domdefaults{'waf_'.$item})) {
delete($domdefaults{'waf_'.$item});
- }
+ }
}
}
if ($updatedomdefs) {
@@ -22223,7 +21507,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'}})));
@@ -22553,7 +21837,7 @@ sub modify_usersessions {
if (($offload eq 'offloadoth') && (@okoffloadoth)) {
$changes{'offloadoth'} = 1;
}
- }
+ }
}
} else {
if (@okoffload) {
@@ -23091,7 +22375,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;
}
@@ -23777,7 +23061,6 @@ function balancerChange(balnum,baltotal,
END
}
-
sub new_spares_js {
my @sparestypes = ('primary','default');
my $types = join("','",@sparestypes);
|
|