--- loncom/interface/loncreateuser.pm 2009/09/07 13:23:23 1.295.2.13 +++ loncom/interface/loncreateuser.pm 2009/09/10 23:14:29 1.295.2.14 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Create a user # -# $Id: loncreateuser.pm,v 1.295.2.13 2009/09/07 13:23:23 raeburn Exp $ +# $Id: loncreateuser.pm,v 1.295.2.14 2009/09/10 23:14:29 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -229,7 +229,7 @@ sub build_tools_display { 'usde' => "Use default", 'uscu' => "Use custom", 'official' => 'Can request creation of official courses', - 'unofficial' => 'Can request creation of unofficial courses', + 'unofficial' => 'Can request creation of unofficial courses', ); if ($context eq 'requestcourses') { %userenv = &Apache::lonnet::userenvironment($ccdomain,$ccuname, @@ -292,7 +292,11 @@ sub build_tools_display { } if ($curroption =~ /^autolimit=(\d*)$/) { $currlimit = $1; - $currdisp = &mt('Yes, up to [quant,_1,request]/user',$currlimit); + if ($currlimit eq '') { + $currdisp = &mt('Yes, automatic creation'); + } else { + $currdisp = &mt('Yes, up to [quant,_1,request]/user',$currlimit); + } } else { $currdisp = $reqdisplay{$curroption}; } @@ -326,9 +330,12 @@ sub build_tools_display { if ($option eq 'autolimit') { $custdisp .= ''; + 'value="'.$currlimit.'" />
'. + $reqtitles{'unlimited'}; + } else { + $custdisp .= ''; } - $custdisp .= ''; + $custdisp .= ''; } $custdisp .= ''; $custradio = ''.&mt('Custom setting').'
'.$custdisp; @@ -378,22 +385,27 @@ sub coursereq_externaluser { my ($curroption,$currlimit,$tooloff); if ($userenv{'reqcrsotherdom.'.$item} ne '') { my @curr = split(',',$userenv{'reqcrsotherdom.'.$item}); - if (grep(/^\Q$cdom\E:($optregex)=?(\d*)$/,@curr)) { - $curroption = $1; - $currlimit = $2; - if (!$curroption) { - $curroption = 'norequest'; + foreach my $req (@curr) { + if ($req =~ /^\Q$cdom\E\:($optregex)=?(\d*)$/) { + $curroption = $1; + $currlimit = $2; + last; } } + if (!$curroption) { + $curroption = 'norequest'; + $tooloff = ' checked="checked"'; + } } else { $curroption = 'norequest'; $tooloff = ' checked="checked"'; } $output.= &Apache::loncommon::start_data_table_row()."\n". - ' '.$lt{$item}.': '. + ' '.$lt{$item}.': '. + ''; foreach my $option (@options) { if ($option eq 'validate') { my $canvalidate = 0; @@ -408,18 +420,21 @@ sub coursereq_externaluser { if ($option eq $curroption) { $checked = ' checked="checked"'; } - $output .= ''; } - $output .= ''."\n". + $output .= '
'."\n". ' '; + '" value=""'.$tooloff.' />'.$reqtitles{'norequest'}. + ' '; + $reqtitles{$option}.''; if ($option eq 'autolimit') { - $output .= ''; + 'value="'.$currlimit.'" />'. + '
'.$reqtitles{'unlimited'}; + } else { + $output .= ''; } - $output .= ' ' + $output .= '
'."\n". &Apache::loncommon::end_data_table_row()."\n"; } return $output; @@ -434,16 +449,17 @@ sub courserequest_titles { approval => 'Approval by Dom. Coord.', validate => 'With validation', autolimit => 'Numerical limit', + unlimited => '(blank for unlimited)', ); - return %titles; -} - + return %titles; +} + sub courserequest_display { my %titles = &Apache::lonlocal::texthash ( approval => 'Yes, need approval', validate => 'Yes, with validation', norequest => 'No', - ); + ); return %titles; } @@ -709,13 +725,13 @@ ENDSCRIPT faq=>282,bug=>'Instructor Interface',}); if ($env{'form.action'} eq 'singleuser') { $r->print(&Apache::lonhtmlcommon::breadcrumbs('User Management', - 'Course_Change_Privileges')); + 'Course_Change_Privileges')); $r->print("$lt{'usrch'}
"); $r->print(&entry_form($srch->{'srchdomain'},$srch,undef,$context)); $r->print('

'.$lt{'usel'}.'

'); } elsif ($env{'form.action'} eq 'singlestudent') { $r->print(&Apache::lonhtmlcommon::breadcrumbs('User Management', - 'Course_Add_Student')); + 'Course_Add_Student')); $r->print($jscript."$lt{'stusrch'}
"); $r->print(&entry_form($srch->{'srchdomain'},$srch,undef,$context)); $r->print('

'.$lt{'stusel'}.'

