--- loncom/interface/lonconfigsettings.pm 2010/08/14 13:38:33 1.15.2.1
+++ loncom/interface/lonconfigsettings.pm 2021/09/21 22:54:26 1.53
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Handler to set domain-wide configuration settings
#
-# $Id: lonconfigsettings.pm,v 1.15.2.1 2010/08/14 13:38:33 raeburn Exp $
+# $Id: lonconfigsettings.pm,v 1.53 2021/09/21 22:54:26 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -35,15 +35,21 @@ use Apache::lonnet;
use Apache::loncommon();
use Apache::lonhtmlcommon();
use Apache::lonlocal;
+use Apache::lonparmset();
+use Apache::courseclassifier();
+use LONCAPA qw(:DEFAULT :match);
sub print_header {
- my ($r,$phase,$context,$jscript) = @_;
- my ($pagetitle,$brcrumtitle,$action,$call_category_check);
+ my ($r,$phase,$context,$jscript,$container,$instcode,$dom,$values) = @_;
+ my ($pagetitle,$brcrumtitle,$action,$call_category_check,$instcode_check,
+ $crstype,@actions,@code_order);
+ if ($phase eq 'display') {
+ @actions = &Apache::loncommon::get_env_multiple('form.actions');
+ }
if ($context eq 'domain') {
($pagetitle, $brcrumtitle) = ('View/Modify Domain Settings','View/Modify Domain Settings');
$action = '/adm/domainprefs';
if ($phase eq 'display') {
- my @actions = &Apache::loncommon::get_env_multiple('form.actions');
if (grep(/^coursecategories$/,@actions)) {
$call_category_check = qq|
if (formname == document.display) {
@@ -55,14 +61,65 @@ sub print_header {
}
}
} else {
- if (&Apache::loncommon::course_type() eq 'Community') {
+ $crstype = &Apache::loncommon::course_type();
+ if ($crstype eq 'Community') {
($pagetitle,$brcrumtitle) = ('Community Configuration','Community Configuration');
} else {
($pagetitle,$brcrumtitle) = ('Course Configuration','Course Configuration');
}
$action = '/adm/courseprefs';
+ if ($phase eq 'display') {
+ if (grep(/^courseinfo$/,@actions)) {
+ my %codedefaults;
+ &Apache::lonnet::auto_instcode_defaults($env{'request.role.domain'},\%codedefaults,
+ \@code_order);
+ if (@code_order) {
+ my $noinstcodestr = &mt('You indicated cloning based on category, but did not select any categories.');
+ &js_escape(\$noinstcodestr);
+ $instcode_check = <<"ENDSCRIPT";
+ if (formname == document.display) {
+ if (formname.cloners_instcode.length) {
+ for (var j=0; j'.&mt($prefs->{$item}{'text'}).'
'.
&Apache::domainprefs::process_changes($r,$dom,
- $confname,$item,$roles,$values));
+ $confname,$item,$roles,$values,\%lastact));
} else {
$changes{$item} = {};
- &Apache::courseprefs::process_changes($dom,$item,$values,
- $prefs->{$item},$changes{$item},
- $allitems,\%disallowed,$crstype);
+ $errors =
+ &Apache::courseprefs::process_changes($dom,$confname,$item,$values,
+ $prefs->{$item},$changes{$item},
+ $allitems,\%disallowed,$crstype);
if (keys(%{$changes{$item}}) > 0) {
$numchanged ++;
}
@@ -223,48 +413,87 @@ sub make_changes {
}
$r->print('
'.$errors.'
'); + } } $r->print(''); my $footer_text = 'Back to configuration display'; if ($context eq 'course') { $footer_text = 'Back to display/edit settings'; } - &print_footer($r,$phase,'display',$footer_text,\@actions); + &print_footer($r,$phase,'display',$footer_text,\@actions,$container,$parm_permission); $r->print('
'); + return \%lastact; } sub display_settings { my ($r,$dom,$phase,$context,$prefs_order,$prefs,$values,$confname,$jscript, - $allitems,$crstype) = @_; + $allitems,$crstype,$container,$parm_permission) = @_; my %brcrumtext = &get_crumb_text(); my @actions = &Apache::loncommon::get_env_multiple('form.actions'); &Apache::lonhtmlcommon::add_breadcrumb ({href=>"javascript:changePage(document.$phase,'display')", text=>"Display/Edit Settings"}); - &print_header($r,$phase,$context,$jscript); + my $instcode; + if (ref($values) eq 'HASH') { + $instcode = $values->{'internal.coursecode'}; + } + &print_header($r,$phase,$context,$jscript,$container,$instcode,$dom,$values); my $divwidth = 900; if ((ref($prefs_order) eq 'ARRAY') && (ref($prefs) eq 'HASH') && (ref($values) eq 'HASH')) { if (@actions > 0) { my $rowsum = 0; - my (%output,%rowtotal,@items); + my (%output,%rowtotal,@items,$got_check_uncheck); foreach my $item (@{$prefs_order}) { if (grep(/^\Q$item\E$/,@actions)) { push(@items,$item); if ($context eq 'domain') { - if ($item eq 'usersessions') { - $r->print(''."\n"); + my $settings; + if (ref($values) eq 'HASH') { + $settings = $values->{$item}; + } + if (($item eq 'usersessions') || ($item eq 'ssl')) { + unless ($got_check_uncheck) { + $r->print(''."\n"); + $got_check_uncheck = 1; + } + } elsif ($item eq 'selfcreation') { + if (ref($values) eq 'HASH') { + $settings = $values->{'usercreation'}; + } + } elsif ($item eq 'defaults') { + if (ref($values->{'inststatus'}) eq 'HASH') { + if (ref($values->{'defaults'}) eq 'HASH') { + $settings = {%{$values->{'inststatus'}},%{$values->{'defaults'}}}; + } else { + $settings = $values->{'inststatus'}; + } + } else { + my ($othertitle,$usertypes,$types) = &Apache::loncommon::sorted_inst_types($dom); + my $inststatus = { + inststatustypes => $usertypes, + inststatusorder => $types, + inststatusguest => [], + }; + if (ref($values->{defaults}) eq 'HASH') { + $settings = {%{$inststatus},%{$values->{'defaults'}}}; + } else { + $settings = $inststatus; + } + } } ($output{$item},$rowtotal{$item}) = &Apache::domainprefs::print_config_box($r,$dom,$confname, - $phase,$item,$prefs->{$item},$values->{$item}); + $phase,$item,$prefs->{$item},$settings); } else { ($output{$item},$rowtotal{$item}) = &Apache::courseprefs::print_config_box($r,$dom,$phase, - $item,$prefs->{$item},$values,$allitems,$crstype); + $item,$prefs->{$item},$values,$allitems,$crstype,$parm_permission); } $rowsum += $rowtotal{$item}; } @@ -274,7 +503,7 @@ sub display_settings { $r->print($output{$items[$i]}); } $r->print(''); - $r->print(&print_footer($r,$phase,'process','Save Changes',\@actions)); + $r->print(&print_footer($r,$phase,'process','Save Changes',\@actions,$container,$parm_permission)); } else { $r->print(''. ''.&mt('No settings chosen'). @@ -282,23 +511,32 @@ sub display_settings { } $r->print(''); } + if ($container) { + &Apache::lonparmset::endSettingsScreen($r); + } $r->print(&Apache::loncommon::end_page()); return; } sub display_choices { - my ($r,$phase,$context,$prefs_order,$prefs) = @_; + my ($r,$phase,$context,$prefs_order,$prefs,$container,$parm_permission) = @_; if ($phase eq '') { $phase = 'pickactions'; } my %helphash; - &print_header($r,$phase,$context); + &print_header($r,$phase,$context,undef,$container); $r->print(''."\n"); - $r->print('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.