--- loncom/interface/lonpickuser.pm 2009/08/04 20:08:34 1.1 +++ loncom/interface/lonpickuser.pm 2009/08/19 19:57:53 1.3 @@ -1,7 +1,7 @@ # The LearningOnline Network # Search for a user # -# $Id: lonpickuser.pm,v 1.1 2009/08/04 20:08:34 raeburn Exp $ +# $Id: lonpickuser.pm,v 1.3 2009/08/19 19:57:53 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -71,15 +71,36 @@ sub handler { # Get parameters from query string &Apache::loncommon::get_unprocessed_cgi ($ENV{'QUERY_STRING'},['srchdom','form','udomelement','unameelement','ulastelement', - 'ufirstelement','uemailelement','hideudomelement']); + 'ufirstelement','uemailelement','hideudomelement','coursedom']); my $js; - if ($env{'form.phase'} eq 'get_user_info') { + if (($env{'form.phase'} eq 'get_user_info') || + ($env{'form.phase'} eq 'store_newuser')) { $js = &gochoose_javascript(); + } elsif ($env{'form.phase'} eq 'define_newuser') { + $js = <<"ENDSP"; + +ENDSP } - - $r->print(&Apache::loncommon::start_page('Selecting course personnel',$js, - {'no_nav_bar' => 1, })); + my $startargs = {'no_nav_bar' => 1, }; + if ($env{'form.phase'} eq 'store_newuser') { + my $uname = $env{'form.srchterm'}; + my $udom = $env{'form.srchdomain'}; + my $newfirst = $env{'form.newfirst'}; + my $newlast = $env{'form.newlast'}; + my $newemail = $env{'form.newemail'}; + $startargs->{'add_entries'} = { onload => 'javascript:gochoose('."'$uname','$udom','$newfirst','$newlast','$newemail'".');' }; + } + $r->print(&Apache::loncommon::start_page('Selecting course personnel', + $js,$startargs)); my %toset = ( uname => 'unameelement', udom => 'udomelement', @@ -108,7 +129,7 @@ sub handler { $srch{'srchterm'},$rules); } - my $dom = $env{'form.srchdom'}; + my $dom = $env{'form.coursedom'}; my $cancreate = &Apache::lonuserutils::can_create_user($dom,$context,$usertype); @@ -118,22 +139,26 @@ sub handler { my $srchbutton = &mt('Search'); my $headertext = &mt('Search for a user to add to course personnel'); - my $opener_elems; + my $opener_elems = ''."\n". + ''."\n"; foreach my $item (keys(%toset)) { if (exists($env{'form.'.$toset{$item}})) { $opener_elems .= ''."\n"; } - } - $r->print(<<"ENDBLOCK"); + } + unless ($env{'form.phase'} eq 'define_newuser') { + $r->print(<<"ENDBLOCK");