--- loncom/interface/domainprefs.pm 2012/12/20 02:58:05 1.160.6.10 +++ loncom/interface/domainprefs.pm 2013/02/02 00:22:51 1.189 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Handler to set domain-wide configuration settings # -# $Id: domainprefs.pm,v 1.160.6.10 2012/12/20 02:58:05 raeburn Exp $ +# $Id: domainprefs.pm,v 1.189 2013/02/02 00:22:51 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -45,7 +45,7 @@ described at http://www.lon-capa.org. =head1 OVERVIEW Each institution using LON-CAPA will typically have a single domain designated -for use by individuals affliated with the institution. Accordingly, each domain +for use by individuals affiliated with the institution. Accordingly, each domain may define a default set of logos and a color scheme which can be used to "brand" the LON-CAPA instance. In addition, an institution will typically have a language and timezone which are used for the majority of courses. @@ -86,7 +86,7 @@ $dom,$settings,$rowtotal,$action. $dom is the domain, $settings is a reference to a hash of current settings for the current context, $rowtotal is a reference to the scalar used to record the -number of rows displayed on the page, and $action is the context (quotas, +number of rows displayed on the page, and $action is the context (quotas, requestcourses or requestauthor). The print_quotas routine was orginally created to display/store information @@ -210,13 +210,15 @@ sub handler { 'quotas','autoenroll','autoupdate','autocreate', 'directorysrch','usercreation','usermodification', 'contacts','defaults','scantron','coursecategories', - 'serverstatuses','requestcourses','usersessions', - 'loadbalancing','requestauthor'],$dom); + 'serverstatuses','requestcourses','helpsettings', + 'coursedefaults','usersessions','loadbalancing', + 'requestauthor'],$dom); my @prefs_order = ('rolecolors','login','defaults','quotas','autoenroll', 'autoupdate','autocreate','directorysrch','contacts', 'usercreation','usermodification','scantron', 'requestcourses','requestauthor','coursecategories', - 'serverstatuses','usersessions'); + 'serverstatuses','helpsettings', + 'coursedefaults','usersessions'); my %existing; if (ref($domconfig{'loadbalancing'}) eq 'HASH') { %existing = %{$domconfig{'loadbalancing'}}; @@ -353,6 +355,26 @@ sub handler { col3 => 'Specific IPs', }], }, + 'helpsettings' => + {text => 'Help page settings', + help => 'Domain_Configuration_Help_Settings', + header => [{col1 => 'Help Settings (logged-in users)', + col2 => 'Value'}], + }, + 'coursedefaults' => + {text => 'Course/Community defaults', + help => 'Domain_Configuration_Course_Defaults', + header => [{col1 => 'Defaults which can be overridden in each course by a CC', + col2 => 'Value',}, + {col1 => 'Defaults which can be overridden for each course by a DC', + col2 => 'Value',},], + }, + 'privacy' => + {text => 'User Privacy', + help => 'Domain_Configuration_User_Privacy', + header => [{col1 => 'Setting', + col2 => 'Value',}], + }, 'usersessions' => {text => 'User session hosting/offloading', help => 'Domain_Configuration_User_Sessions', @@ -368,7 +390,7 @@ sub handler { help => 'Domain_Configuration_Load_Balancing', header => [{col1 => 'Balancers', col2 => 'Default destinations', - col3 => 'User affliation', + col3 => 'User affiliation', col4 => 'Overrides'}, ], }, @@ -384,12 +406,14 @@ sub handler { col2 => 'Value'}], }; } + my @roles = ('student','coordinator','author','admin'); my @actions = &Apache::loncommon::get_env_multiple('form.actions'); &Apache::lonhtmlcommon::add_breadcrumb ({href=>"javascript:changePage(document.$phase,'pickactions')", text=>"Settings to display/modify"}); my $confname = $dom.'-domainconfig'; + if ($phase eq 'process') { &Apache::lonconfigsettings::make_changes($r,$dom,$phase,$context,\@prefs_order,\%prefs,\%domconfig,$confname,\@roles); } elsif ($phase eq 'display') { @@ -405,6 +429,34 @@ sub handler { } &Apache::lonconfigsettings::display_settings($r,$dom,$phase,$context,\@prefs_order,\%prefs,\%domconfig,$confname,$js); } else { +# check if domconfig user exists for the domain. + my $servadm = $r->dir_config('lonAdmEMail'); + my ($configuserok,$author_ok,$switchserver) = + &config_check($dom,$confname,$servadm); + unless ($configuserok eq 'ok') { + &Apache::lonconfigsettings::print_header($r,$phase,$context); + $r->print(&mt('The domain configuration user "[_1]" has yet to be created.', + $confname). + '
' + ); + if ($switchserver) { + $r->print(&mt('Ordinarily, that domain configuration user is created when the ./UPDATE script is run to install LON-CAPA for the first time.'). + '
'. + &mt('However, that does not apply when new domains are added to a multi-domain server, and ./UPDATE has not been run recently.'). + '
'. + &mt('The "[_1]" user can be created automatically when a Domain Coordinator visits the web-based "Set domain configuration" screen, in a session hosted on the primary library server.',$confname). + '
'. + &mt('To do that now, use the following link: [_1]',$switchserver) + ); + } else { + $r->print(&mt('To create that user from the command line run the ./UPDATE script found in the top level directory of the extracted LON-CAPA tarball.'). + '
'. + &mt('Once that is done, you will be able to use the web-based "Set domain configuration" to configure the domain') + ); + } + $r->print(&Apache::loncommon::end_page()); + return OK; + } if (keys(%domconfig) == 0) { my $primarylibserv = &Apache::lonnet::domain($dom,'primary'); my @ids=&Apache::lonnet::current_machine_ids(); @@ -483,6 +535,10 @@ sub process_changes { $output = &modify_quotas($dom,$action,%domconfig); } elsif ($action eq 'requestauthor') { $output = &modify_quotas($dom,$action,%domconfig); + } elsif ($action eq 'helpsettings') { + $output = &modify_helpsettings($r,$dom,$confname,%domconfig); + } elsif ($action eq 'coursedefaults') { + $output = &modify_coursedefaults($dom,%domconfig); } elsif ($action eq 'usersessions') { $output = &modify_usersessions($dom,%domconfig); } elsif ($action eq 'loadbalancing') { @@ -513,7 +569,7 @@ sub print_config_box { if ($numheaders > 1) { my $colspan = ''; my $rightcolspan = ''; - if (($action eq 'rolecolors') || ($action eq 'coursecategories') || + if (($action eq 'rolecolors') || ($action eq 'coursecategories') || (($action eq 'login') && ($numheaders < 3))) { $colspan = ' colspan="2"'; } @@ -552,6 +608,8 @@ sub print_config_box { $output .= &print_usersessions('top',$dom,$settings,\$rowtotal); } elsif ($action eq 'rolecolors') { $output .= &print_rolecolors($phase,'student',$dom,$confname,$settings,\$rowtotal); + } elsif ($action eq 'coursedefaults') { + $output .= &print_coursedefaults('top',$dom,$settings,\$rowtotal); } $output .= ' @@ -781,7 +839,7 @@ sub print_login { ' '. + ' value="'.$current_color.'" /> '. ' '; unless ($role eq 'login') { $datatable .= ''. @@ -1177,11 +1237,11 @@ sub display_color_options { } else { $datatable .= ' '; } - $current_color = $designs->{'fontmenu'} ? - $designs->{'fontmenu'} : $defaults->{'fontmenu'}; + $current_color = $designs->{'fontmenu'} ? + $designs->{'fontmenu'} : $defaults->{'fontmenu'}; $datatable .= ''. ' '. ' '; } @@ -1310,9 +1370,10 @@ sub display_color_options { } $datatable .= ''. ''; + foreach my $item (@{$bgs}) { $datatable .= ''."\n"; + '. + &mt('[_1] when busy, offloads to:' + ,''.$server.''). + "\n"; my (%current,%canselect); my @choices = &possible_newspares($server,$spareid->{$server},$serverhomes,$altids); @@ -2895,7 +2958,7 @@ sub print_loadbalancing { ''; @@ -2977,7 +3040,6 @@ sub print_loadbalancing { '
'; - my $color = $designs->{'bgs'}{$item} ? $designs->{'bgs'}{$item} : $defaults->{'bgs'}{$item}; + my $color = $designs->{'bgs'}{$item} ? $designs->{'bgs'}{$item} : $defaults->{'bgs'}{$item}; if ($designs->{'bgs'}{$item}) { $datatable .= ' '; } @@ -1338,7 +1399,7 @@ sub display_color_options { $datatable .= ''. ''; foreach my $item (@{$links}) { - my $color = $designs->{'link'}{$item} ? $designs->{'link'}{$item} : $defaults->{'links'}{$item}; + my $color = $designs->{'link'}{$item} ? $designs->{'link'}{$item} : $defaults->{'links'}{$item}; $datatable .= ''; - } $$rowtotal += $itemcount; return $datatable; @@ -1475,7 +1535,7 @@ sub print_quotas { } elsif ($context eq 'requestauthor') { @usertools = ('author'); @options = ('norequest','approval','automatic'); - %titles = &authorrequest_titles(); + %titles = &authorrequest_titles(); } else { @usertools = ('aboutme','blog','webdav','portfolio'); %titles = &tool_titles(); @@ -1935,7 +1995,7 @@ sub print_requestmail { $datatable .= ''; + $fullname.' ('.$uname.':'.$udom.')'; } $datatable .= '
'."\n"; if ($designs->{'links'}{$item}) { @@ -1346,7 +1407,6 @@ sub display_color_options { } $datatable .= '
'; } else { @@ -2728,7 +2788,10 @@ sub spares_row { $css_class = $itemcount%2 ? ' class="LC_odd_row"' : ''; $datatable .= '
- '.$server.' when busy, offloads to:'. '

'; if ($lonhost eq '') { - $datatable .= ''; + $datatable .= ''; if (keys(%currbalancer) > 0) { $datatable .= &mt('Add balancer:'); } else { @@ -2911,7 +2974,7 @@ sub print_loadbalancing { next if ($currbalancer{$server}); $datatable .= ''."\n"; } - $datatable .= + $datatable .= ''."\n". ' '."\n"; } else { @@ -2950,7 +3013,7 @@ sub print_loadbalancing { if (exists($currbalancer{$spares[$i]})) { $disabled = ' disabled="disabled"'; } - $targettable .= + $targettable .= '

'.$targettable.'

'; } } - my $cssidx = $balnum%2; $datatable .= ''. &loadbalancing_rules($dom,$intdom,$currrules{$lonhost}, $othertitle,$usertypes,$types,\%servers, @@ -3035,7 +3097,7 @@ sub loadbalancing_rules { $css_class,$balnum,$islast) = @_; my $output; my $num = 0; - my ($alltypes,$othertypes,$titles) = + my ($alltypes,$othertypes,$titles) = &loadbalancing_titles($dom,$intdom,$usertypes,$types); if ((ref($alltypes) eq 'ARRAY') && (ref($titles) eq 'HASH')) { foreach my $type (@{$alltypes}) { @@ -3107,7 +3169,7 @@ sub loadbalance_rule_row { if ($islast && $num == 1) { $space = '
 
'; } - my $output = + my $output = ''.$space. '
'.$title.'
'."\n". ''.$space. @@ -3127,7 +3189,7 @@ sub loadbalance_rule_row { unless ($checked) { $default = ' selected="selected"'; } - $extra = + $extra = ': '. &Apache::loncommon::plainname($dcname,$dcdom). + ' ('.$dcname.':'.$dcdom.')'. '
'; } $datatable .= ''; @@ -8507,7 +8579,7 @@ sub lonbalance_targets_js { } &get_loadbalancers_config($servers,\%existing,\%currbalancer, \%currtargets,\%currrules); - my $balancers = join("','",sort(keys(%currbalancer))); + my $balancers = join("','",sort(keys(%currbalancer))); return <<"END";