--- loncom/interface/domainprefs.pm 2013/03/01 21:17:24 1.160.6.16 +++ loncom/interface/domainprefs.pm 2012/10/02 18:35:19 1.172 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Handler to set domain-wide configuration settings # -# $Id: domainprefs.pm,v 1.160.6.16 2013/03/01 21:17:24 raeburn Exp $ +# $Id: domainprefs.pm,v 1.172 2012/10/02 18:35:19 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 affiliated with the institution. Accordingly, each domain +for use by individuals affliated 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','coursedefaults', - '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','coursedefaults','usersessions'); + 'serverstatuses','helpsettings', + 'coursedefaults','usersessions'); my %existing; if (ref($domconfig{'loadbalancing'}) eq 'HASH') { %existing = %{$domconfig{'loadbalancing'}}; @@ -353,12 +355,26 @@ sub handler { col3 => 'Specific IPs', }], }, - 'coursedefaults' => + '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 for each course by a DC', + 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', @@ -370,11 +386,11 @@ sub handler { col2 => 'Rules'}], }, 'loadbalancing' => - {text => 'Dedicated Load Balancer(s)', + {text => 'Dedicated Load Balancer', help => 'Domain_Configuration_Load_Balancing', header => [{col1 => 'Balancers', col2 => 'Default destinations', - col3 => 'User affiliation', + col3 => 'User affliation', col4 => 'Overrides'}, ], }, @@ -390,19 +406,16 @@ 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') { - my $js = &recaptcha_js(). - &credits_js(); + my $js = &recaptcha_js(); if ((keys(%servers) > 1) || (keys(%existing) > 0)) { my ($othertitle,$usertypes,$types) = &Apache::loncommon::sorted_inst_types($dom); @@ -414,34 +427,6 @@ 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(); @@ -520,6 +505,8 @@ 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') { @@ -552,7 +539,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"'; } @@ -591,6 +578,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 .= ' @@ -680,6 +669,8 @@ sub print_config_box { '.&mt($item->{'header'}->[2]->{'col2'}).' '. &print_usersessions('bottom',$dom,$settings,\$rowtotal); $rowtotal ++; + } elsif ($action eq 'coursedefaults') { + $output .= &print_coursedefaults('bottom',$dom,$settings,\$rowtotal); } elsif ($action eq 'rolecolors') { $output .= &print_rolecolors($phase,'coordinator',$dom,$confname,$settings,\$rowtotal).' @@ -776,8 +767,6 @@ sub print_config_box { $output .= &print_helpsettings($dom,$confname,$settings,\$rowtotal); } elsif ($action eq 'loadbalancing') { $output .= &print_loadbalancing($dom,$settings,\$rowtotal); - } elsif ($action eq 'coursedefaults') { - $output .= &print_coursedefaults('bottom',$dom,$settings,\$rowtotal); } } $output .= ' @@ -820,7 +809,7 @@ sub print_login { ' '. - ' '; + ' '.$fontlink. + '    '. + ''; unless ($role eq 'login') { $datatable .= ''. ''.$choices->{'fontmenu'}.''; @@ -1218,13 +1206,13 @@ sub display_color_options { } else { $datatable .= ' '; } - $current_color = $designs->{'fontmenu'} ? - $designs->{'fontmenu'} : $defaults->{'fontmenu'}; + $fontlink = &color_pick($phase,$role,'fontmenu',$choices->{'fontmenu'},$designs->{'fontmenu'}); $datatable .= ''. - ' '. - ' '; + ' '.$fontlink. + '    '. + ''; } my $switchserver = &check_switchserver($dom,$confname); foreach my $img (@{$images}) { @@ -1351,14 +1339,13 @@ sub display_color_options { } $datatable .= ''. ''; - foreach my $item (@{$bgs}) { - $datatable .= ''; } $datatable .= '
'; - my $color = $designs->{'bgs'}{$item} ? $designs->{'bgs'}{$item} : $defaults->{'bgs'}{$item}; + my $link = &color_pick($phase,$role,$item,$choices->{$item},$designs->{'bgs'}{$item}); + $datatable .= ''.$link; if ($designs->{'bgs'}{$item}) { - $datatable .= ' '; + $datatable .= '    '; } - $datatable .= '
'; @@ -1380,13 +1367,13 @@ sub display_color_options { $datatable .= ''. ''; foreach my $item (@{$links}) { - my $color = $designs->{'link'}{$item} ? $designs->{'link'}{$item} : $defaults->{'links'}{$item}; - $datatable .= ''; } $$rowtotal += $itemcount; @@ -1516,7 +1503,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(); @@ -1872,8 +1859,8 @@ sub print_quotas { $checked = ' checked="checked"'; } $datatable .= '  '; } } else { @@ -1907,16 +1894,35 @@ sub print_quotas { sub print_requestmail { my ($dom,$action,$settings,$rowtotal) = @_; - my ($now,$datatable,%currapp,$rows); + my ($now,$datatable,%dompersonnel,@domcoord,@currapproval,$rows); $now = time; + $rows = 0; + %dompersonnel = &Apache::lonnet::get_domain_roles($dom,['dc'],$now,$now); + foreach my $server (keys(%dompersonnel)) { + foreach my $user (sort(keys(%{$dompersonnel{$server}}))) { + my ($trole,$uname,$udom,$runame,$rudom,$rsec) = split(/:/,$user); + if (!grep(/^$uname:$udom$/,@domcoord)) { + push(@domcoord,$uname.':'.$udom); + } + } + } if (ref($settings) eq 'HASH') { if (ref($settings->{'notify'}) eq 'HASH') { if ($settings->{'notify'}{'approval'} ne '') { - map {$currapp{$_}=1;} split(/,/,$settings->{'notify'}{'approval'}); + @currapproval = split(',',$settings->{'notify'}{'approval'}); } } } - my $numinrow = 2; + if (@currapproval) { + foreach my $dc (@currapproval) { + unless (grep(/^\Q$dc\E$/,@domcoord)) { + push(@domcoord,$dc); + } + } + } + @domcoord = sort(@domcoord); + my $numinrow = 4; + my $numdc = @domcoord; my $css_class = 'class="LC_odd_row"'; my $text; if ($action eq 'requestcourses') { @@ -1927,12 +1933,42 @@ sub print_requestmail { $datatable = ''. ' '. ' '; $$rowtotal += $rows; @@ -2087,7 +2123,8 @@ sub print_autoupdate { sub print_autocreate { my ($dom,$settings,$rowtotal) = @_; - my (%createon,%createoff,%currhash); + my (%createon,%createoff); + my $curr_dc; my @types = ('xml','req'); if (ref($settings) eq 'HASH') { foreach my $item (@types) { @@ -2100,9 +2137,7 @@ sub print_autocreate { } } } - if ($settings->{'xmldc'} ne '') { - $currhash{$settings->{'xmldc'}} = 1; - } + $curr_dc = $settings->{'xmldc'}; } else { foreach my $item (@types) { $createoff{$item} = ' checked="checked" '; @@ -2110,7 +2145,6 @@ sub print_autocreate { } } $$rowtotal += 2; - my $numinrow = 2; my $datatable=''. ''. ''; + $$rowtotal ++ ; } else { $datatable .= $dctable.''; } - $$rowtotal += $rows; return $datatable; } @@ -2257,7 +2290,7 @@ sub print_contacts { my @contacts = ('adminemail','supportemail'); my (%checked,%to,%otheremails,%bccemails); my @mailings = ('errormail','packagesmail','lonstatusmail','helpdeskmail', - 'requestsmail','updatesmail'); + 'requestsmail'); foreach my $type (@mailings) { $otheremails{$type} = ''; } @@ -2293,7 +2326,6 @@ sub print_contacts { $checked{'helpdeskmail'}{'supportemail'} = ' checked="checked" '; $checked{'lonstatusmail'}{'adminemail'} = ' checked="checked" '; $checked{'requestsmail'}{'adminemail'} = ' checked="checked" '; - $checked{'updatesmail'}{'adminemail'} = ' checked="checked" '; } my ($titles,$short_titles) = &contact_titles(); my $rownum = 0; @@ -2353,8 +2385,7 @@ sub print_helpsettings { } sub radiobutton_prefs { - my ($settings,$toggles,$defaultchecked,$choices,$itemcount,$onclick, - $additional) = @_; + my ($settings,$toggles,$defaultchecked,$choices,$itemcount) = @_; return unless ((ref($toggles) eq 'ARRAY') && (ref($defaultchecked) eq 'HASH') && (ref($choices) eq 'HASH')); @@ -2380,22 +2411,17 @@ sub radiobutton_prefs { } } } - if ($onclick) { - $onclick = ' onclick="'.$onclick.'"'; - } foreach my $item (@{$toggles}) { $css_class = $itemcount%2?' class="LC_odd_row"':''; $datatable .= - ''. ''. + $checkedoff{$item}.' value="0" />'.&mt('No').''. + ''. ''; $itemcount ++; } @@ -2404,31 +2430,28 @@ sub radiobutton_prefs { sub print_coursedefaults { my ($position,$dom,$settings,$rowtotal) = @_; - my ($css_class,$datatable,%checkedon,%checkedoff,%defaultchecked,@toggles); + my ($css_class,$datatable); my $itemcount = 1; - my %choices = &Apache::lonlocal::texthash ( - canuse_pdfforms => 'Course/Community users can create/upload PDF forms', - anonsurvey_threshold => 'Responder count needed before showing submissions for anonymous surveys', - coursecredits => 'Credits can be specified for courses', - ); if ($position eq 'top') { + my (%checkedon,%checkedoff,%choices,%defaultchecked,@toggles); + %choices = + &Apache::lonlocal::texthash ( + canuse_pdfforms => 'Course/Community users can create/upload PDF forms', + ); %defaultchecked = ('canuse_pdfforms' => 'off'); - @toggles = ('canuse_pdfforms'); + @toggles = ('canuse_pdfforms',); ($datatable,$itemcount) = &radiobutton_prefs($settings,\@toggles,\%defaultchecked, \%choices,$itemcount); + $$rowtotal += $itemcount; } else { $css_class = $itemcount%2 ? ' class="LC_odd_row"' : ''; - my ($currdefresponder,$def_official_credits,$def_unofficial_credits); - my $currusecredits = 0; + my %choices = + &Apache::lonlocal::texthash ( + anonsurvey_threshold => 'Responder count needed before showing submissions for anonymous surveys', + ); + my $currdefresponder; if (ref($settings) eq 'HASH') { $currdefresponder = $settings->{'anonsurvey_threshold'}; - if (ref($settings->{'coursecredits'}) eq 'HASH') { - $def_official_credits = $settings->{'coursecredits'}->{'official'}; - $def_unofficial_credits = $settings->{'coursecredits'}->{'unofficial'}; - if (($def_official_credits ne '') || ($def_unofficial_credits ne '')) { - $currusecredits = 1; - } - } } if (!$currdefresponder) { $currdefresponder = 10; @@ -2436,41 +2459,13 @@ sub print_coursedefaults { $currdefresponder = 1; } $datatable .= - ''. ''."\n"; - $itemcount ++; - my $onclick = 'toggleCredits(this.form);'; - my $display = 'none'; - if ($currusecredits) { - $display = 'block'; - } - my $additional = '
'. - ''. - &mt('Default credits for official courses [_1]', - ''). - '
'. - ''. - &mt('Default credits for unofficial courses [_1]', - ''). - '
'."\n"; - %defaultchecked = ('coursecredits' => 'off'); - @toggles = ('coursecredits'); - my $current = { - 'coursecredits' => $currusecredits, - }; - (my $table,$itemcount) = - &radiobutton_prefs($current,\@toggles,\%defaultchecked, - \%choices,$itemcount,$onclick,$additional); - $datatable .= $table; + ''; } - $$rowtotal += $itemcount; return $datatable; } @@ -2761,10 +2756,7 @@ sub spares_row { $css_class = $itemcount%2 ? ' class="LC_odd_row"' : ''; $datatable .= ' '."\n"; my (%current,%canselect); my @choices = &possible_newspares($server,$spareid->{$server},$serverhomes,$altids); @@ -2931,7 +2923,7 @@ sub print_loadbalancing { ''; @@ -3013,6 +3005,7 @@ sub print_loadbalancing { '
'."\n"; - + $datatable .= ''."\n". + &color_pick($phase,$role,$item,$choices->{$item}, + $designs->{'links'}{$item}); if ($designs->{'links'}{$item}) { - $datatable.=' '; + $datatable.='    '; } - $datatable .= '
'.$text.''; - my ($numdc,$table,$rows) = &active_dc_picker($dom,$numinrow,'checkbox', - 'reqapprovalnotify',%currapp); - if ($numdc > 0) { - $datatable .= $table; + if (@domcoord > 0) { + $datatable .= ''; + for (my $i=0; $i<$numdc; $i++) { + my $rem = $i%($numinrow); + if ($rem == 0) { + if ($i > 0) { + $datatable .= ''; + } + $datatable .= ''; + $rows ++; + } + my $check = ' '; + if (grep(/^\Q$domcoord[$i]\E$/,@currapproval)) { + $check = ' checked="checked" '; + } + my ($uname,$udom) = split(':',$domcoord[$i]); + my $fullname = &Apache::loncommon::plainname($uname,$udom); + if ($i == $numdc-1) { + my $colsleft = $numinrow-$rem; + if ($colsleft > 1) { + $datatable .= ''; + } + $datatable .= '
'; + } else { + $datatable .= ''; + } + } else { + $datatable .= ''; + } + $datatable .= '
'; } else { $datatable .= &mt('There are no active Domain Coordinators'); + $rows ++; } $datatable .='
'.&mt('Create pending official courses from XML files').' '. ''; - my ($numdc,$dctable,$rows) = &active_dc_picker($dom,$numinrow,'radio', - 'autocreate_xmldc',%currhash); + my ($numdc,$dctable) = &active_dc_picker($dom,$curr_dc); if ($numdc > 1) { $datatable .= '
'. &mt('Course creation processed as: (choose Dom. Coord.)'). ''.$dctable.'
'. - ''.$choices->{$item}. + ''.$choices->{$item}. ''. ' '. - ''.$additional. - '
'. - $choices{'anonsurvey_threshold'}. + ''.$choices{'anonsurvey_threshold'}. ''. ''. - '
- '. - &mt('[_1] when busy, offloads to:' - ,''.$server.''). - "\n"; + '.$server.' when busy, offloads to:'. '

