--- loncom/interface/lonconfigsettings.pm 2009/03/31 16:59:01 1.1 +++ loncom/interface/lonconfigsettings.pm 2014/04/23 10:26:37 1.21.4.6 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Handler to set domain-wide configuration settings # -# $Id: lonconfigsettings.pm,v 1.1 2009/03/31 16:59:01 raeburn Exp $ +# $Id: lonconfigsettings.pm,v 1.21.4.6 2014/04/23 10:26:37 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -37,18 +37,37 @@ use Apache::lonhtmlcommon(); use Apache::lonlocal; sub print_header { - my ($r,$phase,$context) = @_; - my ($pagetitle,$brcrumtitle,$action); + my ($r,$phase,$context,$jscript,$container) = @_; + my ($pagetitle,$brcrumtitle,$action,$call_category_check,$crstype); 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) { + if (!categoryCheck(formname)) { + return; + } + } +|; + } + } } else { - ($pagetitle, $brcrumtitle) = ('Set Course Environment','Course Environment'); + $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'; } my $alert = &mt('You must select at least one functionality type to display.'); my $js = ' '; + if ($jscript) { + $js .= " + +$jscript + +"; + } my $additem; if ($phase eq 'pickactions') { my %loaditems = ( - 'onload' => "javascript:getViewportDims(document.$phase.width,document.$phase.height);setDisplayColumns();setFormElements(document.pickactions);", - ); - $additem = {'add_entries' => \%loaditems,}; - } else { - my %loaditems = ( - 'onload' => "javascript:getViewportDims(document.$phase.width,document.$phase.height);", + 'onload' => "setFormElements(document.pickactions);", ); $additem = {'add_entries' => \%loaditems,}; } @@ -110,24 +135,24 @@ function changePage(formname,newphase) { } sub print_footer { - my ($r,$phase,$newphase,$button_text,$actions) = @_; + my ($r,$phase,$newphase,$button_text,$actions,$container) = @_; $button_text = &mt($button_text); - $r->print(''. - ''. - ''); + $r->print(''); + if (defined($env{'form.origin'})) { + $r->print(''."\n"); + } if (($phase eq 'display') || ($phase eq 'process')) { if (ref($actions) eq 'ARRAY') { foreach my $item (@{$actions}) { - $r->print('')."\n"; + $r->print(''."\n"); } } - $r->print(''); } my $dest='"javascript:changePage(document.'.$phase.','."'$newphase'".')"'; if ($phase eq 'process') { - $r->print('
'); + $r->print( + &Apache::lonhtmlcommon::actionbox( + [''.$button_text.''])); } else { my $onclick; if ($phase eq 'display') { @@ -139,113 +164,156 @@ sub print_footer { $button_text.'" onclick='.$onclick.' />'); } if ($phase eq 'process') { - $r->print(''.&Apache::loncommon::end_page()); + $r->print(''); + $r->print(&Apache::loncommon::end_page()); } return; } 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,$container) = @_; 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); + &print_header($r,$phase,$context,undef,$container); + my ($crstype,%lastact); + 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(''); + 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,$container); $r->print('
'); + return \%lastact; } sub display_settings { - my ($r,$dom,$phase,$context,$prefs_order,$prefs,$values,$confname) = @_; + my ($r,$dom,$phase,$context,$prefs_order,$prefs,$values,$confname,$jscript, + $allitems,$crstype,$container) = @_; 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"}); - &print_header($r,$phase,$context); + text=>"Display/Edit Settings"}); + &print_header($r,$phase,$context,$jscript,$container); + 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->{$item}); + $item,$prefs->{$item},$values,$allitems,$crstype); } $rowsum += $rowtotal{$item}; } } - my $colend; - my $halfway = $rowsum/2; - my $aggregate = 0; - my $sumleft = 0; - my $sumright = 0; - my $crossover; + $r->print(''); for (my $i=0; $i<$colend; $i++) { $r->print($output{$items[$i]}); } - $r->print(' | '); - if ($colend < @items) { - for (my $i=$colend; $i<@items; $i++) { - $r->print($output{$items[$i]}); - } - } - $r->print(' |
'."\n". + ''."\n"); + $r->print('
'.&mt('Display using: ')."\n". - '
'); + $r->print('