--- loncom/interface/lonconfigsettings.pm 2009/04/22 12:42:16 1.2 +++ loncom/interface/lonconfigsettings.pm 2009/08/23 17:21:22 1.6 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Handler to set domain-wide configuration settings # -# $Id: lonconfigsettings.pm,v 1.2 2009/04/22 12:42:16 raeburn Exp $ +# $Id: lonconfigsettings.pm,v 1.6 2009/08/23 17:21:22 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -43,12 +43,14 @@ sub print_header { ($pagetitle, $brcrumtitle) = ('View/Modify Domain Settings','Domain Settings'); $action = '/adm/domainprefs'; } else { - ($pagetitle, $brcrumtitle) = ('Set Course Environment','Course Environment'); + ($pagetitle, $brcrumtitle) = ('Course Configuration','Course Configuration'); $action = '/adm/courseprefs'; } my $alert = &mt('You must select at least one functionality type to display.'); my $js = ' '; if ($jscript) { @@ -124,6 +128,9 @@ sub print_footer { $env{'form.width'}.'" />'. ''); + if (defined($env{'form.origin'})) { + $r->print(''."\n"); + } if (($phase eq 'display') || ($phase eq 'process')) { if (ref($actions) eq 'ARRAY') { foreach my $item (@{$actions}) { @@ -152,9 +159,10 @@ sub print_footer { } sub make_changes { - my ($r,$dom,$phase,$context,$prefs_order,$prefs,$values,$confname,$roles) = @_; + my ($r,$dom,$phase,$context,$prefs_order,$prefs,$values,$confname,$roles,$allitems) = @_; my %brcrumtext = &get_crumb_text(); my @actions = &Apache::loncommon::get_env_multiple('form.actions'); + my ($numchanged,%changes,%disallowed); &Apache::lonhtmlcommon::add_breadcrumb ({href=>"javascript:changePage(document.$phase,'display')", text=>$brcrumtext{$context}}, @@ -165,27 +173,59 @@ sub make_changes { (ref($prefs) eq 'HASH')) { foreach my $item (@{$prefs_order}) { if (grep(/^\Q$item\E$/,@actions)) { - $r->print('

'.&mt($prefs->{$item}{'text'}).'

'); if ($context eq 'domain') { - $r->print(&Apache::domainprefs::process_changes($r,$dom,$confname,$item,$roles,$values)); + $r->print('

'.&mt($prefs->{$item}{'text'}).'

'. + &Apache::domainprefs::process_changes($r,$dom, + $confname,$item,$roles,$values,)); } else { - $r->print(&Apache::courseprefs::process_changes($r,$dom,$item,$values)); + $changes{$item} = {}; + &Apache::courseprefs::process_changes($dom,$item,$values, + $prefs->{$item},$changes{$item}, + $allitems,\%disallowed); + if (keys(%{$changes{$item}}) > 0) { + $numchanged ++; + } + } + } + } + } + if ($context eq 'course') { + if ($numchanged) { + $r->print(&Apache::courseprefs::store_changes($dom,$confname,$prefs_order,\@actions, + $prefs,$values,\%changes)); + } else { + $r->print(&mt('No changes made to course configuration.')); + } + if (keys(%disallowed) > 0) { + $r->print('

'); + foreach my $item ('cloners','rolenames','feedback','discussion','localization') { + if (ref($disallowed{$item}) eq 'HASH') { + if (keys(%{$disallowed{$item}}) > 0) { + $r->print(&Apache::courseprefs::display_disallowed($item,$disallowed{$item}, + $prefs)); + } } } + $r->print('

'); } } $r->print('

'); - &print_footer($r,$phase,'display','Back to configuration display',\@actions); + 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); $r->print('

'); } sub display_settings { - my ($r,$dom,$phase,$context,$prefs_order,$prefs,$values,$confname,$jscript) = @_; + my ($r,$dom,$phase,$context,$prefs_order,$prefs,$values,$confname,$jscript, + $allitems) = @_; 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=>"Course Settings"}); + text=>"Display/Edit Settings"}); &print_header($r,$phase,$context,$jscript); if ((ref($prefs_order) eq 'ARRAY') && (ref($prefs) eq 'HASH') && (ref($values) eq 'HASH')) { if (@actions > 0) { @@ -202,7 +242,7 @@ sub display_settings { } else { ($output{$item},$rowtotal{$item}) = &Apache::courseprefs::print_config_box($r,$dom,$phase, - $item,$prefs->{$item},$values); + $item,$prefs->{$item},$values,$allitems); } $rowsum += $rowtotal{$item}; } @@ -267,9 +307,11 @@ sub display_choices { } my %helphash; &print_header($r,$phase,$context); - $r->print('

'.&mt('Functionality to display/modify').'

'); + $r->print('

'.&mt('Settings to display/modify').'

'); $r->print(''."\n".'

'.(' 'x2). @@ -372,7 +414,7 @@ ENDCOL sub get_crumb_text { my %brcrumbtext = ( domain => 'Domain Settings', - course => 'Course Settings', + course => 'Display/Edit Settings', ); return %brcrumbtext; }