--- loncom/interface/domainprefs.pm 2016/10/24 04:01:16 1.160.6.73 +++ loncom/interface/domainprefs.pm 2017/01/21 21:51:56 1.160.6.76 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Handler to set domain-wide configuration settings # -# $Id: domainprefs.pm,v 1.160.6.73 2016/10/24 04:01:16 raeburn Exp $ +# $Id: domainprefs.pm,v 1.160.6.76 2017/01/21 21:51:56 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -216,7 +216,6 @@ sub handler { 'serverstatuses','requestcourses','helpsettings', 'coursedefaults','usersessions','loadbalancing', 'requestauthor','selfenrollment','inststatus'],$dom); - 'selfenrollment','inststatus'],$dom); my @prefs_order = ('rolecolors','login','defaults','quotas','autoenroll', 'autoupdate','autocreate','directorysrch','contacts', 'usercreation','selfcreation','usermodification','scantron', @@ -4020,6 +4019,9 @@ sub print_loadbalancing { my ($numspares,@spares) = &count_servers($lonhost,%servers); my @sparestypes = ('primary','default'); my %typetitles = &sparestype_titles(); + my %hostherechecked = ( + no => ' checked="checked"', + ); foreach my $sparetype (@sparestypes) { my $targettable; for (my $i=0; $i<$numspares; $i++) { @@ -4065,6 +4067,23 @@ sub print_loadbalancing { $datatable .= ''.$typetitles{$sparetype}.'
'. ''.$targettable.'

'; } + $hostherechecked{$sparetype} = ''; + if (ref($currtargets{$lonhost}) eq 'HASH') { + if (ref($currtargets{$lonhost}{$sparetype}) eq 'ARRAY') { + if (grep(/^\Q$lonhost\E$/,@{$currtargets{$lonhost}{$sparetype}})) { + $hostherechecked{$sparetype} = ' checked="checked"'; + $hostherechecked{'no'} = ''; + } + } + } + } + $datatable .= &mt('Hosting on balancer itself').'
'. + '
'; + foreach my $sparetype (@sparestypes) { + $datatable .= '
'; } $datatable .= ''. &loadbalancing_rules($dom,$intdom,$currrules{$lonhost}, @@ -10591,13 +10610,15 @@ sub modify_helpsettings { $rolename=~s/[^A-Za-z0-9]//gs; if ($rolename ne '') { unless(exists($existing{'rolesdef_'.$rolename})) { - my $errmsg; - my $result = &Apache::lonuserutils::store_custom_role($rolename,$prefix, - $confname,$dom); + my %newprivs = &Apache::lonuserutils::custom_role_update($rolename,$prefix); + my $result = &Apache::lonnet::definerole($rolename,$newprivs{'s'},$newprivs{'d'}, + $newprivs{'c'},$confname,$dom); if ($result eq 'ok') { $changes{'newcustomrole'} = $rolename; } else { - $errmsg = ': '.$result; + $errors .= '
  • '. + &mt('An error occurred storing the new custom role: [_1]', + $result).'
  • '; } } } @@ -11631,8 +11652,13 @@ sub modify_loadbalancing { push(@offloadto,$target); } } - $defaultshash{'loadbalancing'}{$balancer}{'targets'}{$sparetype} = \@offloadto; } + if ($env{'form.loadbalancing_target_'.$i.'_hosthere'} eq $sparetype) { + unless(grep(/^\Q$balancer\E$/,@offloadto)) { + push(@offloadto,$balancer); + } + } + $defaultshash{'loadbalancing'}{$balancer}{'targets'}{$sparetype} = \@offloadto; } if (ref($currtargets{$balancer}) eq 'HASH') { foreach my $sparetype (@sparestypes) {