--- loncom/interface/lonconfigsettings.pm 2014/02/15 17:14:53 1.21.4.5
+++ loncom/interface/lonconfigsettings.pm 2024/07/06 17:30:45 1.21.4.16
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Handler to set domain-wide configuration settings
#
-# $Id: lonconfigsettings.pm,v 1.21.4.5 2014/02/15 17:14:53 raeburn Exp $
+# $Id: lonconfigsettings.pm,v 1.21.4.16 2024/07/06 17:30:45 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -35,15 +35,20 @@ use Apache::lonnet;
use Apache::loncommon();
use Apache::lonhtmlcommon();
use Apache::lonlocal;
+use Apache::courseclassifier();
+use LONCAPA qw(:DEFAULT :match);
sub print_header {
- my ($r,$phase,$context,$jscript,$container) = @_;
- my ($pagetitle,$brcrumtitle,$action,$call_category_check,$crstype);
+ my ($r,$phase,$context,$jscript,$container,$instcode,$dom) = @_;
+ 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) {
@@ -62,8 +67,58 @@ sub print_header {
($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
'.$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,$container); + &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,$container) = @_; + $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,$container); + my $instcode; + if (ref($values) eq 'HASH') { + $instcode = $values->{'internal.coursecode'}; + } + &print_header($r,$phase,$context,$jscript,$container,$instcode,$dom); my $divwidth = 900; if ((ref($prefs_order) eq 'ARRAY') && (ref($prefs) eq 'HASH') && (ref($values) eq 'HASH')) { if (@actions > 0) { @@ -258,7 +411,10 @@ sub display_settings { if (grep(/^\Q$item\E$/,@actions)) { push(@items,$item); if ($context eq 'domain') { - my $settings = $values->{$item}; + my $settings; + if (ref($values) eq 'HASH') { + $settings = $values->{$item}; + } if ($item eq 'usersessions') { $r->print(''."\n"); } elsif ($item eq 'selfcreation') { - $settings = $values->{'usercreation'}; + 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},$settings); } else { ($output{$item},$rowtotal{$item}) = - &Apache::courseprefs::print_config_box($r,$dom,$phase, - $item,$prefs->{$item},$values,$allitems,$crstype); + &Apache::courseprefs::print_config_box($r,$dom,$confname,$phase, + $item,$prefs->{$item},$values,$allitems,$crstype,$parm_permission); } $rowsum += $rowtotal{$item}; } @@ -284,7 +462,7 @@ sub display_settings { $r->print($output{$items[$i]}); } $r->print(''); - $r->print(&print_footer($r,$phase,'process','Save Changes',\@actions,$container)); + $r->print(&print_footer($r,$phase,'process','Save Changes',\@actions,$container,$parm_permission)); } else { $r->print(''. ''.&mt('No settings chosen'). @@ -297,7 +475,7 @@ sub display_settings { } sub display_choices { - my ($r,$phase,$context,$prefs_order,$prefs,$container) = @_; + my ($r,$phase,$context,$prefs_order,$prefs,$container,$parm_permission) = @_; if ($phase eq '') { $phase = 'pickactions'; } @@ -308,7 +486,13 @@ sub display_choices { &Apache::loncommon::check_uncheck_jscript()."\n". '// ]]>'."\n". ''."\n"); - $r->print('