--- loncom/interface/loncreateuser.pm 2014/12/11 01:20:50 1.404 +++ loncom/interface/loncreateuser.pm 2016/09/27 21:47:48 1.413 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Create a user # -# $Id: loncreateuser.pm,v 1.404 2014/12/11 01:20:50 raeburn Exp $ +# $Id: loncreateuser.pm,v 1.413 2016/09/27 21:47:48 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -251,13 +251,15 @@ sub build_tools_display { 'unofficial' => 'Can request creation of unofficial courses', 'community' => 'Can request creation of communities', 'textbook' => 'Can request creation of textbook courses', + 'placement' => 'Can request creation of placement tests', 'requestauthor' => 'Can request author space', ); if ($context eq 'requestcourses') { %userenv = &Apache::lonnet::userenvironment($ccdomain,$ccuname, 'requestcourses.official','requestcourses.unofficial', - 'requestcourses.community','requestcourses.textbook'); - @usertools = ('official','unofficial','community','textbook'); + 'requestcourses.community','requestcourses.textbook', + 'requestcourses.placement'); + @usertools = ('official','unofficial','community','textbook','placement'); @options =('norequest','approval','autolimit','validate'); %validations = &Apache::lonnet::auto_courserequest_checks($ccdomain); %reqtitles = &courserequest_titles(); @@ -447,12 +449,14 @@ sub coursereq_externaluser { 'unofficial' => 'Can request creation of unofficial courses', 'community' => 'Can request creation of communities', 'textbook' => 'Can request creation of textbook courses', + 'placement' => 'Can request creation of placement tests', ); %userenv = &Apache::lonnet::userenvironment($ccdomain,$ccuname, 'reqcrsotherdom.official','reqcrsotherdom.unofficial', - 'reqcrsotherdom.community','reqcrsotherdom.textbook'); - @usertools = ('official','unofficial','community','textbook'); + 'reqcrsotherdom.community','reqcrsotherdom.textbook', + 'reqcrsotherdom.placement'); + @usertools = ('official','unofficial','community','textbook','placement'); @options = ('approval','validate','autolimit'); %validations = &Apache::lonnet::auto_courserequest_checks($cdom); my $optregex = join('|',@options); @@ -533,6 +537,7 @@ sub courserequest_titles { unofficial => 'Unofficial', community => 'Communities', textbook => 'Textbook', + placement => 'Placement Tests', norequest => 'Not allowed', approval => 'Approval by Dom. Coord.', validate => 'With validation', @@ -813,7 +818,7 @@ sub entry_form { } my $cancreate = &Apache::lonuserutils::can_create_user($dom,$context,$usertype); - my $userpicker = + my ($userpicker,$cansearch) = &Apache::loncommon::user_picker($dom,$srch,$forcenewuser, 'document.crtuser',$cancreate,$usertype); my $srchbutton = &mt('Search'); @@ -822,7 +827,9 @@ sub entry_form { } elsif ($cancreate && $responsemsg ne '' && $inexact) { $srchbutton = &mt('Search or Add New User'); } - my $output = <<"ENDBLOCK"; + my $output; + if ($cansearch) { + $output = <<"ENDBLOCK";
@@ -830,6 +837,9 @@ $userpicker
ENDBLOCK + } else { + $output = '

'.$userpicker.'

'; + } if ($env{'form.phase'} eq '') { my $defdom=$env{'request.role.domain'}; my $domform = &Apache::loncommon::select_dom_form($defdom,'srchdomain'); @@ -2244,8 +2254,8 @@ sub personal_data_display { ''; $rowcount ++; $output .= &Apache::lonhtmlcommon::row_closure(1); - my $upassone = ''; - my $upasstwo = ''; + my $upassone = ''; + my $upasstwo = ''; $output .= &Apache::lonhtmlcommon::row_title(&mt('Password').'*', 'LC_pick_box_title', 'LC_oddrow_value')."\n". @@ -2351,7 +2361,7 @@ sub personal_data_display { } if (($context eq 'selfcreate') && ($newuser eq 'email')) { if ($captchaform) { - $output .= &Apache::lonhtmlcommon::row_title($lt{'valid'}, + $output .= &Apache::lonhtmlcommon::row_title($lt{'valid'}.'*', 'LC_pick_box_title')."\n". $captchaform."\n".'

'. &Apache::lonhtmlcommon::row_closure(1); @@ -2579,7 +2589,7 @@ sub update_user_data { my (%alerts,%rulematch,%inst_results,%curr_rules); my @userinfo = ('firstname','middlename','lastname','generation','permanentemail','id'); my @usertools = ('aboutme','blog','webdav','portfolio'); - my @requestcourses = ('official','unofficial','community','textbook'); + my @requestcourses = ('official','unofficial','community','textbook','placement'); my @requestauthor = ('requestauthor'); my ($othertitle,$usertypes,$types) = &Apache::loncommon::sorted_inst_types($env{'form.ccdomain'}); @@ -2752,7 +2762,7 @@ sub update_user_data { 'requestcourses.community','requestcourses.textbook', 'reqcrsotherdom.official','reqcrsotherdom.unofficial', 'reqcrsotherdom.community','reqcrsotherdom.textbook', - 'requestauthor'], + 'reqcrsotherdom.placement','requestauthor'], $env{'form.ccdomain'},$env{'form.ccuname'}); my ($tmp) = keys(%userenv); if ($tmp =~ /^(con_lost|error)/i) { @@ -3043,8 +3053,9 @@ sub update_user_data { ($env{'user.domain'} eq $env{'form.ccdomain'})) { my %newenvhash; foreach my $key (keys(%changed)) { - if (($key eq 'official') || ($key eq 'unofficial') - || ($key eq 'community') || ($key eq 'textbook')) { + if (($key eq 'official') || ($key eq 'unofficial') || + ($key eq 'community') || ($key eq 'textbook') || + ($key eq 'placement')) { $newenvhash{'environment.requestcourses.'.$key} = $changeHash{'requestcourses.'.$key}; if ($changeHash{'requestcourses.'.$key}) { @@ -3110,7 +3121,7 @@ sub update_user_data { \%newsettingstext); if ($env{'form.cid'} ne $userenv{'id'}) { &Apache::lonnet::idput($env{'form.ccdomain'}, - ($env{'form.ccuname'} => $env{'form.cid'})); + {$env{'form.ccuname'} => $env{'form.cid'}},$uhome,'ids'); if (($recurseid) && (&Apache::lonnet::allowed('mau',$env{'form.ccdomain'}))) { my $idresult = @@ -3253,6 +3264,7 @@ sub display_userinfo { 'unofficial' => 'Can Request Unofficial Courses', 'community' => 'Can Request Communities', 'textbook' => 'Can Request Textbook Courses', + 'placement' => 'Can Request Placement Tests', 'requestauthor' => 'Can Request Author Role', 'inststatus' => "Affiliation", 'prvs' => 'Previous Value:', @@ -5400,6 +5412,7 @@ sub print_main_menu { groups => 'Community Groups', }, ); + $linktext{'Placement'} = $linktext{'Course'}; my %linktitle = ( 'Course' => { @@ -5414,6 +5427,8 @@ sub print_main_menu { }, ); + $linktitle{'Placement'} = $linktitle{'Course'}; + push(@{ $menu[0]->{items} }, #Category: Single Users { linktext => $linktext{$crstype}{'single'}, @@ -5544,6 +5559,7 @@ sub print_selfenroll_menu { butn => 'but no user types have been checked.', wilf => "Please uncheck 'activate' or check at least one type.", ); + &js_escape(\%alerts); my $selfenroll_js = <<"ENDSCRIPT"; function update_types(caller,num) { var delidx = getIndexByName('selfenroll_delete'); @@ -5745,6 +5761,12 @@ ENDSCRIPT $cathash = $domconfig{'coursecategories'}{'cats'}; $cattype{'auth'} = $domconfig{'coursecategories'}{'auth'}; $cattype{'unauth'} = $domconfig{'coursecategories'}{'unauth'}; + if ($cattype{'auth'} eq '') { + $cattype{'auth'} = 'std'; + } + if ($cattype{'unauth'} eq '') { + $cattype{'unauth'} = 'std'; + } } else { $cathash = {}; $cattype{'auth'} = 'std'; @@ -6816,13 +6838,29 @@ sub user_search_result { } } if ($response ne '') { - $response = ''.$response.''; + $response = ''.$response.'
'; } if ($srch->{'srchin'} eq 'instd') { - my $instd_chk = &directorysrch_check($srch); + my $instd_chk = &instdirectorysrch_check($srch); if ($instd_chk ne 'ok') { - $response = ''.$instd_chk.''. - '
'.&mt('You may want to search in the LON-CAPA domain instead of the institutional directory.').'

'; + my $domd_chk = &domdirectorysrch_check($srch); + $response .= ''.$instd_chk.'
'; + if ($domd_chk eq 'ok') { + $response .= &mt('You may want to search in the LON-CAPA domain instead of the institutional directory.'); + } + $response .= '

'; + } + } else { + unless (($context eq 'requestcrs') && ($srch->{'srchtype'} eq 'exact')) { + my $domd_chk = &domdirectorysrch_check($srch); + if ($domd_chk ne 'ok') { + my $instd_chk = &instdirectorysrch_check($srch); + $response .= ''.$domd_chk.'
'; + if ($instd_chk eq 'ok') { + $response .= &mt('You may want to search in the institutional directory instead of the LON-CAPA domain.'); + } + $response .= '

'; + } } } if ($response ne '') { @@ -6986,7 +7024,8 @@ sub user_search_result { ($currstate,$response,$forcenewuser) = &build_search_response($context,$srch,%srch_results); } else { - my $showdom = &display_domain_info($srch->{'srchdomain'}); $response = ''. + my $showdom = &display_domain_info($srch->{'srchdomain'}); + $response = ''. &mt('Institutional directory search is not available in domain: [_1]',$showdom). '
'. &mt('You may want to search in the LON-CAPA domain instead of the institutional directory.'). @@ -6997,7 +7036,26 @@ sub user_search_result { return ($currstate,$response,$forcenewuser,\%srch_results); } -sub directorysrch_check { +sub domdirectorysrch_check { + my ($srch) = @_; + my $response; + my %dom_inst_srch = &Apache::lonnet::get_dom('configuration', + ['directorysrch'],$srch->{'srchdomain'}); + my $showdom = &display_domain_info($srch->{'srchdomain'}); + if (ref($dom_inst_srch{'directorysrch'}) eq 'HASH') { + if ($dom_inst_srch{'directorysrch'}{'lcavailable'} eq '0') { + return &mt('LON-CAPA directory search is not available in domain: [_1]',$showdom); + } + if ($dom_inst_srch{'directorysrch'}{'lclocalonly'}) { + if ($env{'request.role.domain'} ne $srch->{'srchdomain'}) { + return &mt('LON-CAPA directory search in domain: [_1] is only allowed for users with a current role in the domain.',$showdom); + } + } + } + return 'ok'; +} + +sub instdirectorysrch_check { my ($srch) = @_; my $can_search = 0; my $response;