--- loncom/interface/domainprefs.pm 2009/11/10 19:12:11 1.118
+++ loncom/interface/domainprefs.pm 2010/12/08 04:22:16 1.123.2.5
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Handler to set domain-wide configuration settings
#
-# $Id: domainprefs.pm,v 1.118 2009/11/10 19:12:11 jms Exp $
+# $Id: domainprefs.pm,v 1.123.2.5 2010/12/08 04:22:16 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -202,11 +202,12 @@ sub handler {
'quotas','autoenroll','autoupdate','directorysrch',
'usercreation','usermodification','contacts','defaults',
'scantron','coursecategories','serverstatuses',
- 'requestcourses','helpsettings'],$dom);
+ 'requestcourses','helpsettings','coursedefaults'],$dom);
my @prefs_order = ('rolecolors','login','defaults','quotas','autoenroll',
'autoupdate','directorysrch','contacts',
'usercreation','usermodification','scantron',
- 'requestcourses','coursecategories','serverstatuses','helpsettings');
+ 'requestcourses','coursecategories','serverstatuses','helpsettings',
+ 'coursedefaults');
my %prefs = (
'rolecolors' =>
{ text => 'Default color schemes',
@@ -228,7 +229,7 @@ sub handler {
},
'defaults' =>
- { text => 'Default authentication/language/timezone',
+ { text => 'Default authentication/language/timezone/portal',
help => 'Domain_Configuration_LangTZAuth',
header => [{col1 => 'Setting',
col2 => 'Value'}],
@@ -303,7 +304,7 @@ sub handler {
col2 => 'Value'}],
},
'coursecategories' =>
- { text => 'Cataloging of courses',
+ { text => 'Cataloging of courses/communities',
help => 'Domain_Configuration_Cataloging_Courses',
header => [{col1 => 'Category settings',
col2 => '',},
@@ -322,6 +323,20 @@ sub handler {
'helpsettings' =>
{text => 'Help page settings',
help => 'Domain_Configuration_Help_Settings',
+ header => [{col1 => 'Authenticated Help Settings',
+ col2 => ''},
+ {col1 => 'Unauthenticated Help Settings',
+ col2 => ''}],
+ },
+ 'coursedefaults' =>
+ {text => 'Course/Community defaults',
+ help => 'Domain_Configuration_Course_Defaults',
+ header => [{col1 => 'Defaults which can be overridden for each course by a DC',
+ col2 => 'Value',}],
+ },
+ 'privacy' =>
+ {text => 'User Privacy',
+ help => 'Domain_Configuration_User_Privacy',
header => [{col1 => 'Setting',
col2 => 'Value',}],
},
@@ -422,7 +437,9 @@ sub process_changes {
} elsif ($action eq 'requestcourses') {
$output = &modify_quotas($dom,$action,%domconfig);
} elsif ($action eq 'helpsettings') {
- $output = &modify_helpsettings($dom,%domconfig);
+ $output = &modify_helpsettings($r,$dom,$confname,%domconfig);
+ } elsif ($action eq 'coursedefaults') {
+ $output = &modify_coursedefaults($dom,%domconfig);
}
return $output;
}
@@ -448,7 +465,7 @@ sub print_config_box {
}
if ($numheaders > 1) {
my $colspan = '';
- if (($action eq 'rolecolors') || ($action eq 'coursecategories')) {
+ if (($action eq 'rolecolors') || ($action eq 'coursecategories') || ($action eq 'helpsettings')) {
$colspan = ' colspan="2"';
}
$output .= '
@@ -474,8 +491,8 @@ sub print_config_box {
} elsif ($action eq 'requestcourses') {
$output .= &print_quotas($dom,$settings,\$rowtotal,$action);
} elsif ($action eq 'helpsettings') {
- $output .= &print_helpsettings($dom,$settings,\$rowtotal);
- } else {
+ $output .= &print_helpsettings('top',$dom,$confname,$settings,\$rowtotal);
+ } elsif ($action eq 'rolecolors') {
$output .= &print_rolecolors($phase,'student',$dom,$confname,$settings,\$rowtotal);
}
$output .= '
@@ -526,7 +543,9 @@ sub print_config_box {
$output .= &print_login('bottom',$dom,$confname,$phase,$settings,\$rowtotal);
} elsif ($action eq 'requestcourses') {
$output .= &print_courserequestmail($dom,$settings,\$rowtotal);
- } else {
+ } elsif ($action eq 'helpsettings') {
+ $output .= &print_helpsettings('bottom',$dom,$confname,$settings,\$rowtotal);
+ } elsif ($action eq 'rolecolors') {
$output .= &print_rolecolors($phase,'coordinator',$dom,$confname,$settings,\$rowtotal).'
@@ -611,8 +630,10 @@ sub print_config_box {
} elsif ($action eq 'serverstatuses') {
$output .= &print_serverstatuses($dom,$settings,\$rowtotal);
} elsif ($action eq 'helpsettings') {
- $output .= &print_helpsettings($dom,$settings,\$rowtotal);
- }
+ $output .= &print_helpsettings('top',$dom,$confname,$settings,\$rowtotal);
+ } elsif ($action eq 'coursedefaults') {
+ $output .= &print_coursedefaults($dom,$settings,\$rowtotal);
+ }
}
$output .= '
@@ -1930,32 +1951,116 @@ sub print_contacts {
sub print_helpsettings {
- my ($dom,$settings,$rowtotal) = @_;
+ my ($position,$dom,$confname,$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?',
- );
+ my $switchserver = &check_switchserver($dom,$confname);
- %defaultchecked = ('submitbugs' => 'on');
+ my $itemcount = 1;
- @toggles = ('submitbugs',);
-
- foreach my $item (@toggles) {
- if ($defaultchecked{$item} eq 'on') {
+ if ($position eq 'top') {
+
+ 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') {
+ $checkedoff{$item} = ' checked="checked" ';
+ $checkedon{$item} = ' ';
+ }
+ }
+
+ if (ref($settings) eq 'HASH') {
+ foreach my $item (@toggles) {
+ if ($settings->{$item} eq '1') {
+ $checkedon{$item} = ' checked="checked" ';
+ $checkedoff{$item} = ' ';
+ } elsif ($settings->{$item} eq '0') {
+ $checkedoff{$item} = ' checked="checked" ';
+ $checkedon{$item} = ' ';
+ }
+ }
+ }
+
+ foreach my $item (@toggles) {
+ $css_class = $itemcount%2 ? ' class="LC_odd_row"' : '';
+ $datatable .=
+ '
+ '.$choices{$item}.'
+
+
+ '.&mt('Yes').'
+ '.&mt('No').' '.
+ ' '.
+ ' ';
+ $itemcount ++;
+ }
+
+ } else {
+
+ $css_class = $itemcount%2 ? ' class="LC_odd_row"' : '';
+
+ $datatable .= '';
+
+ if (ref($settings) eq 'HASH') {
+ if ($settings->{'loginhelpurl'} ne '') {
+ my($directory, $filename) = $settings->{'loginhelpurl'} =~ m/(.*\/)(.*)$/;
+ $datatable .= ''.&mt('Custom Login Page Help File In Use').' ';
+ $datatable .= ' '.&mt('Delete?').' '
+ } else {
+ $datatable .= ''.&mt('Default Login Page Help File In Use').' ';
+ $datatable .= ' ';
+ }
+ } else {
+ $datatable .= ' ';
+ $datatable .= ' ';
+ }
+
+ $datatable .= '';
+ if ($switchserver) {
+ $datatable .= &mt('Upload to library server: [_1]',$switchserver);
+ } else {
+ $datatable .= &mt('Upload Custom Login Page Help File:');
+ $datatable .=' ';
+ }
+ $datatable .= ' ';
+
+ }
+
+ 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);
+
+ 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} = ' ';
@@ -1964,12 +2069,11 @@ sub print_helpsettings {
$checkedon{$item} = ' ';
}
}
- }
-
- foreach my $item (@toggles) {
+ }
+ foreach my $item (@{$toggles}) {
$css_class = $itemcount%2?' class="LC_odd_row"':'';
- $datatable .=
- ''.$choices{$item}.
+ $datatable .=
+ ''.$choices->{$item}.
' '.
''.
' 'Responder count needed before showing submissions for anonymous surveys',
+ );
+ my $currdefresponder;
+ if (ref($settings) eq 'HASH') {
+ $currdefresponder = $settings->{'anonsurvey_threshold'};
+ }
+ if (!$currdefresponder) {
+ $currdefresponder = 10;
+ } elsif ($currdefresponder < 1) {
+ $currdefresponder = 1;
+ }
+ $datatable .=
+ ''.$choices{'anonsurvey_threshold'}.
+ ' '.
+ ''.
+ ' '.
+ ' ';
+ $$rowtotal += $itemcount;
+ return $datatable;
}
sub contact_titles {
@@ -2355,9 +2488,9 @@ sub print_usermodification {
sub print_defaults {
my ($dom,$rowtotal) = @_;
my @items = ('auth_def','auth_arg_def','lang_def','timezone_def',
- 'datelocale_def');
+ 'datelocale_def','portal_def');
my %domdefaults = &Apache::lonnet::get_domain_defaults($dom);
- my $titles = &defaults_titles();
+ my $titles = &defaults_titles($dom);
my $rownum = 0;
my ($datatable,$css_class);
foreach my $item (@items) {
@@ -2394,8 +2527,12 @@ sub print_defaults {
my $includeempty = 1;
$datatable .= &Apache::loncommon::select_datelocale($item,$domdefaults{$item},undef,$includeempty);
} else {
+ my $size;
+ if ($item eq 'portal_def') {
+ $size = ' size="25"';
+ }
$datatable .= ' ';
+ $domdefaults{$item}.'"'.$size.' />';
}
$datatable .= ' ';
$rownum ++;
@@ -2405,13 +2542,25 @@ sub print_defaults {
}
sub defaults_titles {
+ my ($dom) = @_;
my %titles = &Apache::lonlocal::texthash (
'auth_def' => 'Default authentication type',
'auth_arg_def' => 'Default authentication argument',
'lang_def' => 'Default language',
'timezone_def' => 'Default timezone',
'datelocale_def' => 'Default locale for dates',
+ 'portal_def' => 'Portal/Default URL',
);
+ if ($dom) {
+ my $uprimary_id = &Apache::lonnet::domain($dom,'primary');
+ my $uint_dom = &Apache::lonnet::internet_dom($uprimary_id);
+ my $protocol = $Apache::lonnet::protocol{$uprimary_id};
+ $protocol = 'http' if ($protocol ne 'https');
+ if ($uint_dom) {
+ $titles{'portal_def'} .= ' '.&mt('(for example: [_1])',$protocol.'://loncapa.'.
+ $uint_dom);
+ }
+ }
return (\%titles);
}
@@ -2595,6 +2744,11 @@ sub print_coursecategories {
my $toggle_cats_dom = ' checked="checked" ';
my $can_cat_crs = ' ';
my $can_cat_dom = ' checked="checked" ';
+ my $toggle_catscomm_comm = ' ';
+ my $toggle_catscomm_dom = ' checked="checked" ';
+ my $can_catcomm_comm = ' ';
+ my $can_catcomm_dom = ' checked="checked" ';
+
if (ref($settings) eq 'HASH') {
if ($settings->{'togglecats'} eq 'crs') {
$toggle_cats_crs = $toggle_cats_dom;
@@ -2604,14 +2758,25 @@ sub print_coursecategories {
$can_cat_crs = $can_cat_dom;
$can_cat_dom = ' ';
}
+ if ($settings->{'togglecatscomm'} eq 'comm') {
+ $toggle_catscomm_comm = $toggle_catscomm_dom;
+ $toggle_catscomm_dom = ' ';
+ }
+ if ($settings->{'categorizecomm'} eq 'comm') {
+ $can_catcomm_comm = $can_catcomm_dom;
+ $can_catcomm_dom = ' ';
+ }
}
my %title = &Apache::lonlocal::texthash (
- togglecats => 'Show/Hide a course in the catalog',
- categorize => 'Assign a category to a course',
+ togglecats => 'Show/Hide a course in catalog',
+ togglecatscomm => 'Show/Hide a community in catalog',
+ categorize => 'Assign a category to a course',
+ categorizecomm => 'Assign a category to a community',
);
my %level = &Apache::lonlocal::texthash (
- dom => 'Set in "Modify Course" (Domain)',
- crs => 'Set in "Modify Parameters" (Course)',
+ dom => 'Set in Domain',
+ crs => 'Set in Course',
+ comm => 'Set in Community',
);
$datatable = ''.
''.$title{'togglecats'}.' '.
@@ -2627,8 +2792,22 @@ sub print_coursecategories {
$can_cat_dom.' value="dom" />'.$level{'dom'}.' '.
' '.$level{'crs'}.' '.
+ ' '.
+ ''.$title{'togglecatscomm'}.' '.
+ ''.
+ ' '.$level{'dom'}.' '.
+ ' '.$level{'comm'}.' '.
+ ' '.
+ ''.$title{'categorizecomm'}.' '.
+ ''.
+ ' '.$level{'dom'}.' '.
+ ' '.$level{'comm'}.' '.
' ';
- $$rowtotal += 2;
+ $$rowtotal += 4;
} else {
my $css_class;
my $itemcount = 1;
@@ -2650,7 +2829,15 @@ sub print_coursecategories {
if (ref($cats[0]) eq 'ARRAY') {
my $numtop = @{$cats[0]};
my $maxnum = $numtop;
- if ((!grep(/^instcode$/,@{$cats[0]})) || ($cathash->{'instcode::0'} eq '')) {
+ my %default_names = (
+ instcode => &mt('Official courses'),
+ communities => &mt('Communities'),
+ );
+
+ if ((!grep(/^instcode$/,@{$cats[0]})) ||
+ ($cathash->{'instcode::0'} eq '') ||
+ (!grep(/^communities$/,@{$cats[0]})) ||
+ ($cathash->{'communities::0'} eq '')) {
$maxnum ++;
}
my $lastidx;
@@ -2671,14 +2858,33 @@ sub print_coursecategories {
$datatable .= ''.$vpos.' ';
}
$datatable .= ' ';
- if ($parent eq 'instcode') {
- $datatable .= ''.&mt('Official courses')
- .' ('
- .&mt('with institutional codes').') '
- .' '
- .&mt('Display').' '
- .' '
- .&mt('Do not display').' ';
+ if ($parent eq 'instcode' || $parent eq 'communities') {
+ $datatable .= ''
+ .$default_names{$parent}.' ';
+ if ($parent eq 'instcode') {
+ $datatable .= '('
+ .&mt('with institutional codes')
+ .') ';
+ } else {
+ $datatable .= '';
+ }
+ $datatable .= ' ';
} else {
$datatable .= $parent
.' '
.' '."\n";
$itemcount ++;
- if ((!grep(/^instcode$/,@{$cats[0]})) || ($cathash->{'instcode::0'} eq '')) {
- $css_class = $itemcount%2?' class="LC_odd_row"':'';
- my $chgstr = ' onchange="javascript:reorderCats(this.form,'."'','instcode_pos','$lastidx'".');"';
- $datatable .= ''.
- '';
- for (my $k=0; $k<=$maxnum; $k++) {
- my $vpos = $k+1;
- my $selstr;
- if ($k == $maxnum) {
- $selstr = ' selected="selected" ';
+ 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 .= ''.
+ '';
+ for (my $k=0; $k<=$maxnum; $k++) {
+ my $vpos = $k+1;
+ my $selstr;
+ if ($k == $maxnum) {
+ $selstr = ' selected="selected" ';
+ }
+ $datatable .= ''.$vpos.' ';
}
- $datatable .= ''.$vpos.' ';
+ $datatable .= ' '.
+ ''.
+ $default_names{$default}.' ';
+ if ($default eq 'instcode') {
+ $datatable .= '('
+ .&mt('with institutional codes').') ';
+ }
+ $datatable .= ' '
+ .' '
+ .&mt('Display').' '
+ .' '
+ .&mt('Do not display').' ';
}
- $datatable .= ' '
- .&mt('Official courses').' '.'('
- .&mt('with institutional codes').') '
- .' '
- .&mt('Display').' '
- .' '
- .&mt('Do not display').' ';
}
}
} else {
@@ -2814,6 +3027,9 @@ 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";
@@ -2882,25 +3111,40 @@ ENDSCRIPT
sub initialize_categories {
my ($itemcount) = @_;
- my $datatable;
- my $css_class = $itemcount%2?' class="LC_odd_row"':'';
- my $chgstr = ' onchange="javascript:reorderCats(this.form,'."'','instcode_pos','0'".');"';
-
- $datatable = ''
- .'1 '
- .'2 '
- .&mt('Official courses (with institutional codes)')
- .' '
- .' '
- .&mt('Display').' '
- .' '.&mt('Do not display')
+ 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 .= ''
+ .''
+ .'1 '
+ .'2 '
+ .'3 '
+ .$default_names{$default}
+ .' '
+ .' '
+ .&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 .= ''
- .'1 '
- .'2 '
+ .''
+ .'1 '
+ .'2 '
+ .'3 '
.&mt('Add category').' '.&mt('Name:')
.' ';
return $datatable;
@@ -3231,8 +3475,10 @@ sub modify_login {
my %servers = &dom_servers($dom);
if (keys(%servers) > 1) {
foreach my $lonhost (keys(%servers)) {
- next if ($env{'form.'.$lonhost.'_serverurl'} eq $curr_loginvia{$lonhost});
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;
@@ -3244,7 +3490,7 @@ sub modify_login {
}
}
}
-
+
my $putresult = &Apache::lonnet::put_dom('configuration',\%loginhash,
$dom);
if ($putresult eq 'ok') {
@@ -5205,8 +5451,18 @@ sub modify_defaults {
my ($dom,$r) = @_;
my ($resulttext,$mailmsgtxt,%newvalues,%changes,@errors);
my %domdefaults = &Apache::lonnet::get_domain_defaults($dom);
- my @items = ('auth_def','auth_arg_def','lang_def','timezone_def','datelocale_def');
+ my @items = ('auth_def','auth_arg_def','lang_def','timezone_def','datelocale_def',
+ 'portal_def');
my @authtypes = ('internal','krb4','krb5','localauth');
+ my @doms = &Apache::lonnet::current_machine_domains();
+ my @langs;
+ foreach my $dom (@doms) {
+ if ($dom =~ /^(\w{2})\w?itest$/) {
+ push (@langs,$1.'t');
+ } elsif ($dom =~ /^(\w{2})\w?i$/) {
+ push(@langs,$1.'i');
+ }
+ }
foreach my $item (@items) {
$newvalues{$item} = $env{'form.'.$item};
if ($item eq 'auth_def') {
@@ -5219,7 +5475,8 @@ sub modify_defaults {
if ($newvalues{$item} ne '') {
if ($newvalues{$item} =~ /^(\w+)/) {
my $langcode = $1;
- if ($langcode ne 'x_chef') {
+ if ((!grep(/^\Q$langcode\E/,@langs)) &&
+ ($langcode ne 'x_chef')) {
if (code2language($langcode) eq '') {
push(@errors,$item);
}
@@ -5241,6 +5498,12 @@ sub modify_defaults {
push(@errors,$item);
}
}
+ } elsif ($item eq 'portal_def') {
+ if ($newvalues{$item} ne '') {
+ unless ($newvalues{$item} =~ /^https?\:\/\/(([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9\-]*[a-zA-Z0-9])\.)*([A-Za-z]|[A-Za-z][A-Za-z0-9\-]*[A-Za-z0-9])\/?$/) {
+ push(@errors,$item);
+ }
+ }
}
if (grep(/^\Q$item\E$/,@errors)) {
$newvalues{$item} = $domdefaults{$item};
@@ -5396,6 +5659,14 @@ 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;
@@ -5403,11 +5674,20 @@ sub modify_coursecategories {
togglecats => $env{'form.togglecats'},
categorize => $env{'form.categorize'},
};
+ $changes{'togglecatscomm'} = 1;
+ $changes{'categorizecomm'} = 1;
+ $domconfig{'coursecategories'} = {
+ togglecats => $env{'form.togglecatscomm'},
+ categorize => $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') {
@@ -5457,10 +5737,26 @@ 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 '') {
- my $newitem = &escape($env{'form.addcategory_name'}).'::0';
- $domconfig{'coursecategories'}{'cats'}{$newitem} = $env{'form.addcategory_pos'};
- $adds{$newitem} = 1;
+ 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 $putresult;
if ((keys(%deletions) > 0) || (keys(%reorderings) > 0) || (keys(%adds) > 0)) {
@@ -5497,12 +5793,15 @@ sub modify_coursecategories {
$putresult = &Apache::lonnet::put_dom('configuration',\%domconfig,$dom);
if ($putresult eq 'ok') {
my %title = (
- togglecats => 'Show/Hide a course in the catalog',
- categorize => 'Category assigned to course',
+ 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',
);
my %level = (
- dom => 'set from "Modify Course" (Domain)',
- crs => 'set from "Parameters" (Course)',
+ dom => 'set in Domain ("Modify Course/Community")',
+ crs => 'set in Course ("Course Configuration")',
+ comm => 'set in Community ("Community Configuration")',
);
$resulttext = &mt('Changes made:').'';
if ($changes{'togglecats'}) {
@@ -5511,6 +5810,12 @@ 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 +5865,7 @@ sub modify_coursecategories {
&mt('An error occurred: [_1]',$putresult).' ';
}
} else {
- $resulttext = &mt('No changes made to course categories');
+ $resulttext = &mt('No changes made to course and community categories');
}
return $resulttext;
}
@@ -5691,12 +5996,20 @@ sub modify_serverstatuses {
}
sub modify_helpsettings {
- my ($dom,%domconfig) = @_;
+ my ($r,$dom,$confname,%domconfig) = @_;
my ($resulttext,$errors,%changes,%helphash);
+ my $customhelpfile = $env{'form.loginhelpurl.filename'};
+ my $defaulthelpfile = 'defaulthelp.html';
+ my $servadm = $r->dir_config('lonAdmEMail');
+ my ($configuserok,$author_ok,$switchserver) =
+ &config_check($dom,$confname,$servadm);
+
my %defaultchecked = ('submitbugs' => 'on');
my @offon = ('off','on');
- my %title = ( submitbugs => 'Display link for users to submit a bug');
+ my %title = ( submitbugs => 'Display link for users to submit a bug',
+ loginhelpurl => 'Unauthenticated login help page set to custom file');
+
my @toggles = ('submitbugs');
$helphash{'helpsettings'} = {};
@@ -5727,11 +6040,53 @@ sub modify_helpsettings {
}
}
$helphash{'helpsettings'}{$item} = $env{'form.'.$item};
- }
+ }
+
+ if ($customhelpfile ne '') {
+ my $error;
+ if ($configuserok eq 'ok') {
+ if ($switchserver) {
+ $error = &mt("Upload of custom help file is not permitted to this server: [_1]",$switchserver);
+ } else {
+ if ($author_ok eq 'ok') {
+ my ($result,$loginhelpurl) =
+ &publishlogo($r,'upload','loginhelpurl',$dom,
+ $confname,'help','','',$customhelpfile);
+ if ($result eq 'ok') {
+ $helphash{'helpsettings'}{'loginhelpurl'} = $loginhelpurl;
+ $changes{'loginhelpurl'} = 1;
+ } else {
+ $error = &mt("Upload of [_1] failed because an error occurred publishing the file in RES space. Error was: [_2].",$customhelpfile,$result);
+ }
+ } else {
+ $error = &mt("Upload of [_1] failed because an author role could not be assigned to a Domain Configuration user ([_2]) in domain: [_3]. Error was: [_4].",$customhelpfile,$confname,$dom,$author_ok);
+ }
+ }
+ } else {
+ $error = &mt("Upload of [_1] failed because a Domain Configuration user ([_2]) could not be created in domain: [_3]. Error was: [_4].",$customhelpfile,$confname,$dom,$configuserok);
+ }
+ if ($error) {
+ &Apache::lonnet::logthis($error);
+ $errors .= ''.$error.' ';
+ }
+ }
+
+ if ($domconfig{'helpsettings'}{'loginhelpurl'} ne '') {
+ if ($env{'form.loginhelpurl_del'}) {
+ $helphash{'helpsettings'}{'loginhelpurl'} = '';
+ $changes{'loginhelpurl'} = 1;
+ }
+ }
}
- my $putresult = &Apache::lonnet::put_dom('configuration',\%helphash,
- $dom);
+
+ my $putresult;
+
+ if (keys(%changes) > 0) {
+ $putresult = &Apache::lonnet::put_dom('configuration',\%helphash,$dom);
+ } else {
+ $putresult = 'ok';
+ }
if ($putresult eq 'ok') {
if (keys(%changes) > 0) {
@@ -5740,6 +6095,13 @@ sub modify_helpsettings {
if ($item eq 'submitbugs') {
$resulttext .= ''.&mt("$title{$item} set to $offon[$env{'form.'.$item}]").' ';
}
+ if ($item eq 'loginhelpurl') {
+ if ($helphash{'helpsettings'}{'loginhelpurl'} eq '') {
+ $resulttext .= ''.&mt('[_1] help file removed; [_2] file will be used for the unathorized help page in this domain.',$customhelpfile,$defaulthelpfile).' ';
+ } else {
+ $resulttext .= ''.&mt("$title{$item} [_1]",$customhelpfile).' ';
+ }
+ }
}
$resulttext .= '';
} else {
@@ -5755,6 +6117,87 @@ sub modify_helpsettings {
}
return $resulttext;
}
+
+sub modify_coursedefaults {
+ 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') {
+ 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};
+ }
+ my $currdefresponder = $domconfig{'coursedefaults'}{'anonsurvey_threshold'};
+ my $newdefresponder = $env{'form.anonsurvey_threshold'};
+ $newdefresponder =~ s/\D//g;
+ if ($newdefresponder eq '' || $newdefresponder < 1) {
+ $newdefresponder = 1;
+ }
+ $defaultshash{'coursedefaults'}{'anonsurvey_threshold'} = $newdefresponder;
+ if ($currdefresponder ne $newdefresponder) {
+ unless ($currdefresponder eq '' && $newdefresponder == 10) {
+ $changes{'anonsurvey_threshold'} = 1;
+ }
+ }
+ }
+ my $putresult = &Apache::lonnet::put_dom('configuration',\%defaultshash,
+ $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"').' ';
+ }
+ } elsif ($item eq 'anonsurvey_threshold') {
+ $resulttext .= ''.&mt('Responder count required for display of anonymous survey submissions set to [_1].',$defaultshash{'coursedefaults'}{'anonsurvey_threshold'}).' ';
+ }
+
+ }
+ $resulttext .= ' ';
+ } else {
+ $resulttext = &mt('No changes made to course defaults');
+ }
+ } else {
+ $resulttext = ''.
+ &mt('An error occurred: [_1]',$putresult).' ';
+ }
+ return $resulttext;
+}
sub recurse_check {
my ($chkcats,$categories,$depth,$name) = @_;