[LON-CAPA-cvs] cvs: loncom /interface domainprefs.pm lonconfigsettings.pm
raeburn
raeburn at source.lon-capa.org
Sun Oct 6 17:25:59 EDT 2013
raeburn Sun Oct 6 21:25:59 2013 EDT
Modified files:
/loncom/interface lonconfigsettings.pm domainprefs.pm
Log:
- Setting domain configuration for items included in domdefaults, which is
cached for 24hrs in memcache.
- &devalidate_remote_domconfs() takes second arg -- $cachekeys -- a reference
to a hash of items to devalidate on the domain's servers.
- two possible hash keys: domainconfig or domdefaults
- Update of domdefaults as a result of processing changes in domain configuration
cause lonnet::do_cache_new() to be called on current server, and also
domdefaults to be added to the $cachekeys hash.
- Seventh arg in domainprefs::process_changes() is now a ref to a hash instead
of a ref to a scalar.
- lonconfigsettings::make_changes() now returns a ref to a HASH, where keys
(if any) are items to devalidate on the domain's servers.
- Retrieval of domdefaults when displaying domain configuration screen or
processing changes includes directive to ignore_cache and read from
configuration.db file on domain's primary library server.
-------------- next part --------------
Index: loncom/interface/lonconfigsettings.pm
diff -u loncom/interface/lonconfigsettings.pm:1.26 loncom/interface/lonconfigsettings.pm:1.27
--- loncom/interface/lonconfigsettings.pm:1.26 Sat Sep 7 00:19:00 2013
+++ loncom/interface/lonconfigsettings.pm Sun Oct 6 21:25:59 2013
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Handler to set domain-wide configuration settings
#
-# $Id: lonconfigsettings.pm,v 1.26 2013/09/07 00:19:00 raeburn Exp $
+# $Id: lonconfigsettings.pm,v 1.27 2013/10/06 21:25:59 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -188,7 +188,7 @@
{href=>"javascript:changePage(document.$phase,'$phase')",
text=>"Updated"});
&print_header($r,$phase,$context,undef,$container);
- my ($crstype,$lastact);
+ my ($crstype,%lastact);
if ($context eq 'course') {
$crstype = &Apache::loncommon::course_type();
}
@@ -199,7 +199,7 @@
if ($context eq 'domain') {
$r->print('<h3>'.&mt($prefs->{$item}{'text'}).'</h3>'.
&Apache::domainprefs::process_changes($r,$dom,
- $confname,$item,$roles,$values,\$lastact));
+ $confname,$item,$roles,$values,\%lastact));
} else {
$changes{$item} = {};
&Apache::courseprefs::process_changes($dom,$item,$values,
@@ -244,7 +244,7 @@
}
&print_footer($r,$phase,'display',$footer_text,\@actions,$container);
$r->print('</p>');
- return $lastact;
+ return \%lastact;
}
sub display_settings {
Index: loncom/interface/domainprefs.pm
diff -u loncom/interface/domainprefs.pm:1.211 loncom/interface/domainprefs.pm:1.212
--- loncom/interface/domainprefs.pm:1.211 Sun Oct 6 20:33:45 2013
+++ loncom/interface/domainprefs.pm Sun Oct 6 21:25:59 2013
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Handler to set domain-wide configuration settings
#
-# $Id: domainprefs.pm,v 1.211 2013/10/06 20:33:45 raeburn Exp $
+# $Id: domainprefs.pm,v 1.212 2013/10/06 21:25:59 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -416,10 +416,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().
@@ -514,7 +515,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') {
@@ -530,7 +531,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') {
@@ -538,15 +539,15 @@
} 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 'helpsettings') {
$output = &modify_helpsettings($r,$dom,$confname,%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);
}
@@ -794,7 +795,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') {
@@ -3759,10 +3760,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);
@@ -3786,7 +3795,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.
@@ -3795,15 +3804,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;
@@ -3811,7 +3820,7 @@
$size = ' size="25"';
}
$datatable .= '<input type="text" name="'.$item.'" value="'.
- $domdefaults{$item}.'"'.$size.' />';
+ $defaults{$item}.'"'.$size.' />';
}
$datatable .= '</td></tr>';
$rownum ++;
@@ -4980,7 +4989,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') {
@@ -5128,7 +5139,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 {
@@ -5809,7 +5822,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') {
@@ -5831,7 +5844,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') {
@@ -6030,7 +6043,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')) {
@@ -6241,7 +6256,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 {
@@ -6799,7 +6816,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) {
@@ -6874,7 +6893,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}})) {
@@ -7441,9 +7460,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) {
@@ -7503,7 +7522,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};
@@ -7526,6 +7545,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') {
@@ -7618,7 +7640,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');
}
@@ -8042,7 +8066,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');
@@ -8133,10 +8157,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'};
}
@@ -8157,6 +8180,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))) {
@@ -8208,7 +8234,7 @@
}
sub modify_usersessions {
- my ($dom,%domconfig) = @_;
+ my ($dom,$lastactref,%domconfig) = @_;
my @hostingtypes = ('version','excludedomain','includedomain');
my @offloadtypes = ('primary','default');
my %types = (
@@ -8225,7 +8251,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) {
@@ -8401,6 +8427,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>';
@@ -9380,17 +9409,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});
- my $cachekey = &escape('domainconfig').':'.&escape($dom);
- &Apache::lonnet::remote_devalidate_cache($server,[$cachekey]);
+ 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