[LON-CAPA-cvs] cvs: loncom(version_2_11_X) /interface lonmodifycourse.pm

raeburn raeburn at source.lon-capa.org
Fri Jul 26 13:43:55 EDT 2019


raeburn		Fri Jul 26 17:43:55 2019 EDT

  Modified files:              (Branch: version_2_11_X)
    /loncom/interface	lonmodifycourse.pm 
  Log:
  - For 2.11
    Backport 1.95
  
  
Index: loncom/interface/lonmodifycourse.pm
diff -u loncom/interface/lonmodifycourse.pm:1.79.2.6 loncom/interface/lonmodifycourse.pm:1.79.2.7
--- loncom/interface/lonmodifycourse.pm:1.79.2.6	Sat Apr  8 19:05:44 2017
+++ loncom/interface/lonmodifycourse.pm	Fri Jul 26 17:43:54 2019
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # handler for DC-only modifiable course settings
 #
-# $Id: lonmodifycourse.pm,v 1.79.2.6 2017/04/08 19:05:44 raeburn Exp $
+# $Id: lonmodifycourse.pm,v 1.79.2.7 2019/07/26 17:43:54 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -39,6 +39,9 @@
 use lib '/home/httpd/lib/perl';
 use LONCAPA qw(:DEFAULT :match);
 
+my $registered_cleanup;
+my $modified_dom;
+
 sub get_dc_settable {
     my ($type,$cdom) = @_;
     if ($type eq 'Community') {
@@ -1414,6 +1417,18 @@
             my $putres = &Apache::lonnet::courseidput($cdom,\%crsinfo,$chome,'notime');
             if ($putres eq 'ok') {
                 &update_coowners($cdom,$cnum,$chome,\%settings,\%newattr);
+                if ($changed{'code'}) {
+                    &Apache::lonnet::devalidate_cache_new('instcats',$cdom);
+                    # Update cache of self-cataloging courses on institution's server(s).
+                    if (&Apache::lonnet::shared_institution($cdom)) {
+                        unless ($registered_cleanup) {
+                            my $handlers = $r->get_handlers('PerlCleanupHandler');
+                            $r->set_handlers('PerlCleanupHandler' => [\&devalidate_remote_instcats,@{$handlers}]);
+                            $registered_cleanup=1;
+                            $modified_dom = $cdom;
+                        }
+                    }
+                }
             }
         }
     }
@@ -2446,6 +2461,22 @@
     return ($allowed,\%permission);
 }
 
+sub devalidate_remote_instcats {
+    if ($modified_dom ne '') {
+        my %servers = &Apache::lonnet::internet_dom_servers($modified_dom);
+        my %thismachine;
+        map { $thismachine{$_} = 1; } &Apache::lonnet::current_machine_ids();
+        if (keys(%servers)) {
+            foreach my $server (keys(%servers)) {
+                next if ($thismachine{$server});
+                &Apache::lonnet::remote_devalidate_cache($server,['instcats:'.$modified_dom]);
+            }
+        }
+        $modified_dom = '';
+    }
+    return;
+}
+
 sub handler {
     my $r = shift;
     if ($r->header_only) {
@@ -2454,6 +2485,9 @@
         return OK;
     }
 
+    $registered_cleanup=0;
+    $modified_dom = '';
+
     my $dom = $env{'request.role.domain'};
     my $domdesc = &Apache::lonnet::domain($dom,'description');
     my ($allowed,$permission) = &get_permission($dom);




More information about the LON-CAPA-cvs mailing list