--- loncom/interface/domainprefs.pm 2009/08/13 20:38:45 1.102.2.1 +++ loncom/interface/domainprefs.pm 2009/08/23 12:40:50 1.102.2.2 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Handler to set domain-wide configuration settings # -# $Id: domainprefs.pm,v 1.102.2.1 2009/08/13 20:38:45 raeburn Exp $ +# $Id: domainprefs.pm,v 1.102.2.2 2009/08/23 12:40:50 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -105,7 +105,7 @@ affiliate type (and also default, and _L (official, unofficial and community). In each case the radio buttons allow the selection of one of four values: -0, approve, validate, autolimit=N (where N is blank, or a positive integer). +0, approval, validate, autolimit=N (where N is blank, or a positive integer). which have the following effects: 0 @@ -116,7 +116,7 @@ which have the following effects: =back -approve +approval =over @@ -1126,7 +1126,7 @@ sub print_quotas { my ($css_class,%titles); if ($context eq 'requestcourses') { @usertools = ('official','unofficial','community'); - @options =('norequest','approve','autolimit','validate'); + @options =('norequest','approval','autolimit','validate'); %validations = &Apache::lonnet::auto_courserequest_checks($dom); %titles = &courserequest_titles(); } else { @@ -1199,7 +1199,10 @@ sub print_quotas { if ($option eq 'autolimit') { $cell{$item} .= ''; + 'value="'.$currlimit.'" />'; + } + if ($option eq 'autolimit') { + $cell{$item} .= $titles{'unlimited'}; } $cell{$item} .= '  '; } @@ -1223,7 +1226,7 @@ sub print_quotas { if ($context eq 'requestcourses') { $datatable .= ''; foreach my $item (@usertools) { - $datatable .= ''.$cell{$item}.''; + $datatable .= ''.$cell{$item}.''; } $datatable .= ''; } @@ -1305,6 +1308,9 @@ sub print_quotas { 'value="'.$currlimit.'" />'; } $defcell{$item} .= '  '; + if ($option eq 'autolimit') { + $defcell{$item} .= $titles{'unlimited'}; + } } } else { my $checked = 'checked="checked" '; @@ -1326,7 +1332,7 @@ sub print_quotas { if ($context eq 'requestcourses') { $datatable .= ''; foreach my $item (@usertools) { - $datatable .= ''.$defcell{$item}.''; + $datatable .= ''.$defcell{$item}.''; } $datatable .= ''; } @@ -1340,10 +1346,13 @@ sub print_quotas { $typecount ++; $css_class = $typecount%2?' class="LC_odd_row"':''; $datatable .= ''. - ''.&mt('LON-CAPA Advanced Users'). - ' ('. - &mt('overrides affiliation').')'. - ''; + ''.&mt('LON-CAPA Advanced Users').' '; + if ($context eq 'requestcourses') { + $datatable .= &mt('(overrides affiliation, if set)'); + } else { + $datatable .= &mt('(overrides affiliation, if checked)'); + } + $datatable .= ''. if ($context eq 'requestcourses') { $datatable .= ''; } else { @@ -1365,6 +1374,14 @@ sub print_quotas { $curroption = 'norequest'; } $datatable .= ''; + my $checked = ''; + if ($curroption eq '') { + $checked = ' checked="checked"'; + } + $advcell{$item} .= '  '; foreach my $option (@options) { my $val = $option; if ($option eq 'norequest') { @@ -1380,7 +1397,7 @@ sub print_quotas { next if (!$canvalidate); } my $checked = ''; - if ($option eq $curroption) { + if ($val eq $curroption) { $checked = ' checked="checked"'; } elsif ($option eq 'autolimit') { if ($curroption =~ /^autolimit/) { @@ -1397,6 +1414,9 @@ sub print_quotas { 'value="'.$currlimit.'" />'; } $advcell{$item} .= '  '; + if ($option eq 'autolimit') { + $advcell{$item} .= $titles{'unlimited'}; + } } } else { my $checked = 'checked="checked" '; @@ -1418,7 +1438,7 @@ sub print_quotas { if ($context eq 'requestcourses') { $datatable .= ''; foreach my $item (@usertools) { - $datatable .= ''; + $datatable .= ''; } $datatable .= '
'.$titles{$item}.'
'.$advcell{$item}.''.$advcell{$item}.'
'; } @@ -1429,7 +1449,7 @@ sub print_quotas { sub print_courserequestmail { my ($dom,$settings,$rowtotal) = @_; - my ($now,$datatable,%dompersonnel,@domcoord,@currapprove,$rows); + my ($now,$datatable,%dompersonnel,@domcoord,@currapproval,$rows); $now = time; $rows = 0; %dompersonnel = &Apache::lonnet::get_domain_roles($dom,['dc'],$now,$now); @@ -1444,12 +1464,12 @@ sub print_courserequestmail { if (ref($settings) eq 'HASH') { if (ref($settings->{'notify'}) eq 'HASH') { if ($settings->{'notify'}{'approval'} ne '') { - @currapprove = split(',',$settings->{'notify'}{'approval'}); + @currapproval = split(',',$settings->{'notify'}{'approval'}); } } } - if (@currapprove) { - foreach my $dc (@currapprove) { + if (@currapproval) { + foreach my $dc (@currapproval) { unless (grep(/^\Q$dc\E$/,@domcoord)) { push(@domcoord,$dc); } @@ -1475,7 +1495,7 @@ sub print_courserequestmail { $rows ++; } my $check = ' '; - if (grep(/^\Q$domcoord[$i]\E$/,@currapprove)) { + if (grep(/^\Q$domcoord[$i]\E$/,@currapproval)) { $check = ' checked="checked" '; } my ($uname,$udom) = split(':',$domcoord[$i]); @@ -1846,16 +1866,17 @@ sub courserequest_titles { unofficial => 'Unofficial', community => 'Communities', norequest => 'Not allowed', - approve => 'Approval by Dom. Coord.', + approval => 'Approval by Dom. Coord.', validate => 'With validation', autolimit => 'Numerical limit', + unlimited => '(blank for unlimited)', ); return %titles; } sub courserequest_conditions { my %conditions = &Apache::lonlocal::texthash ( - approve => '(Processing of request subject to approval by Domain Coordinator).', + approval => '(Processing of request subject to approval by Domain Coordinator).', validate => '(Processing of request subject to instittutional validation).', ); return %conditions; @@ -3735,7 +3756,7 @@ sub modify_quotas { } if ($context eq 'requestcourses') { @usertools = ('official','unofficial','community'); - @options =('norequest','approve','autolimit','validate'); + @options =('norequest','approval','autolimit','validate'); %validations = &Apache::lonnet::auto_courserequest_checks($dom); %titles = &courserequest_titles(); $toolregexp = join('|',@usertools); @@ -3790,7 +3811,12 @@ sub modify_quotas { } foreach my $item (@usertools) { foreach my $type (@{$types},'default','_LC_adv') { + my $unset; if ($context eq 'requestcourses') { + $unset = '0'; + if ($type eq '_LC_adv') { + $unset = ''; + } if ($confhash{$item}{$type} eq 'autolimit') { $confhash{$item}{$type} .= '='; unless ($limithash{$item}{$type} =~ /\D/) { @@ -3811,7 +3837,7 @@ sub modify_quotas { } } else { if ($context eq 'requestcourses') { - if ($confhash{$item}{$type} ne 'norequest') { + if ($confhash{$item}{$type} ne $unset) { $changes{$item}{$type} = 1; } } else { @@ -3822,7 +3848,7 @@ sub modify_quotas { } } else { if ($context eq 'requestcourses') { - if ($confhash{$item}{$type} eq 'norequest') { + if ($confhash{$item}{$type} ne $unset) { $changes{$item}{$type} = 1; } } else { @@ -3914,8 +3940,8 @@ sub modify_quotas { $env{'user.domain'}, $item,'reload',$context); if ($context eq 'requestcourses') { - if ($env{'environment.crsrequest.'.$item} ne $newacc) { - $newenv{'environment.crsrequest.'.$item} = $newacc; + if ($env{'environment.canrequest.'.$item} ne $newacc) { + $newenv{'environment.canrequest.'.$item} = $newacc; } } else { if ($env{'environment.availabletools.'.$item} ne $newacc) { @@ -3948,7 +3974,15 @@ sub modify_quotas { $resulttext .= '
  • '.&mt('Set to be available to [_1]',$typetitle).'
  • '; } } else { - $resulttext .= '
  • '.&mt('Set to be unavailable to [_1]',$typetitle).'
  • '; + if ($type eq '_LC_adv') { + if ($confhash{$item}{$type} eq '0') { + $resulttext .= '
  • '.&mt('Set to be unavailable to [_1]',$typetitle).'
  • '; + } else { + $resulttext .= '
  • '.&mt('No override set for [_1]',$typetitle).'
  • '; + } + } else { + $resulttext .= '
  • '.&mt('Set to be unavailable to [_1]',$typetitle).'
  • '; + } } } } @@ -4496,6 +4530,8 @@ sub modify_usercreation { if (@{$types} > 0) { @{$cancreate{'statustocreate'}} = &Apache::loncommon::get_env_multiple('form.statustocreate'); + } else { + @{$cancreate{'statustocreate'}} = (); } push(@contexts,'statustocreate'); } @@ -4504,9 +4540,11 @@ sub modify_usercreation { if (($item eq 'selfcreate') || ($item eq 'statustocreate')) { if (ref($curr_usercreation{'cancreate'}{$item}) eq 'ARRAY') { foreach my $curr (@{$curr_usercreation{'cancreate'}{$item}}) { - if (!grep(/^$curr$/,@{$cancreate{$item}})) { - if (!grep(/^$item$/,@{$changes{'cancreate'}})) { - push(@{$changes{'cancreate'}},$item); + if (ref($cancreate{$item}) eq 'ARRAY') { + if (!grep(/^$curr$/,@{$cancreate{$item}})) { + if (!grep(/^$item$/,@{$changes{'cancreate'}})) { + push(@{$changes{'cancreate'}},$item); + } } } } @@ -4975,8 +5013,10 @@ sub modify_defaults { if ($newvalues{$item} ne '') { if ($newvalues{$item} =~ /^(\w+)/) { my $langcode = $1; - if (code2language($langcode) eq '') { - push(@errors,$item); + if ($langcode ne 'x_chef') { + if (code2language($langcode) eq '') { + push(@errors,$item); + } } } else { push(@errors,$item);