--- loncom/interface/domainprefs.pm 2013/08/12 16:51:57 1.203 +++ loncom/interface/domainprefs.pm 2013/09/21 13:49:31 1.208 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Handler to set domain-wide configuration settings # -# $Id: domainprefs.pm,v 1.203 2013/08/12 16:51:57 raeburn Exp $ +# $Id: domainprefs.pm,v 1.208 2013/09/21 13:49:31 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -416,7 +416,11 @@ sub handler { my $confname = $dom.'-domainconfig'; if ($phase eq 'process') { - &Apache::lonconfigsettings::make_changes($r,$dom,$phase,$context,\@prefs_order,\%prefs,\%domconfig,$confname,\@roles); + if (&Apache::lonconfigsettings::make_changes($r,$dom,$phase,$context,\@prefs_order, + \%prefs,\%domconfig,$confname,\@roles) eq 'update') { + $r->rflush(); + &devalidate_remote_domconfs($dom); + } } elsif ($phase eq 'display') { my $js = &recaptcha_js(). &credits_js(); @@ -498,21 +502,21 @@ sub handler { } sub process_changes { - my ($r,$dom,$confname,$action,$roles,$values) = @_; + my ($r,$dom,$confname,$action,$roles,$values,$lastactref) = @_; my %domconfig; if (ref($values) eq 'HASH') { %domconfig = %{$values}; } my $output; if ($action eq 'login') { - $output = &modify_login($r,$dom,$confname,%domconfig); + $output = &modify_login($r,$dom,$confname,$lastactref,%domconfig); } elsif ($action eq 'rolecolors') { $output = &modify_rolecolors($r,$dom,$confname,$roles, - %domconfig); + $lastactref,%domconfig); } elsif ($action eq 'quotas') { $output = &modify_quotas($dom,$action,%domconfig); } elsif ($action eq 'autoenroll') { - $output = &modify_autoenroll($dom,%domconfig); + $output = &modify_autoenroll($dom,$lastactref,%domconfig); } elsif ($action eq 'autoupdate') { $output = &modify_autoupdate($dom,%domconfig); } elsif ($action eq 'autocreate') { @@ -524,11 +528,11 @@ sub process_changes { } elsif ($action eq 'usermodification') { $output = &modify_usermodification($dom,%domconfig); } elsif ($action eq 'contacts') { - $output = &modify_contacts($dom,%domconfig); + $output = &modify_contacts($dom,$lastactref,%domconfig); } elsif ($action eq 'defaults') { $output = &modify_defaults($dom,$r,%domconfig); } elsif ($action eq 'scantron') { - $output = &modify_scantron($r,$dom,$confname,%domconfig); + $output = &modify_scantron($r,$dom,$confname,$lastactref,%domconfig); } elsif ($action eq 'coursecategories') { $output = &modify_coursecategories($dom,%domconfig); } elsif ($action eq 'serverstatuses') { @@ -1959,7 +1963,7 @@ sub print_quotas { sub print_requestmail { my ($dom,$action,$settings,$rowtotal) = @_; - my ($now,$datatable,%currapp,$rows); + my ($now,$datatable,%currapp); $now = time; if (ref($settings) eq 'HASH') { if (ref($settings->{'notify'}) eq 'HASH') { @@ -4437,7 +4441,7 @@ sub build_category_rows { if (ref($cats->[$depth]{$parent}) eq 'ARRAY') { my $numchildren = @{$cats->[$depth]{$parent}}; my $css_class = $itemcount%2?' class="LC_odd_row"':''; - $text .= ''; + $text .= '
'; my ($idxnum,$parent_name,$parent_item); my $higher = $depth - 1; if ($higher == 0) { @@ -4729,7 +4733,7 @@ sub usertype_update_row { } sub modify_login { - my ($r,$dom,$confname,%domconfig) = @_; + my ($r,$dom,$confname,$lastactref,%domconfig) = @_; my ($resulttext,$errors,$colchgtext,%changes,%colchanges,%newfile,%newurl, %curr_loginvia,%loginhash,@currlangs,@newlangs,$addedfile,%title,@offon); %title = ( coursecatalog => 'Display course catalog', @@ -4967,6 +4971,7 @@ sub modify_login { } if (keys(%changes) > 0 || $colchgtext) { &Apache::loncommon::devalidate_domconfig_cache($dom); + $$lastactref = 'update'; $resulttext = &mt('Changes made:').'
    '; foreach my $item (sort(keys(%changes))) { if ($item eq 'loginvia') { @@ -5099,7 +5104,7 @@ sub color_font_choices { } sub modify_rolecolors { - my ($r,$dom,$confname,$roles,%domconfig) = @_; + my ($r,$dom,$confname,$roles,$lastactref,%domconfig) = @_; my ($resulttext,%rolehash); $rolehash{'rolecolors'} = {}; if (ref($domconfig{'rolecolors'}) ne 'HASH') { @@ -5114,6 +5119,7 @@ sub modify_rolecolors { if ($putresult eq 'ok') { if (keys(%changes) > 0) { &Apache::loncommon::devalidate_domconfig_cache($dom); + $$lastactref = 'update'; $resulttext = &display_colorchgs($dom,\%changes,$roles, $rolehash{'rolecolors'}); } else { @@ -5545,7 +5551,7 @@ sub publishlogo { if ($file=~/\.(\w+)$/ && (&Apache::loncommon::fileembstyle($1) eq 'hdn')) { $output = - &mt('Invalid file extension ([_1]) - reserved for LONCAPA use.',$1); + &mt('Invalid file extension ([_1]) - reserved for internal use.',$1); } elsif ($file=~/\.(\w+)$/ && !defined(&Apache::loncommon::fileembstyle($1))) { $output = &mt('Unrecognized file extension ([_1]) - rename the file with a proper extension and re-upload.',$1); @@ -6158,7 +6164,7 @@ sub modify_quotas { } sub modify_autoenroll { - my ($dom,%domconfig) = @_; + my ($dom,$lastactref,%domconfig) = @_; my ($resulttext,%changes); my %currautoenroll; if (ref($domconfig{'autoenroll'}) eq 'HASH') { @@ -6226,6 +6232,7 @@ sub modify_autoenroll { if ($changes{'coowners'}) { $resulttext .= '
  • '.&mt("$title{'coowners'} set to $offon[$env{'form.autoassign_coowners'}]").'
  • '; &Apache::loncommon::devalidate_domconfig_cache($dom); + $$lastactref = 'update'; } $resulttext .= '
