--- loncom/interface/domainprefs.pm 2010/01/02 22:02:44 1.102.2.7
+++ loncom/interface/domainprefs.pm 2009/11/16 04:03:05 1.119
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Handler to set domain-wide configuration settings
#
-# $Id: domainprefs.pm,v 1.102.2.7 2010/01/02 22:02:44 raeburn Exp $
+# $Id: domainprefs.pm,v 1.119 2009/11/16 04:03:05 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -202,12 +202,11 @@ sub handler {
'quotas','autoenroll','autoupdate','directorysrch',
'usercreation','usermodification','contacts','defaults',
'scantron','coursecategories','serverstatuses',
- 'requestcourses','coursedefaults'],$dom);
+ 'requestcourses','helpsettings'],$dom);
my @prefs_order = ('rolecolors','login','defaults','quotas','autoenroll',
'autoupdate','directorysrch','contacts',
'usercreation','usermodification','scantron',
- 'requestcourses','coursecategories','serverstatuses',
- 'coursedefaults');
+ 'requestcourses','coursecategories','serverstatuses','helpsettings');
my %prefs = (
'rolecolors' =>
{ text => 'Default color schemes',
@@ -221,12 +220,13 @@ sub handler {
{col1 => 'Administrator Settings',
col2 => '',}],
},
- 'login' =>
+ 'login' =>
{ text => 'Log-in page options',
help => 'Domain_Configuration_Login_Page',
header => [{col1 => 'Item',
col2 => '',}],
},
+
'defaults' =>
{ text => 'Default authentication/language/timezone',
help => 'Domain_Configuration_LangTZAuth',
@@ -303,7 +303,7 @@ sub handler {
col2 => 'Value'}],
},
'coursecategories' =>
- { text => 'Cataloging of courses/communities',
+ { text => 'Cataloging of courses',
help => 'Domain_Configuration_Cataloging_Courses',
header => [{col1 => 'Category settings',
col2 => '',},
@@ -319,13 +319,23 @@ sub handler {
col3 => 'Specific IPs',
}],
},
- 'coursedefaults' =>
- {text => 'Course/Community defaults',
- help => 'Domain_Configuration_Course_Defaults',
+ 'helpsettings' =>
+ {text => 'Help page settings',
+ help => 'Domain_Configuration_Help_Settings',
header => [{col1 => 'Setting',
col2 => 'Value',}],
},
);
+ my %servers = &dom_servers($dom);
+ if (keys(%servers) > 1) {
+ $prefs{'login'} = { text => 'Log-in page options',
+ help => 'Domain_Configuration_Login_Page',
+ header => [{col1 => 'Log-in Service',
+ col2 => 'Server Setting',},
+ {col1 => 'Log-in Page Items',
+ col2 => ''}],
+ };
+ }
my @roles = ('student','coordinator','author','admin');
my @actions = &Apache::loncommon::get_env_multiple('form.actions');
&Apache::lonhtmlcommon::add_breadcrumb
@@ -411,8 +421,8 @@ sub process_changes {
$output = &modify_serverstatuses($dom,%domconfig);
} elsif ($action eq 'requestcourses') {
$output = &modify_quotas($dom,$action,%domconfig);
- } elsif ($action eq 'coursedefaults') {
- $output = &modify_coursedefaults($dom,%domconfig);
+ } elsif ($action eq 'helpsettings') {
+ $output = &modify_helpsettings($dom,%domconfig);
}
return $output;
}
@@ -432,9 +442,11 @@ sub print_config_box {
&Apache::loncommon::help_open_topic($item->{'help'}).''."\n".
'';
$rowtotal ++;
- if (($action eq 'autoupdate') || ($action eq 'rolecolors') ||
- ($action eq 'usercreation') || ($action eq 'usermodification') ||
- ($action eq 'coursecategories') || ($action eq 'requestcourses')) {
+ my $numheaders = 1;
+ if (ref($item->{'header'}) eq 'ARRAY') {
+ $numheaders = scalar(@{$item->{'header'}});
+ }
+ if ($numheaders > 1) {
my $colspan = '';
if (($action eq 'rolecolors') || ($action eq 'coursecategories')) {
$colspan = ' colspan="2"';
@@ -456,8 +468,13 @@ sub print_config_box {
$output .= &print_usermodification('top',$dom,$settings,\$rowtotal);
} elsif ($action eq 'coursecategories') {
$output .= &print_coursecategories('top',$dom,$item,$settings,\$rowtotal);
+ } elsif ($action eq 'login') {
+ $output .= &print_login('top',$dom,$confname,$phase,$settings,\$rowtotal);
+ $colspan = ' colspan="2"';
} elsif ($action eq 'requestcourses') {
$output .= &print_quotas($dom,$settings,\$rowtotal,$action);
+ } elsif ($action eq 'helpsettings') {
+ $output .= &print_helpsettings($dom,$settings,\$rowtotal);
} else {
$output .= &print_rolecolors($phase,'student',$dom,$confname,$settings,\$rowtotal);
}
@@ -505,6 +522,8 @@ sub print_config_box {
$rowtotal ++;
} elsif ($action eq 'coursecategories') {
$output .= &print_coursecategories('bottom',$dom,$item,$settings,\$rowtotal);
+ } elsif ($action eq 'login') {
+ $output .= &print_login('bottom',$dom,$confname,$phase,$settings,\$rowtotal);
} elsif ($action eq 'requestcourses') {
$output .= &print_courserequestmail($dom,$settings,\$rowtotal);
} else {
@@ -575,7 +594,8 @@ sub print_config_box {
$output .= '';
$rowtotal ++;
if ($action eq 'login') {
- $output .= &print_login($dom,$confname,$phase,$settings,\$rowtotal);
+ $output .= &print_login('bottom',$dom,$confname,$phase,$settings,
+ \$rowtotal);
} elsif ($action eq 'quotas') {
$output .= &print_quotas($dom,$settings,\$rowtotal,$action);
} elsif ($action eq 'autoenroll') {
@@ -590,9 +610,9 @@ sub print_config_box {
$output .= &print_scantronformat($r,$dom,$confname,$settings,\$rowtotal);
} elsif ($action eq 'serverstatuses') {
$output .= &print_serverstatuses($dom,$settings,\$rowtotal);
- } elsif ($action eq 'coursedefaults') {
- $output .= &print_coursedefaults($dom,$settings,\$rowtotal);
- }
+ } elsif ($action eq 'helpsettings') {
+ $output .= &print_helpsettings($dom,$settings,\$rowtotal);
+ }
}
$output .= '
@@ -603,8 +623,48 @@ sub print_config_box {
}
sub print_login {
- my ($dom,$confname,$phase,$settings,$rowtotal) = @_;
+ my ($position,$dom,$confname,$phase,$settings,$rowtotal) = @_;
+ my ($css_class,$datatable);
my %choices = &login_choices();
+ my $itemcount = 1;
+
+ if ($position eq 'top') {
+ my %servers = &dom_servers($dom);
+ my $choice = $choices{'disallowlogin'};
+ $css_class = ' class="LC_odd_row"';
+ $datatable .= '
'.$choices{'disallowlogin'}.' | '.
+ ''.$choices{'hostid'}.' | '.
+ ''.$choices{'serverurl'}.' | '."\n";
+ my %disallowed;
+ if (ref($settings) eq 'HASH') {
+ if (ref($settings->{'loginvia'}) eq 'HASH') {
+ %disallowed = %{$settings->{'loginvia'}};
+ }
+ }
+ foreach my $lonhost (sort(keys(%servers))) {
+ my $direct = 'selected="selected"';
+ if ($disallowed{$lonhost} eq '') {
+ $direct = '';
+ }
+ $datatable .= ''.$servers{$lonhost}.' | '.
+ ' | ';
+ }
+ $datatable .= '
|
';
+ return $datatable;
+ }
+
my %defaultchecked = (
'coursecatalog' => 'on',
'adminmail' => 'off',
@@ -740,23 +800,27 @@ sub login_choices {
my %choices =
&Apache::lonlocal::texthash (
coursecatalog => 'Display Course/Community Catalog link?',
- adminmail => "Display Administrator's E-mail Address?",
- newuser => "Link to create a user account",
- img => "Header",
- logo => "Main Logo",
- domlogo => "Domain Logo",
- login => "Log-in Header",
- textcol => "Text color",
- bgcol => "Box color",
- bgs => "Background colors",
- links => "Link colors",
- font => "Font color",
- pgbg => "Header",
- mainbg => "Page",
- sidebg => "Login box",
- link => "Link",
- alink => "Active link",
- vlink => "Visited link",
+ adminmail => "Display Administrator's E-mail Address?",
+ disallowlogin => "Login page requests redirected",
+ hostid => "Server",
+ serverurl => "Redirect to log-in via:",
+ directlogin => "No redirect",
+ newuser => "Link to create a user account",
+ img => "Header",
+ logo => "Main Logo",
+ domlogo => "Domain Logo",
+ login => "Log-in Header",
+ textcol => "Text color",
+ bgcol => "Box color",
+ bgs => "Background colors",
+ links => "Link colors",
+ font => "Font color",
+ pgbg => "Header",
+ mainbg => "Page",
+ sidebg => "Login box",
+ link => "Link",
+ alink => "Active link",
+ vlink => "Visited link",
);
return %choices;
}
@@ -774,6 +838,7 @@ sub print_rolecolors {
my %defaults = (
img => $defaultdesign{$role.'.img'},
font => $defaultdesign{$role.'.font'},
+ fontmenu => $defaultdesign{$role.'.fontmenu'},
);
foreach my $item (@bgs) {
$defaults{'bgs'}{$item} = $defaultdesign{$role.'.'.$item};
@@ -791,6 +856,10 @@ sub print_rolecolors {
$designs{'font'} = $settings->{$role}->{'font'};
$is_custom{'font'} = 1;
}
+ if ($settings->{$role}->{'fontmenu'} ne '') {
+ $designs{'fontmenu'} = $settings->{$role}->{'fontmenu'};
+ $is_custom{'fontmenu'} = 1;
+ }
foreach my $item (@bgs) {
if ($settings->{$role}->{$item} ne '') {
$designs{'bgs'}{$item} = $settings->{$role}->{$item};
@@ -809,6 +878,10 @@ sub print_rolecolors {
$designs{img} = $designhash{$dom.'.'.$role.'.img'};
$is_custom{'img'} = 1;
}
+ if ($designhash{$dom.'.'.$role.'.fontmenu'} ne '') {
+ $designs{fontmenu} = $designhash{$dom.'.'.$role.'.fontmenu'};
+ $is_custom{'fontmenu'} = 1;
+ }
if ($designhash{$dom.'.'.$role.'.font'} ne '') {
$designs{font} = $designhash{$dom.'.'.$role.'.font'};
$is_custom{'font'} = 1;
@@ -837,7 +910,7 @@ sub display_color_options {
my ($dom,$confname,$phase,$role,$itemcount,$choices,$is_custom,$defaults,$designs,
$images,$bgs,$links,$alt_text,$rowtotal,$logintext,$loginheader) = @_;
my $css_class = $itemcount%2?' class="LC_odd_row"':'';
- my $datatable = ''.
+ my $datatable = '
'.
''.$choices->{'font'}.' | ';
if (!$is_custom->{'font'}) {
$datatable .= ''.&mt('Default in use:').' '.$defaults->{'font'}.' | ';
@@ -851,6 +924,22 @@ sub display_color_options {
' '.
'
';
+ unless ($role eq 'login') {
+ $datatable .= ''.
+ ''.$choices->{'fontmenu'}.' | ';
+ if (!$is_custom->{'fontmenu'}) {
+ $datatable .= ''.&mt('Default in use:').' '.$defaults->{'fontmenu'}.' | ';
+ } else {
+ $datatable .= ' | ';
+ }
+ $fontlink = &color_pick($phase,$role,'fontmenu',$choices->{'fontmenu'},$designs->{'fontmenu'});
+ $datatable .= ''.
+ ' '.$fontlink.
+ ' '.
+ ' |
';
+ }
my $switchserver = &check_switchserver($dom,$confname);
foreach my $img (@{$images}) {
$itemcount ++;
@@ -1137,7 +1226,7 @@ sub print_quotas {
my ($css_class,%titles);
if ($context eq 'requestcourses') {
@usertools = ('official','unofficial','community');
- @options =('norequest','approval','autolimit','validate');
+ @options =('norequest','approval','validate','autolimit');
%validations = &Apache::lonnet::auto_courserequest_checks($dom);
%titles = &courserequest_titles();
} else {
@@ -1212,10 +1301,10 @@ sub print_quotas {
$item.'_limit_'.$type.'" size="1" '.
'value="'.$currlimit.'" />';
}
+ $cell{$item} .= ' ';
if ($option eq 'autolimit') {
- $cell{$item} .= $titles{'unlimited'};
+ $cell{$item} .= $titles{'unlimited'}
}
- $cell{$item} .= ' ';
}
} else {
my $checked = 'checked="checked" ';
@@ -1237,7 +1326,7 @@ sub print_quotas {
if ($context eq 'requestcourses') {
$datatable .= '';
foreach my $item (@usertools) {
- $datatable .= ''.$cell{$item}.' | ';
+ $datatable .= ''.$cell{$item}.' | ';
}
$datatable .= '
';
}
@@ -1320,7 +1409,7 @@ sub print_quotas {
}
$defcell{$item} .= ' ';
if ($option eq 'autolimit') {
- $defcell{$item} .= $titles{'unlimited'};
+ $defcell{$item} .= $titles{'unlimited'}
}
}
} else {
@@ -1343,7 +1432,7 @@ sub print_quotas {
if ($context eq 'requestcourses') {
$datatable .= '';
foreach my $item (@usertools) {
- $datatable .= ''.$defcell{$item}.' | ';
+ $datatable .= ''.$defcell{$item}.' | ';
}
$datatable .= '
';
}
@@ -1423,7 +1512,7 @@ sub print_quotas {
}
$advcell{$item} .= ' ';
if ($option eq 'autolimit') {
- $advcell{$item} .= $titles{'unlimited'};
+ $advcell{$item} .= $titles{'unlimited'}
}
}
} else {
@@ -1446,7 +1535,7 @@ sub print_quotas {
if ($context eq 'requestcourses') {
$datatable .= '';
foreach my $item (@usertools) {
- $datatable .= ''.$advcell{$item}.' | ';
+ $datatable .= ''.$advcell{$item}.' | ';
}
$datatable .= '
';
}
@@ -1839,24 +1928,34 @@ sub print_contacts {
return $datatable;
}
-sub radiobutton_prefs {
- my ($settings,$toggles,$defaultchecked,$choices,$itemcount) = @_;
- return unless ((ref($toggles) eq 'ARRAY') && (ref($defaultchecked) eq 'HASH') &&
- (ref($choices) eq 'HASH'));
-
- my (%checkedon,%checkedoff,$datatable,$css_class);
+sub print_helpsettings {
- foreach my $item (@{$toggles}) {
- if ($defaultchecked->{$item} eq 'on') {
+ my ($dom,$settings,$rowtotal) = @_;
+ my ($css_class,$datatable);
+ my $itemcount = 1;
+ my (%checkedon,%checkedoff,%choices,%defaultchecked,@toggles);
+
+ %choices =
+ &Apache::lonlocal::texthash (
+ submitbugs => 'Display "Submit a bug" link?',
+ );
+
+ %defaultchecked = ('submitbugs' => 'on');
+
+ @toggles = ('submitbugs',);
+
+ foreach my $item (@toggles) {
+ if ($defaultchecked{$item} eq 'on') {
$checkedon{$item} = ' checked="checked" ';
$checkedoff{$item} = ' ';
- } elsif ($defaultchecked->{$item} eq 'off') {
+ } elsif ($defaultchecked{$item} eq 'off') {
$checkedoff{$item} = ' checked="checked" ';
$checkedon{$item} = ' ';
}
}
+
if (ref($settings) eq 'HASH') {
- foreach my $item (@{$toggles}) {
+ foreach my $item (@toggles) {
if ($settings->{$item} eq '1') {
$checkedon{$item} = ' checked="checked" ';
$checkedoff{$item} = ' ';
@@ -1865,11 +1964,12 @@ sub radiobutton_prefs {
$checkedon{$item} = ' ';
}
}
- }
- foreach my $item (@{$toggles}) {
+ }
+
+ foreach my $item (@toggles) {
$css_class = $itemcount%2?' class="LC_odd_row"':'';
- $datatable .=
- ''.$choices->{$item}.
+ $datatable .=
+ ''.$choices{$item}.
' | '.
''.
' | ';
- if ($parent eq 'instcode' || $parent eq 'communities') {
- $datatable .= ''.
- .$default_names{$parent}.'';
- if ($parent eq 'instcode') {
- $datatable .= ' ('
- .&mt('with institutional codes')
- .') | ';
- } else {
- $datatable .= '';
- }
- $datatable .= ' | ';
+ if ($parent eq 'instcode') {
+ $datatable .= ''.&mt('Official courses')
+ .' ('
+ .&mt('with institutional codes').')'
+ .''
+ .&mt('Display').' '
+ .''
+ .&mt('Do not display').' | ';
} else {
$datatable .= $parent
.' '
.' '."\n";
$itemcount ++;
- foreach my $default ('instcode','communities') {
- if ((!grep(/^\Q$default\E$/,@{$cats[0]})) || ($cathash->{$default.'::0'} eq '')) {
- $css_class = $itemcount%2?' class="LC_odd_row"':'';
- my $chgstr = ' onchange="javascript:reorderCats(this.form,'."'','$default"."_pos','$lastidx'".');"';
- $datatable .= ' | '.
- ' | '
+ .&mt('Official courses').''.' ('
+ .&mt('with institutional codes').') | '
+ .''
+ .&mt('Display').' '
+ .''
+ .&mt('Do not display').' | ';
}
}
} else {
@@ -2794,9 +2814,6 @@ sub coursecategories_javascript {
$jstext = ' var categories = Array(1);'."\n".
' categories[0] = Array("instcode_pos");'."\n";
}
- my $instcode_reserved = &mt('The name: "instcode" is a reserved category');
- my $communities_reserved = &mt('The name: "communities" is a reserved category');
- my $choose_again = '\\n'.&mt('Please use a different name for the new top level category');
$output = <<"ENDSCRIPT";
@@ -2878,40 +2882,25 @@ ENDSCRIPT
sub initialize_categories {
my ($itemcount) = @_;
- my ($datatable,$css_class,$chgstr);
- my %default_names = (
- instcode => 'Official courses (with institutional codes)',
- communities => 'Communities',
- );
- my $select0 = ' selected="selected"';
- my $select1 = '';
- foreach my $default ('instcode','communities') {
- $css_class = $itemcount%2?' class="LC_odd_row"':'';
- $chgstr = ' onchange="javascript:reorderCats(this.form,'."'',$default"."_pos','0'".');"';
- if ($default eq 'communities') {
- $select1 = $select0;
- $select0 = '';
- }
- $datatable .= ''
- .''
- .''
- .''
- .' '
- .$default_names{$default}
- .' | '
- .''
- .&mt('Display').' '
- .''.&mt('Do not display')
+ my $datatable;
+ my $css_class = $itemcount%2?' class="LC_odd_row"':'';
+ my $chgstr = ' onchange="javascript:reorderCats(this.form,'."'','instcode_pos','0'".');"';
+
+ $datatable = ''
+ .''
+ .' '
+ .&mt('Official courses (with institutional codes)')
+ .' | '
+ .''
+ .&mt('Display').' '
+ .''.&mt('Do not display')
.' | ';
- $itemcount ++;
- }
+ $itemcount ++;
$css_class = $itemcount%2?' class="LC_odd_row"':'';
$chgstr = ' onchange="javascript:reorderCats(this.form,'."'','addcategory_pos','0'".');"';
$datatable .= ''
- .''
- .''
- .''
- .' '
+ .''
+ .' '
.&mt('Add category').' | '.&mt('Name:')
.' | ';
return $datatable;
@@ -3218,6 +3207,14 @@ sub modify_login {
newuser => 'Link for visitors to create a user account',
loginheader => 'Log-in box header');
my @offon = ('off','on');
+ my %curr_loginvia;
+ if (ref($domconfig{login}) eq 'HASH') {
+ if (ref($domconfig{login}{loginvia}) eq 'HASH') {
+ foreach my $lonhost (keys(%{$domconfig{login}{loginvia}})) {
+ $curr_loginvia{$lonhost} = $domconfig{login}{loginvia}{$lonhost};
+ }
+ }
+ }
my %loginhash;
($errors,%colchanges) = &modify_colors($r,$dom,$confname,['login'],
\%domconfig,\%loginhash);
@@ -3230,6 +3227,26 @@ sub modify_login {
$colchgtext = &display_colorchgs($dom,\%colchanges,['login'],
\%loginhash);
}
+
+ my %servers = &dom_servers($dom);
+ if (keys(%servers) > 1) {
+ foreach my $lonhost (keys(%servers)) {
+ next if ($env{'form.'.$lonhost.'_serverurl'} eq $lonhost);
+ if ($env{'form.'.$lonhost.'_serverurl'} eq $curr_loginvia{$lonhost}) {
+ $loginhash{login}{loginvia}{$lonhost} = $curr_loginvia{$lonhost}; next;
+ }
+ if ($curr_loginvia{$lonhost} ne '') {
+ $loginhash{login}{loginvia}{$lonhost} = $env{'form.'.$lonhost.'_serverurl'};
+ $changes{'loginvia'}{$lonhost} = 1;
+ } else {
+ if (defined($servers{$env{'form.'.$lonhost.'_serverurl'}})) {
+ $loginhash{login}{loginvia}{$lonhost} = $env{'form.'.$lonhost.'_serverurl'};
+ $changes{'loginvia'}{$lonhost} = 1;
+ }
+ }
+ }
+ }
+
my $putresult = &Apache::lonnet::put_dom('configuration',\%loginhash,
$dom);
if ($putresult eq 'ok') {
@@ -3276,6 +3293,18 @@ sub modify_login {
foreach my $item (sort(keys(%changes))) {
if ($item eq 'loginheader') {
$resulttext .= ''.&mt("$title{$item} set to $env{'form.loginheader'}").'';
+ } elsif ($item eq 'loginvia') {
+ if (ref($changes{$item}) eq 'HASH') {
+ $resulttext .= ''.&mt('Log-in page availability:').'';
+ foreach my $lonhost (sort(keys(%{$changes{$item}}))) {
+ if ($servers{$env{'form.'.$lonhost.'_serverurl'}} ne '') {
+ $resulttext .= '- '.&mt('Server: [_1] log-in page now redirects to [_2]',$lonhost,$servers{$env{'form.'.$lonhost.'_serverurl'}}).'
';
+ } else {
+ $resulttext .= '- '.&mt('Server: [_1] now has standard log-in page.',$lonhost).'
';
+ }
+ }
+ $resulttext .= ' ';
+ }
} else {
$resulttext .= ''.&mt("$title{$item} set to $offon[$env{'form.'.$item}]").'';
}
@@ -3303,6 +3332,7 @@ sub color_font_choices {
links => "Link colors",
images => "Images",
font => "Font color",
+ fontmenu => "Font Menu",
pgbg => "Page",
tabbg => "Header",
sidebg => "Border",
@@ -3360,6 +3390,7 @@ sub modify_colors {
@logintext = ('textcol','bgcol');
} else {
%choices = &color_font_choices();
+ $confhash->{$role}{'fontmenu'} = $env{'form.'.$role.'_fontmenu'};
}
if ($role eq 'login') {
@images = ('img','logo','domlogo','login');
@@ -3482,6 +3513,17 @@ sub modify_colors {
$changes{$role}{'font'} = 1;
}
}
+ if ($role ne 'login') {
+ if ($domconfig->{$role}{'fontmenu'} ne '') {
+ if ($confhash->{$role}{'fontmenu'} ne $domconfig->{$role}{'fontmenu'}) {
+ $changes{$role}{'fontmenu'} = 1;
+ }
+ } else {
+ if ($confhash->{$role}{'fontmenu'}) {
+ $changes{$role}{'fontmenu'} = 1;
+ }
+ }
+ }
foreach my $item (@bgs) {
if ($domconfig->{$role}{$item} ne '') {
if ($confhash->{$role}{$item} ne $domconfig->{$role}{$item}) {
@@ -3922,7 +3964,7 @@ sub modify_quotas {
}
if ($context eq 'requestcourses') {
@usertools = ('official','unofficial','community');
- @options =('norequest','approval','autolimit','validate');
+ @options =('norequest','approval','validate','autolimit');
%validations = &Apache::lonnet::auto_courserequest_checks($dom);
%titles = &courserequest_titles();
$toolregexp = join('|',@usertools);
@@ -3977,7 +4019,7 @@ sub modify_quotas {
}
foreach my $item (@usertools) {
foreach my $type (@{$types},'default','_LC_adv') {
- my $unset;
+ my $unset;
if ($context eq 'requestcourses') {
$unset = '0';
if ($type eq '_LC_adv') {
@@ -5356,33 +5398,18 @@ sub modify_coursecategories {
$changes{'categorize'} = 1;
$domconfig{'coursecategories'}{'categorize'} = $env{'form.categorize'};
}
- if ($domconfig{'coursecategories'}{'togglecatscomm'} ne $env{'form.togglecatscomm'}) {
- $changes{'togglecatscomm'} = 1;
- $domconfig{'coursecategories'}{'togglecatscomm'} = $env{'form.togglecatscomm'};
- }
- if ($domconfig{'coursecategories'}{'categorizecomm'} ne $env{'form.categorizecomm'}) {
- $changes{'categorizecomm'} = 1;
- $domconfig{'coursecategories'}{'categorizecomm'} = $env{'form.categorizecomm'};
- }
} else {
$changes{'togglecats'} = 1;
$changes{'categorize'} = 1;
- $changes{'togglecatscomm'} = 1;
- $changes{'categorizecomm'} = 1;
$domconfig{'coursecategories'} = {
togglecats => $env{'form.togglecats'},
categorize => $env{'form.categorize'},
- togglecatscomm => $env{'form.togglecatscomm'},
- categorizecomm => $env{'form.categorizecomm'},
};
}
if (ref($cathash) eq 'HASH') {
if (($domconfig{'coursecategories'}{'cats'}{'instcode::0'} ne '') && ($env{'form.instcode'} == 0)) {
push (@deletecategory,'instcode::0');
}
- if (($domconfig{'coursecategories'}{'cats'}{'communities::0'} ne '') && ($env{'form.communities'} == 0)) {
- push(@deletecategory,'communities::0');
- }
}
my (@predelcats,@predeltrails,%predelallitems,%sort_by_deltrail);
if (ref($cathash) eq 'HASH') {
@@ -5432,26 +5459,10 @@ sub modify_coursecategories {
$adds{$newitem} = 1;
}
}
- if ($env{'form.communities'} eq '1') {
- if (ref($cathash) eq 'HASH') {
- my $newitem = 'communities::0';
- if ($cathash->{$newitem} eq '') {
- $domconfig{'coursecategories'}{'cats'}{$newitem} = $env{'form.communities_pos'};
- $adds{$newitem} = 1;
- }
- } else {
- my $newitem = 'communities::0';
- $domconfig{'coursecategories'}{'cats'}{$newitem} = $env{'form.communities_pos'};
- $adds{$newitem} = 1;
- }
- }
if ($env{'form.addcategory_name'} ne '') {
- if (($env{'form.addcategory_name'} ne 'instcode') &&
- ($env{'form.addcategory_name'} ne 'communities')) {
- my $newitem = &escape($env{'form.addcategory_name'}).'::0';
- $domconfig{'coursecategories'}{'cats'}{$newitem} = $env{'form.addcategory_pos'};
- $adds{$newitem} = 1;
- }
+ my $newitem = &escape($env{'form.addcategory_name'}).'::0';
+ $domconfig{'coursecategories'}{'cats'}{$newitem} = $env{'form.addcategory_pos'};
+ $adds{$newitem} = 1;
}
my $putresult;
if ((keys(%deletions) > 0) || (keys(%reorderings) > 0) || (keys(%adds) > 0)) {
@@ -5488,15 +5499,12 @@ sub modify_coursecategories {
$putresult = &Apache::lonnet::put_dom('configuration',\%domconfig,$dom);
if ($putresult eq 'ok') {
my %title = (
- togglecats => 'Show/Hide a course in catalog',
- categorize => 'Assign a category to a course',
- togglecatscomm => 'Show/Hide a community in catalog',
- categorizecomm => 'Assign a category to a community',
+ togglecats => 'Show/Hide a course in the catalog',
+ categorize => 'Category assigned to course',
);
my %level = (
- dom => 'set in Domain ("Modify Course/Community")',
- crs => 'set in Course ("Course Configuration")',
- comm => 'set in Community ("Community Configuration")',
+ dom => 'set from "Modify Course" (Domain)',
+ crs => 'set from "Parameters" (Course)',
);
$resulttext = &mt('Changes made:').'';
if ($changes{'togglecats'}) {
@@ -5505,12 +5513,6 @@ sub modify_coursecategories {
if ($changes{'categorize'}) {
$resulttext .= '- '.&mt("$title{'categorize'} $level{$env{'form.categorize'}}").'
';
}
- if ($changes{'togglecatscomm'}) {
- $resulttext .= '- '.&mt("$title{'togglecatscomm'} $level{$env{'form.togglecatscomm'}}").'
';
- }
- if ($changes{'categorizecomm'}) {
- $resulttext .= '- '.&mt("$title{'categorizecomm'} $level{$env{'form.categorizecomm'}}").'
';
- }
if ((keys(%deletions) > 0) || (keys(%reorderings) > 0) || (keys(%adds) > 0)) {
my $cathash;
if (ref($domconfig{'coursecategories'}) eq 'HASH') {
@@ -5560,7 +5562,7 @@ sub modify_coursecategories {
&mt('An error occurred: [_1]',$putresult).' ';
}
} else {
- $resulttext = &mt('No changes made to course and community categories');
+ $resulttext = &mt('No changes made to course categories');
}
return $resulttext;
}
@@ -5690,68 +5692,68 @@ sub modify_serverstatuses {
return $resulttext;
}
-sub modify_coursedefaults {
+sub modify_helpsettings {
my ($dom,%domconfig) = @_;
- my ($resulttext,$errors,%changes,%defaultshash);
- my %defaultchecked = ('canuse_pdfforms' => 'off');
- my @offon = ('off','on');
- my @toggles = ('canuse_pdfforms');
-
- $defaultshash{'coursedefaults'} = {};
-
- if (ref($domconfig{'coursedefaults'}) ne 'HASH') {
- if ($domconfig{'coursedefaults'} eq '') {
- $domconfig{'coursedefaults'} = {};
- }
- }
-
- if (ref($domconfig{'coursedefaults'}) eq 'HASH') {
+ my ($resulttext,$errors,%changes,%helphash);
+
+ my %defaultchecked = ('submitbugs' => 'on');
+ my @offon = ('off','on');
+ my %title = ( submitbugs => 'Display link for users to submit a bug');
+ my @toggles = ('submitbugs');
+
+ $helphash{'helpsettings'} = {};
+
+ if (ref($domconfig{'helpsettings'}) ne 'HASH') {
+ if ($domconfig{'helpsettings'} eq '') {
+ $domconfig{'helpsettings'} = {};
+ }
+ }
+
+ if (ref($domconfig{'helpsettings'}) eq 'HASH') {
+
foreach my $item (@toggles) {
- if ($defaultchecked{$item} eq 'on') {
- if (($domconfig{'coursedefaults'}{$item} eq '') &&
- ($env{'form.'.$item} eq '0')) {
- $changes{$item} = 1;
- } elsif ($domconfig{'coursdefaults'}{$item} ne $env{'form.'.$item}) {
- $changes{$item} = 1;
- }
- } elsif ($defaultchecked{$item} eq 'off') {
- if (($domconfig{'coursedefaults'}{$item} eq '') &&
- ($env{'form.'.$item} eq '1')) {
- $changes{$item} = 1;
- } elsif ($domconfig{'coursedefaults'}{$item} ne $env{'form.'.$item}) {
- $changes{$item} = 1;
- }
- }
- $defaultshash{'coursedefaults'}{$item} = $env{'form.'.$item};
- }
+
+ if ($defaultchecked{$item} eq 'on') {
+ if (($domconfig{'helpsettings'}{$item} eq '') &&
+ ($env{'form.'.$item} eq '0')) {
+ $changes{$item} = 1;
+ } elsif ($domconfig{'helpsettings'}{$item} ne $env{'form.'.$item}) {
+ $changes{$item} = 1;
+ }
+ } elsif ($defaultchecked{$item} eq 'off') {
+ if (($domconfig{'helpsettings'}{$item} eq '') &&
+ ($env{'form.'.$item} eq '1')) {
+ $changes{$item} = 1;
+ } elsif ($domconfig{'helpsettings'}{$item} ne $env{'form.'.$item}) {
+ $changes{$item} = 1;
+ }
+ }
+ $helphash{'helpsettings'}{$item} = $env{'form.'.$item};
+ }
}
- my $putresult = &Apache::lonnet::put_dom('configuration',\%defaultshash,
+
+ my $putresult = &Apache::lonnet::put_dom('configuration',\%helphash,
$dom);
+
if ($putresult eq 'ok') {
if (keys(%changes) > 0) {
- if ($changes{'canuse_pdfforms'}) {
- my %domdefaults = &Apache::lonnet::get_domain_defaults($dom);
- $domdefaults{'canuse_pdfforms'}=$defaultshash{'coursedefaults'}{'canuse_pdfforms'};
- my $cachetime = 24*60*60;
- &Apache::lonnet::do_cache_new('domdefaults',$dom,\%domdefaults,$cachetime);
- }
- $resulttext = &mt('Changes made:').'';
- foreach my $item (sort(keys(%changes))) {
- if ($item eq 'canuse_pdfforms') {
- if ($env{'form.'.$item} eq '1') {
- $resulttext .= '- '.&mt("Course/Community users can create/upload PDF forms set to 'on'").'
';
- } else {
- $resulttext .= '- '.&mt('Course/Community users can create/upload PDF forms set to "off"').'
';
- }
- }
- }
- $resulttext .= ' ';
- } else {
- $resulttext = &mt('No changes made to course defaults');
- }
+ $resulttext = &mt('Changes made:').'';
+ foreach my $item (sort(keys(%changes))) {
+ if ($item eq 'submitbugs') {
+ $resulttext .= '- '.&mt("$title{$item} set to $offon[$env{'form.'.$item}]").'
';
+ }
+ }
+ $resulttext .= ' ';
+ } else {
+ $resulttext = &mt('No changes made to help settings');
+ }
} else {
$resulttext = ''.
- &mt('An error occurred: [_1]',$putresult).'';
+ &mt('An error occurred: [_1]',$putresult).'';
+ }
+ if ($errors) {
+ $resulttext .= &mt('The following errors occurred: ').'';
}
return $resulttext;
}
@@ -5796,4 +5798,37 @@ sub recurse_cat_deletes {
return;
}
+sub dom_servers {
+ my ($dom) = @_;
+ my (%uniqservers,%servers);
+ my $primaryserver = &Apache::lonnet::hostname(&Apache::lonnet::domain($dom,'primary'));
+ my @machinedoms = &Apache::lonnet::machine_domains($primaryserver);
+ foreach my $mdom (@machinedoms) {
+ my %currservers = %servers;
+ my %server = &Apache::lonnet::get_servers($mdom);
+ %servers = (%currservers,%server);
+ }
+ my %by_hostname;
+ foreach my $id (keys(%servers)) {
+ push(@{$by_hostname{$servers{$id}}},$id);
+ }
+ foreach my $hostname (sort(keys(%by_hostname))) {
+ if (@{$by_hostname{$hostname}} > 1) {
+ my $match = 0;
+ foreach my $id (@{$by_hostname{$hostname}}) {
+ if (&Apache::lonnet::host_domain($id) eq $dom) {
+ $uniqservers{$id} = $hostname;
+ $match = 1;
+ }
+ }
+ unless ($match) {
+ $uniqservers{$by_hostname{$hostname}[0]} = $hostname;
+ }
+ } else {
+ $uniqservers{$by_hostname{$hostname}[0]} = $hostname;
+ }
+ }
+ return %uniqservers;
+}
+
1;
| |