[LON-CAPA-cvs] cvs: loncom /interface courseprefs.pm lonconfigsettings.pm
raeburn
raeburn at source.lon-capa.org
Tue Apr 5 08:27:39 EDT 2022
raeburn Tue Apr 5 12:27:39 2022 EDT
Modified files:
/loncom/interface courseprefs.pm lonconfigsettings.pm
Log:
- Expire cache of course's link protection settings on other servers in a
course's domain after making changes.
Index: loncom/interface/courseprefs.pm
diff -u loncom/interface/courseprefs.pm:1.107 loncom/interface/courseprefs.pm:1.108
--- loncom/interface/courseprefs.pm:1.107 Tue Apr 5 12:22:41 2022
+++ loncom/interface/courseprefs.pm Tue Apr 5 12:27:39 2022
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Handler to set configuration settings for a course
#
-# $Id: courseprefs.pm,v 1.107 2022/04/05 12:22:41 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 @@
);
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 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 @@
}
} 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_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})) {
@@ -1673,6 +1677,9 @@
foreach my $entry (keys(%haschanges)) {
$changes->{$entry} = $linkprot{$entry};
}
+ if (ref($lastactref) eq 'HASH') {
+ $lastactref->{'courselti'} = 1';
+ }
}
return $errors;
}
@@ -6554,4 +6561,28 @@
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;
+}
+
1;
Index: loncom/interface/lonconfigsettings.pm
diff -u loncom/interface/lonconfigsettings.pm:1.63 loncom/interface/lonconfigsettings.pm:1.64
--- loncom/interface/lonconfigsettings.pm:1.63 Sat Mar 12 23:03:09 2022
+++ loncom/interface/lonconfigsettings.pm Tue Apr 5 12:27:39 2022
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Handler to set domain-wide configuration settings
#
-# $Id: lonconfigsettings.pm,v 1.63 2022/03/12 23:03:09 raeburn Exp $
+# $Id: lonconfigsettings.pm,v 1.64 2022/04/05 12:27:39 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -539,7 +539,8 @@
$errors =
&Apache::courseprefs::process_changes($dom,$confname,$item,$values,
$prefs->{$item},$changes{$item},
- $allitems,\%disallowed,$crstype);
+ $allitems,\%disallowed,$crstype,
+ \%lastact);
if (keys(%{$changes{$item}}) > 0) {
$numchanged ++;
}
More information about the LON-CAPA-cvs
mailing list