'; } else { @@ -6677,7 +6684,7 @@ sub modify_directorysrch { } sub modify_contacts { - my ($dom,%domconfig) = @_; + my ($dom,$lastactref,%domconfig) = @_; my ($resulttext,%currsetting,%newsetting,%changes,%contacts_hash); if (ref($domconfig{'contacts'}) eq 'HASH') { foreach my $key (keys(%{$domconfig{'contacts'}})) { @@ -6782,6 +6789,8 @@ sub modify_contacts { $dom); if ($putresult eq 'ok') { if (keys(%changes) > 0) { + &Apache::loncommon::devalidate_domconfig_cache($dom); + $$lastactref = 'update'; my ($titles,$short_titles) = &contact_titles(); $resulttext = &mt('Changes made:').'
    '; foreach my $item (@contacts) { @@ -7539,7 +7548,7 @@ sub modify_defaults { } sub modify_scantron { - my ($r,$dom,$confname,%domconfig) = @_; + my ($r,$dom,$confname,$lastactref,%domconfig) = @_; my ($resulttext,%confhash,%changes,$errors); my $custom = 'custom.tab'; my $default = 'default.tab'; @@ -7600,6 +7609,7 @@ sub modify_scantron { } $resulttext .= '
'; &Apache::loncommon::devalidate_domconfig_cache($dom); + $$lastactref = 'update'; } else { $resulttext = &mt('No changes made to bubblesheet format file'); } @@ -8064,7 +8074,7 @@ sub modify_coursedefaults { } foreach my $item (@numbers) { my ($currdef,$newdef); - my $newdef = $env{'form.'.$item}; + $newdef = $env{'form.'.$item}; if ($item eq 'anonsurvey_threshold') { $currdef = $domconfig{'coursedefaults'}{$item}; $newdef =~ s/\D//g; @@ -9359,4 +9369,21 @@ sub captcha_phrases { ); } + +sub devalidate_remote_domconfs { + my ($dom) = @_; + my $primary_id = &Apache::lonnet::domain($dom,'primary'); + my $intdom = &Apache::lonnet::internet_dom($primary_id); + my %servers = &Apache::lonnet::internet_dom_servers($dom); + my %thismachine; + map { $thismachine{$_} = 1; } &Apache::lonnet::current_machine_ids(); + if (keys(%servers) > 1) { + foreach my $server (keys(%servers)) { + next if ($thismachine{$server}); + &Apache::lonnet::remote_devalidate_cache($server,'domainconfig',$dom); + } + } + return; +} + 1;