--- loncom/interface/lonconfigsettings.pm 2010/11/19 13:08:47 1.16
+++ loncom/interface/lonconfigsettings.pm 2014/04/23 10:11:26 1.29
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Handler to set domain-wide configuration settings
#
-# $Id: lonconfigsettings.pm,v 1.16 2010/11/19 13:08:47 raeburn Exp $
+# $Id: lonconfigsettings.pm,v 1.29 2014/04/23 10:11:26 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -35,10 +35,11 @@ use Apache::lonnet;
use Apache::loncommon();
use Apache::lonhtmlcommon();
use Apache::lonlocal;
+use Apache::lonparmset();
sub print_header {
- my ($r,$phase,$context,$jscript) = @_;
- my ($pagetitle,$brcrumtitle,$action,$call_category_check);
+ my ($r,$phase,$context,$jscript,$container) = @_;
+ my ($pagetitle,$brcrumtitle,$action,$call_category_check,$crstype);
if ($context eq 'domain') {
($pagetitle, $brcrumtitle) = ('View/Modify Domain Settings','View/Modify Domain Settings');
$action = '/adm/domainprefs';
@@ -55,7 +56,8 @@ 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');
@@ -93,9 +95,11 @@ function changePage(formname,newphase) {
formname.submit();
}'."\n";
if ($phase eq 'pickactions') {
+ $js .= &Apache::lonhtmlcommon::color_picker();
$js .=
&Apache::lonhtmlcommon::set_form_elements({actions => 'checkbox'})."\n";
} elsif ($phase eq 'display') {
+ $js .= &Apache::lonhtmlcommon::color_picker();
$js .= &color_pick_js()."\n";
}
$js .= &Apache::loncommon::viewport_size_js().'
@@ -126,13 +130,16 @@ $jscript
');
+ if ($container) {
+ &Apache::lonparmset::startSettingsScreen($r,$container,$crstype);
+ }
$r->print('
'.&Apache::loncommon::end_page());
+ $r->print('');
+ if ($container) {
+ &Apache::lonparmset::endSettingsScreen($r);
+ }
+ $r->print(&Apache::loncommon::end_page());
}
return;
}
sub make_changes {
- my ($r,$dom,$phase,$context,$prefs_order,$prefs,$values,$confname,$roles,$allitems) = @_;
+ 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);
@@ -174,8 +187,8 @@ sub make_changes {
text=>$brcrumtext{$context}},
{href=>"javascript:changePage(document.$phase,'$phase')",
text=>"Updated"});
- &print_header($r,$phase,$context);
- my $crstype;
+ &print_header($r,$phase,$context,undef,$container);
+ my ($crstype,%lastact);
if ($context eq 'course') {
$crstype = &Apache::loncommon::course_type();
}
@@ -186,7 +199,7 @@ 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,\%lastact));
} else {
$changes{$item} = {};
&Apache::courseprefs::process_changes($dom,$item,$values,
@@ -229,19 +242,20 @@ sub make_changes {
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);
$r->print('');
+ return \%lastact;
}
sub display_settings {
my ($r,$dom,$phase,$context,$prefs_order,$prefs,$values,$confname,$jscript,
- $allitems,$crstype) = @_;
+ $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=>"Display/Edit Settings"});
- &print_header($r,$phase,$context,$jscript);
+ &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) {
@@ -251,16 +265,44 @@ sub display_settings {
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,
@@ -274,7 +316,7 @@ sub display_settings {
$r->print($output{$items[$i]});
}
$r->print('');
- $r->print(&print_footer($r,$phase,'process','Save Changes',\@actions));
+ $r->print(&print_footer($r,$phase,'process','Save Changes',\@actions,$container));
} else {
$r->print(''.
''.&mt('No settings chosen').
@@ -282,45 +324,20 @@ sub display_settings {
}
$r->print('');
}
- if ($context eq 'course') {
- $r->print('
-
-');
+ if ($container) {
+ &Apache::lonparmset::endSettingsScreen($r);
}
$r->print(&Apache::loncommon::end_page());
return;
}
sub display_choices {
- my ($r,$phase,$context,$prefs_order,$prefs) = @_;
+ my ($r,$phase,$context,$prefs_order,$prefs,$container) = @_;
if ($phase eq '') {
$phase = 'pickactions';
}
my %helphash;
- &print_header($r,$phase,$context);
+ &print_header($r,$phase,$context,undef,$container);
$r->print('