--- loncom/interface/lonpickuser.pm 2009/08/19 19:57:53 1.3 +++ loncom/interface/lonpickuser.pm 2011/01/05 18:39:38 1.5 @@ -1,7 +1,7 @@ # The LearningOnline Network # Search for a user # -# $Id: lonpickuser.pm,v 1.3 2009/08/19 19:57:53 raeburn Exp $ +# $Id: lonpickuser.pm,v 1.5 2011/01/05 18:39:38 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -71,7 +71,7 @@ sub handler { # Get parameters from query string &Apache::loncommon::get_unprocessed_cgi ($ENV{'QUERY_STRING'},['srchdom','form','udomelement','unameelement','ulastelement', - 'ufirstelement','uemailelement','hideudomelement','coursedom']); + 'ufirstelement','uemailelement','hideudomelement','coursedom','caller']); my $js; if (($env{'form.phase'} eq 'get_user_info') || @@ -89,6 +89,77 @@ function setphase(caller) { // ]]> ENDSP + } elsif ($env{'form.caller'} eq 'checkusername') { + $js = <<"ENDCHK"; + +ENDCHK + } elsif ($env{'form.phase'} eq '') { + $js = <<"ENDSET"; + +ENDSET } my $startargs = {'no_nav_bar' => 1, }; if ($env{'form.phase'} eq 'store_newuser') { @@ -98,9 +169,18 @@ ENDSP my $newlast = $env{'form.newlast'}; my $newemail = $env{'form.newemail'}; $startargs->{'add_entries'} = { onload => 'javascript:gochoose('."'$uname','$udom','$newfirst','$newlast','$newemail'".');' }; + } elsif ($env{'form.caller'} eq 'checkusername') { + $startargs->{'add_entries'} = { onload => 'javascript:checkUser();' }; + } elsif ($env{'form.phase'} eq '') { + $startargs->{'add_entries'} = { onload => 'javascript:setUserSearch();' }; } $r->print(&Apache::loncommon::start_page('Selecting course personnel', $js,$startargs)); + if ($env{'form.caller'} eq 'checkusername') { + $r->print(&check_user_form(). + &Apache::loncommon::end_page()); + return OK; + } my %toset = ( uname => 'unameelement', udom => 'udomelement', @@ -123,10 +203,12 @@ ENDSP ($srch{'srchtype'} eq 'exact') && ($srch{'srchdomain'} ne '') && ($srch{'srchterm'} ne '')) { + my (%curr_rules,%got_rules); my ($rules,$ruleorder) = &Apache::lonnet::inst_userrules($srch{'srchdomain'},'username'); $usertype = &Apache::lonuserutils::check_usertype($srch{'srchdomain'}, - $srch{'srchterm'},$rules); + $srch{'srchterm'},$rules, + \%curr_rules,\%got_rules); } my $dom = $env{'form.coursedom'}; @@ -135,19 +217,16 @@ ENDSP &Apache::lonuserutils::can_create_user($dom,$context,$usertype); my $userpicker = &Apache::loncommon::user_picker($dom,\%srch,$forcenewuser, - 'document.userpicker',$cancreate,$usertype); + 'document.userpicker',$cancreate, + $usertype,$context); my $srchbutton = &mt('Search'); my $headertext = &mt('Search for a user to add to course personnel'); my $opener_elems = ''."\n". ''."\n"; - foreach my $item (keys(%toset)) { - if (exists($env{'form.'.$toset{$item}})) { - $opener_elems .= ''."\n"; - } - } + $env{'form.coursedom'}.'" />'."\n". + &set_opener_elems(); unless ($env{'form.phase'} eq 'define_newuser') { $r->print(<<"ENDBLOCK");