--- loncom/interface/lonviewclasslist.pm 2010/03/25 17:38:43 1.13 +++ loncom/interface/lonviewclasslist.pm 2012/12/31 14:29:08 1.14 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Handler to display the classlist # -# $Id: lonviewclasslist.pm,v 1.13 2010/03/25 17:38:43 raeburn Exp $ +# $Id: lonviewclasslist.pm,v 1.14 2012/12/31 14:29:08 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -34,6 +34,7 @@ use strict; use Apache::loncoursedata(); use Apache::loncommon(); use Apache::lonhtmlcommon(); +use Apache::courseprefs(); use Apache::Constants qw(:common :http REDIRECT); use Apache::lonlocal; use Apache::lonnet; @@ -61,7 +62,7 @@ sub handler { return OK; } &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'}, - ['register']); + ['register','forceedit','action','symb','todocs']); if (! ($env{'request.course.fn'})) { $env{'user.error.msg'}= "/adm/viewclasslist:not in course role"; @@ -87,13 +88,95 @@ ENDHEADER # Get classlist view settings my %viewsettings = &retrieve_view_settings(); - # Print classlist - if (keys(%viewsettings) > 0) { - $r->print(&html_classlist($r,\%viewsettings)); + if (($env{'form.forceedit'}) || ($env{'form.action'} eq 'setconfig')) { + if (&Apache::lonnet::allowed('opa',$env{'request.course.id'})) { + my $crstype = &Apache::loncommon::course_type(); + my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'}; + my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'}; + my $rosterprefs = &roster_prefs($crstype); + my $allitems = {}; + if ($env{'form.action'} eq 'setconfig') { + my %values=&Apache::lonnet::dump('environment',$cdom,$cnum); + if (keys(%values) > 0) { + my ($numchanged,%changes,%disallowed); + my $prefs = { + classlists => $rosterprefs, + }; + $changes{'classlists'} = {}; + &Apache::courseprefs::process_changes($cdom,'classlists',\%values, + $rosterprefs, + $changes{'classlists'}, + $allitems,\%disallowed,$crstype); + my $message; + if (keys(%{$changes{'classlists'}}) > 0) { + my $actions = ['classlists']; + $message = + &Apache::courseprefs::store_changes($cdom,$cnum,$actions, + $actions,$prefs,\%values, + \%changes,$crstype); + } else { + if ($crstype eq 'Community') { + $message = &mt('No changes made to community settings.'); + } else { + $message = &mt('No changes made to course settings.'); + } + } + $r->print(&Apache::loncommon::confirmwrapper($message)); + } else { + $r->print('