--- loncom/interface/lonconfigsettings.pm 2009/05/12 21:20:42 1.4 +++ loncom/interface/lonconfigsettings.pm 2010/01/08 00:52:06 1.10 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Handler to set domain-wide configuration settings # -# $Id: lonconfigsettings.pm,v 1.4 2009/05/12 21:20:42 raeburn Exp $ +# $Id: lonconfigsettings.pm,v 1.10 2010/01/08 00:52:06 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) = ('Course Configuration','Course Configuration'); + 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}) { @@ -162,6 +186,10 @@ sub make_changes { {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}) { @@ -169,12 +197,12 @@ sub make_changes { if ($context eq 'domain') { $r->print('

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

'. &Apache::domainprefs::process_changes($r,$dom, - $confname,$item,$roles,$values,)); + $confname,$item,$roles,$values)); } else { $changes{$item} = {}; &Apache::courseprefs::process_changes($dom,$item,$values, $prefs->{$item},$changes{$item}, - $allitems,\%disallowed); + $allitems,\%disallowed,$crstype); if (keys(%{$changes{$item}}) > 0) { $numchanged ++; } @@ -185,9 +213,13 @@ sub make_changes { if ($context eq 'course') { if ($numchanged) { $r->print(&Apache::courseprefs::store_changes($dom,$confname,$prefs_order,\@actions, - $prefs,$values,\%changes)); + $prefs,$values,\%changes,$crstype)); } else { - $r->print(&mt('No changes made to course configuration.')); + 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('

'); @@ -195,7 +227,7 @@ sub make_changes { if (ref($disallowed{$item}) eq 'HASH') { if (keys(%{$disallowed{$item}}) > 0) { $r->print(&Apache::courseprefs::display_disallowed($item,$disallowed{$item}, - $prefs)); + $prefs,$crstype)); } } } @@ -213,7 +245,7 @@ sub make_changes { sub display_settings { my ($r,$dom,$phase,$context,$prefs_order,$prefs,$values,$confname,$jscript, - $allitems) = @_; + $allitems,$crstype) = @_; my %brcrumtext = &get_crumb_text(); my @actions = &Apache::loncommon::get_env_multiple('form.actions'); &Apache::lonhtmlcommon::add_breadcrumb @@ -235,7 +267,7 @@ sub display_settings { } else { ($output{$item},$rowtotal{$item}) = &Apache::courseprefs::print_config_box($r,$dom,$phase, - $item,$prefs->{$item},$values,$allitems); + $item,$prefs->{$item},$values,$allitems,$crstype); } $rowsum += $rowtotal{$item}; } @@ -269,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 + }); + if ($(".LC_nested tr.advanced").get(0)) { + $(".LC_nested tr.advanced").each(function() { + $(this).hide(); + p = $(this).parents("div.ui-accordion-content") + if (p.find(".LC_advanced_toggle").length) { + return; + } + p.prepend("Show advanced options"); + }); + $(".LC_advanced_toggle input").change(function() { + if($(this).is(":checked")) { + $(this).parents("div.ui-accordion-content").find("tr.advanced").fadeIn("normal"); + } else { + $(this).parents("div.ui-accordion-content").find("tr.advanced").fadeOut("normal"); + } + }); + } + }); + +'); + } $r->print(&Apache::loncommon::end_page()); return; } @@ -300,9 +373,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).