--- loncom/interface/lonconfigsettings.pm 2009/04/22 12:42:16 1.2 +++ loncom/interface/lonconfigsettings.pm 2010/01/07 18:21:25 1.9 @@ -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.9 2010/01/07 18:21:25 faziophi Exp $ # # Copyright Michigan State University Board of Trustees # @@ -38,17 +38,35 @@ use Apache::lonlocal; sub print_header { my ($r,$phase,$context,$jscript) = @_; - my ($pagetitle,$brcrumtitle,$action); + my ($pagetitle,$brcrumtitle,$action,$call_category_check); if ($context eq 'domain') { ($pagetitle, $brcrumtitle) = ('View/Modify Domain Settings','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) { + if (!categoryCheck(formname)) { + return; + } + } +|; + } + } } else { - ($pagetitle, $brcrumtitle) = ('Set Course Environment','Course Environment'); + if (&Apache::loncommon::course_type() eq 'Community') { + ($pagetitle,$brcrumtitle) = ('Community Configuration','Community Configuration'); + } else { + ($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 +145,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,40 +176,81 @@ 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}}, {href=>"javascript:changePage(document.$phase,'$phase')", text=>"Updated"}); &print_header($r,$phase,$context); + my $crstype; + if ($context eq 'course') { + $crstype = &Apache::loncommon::course_type(); + } if ((ref($prefs_order) eq 'ARRAY') && (ref($prefs) eq 'HASH') && (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,$crstype); + 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,$crstype)); + } else { + if ($crstype eq 'Community') { + $r->print(&mt("No changes made to community configuration.")); + } 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,$crstype)); + } } } + $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,$crstype) = @_; 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 +267,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,$crstype); } $rowsum += $rowtotal{$item}; } @@ -236,17 +301,30 @@ sub display_settings { } else { $colend = @items; } - $r->print('

'); for (my $i=0; $i<$colend; $i++) { + if ($context ne 'course') { + $r->print('

'); + } + else { + $r->print('
'); + } + for (my $i=0; $i<$colend; $i++) { $r->print($output{$items[$i]}); } - $r->print('
'); + if ($context ne 'course') { + $r->print(''); + } if ($colend < @items) { for (my $i=$colend; $i<@items; $i++) { $r->print($output{$items[$i]}); } } - $r->print('

'); - $r->print(&print_footer($r,$phase,'process','Save',\@actions)); + if ($context ne 'course') { + $r->print('

'); + } + else { + $r->print(''); + } + $r->print(&print_footer($r,$phase,'process','Save Changes',\@actions)); } else { $r->print(''. ' + $(document).ready(function(){ + $("#prefs").accordion({ + autoHeight: false + }); + $("#prefs td.LC_left_item").css("text-align", "right"); + $("#prefs td.LC_left_item").css("width", "40%"); + $("#prefs td.LC_left_item").css("padding-right", "10px"); + $("#prefs td.LC_right_item").css("text-align", "left"); + $("#prefs td.LC_right_item").css("width", "60%"); + }); + +'); + } $r->print(&Apache::loncommon::end_page()); return; } @@ -267,9 +361,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 +468,7 @@ ENDCOL sub get_crumb_text { my %brcrumbtext = ( domain => 'Domain Settings', - course => 'Course Settings', + course => 'Display/Edit Settings', ); return %brcrumbtext; }