--- loncom/interface/courseprefs.pm 2022/02/16 00:06:04 1.103 +++ loncom/interface/courseprefs.pm 2022/04/05 12:27:39 1.108 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Handler to set configuration settings for a course # -# $Id: courseprefs.pm,v 1.103 2022/02/16 00:06:04 raeburn Exp $ +# $Id: courseprefs.pm,v 1.108 2022/04/05 12:27:39 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -601,10 +601,14 @@ sub handler { ); if (($phase eq 'process') && ($parm_permission->{'process'})) { my @allitems = &get_allitems(%prefs); - &Apache::lonconfigsettings::make_changes($r,$cdom,$phase,$context, - \@prefs_order,\%prefs,\%values, - $cnum,undef,\@allitems, - 'coursepref',$parm_permission); + my $result = &Apache::lonconfigsettings::make_changes($r,$cdom,$phase,$context, + \@prefs_order,\%prefs,\%values, + $cnum,undef,\@allitems, + 'coursepref',$parm_permission); + if ((ref($result) eq 'HASH') && (keys(%{$result}))) { + $r->rflush(); + &devalidate_remote_courseprefs($cdom,$cnum,$result); + } } elsif (($phase eq 'display') && ($parm_permission->{'display'})) { my $noedit; if (ref($parm_permission) eq 'HASH') { @@ -812,7 +816,7 @@ sub print_config_box { } sub process_changes { - my ($cdom,$cnum,$action,$values,$item,$changes,$allitems,$disallowed,$crstype) = @_; + my ($cdom,$cnum,$action,$values,$item,$changes,$allitems,$disallowed,$crstype,$lastactref) = @_; my (%newvalues,$errors); if (ref($item) eq 'HASH') { if (ref($changes) eq 'HASH') { @@ -981,7 +985,7 @@ sub process_changes { } } elsif ($action eq 'linkprot') { if (ref($values) eq 'HASH') { - $errors = &process_linkprot($cdom,$cnum,$values->{$action},$changes,'course'); + $errors = &process_linkprot($cdom,$cnum,$values->{$action},$changes,'course',$lastactref); } } else { foreach my $entry (@ordered) { @@ -1477,7 +1481,7 @@ sub process_changes { } sub process_linkprot { - my ($cdom,$cnum,$values,$changes,$context) = @_; + my ($cdom,$cnum,$values,$changes,$context,$lastactref) = @_; my ($home,$dest,$ltiauth,$privkey,$privnum,$cipher,$errors,%linkprot); if (ref($values) eq 'HASH') { foreach my $id (keys(%{$values})) { @@ -1501,7 +1505,7 @@ sub process_linkprot { if (grep(/^\Q$home\E$/,@ids)) { if (ref($domdefs{'privhosts'}) eq 'ARRAY') { if (grep(/^\Q$home\E$/,@{$domdefs{'privhosts'}})) { - my %privhash = &Apache::lonnet::restore_dom('lti','private',$cdom,$home,1); + my %privhash = &Apache::lonnet::restore_dom('lti','private',$cdom,$home,1); $privkey = $privhash{'key'}; $privnum = $privhash{'version'}; if (($privnum) && ($privkey ne '')) { @@ -1593,7 +1597,8 @@ sub process_linkprot { my $reqitem = 'form.linkprot_requser_'.$idx; $env{$reqitem} =~ s/(`)/'/g; unless ($idx eq 'add') { - if ($current{'requser'} ne $env{$reqitem}) { + if ((!$current{'requser'} && $env{$reqitem}) || + ($current{'requser'} && !$env{$reqitem})) { $haschanges{$itemid} = 1; } } @@ -1655,6 +1660,7 @@ sub process_linkprot { } } else { $linkprot{$itemid}{'secret'} = $current{'secret'}; + $linkprot{$itemid}{'cipher'} = $current{'cipher'}; } } elsif ($env{$secretitem} ne '') { if ($privnum && $cipher) { @@ -1671,6 +1677,9 @@ sub process_linkprot { foreach my $entry (keys(%haschanges)) { $changes->{$entry} = $linkprot{$entry}; } + if (ref($lastactref) eq 'HASH') { + $lastactref->{'courselti'} = 1'; + } } return $errors; } @@ -2814,6 +2823,16 @@ function toggleLinkProtReqUser(form,item } return; } + +function uncheckLinkProtMakeVis(item,num) { + if (document.getElementById('linkprot_'+item+'_'+num)) { + var currtype = document.getElementById('linkprot_'+item+'_'+num).type; + if (currtype.toLowerCase() == 'checkbox') { + document.getElementById('linkprot_'+item+'_'+num).checked = false; + } + } + return; +} ENDSCRIPT } @@ -5622,9 +5641,6 @@ sub menucollections_display { sub print_linkprotection { my ($cdom,$cnum,$settings,$rowtotal,$crstype,$noedit,$context) = @_; - unless (ref($settings) eq 'HASH') { - return; - } my %linkprotection; my $count = 0; @@ -5669,7 +5685,7 @@ sub print_linkprotection { } } - if (ref($settings->{'linkprot'}) eq 'HASH') { + if ((ref($settings) eq 'HASH') && (ref($settings->{'linkprot'}) eq 'HASH')) { if (keys(%{$settings->{'linkprot'}})) { my @current = sort { $a <=> $b } keys(%{$settings->{'linkprot'}}); $next += $current[-1]; @@ -5766,13 +5782,13 @@ sub print_linkprotection { '  '; } else { $datatable .= ''.$desc{'secret'}.':'. ''. - ''. + ''. ''; } } @@ -5792,7 +5808,7 @@ sub print_linkprotection { $datatable .= ''."\n". ''."\n". ''.&mt('Add').''."\n". - ''; + ''; my ($usersty,$onclickrequser,%checkedrequser); if ($ltiauth) { $usersty = 'display:none'; @@ -5824,7 +5840,7 @@ sub print_linkprotection { $datatable .= ''.$desc{'key'}.': '."\n". (' 'x2). ''.$desc{'secret'}.':'. - ' '."\n"; + ' '."\n"; } if ($ltiauth) { $datatable .= ''. @@ -6542,6 +6558,30 @@ sub change_clone { } } } + return; +} + +sub devalidate_remote_courseprefs { + my ($cdom,$cnum,$cachekeys) = @_; + return unless (ref($cachekeys) eq 'HASH'); + my %servers = &Apache::lonnet::internet_dom_servers($cdom); + my %thismachine; + map { $thismachine{$_} = 1; } &Apache::lonnet::current_machine_ids(); + my @posscached = ('courselti'); + if (keys(%servers)) { + foreach my $server (keys(%servers)) { + next if ($thismachine{$server}); + my @cached; + foreach my $name (@posscached) { + if ($cachekeys->{$name}) { + push(@cached,&escape($name).':'.&escape($cdom.'_'.$cnum)); + } + } + if (@cached) { + &Apache::lonnet::remote_devalidate_cache($server,\@cached); + } + } + } return; } 500 Internal Server Error

Internal Server Error

The server encountered an internal error or misconfiguration and was unable to complete your request.

Please contact the server administrator at root@localhost to inform them of the time this error occurred, and the actions you performed just before this error.

More information about this error may be available in the server error log.