version 1.178, 2007/08/26 15:31:03
|
version 1.179, 2007/08/26 21:09:43
|
Line 264 ENDCUSTOM
|
Line 264 ENDCUSTOM
|
sub entry_form { |
sub entry_form { |
my ($dom,$srch,$forcenewuser) = @_; |
my ($dom,$srch,$forcenewuser) = @_; |
my $userpicker = |
my $userpicker = |
&Apache::loncommon::user_picker($dom,$srch,$forcenewuser); |
&Apache::loncommon::user_picker($dom,$srch,$forcenewuser, |
|
'document.crtuser'); |
my $srchbutton = &mt('Search'); |
my $srchbutton = &mt('Search'); |
my $output = <<"ENDDOCUMENT"; |
my $output = <<"ENDDOCUMENT"; |
<form action="/adm/createuser" method="post" name="crtuser"> |
<form action="/adm/createuser" method="post" name="crtuser"> |
<input type="hidden" name="phase" value="get_user_info" /> |
<input type="hidden" name="phase" value="get_user_info" /> |
$userpicker |
$userpicker |
<input name="userrole" type="button" value="$srchbutton" onclick="javascript:validateEntry()" /> |
<input name="userrole" type="button" value="$srchbutton" onclick="javascript:validateEntry(document.crtuser)" /> |
</form> |
</form> |
ENDDOCUMENT |
ENDDOCUMENT |
return $output; |
return $output; |
Line 305 END
|
Line 306 END
|
|
|
# =================================================================== Phase two |
# =================================================================== Phase two |
sub print_user_selection_page { |
sub print_user_selection_page { |
my ($r,$response,$srch,$srch_results) = @_; |
my ($r,$response,$srch,$srch_results,$context,$srcharray) = @_; |
my @fields = ('username','domain','lastname','firstname','permanentemail'); |
my @fields = ('username','domain','lastname','firstname','permanentemail'); |
my $sortby = $env{'form.sortby'}; |
my $sortby = $env{'form.sortby'}; |
|
|
Line 329 $jsback
|
Line 330 $jsback
|
ENDSCRIPT |
ENDSCRIPT |
|
|
my %lt=&Apache::lonlocal::texthash( |
my %lt=&Apache::lonlocal::texthash( |
'srch' => "User Search to add/modify roles", |
'usrch' => "User Search to add/modify roles", |
|
'stusrch' => "User Search to enroll student", |
|
'usel' => "Select a user to add/modify roles", |
|
'stusel' => "Select a user to enroll as a student", |
'username' => "username", |
'username' => "username", |
'domain' => "domain", |
'domain' => "domain", |
'lastname' => "last name", |
'lastname' => "last name", |
'firstname' => "first name", |
'firstname' => "first name", |
'permanentemail' => "permanent e-mail", |
'permanentemail' => "permanent e-mail", |
); |
); |
$r->print(&Apache::loncommon::start_page('Create Users, Change User Privileges',$jscript)); |
if ($context eq 'createuser') { |
&Apache::lonhtmlcommon::add_breadcrumb |
$r->print(&Apache::loncommon::start_page('Create Users, Change User Privileges',$jscript)); |
({href=>"javascript:backPage(document.usersrchform,'','')", |
&Apache::lonhtmlcommon::add_breadcrumb |
text=>"User modify/custom role edit", |
({href=>"javascript:backPage(document.usersrchform,'','')", |
faq=>282,bug=>'Instructor Interface',}, |
text=>"User modify/custom role edit", |
{href=>"javascript:backPage(document.usersrchform,'get_user_info','select')", |
faq=>282,bug=>'Instructor Interface',}, |
text=>"Select User", |
{href=>"javascript:backPage(document.usersrchform,'get_user_info','select')", |
faq=>282,bug=>'Instructor Interface',}); |
text=>"Select User", |
$r->print(&Apache::lonhtmlcommon::breadcrumbs('User Management')); |
faq=>282,bug=>'Instructor Interface',}); |
$r->print("<b>$lt{'srch'}</b><br />"); |
$r->print(&Apache::lonhtmlcommon::breadcrumbs('User Management')); |
$r->print(&entry_form($srch->{'srchdomain'},$srch)); |
$r->print("<b>$lt{'usrch'}</b><br />"); |
$r->print('<h3>'.&mt('Select a user to add/modify roles').'</h3>'); |
$r->print(&entry_form($srch->{'srchdomain'},$srch)); |
|
$r->print('<h3>'.$lt{'usel'}.'</h3>'); |
|
} else { |
|
$r->print($jscript."<b>$lt{'stusrch'}</b><br />"); |
|
$r->print(&Apache::londropadd::single_user_entry_form($srch->{'srchdomain'},$srch)); |
|
$r->print('</form><h3>'.$lt{'stusel'}.'</h3>'); |
|
} |
$r->print('<form name="usersrchform" method="post">'. |
$r->print('<form name="usersrchform" method="post">'. |
&Apache::loncommon::start_data_table()."\n". |
&Apache::loncommon::start_data_table()."\n". |
&Apache::loncommon::start_data_table_header_row()."\n". |
&Apache::loncommon::start_data_table_header_row()."\n". |
Line 381 ENDSCRIPT
|
Line 391 ENDSCRIPT
|
$r->print(&Apache::loncommon::end_data_table_row()); |
$r->print(&Apache::loncommon::end_data_table_row()); |
} |
} |
$r->print(&Apache::loncommon::end_data_table().'<br /><br />'); |
$r->print(&Apache::loncommon::end_data_table().'<br /><br />'); |
$r->print(&Apache::lonhtmlcommon::echo_form_input(['sortby','seluname','seludom','state','phase'])); |
if (ref($srcharray) eq 'ARRAY') { |
|
foreach my $item (@{$srcharray}) { |
|
$r->print('<input type="hidden" name="'.$item.'" value="'.$env{'form.'.$item}.'" />'."\n"); |
|
} |
|
} |
$r->print(' <input type="hidden" name="sortby" value="'.$sortby.'" />'."\n". |
$r->print(' <input type="hidden" name="sortby" value="'.$sortby.'" />'."\n". |
' <input type="hidden" name="seluname" value="" />'."\n". |
' <input type="hidden" name="seluname" value="" />'."\n". |
' <input type="hidden" name="seludom" value="" />'."\n". |
' <input type="hidden" name="seludom" value="" />'."\n". |
' <input type="hidden" name="state" value="select" />'."\n". |
' <input type="hidden" name="currstate" value="select" />'."\n". |
' <input type="hidden" name="phase" value="get_user_info" />'."\n". |
' <input type="hidden" name="phase" value="get_user_info" />'."\n"); |
'</form>'); |
|
$r->print($response); |
$r->print($response); |
$r->print(&Apache::loncommon::end_page()); |
if ($context eq 'createuser') { |
|
$r->print('</form>'.&Apache::loncommon::end_page()); |
|
} else { |
|
$r->print('<input type="hidden" name="action" value="enrollstudent" />'."\n". |
|
'<input type="hidden" name="state" value="gotusername" />'."\n"); |
|
} |
} |
} |
|
|
sub print_user_query_page { |
sub print_user_query_page { |
my ($r) = @_; |
my ($r,$caller) = @_; |
# FIXME - this is for a network-wide name search (similar to catalog search) |
# FIXME - this is for a network-wide name search (similar to catalog search) |
# To use frames with similar behavior to catalog/portfolio search. |
# To use frames with similar behavior to catalog/portfolio search. |
# To be implemented. |
# To be implemented. |
Line 1204 ENDNOPRIV
|
Line 1222 ENDNOPRIV
|
$r->print(&course_level_table(%inccourses)); |
$r->print(&course_level_table(%inccourses)); |
$r->print('<hr /><input type="button" value="'.&mt('Modify User').'" onClick="setSections()" />'."\n"); |
$r->print('<hr /><input type="button" value="'.&mt('Modify User').'" onClick="setSections()" />'."\n"); |
} |
} |
$r->print(&Apache::lonhtmlcommon::echo_form_input(['phase','userrole','ccdomain','prevphase','state'])); |
$r->print(&Apache::lonhtmlcommon::echo_form_input(['phase','userrole','ccdomain','prevphase','currstate'])); |
$r->print('<input type="hidden" name="state" value="" />'); |
$r->print('<input type="hidden" name="currstate" value="" />'); |
$r->print('<input type="hidden" name="prevphase" value="'.$env{'form.phase'}.'" />'); |
$r->print('<input type="hidden" name="prevphase" value="'.$env{'form.phase'}.'" />'); |
$r->print("</form>".&Apache::loncommon::end_page()); |
$r->print("</form>".&Apache::loncommon::end_page()); |
} |
} |
Line 1750 END
|
Line 1768 END
|
} |
} |
} |
} |
$r->print('<input type="hidden" name="phase" value="" />'."\n". |
$r->print('<input type="hidden" name="phase" value="" />'."\n". |
'<input type ="hidden" name="state" value="" />'."\n". |
'<input type ="hidden" name="currstate" value="" />'."\n". |
'</form>'); |
'</form>'); |
$r->print(&Apache::loncommon::end_page()); |
$r->print(&Apache::loncommon::end_page()); |
} |
} |
Line 1949 ENDCCF
|
Line 1967 ENDCCF
|
} |
} |
$r->print(&Apache::loncommon::end_data_table(). |
$r->print(&Apache::loncommon::end_data_table(). |
'<input type="hidden" name="startrolename" value="'.$env{'form.rolename'}. |
'<input type="hidden" name="startrolename" value="'.$env{'form.rolename'}. |
'" />'."\n".'<input type="hidden" name="state" value="" />'."\n". |
'" />'."\n".'<input type="hidden" name="currstate" value="" />'."\n". |
'<input type="reset" value="'.&mt("Reset").'" />'."\n". |
'<input type="reset" value="'.&mt("Reset").'" />'."\n". |
'<input type="submit" value="'.&mt('Define Role').'" /></form>'. |
'<input type="submit" value="'.&mt('Define Role').'" /></form>'. |
&Apache::loncommon::end_page()); |
&Apache::loncommon::end_page()); |
Line 2142 sub handler {
|
Line 2160 sub handler {
|
$srch->{$item} = $env{'form.'.$item}; |
$srch->{$item} = $env{'form.'.$item}; |
} |
} |
if ($env{'form.phase'} eq 'get_user_info') { |
if ($env{'form.phase'} eq 'get_user_info') { |
my ($state,$response,$forcenewuser,$results) = |
my ($currstate,$response,$forcenewuser,$results) = |
&user_search_result($srch); |
&user_search_result($srch); |
if ($state eq 'select') { |
if ($currstate eq 'select') { |
&print_user_selection_page($r,$response,$srch,$results); |
&print_user_selection_page($r,$response,$srch,$results,'createuser',\@search); |
} elsif ($state eq 'modify') { |
} elsif ($currstate eq 'modify') { |
my ($ccuname,$ccdomain); |
my ($ccuname,$ccdomain); |
if (($srch->{'srchby'} eq 'uname') && |
if (($srch->{'srchby'} eq 'uname') && |
($srch->{'srchtype'} eq 'exact')) { |
($srch->{'srchtype'} eq 'exact')) { |
Line 2160 sub handler {
|
Line 2178 sub handler {
|
$ccdomain=&LONCAPA::clean_domain($ccdomain); |
$ccdomain=&LONCAPA::clean_domain($ccdomain); |
&print_user_modification_page($r,$ccuname,$ccdomain,$srch, |
&print_user_modification_page($r,$ccuname,$ccdomain,$srch, |
$response); |
$response); |
} elsif ($state eq 'query') { |
} elsif ($currstate eq 'query') { |
&print_user_query_page($r); |
&print_user_query_page($r,'createuser'); |
} else { |
} else { |
&print_username_entry_form($r,$response,$srch,$forcenewuser); |
&print_username_entry_form($r,$response,$srch,$forcenewuser); |
} |
} |
Line 2193 sub user_search_result {
|
Line 2211 sub user_search_result {
|
my %allhomes; |
my %allhomes; |
my %inst_matches; |
my %inst_matches; |
my %srch_results; |
my %srch_results; |
my ($response,$state,$forcenewuser); |
my ($response,$currstate,$forcenewuser); |
$srch->{'srchterm'} =~ s/^\s+//; |
$srch->{'srchterm'} =~ s/^\s+//; |
$srch->{'srchterm'} =~ s/\s+$//; |
$srch->{'srchterm'} =~ s/\s+$//; |
|
|
Line 2230 sub user_search_result {
|
Line 2248 sub user_search_result {
|
} |
} |
} |
} |
if ($response ne '') { |
if ($response ne '') { |
return ($state,'<span class="LC_warning">'.$response.'</span>'); |
return ($currstate,'<span class="LC_warning">'.$response.'</span>'); |
} |
} |
if ($srch->{'srchby'} eq 'uname') { |
if ($srch->{'srchby'} eq 'uname') { |
if (($srch->{'srchin'} eq 'dom') || ($srch->{'srchin'} eq 'crs')) { |
if (($srch->{'srchin'} eq 'dom') || ($srch->{'srchin'} eq 'crs')) { |
Line 2241 sub user_search_result {
|
Line 2259 sub user_search_result {
|
my $domdesc = &Apache::lonnet::domain($env{'request.role.domain'},'description'); |
my $domdesc = &Apache::lonnet::domain($env{'request.role.domain'},'description'); |
$response = &mt('New users can only be created in the domain to which you current role belongs - [_1].',$env{'request.role.domain'}.' ('.$domdesc.')'); |
$response = &mt('New users can only be created in the domain to which you current role belongs - [_1].',$env{'request.role.domain'}.' ('.$domdesc.')'); |
} else { |
} else { |
$state = 'modify'; |
$currstate = 'modify'; |
} |
} |
} else { |
} else { |
$state = 'modify'; |
$currstate = 'modify'; |
} |
} |
} else { |
} else { |
if ($srch->{'srchin'} eq 'dom') { |
if ($srch->{'srchin'} eq 'dom') { |
if ($srch->{'srchtype'} eq 'exact') { |
if ($srch->{'srchtype'} eq 'exact') { |
my $uhome=&Apache::lonnet::homeserver($srch->{'srchterm'},$srch->{'srchdomain'}); |
my $uhome=&Apache::lonnet::homeserver($srch->{'srchterm'},$srch->{'srchdomain'}); |
if ($uhome eq 'no_host') { |
if ($uhome eq 'no_host') { |
($state,$response,$forcenewuser) = |
($currstate,$response,$forcenewuser) = |
&build_search_response($srch,%srch_results); |
&build_search_response($srch,%srch_results); |
} else { |
} else { |
$state = 'modify'; |
$currstate = 'modify'; |
} |
} |
} else { |
} else { |
%srch_results = &Apache::lonnet::usersearch($srch); |
%srch_results = &Apache::lonnet::usersearch($srch); |
($state,$response,$forcenewuser) = |
($currstate,$response,$forcenewuser) = |
&build_search_response($srch,%srch_results); |
&build_search_response($srch,%srch_results); |
} |
} |
} else { |
} else { |
my $courseusers = &get_courseusers(); |
my $courseusers = &get_courseusers(); |
if ($srch->{'srchtype'} eq 'exact') { |
if ($srch->{'srchtype'} eq 'exact') { |
if (exists($courseusers->{$srch->{'srchterm'}.':'.$srch->{'srchdomain'}})) { |
if (exists($courseusers->{$srch->{'srchterm'}.':'.$srch->{'srchdomain'}})) { |
$state = 'modify'; |
$currstate = 'modify'; |
} else { |
} else { |
($state,$response,$forcenewuser) = |
($currstate,$response,$forcenewuser) = |
&build_search_response($srch,%srch_results); |
&build_search_response($srch,%srch_results); |
} |
} |
} else { |
} else { |
Line 2293 sub user_search_result {
|
Line 2311 sub user_search_result {
|
} |
} |
} |
} |
} |
} |
($state,$response,$forcenewuser) = |
($currstate,$response,$forcenewuser) = |
&build_search_response($srch,%srch_results); |
&build_search_response($srch,%srch_results); |
} |
} |
} |
} |
} |
} |
} elsif ($srch->{'srchin'} eq 'alc') { |
} elsif ($srch->{'srchin'} eq 'alc') { |
$state = 'query'; |
$currstate = 'query'; |
} elsif ($srch->{'srchin'} eq 'instd') { |
} elsif ($srch->{'srchin'} eq 'instd') { |
%srch_results = &Apache::lonnet::inst_directory_query($srch); |
%srch_results = &Apache::lonnet::inst_directory_query($srch); |
($state,$response,$forcenewuser) = |
($currstate,$response,$forcenewuser) = |
&build_search_response($srch,%srch_results); |
&build_search_response($srch,%srch_results); |
} |
} |
} else { |
} else { |
if ($srch->{'srchin'} eq 'dom') { |
if ($srch->{'srchin'} eq 'dom') { |
%srch_results = &Apache::lonnet::usersearch($srch); |
%srch_results = &Apache::lonnet::usersearch($srch); |
($state,$response,$forcenewuser) = |
($currstate,$response,$forcenewuser) = |
&build_search_response($srch,%srch_results); |
&build_search_response($srch,%srch_results); |
} elsif ($srch->{'srchin'} eq 'crs') { |
} elsif ($srch->{'srchin'} eq 'crs') { |
my $courseusers = &get_courseusers(); |
my $courseusers = &get_courseusers(); |
Line 2360 sub user_search_result {
|
Line 2378 sub user_search_result {
|
} |
} |
} |
} |
} |
} |
($state,$response,$forcenewuser) = |
($currstate,$response,$forcenewuser) = |
&build_search_response($srch,%srch_results); |
&build_search_response($srch,%srch_results); |
} elsif ($srch->{'srchin'} eq 'alc') { |
} elsif ($srch->{'srchin'} eq 'alc') { |
$state = 'query'; |
$currstate = 'query'; |
} elsif ($srch->{'srchin'} eq 'instd') { |
} elsif ($srch->{'srchin'} eq 'instd') { |
%srch_results = &Apache::lonnet::inst_directory_query($srch); |
%srch_results = &Apache::lonnet::inst_directory_query($srch); |
($state,$response,$forcenewuser) = |
($currstate,$response,$forcenewuser) = |
&build_search_response($srch,%srch_results); |
&build_search_response($srch,%srch_results); |
} |
} |
} |
} |
return ($state,$response,$forcenewuser,\%srch_results); |
return ($currstate,$response,$forcenewuser,\%srch_results); |
} |
} |
|
|
sub directorysrch_check { |
sub directorysrch_check { |
Line 2467 sub get_courseusers {
|
Line 2485 sub get_courseusers {
|
|
|
sub build_search_response { |
sub build_search_response { |
my ($srch,%srch_results) = @_; |
my ($srch,%srch_results) = @_; |
my ($state,$response,$forcenewuser); |
my ($currstate,$response,$forcenewuser); |
my %names = ( |
my %names = ( |
'uname' => 'username', |
'uname' => 'username', |
'lastname' => 'last name', |
'lastname' => 'last name', |
Line 2486 sub build_search_response {
|
Line 2504 sub build_search_response {
|
exact => 'No exact match', |
exact => 'No exact match', |
); |
); |
if (keys(%srch_results) > 1) { |
if (keys(%srch_results) > 1) { |
$state = 'select'; |
$currstate = 'select'; |
} else { |
} else { |
if (keys(%srch_results) == 1) { |
if (keys(%srch_results) == 1) { |
$state = 'modify'; |
$currstate = 'modify'; |
$response = &mt("$single{$srch->{'srchtype'}} was found for this $names{$srch->{'srchby'}} ([_1]) in $names{$srch->{'srchin'}}.",$srch->{'srchterm'}); |
$response = &mt("$single{$srch->{'srchtype'}} was found for this $names{$srch->{'srchby'}} ([_1]) in $names{$srch->{'srchin'}}.",$srch->{'srchterm'}); |
} else { |
} else { |
$response = '<span class="LC_warning">'.&mt("$nomatch{$srch->{'srchtype'}} found for this $names{$srch->{'srchby'}} ([_1]) in $names{$srch->{'srchin'}}.",$srch->{'srchterm'}).'</span>'; |
$response = '<span class="LC_warning">'.&mt("$nomatch{$srch->{'srchtype'}} found for this $names{$srch->{'srchby'}} ([_1]) in $names{$srch->{'srchin'}}.",$srch->{'srchterm'}).'</span>'; |
Line 2517 sub build_search_response {
|
Line 2535 sub build_search_response {
|
} |
} |
} |
} |
} |
} |
return ($state,$response,$forcenewuser); |
return ($currstate,$response,$forcenewuser); |
} |
} |
|
|
sub crumb_utilities { |
sub crumb_utilities { |
Line 2533 sub crumb_utilities {
|
Line 2551 sub crumb_utilities {
|
rolename => 'selectbox', |
rolename => 'selectbox', |
newrolename => 'textbox', |
newrolename => 'textbox', |
}, |
}, |
|
studentform => { |
|
srchterm => 'text', |
|
srchin => 'selectbox', |
|
srchby => 'selectbox', |
|
srchtype => 'selectbox', |
|
srchdomain => 'selectbox', |
|
}, |
); |
); |
|
|
my $jsback .= qq| |
my $jsback .= qq| |
function backPage(formname,prevphase,prevstate) { |
function backPage(formname,prevphase,prevstate) { |
formname.phase.value = prevphase; |
formname.phase.value = prevphase; |
formname.state.value = prevstate; |
formname.currstate.value = prevstate; |
formname.submit(); |
formname.submit(); |
} |
} |
|; |
|; |