version 1.166, 2007/08/02 01:02:56
|
version 1.187, 2007/09/19 06:24:26
|
Line 68 use Apache::longroup;
|
Line 68 use Apache::longroup;
|
use LONCAPA qw(:DEFAULT :match); |
use LONCAPA qw(:DEFAULT :match); |
|
|
my $loginscript; # piece of javascript used in two separate instances |
my $loginscript; # piece of javascript used in two separate instances |
my $generalrule; |
|
my $authformnop; |
my $authformnop; |
my $authformkrb; |
my $authformkrb; |
my $authformint; |
my $authformint; |
Line 76 my $authformfsys;
|
Line 75 my $authformfsys;
|
my $authformloc; |
my $authformloc; |
|
|
sub initialize_authen_forms { |
sub initialize_authen_forms { |
|
my ($dom,$curr_authtype) = @_; |
my ($krbdefdom)=( $ENV{'SERVER_NAME'}=~/(\w+\.\w+)$/); |
my ($krbdefdom)=( $ENV{'SERVER_NAME'}=~/(\w+\.\w+)$/); |
$krbdefdom= uc($krbdefdom); |
$krbdefdom= uc($krbdefdom); |
my %param = ( formname => 'document.cu', |
my %param = ( formname => 'document.cu', |
kerb_def_dom => $krbdefdom |
kerb_def_dom => $krbdefdom, |
); |
domain => $dom, |
|
); |
|
if ($curr_authtype =~ /^(krb4|krb5|internal|localauth|unix):$/) { |
|
$param{'curr_authtype'} = $curr_authtype; |
|
} |
# no longer static due to configurable kerberos defaults |
# no longer static due to configurable kerberos defaults |
# $loginscript = &Apache::loncommon::authform_header(%param); |
# $loginscript = &Apache::loncommon::authform_header(%param); |
$generalrule = &Apache::loncommon::authform_authorwarning(%param); |
|
$authformnop = &Apache::loncommon::authform_nochange(%param); |
$authformnop = &Apache::loncommon::authform_nochange(%param); |
# no longer static due to configurable kerberos defaults |
# no longer static due to configurable kerberos defaults |
# $authformkrb = &Apache::loncommon::authform_kerberos(%param); |
# $authformkrb = &Apache::loncommon::authform_kerberos(%param); |
Line 216 sub print_username_entry_form {
|
Line 219 sub print_username_entry_form {
|
$jscript,{'add_entries' => \%loaditems,}); |
$jscript,{'add_entries' => \%loaditems,}); |
&Apache::lonhtmlcommon::add_breadcrumb |
&Apache::lonhtmlcommon::add_breadcrumb |
({href=>"javascript:backPage(document.crtuser)", |
({href=>"javascript:backPage(document.crtuser)", |
text=>"User modify/custom role", |
text=>"User modify/custom role edit", |
faq=>282,bug=>'Instructor Interface',}); |
faq=>282,bug=>'Instructor Interface',}); |
|
|
my $crumbs = &Apache::lonhtmlcommon::breadcrumbs('User Management'); |
my $crumbs = &Apache::lonhtmlcommon::breadcrumbs('User Management'); |
Line 264 ENDCUSTOM
|
Line 267 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 309 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 333 $jsback
|
ENDSCRIPT |
ENDSCRIPT |
|
|
my %lt=&Apache::lonlocal::texthash( |
my %lt=&Apache::lonlocal::texthash( |
'srch' => "User Search to add/modify roles of", |
'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 of').'</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 360 ENDSCRIPT
|
Line 373 ENDSCRIPT
|
$r->print(&Apache::loncommon::end_data_table_header_row()); |
$r->print(&Apache::loncommon::end_data_table_header_row()); |
|
|
my @sorted_users = sort { |
my @sorted_users = sort { |
lc($srch_results->{$a}->{$sortby}) cmp lc($srch_results->{$b}->{$sortby}) |
lc($srch_results->{$a}->{$sortby}) cmp lc($srch_results->{$b}->{$sortby}) |
|| |
|| |
lc($srch_results->{$a}->{lastname}) cmp lc($srch_results->{$b}->{lastname}) |
lc($srch_results->{$a}->{lastname}) cmp lc($srch_results->{$b}->{lastname}) |
|| |
|| |
lc($srch_results->{$a}->{firstname}) cmp lc($srch_results->{$b}->{firstname}) |
lc($srch_results->{$a}->{firstname}) cmp lc($srch_results->{$b}->{firstname}) |
|
|| |
|
lc($a) cmp lc($b) |
} (keys(%$srch_results)); |
} (keys(%$srch_results)); |
|
|
foreach my $user (@sorted_users) { |
foreach my $user (@sorted_users) { |
Line 379 ENDSCRIPT
|
Line 394 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 400 sub print_user_query_page {
|
Line 423 sub print_user_query_page {
|
|
|
sub print_user_modification_page { |
sub print_user_modification_page { |
my ($r,$ccuname,$ccdomain,$srch,$response) = @_; |
my ($r,$ccuname,$ccdomain,$srch,$response) = @_; |
unless (($ccuname) && ($ccdomain)) { |
if (($ccuname eq '') || ($ccdomain eq '')) { |
&print_username_entry_form($r); |
my $usermsg = &mt('No username and/or domain provided.'); |
|
&print_username_entry_form($r,$usermsg); |
return; |
return; |
} |
} |
|
my ($curr_authtype,$instsrch,$rulematch,$rules,%inst_results); |
|
my $uhome=&Apache::lonnet::homeserver($ccuname,$ccdomain); |
|
if ($uhome eq 'no_host') { |
|
$instsrch = |
|
{ |
|
srchin => 'instd', |
|
srchby => 'uname', |
|
srchtype => 'exact', |
|
srchterm => $ccuname, |
|
srchdomain => $ccdomain, |
|
}; |
|
(my $usercheckmsg,$rulematch,$rules,%inst_results) = |
|
&Apache::loncommon::username_rule_check($instsrch,'new'); |
|
if ($usercheckmsg) { |
|
&print_username_entry_form($r,$usercheckmsg); |
|
return; |
|
} |
|
} else { |
|
$curr_authtype = |
|
&Apache::lonnet::queryauthenticate($ccuname,$ccdomain); |
|
} |
if ($response) { |
if ($response) { |
$response = '<br />'.$response |
$response = '<br />'.$response |
} |
} |
Line 414 sub print_user_modification_page {
|
Line 459 sub print_user_modification_page {
|
|
|
my %param = ( formname => 'document.cu', |
my %param = ( formname => 'document.cu', |
kerb_def_dom => $krbdefdom, |
kerb_def_dom => $krbdefdom, |
kerb_def_auth => $krbdef |
kerb_def_auth => $krbdef, |
|
curr_authtype => $curr_authtype, |
|
domain => $ccdomain, |
); |
); |
$loginscript = &Apache::loncommon::authform_header(%param); |
$loginscript = &Apache::loncommon::authform_header(%param); |
$authformkrb = &Apache::loncommon::authform_kerberos(%param); |
$authformkrb = &Apache::loncommon::authform_kerberos(%param); |
Line 655 ENDSECCODE
|
Line 702 ENDSECCODE
|
<input type="hidden" name="pres_type" value="" /> |
<input type="hidden" name="pres_type" value="" /> |
<input type="hidden" name="pres_marker" value="" /> |
<input type="hidden" name="pres_marker" value="" /> |
ENDFORMINFO |
ENDFORMINFO |
my $uhome=&Apache::lonnet::homeserver($ccuname,$ccdomain); |
|
my %inccourses; |
my %inccourses; |
foreach my $key (keys(%env)) { |
foreach my $key (keys(%env)) { |
if ($key=~/^user\.priv\.cm\.\/($match_domain)\/($match_username)/) { |
if ($key=~/^user\.priv\.cm\.\/($match_domain)\/($match_username)/) { |
Line 663 ENDFORMINFO
|
Line 709 ENDFORMINFO
|
} |
} |
} |
} |
if ($uhome eq 'no_host') { |
if ($uhome eq 'no_host') { |
my $newuser; |
|
my $instsrch = { |
|
srchin => 'instd', |
|
srchby => 'uname', |
|
srchtype => 'exact', |
|
}; |
|
if ($env{'form.phase'} eq 'userpicked') { |
|
$instsrch->{'srchterm'} = $env{'form.seluname'}; |
|
$instsrch->{'srchdomain'} = $env{'form.seludom'}; |
|
} else { |
|
$instsrch->{'srchterm'} = $ccuname; |
|
$instsrch->{'srchdomain'} = $ccdomain, |
|
} |
|
if (($instsrch->{'srchterm'} ne '') && ($instsrch->{'srchdomain'} ne '')) { |
|
$newuser = $instsrch->{'srchterm'}.':'.$instsrch->{'srchdomain'}; |
|
} |
|
my (%dirsrch_results,%inst_results); |
|
if ($newuser) { |
|
if (&directorysrch_check($instsrch) eq 'ok') { |
|
%dirsrch_results = &Apache::lonnet::inst_directory_query($instsrch); |
|
if (ref($dirsrch_results{$newuser}) eq 'HASH') { |
|
%inst_results = %{$dirsrch_results{$newuser}}; |
|
} |
|
} |
|
} |
|
my $home_server_list= |
|
'<option value="default" selected>default</option>'."\n". |
|
&Apache::loncommon::home_server_option_list($ccdomain); |
|
|
|
my %lt=&Apache::lonlocal::texthash( |
my %lt=&Apache::lonlocal::texthash( |
'cnu' => "Create New User", |
'cnu' => "Create New User", |
'nu' => "New User", |
'nu' => "New User", |
'id' => "in domain", |
'ind' => "in domain", |
'pd' => "Personal Data", |
'pd' => "Personal Data", |
'fn' => "First Name", |
'firstname' => "First Name", |
'mn' => "Middle Name", |
'middlename' => "Middle Name", |
'ln' => "Last Name", |
'lastname' => "Last Name", |
'gen' => "Generation", |
'generation' => "Generation", |
'mail' => "Permanent e-mail address", |
'permanentemail' => "Permanent e-mail address", |
'idsn' => "ID/Student Number", |
'id' => "ID/Student Number", |
'hs' => "Home Server", |
'hs' => "Home Server", |
'lg' => "Login Data" |
'lg' => "Login Data" |
); |
); |
|
my @userinfo = ('firstname','middlename','lastname','generation','permanentemail','id'); |
|
my %textboxsize = ( |
|
firstname => '15', |
|
middlename => '15', |
|
lastname => '15', |
|
generation => '5', |
|
permanentemail => '25', |
|
id => '15', |
|
); |
|
my %element = ( |
|
firstname => 'cfirst', |
|
middlename => 'cmiddle', |
|
lastname => 'clast', |
|
generation => 'cgen', |
|
permanentemail => 'cemail', |
|
id => 'cstid', |
|
); |
my $portfolioform; |
my $portfolioform; |
if (&Apache::lonnet::allowed('mpq',$env{'request.role.domain'})) { |
if (&Apache::lonnet::allowed('mpq',$env{'request.role.domain'})) { |
# Current user has quota modification privileges |
# Current user has quota modification privileges |
$portfolioform = &portfolio_quota($ccuname,$ccdomain); |
$portfolioform = &portfolio_quota($ccuname,$ccdomain); |
} |
} |
my $genhelp=&Apache::loncommon::help_open_topic('Generation'); |
my $genhelp=&Apache::loncommon::help_open_topic('Generation'); |
&initialize_authen_forms(); |
&initialize_authen_forms($ccdomain); |
$r->print(<<ENDNEWUSER); |
$r->print(<<ENDTITLE); |
$start_page |
$start_page |
$crumbs |
$crumbs |
<h1>$lt{'cnu'}</h1> |
|
$response |
$response |
$forminfo |
$forminfo |
<h2>$lt{'nu'} "$ccuname" $lt{'id'} $ccdomain</h2> |
<h2>$lt{'cnu'} "$ccuname" $lt{'ind'} $ccdomain</h2> |
<script type="text/javascript" language="Javascript"> |
<script type="text/javascript" language="Javascript"> |
$loginscript |
$loginscript |
</script> |
</script> |
<input type='hidden' name='makeuser' value='1' /> |
<input type='hidden' name='makeuser' value='1' /> |
<h3>$lt{'pd'}</h3> |
<h3>$lt{'pd'}</h3> |
<p> |
<p> |
<table> |
ENDTITLE |
<tr><td>$lt{'fn'} </td> |
$r->print(&Apache::lonhtmlcommon::start_pick_box()); |
<td><input type="text" name="cfirst" size="15" value="$inst_results{'firstname'}" /></td></tr> |
foreach my $item (@userinfo) { |
<tr><td>$lt{'mn'} </td> |
my $rowtitle = $lt{$item}; |
<td><input type="text" name="cmiddle" size="15" value="$inst_results{'middlename'}" /></td></tr> |
if ($item eq 'generation') { |
<tr><td>$lt{'ln'} </td> |
$rowtitle = $genhelp.$rowtitle; |
<td><input type="text" name="clast" size="15" value="$inst_results{'lastname'}" /></td></tr> |
} |
<tr><td>$lt{'gen'}$genhelp</td> |
$r->print(&Apache::lonhtmlcommon::row_title($rowtitle,undef,'LC_oddrow_value')."\n"); |
<td><input type="text" name="cgen" size="5" value="$inst_results{'generation'}" /></td></tr> |
if ($inst_results{$item} ne '') { |
<tr><td>$lt{'mail'}</td> |
$r->print('<input type="hidden" name="'.$element{$item}.'" value="'.$inst_results{$item}.'" />'.$inst_results{$item}); |
<td><input type="text" name="cemail" size="20" value="$inst_results{'permanentemail'}" /></td></tr> |
} else { |
</table> |
$r->print('<input type="text" name="'.$element{$item}.'" size="'.$textboxsize{$item}.'" value="" />'); |
$lt{'idsn'} <input type="text" name="cstid" size="15" value="$inst_results{'id'}" /></p> |
} |
$lt{'hs'}: <select name="hserver" size="1"> $home_server_list </select> |
$r->print(&Apache::lonhtmlcommon::row_closure(1)); |
<hr /> |
} |
<h3>$lt{'lg'}</h3> |
$r->print(&Apache::lonhtmlcommon::end_pick_box()); |
<p>$generalrule </p> |
my ($home_server_pick,$numlib) = |
<p>$authformkrb </p> |
&Apache::loncommon::home_server_form_item($ccdomain,'hserver', |
<p>$authformint </p> |
'default','hide'); |
<p>$authformfsys</p> |
if ($numlib > 1) { |
<p>$authformloc </p> |
$r->print(" |
|
<br /> |
|
$lt{'hs'}: $home_server_pick |
|
<br />"); |
|
} else { |
|
$r->print($home_server_pick); |
|
} |
|
$r->print("<hr />\n".'<h3>'.$lt{'lg'}.'</h3>'); |
|
my ($fixedauth,$varauth,$authmsg); |
|
if ($rulematch) { |
|
if (ref($rules) eq 'HASH') { |
|
if (ref($rules->{$rulematch}) eq 'HASH') { |
|
my $authtype = $rules->{$rulematch}{'authtype'}; |
|
if ($authtype !~ /^(krb4|krb5|int|fsys|loc)$/) { |
|
$r->print(&set_login($ccdomain)); |
|
} else { |
|
my $authparm = $rules->{$rulematch}{'authparm'}; |
|
if ($authtype =~ /^krb(4|5)$/) { |
|
my $ver = $1; |
|
if ($authparm ne '') { |
|
$fixedauth = <<"KERB"; |
|
<input type="hidden" name="login" value="krb" /> |
|
<input type="hidden" name="krbver" value="$ver" /> |
|
<input type="hidden" name="krbarg" value="$authparm" /> |
|
KERB |
|
$authmsg = $rules->{$rulematch}{'authmsg'}; |
|
} |
|
} else { |
|
$fixedauth = |
|
'<input type="hidden" name="login" value="'.$authtype.'" />'."\n"; |
|
if ($rules->{$rulematch}{'authparmfixed'}) { |
|
$fixedauth .= |
|
'<input type="hidden" name="'.$authtype.'arg" value="'.$authparm.'" />'."\n"; |
|
} else { |
|
$varauth = |
|
'<input type="text" name="'.$authtype.'arg" value="" />'."\n"; |
|
} |
|
} |
|
} |
|
} else { |
|
$r->print(&set_login($ccdomain)); |
|
} |
|
} |
|
if ($authmsg) { |
|
$r->print(<<ENDAUTH); |
|
$fixedauth |
|
$authmsg |
|
$varauth |
|
ENDAUTH |
|
} |
|
} else { |
|
$r->print(&set_login($ccdomain)); |
|
} |
|
$r->print(<<ENDPORT); |
<hr /> |
<hr /> |
$portfolioform |
$portfolioform |
ENDNEWUSER |
ENDPORT |
} else { # user already exists |
} else { # user already exists |
my %lt=&Apache::lonlocal::texthash( |
my %lt=&Apache::lonlocal::texthash( |
'cup' => "Change User Privileges", |
'cup' => "Change User Privileges for", |
'usr' => "User", |
|
'id' => "in domain", |
'id' => "in domain", |
'fn' => "first name", |
'fn' => "first name", |
'mn' => "middle name", |
'mn' => "middle name", |
Line 764 ENDNEWUSER
|
Line 849 ENDNEWUSER
|
$r->print(<<ENDCHANGEUSER); |
$r->print(<<ENDCHANGEUSER); |
$start_page |
$start_page |
$crumbs |
$crumbs |
<h1>$lt{'cup'}</h1> |
|
$forminfo |
$forminfo |
<h2>$lt{'usr'} "$ccuname" $lt{'id'} "$ccdomain"</h2> |
<h2>$lt{'cup'} "$ccuname" $lt{'id'} "$ccdomain"</h2> |
ENDCHANGEUSER |
ENDCHANGEUSER |
# Get the users information |
# Get the users information |
my %userenv = |
my %userenv = |
Line 781 ENDCHANGEUSER
|
Line 865 ENDCHANGEUSER
|
'<th>'.$lt{'fn'}.'</th><th>'.$lt{'mn'}.'</th><th>'.$lt{'ln'}.'</th><th>'.$lt{'gen'}.'</th><th>'.$lt{'email'}.'</th>'. |
'<th>'.$lt{'fn'}.'</th><th>'.$lt{'mn'}.'</th><th>'.$lt{'ln'}.'</th><th>'.$lt{'gen'}.'</th><th>'.$lt{'email'}.'</th>'. |
&Apache::loncommon::end_data_table_header_row(). |
&Apache::loncommon::end_data_table_header_row(). |
&Apache::loncommon::start_data_table_row()); |
&Apache::loncommon::start_data_table_row()); |
foreach my $item ('firstname','middlename','lastname','generation','permenanentemail') { |
foreach my $item ('firstname','middlename','lastname','generation','permanentemail') { |
if (&Apache::lonnet::allowed('mau',$ccdomain)) { |
if (&Apache::lonnet::allowed('mau',$ccdomain)) { |
$r->print(<<"END"); |
$r->print(<<"END"); |
<td><input type="text" name="c$item" value="$userenv{$item}" size="15" /></td> |
<td><input type="text" name="c$item" value="$userenv{$item}" size="15" /></td> |
Line 987 END
|
Line 1071 END
|
$currentauth=~/^krb(4|5):(.*)/; |
$currentauth=~/^krb(4|5):(.*)/; |
my $krbdefdom=$2; |
my $krbdefdom=$2; |
my %param = ( formname => 'document.cu', |
my %param = ( formname => 'document.cu', |
kerb_def_dom => $krbdefdom |
kerb_def_dom => $krbdefdom, |
|
domain => $ccdomain, |
|
curr_authtype => $currentauth, |
); |
); |
$loginscript = &Apache::loncommon::authform_header(%param); |
$loginscript = &Apache::loncommon::authform_header(%param); |
} |
} |
# Check for a bad authentication type |
# Check for a bad authentication type |
unless ($currentauth=~/^krb(4|5):/ or |
if ($currentauth !~ /^(krb4|krb5|unix|internal|localauth):/) { |
$currentauth=~/^unix:/ or |
# bad authentication scheme |
$currentauth=~/^internal:/ or |
|
$currentauth=~/^localauth:/ |
|
) { # bad authentication scheme |
|
if (&Apache::lonnet::allowed('mau',$ccdomain)) { |
if (&Apache::lonnet::allowed('mau',$ccdomain)) { |
&initialize_authen_forms(); |
&initialize_authen_forms($ccdomain); |
my %lt=&Apache::lonlocal::texthash( |
my %lt=&Apache::lonlocal::texthash( |
'err' => "ERROR", |
'err' => "ERROR", |
'uuas' => "This user has an unrecognized authentication scheme", |
'uuas' => "This user has an unrecognized authentication scheme", |
'sldb' => "Please specify login data below", |
'sldb' => "Please specify login data below", |
'ld' => "Login Data" |
'ld' => "Login Data" |
); |
); |
|
my $choices = &set_login($ccdomain); |
$r->print(<<ENDBADAUTH); |
$r->print(<<ENDBADAUTH); |
<hr /> |
<hr /> |
<script type="text/javascript" language="Javascript"> |
<script type="text/javascript" language="Javascript"> |
Line 1013 $loginscript
|
Line 1097 $loginscript
|
<font color='#ff0000'>$lt{'err'}:</font> |
<font color='#ff0000'>$lt{'err'}:</font> |
$lt{'uuas'} ($currentauth). $lt{'sldb'}. |
$lt{'uuas'} ($currentauth). $lt{'sldb'}. |
<h3>$lt{'ld'}</h3> |
<h3>$lt{'ld'}</h3> |
<p>$generalrule</p> |
$choices |
<p>$authformkrb</p> |
|
<p>$authformint</p> |
|
<p>$authformfsys</p> |
|
<p>$authformloc</p> |
|
ENDBADAUTH |
ENDBADAUTH |
} else { |
} else { |
# This user is not allowed to modify the user's |
# This user is not allowed to modify the user's |
Line 1037 ENDBADAUTH
|
Line 1117 ENDBADAUTH
|
} else { # Authentication type is valid |
} else { # Authentication type is valid |
my $authformcurrent=''; |
my $authformcurrent=''; |
my $authform_other=''; |
my $authform_other=''; |
&initialize_authen_forms(); |
&initialize_authen_forms($ccdomain,$currentauth); |
if ($currentauth=~/^krb(4|5):/) { |
my ($authformcurrent,$authform_other,$can_modify) = |
$authformcurrent=$authformkrb; |
&modify_login_block($ccdomain,$currentauth); |
$authform_other="<p>$authformint</p>\n". |
|
"<p>$authformfsys</p><p>$authformloc</p>"; |
|
} |
|
elsif ($currentauth=~/^internal:/) { |
|
$authformcurrent=$authformint; |
|
$authform_other="<p>$authformkrb</p>". |
|
"<p>$authformfsys</p><p>$authformloc</p>"; |
|
} |
|
elsif ($currentauth=~/^unix:/) { |
|
$authformcurrent=$authformfsys; |
|
$authform_other="<p>$authformkrb</p>". |
|
"<p>$authformint</p><p>$authformloc;</p>"; |
|
} |
|
elsif ($currentauth=~/^localauth:/) { |
|
$authformcurrent=$authformloc; |
|
$authform_other="<p>$authformkrb</p>". |
|
"<p>$authformint</p><p>$authformfsys</p>"; |
|
} |
|
$authformcurrent.=' <i>(will override current values)</i><br />'; |
|
if (&Apache::lonnet::allowed('mau',$ccdomain)) { |
if (&Apache::lonnet::allowed('mau',$ccdomain)) { |
# Current user has login modification privileges |
# Current user has login modification privileges |
my %lt=&Apache::lonlocal::texthash( |
my %lt=&Apache::lonlocal::texthash( |
Line 1071 ENDBADAUTH
|
Line 1132 ENDBADAUTH
|
$loginscript |
$loginscript |
</script> |
</script> |
<h3>$lt{'ccld'}</h3> |
<h3>$lt{'ccld'}</h3> |
<p>$generalrule</p> |
<p>$authformnop |
<p>$authformnop</p> |
|
<p>$authformcurrent</p> |
|
<h3>$lt{'enld'}</h3> |
|
$authform_other |
|
ENDOTHERAUTHS |
ENDOTHERAUTHS |
|
if ($can_modify) { |
|
$r->print('</p><p>'.$authformcurrent.'</p>'); |
|
} else { |
|
$r->print(' ('.$authformcurrent.')</p>'); |
|
} |
|
if ($authform_other ne '') { |
|
$r->print('<h3>'.$lt{'enld'}.'</h3>'."\n". |
|
$authform_other); |
|
} |
} else { |
} else { |
if (&Apache::lonnet::allowed('mau',$env{'request.role.domain'})) { |
if (&Apache::lonnet::allowed('mau',$env{'request.role.domain'})) { |
my %lt=&Apache::lonlocal::texthash( |
my %lt=&Apache::lonlocal::texthash( |
Line 1091 $lt{'yodo'} $lt{'ifch'}: $ccdomain
|
Line 1157 $lt{'yodo'} $lt{'ifch'}: $ccdomain
|
ENDNOPRIV |
ENDNOPRIV |
} |
} |
} |
} |
if (&Apache::lonnet::allowed('mpq',$env{'request.role.domain'})) { |
|
# Current user has quota modification privileges |
|
$r->print(&portfolio_quota($ccuname,$ccdomain)); |
|
} |
|
} ## End of "check for bad authentication type" logic |
} ## End of "check for bad authentication type" logic |
|
if (&Apache::lonnet::allowed('mpq',$ccdomain)) { |
|
# Current user has quota modification privileges |
|
$r->print(&portfolio_quota($ccuname,$ccdomain)); |
|
} elsif (&Apache::lonnet::allowed('mpq',$env{'request.role.domain'})) { |
|
my %lt=&Apache::lonlocal::texthash( |
|
'dska' => "Disk space allocated to user's portfolio files", |
|
'youd' => "You do not have privileges to modify the portfolio quota for this user.", |
|
'ichr' => "If a change is required, contact a domain coordinator for the domain", |
|
); |
|
$r->print(<<ENDNOPORTPRIV); |
|
<hr /> |
|
<h3>$lt{'dska'}</h3> |
|
$lt{'youd'} $lt{'ichr'}: $ccdomain |
|
ENDNOPORTPRIV |
|
} |
} ## End of new user/old user logic |
} ## End of new user/old user logic |
$r->print('<hr /><h3>'.&mt('Add Roles').'</h3>'); |
$r->print('<hr /><h3>'.&mt('Add Roles').'</h3>'); |
# |
# |
Line 1134 ENDNOPRIV
|
Line 1211 ENDNOPRIV
|
<td><input type="hidden" name="start_'.$cudom.'_'.$cuname.'_ca" value="" /> |
<td><input type="hidden" name="start_'.$cudom.'_'.$cuname.'_ca" value="" /> |
<a href= |
<a href= |
"javascript:pjump('."'date_start','Start Date Co-Author',document.cu.start_$cudom\_$cuname\_ca.value,'start_$cudom\_$cuname\_ca','cu.pres','dateset'".')">'.$lt{'ssd'}.'</a></td> |
"javascript:pjump('."'date_start','Start Date Co-Author',document.cu.start_$cudom\_$cuname\_ca.value,'start_$cudom\_$cuname\_ca','cu.pres','dateset'".')">'.$lt{'ssd'}.'</a></td> |
<td><input type=hidden name="end_'.$cudom.'_'.$cuname.'_ca" value="" /> |
<td><input type="hidden" name="end_'.$cudom.'_'.$cuname.'_ca" value="" /> |
<a href= |
<a href= |
"javascript:pjump('."'date_end','End Date Co-Author',document.cu.end_$cudom\_$cuname\_ca.value,'end_$cudom\_$cuname\_ca','cu.pres','dateset'".')">'.$lt{'sed'}.'</a></td>'."\n". |
"javascript:pjump('."'date_end','End Date Co-Author',document.cu.end_$cudom\_$cuname\_ca.value,'end_$cudom\_$cuname\_ca','cu.pres','dateset'".')">'.$lt{'sed'}.'</a></td>'."\n". |
&Apache::loncommon::end_data_table_row()."\n". |
&Apache::loncommon::end_data_table_row()."\n". |
Line 1142 ENDNOPRIV
|
Line 1219 ENDNOPRIV
|
'<td><input type=checkbox name="act_'.$cudom.'_'.$cuname.'_aa" /></td> |
'<td><input type=checkbox name="act_'.$cudom.'_'.$cuname.'_aa" /></td> |
<td>'.$lt{'caa'}.'</td> |
<td>'.$lt{'caa'}.'</td> |
<td>'.$cudom.'_'.$cuname.'</td> |
<td>'.$cudom.'_'.$cuname.'</td> |
<td><input type=hidden name="start_'.$cudom.'_'.$cuname.'_aa" value="" /> |
<td><input type="hidden" name="start_'.$cudom.'_'.$cuname.'_aa" value="" /> |
<a href= |
<a href= |
"javascript:pjump('."'date_start','Start Date Assistant Co-Author',document.cu.start_$cudom\_$cuname\_aa.value,'start_$cudom\_$cuname\_aa','cu.pres','dateset'".')">'.$lt{'ssd'}.'</a></td> |
"javascript:pjump('."'date_start','Start Date Assistant Co-Author',document.cu.start_$cudom\_$cuname\_aa.value,'start_$cudom\_$cuname\_aa','cu.pres','dateset'".')">'.$lt{'ssd'}.'</a></td> |
<td><input type=hidden name="end_'.$cudom.'_'.$cuname.'_aa" value="" /> |
<td><input type="hidden" name="end_'.$cudom.'_'.$cuname.'_aa" value="" /> |
<a href= |
<a href= |
"javascript:pjump('."'date_end','End Date Assistant Co-Author',document.cu.end_$cudom\_$cuname\_aa.value,'end_$cudom\_$cuname\_aa','cu.pres','dateset'".')">'.$lt{'sed'}.'</a></td>'."\n". |
"javascript:pjump('."'date_end','End Date Assistant Co-Author',document.cu.end_$cudom\_$cuname\_aa.value,'end_$cudom\_$cuname\_aa','cu.pres','dateset'".')">'.$lt{'sed'}.'</a></td>'."\n". |
&Apache::loncommon::end_data_table_row()."\n". |
&Apache::loncommon::end_data_table_row()."\n". |
Line 1177 ENDNOPRIV
|
Line 1254 ENDNOPRIV
|
'<td><input type=checkbox name="act_'.$thisdomain.'_'.$role.'" /></td> |
'<td><input type=checkbox name="act_'.$thisdomain.'_'.$role.'" /></td> |
<td>'.$plrole.'</td> |
<td>'.$plrole.'</td> |
<td>'.$thisdomain.'</td> |
<td>'.$thisdomain.'</td> |
<td><input type=hidden name="start_'.$thisdomain.'_'.$role.'" value="" /> |
<td><input type="hidden" name="start_'.$thisdomain.'_'.$role.'" value="" /> |
<a href= |
<a href= |
"javascript:pjump('."'date_start','Start Date $plrole',document.cu.start_$thisdomain\_$role.value,'start_$thisdomain\_$role','cu.pres','dateset'".')">'.$lt{'ssd'}.'</a></td> |
"javascript:pjump('."'date_start','Start Date $plrole',document.cu.start_$thisdomain\_$role.value,'start_$thisdomain\_$role','cu.pres','dateset'".')">'.$lt{'ssd'}.'</a></td> |
<td><input type=hidden name="end_'.$thisdomain.'_'.$role.'" value="" /> |
<td><input type="hidden" name="end_'.$thisdomain.'_'.$role.'" value="" /> |
<a href= |
<a href= |
"javascript:pjump('."'date_end','End Date $plrole',document.cu.end_$thisdomain\_$role.value,'end_$thisdomain\_$role','cu.pres','dateset'".')">'.$lt{'sed'}.'</a></td>'. |
"javascript:pjump('."'date_end','End Date $plrole',document.cu.end_$thisdomain\_$role.value,'end_$thisdomain\_$role','cu.pres','dateset'".')">'.$lt{'sed'}.'</a></td>'. |
&Apache::loncommon::end_data_table_row(); |
&Apache::loncommon::end_data_table_row(); |
Line 1202 ENDNOPRIV
|
Line 1279 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()); |
} |
} |
|
|
|
sub set_login { |
|
my ($dom) = @_; |
|
my %domconfig = &Apache::lonnet::get_dom('configuration',['usercreation'],$dom); |
|
my $response; |
|
my ($authnum,%can_assign) = |
|
&Apache::loncommon::get_assignable_auth($dom); |
|
if (($can_assign{'krb4'}) || ($can_assign{'krb5'})) { |
|
$response .= "<p>$authformkrb </p>\n"; |
|
} |
|
if ($can_assign{'int'}) { |
|
$response .= "<p>$authformint </p>\n" |
|
} |
|
if ($can_assign{'loc'}) { |
|
$response .= "<p>$authformloc </p>\n"; |
|
} |
|
return $response; |
|
} |
|
|
|
sub modify_login_block { |
|
my ($dom,$currentauth) = @_; |
|
my %domconfig = &Apache::lonnet::get_dom('configuration',['usercreation'],$dom); |
|
my ($authnum,%can_assign) = |
|
&Apache::loncommon::get_assignable_auth($dom); |
|
my ($authformcurrent,$authform_other,$show_override_msg); |
|
if ($currentauth=~/^krb(4|5):/) { |
|
$authformcurrent=$authformkrb; |
|
if ($can_assign{'int'}) { |
|
$authform_other = "<p>$authformint </p>\n" |
|
} |
|
if ($can_assign{'loc'}) { |
|
$authform_other .= "<p>$authformloc </p>\n"; |
|
} |
|
if (($can_assign{'krb4'}) || ($can_assign{'krb5'})) { |
|
$show_override_msg = 1; |
|
} |
|
} elsif ($currentauth=~/^internal:/) { |
|
$authformcurrent=$authformint; |
|
if (($can_assign{'krb4'}) || ($can_assign{'krb5'})) { |
|
$authform_other = "<p>$authformkrb </p>\n" |
|
} |
|
if ($can_assign{'loc'}) { |
|
$authform_other .= "<p>$authformloc </p>\n"; |
|
} |
|
if ($can_assign{'int'}) { |
|
$show_override_msg = 1; |
|
} |
|
} elsif ($currentauth=~/^unix:/) { |
|
$authformcurrent=$authformfsys; |
|
if (($can_assign{'krb4'}) || ($can_assign{'krb5'})) { |
|
$authform_other = "<p>$authformkrb </p>\n" |
|
} |
|
if ($can_assign{'int'}) { |
|
$authform_other .= "<p>$authformint </p>\n" |
|
} |
|
if ($can_assign{'loc'}) { |
|
$authform_other .= "<p>$authformloc </p>\n"; |
|
} |
|
if ($can_assign{'fsys'}) { |
|
$show_override_msg = 1; |
|
} |
|
} elsif ($currentauth=~/^localauth:/) { |
|
$authformcurrent=$authformloc; |
|
if (($can_assign{'krb4'}) || ($can_assign{'krb5'})) { |
|
$authform_other = "<p>$authformkrb </p>\n" |
|
} |
|
if ($can_assign{'int'}) { |
|
$authform_other .= "<p>$authformint </p>\n" |
|
} |
|
if ($can_assign{'loc'}) { |
|
$show_override_msg = 1; |
|
} |
|
} |
|
if ($show_override_msg) { |
|
$authformcurrent.= ' <span class="LC_cusr_emph">'. |
|
&mt('will override current values'). |
|
'</span><br />'; |
|
} |
|
return ($authformcurrent,$authform_other,$show_override_msg); |
|
} |
|
|
# ================================================================= Phase Three |
# ================================================================= Phase Three |
sub update_user_data { |
sub update_user_data { |
my ($r) = @_; |
my ($r) = @_; |
Line 1337 sub update_user_data {
|
Line 1494 sub update_user_data {
|
($env{'form.ccdomain'},$env{'form.ccuname'},$env{'form.cstid'}, |
($env{'form.ccdomain'},$env{'form.ccuname'},$env{'form.cstid'}, |
$amode,$genpwd,$env{'form.cfirst'}, |
$amode,$genpwd,$env{'form.cfirst'}, |
$env{'form.cmiddle'},$env{'form.clast'},$env{'form.cgen'}, |
$env{'form.cmiddle'},$env{'form.clast'},$env{'form.cgen'}, |
undef,$desiredhost |
undef,$desiredhost,$env{'form.cemail'} |
); |
); |
$r->print(&mt('Generating user').': '.$result); |
$r->print(&mt('Generating user').': '.$result); |
my $home = &Apache::lonnet::homeserver($env{'form.ccuname'}, |
my $home = &Apache::lonnet::homeserver($env{'form.ccuname'}, |
Line 1444 sub update_user_data {
|
Line 1601 sub update_user_data {
|
$changeHash{'middlename'} = $env{'form.cmiddlename'}; |
$changeHash{'middlename'} = $env{'form.cmiddlename'}; |
$changeHash{'lastname'} = $env{'form.clastname'}; |
$changeHash{'lastname'} = $env{'form.clastname'}; |
$changeHash{'generation'} = $env{'form.cgeneration'}; |
$changeHash{'generation'} = $env{'form.cgeneration'}; |
$changeHash{'permanentemail'} = $env{'form.permanentemail'}; |
$changeHash{'permanentemail'} = $env{'form.cpermanentemail'}; |
my $putresult = &Apache::lonnet::put |
my $putresult = &Apache::lonnet::put |
('environment',\%changeHash, |
('environment',\%changeHash, |
$env{'form.ccdomain'},$env{'form.ccuname'}); |
$env{'form.ccdomain'},$env{'form.ccuname'}); |
Line 1469 sub update_user_data {
|
Line 1626 sub update_user_data {
|
<th>$lt{'mddl'}</th> |
<th>$lt{'mddl'}</th> |
<th>$lt{'lst'}</th> |
<th>$lt{'lst'}</th> |
<th>$lt{'gen'}</th> |
<th>$lt{'gen'}</th> |
<th>$lt{'disk'}<th></tr> |
<th>$lt{'mail'}</th> |
|
<th>$lt{'disk'}</th></tr> |
<tr><td>$lt{'prvs'}</td> |
<tr><td>$lt{'prvs'}</td> |
<td>$userenv{'firstname'} </td> |
<td>$userenv{'firstname'} </td> |
<td>$userenv{'middlename'} </td> |
<td>$userenv{'middlename'} </td> |
Line 1535 END
|
Line 1693 END
|
if ($key=~/^form\.rev/) { |
if ($key=~/^form\.rev/) { |
if ($key=~/^form\.rev\:([^\_]+)\_([^\_\.]+)$/) { |
if ($key=~/^form\.rev\:([^\_]+)\_([^\_\.]+)$/) { |
# Revoke standard role |
# Revoke standard role |
$r->print(&mt('Revoking').' '.$2.' in '.$1.': <b>'. |
my ($scope,$role) = ($1,$2); |
&Apache::lonnet::revokerole($env{'form.ccdomain'}, |
my $result = |
$env{'form.ccuname'},$1,$2).'</b><br />'); |
&Apache::lonnet::revokerole($env{'form.ccdomain'}, |
if ($2 eq 'st') { |
$env{'form.ccuname'}, |
$1=~m{^/($match_domain)/($match_courseid)}; |
$scope,$role); |
my $cid=$1.'_'.$2; |
$r->print(&mt('Revoking [_1] in [_2]: [_3]', |
my $user = $env{'form.ccuname'}.':'.$env{'form.ccdomain'}; |
$role,$scope,'<b>'.$result.'</b>').'<br />'); |
my $result = |
if ($role eq 'st') { |
&Apache::lonnet::cput('classlist', |
my $result = &classlist_drop($scope,$env{'form.ccuname'}, |
{ $user => $now }, |
$env{'form.ccdomain'},$now); |
$env{'course.'.$cid.'.domain'}, |
$r->print($result); |
$env{'course.'.$cid.'.num'}); |
|
$r->print(&mt('Drop from classlist: [_1]', |
|
'<b>'.$result.'</b>').'<br />'); |
|
} |
} |
} |
} |
if ($key=~m{^form\.rev\:([^_]+)_cr\.cr/($match_domain)/($match_username)/(\w+)$}) { |
if ($key=~m{^form\.rev\:([^_]+)_cr\.cr/($match_domain)/($match_username)/(\w+)$ }s) { |
# Revoke custom role |
# Revoke custom role |
$r->print(&mt('Revoking custom role:'). |
$r->print(&mt('Revoking custom role:'). |
' '.$4.' by '.$3.':'.$2.' in '.$1.': <b>'. |
' '.$4.' by '.$3.':'.$2.' in '.$1.': <b>'. |
Line 1562 END
|
Line 1717 END
|
} elsif ($key=~/^form\.del/) { |
} elsif ($key=~/^form\.del/) { |
if ($key=~/^form\.del\:([^\_]+)\_([^\_\.]+)$/) { |
if ($key=~/^form\.del\:([^\_]+)\_([^\_\.]+)$/) { |
# Delete standard role |
# Delete standard role |
$r->print(&mt('Deleting').' '.$2.' in '.$1.': '. |
my ($scope,$role) = ($1,$2); |
&Apache::lonnet::assignrole($env{'form.ccdomain'}, |
my $result = |
$env{'form.ccuname'},$1,$2,$now,0,1).'<br />'); |
&Apache::lonnet::assignrole($env{'form.ccdomain'}, |
if ($2 eq 'st') { |
$env{'form.ccuname'}, |
$1=~m{^/($match_domain)/($match_courseid)}; |
$scope,$role,$now,0,1); |
my $cid=$1.'_'.$2; |
$r->print(&mt('Deleting [_1] in [_2]: [_3]',$role,$scope, |
my $user = $env{'form.ccuname'}.':'.$env{'form.ccdomain'}; |
'<b>'.$result.'</b>').'<br />'); |
my $result = |
if ($role eq 'st') { |
&Apache::lonnet::cput('classlist', |
my $result = &classlist_drop($scope,$env{'form.ccuname'}, |
{ $user => $now }, |
$env{'form.ccdomain'},$now); |
$env{'course.'.$cid.'.domain'}, |
$r->print($result); |
$env{'course.'.$cid.'.num'}); |
|
$r->print(&mt('Drop from classlist: [_1]', |
|
'<b>'.$result.'</b>').'<br />'); |
|
} |
} |
} |
} |
if ($key=~m{^form\.del\:([^_]+)_cr\.cr/($match_domain)/($match_username)/(\w+)$}) { |
if ($key=~m{^form\.del\:([^_]+)_cr\.cr/($match_domain)/($match_username)/(\w+)$}) { |
my ($url,$rdom,$rnam,$rolename) = ($1,$2,$3,$4); |
my ($url,$rdom,$rnam,$rolename) = ($1,$2,$3,$4); |
# Delete custom role |
# Delete custom role |
$r->print(&mt('Deleting custom role [_1] by [_2]@[_3] in [_4]', |
$r->print(&mt('Deleting custom role [_1] by [_2]:[_3] in [_4]', |
$rolename,$rnam,$rdom,$url).': <b>'. |
$rolename,$rnam,$rdom,$url).': <b>'. |
&Apache::lonnet::assigncustomrole($env{'form.ccdomain'}, |
&Apache::lonnet::assigncustomrole($env{'form.ccdomain'}, |
$env{'form.ccuname'},$url,$rdom,$rnam,$rolename,$now, |
$env{'form.ccuname'},$url,$rdom,$rnam,$rolename,$now, |
Line 1753 END
|
Line 1905 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()); |
} |
} |
|
|
|
sub classlist_drop { |
|
my ($scope,$uname,$udom,$now) = @_; |
|
my ($cdom,$cnum) = ($scope=~m{^/($match_domain)/($match_courseid)}); |
|
my $cid=$cdom.'_'.$cnum; |
|
my $user = $uname.':'.$udom; |
|
if (!&active_student_roles($cnum,$cdom,$uname,$udom)) { |
|
my $result = |
|
&Apache::lonnet::cput('classlist', |
|
{ $user => $now }, |
|
$env{'course.'.$cid.'.domain'}, |
|
$env{'course.'.$cid.'.num'}); |
|
return &mt('Drop from classlist: [_1]', |
|
'<b>'.$result.'</b>').'<br />'; |
|
} |
|
} |
|
|
|
sub active_student_roles { |
|
my ($cnum,$cdom,$uname,$udom) = @_; |
|
my %roles = |
|
&Apache::lonnet::get_my_roles($uname,$udom,'userroles', |
|
['future','active'],['st']); |
|
return exists($roles{"$cnum:$cdom:st"}); |
|
} |
|
|
sub quota_admin { |
sub quota_admin { |
my ($setquota,$changeHash) = @_; |
my ($setquota,$changeHash) = @_; |
my $quotachanged; |
my $quotachanged; |
Line 1928 ENDCCF
|
Line 2104 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 2121 sub handler {
|
Line 2297 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 2139 sub handler {
|
Line 2315 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 2172 sub user_search_result {
|
Line 2348 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,$dirsrchres); |
|
$srch->{'srchterm'} =~ s/\s+/ /g; |
if ($srch->{'srchby'} !~ /^(uname|lastname|lastfirst)$/) { |
if ($srch->{'srchby'} !~ /^(uname|lastname|lastfirst)$/) { |
$response = &mt('Invalid search.'); |
$response = &mt('Invalid search.'); |
} |
} |
if ($srch->{'srchin'} !~ /^(crs|dom|alc|instd)$/) { |
if ($srch->{'srchin'} !~ /^(crs|dom|alc|instd)$/) { |
$response = &mt('Invalid search.'); |
$response = &mt('Invalid search.'); |
} |
} |
if ($srch->{'srchtype'} !~ /^(exact|contains)$/) { |
if ($srch->{'srchtype'} !~ /^(exact|contains|begins)$/) { |
$response = &mt('Invalid search.'); |
$response = &mt('Invalid search.'); |
} |
} |
if ($srch->{'srchterm'} eq '') { |
if ($srch->{'srchterm'} eq '') { |
$response = &mt('You must enter a search term.'); |
$response = &mt('You must enter a search term.'); |
} |
} |
|
if ($srch->{'srchterm'} =~ /^\s+$/) { |
|
$response = &mt('Your search term must contain more than just spaces.'); |
|
} |
if (($srch->{'srchin'} eq 'dom') || ($srch->{'srchin'} eq 'instd')) { |
if (($srch->{'srchin'} eq 'dom') || ($srch->{'srchin'} eq 'instd')) { |
if (($srch->{'srchdomain'} eq '') || |
if (($srch->{'srchdomain'} eq '') || |
! (&Apache::lonnet::domain($srch->{'srchdomain'}))) { |
! (&Apache::lonnet::domain($srch->{'srchdomain'}))) { |
Line 2194 sub user_search_result {
|
Line 2373 sub user_search_result {
|
} |
} |
if (($srch->{'srchin'} eq 'dom') || ($srch->{'srchin'} eq 'crs') || |
if (($srch->{'srchin'} eq 'dom') || ($srch->{'srchin'} eq 'crs') || |
($srch->{'srchin'} eq 'alc')) { |
($srch->{'srchin'} eq 'alc')) { |
if ($srch->{'srchterm'} !~ /^$match_username$/) { |
if ($srch->{'srchby'} eq 'uname') { |
$response = &mt('You must specify a valid username. Only the following are allowed: letters numbers - . @'); |
if ($srch->{'srchterm'} !~ /^$match_username$/) { |
|
$response = &mt('You must specify a valid username. Only the following are allowed: letters numbers - . @'); |
|
} |
} |
} |
} |
} |
|
if ($response ne '') { |
|
$response = '<span class="LC_warning">'.$response.'</span>'; |
|
} |
if ($srch->{'srchin'} eq 'instd') { |
if ($srch->{'srchin'} eq 'instd') { |
my $instd_chk = &directorysrch_check($srch); |
my $instd_chk = &directorysrch_check($srch); |
if ($instd_chk ne 'ok') { |
if ($instd_chk ne 'ok') { |
$response = $instd_chk; |
$response = '<span class="LC_warning">'.$instd_chk.'</span>'. |
|
'<br />'.&mt('You may want to search in the LON-CAPA domain instead of the institutional directory.').'<br /><br />'; |
} |
} |
} |
} |
if ($response ne '') { |
if ($response ne '') { |
return ($state,'<span class="LC_warning">'.$response.'</span>'); |
return ($currstate,$response); |
} |
} |
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 2214 sub user_search_result {
|
Line 2399 sub user_search_result {
|
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') { |
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.')'); |
my $showdom = &display_domain_info($env{'request.role.domain'}); |
|
$response = &mt('New users can only be created in the domain to which your current role belongs - [_1].',$showdom); |
} 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 { |
foreach my $user (keys(%courseusers)) { |
foreach my $user (keys(%$courseusers)) { |
my ($cuname,$cudomain) = split(/:/,$user); |
my ($cuname,$cudomain) = split(/:/,$user); |
if ($cudomain eq $srch->{'srchdomain'}) { |
if ($cudomain eq $srch->{'srchdomain'}) { |
if ($cuname =~ /\Q$srch->{'srchterm'}\E/i) { |
my $matched = 0; |
$srch_results{$user} = ''; |
if ($srch->{'srchtype'} eq 'begins') { |
|
if ($cuname =~ /^\Q$srch->{'srchterm'}\E/i) { |
|
$matched = 1; |
|
} |
|
} else { |
|
if ($cuname =~ /\Q$srch->{'srchterm'}\E/i) { |
|
$matched = 1; |
|
} |
|
} |
|
if ($matched) { |
|
$srch_results{$user} = |
|
{&Apache::lonnet::get('environment', |
|
['firstname', |
|
'lastname', |
|
'permanentemail'])}; |
} |
} |
} |
} |
} |
} |
($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); |
($dirsrchres,%srch_results) = &Apache::lonnet::inst_directory_query($srch); |
($state,$response,$forcenewuser) = |
if ($dirsrchres eq 'ok') { |
&build_search_response($srch,%srch_results); |
($currstate,$response,$forcenewuser) = |
|
&build_search_response($srch,%srch_results); |
|
} else { |
|
my $showdom = &display_domain_info($srch->{'srchdomain'}); |
|
$response = '<span class="LC_warning">'. |
|
&mt('Institutional directory search is not available in domain: [_1]',$showdom). |
|
'</span><br />'. |
|
&mt('You may want to search in the LON-CAPA domain instead of the institutional directory.'). |
|
'<br /><br />'; |
|
} |
} |
} |
} 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(); |
foreach my $user (keys(%courseusers)) { |
foreach my $user (keys(%$courseusers)) { |
my ($uname,$udom) = split(/:/,$user); |
my ($uname,$udom) = split(/:/,$user); |
my %names = &Apache::loncommon::getnames($uname,$udom); |
my %names = &Apache::loncommon::getnames($uname,$udom); |
my %emails = &Apache::loncommon::getemails($uname,$udom); |
my %emails = &Apache::loncommon::getemails($uname,$udom); |
if ($srch->{'srchby'} eq 'lastname') { |
if ($srch->{'srchby'} eq 'lastname') { |
if ((($srch->{'srchtype'} eq 'exact') && |
if ((($srch->{'srchtype'} eq 'exact') && |
($names{'lastname'} eq $srch->{'srchterm'})) || |
($names{'lastname'} eq $srch->{'srchterm'})) || |
|
(($srch->{'srchtype'} eq 'begins') && |
|
($names{'lastname'} =~ /^\Q$srch->{'srchterm'}\E/i)) || |
(($srch->{'srchtype'} eq 'contains') && |
(($srch->{'srchtype'} eq 'contains') && |
($names{'lastname'} =~ /\Q$srch->{'srchterm'}\E/i))) { |
($names{'lastname'} =~ /\Q$srch->{'srchterm'}\E/i))) { |
$srch_results{$user} = {firstname => $names{'firstname'}, |
$srch_results{$user} = {firstname => $names{'firstname'}, |
Line 2289 sub user_search_result {
|
Line 2500 sub user_search_result {
|
} |
} |
} elsif ($srch->{'srchby'} eq 'lastfirst') { |
} elsif ($srch->{'srchby'} eq 'lastfirst') { |
my ($srchlast,$srchfirst) = split(/,/,$srch->{'srchterm'}); |
my ($srchlast,$srchfirst) = split(/,/,$srch->{'srchterm'}); |
|
$srchlast =~ s/\s+$//; |
|
$srchfirst =~ s/^\s+//; |
if ($srch->{'srchtype'} eq 'exact') { |
if ($srch->{'srchtype'} eq 'exact') { |
if (($names{'lastname'} eq $srchlast) && |
if (($names{'lastname'} eq $srchlast) && |
($names{'firstname'} eq $srchfirst)) { |
($names{'firstname'} eq $srchfirst)) { |
Line 2298 sub user_search_result {
|
Line 2511 sub user_search_result {
|
|
|
}; |
}; |
} |
} |
} elsif ($srch->{'srchtype'} eq 'contains') { |
} elsif ($srch->{'srchtype'} eq 'begins') { |
|
if (($names{'lastname'} =~ /^\Q$srchlast\E/i) && |
|
($names{'firstname'} =~ /^\Q$srchfirst\E/i)) { |
|
$srch_results{$user} = {firstname => $names{'firstname'}, |
|
lastname => $names{'lastname'}, |
|
permanentemail => $emails{'permanentemail'}, |
|
}; |
|
} |
|
} else { |
if (($names{'lastname'} =~ /\Q$srchlast\E/i) && |
if (($names{'lastname'} =~ /\Q$srchlast\E/i) && |
($names{'firstname'} =~ /\Q$srchfirst\E/i)) { |
($names{'firstname'} =~ /\Q$srchfirst\E/i)) { |
$srch_results{$user} = {firstname => $names{'firstname'}, |
$srch_results{$user} = {firstname => $names{'firstname'}, |
Line 2309 sub user_search_result {
|
Line 2530 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); |
($dirsrchres,%srch_results) = &Apache::lonnet::inst_directory_query($srch); |
($state,$response,$forcenewuser) = |
if ($dirsrchres eq 'ok') { |
&build_search_response($srch,%srch_results); |
($currstate,$response,$forcenewuser) = |
|
&build_search_response($srch,%srch_results); |
|
} else { |
|
my $showdom = &display_domain_info($srch->{'srchdomain'}); $response = '<span class="LC_warning">'. |
|
&mt('Institutional directory search is not available in domain: [_1]',$showdom). |
|
'</span><br />'. |
|
&mt('You may want to search in the LON-CAPA domain instead of the institutional directory.'). |
|
'<br /><br />'; |
|
} |
} |
} |
} |
} |
return ($state,$response,$forcenewuser,\%srch_results); |
return ($currstate,$response,$forcenewuser,\%srch_results); |
} |
} |
|
|
sub directorysrch_check { |
sub directorysrch_check { |
Line 2328 sub directorysrch_check {
|
Line 2557 sub directorysrch_check {
|
my $response; |
my $response; |
my %dom_inst_srch = &Apache::lonnet::get_dom('configuration', |
my %dom_inst_srch = &Apache::lonnet::get_dom('configuration', |
['directorysrch'],$srch->{'srchdomain'}); |
['directorysrch'],$srch->{'srchdomain'}); |
|
my $showdom = &display_domain_info($srch->{'srchdomain'}); |
if (ref($dom_inst_srch{'directorysrch'}) eq 'HASH') { |
if (ref($dom_inst_srch{'directorysrch'}) eq 'HASH') { |
if (!$dom_inst_srch{'directorysrch'}{'available'}) { |
if (!$dom_inst_srch{'directorysrch'}{'available'}) { |
return &mt('Institutional directory search unavailable in domain: [_1]',$srch->{'srchdomain'}); |
return &mt('Institutional directory search is not available in domain: [_1]',$showdom); |
} |
} |
if ($dom_inst_srch{'directorysrch'}{'localonly'}) { |
if ($dom_inst_srch{'directorysrch'}{'localonly'}) { |
if ($env{'request.role.domain'} ne $srch->{'srchdomain'}) { |
if ($env{'request.role.domain'} ne $srch->{'srchdomain'}) { |
return &mt('Insitutional directory search in domain: [_1] is only allowed for users with a current role in the domain.',$srch->{'srchdomain'}); |
return &mt('Institutional directory search in domain: [_1] is only allowed for users with a current role in the domain.',$showdom); |
} |
} |
my @usertypes = split(/:/,$env{'environment.inststatus'}); |
my @usertypes = split(/:/,$env{'environment.inststatus'}); |
if (!@usertypes) { |
if (!@usertypes) { |
Line 2355 sub directorysrch_check {
|
Line 2585 sub directorysrch_check {
|
push (@longtypes,$insttypes->{$item}); |
push (@longtypes,$insttypes->{$item}); |
} |
} |
my $insttype_str = join(', ',@longtypes); |
my $insttype_str = join(', ',@longtypes); |
return &mt('Directory search in domain: [_1] is unavailable to your user type: ',$srch->{'srchdomain'}).$insttype_str; |
return &mt('Institutional directory search in domain: [_1] is not available to your user type: ',$showdom).$insttype_str; |
} |
} |
} else { |
} else { |
$can_search = 1; |
$can_search = 1; |
} |
} |
} else { |
} else { |
return &mt('Directory search has not been configured for domain: [_1]',$srch->{'srchdomain'}); |
return &mt('Institutional directory search has not been configured for domain: [_1]',$showdom); |
} |
} |
my %longtext = &Apache::lonlocal::texthash ( |
my %longtext = &Apache::lonlocal::texthash ( |
uname => 'username', |
uname => 'username', |
lastfirst => 'last name, first name', |
lastfirst => 'last name, first name', |
lastname => 'last name', |
lastname => 'last name', |
contains => 'is contained in', |
contains => 'contains', |
exact => 'as exact match to' |
exact => 'as exact match to', |
|
begins => 'begins with', |
); |
); |
if ($can_search) { |
if ($can_search) { |
if (ref($dom_inst_srch{'directorysrch'}{'searchby'}) eq 'ARRAY') { |
if (ref($dom_inst_srch{'directorysrch'}{'searchby'}) eq 'ARRAY') { |
if (!grep(/^\Q$srch->{'srchby'}\E$/,@{$dom_inst_srch{'directorysrch'}{'searchby'}})) { |
if (!grep(/^\Q$srch->{'srchby'}\E$/,@{$dom_inst_srch{'directorysrch'}{'searchby'}})) { |
return &mt('Directory search in domain: [_1] is not available for searching by [_2]',$srch->{'srchdomain'},$longtext{$srch->{'srchby'}}); |
return &mt('Institutional directory search in domain: [_1] is not available for searching by "[_2]"',$showdom,$longtext{$srch->{'srchby'}}); |
} |
} |
} else { |
} else { |
return &mt('Directory search in domain: [_1] is not available.', $srch->{'srchdomain'}); |
return &mt('Institutional directory search in domain: [_1] is not available.', $showdom); |
} |
} |
} |
} |
if ($can_search) { |
if ($can_search) { |
if (($dom_inst_srch{'directorysrch'}{'searchtypes'} eq 'specify') || |
if (ref($dom_inst_srch{'directorysrch'}{'searchtypes'}) eq 'ARRAY') { |
($dom_inst_srch{'directorysrch'}{'searchtypes'} eq $srch->{'srchtype'})) { |
if (grep(/^\Q$srch->{'srchtype'}\E/,@{$dom_inst_srch{'directorysrch'}{'searchtypes'}})) { |
return 'ok'; |
return 'ok'; |
} else { |
} else { |
return &mt('Directory search in domain [_1] is not available for the requested search type: [_2]',$srch->{'srchdomain'},$longtext{$srch->{'srchtype'}}); |
return &mt('Institutional directory search in domain [_1] is not available for the requested search type: "[_2]"',$showdom,$longtext{$srch->{'srchtype'}}); |
|
} |
|
} else { |
|
if ((($dom_inst_srch{'directorysrch'}{'searchtypes'} eq 'specify') && |
|
($srch->{'srchtype'} eq 'exact' || $srch->{'srchtype'} eq 'contains')) || |
|
($dom_inst_srch{'directorysrch'}{'searchtypes'} eq $srch->{'srchtype'})) { |
|
return 'ok'; |
|
} else { |
|
return &mt('Institutional directory search in domain [_1] is not available for the requested search type: "[_2]"',$showdom,$longtext{$srch->{'srchtype'}}); |
|
} |
} |
} |
} |
} |
} |
} |
|
|
|
|
sub get_courseusers { |
sub get_courseusers { |
my %advhash; |
my %advhash; |
|
my $classlist = &Apache::loncoursedata::get_classlist(); |
my %coursepersonnel=&Apache::lonnet::get_course_adv_roles(); |
my %coursepersonnel=&Apache::lonnet::get_course_adv_roles(); |
foreach my $role (sort(keys(%coursepersonnel))) { |
foreach my $role (sort(keys(%coursepersonnel))) { |
foreach my $user (split(/\,/,$coursepersonnel{$role})) { |
foreach my $user (split(/\,/,$coursepersonnel{$role})) { |
$advhash{$user} = ''; |
if (!exists($classlist->{$user})) { |
|
$classlist->{$user} = []; |
|
} |
} |
} |
} |
} |
my $classlist = &Apache::loncoursedata::get_classlist(); |
return $classlist; |
my %combined = (%advhash, %{$classlist}); |
|
return %combined; |
|
} |
} |
|
|
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', |
'lastfirst' => 'last name, first name', |
'lastfirst' => 'last name, first name', |
'crs' => 'this course', |
'crs' => 'this course', |
'dom' => 'this domain', |
'dom' => 'LON-CAPA domain: ', |
'instd' => "your institution's directory", |
'instd' => 'the institutional directory for domain: ', |
); |
); |
|
|
my %single = ( |
my %single = ( |
|
begins => 'A match', |
contains => 'A match', |
contains => 'A match', |
exact => 'An exact match', |
exact => 'An exact match', |
); |
); |
my %nomatch = ( |
my %nomatch = ( |
|
begins => 'No match', |
contains => 'No match', |
contains => 'No match', |
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 the $names{$srch->{'srchby'}} ([_1]) in $names{$srch->{'srchin'}}.",$srch->{'srchterm'}); |
|
if ($srch->{'srchin'} eq 'dom' || $srch->{'srchin'} eq 'instd') { |
|
$response .= &display_domain_info($srch->{'srchdomain'}); |
|
} |
} 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 the $names{$srch->{'srchby'}} ([_1]) in $names{$srch->{'srchin'}}",$srch->{'srchterm'}); |
|
if ($srch->{'srchin'} eq 'dom' || $srch->{'srchin'} eq 'instd') { |
|
$response .= &display_domain_info($srch->{'srchdomain'}); |
|
} |
|
$response .= '</span>'; |
if ($srch->{'srchin'} ne 'alc') { |
if ($srch->{'srchin'} ne 'alc') { |
$forcenewuser = 1; |
$forcenewuser = 1; |
my $cansrchinst = 0; |
my $cansrchinst = 0; |
Line 2442 sub build_search_response {
|
Line 2691 sub build_search_response {
|
} |
} |
} |
} |
} |
} |
if (($srch->{'srchby'} eq 'lastfirst') || |
if ((($srch->{'srchby'} eq 'lastfirst') || |
($srch->{'srchby'} eq 'lastname')) { |
($srch->{'srchby'} eq 'lastname')) && |
if ($srch->{'srchin'} eq 'crs') { |
($srch->{'srchin'} eq 'dom')) { |
$response .= '<br />'.&mt('You may want to broaden your search to the whole domain.'); |
if ($cansrchinst) { |
} elsif ($srch->{'srchin'} eq 'dom') { |
$response .= '<br />'.&mt('You may want to broaden your search to a search of the institutional directory for the domain.'); |
if ($cansrchinst) { |
|
$response .= '<br />'.&mt('You may want to broaden your search to a search of the institutional directory for this domain.'); |
|
} |
|
} |
} |
} |
} |
$response .= '<br />'.&mt("To add as a new user:").'<ul><li>'.&mt("Enter the proposed username in the <i>'Search for'</i> box").'</li><li>'.&mt("Set <i>'Make new user if no match found</i>' to <b>Yes</b>").'</li><li>'.&mt("Click <i>'Search'</i>").'</li></ul>'.&mt("Note: you can only create new users in the domain of your current role - [_1]",$env{'request.role.domain'}).'<br /><br />'; |
if ($srch->{'srchin'} eq 'crs') { |
|
$response .= '<br />'.&mt('You may want to broaden your search to the selected LON-CAPA domain.'); |
|
} |
|
} |
|
if (!($srch->{'srchby'} eq 'uname' && $srch->{'srchin'} eq 'dom' && $srch->{'srchtype'} eq 'exact' && $srch->{'srchdomain'} eq $env{'request.role.domain'})) { |
|
my $showdom = &display_domain_info($env{'request.role.domain'}); |
|
$response .= '<br /><br />'.&mt("<b>To add a new user</b> (you can only create new users in your current role's domain - <span class=\"LC_cusr_emph\">[_1]</span>):",$env{'request.role.domain'}).'<ul><li>'.&mt("Set 'Domain/institution to search' to: <span class=\"LC_cusr_emph\">[_1]</span>",$showdom).'<li>'.&mt("Set 'Search criteria' to: <span class=\"LC_cusr_emph\">'username is ...... in selected LON-CAPA domain'").'</span></li><li>'.&mt('Provide the proposed username').'</li><li>'.&mt('Search').'</li></ul><br />'; |
} |
} |
} |
} |
} |
} |
return ($state,$response,$forcenewuser); |
return ($currstate,$response,$forcenewuser); |
|
} |
|
|
|
sub display_domain_info { |
|
my ($dom) = @_; |
|
my $output = $dom; |
|
if ($dom ne '') { |
|
my $domdesc = &Apache::lonnet::domain($dom,'description'); |
|
if ($domdesc ne '') { |
|
$output .= ' <span class="LC_cusr_emph">('.$domdesc.')</span>'; |
|
} |
|
} |
|
return $output; |
} |
} |
|
|
sub crumb_utilities { |
sub crumb_utilities { |
Line 2472 sub crumb_utilities {
|
Line 2736 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(); |
} |
} |
|; |
|; |
Line 2548 sub course_level_table {
|
Line 2819 sub course_level_table {
|
$table .= '<td> </td>'; |
$table .= '<td> </td>'; |
} |
} |
$table .= <<ENDTIMEENTRY; |
$table .= <<ENDTIMEENTRY; |
<td><input type=hidden name="start_$protectedcourse\_$role" value='' /> |
<td><input type="hidden" name="start_$protectedcourse\_$role" value='' /> |
<a href= |
<a href= |
"javascript:pjump('date_start','Start Date $plrole',document.cu.start_$protectedcourse\_$role.value,'start_$protectedcourse\_$role','cu.pres','dateset')">$lt{'ssd'}</a></td> |
"javascript:pjump('date_start','Start Date $plrole',document.cu.start_$protectedcourse\_$role.value,'start_$protectedcourse\_$role','cu.pres','dateset')">$lt{'ssd'}</a></td> |
<td><input type=hidden name="end_$protectedcourse\_$role" value='' /> |
<td><input type="hidden" name="end_$protectedcourse\_$role" value='' /> |
<a href= |
<a href= |
"javascript:pjump('date_end','End Date $plrole',document.cu.end_$protectedcourse\_$role.value,'end_$protectedcourse\_$role','cu.pres','dateset')">$lt{'sed'}</a></td> |
"javascript:pjump('date_end','End Date $plrole',document.cu.end_$protectedcourse\_$role.value,'end_$protectedcourse\_$role','cu.pres','dateset')">$lt{'sed'}</a></td> |
ENDTIMEENTRY |
ENDTIMEENTRY |
Line 2584 ENDTIMEENTRY
|
Line 2855 ENDTIMEENTRY
|
'name="sec_'.$customrole.'" /></td>'; |
'name="sec_'.$customrole.'" /></td>'; |
} |
} |
$table .= <<ENDENTRY; |
$table .= <<ENDENTRY; |
<td><input type=hidden name="start_$customrole" value='' /> |
<td><input type="hidden" name="start_$customrole" value='' /> |
<a href= |
<a href= |
"javascript:pjump('date_start','Start Date $plrole',document.cu.start_$customrole.value,'start_$customrole','cu.pres','dateset')">$lt{'ssd'}</a></td> |
"javascript:pjump('date_start','Start Date $plrole',document.cu.start_$customrole.value,'start_$customrole','cu.pres','dateset')">$lt{'ssd'}</a></td> |
<td><input type=hidden name="end_$customrole" value='' /> |
<td><input type="hidden" name="end_$customrole" value='' /> |
<a href= |
<a href= |
"javascript:pjump('date_end','End Date $plrole',document.cu.end_$customrole.value,'end_$customrole','cu.pres','dateset')">$lt{'sed'}</a></td> |
"javascript:pjump('date_end','End Date $plrole',document.cu.end_$customrole.value,'end_$customrole','cu.pres','dateset')">$lt{'sed'}</a></td> |
ENDENTRY |
ENDENTRY |
Line 2679 sub course_level_dc {
|
Line 2950 sub course_level_dc {
|
'<input type="hidden" name="groups" value="" /></td>'. |
'<input type="hidden" name="groups" value="" /></td>'. |
'</tr></table></td>'; |
'</tr></table></td>'; |
$otheritems .= <<ENDTIMEENTRY; |
$otheritems .= <<ENDTIMEENTRY; |
<td><input type=hidden name="start" value='' /> |
<td><input type="hidden" name="start" value='' /> |
<a href= |
<a href= |
"javascript:pjump('date_start','Start Date',document.cu.start.value,'start','cu.pres','dateset')">$lt{'ssd'}</a></td> |
"javascript:pjump('date_start','Start Date',document.cu.start.value,'start','cu.pres','dateset')">$lt{'ssd'}</a></td> |
<td><input type=hidden name="end" value='' /> |
<td><input type="hidden" name="end" value='' /> |
<a href= |
<a href= |
"javascript:pjump('date_end','End Date',document.cu.end.value,'end','cu.pres','dateset')">$lt{'sed'}</a></td> |
"javascript:pjump('date_end','End Date',document.cu.end.value,'end','cu.pres','dateset')">$lt{'sed'}</a></td> |
ENDTIMEENTRY |
ENDTIMEENTRY |