--- loncom/interface/domainprefs.pm 2014/07/15 21:52:16 1.160.6.51 +++ loncom/interface/domainprefs.pm 2015/06/15 20:18:35 1.160.6.65 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Handler to set domain-wide configuration settings # -# $Id: domainprefs.pm,v 1.160.6.51 2014/07/15 21:52:16 raeburn Exp $ +# $Id: domainprefs.pm,v 1.160.6.65 2015/06/15 20:18:35 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -250,6 +250,8 @@ sub handler { header => [{col1 => 'Log-in Page Items', col2 => '',}, {col1 => 'Log-in Help', + col2 => 'Value'}, + {col1 => 'Custom HTML in document head', col2 => 'Value'}], print => \&print_login, modify => \&modify_login, @@ -412,7 +414,9 @@ sub handler { 'coursedefaults' => {text => 'Course/Community defaults', help => 'Domain_Configuration_Course_Defaults', - header => [{col1 => 'Defaults which can be overridden for each course by a DC', + header => [{col1 => 'Defaults which can be overridden in each course by a CC', + col2 => 'Value',}, + {col1 => 'Defaults which can be overridden for each course by a DC', col2 => 'Value',},], print => \&print_coursedefaults, modify => \&modify_coursedefaults, @@ -461,6 +465,8 @@ sub handler { {col1 => 'Log-in Page Items', col2 => ''}, {col1 => 'Log-in Help', + col2 => 'Value'}, + {col1 => 'Custom HTML in document head', col2 => 'Value'}], print => \&print_login, modify => \&modify_login, @@ -650,7 +656,7 @@ sub print_config_box { my $colspan = ''; my $rightcolspan = ''; if (($action eq 'rolecolors') || ($action eq 'defaults') || - (($action eq 'login') && ($numheaders < 3))) { + (($action eq 'login') && ($numheaders < 4))) { $colspan = ' colspan="2"'; } if ($action eq 'usersessions') { @@ -666,13 +672,13 @@ sub print_config_box { '; $rowtotal ++; if (($action eq 'autoupdate') || ($action eq 'usercreation') || ($action eq 'selfcreation') || - ($action eq 'usermodification') || ($action eq 'defaults') || + ($action eq 'usermodification') || ($action eq 'defaults') || ($action eq 'coursedefaults') || ($action eq 'selfenrollment') || ($action eq 'usersessions')) { $output .= $item->{'print'}->('top',$dom,$settings,\$rowtotal); } elsif ($action eq 'coursecategories') { $output .= $item->{'print'}->('top',$dom,$item,$settings,\$rowtotal); } elsif ($action eq 'login') { - if ($numheaders == 3) { + if ($numheaders == 4) { $colspan = ' colspan="2"'; $output .= &print_login('service',$dom,$confname,$phase,$settings,\$rowtotal); } else { @@ -721,10 +727,11 @@ sub print_config_box { $output .= $item->{'print'}->('bottom',$dom,$settings,\$rowtotal); } $rowtotal ++; - } elsif (($action eq 'usermodification') || ($action eq 'defaults')) { + } elsif (($action eq 'usermodification') || ($action eq 'coursedefaults') || + ($action eq 'defaults')) { $output .= $item->{'print'}->('bottom',$dom,$settings,\$rowtotal); } elsif ($action eq 'login') { - if ($numheaders == 3) { + if ($numheaders == 4) { $output .= &print_login('page',$dom,$confname,$phase,$settings,\$rowtotal).' @@ -740,6 +747,27 @@ sub print_config_box { } else { $output .= &print_login('help',$dom,$confname,$phase,$settings,\$rowtotal); } + $output .= ' + + + + + + + '; + if ($numheaders == 4) { + $output .= ' + + + '; + } else { + $output .= ' + + + '; + } + $rowtotal ++; + $output .= &print_login('headtag',$dom,$confname,$phase,$settings,\$rowtotal); } elsif ($action eq 'requestcourses') { $output .= &print_requestmail($dom,$action,$settings,\$rowtotal); $rowtotal ++; @@ -864,8 +892,6 @@ sub print_config_box { $output .= &print_scantronformat($r,$dom,$confname,$settings,\$rowtotal); } elsif ($action eq 'helpsettings') { $output .= &print_helpsettings($dom,$confname,$settings,\$rowtotal); - } elsif ($action eq 'coursedefaults') { - $output .= $item->{'print'}->('bottom',$dom,$settings,\$rowtotal); } } $output .= ' @@ -1162,6 +1188,57 @@ sub print_login { $itemcount ++; } $datatable .= &captcha_choice('login',$settings,$itemcount); + } elsif ($caller eq 'headtag') { + my %domservers = &Apache::lonnet::get_servers($dom); + my $choice = $choices{'headtag'}; + $css_class = ' class="LC_odd_row"'; + $datatable .= ''. + ''; } return $datatable; } @@ -1195,6 +1272,9 @@ sub login_choices { link => "Link", alink => "Active link", vlink => "Visited link", + headtag => "Custom markup", + action => "Action", + current => "Current", ); return %choices; } @@ -2746,7 +2826,7 @@ sub print_helpsettings { sub radiobutton_prefs { my ($settings,$toggles,$defaultchecked,$choices,$itemcount,$onclick, - $additional) = @_; + $additional,$align) = @_; return unless ((ref($toggles) eq 'ARRAY') && (ref($defaultchecked) eq 'HASH') && (ref($choices) eq 'HASH')); @@ -2780,8 +2860,14 @@ sub radiobutton_prefs { $datatable .= ''. - ''; + if ($align eq 'left') { + $datatable .= ''. + ''; + $itemcount ++; } else { $css_class = $itemcount%2 ? ' class="LC_odd_row"' : ''; - my ($currdefresponder,$def_official_credits,$def_unofficial_credits,$def_textbook_credits, - %curruploadquota); + my ($currdefresponder,%defcredits,%curruploadquota,%deftimeout); my $currusecredits = 0; + my $postsubmitclient = 1; my @types = ('official','unofficial','community','textbook'); if (ref($settings) eq 'HASH') { $currdefresponder = $settings->{'anonsurvey_threshold'}; @@ -2827,14 +2992,42 @@ sub print_coursedefaults { } } if (ref($settings->{'coursecredits'}) eq 'HASH') { - $def_official_credits = $settings->{'coursecredits'}->{'official'}; - $def_unofficial_credits = $settings->{'coursecredits'}->{'unofficial'}; - $def_textbook_credits = $settings->{'coursecredits'}->{'textbook'}; - if (($def_official_credits ne '') || ($def_unofficial_credits ne '') || - ($def_textbook_credits ne '')) { - $currusecredits = 1; + foreach my $type (@types) { + next if ($type eq 'community'); + $defcredits{$type} = $settings->{'coursecredits'}->{$type}; + if ($defcredits{$type} ne '') { + $currusecredits = 1; + } } } + if (ref($settings->{'postsubmit'}) eq 'HASH') { + if ($settings->{'postsubmit'}->{'client'} eq 'off') { + $postsubmitclient = 0; + foreach my $type (@types) { + $deftimeout{$type} = $staticdefaults{'postsubmit'}; + } + } else { + foreach my $type (@types) { + if (ref($settings->{'postsubmit'}->{'timeout'}) eq 'HASH') { + if ($settings->{'postsubmit'}->{'timeout'}->{$type} =~ /^\d+$/) { + $deftimeout{$type} = $settings->{'postsubmit'}->{'timeout'}->{$type}; + } else { + $deftimeout{$type} = $staticdefaults{'postsubmit'}; + } + } else { + $deftimeout{$type} = $staticdefaults{'postsubmit'}; + } + } + } + } else { + foreach my $type (@types) { + $deftimeout{$type} = $staticdefaults{'postsubmit'}; + } + } + } else { + foreach my $type (@types) { + $deftimeout{$type} = $staticdefaults{'postsubmit'}; + } } if (!$currdefresponder) { $currdefresponder = $staticdefaults{'anonsurvey_threshold'}; @@ -2874,21 +3067,14 @@ sub print_coursedefaults { $display = 'block'; } my $additional = '
'. - ''. - &mt('Default credits for official courses [_1]', - ''). - '
'. - ''. - &mt('Default credits for unofficial courses [_1]', - ''). - '
'. - ''. - &mt('Default credits for textbook courses [_1]', - ''). - '
'."\n"; + ''.&mt('Default credits').'
'.&mt($item->{'header'}->[3]->{'col1'}).''.&mt($item->{'header'}->[3]->{'col2'}).'
'.&mt($item->{'header'}->[2]->{'col1'}).''.&mt($item->{'header'}->[2]->{'col2'}).'
'.$choice.''. + ''. + ''. + ''."\n"; + my (%currurls,%currexempt); + if (ref($settings) eq 'HASH') { + if (ref($settings->{'headtag'}) eq 'HASH') { + foreach my $lonhost (keys(%{$settings->{'headtag'}})) { + if (ref($settings->{'headtag'}{$lonhost}) eq 'HASH') { + $currurls{$lonhost} = $settings->{'headtag'}{$lonhost}{'url'}; + $currexempt{$lonhost} = $settings->{'headtag'}{$lonhost}{'exempt'}; + } + } + } + } + my %lt = &Apache::lonlocal::texthash( + del => 'Delete?', + rep => 'Replace:', + upl => 'Upload:', + curr => 'View contents', + none => 'None', + ); + my $switchserver = &check_switchserver($dom,$confname); + foreach my $lonhost (sort(keys(%domservers))) { + my $exempt = &check_exempt_addresses($currexempt{$lonhost}); + $datatable .= ''; + if ($currurls{$lonhost}) { + $datatable .= ''. + ''; + } + $datatable .= '
'.$choices{'hostid'}.''.$choices{'current'}.''.$choices{'action'}.''.$choices{'exempt'}.'
'.$domservers{$lonhost}.''.$lt{'curr'}.' '.$lt{'rep'}.''; + } else { + $datatable .= ''.$lt{'none'}.''.$lt{'upl'}; + } + $datatable .='
'; + if ($switchserver) { + $datatable .= &mt('Upload to library server: [_1]',$switchserver); + } else { + $datatable .= ''; + } + $datatable .= '
'. ''.$choices->{$item}. - ''. + ''; + } else { + $datatable .= ''; + } + $datatable .= + ''. ' '. + ''.$choices{'canclone'}. + ''; + my $currcanclone = 'none'; + my $onclick; + my @cloneoptions = ('none','domain'); + my %clonetitles = ( + none => 'No additional course requesters', + domain => "Any course requester in course's domain", + instcode => 'Course requests for official courses ...', + ); + my (%codedefaults,@code_order,@posscodes); + if (&Apache::lonnet::auto_instcode_defaults($dom,\%codedefaults, + \@code_order) eq 'ok') { + if (@code_order > 0) { + push(@cloneoptions,'instcode'); + $onclick = ' onclick="toggleDisplay(this.form,'."'cloneinstcode'".');"'; + } + } + if (ref($settings) eq 'HASH') { + if ($settings->{'canclone'}) { + if (ref($settings->{'canclone'}) eq 'HASH') { + if (ref($settings->{'canclone'}{'instcode'}) eq 'ARRAY') { + if (@code_order > 0) { + $currcanclone = 'instcode'; + @posscodes = @{$settings->{'canclone'}{'instcode'}}; + } + } + } elsif ($settings->{'canclone'} eq 'domain') { + $currcanclone = $settings->{'canclone'}; + } + } + } + foreach my $option (@cloneoptions) { + my ($checked,$additional); + if ($currcanclone eq $option) { + $checked = ' checked="checked"'; + } + if ($option eq 'instcode') { + if (@code_order) { + my $show = 'none'; + if ($checked) { + $show = 'block'; + } + $additional = '
'. + &mt('Institutional codes for new and cloned course have identical:'). + '
'; + foreach my $item (@code_order) { + my $codechk; + if ($checked) { + if (grep(/^\Q$item\E$/,@posscodes)) { + $codechk = ' checked="checked"'; + } + } + $additional .= ''; + } + $additional .= (' 'x2).'('.&mt('check as many as needed').')
'; + } + } + $datatable .= + ' '.$additional.'
'; + } + $datatable .= '
'; + foreach my $type (@types) { + next if ($type eq 'community'); + $additional .= ''; + } + $additional .= '
'.&mt($type).'
'. + '
'."\n"; %defaultchecked = ('coursecredits' => 'off'); @toggles = ('coursecredits'); my $current = { @@ -2896,9 +3082,32 @@ sub print_coursedefaults { }; (my $table,$itemcount) = &radiobutton_prefs($current,\@toggles,\%defaultchecked, - \%choices,$itemcount,$onclick,$additional); + \%choices,$itemcount,$onclick,$additional,'left'); + $datatable .= $table; + $onclick = "toggleDisplay(this.form,'studentsubmission');"; + my $display = 'none'; + if ($postsubmitclient) { + $display = 'block'; + } + $additional = '
'. + &mt('Number of seconds submit is disabled').'
'. + ''.&mt('Enter 0 to remain disabled until page reload.').'
'. + ''; + foreach my $type (@types) { + $additional .= ''; + } + $additional .= '
'.&mt($type).'
'. + '
'."\n"; + %defaultchecked = ('postsubmit' => 'on'); + @toggles = ('postsubmit'); + my $current = { + 'postsubmit' => $postsubmitclient, + }; + ($table,$itemcount) = + &radiobutton_prefs($current,\@toggles,\%defaultchecked, + \%choices,$itemcount,$onclick,$additional,'left'); $datatable .= $table; - $itemcount ++; } $$rowtotal += $itemcount; return $datatable; @@ -3143,7 +3352,13 @@ sub print_usersessions { if ($position eq 'top') { if (keys(%serverhomes) > 1) { my %spareid = ¤t_offloads_to($dom,$settings,\%servers); - $datatable .= &spares_row($dom,\%servers,\%spareid,\%serverhomes,\%altids,$rowtotal); + my $curroffloadnow; + if (ref($settings) eq 'HASH') { + if (ref($settings->{'offloadnow'}) eq 'HASH') { + $curroffloadnow = $settings->{'offloadnow'}; + } + } + $datatable .= &spares_row($dom,\%servers,\%spareid,\%serverhomes,\%altids,$curroffloadnow,$rowtotal); } else { $datatable .= ''. &mt('Nothing to set here, as the cluster to which this domain belongs only contains one server.'); @@ -3393,7 +3608,7 @@ sub current_offloads_to { } sub spares_row { - my ($dom,$servers,$spareid,$serverhomes,$altids,$rowtotal) = @_; + my ($dom,$servers,$spareid,$serverhomes,$altids,$curroffloadnow,$rowtotal) = @_; my $css_class; my $numinrow = 4; my $itemcount = 1; @@ -3413,12 +3628,21 @@ sub spares_row { } } next unless (ref($spareid->{$server}) eq 'HASH'); + my $checkednow; + if (ref($curroffloadnow) eq 'HASH') { + if ($curroffloadnow->{$server}) { + $checkednow = ' checked="checked"'; + } + } $css_class = $itemcount%2 ? ' class="LC_odd_row"' : ''; $datatable .= ' '. &mt('[_1] when busy, offloads to:' - ,''.$server.''). + ,''.$server.'').'
'. + ''."\n". + ''. "\n"; my (%current,%canselect); my @choices = @@ -3642,9 +3866,10 @@ sub print_loadbalancing { $disabled = ' disabled="disabled"'; } $targettable .= - ''; my $rem = $i%($numinrow); if ($rem == 0) { if (($i > 0) && ($i < $numspares-1)) { @@ -3734,7 +3959,7 @@ sub loadbalancing_rules { if (ref($currrules) eq 'HASH') { $current = $currrules->{$type}; } - if (($type eq '_LC_external') || ($type eq '_LC_internetdom') || ($type eq '_LC_ipchange')) { + if (($type eq '_LC_external') || ($type eq '_LC_internetdom')) { if ($dom ne &Apache::lonnet::host_domain($lonhost)) { $current = ''; } @@ -3786,7 +4011,7 @@ sub loadbalance_rule_row { my @rulenames; my %ruletitles = &offloadtype_text(); if (($type eq '_LC_ipchangesso') || ($type eq '_LC_ipchange')) { - @rulenames = ('balancer','offloadedto'); + @rulenames = ('balancer','offloadedto','specific'); } else { @rulenames = ('default','homeserver'); if ($type eq '_LC_external') { @@ -3797,7 +4022,7 @@ sub loadbalance_rule_row { push(@rulenames,'none'); } my $style = $targets_div_style; - if (($type eq '_LC_external') || ($type eq '_LC_internetdom') || ($type eq '_LC_ipchange')) { + if (($type eq '_LC_external') || ($type eq '_LC_internetdom')) { $style = $homedom_div_style; } my $space; @@ -3848,8 +4073,13 @@ sub loadbalance_rule_row { ' '.$ruletitles{$rulenames[$i]}. - ''.$extra.'
'."\n"; + ')"'.$checked.' /> '; + if (($rulenames[$i] eq 'specific') && ($type =~ /^_LC_ipchange/)) { + $output .= $ruletitles{'particular'}; + } else { + $output .= $ruletitles{$rulenames[$i]}; + } + $output .= ''.$extra.'
'."\n"; } $output .= ''."\n"; return $output; @@ -3864,6 +4094,7 @@ sub offloadtype_text { 'none' => 'No offload', 'balancer' => 'Session hosted on Load Balancer, after re-authentication', 'offloadedto' => 'Session hosted on offload server, after re-authentication', + 'particular' => 'Session hosted (after re-auth) on server:', ); return %ruletitles; } @@ -4538,11 +4769,8 @@ sub print_defaults { my $includeempty = 1; $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($defaults{$item},$item, - \%langchoices); + my $includeempty = 1; + $datatable .= &Apache::loncommon::select_language($item,$defaults{$item},$includeempty); } else { my $size; if ($item eq 'portal_def') { @@ -4611,7 +4839,7 @@ sub print_defaults { $datatable .= ''; } $datatable .= ' '.&mt('Internal ID:'). - ''. + ''. ' '.&mt('(new)'). ''. &mt('Name displayed:'). @@ -5148,7 +5376,7 @@ sub serverstatus_pages { return ('userstatus','lonstatus','loncron','server-status','codeversions', 'checksums','clusterstatus','metadata_keywords','metadata_harvest', 'takeoffline','takeonline','showenv','toggledebug','ping','domconf', - 'uniquecodes','diskusage'); + 'uniquecodes','diskusage','coursecatalog'); } sub defaults_javascript { @@ -5753,6 +5981,7 @@ sub modify_login { } my %servers = &Apache::lonnet::internet_dom_servers($dom); + my %domservers = &Apache::lonnet::get_servers($dom); my @loginvia_attribs = ('serverpath','custompath','exempt'); if (keys(%servers) > 1) { foreach my $lonhost (keys(%servers)) { @@ -5795,22 +6024,7 @@ sub modify_login { $changes{'loginvia'}{$lonhost} = 1; } if ($item eq 'exempt') { - $new =~ s/^\s+//; - $new =~ s/\s+$//; - my @poss_ips = split(/\s*[,:]\s*/,$new); - my @okips; - foreach my $ip (@poss_ips) { - if ($ip =~ /^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/) { - if (($1 <= 255) && ($2 <= 255) && ($3 <= 255) && ($4 <= 255)) { - push(@okips,$ip); - } - } - } - if (@okips > 0) { - $new = join(',',@okips); - } else { - $new = ''; - } + $new = &check_exempt_addresses($new); } $loginhash{login}{loginvia}{$lonhost}{$item} = $new; } @@ -5922,6 +6136,85 @@ sub modify_login { $errors .= '
  • '.$error.'
  • '; } } + + my (%currheadtagurls,%currexempt,@newhosts,%newheadtagurls,%possexempt); + if (ref($domconfig{'login'}) eq 'HASH') { + if (ref($domconfig{'login'}{'headtag'}) eq 'HASH') { + foreach my $lonhost (keys(%{$domconfig{'login'}{'headtag'}})) { + if ($domservers{$lonhost}) { + if (ref($domconfig{'login'}{'headtag'}{$lonhost}) eq 'HASH') { + $currheadtagurls{$lonhost} = $domconfig{'login'}{'headtag'}{$lonhost}{'url'}; + $currexempt{$lonhost} = $domconfig{'login'}{'headtagexempt'}{$lonhost}{'exempt'} + } + } + } + } + } + my @delheadtagurls = &Apache::loncommon::get_env_multiple('form.loginheadtag_del'); + foreach my $lonhost (sort(keys(%domservers))) { + if (grep(/^\Q$lonhost\E$/,@delheadtagurls)) { + $changes{'headtag'}{$lonhost} = 1; + } else { + if ($env{'form.loginheadtagexempt_'.$lonhost}) { + $possexempt{$lonhost} = &check_exempt_addresses($env{'form.loginheadtagexempt_'.$lonhost}); + } + if ($env{'form.loginheadtag_'.$lonhost.'.filename'}) { + push(@newhosts,$lonhost); + } elsif ($currheadtagurls{$lonhost}) { + $loginhash{'login'}{'headtag'}{$lonhost}{'url'} = $currheadtagurls{$lonhost}; + if ($currexempt{$lonhost}) { + if ((!exists($possexempt{$lonhost})) || ($possexempt{$lonhost} ne $currexempt{$lonhost})) { + $changes{'headtag'}{$lonhost} = 1; + } + } elsif ($possexempt{$lonhost}) { + $changes{'headtag'}{$lonhost} = 1; + } + if ($possexempt{$lonhost}) { + $loginhash{'login'}{'headtag'}{$lonhost}{'exempt'} = $possexempt{$lonhost}; + } + } + } + } + if (@newhosts) { + my $error; + my ($configuserok,$author_ok,$switchserver) = &config_check($dom,$confname,$servadm); + if ($configuserok eq 'ok') { + if ($switchserver) { + $error = &mt("Upload of custom markup is not permitted to this server: [_1]",$switchserver); + } elsif ($author_ok eq 'ok') { + foreach my $lonhost (@newhosts) { + my $formelem = 'loginheadtag_'.$lonhost; + (my $result,$newheadtagurls{$lonhost}) = &publishlogo($r,'upload',$formelem,$dom,$confname, + "login/headtag/$lonhost",'','', + $env{'form.loginheadtag_'.$lonhost.'.filename'}); + if ($result eq 'ok') { + $loginhash{'login'}{'headtag'}{$lonhost}{'url'} = $newheadtagurls{$lonhost}; + $changes{'headtag'}{$lonhost} = 1; + if ($possexempt{$lonhost}) { + $loginhash{'login'}{'headtag'}{$lonhost}{'exempt'} = $possexempt{$lonhost}; + } + } else { + my $puberror = &mt("Upload of [_1] failed because an error occurred publishing the file in RES space. Error was: [_2].", + $newheadtagurls{$lonhost},$result); + $errors .= '
  • '.$puberror.'
  • '; + if ((grep(/^\Q$lonhost\E$/,keys(%currheadtagurls))) && + (!grep(/^\Q$lonhost\E$/,@delheadtagurls))) { + $loginhash{'login'}{'headtag'}{$lonhost} = $currheadtagurls{$lonhost}; + } + } + } + } else { + $error = &mt("Upload of custom markup file(s) failed because an author role could not be assigned to a Domain Configuration user ([_1]) in domain: [_2]. Error was: [_3].",$confname,$dom,$author_ok); + } + } else { + $error = &mt("Upload of custom markup file(s) failed because a Domain Configuration user ([_1]) could not be created in domain: [_2]. Error was: [_3].",$confname,$dom,$configuserok); + } + if ($error) { + &Apache::lonnet::logthis($error); + $errors .= '
  • '.$error.'
  • '; + } + } + &process_captcha('login',\%changes,$loginhash{'login'},$domconfig{'login'}); my $defaulthelpfile = '/adm/loginproblems.html'; @@ -6022,6 +6315,25 @@ sub modify_login { } } } + } elsif ($item eq 'headtag') { + if (ref($changes{$item}) eq 'HASH') { + foreach my $lonhost (sort(keys(%{$changes{$item}}))) { + if (grep(/^\Q$lonhost\E$/,@delheadtagurls)) { + $resulttext .= '
  • '.&mt('custom markup file removed for [_1]',$domservers{$lonhost}).'
  • '; + } elsif (ref($loginhash{'login'}{'headtag'}{$lonhost}) eq 'HASH') { + $resulttext .= '
  • '.&mt('custom markup').' '.&mt('(for [_1])',$servers{$lonhost}).' '; + if ($possexempt{$lonhost}) { + $resulttext .= &mt('not included for client IP(s): [_1]',$possexempt{$lonhost}); + } else { + $resulttext .= &mt('included for any client IP'); + } + $resulttext .= '
  • '; + } + } + } } elsif ($item eq 'captcha') { if (ref($loginhash{'login'}) eq 'HASH') { my $chgtxt; @@ -6053,7 +6365,7 @@ sub modify_login { if (!$privkey) { $chgtxt .= '
  • '.&mt('Private key deleted').'
  • '; } else { - $chgtxt .= '
  • '.&mt('Private key set to [_1]',$pubkey).'
  • '; + $chgtxt .= '
  • '.&mt('Private key set to [_1]',$privkey).'
  • '; } $chgtxt .= ''; $resulttext .= '
  • '.$chgtxt.'
  • '; @@ -6077,6 +6389,27 @@ sub modify_login { return $resulttext; } +sub check_exempt_addresses { + my ($iplist) = @_; + $iplist =~ s/^\s+//; + $iplist =~ s/\s+$//; + my @poss_ips = split(/\s*[,:]\s*/,$iplist); + my (@okips,$new); + foreach my $ip (@poss_ips) { + if ($ip =~ /^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/) { + if (($1 <= 255) && ($2 <= 255) && ($3 <= 255) && ($4 <= 255)) { + push(@okips,$ip); + } + } + } + if (@okips > 0) { + $new = join(',',@okips); + } else { + $new = ''; + } + return $new; +} + sub color_font_choices { my %choices = &Apache::lonlocal::texthash ( @@ -7062,10 +7395,14 @@ sub modify_quotas { if (@{$confhash{'validation'}{$item}} > 0) { @{$confhash{'validation'}{$item}} = sort(@{$confhash{'validation'}{$item}}); } - if (ref($domconfig{'requestcourses'}{'validation'}) eq 'HASH') { - if (ref($domconfig{'requestcourses'}{'validation'}{$item}) eq 'ARRAY') { - @changed = &Apache::loncommon::compare_arrays($confhash{'validation'}{$item}, - $domconfig{'requestcourses'}{'validation'}{$item}); + if (ref($domconfig{'requestcourses'}) eq 'HASH') { + if (ref($domconfig{'requestcourses'}{'validation'}) eq 'HASH') { + if (ref($domconfig{'requestcourses'}{'validation'}{$item}) eq 'ARRAY') { + @changed = &Apache::loncommon::compare_arrays($confhash{'validation'}{$item}, + $domconfig{'requestcourses'}{'validation'}{$item}); + } else { + @changed = @{$confhash{'validation'}{$item}}; + } } else { @changed = @{$confhash{'validation'}{$item}}; } @@ -7086,9 +7423,15 @@ sub modify_quotas { $env{'form.requestcourses_validation_'.$item} =~ s/[\n\r\f]+/\s/gs; } } - if (ref($domconfig{'requestcourses'}{'validation'}) eq 'HASH') { - if ($domconfig{'requestcourses'}{'validation'}{$item} ne $confhash{'validation'}{$item}) { - $changes{'validation'}{$item} = $confhash{'validation'}{$item}; + if (ref($domconfig{'requestcourses'}) eq 'HASH') { + if (ref($domconfig{'requestcourses'}{'validation'}) eq 'HASH') { + if ($domconfig{'requestcourses'}{'validation'}{$item} ne $confhash{'validation'}{$item}) { + $changes{'validation'}{$item} = $confhash{'validation'}{$item}; + } + } else { + if ($confhash{'validation'}{$item} ne '') { + $changes{'validation'}{$item} = $confhash{'validation'}{$item}; + } } } else { if ($confhash{'validation'}{$item} ne '') { @@ -7106,14 +7449,18 @@ sub modify_quotas { } } if (ref($confhash{'validation'}) eq 'HASH') { - if (ref($domconfig{'requestcourses'}{'validation'}) eq 'HASH') { - if ($domconfig{'requestcourses'}{'validation'}{'dc'}) { - unless ($confhash{'validation'}{'dc'} eq $domconfig{'requestcourses'}{'validation'}{'dc'}) { - if ($confhash{'validation'}{'dc'} eq '') { - $changes{'validation'}{'dc'} = &mt('None'); - } else { - $changes{'validation'}{'dc'} = $confhash{'validation'}{'dc'}; + if (ref($domconfig{'requestcourses'}) eq 'HASH') { + if (ref($domconfig{'requestcourses'}{'validation'}) eq 'HASH') { + if ($domconfig{'requestcourses'}{'validation'}{'dc'}) { + unless ($confhash{'validation'}{'dc'} eq $domconfig{'requestcourses'}{'validation'}{'dc'}) { + if ($confhash{'validation'}{'dc'} eq '') { + $changes{'validation'}{'dc'} = &mt('None'); + } else { + $changes{'validation'}{'dc'} = $confhash{'validation'}{'dc'}; + } } + } elsif ($confhash{'validation'}{'dc'} ne '') { + $changes{'validation'}{'dc'} = $confhash{'validation'}{'dc'}; } } elsif ($confhash{'validation'}{'dc'} ne '') { $changes{'validation'}{'dc'} = $confhash{'validation'}{'dc'}; @@ -7121,9 +7468,13 @@ sub modify_quotas { } elsif ($confhash{'validation'}{'dc'} ne '') { $changes{'validation'}{'dc'} = $confhash{'validation'}{'dc'}; } - } elsif (ref($domconfig{'requestcourses'}{'validation'}) eq 'HASH') { - if ($domconfig{'requestcourses'}{'validation'}{'dc'}) { - $changes{'validation'}{'dc'} = &mt('None'); + } else { + if (ref($domconfig{'requestcourses'}) eq 'HASH') { + if (ref($domconfig{'requestcourses'}{'validation'}) eq 'HASH') { + if ($domconfig{'requestcourses'}{'validation'}{'dc'}) { + $changes{'validation'}{'dc'} = &mt('None'); + } + } } } } @@ -9057,8 +9408,8 @@ sub process_captcha { if ($newsettings->{'captcha'} eq 'recaptcha') { $newpub = $env{'form.'.$container.'_recaptchapub'}; $newpriv = $env{'form.'.$container.'_recaptchapriv'}; - $newpub =~ s/\W//g; - $newpriv =~ s/\W//g; + $newpub =~ s/[^\w\-]//g; + $newpriv =~ s/[^\w\-]//g; $newsettings->{'recaptchakeys'} = { public => $newpub, private => $newpriv, @@ -9965,14 +10316,18 @@ sub modify_helpsettings { sub modify_coursedefaults { my ($dom,$lastactref,%domconfig) = @_; my ($resulttext,$errors,%changes,%defaultshash); - my %defaultchecked = ('canuse_pdfforms' => 'off'); - my @toggles = ('canuse_pdfforms'); + my %defaultchecked = ( + 'uselcmath' => 'on', + 'usejsme' => 'on' + ); + my @toggles = ('uselcmath','usejsme'); my @numbers = ('anonsurvey_threshold','uploadquota_official','uploadquota_unofficial', 'uploadquota_community','uploadquota_textbook'); my @types = ('official','unofficial','community','textbook'); my %staticdefaults = ( anonsurvey_threshold => 10, uploadquota => 500, + postsubmit => 60, ); $defaultshash{'coursedefaults'} = {}; @@ -10033,27 +10388,117 @@ sub modify_coursedefaults { } } } - - my $officialcreds = $env{'form.official_credits'}; - $officialcreds =~ s/[^\d.]+//g; - my $unofficialcreds = $env{'form.unofficial_credits'}; - $unofficialcreds =~ s/[^\d.]+//g; - my $textbookcreds = $env{'form.textbook_credits'}; - $textbookcreds =~ s/[^\d.]+//g; - if (ref($domconfig{'coursedefaults'}{'coursecredits'} ne 'HASH') && - ($env{'form.coursecredits'} eq '1')) { - $changes{'coursecredits'} = 1; - } else { - if (($domconfig{'coursedefaults'}{'coursecredits'}{'official'} ne $officialcreds) || - ($domconfig{'coursedefaults'}{'coursecredits'}{'unofficial'} ne $unofficialcreds) || - ($domconfig{'coursedefaults'}{'coursecredits'}{'textbook'} ne $textbookcreds)) { - $changes{'coursecredits'} = 1; - } - } - $defaultshash{'coursedefaults'}{'coursecredits'} = { - official => $officialcreds, - unofficial => $unofficialcreds, - textbook => $textbookcreds, + my $currclone = $domconfig{'coursedefaults'}{'canclone'}; + my @currclonecode; + if (ref($currclone) eq 'HASH') { + if (ref($currclone->{'instcode'}) eq 'ARRAY') { + @currclonecode = @{$currclone->{'instcode'}}; + } + } + my $newclone; + if ($env{'form.canclone'} =~ /^(none|domain|instcode)$/) { + $newclone = $env{'form.canclone'}; + } + if ($newclone eq 'instcode') { + my @newcodes = &Apache::loncommon::get_env_multiple('form.clonecode'); + my (%codedefaults,@code_order,@clonecode); + &Apache::lonnet::auto_instcode_defaults($dom,\%codedefaults, + \@code_order); + foreach my $item (@code_order) { + if (grep(/^\Q$item\E$/,@newcodes)) { + push(@clonecode,$item); + } + } + if (@clonecode) { + $defaultshash{'coursedefaults'}{'canclone'} = { $newclone => \@clonecode }; + my @diffs = &Apache::loncommon::compare_arrays(\@currclonecode,\@clonecode); + if (@diffs) { + $changes{'canclone'} = 1; + } + } else { + $newclone eq ''; + } + } elsif ($newclone ne '') { + $defaultshash{'coursedefaults'}{'canclone'} = $newclone; + } + if ($newclone ne $currclone) { + $changes{'canclone'} = 1; + } + my %credits; + foreach my $type (@types) { + unless ($type eq 'community') { + $credits{$type} = $env{'form.'.$type.'_credits'}; + $credits{$type} =~ s/[^\d.]+//g; + } + } + if ((ref($domconfig{'coursedefaults'}{'coursecredits'}) ne 'HASH') && + ($env{'form.coursecredits'} eq '1')) { + $changes{'coursecredits'} = 1; + foreach my $type (keys(%credits)) { + $defaultshash{'coursedefaults'}{'coursecredits'}{$type} = $credits{$type}; + } + } else { + if ($env{'form.coursecredits'} eq '1') { + foreach my $type (@types) { + unless ($type eq 'community') { + if ($domconfig{'coursedefaults'}{'coursecredits'}{$type} ne $credits{$type}) { + $changes{'coursecredits'} = 1; + } + $defaultshash{'coursedefaults'}{'coursecredits'}{$type} = $credits{$type}; + } + } + } elsif (ref($domconfig{'coursedefaults'}{'coursecredits'}) eq 'HASH') { + foreach my $type (@types) { + unless ($type eq 'community') { + if ($domconfig{'coursedefaults'}{'coursecredits'}{$type}) { + $changes{'coursecredits'} = 1; + last; + } + } + } + } + } + if ($env{'form.postsubmit'} eq '1') { + $defaultshash{'coursedefaults'}{'postsubmit'}{'client'} = 'on'; + my %currtimeout; + if (ref($domconfig{'coursedefaults'}{'postsubmit'}) eq 'HASH') { + if ($domconfig{'coursedefaults'}{'postsubmit'}{'client'} eq 'off') { + $changes{'postsubmit'} = 1; + } + if (ref($domconfig{'coursedefaults'}{'postsubmit'}{'timeout'}) eq 'HASH') { + %currtimeout = %{$domconfig{'coursedefaults'}{'postsubmit'}{'timeout'}}; + } + } else { + $changes{'postsubmit'} = 1; + } + foreach my $type (@types) { + my $timeout = $env{'form.'.$type.'_timeout'}; + $timeout =~ s/\D//g; + if ($timeout == $staticdefaults{'postsubmit'}) { + $timeout = ''; + } elsif (($timeout eq '') || ($timeout =~ /^0+$/)) { + $timeout = '0'; + } + unless ($timeout eq '') { + $defaultshash{'coursedefaults'}{'postsubmit'}{'timeout'}{$type} = $timeout; + } + if (exists($currtimeout{$type})) { + if ($timeout ne $currtimeout{$type}) { + $changes{'postsubmit'} = 1; + } + } elsif ($timeout ne '') { + $changes{'postsubmit'} = 1; + } + } + } else { + $defaultshash{'coursedefaults'}{'postsubmit'}{'client'} = 'off'; + if (ref($domconfig{'coursedefaults'}{'postsubmit'}) eq 'HASH') { + if ($domconfig{'coursedefaults'}{'postsubmit'}{'client'} eq 'on') { + $changes{'postsubmit'} = 1; + } + } else { + $changes{'postsubmit'} = 1; + } } } my $putresult = &Apache::lonnet::put_dom('configuration',\%defaultshash, @@ -10061,19 +10506,31 @@ sub modify_coursedefaults { if ($putresult eq 'ok') { if (keys(%changes) > 0) { my %domdefaults = &Apache::lonnet::get_domain_defaults($dom,1); - if (($changes{'canuse_pdfforms'}) || ($changes{'coursecredits'}) || - ($changes{'uploadquota'})) { - if ($changes{'canuse_pdfforms'}) { - $domdefaults{'canuse_pdfforms'}=$defaultshash{'coursedefaults'}{'canuse_pdfforms'}; + if (($changes{'uploadquota'}) || ($changes{'postsubmit'}) || + ($changes{'coursecredits'}) || ($changes{'uselcmath'}) || ($changes{'usejsme'}) || + ($changes{'canclone'})) { + foreach my $item ('uselcmath','usejsme') { + if ($changes{$item}) { + $domdefaults{$item}=$defaultshash{'coursedefaults'}{$item}; + } } if ($changes{'coursecredits'}) { if (ref($defaultshash{'coursedefaults'}{'coursecredits'}) eq 'HASH') { - $domdefaults{'officialcredits'} = - $defaultshash{'coursedefaults'}{'coursecredits'}{'official'}; - $domdefaults{'unofficialcredits'} = - $defaultshash{'coursedefaults'}{'coursecredits'}{'unofficial'}; - $domdefaults{'textbookcredits'} = - $domdefaults{'coursedefaults'}{'coursecredits'}{'textbook'}; + foreach my $type (keys(%{$defaultshash{'coursedefaults'}{'coursecredits'}})) { + $domdefaults{$type.'credits'} = + $defaultshash{'coursedefaults'}{'coursecredits'}{$type}; + } + } + } + if ($changes{'postsubmit'}) { + if (ref($defaultshash{'coursedefaults'}{'postsubmit'}) eq 'HASH') { + $domdefaults{'postsubmit'} = $defaultshash{'coursedefaults'}{'postsubmit'}{'client'}; + if (ref($defaultshash{'coursedefaults'}{'postsubmit'}{'timeout'}) eq 'HASH') { + foreach my $type (keys(%{$defaultshash{'coursedefaults'}{'postsubmit'}{'timeout'}})) { + $domdefaults{$type.'postsubtimeout'} = + $defaultshash{'coursedefaults'}{'postsubmit'}{'timeout'}{$type}; + } + } } } if ($changes{'uploadquota'}) { @@ -10083,6 +10540,18 @@ sub modify_coursedefaults { } } } + if ($changes{'canclone'}) { + if (ref($defaultshash{'coursedefaults'}{'canclone'}) eq 'HASH') { + if (ref($defaultshash{'coursedefaults'}{'canclone'}{'instcode'}) eq 'ARRAY') { + my @clonecodes = @{$defaultshash{'coursedefaults'}{'canclone'}{'instcode'}}; + if (@clonecodes) { + $domdefaults{'canclone'} = join('+',@clonecodes); + } + } + } else { + $domdefaults{'canclone'}=$defaultshash{'coursedefaults'}{'canclone'}; + } + } my $cachetime = 24*60*60; &Apache::lonnet::do_cache_new('domdefaults',$dom,\%domdefaults,$cachetime); if (ref($lastactref) eq 'HASH') { @@ -10091,11 +10560,17 @@ sub modify_coursedefaults { } $resulttext = &mt('Changes made:').'
      '; foreach my $item (sort(keys(%changes))) { - if ($item eq 'canuse_pdfforms') { + if ($item eq 'uselcmath') { + if ($env{'form.'.$item} eq '1') { + $resulttext .= '
    • '.&mt('Math preview uses LON-CAPA previewer (javascript), if supported by browser.').'
    • '; + } else { + $resulttext .= '
    • '.&mt('Math preview uses DragMath (Java), if supported by client OS.').'
    • '; + } + } elsif ($item eq 'usejsme') { if ($env{'form.'.$item} eq '1') { - $resulttext .= '
    • '.&mt("Course/Community users can create/upload PDF forms set to 'on'").'
    • '; + $resulttext .= '
    • '.&mt('Molecule editor uses JSME (HTML5), if supported by browser.').'
    • '; } else { - $resulttext .= '
    • '.&mt('Course/Community users can create/upload PDF forms set to "off"').'
    • '; + $resulttext .= '
    • '.&mt('Molecule editor uses JME (Java), if supported by client OS.').'
    • '; } } elsif ($item eq 'anonsurvey_threshold') { $resulttext .= '
    • '.&mt('Responder count required for display of anonymous survey submissions set to [_1].',$defaultshash{'coursedefaults'}{'anonsurvey_threshold'}).'
    • '; @@ -10112,6 +10587,42 @@ sub modify_coursedefaults { } else { $resulttext .= '
    • '.&mt('Default quota for content uploaded via Course Editor remains default: [_1] MB',$staticdefaults{'uploadquota'}).'
    • '; } + } elsif ($item eq 'postsubmit') { + if ($domdefaults{'postsubmit'} eq 'off') { + $resulttext .= '
    • '.&mt('Submit button(s) remain enabled on page after student makes submission.'); + } else { + $resulttext .= '
    • '.&mt('Submit button(s) disabled on page after student makes submission').'; '; + if (ref($defaultshash{'coursedefaults'}{'postsubmit'}) eq 'HASH') { + $resulttext .= &mt('durations:').'
        '; + foreach my $type (@types) { + $resulttext .= '
      • '; + my $timeout; + if (ref($defaultshash{'coursedefaults'}{'postsubmit'}{'timeout'}) eq 'HASH') { + $timeout = $defaultshash{'coursedefaults'}{'postsubmit'}{'timeout'}{$type}; + } + my $display; + if ($timeout eq '0') { + $display = &mt('unlimited'); + } elsif ($timeout eq '') { + $display = &mt('[quant,_1,second] (default)',$staticdefaults{'postsubmit'}); + } else { + $display = &mt('[quant,_1,second]',$timeout); + } + if ($type eq 'community') { + $resulttext .= &mt('Communities'); + } elsif ($type eq 'official') { + $resulttext .= &mt('Official courses'); + } elsif ($type eq 'unofficial') { + $resulttext .= &mt('Unofficial courses'); + } elsif ($type eq 'textbook') { + $resulttext .= &mt('Textbook courses'); + } + $resulttext .= ' -- '.$display.'
      • '; + } + $resulttext .= '
      '; + } + $resulttext .= '
    • '; + } } elsif ($item eq 'coursecredits') { if (ref($defaultshash{'coursedefaults'}{'coursecredits'}) eq 'HASH') { if (($domdefaults{'officialcredits'} eq '') && @@ -10129,6 +10640,17 @@ sub modify_coursedefaults { } else { $resulttext .= '
    • '.&mt('Student credits not in use for courses in this domain').'
    • '; } + } elsif ($item eq 'canclone') { + if (ref($defaultshash{'coursedefaults'}{'canclone'}) eq 'HASH') { + if (ref($defaultshash{'coursedefaults'}{'canclone'}{'instcode'}) eq 'ARRAY') { + my $clonecodes = join(' '.&mt('and').' ',@{$defaultshash{'coursedefaults'}{'canclone'}{'instcode'}}); + $resulttext .= '
    • '.&mt('By default, official courses can be cloned from existing courses with the same: [_1]',''.$clonecodes.'').'
    • '; + } + } elsif ($defaultshash{'coursedefaults'}{'canclone'} eq 'domain') { + $resulttext .= '
    • '.&mt('By default, a course requester can clone any course from his/her domain.').'
    • '; + } else { + $resulttext .= '
    • '.&mt('By default, only course owner and coordinators may clone a course.').'
    • '; + } } } $resulttext .= '
    '; @@ -10547,7 +11069,23 @@ sub modify_usersessions { $changes{'spares'}{$lonhost} = \%spareschg; } } - + $defaultshash{'usersessions'}{'offloadnow'} = {}; + my @offloadnow = &Apache::loncommon::get_env_multiple('form.offloadnow'); + my @okoffload; + if (@offloadnow) { + foreach my $server (@offloadnow) { + if (&Apache::lonnet::hostname($server) ne '') { + unless (grep(/^\Q$server\E$/,@okoffload)) { + push(@okoffload,$server); + } + } + } + if (@okoffload) { + foreach my $lonhost (@okoffload) { + $defaultshash{'usersessions'}{'offloadnow'}{$lonhost} = 1; + } + } + } if (ref($domconfig{'usersessions'}) eq 'HASH') { if (ref($domconfig{'usersessions'}{'spares'}) eq 'HASH') { if (ref($changes{'spares'}) eq 'HASH') { @@ -10558,8 +11096,27 @@ sub modify_usersessions { } else { $savespares = 1; } + if (ref($domconfig{'usersessions'}{'offloadnow'}) eq 'HASH') { + foreach my $lonhost (keys(%{$domconfig{'usersessions'}{'offloadnow'}})) { + unless ($defaultshash{'usersessions'}{'offloadnow'}{$lonhost}) { + $changes{'offloadnow'} = 1; + last; + } + } + unless ($changes{'offloadnow'}) { + foreach my $lonhost (keys(%{$defaultshash{'usersessions'}{'offloadnow'}})) { + unless ($domconfig{'usersessions'}{'offloadnow'}{$lonhost}) { + $changes{'offloadnow'} = 1; + last; + } + } + } + } elsif (@okoffload) { + $changes{'offloadnow'} = 1; + } + } elsif (@okoffload) { + $changes{'offloadnow'} = 1; } - my $nochgmsg = &mt('No changes made to settings for user session hosting/offloading.'); if ((keys(%changes) > 0) || ($savespares)) { my $putresult = &Apache::lonnet::put_dom('configuration',\%defaultshash, @@ -10572,6 +11129,9 @@ sub modify_usersessions { if (ref($defaultshash{'usersessions'}{'hosted'}) eq 'HASH') { $domdefaults{'hostedsessions'} = $defaultshash{'usersessions'}{'hosted'}; } + if (ref($defaultshash{'usersessions'}{'offloadnow'}) eq 'HASH') { + $domdefaults{'offloadnow'} = $defaultshash{'usersessions'}{'offloadnow'}; + } } my $cachetime = 24*60*60; &Apache::lonnet::do_cache_new('domdefaults',$dom,\%domdefaults,$cachetime); @@ -10640,6 +11200,21 @@ sub modify_usersessions { $resulttext .= ''; } } + if ($changes{'offloadnow'}) { + if (ref($defaultshash{'usersessions'}{'offloadnow'}) eq 'HASH') { + if (keys(%{$defaultshash{'usersessions'}{'offloadnow'}}) > 0) { + $resulttext .= '
  • '.&mt('Switch active users on next access, for server(s):').'
      '; + foreach my $lonhost (sort(keys(%{$defaultshash{'usersessions'}{'offloadnow'}}))) { + $resulttext .= '
    • '.$lonhost.'
    • '; + } + $resulttext .= '
    '; + } else { + $resulttext .= '
  • '.&mt('No servers now set to switch active users on next access.'); + } + } else { + $resulttext .= '
  • '.&mt('No servers now set to switch active users on next access.').'
  • '; + } + } $resulttext .= ''; } else { $resulttext = $nochgmsg; @@ -10661,6 +11236,7 @@ sub modify_loadbalancing { my ($othertitle,$usertypes,$types) = &Apache::loncommon::sorted_inst_types($dom); my %servers = &Apache::lonnet::internet_dom_servers($dom); + my %libraryservers = &Apache::lonnet::get_servers($dom,'library'); my @sparestypes = ('primary','default'); my %typetitles = &sparestype_titles(); my $resulttext; @@ -10752,7 +11328,10 @@ sub modify_loadbalancing { $rule = $env{'form.loadbalancing_rules_'.$i.'_'.$type}; } if ($rule eq 'specific') { - $rule = $env{'form.loadbalancing_singleserver_'.$i.'_'.$type}; + my $specifiedhost = $env{'form.loadbalancing_singleserver_'.$i.'_'.$type}; + if (exists($servers{$specifiedhost})) { + $rule = $specifiedhost; + } } $defaultshash{'loadbalancing'}{$balancer}{'rules'}{$type} = $rule; if (ref($currrules{$balancer}) eq 'HASH') { @@ -10774,20 +11353,22 @@ sub modify_loadbalancing { \%defaultshash,$dom); if ($putresult eq 'ok') { if (keys(%changes) > 0) { + my %toupdate; if (ref($changes{'delete'}) eq 'ARRAY') { foreach my $balancer (sort(@{$changes{'delete'}})) { $resulttext .= '
  • '.&mt('Load Balancing discontinued for: [_1]',$balancer).'
  • '; - my $cachekey = &escape('loadbalancing').':'.&escape($dom); - &Apache::lonnet::remote_devalidate_cache($balancer,[$cachekey]); + $toupdate{$balancer} = 1; } } if (ref($changes{'add'}) eq 'ARRAY') { foreach my $balancer (sort(@{$changes{'add'}})) { $resulttext .= '
  • '.&mt('Load Balancing enabled for: [_1]',$balancer); + $toupdate{$balancer} = 1; } } if (ref($changes{'curr'}) eq 'HASH') { foreach my $balancer (sort(keys(%{$changes{'curr'}}))) { + $toupdate{$balancer} = 1; if (ref($changes{'curr'}{$balancer}) eq 'HASH') { if ($changes{'curr'}{$balancer}{'targets'}) { my %offloadstr; @@ -10824,8 +11405,38 @@ sub modify_loadbalancing { if ($rule eq '') { $balancetext = $ruletitles{'default'}; } elsif (($rule eq 'homeserver') || ($rule eq 'externalbalancer') || - ($rule eq 'balancer') || ($rule eq 'offloadedto')) { - $balancetext = $ruletitles{$rule}; + ($type eq '_LC_ipchange') || ($type eq '_LC_ipchangesso')) { + if (($type eq '_LC_ipchange') || ($type eq '_LC_ipchangesso')) { + foreach my $sparetype (@sparestypes) { + if (ref($defaultshash{'loadbalancing'}{$balancer}{'targets'}{$sparetype}) eq 'ARRAY') { + map { $toupdate{$_} = 1; } (@{$defaultshash{'loadbalancing'}{$balancer}{'targets'}{$sparetype}}); + } + } + foreach my $item (@{$alltypes}) { + next if ($item =~ /^_LC_ipchange/); + my $hasrule = $defaultshash{'loadbalancing'}{$balancer}{'rules'}{$item}; + if ($hasrule eq 'homeserver') { + map { $toupdate{$_} = 1; } (keys(%libraryservers)); + } else { + unless (($hasrule eq 'default') || ($hasrule eq 'none') || ($hasrule eq 'externalbalancer')) { + if ($servers{$hasrule}) { + $toupdate{$hasrule} = 1; + } + } + } + } + if (($rule eq 'balancer') || ($rule eq 'offloadedto')) { + $balancetext = $ruletitles{$rule}; + } else { + my $receiver = $defaultshash{'loadbalancing'}{$balancer}{'rules'}{$type}; + $balancetext = $ruletitles{'particular'}.' '.$receiver; + if ($receiver) { + $toupdate{$receiver}; + } + } + } else { + $balancetext = $ruletitles{$rule}; + } } else { $balancetext = &mt('offload to [_1]',$defaultshash{'loadbalancing'}{$balancer}{'rules'}{$type}); } @@ -10834,8 +11445,25 @@ sub modify_loadbalancing { } } } - my $cachekey = &escape('loadbalancing').':'.&escape($dom); - &Apache::lonnet::remote_devalidate_cache($balancer,[$cachekey]); + if (keys(%toupdate)) { + my %thismachine; + my $updatedhere; + my $cachetime = 60*60*24; + map { $thismachine{$_} = 1; } &Apache::lonnet::current_machine_ids(); + foreach my $lonhost (keys(%toupdate)) { + if ($thismachine{$lonhost}) { + unless ($updatedhere) { + &Apache::lonnet::do_cache_new('loadbalancing',$dom, + $defaultshash{'loadbalancing'}, + $cachetime); + $updatedhere = 1; + } + } else { + my $cachekey = &escape('loadbalancing').':'.&escape($dom); + &Apache::lonnet::remote_devalidate_cache($lonhost,[$cachekey]); + } + } + } } } if ($resulttext ne '') { @@ -11532,9 +12160,18 @@ function toggleDisplay(domForm,caller) { if (document.getElementById(caller)) { var divitem = document.getElementById(caller); var optionsElement = domForm.coursecredits; + var checkval = 1; + var dispval = 'block'; if (caller == 'emailoptions') { optionsElement = domForm.cancreate_email; } + if (caller == 'studentsubmission') { + optionsElement = domForm.postsubmit; + } + if (caller == 'cloneinstcode') { + optionsElement = domForm.canclone; + checkval = 'instcode'; + } if (optionsElement.length) { var currval; for (var i=0; i 1) { + if (keys(%servers)) { foreach my $server (keys(%servers)) { next if ($thismachine{$server}); my @cached; 500 Internal Server Error

    Internal Server Error

    The server encountered an internal error or misconfiguration and was unable to complete your request.

    Please contact the server administrator at root@localhost to inform them of the time this error occurred, and the actions you performed just before this error.

    More information about this error may be available in the server error log.