--- loncom/interface/domainprefs.pm 2016/09/18 19:22:48 1.160.6.71
+++ 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.71 2016/09/18 19:22:48 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
#
@@ -213,15 +213,15 @@ sub handler {
'quotas','autoenroll','autoupdate','autocreate',
'directorysrch','usercreation','usermodification',
'contacts','defaults','scantron','coursecategories',
- 'serverstatuses','requestcourses','coursedefaults',
- 'usersessions','loadbalancing','requestauthor',
- 'selfenrollment','inststatus'],$dom);
+ 'serverstatuses','requestcourses','helpsettings',
+ 'coursedefaults','usersessions','loadbalancing',
+ 'requestauthor','selfenrollment','inststatus'],$dom);
my @prefs_order = ('rolecolors','login','defaults','quotas','autoenroll',
'autoupdate','autocreate','directorysrch','contacts',
'usercreation','selfcreation','usermodification','scantron',
'requestcourses','requestauthor','coursecategories',
- 'serverstatuses','coursedefaults','selfenrollment',
- 'usersessions');
+ 'serverstatuses','helpsettings','coursedefaults',
+ 'selfenrollment','usersessions');
my %existing;
if (ref($domconfig{'loadbalancing'}) eq 'HASH') {
%existing = %{$domconfig{'loadbalancing'}};
@@ -304,9 +304,11 @@ sub handler {
modify => \&modify_autocreate,
},
'directorysrch' =>
- { text => 'Institutional directory searches',
+ { text => 'Directory searches',
help => 'Domain_Configuration_InstDirectory_Search',
- header => [{col1 => 'Setting',
+ header => [{col1 => 'Institutional Directory Setting',
+ col2 => 'Value',},
+ {col1 => 'LON-CAPA Directory Setting',
col2 => 'Value',}],
print => \&print_directorysrch,
modify => \&modify_directorysrch,
@@ -411,6 +413,16 @@ sub handler {
print => \&print_serverstatuses,
modify => \&modify_serverstatuses,
},
+ 'helpsettings' =>
+ {text => 'Support settings',
+ help => 'Domain_Configuration_Help_Settings',
+ header => [{col1 => 'Help Page Settings (logged-in users)',
+ col2 => 'Value'},
+ {col1 => 'Helpdesk Roles',
+ col2 => 'Settings'},],
+ print => \&print_helpsettings,
+ modify => \&modify_helpsettings,
+ },
'coursedefaults' =>
{text => 'Course/Community defaults',
help => 'Domain_Configuration_Course_Defaults',
@@ -619,6 +631,8 @@ sub process_changes {
$output = &modify_quotas($r,$dom,$action,$lastactref,%domconfig);
} elsif ($action eq 'requestauthor') {
$output = &modify_quotas($r,$dom,$action,$lastactref,%domconfig);
+ } elsif ($action eq 'helpsettings') {
+ $output = &modify_helpsettings($r,$dom,$confname,%domconfig);
} elsif ($action eq 'coursedefaults') {
$output = &modify_coursedefaults($dom,$lastactref,%domconfig);
} elsif ($action eq 'selfenrollment') {
@@ -639,6 +653,22 @@ sub print_config_box {
$output = &coursecategories_javascript($settings);
} elsif ($action eq 'defaults') {
$output = &defaults_javascript($settings);
+ } elsif ($action eq 'helpsettings') {
+ my (%privs,%levelscurrent);
+ my %full=();
+ my %levels=(
+ course => {},
+ domain => {},
+ system => {},
+ );
+ my $context = 'domain';
+ my $crstype = 'Course';
+ my $formname = 'display';
+ &Apache::lonuserutils::custom_role_privs(\%privs,\%full,\%levels,\%levelscurrent);
+ my @templateroles = &Apache::lonuserutils::custom_template_roles($context,$crstype);
+ $output =
+ &Apache::lonuserutils::custom_roledefs_js($context,$crstype,$formname,\%full,
+ \@templateroles);
}
$output .=
'
@@ -656,6 +686,7 @@ sub print_config_box {
my $colspan = '';
my $rightcolspan = '';
if (($action eq 'rolecolors') || ($action eq 'defaults') ||
+ ($action eq 'directorysrch') ||
(($action eq 'login') && ($numheaders < 4))) {
$colspan = ' colspan="2"';
}
@@ -673,7 +704,8 @@ sub print_config_box {
$rowtotal ++;
if (($action eq 'autoupdate') || ($action eq 'usercreation') || ($action eq 'selfcreation') ||
($action eq 'usermodification') || ($action eq 'defaults') || ($action eq 'coursedefaults') ||
- ($action eq 'selfenrollment') || ($action eq 'usersessions')) {
+ ($action eq 'selfenrollment') || ($action eq 'usersessions') || ($action eq 'directorysrch') ||
+ ($action eq 'helpsettings')) {
$output .= $item->{'print'}->('top',$dom,$settings,\$rowtotal);
} elsif ($action eq 'coursecategories') {
$output .= $item->{'print'}->('top',$dom,$item,$settings,\$rowtotal);
@@ -728,7 +760,8 @@ sub print_config_box {
}
$rowtotal ++;
} elsif (($action eq 'usermodification') || ($action eq 'coursedefaults') ||
- ($action eq 'defaults')) {
+ ($action eq 'defaults') || ($action eq 'directorysrch') ||
+ ($action eq 'helpsettings')) {
$output .= $item->{'print'}->('bottom',$dom,$settings,\$rowtotal);
} elsif ($action eq 'login') {
if ($numheaders == 4) {
@@ -841,7 +874,7 @@ sub print_config_box {
';
- if (($action eq 'login') || ($action eq 'directorysrch')) {
+ if ($action eq 'login') {
$output .= '
'.&mt($item->{'header'}->[0]->{'col1'}).' ';
} elsif ($action eq 'serverstatuses') {
@@ -885,13 +918,12 @@ sub print_config_box {
$rowtotal ++;
if ($action eq 'quotas') {
$output .= &print_quotas($dom,$settings,\$rowtotal,$action);
- } elsif (($action eq 'autoenroll') || ($action eq 'autocreate') || ($action eq 'directorysrch') ||
- ($action eq 'contacts') || ($action eq 'serverstatuses') || ($action eq 'loadbalancing')) {
+ } elsif (($action eq 'autoenroll') || ($action eq 'autocreate') ||
+ ($action eq 'contacts') || ($action eq 'serverstatuses') ||
+ ($action eq 'loadbalancing')) {
$output .= $item->{'print'}->($dom,$settings,\$rowtotal);
} elsif ($action eq 'scantron') {
$output .= &print_scantronformat($r,$dom,$confname,$settings,\$rowtotal);
- } elsif ($action eq 'helpsettings') {
- $output .= &print_helpsettings($dom,$confname,$settings,\$rowtotal);
}
}
$output .= '
@@ -2604,115 +2636,149 @@ sub print_autocreate {
}
sub print_directorysrch {
- my ($dom,$settings,$rowtotal) = @_;
- my $srchon = ' ';
- my $srchoff = ' checked="checked" ';
- my ($exacton,$containson,$beginson);
- my $localon = ' ';
- my $localoff = ' checked="checked" ';
- if (ref($settings) eq 'HASH') {
- if ($settings->{'available'} eq '1') {
- $srchon = $srchoff;
- $srchoff = ' ';
- }
- if ($settings->{'localonly'} eq '1') {
- $localon = $localoff;
- $localoff = ' ';
- }
- if (ref($settings->{'searchtypes'}) eq 'ARRAY') {
- foreach my $type (@{$settings->{'searchtypes'}}) {
- if ($type eq 'exact') {
+ my ($position,$dom,$settings,$rowtotal) = @_;
+ my $datatable;
+ if ($position eq 'top') {
+ my $instsrchon = ' ';
+ my $instsrchoff = ' checked="checked" ';
+ my ($exacton,$containson,$beginson);
+ my $instlocalon = ' ';
+ my $instlocaloff = ' checked="checked" ';
+ if (ref($settings) eq 'HASH') {
+ if ($settings->{'available'} eq '1') {
+ $instsrchon = $instsrchoff;
+ $instsrchoff = ' ';
+ }
+ if ($settings->{'localonly'} eq '1') {
+ $instlocalon = $instlocaloff;
+ $instlocaloff = ' ';
+ }
+ if (ref($settings->{'searchtypes'}) eq 'ARRAY') {
+ foreach my $type (@{$settings->{'searchtypes'}}) {
+ if ($type eq 'exact') {
+ $exacton = ' checked="checked" ';
+ } elsif ($type eq 'contains') {
+ $containson = ' checked="checked" ';
+ } elsif ($type eq 'begins') {
+ $beginson = ' checked="checked" ';
+ }
+ }
+ } else {
+ if ($settings->{'searchtypes'} eq 'exact') {
+ $exacton = ' checked="checked" ';
+ } elsif ($settings->{'searchtypes'} eq 'contains') {
+ $containson = ' checked="checked" ';
+ } elsif ($settings->{'searchtypes'} eq 'specify') {
$exacton = ' checked="checked" ';
- } elsif ($type eq 'contains') {
$containson = ' checked="checked" ';
- } elsif ($type eq 'begins') {
- $beginson = ' checked="checked" ';
}
}
- } else {
- if ($settings->{'searchtypes'} eq 'exact') {
- $exacton = ' checked="checked" ';
- } elsif ($settings->{'searchtypes'} eq 'contains') {
- $containson = ' checked="checked" ';
- } elsif ($settings->{'searchtypes'} eq 'specify') {
- $exacton = ' checked="checked" ';
- $containson = ' checked="checked" ';
- }
}
- }
- my ($searchtitles,$titleorder) = &sorted_searchtitles();
- my ($othertitle,$usertypes,$types) = &Apache::loncommon::sorted_inst_types($dom);
+ my ($searchtitles,$titleorder) = &sorted_searchtitles();
+ my ($othertitle,$usertypes,$types) = &Apache::loncommon::sorted_inst_types($dom);
- my $numinrow = 4;
- my $cansrchrow = 0;
- my $datatable=' '.
- ''.&mt('Directory search available?').' '.
- ''.
- ' '.&mt('Yes').' '.
- ' '.&mt('No').' '.
- ' '.
- ''.&mt('Other domains can search?').' '.
- ''.
- ' '.&mt('Yes').' '.
- ' '.&mt('No').' '.
- ' ';
- $$rowtotal += 2;
- if (ref($usertypes) eq 'HASH') {
- if (keys(%{$usertypes}) > 0) {
- $datatable .= &insttypes_row($settings,$types,$usertypes,$dom,
- $numinrow,$othertitle,'cansearch');
- $cansrchrow = 1;
+ my $numinrow = 4;
+ my $cansrchrow = 0;
+ $datatable=''.
+ ''.&mt('Institutional directory search available?').' '.
+ ''.
+ ' '.&mt('Yes').' '.
+ ' '.&mt('No').' '.
+ ' '.
+ ''.&mt('Other domains can search institution?').' '.
+ ''.
+ ' '.&mt('Yes').' '.
+ ' '.&mt('No').' '.
+ ' ';
+ $$rowtotal += 2;
+ if (ref($usertypes) eq 'HASH') {
+ if (keys(%{$usertypes}) > 0) {
+ $datatable .= &insttypes_row($settings,$types,$usertypes,$dom,
+ $numinrow,$othertitle,'cansearch');
+ $cansrchrow = 1;
+ }
}
- }
- if ($cansrchrow) {
- $$rowtotal ++;
- $datatable .= '';
- } else {
- $datatable .= ' ';
- }
- $datatable .= ''.&mt('Supported search methods').
- ' ';
- foreach my $title (@{$titleorder}) {
- if (defined($searchtitles->{$title})) {
- my $check = ' ';
- if (ref($settings) eq 'HASH') {
- if (ref($settings->{'searchby'}) eq 'ARRAY') {
- if (grep(/^\Q$title\E$/,@{$settings->{'searchby'}})) {
- $check = ' checked="checked" ';
+ if ($cansrchrow) {
+ $$rowtotal ++;
+ $datatable .= ' ';
+ } else {
+ $datatable .= ' ';
+ }
+ $datatable .= ''.&mt('Supported search methods').
+ ' ';
- $$rowtotal ++;
- if ($cansrchrow) {
- $datatable .= '';
+ $datatable .= '
';
+ $$rowtotal ++;
+ if ($cansrchrow) {
+ $datatable .= '';
+ } else {
+ $datatable .= ' ';
+ }
+ $datatable .= ''.&mt('Search latitude').' '.
+ ''.
+ ''.
+ ' '.&mt('Exact match').
+ ' '.
+ ' '.&mt('Begins with').
+ ' '.
+ ' '.&mt('Contains').
+ ' ';
+ $$rowtotal ++;
} else {
- $datatable .= '';
+ my $domsrchon = ' checked="checked" ';
+ my $domsrchoff = ' ';
+ my $domlocalon = ' ';
+ my $domlocaloff = ' checked="checked" ';
+ if (ref($settings) eq 'HASH') {
+ if ($settings->{'lclocalonly'} eq '1') {
+ $domlocalon = $domlocaloff;
+ $domlocaloff = ' ';
+ }
+ if ($settings->{'lcavailable'} eq '0') {
+ $domsrchoff = $domsrchon;
+ $domsrchon = ' ';
+ }
+ }
+ $datatable=' '.
+ ''.&mt('LON-CAPA directory search available?').' '.
+ ''.
+ ' '.&mt('Yes').' '.
+ ' '.&mt('No').' '.
+ ' '.
+ ''.&mt('Other domains can search LON-CAPA domain?').' '.
+ ''.
+ ' '.&mt('Yes').' '.
+ ' '.&mt('No').' '.
+ ' ';
+ $$rowtotal += 2;
}
- $datatable .= ''.&mt('Search latitude').' '.
- ''.
- ''.
- ' '.&mt('Exact match').
- ' '.
- ' '.&mt('Begins with').
- ' '.
- ' '.&mt('Contains').
- ' ';
- $$rowtotal ++;
return $datatable;
}
@@ -2816,18 +2882,92 @@ sub print_contacts {
}
sub print_helpsettings {
- my ($dom,$confname,$settings,$rowtotal) = @_;
+ my ($position,$dom,$settings,$rowtotal) = @_;
+ my $confname = $dom.'-domainconfig';
my ($datatable,$itemcount);
- $itemcount = 1;
- my (%choices,%defaultchecked,@toggles);
- $choices{'submitbugs'} = &mt('Display link to: [_1]?',
- &Apache::loncommon::modal_link('http://bugs.loncapa.org',
- &mt('LON-CAPA bug tracker'),600,500));
- %defaultchecked = ('submitbugs' => 'on');
- @toggles = ('submitbugs',);
-
- ($datatable,$itemcount) = &radiobutton_prefs($settings,\@toggles,\%defaultchecked,
- \%choices,$itemcount);
+ if ($position eq 'top') {
+ $itemcount = 1;
+ my (%choices,%defaultchecked,@toggles);
+ $choices{'submitbugs'} = &mt('Display link to: [_1]?',
+ &Apache::loncommon::modal_link('http://bugs.loncapa.org',
+ &mt('LON-CAPA bug tracker'),600,500));
+ %defaultchecked = ('submitbugs' => 'on');
+ @toggles = ('submitbugs');
+ ($datatable,$itemcount) = &radiobutton_prefs($settings,\@toggles,\%defaultchecked,
+ \%choices,$itemcount);
+ $$rowtotal ++;
+ } else {
+ my $css_class;
+ my %existing=&Apache::lonnet::dump('roles',$dom,$confname,'rolesdef_');
+ my %customroles;
+ foreach my $key (keys(%existing)) {
+ if ($key=~/^rolesdef\_(\w+)$/) {
+ my $rolename = $1;
+ my %privs;
+ ($privs{'system'},$privs{'domain'},$privs{'course'}) = split(/\_/,$existing{$key});
+ $customroles{$rolename} = \%privs;
+ }
+ }
+ my $count = 0;
+ my $context = 'domprefs';
+ my $crstype = 'Course';
+ foreach my $role (sort(keys(%customroles))) {
+ my $prefix = 'custhelp'.$count;
+ my %full=();
+ my %levels= (
+ course => {},
+ domain => {},
+ system => {},
+ );
+ my %levelscurrent=(
+ course => {},
+ domain => {},
+ system => {},
+ );
+ &Apache::lonuserutils::custom_role_privs($customroles{$role},\%full,\%levels,\%levelscurrent);
+ my @templateroles = &Apache::lonuserutils::custom_template_roles($context,$crstype);
+ $css_class = $itemcount%2?' class="LC_odd_row"':'';
+ $datatable .= ''.
+ ' '.
+ ' '.
+ &mt('Modify').' '.
+ ''.&mt('Existing helpdesk role:').' '.
+ ''.$role.' '.
+ &Apache::lonuserutils::custom_role_header($context,$crstype,
+ \@templateroles,$prefix).
+ &Apache::lonuserutils::custom_role_table($crstype,\%full,\%levels,
+ \%levelscurrent,$prefix).
+ ' ';
+ $count ++;
+ $itemcount ++;
+ }
+ $css_class = $itemcount%2?' class="LC_odd_row"':'';
+ my $newcust = 'custhelp'.$count;
+ my (%privs,%levelscurrent);
+ my %full=();
+ my %levels= (
+ course => {},
+ domain => {},
+ system => {},
+ );
+ &Apache::lonuserutils::custom_role_privs(\%privs,\%full,\%levels,\%levelscurrent);
+ my @templateroles = &Apache::lonuserutils::custom_template_roles($context,$crstype);
+ $datatable .= ''.
+ ' '. &mt('Add').
+ ' '.
+ ''.
+ ''.&mt('Name of new helpdesk role:').' '.
+ ' '.
+ ' '.
+ &Apache::lonuserutils::custom_role_header($context,$crstype,
+ \@templateroles,$newcust).
+ &Apache::lonuserutils::custom_role_table('Course',\%full,\%levels,
+ \%levelscurrent,$newcust).
+ ' '.
+ ' ';
+ $count ++;
+ $$rowtotal += $count;
+ }
return $datatable;
}
@@ -3879,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++) {
@@ -3924,6 +4067,23 @@ sub print_loadbalancing {
$datatable .= ''.$typetitles{$sparetype}.' '.
' ';
}
+ $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').' '.
+ ' '.&mt('No').' ';
+ foreach my $sparetype (@sparestypes) {
+ $datatable .= ''.$typetitles{$sparetype}.
+ ' ';
}
$datatable .= ''.
&loadbalancing_rules($dom,$intdom,$currrules{$lonhost},
@@ -6189,7 +6349,7 @@ sub modify_login {
if ($domservers{$lonhost}) {
if (ref($domconfig{'login'}{'headtag'}{$lonhost}) eq 'HASH') {
$currheadtagurls{$lonhost} = $domconfig{'login'}{'headtag'}{$lonhost}{'url'};
- $currexempt{$lonhost} = $domconfig{'login'}{'headtag'}{$lonhost}{'exempt'}
+ $currexempt{$lonhost} = $domconfig{'login'}{'headtag'}{$lonhost}{'exempt'};
}
}
}
@@ -8296,8 +8456,10 @@ sub modify_directorysrch {
$currdirsrch{$key} = $domconfig{'directorysrch'}{$key};
}
}
- my %title = ( available => 'Directory search available',
- localonly => 'Other domains can search',
+ my %title = ( available => 'Institutional directory search available',
+ localonly => 'Other domains can search institution',
+ lcavailable => 'LON-CAPA directory search available',
+ lclocalonly => 'Other domains can search LON-CAPA domain',
searchby => 'Search types',
searchtypes => 'Search latitude');
my @offon = ('off','on');
@@ -8371,7 +8533,9 @@ sub modify_directorysrch {
my %dirsrch_hash = (
directorysrch => { available => $env{'form.dirsrch_available'},
cansearch => \@cansearch,
- localonly => $env{'form.dirsrch_localonly'},
+ localonly => $env{'form.dirsrch_instlocalonly'},
+ lclocalonly => $env{'form.dirsrch_domlocalonly'},
+ lcavailable => $env{'form.dirsrch_domavailable'},
searchby => \@searchby,
searchtypes => \@searchtypes,
}
@@ -8388,24 +8552,47 @@ sub modify_directorysrch {
$changes{'available'} = 1;
}
}
- if (exists($currdirsrch{'localonly'})) {
- if ($currdirsrch{'localonly'} ne $env{'form.dirsrch_localonly'}) {
- $changes{'localonly'} = 1;
+ if (exists($currdirsrch{'lcavailable'})) {
+ if ($currdirsrch{'lcavailable'} ne $env{'form.dirsrch_domavailable'}) {
+ $changes{'lcavailable'} = 1;
}
} else {
- if ($env{'form.dirsrch_localonly'} eq '1') {
+ if ($env{'form.dirsrch_lcavailable'} eq '1') {
+ $changes{'lcavailable'} = 1;
+ }
+ }
+ if (exists($currdirsrch{'localonly'})) {
+ if ($currdirsrch{'localonly'} ne $env{'form.dirsrch_instlocalonly'}) {
+ $changes{'localonly'} = 1;
+ }
+ } else {
+ if ($env{'form.dirsrch_instlocalonly'} eq '1') {
$changes{'localonly'} = 1;
}
}
+ if (exists($currdirsrch{'lclocalonly'})) {
+ if ($currdirsrch{'lclocalonly'} ne $env{'form.dirsrch_domlocalonly'}) {
+ $changes{'lclocalonly'} = 1;
+ }
+ } else {
+ if ($env{'form.dirsrch_domlocalonly'} eq '1') {
+ $changes{'lclocalonly'} = 1;
+ }
+ }
if (keys(%changes) > 0) {
$resulttext = &mt('Changes made:').'';
if ($changes{'available'}) {
$resulttext .= ''.&mt("$title{'available'} set to: $offon[$env{'form.dirsrch_available'}]").' ';
}
+ if ($changes{'lcavailable'}) {
+ $resulttext .= ''.&mt("$title{'lcavailable'} set to: $offon[$env{'form.dirsrch_domavailable'}]").' ';
+ }
if ($changes{'localonly'}) {
- $resulttext .= ''.&mt("$title{'localonly'} set to: $otherdoms[$env{'form.dirsrch_localonly'}]").' ';
+ $resulttext .= ''.&mt("$title{'localonly'} set to: $otherdoms[$env{'form.dirsrch_instlocalonly'}]").' ';
+ }
+ if ($changes{'lclocalonly'}) {
+ $resulttext .= ''.&mt("$title{'lclocalonly'} set to: $otherdoms[$env{'form.dirsrch_domlocalonly'}]").' ';
}
-
if (ref($changes{'cansearch'}) eq 'ARRAY') {
my $chgtext;
if (ref($usertypes) eq 'HASH') {
@@ -8456,7 +8643,7 @@ sub modify_directorysrch {
}
$resulttext .= ' ';
} else {
- $resulttext = &mt('No changes made to institution directory search settings');
+ $resulttext = &mt('No changes made to directory search settings');
}
} else {
$resulttext = ''.
@@ -10365,30 +10552,78 @@ sub modify_helpsettings {
my %defaultchecked = ('submitbugs' => 'on');
my @offon = ('off','on');
my @toggles = ('submitbugs');
+ my %current = ('submitbugs' => '');
if (ref($domconfig{'helpsettings'}) eq 'HASH') {
- foreach my $item (@toggles) {
- if ($defaultchecked{$item} eq 'on') {
- if ($domconfig{'helpsettings'}{$item} eq '') {
- if ($env{'form.'.$item} eq '0') {
- $changes{$item} = 1;
- }
- } elsif ($domconfig{'helpsettings'}{$item} ne $env{'form.'.$item}) {
+ %current = %{$domconfig{'helpsettings'}};
+ }
+ foreach my $item (@toggles) {
+ if ($defaultchecked{$item} eq 'on') {
+ if ($current{$item} eq '') {
+ if ($env{'form.'.$item} eq '0') {
$changes{$item} = 1;
}
- } elsif ($defaultchecked{$item} eq 'off') {
- if ($domconfig{'helpsettings'}{$item} eq '') {
- if ($env{'form.'.$item} eq '1') {
- $changes{$item} = 1;
- }
- } elsif ($domconfig{'helpsettings'}{$item} ne $env{'form.'.$item}) {
+ } elsif ($current{$item} ne $env{'form.'.$item}) {
+ $changes{$item} = 1;
+ }
+ } elsif ($defaultchecked{$item} eq 'off') {
+ if ($current{$item} eq '') {
+ if ($env{'form.'.$item} eq '1') {
$changes{$item} = 1;
}
+ } elsif ($current{$item} ne $env{'form.'.$item}) {
+ $changes{$item} = 1;
}
- if (($env{'form.'.$item} eq '0') || ($env{'form.'.$item} eq '1')) {
- $helphash{'helpsettings'}{$item} = $env{'form.'.$item};
+ }
+ if (($env{'form.'.$item} eq '0') || ($env{'form.'.$item} eq '1')) {
+ $helphash{'helpsettings'}{$item} = $env{'form.'.$item};
+ }
+ }
+
+ my @modify = &Apache::loncommon::get_env_multiple('form.modifycusthelp');
+ my $confname = $dom.'-domainconfig';
+ my %existing=&Apache::lonnet::dump('roles',$dom,$confname,'rolesdef_');
+ if (@modify) {
+ foreach my $num (@modify) {
+ my $rolename = $env{'form.custhelprole'.$num};
+ if ($rolename ne '') {
+ if (exists($existing{'rolesdef_'.$rolename})) {
+ my $prefix = 'custhelp'.$num;
+ my %newprivs = &Apache::lonuserutils::custom_role_update($rolename,$prefix);
+ my %currprivs;
+ ($currprivs{'s'},$currprivs{'d'},$currprivs{'c'}) =
+ split(/\_/,$existing{'rolesdef_'.$rolename});
+ foreach my $level ('c','d','s') {
+ if ($newprivs{$level} ne $currprivs{$level}) {
+ $changes{'customrole'}{$rolename} = 1;
+ my $result = &Apache::lonnet::definerole($rolename,$newprivs{'s'},$newprivs{'d'},
+ $newprivs{'c'},$confname,$dom);
+ last;
+ }
+ }
+ }
}
}
}
+ if ($env{'form.newcusthelp'} ne '') {
+ my $prefix = 'custhelp'.$env{'form.newcusthelp'};
+ my $rolename = $env{'form.newcusthelpname'};
+ $rolename=~s/[^A-Za-z0-9]//gs;
+ if ($rolename ne '') {
+ unless(exists($existing{'rolesdef_'.$rolename})) {
+ 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 {
+ $errors .= ''.
+ &mt('An error occurred storing the new custom role: [_1]',
+ $result).' ';
+ }
+ }
+ }
+ }
+
my $putresult;
if (keys(%changes) > 0) {
$putresult = &Apache::lonnet::put_dom('configuration',\%helphash,$dom);
@@ -10399,6 +10634,16 @@ sub modify_helpsettings {
$resulttext .= ''.&mt('Display link to: [_1] set to "'.$offon[$env{'form.'.$item}].'".',
&Apache::loncommon::modal_link('http://bugs.loncapa.org',
&mt('LON-CAPA bug tracker'),600,500)).' ';
+ } elsif ($item eq 'customrole') {
+ if (ref($changes{'customrole'}) eq 'HASH') {
+ foreach my $role (sort(keys(%{$changes{'customrole'}}))) {
+ $resulttext .= ''.&mt('Existing custom role modified: [_1]',
+ $role).' ';
+ }
+ }
+ } elsif ($item eq 'newcustomrole') {
+ $resulttext .= ''.&mt('New custom role added: [_1]',
+ $changes{'newcustomrole'}).' ';
}
}
$resulttext .= '';
@@ -11407,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) {