--- loncom/interface/loncreateuser.pm 2009/09/05 20:17:35 1.313 +++ loncom/interface/loncreateuser.pm 2009/09/10 23:04:52 1.314 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Create a user # -# $Id: loncreateuser.pm,v 1.313 2009/09/05 20:17:35 raeburn Exp $ +# $Id: loncreateuser.pm,v 1.314 2009/09/10 23:04:52 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -261,20 +261,20 @@ sub build_tools_display { } if ($context eq 'requestcourses') { if ($userenv{$context.'.'.$item} eq '') { - $custom_access = &mt('Currently from default setting.'); + $custom_access = &mt('Currently from default setting.'); } else { $custom_access = &mt('Currently from custom setting.'); } } else { if ($userenv{$context.'.'.$item} eq '') { - $custom_access = + $custom_access = &mt('Availability determined currently from default setting.'); if (!$curr_access) { $tool_off = 'checked="checked" '; $tool_on = ''; } } else { - $custom_access = + $custom_access = &mt('Availability determined currently from custom setting.'); if ($userenv{$context.'.'.$item} == 0) { $tool_off = 'checked="checked" '; @@ -294,7 +294,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}; } @@ -328,16 +332,19 @@ sub build_tools_display { if ($option eq 'autolimit') { $custdisp .= ''; + 'value="'.$currlimit.'" />
'. + $reqtitles{'unlimited'}; + } else { + $custdisp .= ''; } - $custdisp .= ''; + $custdisp .= ''; } $custdisp .= ''; $custradio = ''.&mt('Custom setting').'
'.$custdisp; } else { $currdisp = ($curr_access?&mt('Yes'):&mt('No')); $custdisp = ' '; @@ -380,22 +387,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; @@ -410,18 +422,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; @@ -436,6 +451,7 @@ sub courserequest_titles { approval => 'Approval by Dom. Coord.', validate => 'With validation', autolimit => 'Numerical limit', + unlimited => '(blank for unlimited)', ); return %titles; } @@ -636,6 +652,7 @@ sub user_modification_js { return < // {$user}->{firstname}',". "'$srch_results->{$user}->{lastname}',". "'$srch_results->{$user}->{permanentemail}'".');"'; } else { - $onclick = + $onclick = ' onclick="javascript:pickuser('."'".$uname."'".','."'".$udom."'".');"'; } $r->print(&Apache::loncommon::start_data_table_row(). @@ -964,7 +981,6 @@ ENDTITLE &personal_data_display($ccuname,$ccdomain,$newuser,$context, $inst_results{$ccuname.':'.$ccdomain}); $r->print($personal_table); -#FIXME my ($home_server_pick,$numlib) = &Apache::loncommon::home_server_form_item($ccdomain,'hserver', 'default','hide'); @@ -1076,7 +1092,7 @@ ENDCHANGEUSER if (&Apache::lonnet::allowed('ccc',$env{'request.role.domain'})) { $r->print('

'.&mt('User Can Request Creation of Courses in this Domain?').'

'. &Apache::loncommon::start_data_table()); - if ($env{'request.role.domain'} eq $ccdomain) { + if ($env{'request.role.domain'} eq $ccdomain) { $r->print(&build_tools_display($ccuname,$ccdomain,'requestcourses')); } else { $r->print(&coursereq_externaluser($ccuname,$ccdomain, @@ -2453,8 +2469,7 @@ sub update_user_data { \%userenv,\%changeHash,\%changed,\%newaccess,\%newaccesstext); } else { &tool_changes('reqcrsotherdom',\@requestcourses,\%oldaccess,\%oldaccesstext, - \%userenv, - \%changeHash,\%changed,\%newaccess,\%newaccesstext); + \%userenv,\%changeHash,\%changed,\%newaccess,\%newaccesstext); } if ($env{'form.cfirstname'} ne $userenv{'firstname'} || $env{'form.cmiddlename'} ne $userenv{'middlename'} || @@ -2818,14 +2833,24 @@ 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}; } @@ -2834,35 +2859,32 @@ sub tool_changes { 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; + my $newdomstr; if (@new) { $newdomstr = join(',',@new); } @@ -2871,12 +2893,14 @@ 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 { + } else { $newaccesstext->{$tool} = $reqdisplay{$env{'form.'.$context.'_'.$tool}}; } } else { @@ -2895,7 +2919,7 @@ sub tool_changes { if ($newval eq 'autolimit') { $newval .= '='.$env{'form.crsreq_'.$tool.'_limit'}; } - } else { + } else { $newval = $env{'form.'.$context.'_'.$tool}; } if ($userenv->{$context.'.'.$tool} ne '') { @@ -5572,7 +5596,7 @@ sub build_search_response { my $helplink = ' href="javascript:helpMenu('."'display'".')"'; $response .= '

'; if ($context eq 'requestcrs') { - $response .= &mt("You are not authorized to defined new users in the new course's domain - [_1].",$targetdom); + $response .= &mt("You are not authorized to define new users in the new course's domain - [_1].",$targetdom); } else { $response .= &mt("You are not authorized to create new users in your current role's domain - [_1].",$targetdom); }