'; if ($lonhost eq '') { - $datatable .= ''; + $datatable .= ''; if (keys(%currbalancer) > 0) { $datatable .= &mt('Add balancer:'); } else { @@ -2947,7 +2939,7 @@ sub print_loadbalancing { next if ($currbalancer{$server}); $datatable .= ''."\n"; } - $datatable .= + $datatable .= ''."\n". ' '."\n"; } else { @@ -2986,7 +2978,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, @@ -3070,7 +3063,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}) { @@ -3142,7 +3135,7 @@ sub loadbalance_rule_row { if ($islast && $num == 1) { $space = '
 
'; } - my $output = + my $output = ''.$space. '
'.$title.'
'."\n". ''.$space. @@ -3162,7 +3155,7 @@ sub loadbalance_rule_row { unless ($checked) { $default = ' selected="selected"'; } - $extra = + $extra = ': '.$user; - if ($user ne $dcname.':'.$dcdom) { - $table .= ' ('.$dcname.':'.$dcdom.')'. - ''; - } - } - $table .= ''; - } elsif ($numdcs == 1) { - if ($inputtype eq 'radio') { - $table .= ''; - } else { - my $check; - if (exists($currhash{$domcoord[0]})) { - $check = ' checked="checked"'; + $datatable .= ''; } - $table .= ''; - $rows ++; + my ($dcname,$dcdom) = split(':',$dcs[$i]); + $datatable .= ''; } + $datatable .= ''; + } elsif (@dcs) { + $datatable .= ''; } - return ($numdcs,$table,$rows); + return ($numdcs,$datatable); } sub usersession_titles { @@ -8617,7 +8533,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"; - -END - -} - -sub credits_js { - return <<"END"; - -