--- loncom/interface/lonconfigsettings.pm 2010/01/08 00:52:06 1.10
+++ loncom/interface/lonconfigsettings.pm 2024/07/06 16:46:51 1.21.4.15
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Handler to set domain-wide configuration settings
#
-# $Id: lonconfigsettings.pm,v 1.10 2010/01/08 00:52:06 faziophi Exp $
+# $Id: lonconfigsettings.pm,v 1.21.4.15 2024/07/06 16:46:51 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) = @_;
- my ($pagetitle,$brcrumtitle,$action,$call_category_check);
+ 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','Domain Settings');
+ ($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 +60,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,$item,$values,
+ $prefs->{$item},$changes{$item},
+ $allitems,\%disallowed,$crstype);
if (keys(%{$changes{$item}}) > 0) {
$numchanged ++;
}
@@ -212,13 +353,14 @@ sub make_changes {
}
if ($context eq 'course') {
if ($numchanged) {
- $r->print(&Apache::courseprefs::store_changes($dom,$confname,$prefs_order,\@actions,
- $prefs,$values,\%changes,$crstype));
+ my $message = &Apache::courseprefs::store_changes($dom,$confname,$prefs_order,\@actions,
+ $prefs,$values,\%changes,$crstype);
+ $r->print(&Apache::loncommon::confirmwrapper($message));
} else {
if ($crstype eq 'Community') {
- $r->print(&mt("No changes made to community configuration."));
+ $r->print(&Apache::loncommon::confirmwrapper(&mt("No changes made to community configuration.")));
} else {
- $r->print(&mt("No changes made to course configuration."));
+ $r->print(&Apache::loncommon::confirmwrapper(&mt("No changes made to course configuration.")));
}
}
if (keys(%disallowed) > 0) {
@@ -233,165 +375,142 @@ 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); + 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 $halfway = @actions/2; foreach my $item (@{$prefs_order}) { if (grep(/^\Q$item\E$/,@actions)) { push(@items,$item); if ($context eq 'domain') { + my $settings; + if (ref($values) eq 'HASH') { + $settings = $values->{$item}; + } + if ($item eq 'usersessions') { + $r->print(''."\n"); + } 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); + &Apache::courseprefs::print_config_box($r,$dom,$confname,$phase, + $item,$prefs->{$item},$values,$allitems,$crstype,$parm_permission); } $rowsum += $rowtotal{$item}; } } - my $colend; - my $halfway = $rowsum/2; - my $aggregate = 0; - my $sumleft = 0; - my $sumright = 0; - my $crossover; + $r->print('');
- }
- else {
- $r->print(' ');
- }
- for (my $i=0; $i<$colend; $i++) {
$r->print($output{$items[$i]});
}
- if ($context ne 'course') {
- $r->print(' | '); - } - if ($colend < @items) { - for (my $i=$colend; $i<@items; $i++) { - $r->print($output{$items[$i]}); - } - } - if ($context ne 'course') { - $r->print(' |
'."\n"); + my $heading = &mt('Settings to display/modify'); + if (ref($parm_permission) eq 'HASH') { + unless ($parm_permission->{'process'}) { + $heading = &mt('Settings to display'); + } + } + $r->print('
'.&mt('Display using: ')."\n". - '
'); } - $r->print(&print_footer($r,$phase,'display','Go')); + $r->print('