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

raeburn raeburn at source.lon-capa.org
Wed Oct 16 19:57:49 EDT 2013


raeburn		Wed Oct 16 23:57:49 2013 EDT

  Modified files:              (Branch: version_2_11_X)
    /loncom/interface	domainprefs.pm 
  Log:
  - For 2.11
    - Backport 1.211, 1.212
  
  
-------------- next part --------------
Index: loncom/interface/domainprefs.pm
diff -u loncom/interface/domainprefs.pm:1.160.6.26 loncom/interface/domainprefs.pm:1.160.6.27
--- loncom/interface/domainprefs.pm:1.160.6.26	Sun Sep 29 06:55:58 2013
+++ loncom/interface/domainprefs.pm	Wed Oct 16 23:57:49 2013
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Handler to set domain-wide configuration settings
 #
-# $Id: domainprefs.pm,v 1.160.6.26 2013/09/29 06:55:58 raeburn Exp $
+# $Id: domainprefs.pm,v 1.160.6.27 2013/10/16 23:57:49 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -86,7 +86,7 @@
 
 $dom is the domain, $settings is a reference to a hash of current settings for
 the current context, $rowtotal is a reference to the scalar used to record the 
-number of rows displayed on the page, and $action is the context (quotas,
+number of rows displayed on the page, and $action is the context (quotas, 
 requestcourses or requestauthor).
 
 The print_quotas routine was orginally created to display/store information
@@ -400,10 +400,11 @@
     my $confname = $dom.'-domainconfig';
 
     if ($phase eq 'process') {
-        if (&Apache::lonconfigsettings::make_changes($r,$dom,$phase,$context,\@prefs_order,
-                                                     \%prefs,\%domconfig,$confname,\@roles) eq 'update') {
+        my $result = &Apache::lonconfigsettings::make_changes($r,$dom,$phase,$context,\@prefs_order,
+                                                              \%prefs,\%domconfig,$confname,\@roles);
+        if (ref($result) eq 'HASH') {
             $r->rflush();
-            &devalidate_remote_domconfs($dom);
+            &devalidate_remote_domconfs($dom,$result);
         }
     } elsif ($phase eq 'display') {
         my $js = &recaptcha_js().
@@ -498,7 +499,7 @@
         $output = &modify_rolecolors($r,$dom,$confname,$roles,
                                      $lastactref,%domconfig);
     } elsif ($action eq 'quotas') {
-        $output = &modify_quotas($dom,$action,%domconfig);
+        $output = &modify_quotas($dom,$action,$lastactref,%domconfig);
     } elsif ($action eq 'autoenroll') {
         $output = &modify_autoenroll($dom,$lastactref,%domconfig);
     } elsif ($action eq 'autoupdate') {
@@ -514,7 +515,7 @@
     } elsif ($action eq 'contacts') {
         $output = &modify_contacts($dom,$lastactref,%domconfig);
     } elsif ($action eq 'defaults') {
-        $output = &modify_defaults($dom,$r,%domconfig);
+        $output = &modify_defaults($dom,$lastactref,%domconfig);
     } elsif ($action eq 'scantron') {
         $output = &modify_scantron($r,$dom,$confname,$lastactref,%domconfig);
     } elsif ($action eq 'coursecategories') {
@@ -522,13 +523,13 @@
     } elsif ($action eq 'serverstatuses') {
         $output = &modify_serverstatuses($dom,%domconfig);
     } elsif ($action eq 'requestcourses') {
-        $output = &modify_quotas($dom,$action,%domconfig);
+        $output = &modify_quotas($dom,$action,$lastactref,%domconfig);
     } elsif ($action eq 'requestauthor') {
-        $output = &modify_quotas($dom,$action,%domconfig);
+        $output = &modify_quotas($dom,$action,$lastactref,%domconfig);
     } elsif ($action eq 'coursedefaults') {
-        $output = &modify_coursedefaults($dom,%domconfig);
+        $output = &modify_coursedefaults($dom,$lastactref,%domconfig);
     } elsif ($action eq 'usersessions') {
-        $output = &modify_usersessions($dom,%domconfig);
+        $output = &modify_usersessions($dom,$lastactref,%domconfig);
     } elsif ($action eq 'loadbalancing') {
         $output = &modify_loadbalancing($dom,%domconfig);
     }
@@ -772,7 +773,7 @@
         } elsif ($action eq 'contacts') {
             $output .= &print_contacts($dom,$settings,\$rowtotal);
         } elsif ($action eq 'defaults') {
-            $output .= &print_defaults($dom,\$rowtotal);
+            $output .= &print_defaults($dom,$settings,\$rowtotal);
         } elsif ($action eq 'scantron') {
             $output .= &print_scantronformat($r,$dom,$confname,$settings,\$rowtotal);
         } elsif ($action eq 'serverstatuses') {
@@ -3739,10 +3740,18 @@
 }
 
 sub print_defaults {
-    my ($dom,$rowtotal) = @_;
+    my ($dom,$settings,$rowtotal) = @_;
     my @items = ('auth_def','auth_arg_def','lang_def','timezone_def',
                  'datelocale_def','portal_def');
-    my %domdefaults = &Apache::lonnet::get_domain_defaults($dom);
+    my %defaults;
+    if (ref($settings) eq 'HASH') {
+        %defaults = %{$settings};
+    } else {
+        my %domdefaults = &Apache::lonnet::get_domain_defaults($dom,1);
+        foreach my $item (@items) {
+            $defaults{$item} = $domdefaults{$item};
+        }
+    }
     my $titles = &defaults_titles($dom);
     my $rownum = 0;
     my ($datatable,$css_class);
@@ -3766,7 +3775,7 @@
             my %authnames = &authtype_names();
             foreach my $auth (@authtypes) {
                 my $checked = ' ';
-                if ($domdefaults{$item} eq $auth) {
+                if ($defaults{$item} eq $auth) {
                     $checked = ' checked="checked" ';
                 }
                 $datatable .= '<label><input type="radio" name="'.$item.
@@ -3775,15 +3784,15 @@
             }
         } elsif ($item eq 'timezone_def') {
             my $includeempty = 1;
-            $datatable .= &Apache::loncommon::select_timezone($item,$domdefaults{$item},undef,$includeempty);
+            $datatable .= &Apache::loncommon::select_timezone($item,$defaults{$item},undef,$includeempty);
         } elsif ($item eq 'datelocale_def') {
             my $includeempty = 1;
-            $datatable .= &Apache::loncommon::select_datelocale($item,$domdefaults{$item},undef,$includeempty);
+            $datatable .= &Apache::loncommon::select_datelocale($item,$defaults{$item},undef,$includeempty);
         } elsif ($item eq 'lang_def') {
             my %langchoices = &get_languages_hash();
             $langchoices{''} = 'No language preference';
             %langchoices = &Apache::lonlocal::texthash(%langchoices);
-            $datatable .= &Apache::loncommon::select_form($domdefaults{$item},$item,
+            $datatable .= &Apache::loncommon::select_form($defaults{$item},$item,
                                                           \%langchoices);
         } else {
             my $size;
@@ -3791,7 +3800,7 @@
                 $size = ' size="25"';
             }
             $datatable .= '<input type="text" name="'.$item.'" value="'.
-                          $domdefaults{$item}.'"'.$size.' />';
+                          $defaults{$item}.'"'.$size.' />';
         }
         $datatable .= '</td></tr>';
         $rownum ++;
@@ -4960,7 +4969,9 @@
         }
         if (keys(%changes) > 0 || $colchgtext) {
             &Apache::loncommon::devalidate_domconfig_cache($dom);
-            $$lastactref = 'update';
+            if (ref($lastactref) eq 'HASH') {
+                $lastactref->{'domainconfig'} = 1;
+            }
             $resulttext = &mt('Changes made:').'<ul>';
             foreach my $item (sort(keys(%changes))) {
                 if ($item eq 'loginvia') {
@@ -5108,7 +5119,9 @@
     if ($putresult eq 'ok') {
         if (keys(%changes) > 0) {
             &Apache::loncommon::devalidate_domconfig_cache($dom);
-            $$lastactref = 'update';
+            if (ref($lastactref) eq 'HASH') {
+                $lastactref->{'domainconfig'} = 1;
+            }
             $resulttext = &display_colorchgs($dom,\%changes,$roles,
                                              $rolehash{'rolecolors'});
         } else {
@@ -5789,7 +5802,7 @@
 }
 
 sub modify_quotas {
-    my ($dom,$action,%domconfig) = @_;
+    my ($dom,$action,$lastactref,%domconfig) = @_;
     my ($context, at usertools, at options,%validations,%titles,%confhash,%toolshash,
         %limithash,$toolregexp,%conditions,$resulttext,%changes);
     if ($action eq 'quotas') {
@@ -5811,7 +5824,7 @@
         @usertools = ('aboutme','blog','webdav','portfolio');
         %titles = &tool_titles();
     }
-    my %domdefaults = &Apache::lonnet::get_domain_defaults($dom);
+    my %domdefaults = &Apache::lonnet::get_domain_defaults($dom,1);
     my ($othertitle,$usertypes,$types) = &Apache::loncommon::sorted_inst_types($dom);
     foreach my $key (keys(%env)) {
         if ($context eq 'requestcourses') {
@@ -6010,7 +6023,9 @@
         if (keys(%changes) > 0) {
             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:').'<ul>';
             unless (($context eq 'requestcourses') ||
                     ($context eq 'requestauthor')) {
@@ -6221,7 +6236,9 @@
             if ($changes{'coowners'}) {
                 $resulttext .= '<li>'.&mt("$title{'coowners'} set to $offon[$env{'form.autoassign_coowners'}]").'</li>';
                 &Apache::loncommon::devalidate_domconfig_cache($dom);
-                $$lastactref = 'update';
+                if (ref($lastactref) eq 'HASH') {
+                    $lastactref->{'domainconfig'} = 1;
+                }
             }
             $resulttext .= '</ul>';
         } else {
@@ -6779,7 +6796,9 @@
     if ($putresult eq 'ok') {
         if (keys(%changes) > 0) {
             &Apache::loncommon::devalidate_domconfig_cache($dom);
-            $$lastactref = 'update';
+            if (ref($lastactref) eq 'HASH') {
+                $lastactref->{'domainconfig'} = 1;
+            }
             my ($titles,$short_titles)  = &contact_titles();
             $resulttext = &mt('Changes made:').'<ul>';
             foreach my $item (@contacts) {
@@ -6854,7 +6873,7 @@
     foreach my $item(@contexts) {
         if ($item eq 'selfcreate') {
             @{$cancreate{$item}} = &Apache::loncommon::get_env_multiple('form.can_createuser_'.$item);
-            my %domdefaults = &Apache::lonnet::get_domain_defaults($dom);
+            my %domdefaults = &Apache::lonnet::get_domain_defaults($dom,1);
             if (!((($domdefaults{'auth_def'} =~/^krb/) && ($domdefaults{'auth_arg_def'} ne '')) || ($domdefaults{'auth_def'} eq 'localauth'))) {
                 if (ref($cancreate{$item}) eq 'ARRAY') { 
                     if (grep(/^login$/,@{$cancreate{$item}})) {
@@ -7421,9 +7440,9 @@
 }
 
 sub modify_defaults {
-    my ($dom,$r,%domconfig) = @_;
+    my ($dom,$lastactref,%domconfig) = @_;
     my ($resulttext,$mailmsgtxt,%newvalues,%changes, at errors);
-    my %domdefaults = &Apache::lonnet::get_domain_defaults($dom);
+    my %domdefaults = &Apache::lonnet::get_domain_defaults($dom,1);
     my @items = ('auth_def','auth_arg_def','lang_def','timezone_def','datelocale_def','portal_def');
     my @authtypes = ('internal','krb4','krb5','localauth');
     foreach my $item (@items) {
@@ -7483,7 +7502,7 @@
     if ($putresult eq 'ok') {
         if (keys(%changes) > 0) {
             $resulttext = &mt('Changes made:').'<ul>';
-            my $version = $r->dir_config('lonVersion');
+            my $version = &Apache::lonnet::get_server_loncaparev($dom);
             my $mailmsgtext = "Changes made to domain settings in a LON-CAPA installation - domain: $dom (running version: $version) - dns_domain.tab needs to be updated with the following changes, to support legacy 2.4, 2.5 and 2.6 versions of LON-CAPA.\n\n";
             foreach my $item (sort(keys(%changes))) {
                 my $value = $env{'form.'.$item};
@@ -7506,6 +7525,9 @@
             $mailmsgtext .= "\n";
             my $cachetime = 24*60*60;
             &Apache::lonnet::do_cache_new('domdefaults',$dom,\%domdefaults,$cachetime);
+            if (ref($lastactref) eq 'HASH') {
+                $lastactref->{'domdefaults'} = 1;
+            }
             if ($changes{'auth_def'} || $changes{'auth_arg_def'} || $changes{'lang_def'} || $changes{'datelocale_def'}) {
                 my $notify = 1;
                 if (ref($domconfig{'contacts'}) eq 'HASH') {
@@ -7598,7 +7620,9 @@
                 }
                 $resulttext .= '</ul>';
                 &Apache::loncommon::devalidate_domconfig_cache($dom);
-                $$lastactref = 'update';
+                if (ref($lastactref) eq 'HASH') {
+                    $lastactref->{'domainconfig'} = 1;
+                }
             } else {
                 $resulttext = &mt('No changes made to bubblesheet format file');
             }
@@ -8022,7 +8046,7 @@
 }
 
 sub modify_coursedefaults {
-    my ($dom,%domconfig) = @_;
+    my ($dom,$lastactref,%domconfig) = @_;
     my ($resulttext,$errors,%changes,%defaultshash);
     my %defaultchecked = ('canuse_pdfforms' => 'off');
     my @toggles = ('canuse_pdfforms');
@@ -8113,10 +8137,9 @@
     my $putresult = &Apache::lonnet::put_dom('configuration',\%defaultshash,
                                              $dom);
     if ($putresult eq 'ok') {
-        my %domdefaults;
         if (keys(%changes) > 0) {
+            my %domdefaults = &Apache::lonnet::get_domain_defaults($dom,1);
             if (($changes{'canuse_pdfforms'}) || ($changes{'coursecredits'}) || ($changes{'uploadquota'})) {
-                %domdefaults = &Apache::lonnet::get_domain_defaults($dom);
                 if ($changes{'canuse_pdfforms'}) {
                     $domdefaults{'canuse_pdfforms'}=$defaultshash{'coursedefaults'}{'canuse_pdfforms'};
                 }
@@ -8137,6 +8160,9 @@
                 }
                 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:').'<ul>';
             foreach my $item (sort(keys(%changes))) {
@@ -8188,7 +8214,7 @@
 }
 
 sub modify_usersessions {
-    my ($dom,%domconfig) = @_;
+    my ($dom,$lastactref,%domconfig) = @_;
     my @hostingtypes = ('version','excludedomain','includedomain');
     my @offloadtypes = ('primary','default');
     my %types = (
@@ -8205,7 +8231,7 @@
     foreach my $prefix (@prefixes) {
         $defaultshash{'usersessions'}{$prefix} = {};
     }
-    my %domdefaults = &Apache::lonnet::get_domain_defaults($dom);
+    my %domdefaults = &Apache::lonnet::get_domain_defaults($dom,1);
     my $resulttext;
     my %iphost = &Apache::lonnet::get_iphost();
     foreach my $prefix (@prefixes) {
@@ -8381,6 +8407,9 @@
             }
             my $cachetime = 24*60*60;
             &Apache::lonnet::do_cache_new('domdefaults',$dom,\%domdefaults,$cachetime);
+            if (ref($lastactref) eq 'HASH') {
+                $lastactref->{'domdefaults'} = 1;
+            }
             if (keys(%changes) > 0) {
                 my %lt = &usersession_titles();
                 $resulttext = &mt('Changes made:').'<ul>';
@@ -8392,7 +8421,8 @@
                                 foreach my $lonhost (sort(keys(%{$changes{$prefix}}))) {
                                     $resulttext .= '<li><b>'.$lonhost.'</b> ';
                                     my $lonhostdom = &Apache::lonnet::host_domain($lonhost);
-                                    &Apache::lonnet::remote_devalidate_cache($lonhost,'spares',$lonhostdom);
+                                    my $cachekey = &escape('spares').':'.&escape($lonhostdom);
+                                    &Apache::lonnet::remote_devalidate_cache($lonhost,[$cachekey]);
                                     if (ref($changes{$prefix}{$lonhost}) eq 'HASH') {
                                         foreach my $type (@{$types{$prefix}}) {
                                             if ($changes{$prefix}{$lonhost}{$type}) {
@@ -8579,7 +8609,8 @@
                 if (ref($changes{'delete'}) eq 'ARRAY') {
                     foreach my $balancer (sort(@{$changes{'delete'}})) {
                         $resulttext .= '<li>'.&mt('Load Balancing discontinued for: [_1]',$balancer).'</li>';
-                        &Apache::lonnet::remote_devalidate_cache($balancer,'loadbalancing',$dom);
+                        my $cachekey = &escape('loadbalancing').':'.&escape($dom);
+                        &Apache::lonnet::remote_devalidate_cache($balancer,[$cachekey]);
                     }
                 }
                 if (ref($changes{'add'}) eq 'ARRAY') {
@@ -8635,7 +8666,8 @@
                                 }
                             }
                         }
-                        &Apache::lonnet::remote_devalidate_cache($balancer,'loadbalancing',$dom);
+                        my $cachekey = &scape('loadbalancing').':'.&escape($dom);
+                        &Apache::lonnet::remote_devalidate_cache($balancer,[$cachekey]);
                     }
                 }
                 if ($resulttext ne '') {
@@ -9357,16 +9389,24 @@
 }
 
 sub devalidate_remote_domconfs {
-    my ($dom) = @_;
-    my $primary_id = &Apache::lonnet::domain($dom,'primary');
-    my $intdom = &Apache::lonnet::internet_dom($primary_id);
+    my ($dom,$cachekeys) = @_;
+    return unless (ref($cachekeys) eq 'HASH');
     my %servers = &Apache::lonnet::internet_dom_servers($dom);
     my %thismachine;
     map { $thismachine{$_} = 1; } &Apache::lonnet::current_machine_ids();
+    my @posscached = ('domainconfig','domdefaults');
     if (keys(%servers) > 1) {
         foreach my $server (keys(%servers)) {
             next if ($thismachine{$server});
-            &Apache::lonnet::remote_devalidate_cache($server,'domainconfig',$dom);
+            my @cached;
+            foreach my $name (@posscached) {
+                if ($cachekeys->{$name}) {
+                    push(@cached,&escape($name).':'.&escape($dom));
+                }
+            }
+            if (@cached) {
+                &Apache::lonnet::remote_devalidate_cache($server,\@cached);
+            }
         }
     }
     return;


More information about the LON-CAPA-cvs mailing list