'); @@ -2446,7 +2462,6 @@ sub update_user_data { } &tool_changes('tools',\@usertools,\%oldaccess,\%oldaccesstext,\%userenv, \%changeHash,\%changed,\%newaccess,\%newaccesstext); - if ($env{'form.ccdomain'} eq $env{'request.role.domain'}) { &tool_changes('requestcourses',\@requestcourses,\%oldaccess,\%oldaccesstext, \%userenv,\%changeHash,\%changed,\%newaccess,\%newaccesstext); @@ -2693,7 +2708,7 @@ END 'aboutme' => "Personal Information Page Availability", 'portfolio' => "Portfolio Availability", 'official' => "Can Request Official Courses", - 'unofficial' => "Can Request Unofficial Course", + 'unofficial' => "Can Request Unofficial Courses", 'inststatus' => "Affiliation", ); $r->print(<<"END"); @@ -2813,48 +2828,56 @@ sub tool_changes { my %reqdisplay = &courserequest_display(); my $cdom = $env{'request.role.domain'}; foreach my $tool (@{$usertools}) { - $oldaccesstext->{$tool} = &mt('no'); + $oldaccesstext->{$tool} = &mt('No'); + $newaccesstext->{$tool} = $oldaccesstext->{$tool}; $changeHash->{$context.'.'.$tool} = $userenv->{$context.'.'.$tool}; + my $newop; + if ($env{'form.'.$context.'_'.$tool}) { + $newop = $env{'form.'.$context.'_'.$tool}; + if ($newop eq 'autolimit') { + my $limit = $env{'form.'.$context.'_'.$tool.'_limit'}; + $limit =~ s/\D+//g; + $newop .= '='.$limit; + } + } if ($userenv->{$context.'.'.$tool} eq '') { - if ($env{'form.'.$context.'_'.$tool}) { - $changed->{$tool}=&tool_admin($tool,$cdom, + if ($newop) { + $changed->{$tool}=&tool_admin($tool,$cdom.':'.$newop, $changeHash,$context); if ($changed->{$tool}) { - $newaccesstext->{$tool} = &mt('yes'); + $newaccesstext->{$tool} = &mt('Yes'); } else { - $newaccesstext->{$tool} = $oldaccesstext->{$tool}; } + $newaccesstext->{$tool} = $oldaccesstext->{$tool}; + } } } else { my @curr = split(',',$userenv->{$context.'.'.$tool}); my @new; my $changedoms; - my $newop = $env{'form.'.$context.'_'.$tool}; - if ($newop eq 'autolimit') { - $newop .= '='; - unless ($env{'form.'.$context.'_'.$tool.'_limit'} =~ /\D/) { - $newop .= $env{'form.'.$context.'_'.$tool.'_limit'}; - } - } - if (grep(/^\Q$cdom:($optregex\=?\d*)\E$/,@curr)) { - $oldaccesstext->{$tool} = &mt('yes'); - my $oldop = $1; - if ($oldop ne $newop) { - $changedoms = 1; - foreach my $dom (@curr) { - unless ($dom eq $cdom) { - push(@new,$dom); + foreach my $req (@curr) { + if ($req =~ /^\Q$cdom\E\:($optregex\=?\d*)$/) { + $oldaccesstext->{$tool} = &mt('Yes'); + my $oldop = $1; + if ($oldop ne $newop) { + $changedoms = 1; + foreach my $item (@curr) { + my ($reqdom,$option) = split(':',$item); + unless ($reqdom eq $cdom) { + push(@new,$item); + } } + if ($newop) { + push(@new,$cdom.':'.$newop); + } + @new = sort(@new); } - if ($newop) { - push(@new,$cdom.':'.$newop); - } - @new = sort(@new); + last; } - } elsif ($env{'form.'.$context.'_'.$tool}) { + } + if ((!$changedoms) && ($newop)) { $changedoms = 1; @new = sort(@curr,$cdom.':'.$newop); } - $newaccesstext->{$tool} = $oldaccesstext->{$tool}; if ($changedoms) { my $newdomstr; if (@new) { @@ -2865,10 +2888,12 @@ sub tool_changes { if ($changed->{$tool}) { if ($env{'form.'.$context.'_'.$tool}) { if ($env{'form.'.$context.'_'.$tool} eq 'autolimit') { - if ($env{'form.'.$context.'_'.$tool.'_limit'} =~ /\D/) { - $newaccesstext->{$tool} = &mt('Yes, processed automatically'); + my $limit = $env{'form.'.$context.'_'.$tool.'_limit'}; + $limit =~ s/\D+//g; + if ($limit) { + $newaccesstext->{$tool} = &mt('Yes, up to limit of [quant,_1,request] per user.',$limit); } else { - $newaccesstext->{$tool} = &mt('Yes, up to limit of [quant,_1,request] per user).',$env{'form.'.$context.'_'.$tool.'_limit'}); + $newaccesstext->{$tool} = &mt('Yes, processed automatically'); } } else { $newaccesstext->{$tool} = $reqdisplay{$env{'form.'.$context.'_'.$tool}};