version 1.181, 2007/08/31 12:33:32
|
version 1.190, 2007/10/22 22:16:38
|
Line 65 use Apache::lonnet;
|
Line 65 use Apache::lonnet;
|
use Apache::loncommon; |
use Apache::loncommon; |
use Apache::lonlocal; |
use Apache::lonlocal; |
use Apache::longroup; |
use Apache::longroup; |
|
use Apache::lonuserutils; |
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 76 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, |
|
); |
|
my %abv_auth = &auth_abbrev(); |
|
if ($curr_authtype =~ /^(krb4|krb5|internal|localauth|unix):$/) { |
|
my $long_auth = $1; |
|
my %abv_auth = &auth_abbrev(); |
|
$param{'curr_authtype'} = $abv_auth{$long_auth}; |
|
if ($long_auth =~ /^krb(4|5)$/) { |
|
$param{'curr_kerb_ver'} = $1; |
|
} |
|
} |
# 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 92 sub initialize_authen_forms {
|
Line 102 sub initialize_authen_forms {
|
$authformloc = &Apache::loncommon::authform_local(%param); |
$authformloc = &Apache::loncommon::authform_local(%param); |
} |
} |
|
|
|
sub auth_abbrev { |
# ======================================================= Existing Custom Roles |
my %abv_auth = ( |
|
krb4 => 'krb', |
sub my_custom_roles { |
internal => 'int', |
my %returnhash=(); |
localuth => 'loc', |
my %rolehash=&Apache::lonnet::dump('roles'); |
unix => 'fsys', |
foreach my $key (keys %rolehash) { |
); |
if ($key=~/^rolesdef\_(\w+)$/) { |
return %abv_auth; |
$returnhash{$1}=$1; |
|
} |
|
} |
|
return %returnhash; |
|
} |
} |
|
|
# ==================================================== Figure out author access |
# ==================================================== Figure out author access |
Line 175 END_SCRIPT
|
Line 181 END_SCRIPT
|
} |
} |
my $output = $quota_javascript. |
my $output = $quota_javascript. |
'<h3>'.$lt{'disk'}.'</h3>'. |
'<h3>'.$lt{'disk'}.'</h3>'. |
$lt{'cuqu'}.': '.$currquota.' Mb. '. |
&Apache::loncommon::start_data_table(). |
$defaultinfo.'<br /><span class="LC_nobreak">'.$lt{'chqu'}. |
&Apache::loncommon::start_data_table_row(). |
|
'<td>'.$lt{'cuqu'}.': '.$currquota.' Mb. '. |
|
$defaultinfo.'</td>'. |
|
&Apache::loncommon::end_data_table_row(). |
|
&Apache::loncommon::start_data_table_row(). |
|
'<td><span class="LC_nobreak">'.$lt{'chqu'}. |
': <label>'. |
': <label>'. |
'<input type="radio" name="customquota" value="0" '. |
'<input type="radio" name="customquota" value="0" '. |
$custom_off.' onchange="javascript:quota_changes('."'custom'".')" |
$custom_off.' onchange="javascript:quota_changes('."'custom'".')" |
Line 186 END_SCRIPT
|
Line 197 END_SCRIPT
|
$lt{'cust'}.':</label> '. |
$lt{'cust'}.':</label> '. |
'<input type="text" name="portfolioquota" size ="5" value="'. |
'<input type="text" name="portfolioquota" size ="5" value="'. |
$showquota.'" onfocus="javascript:quota_changes('."'quota'".')" '. |
$showquota.'" onfocus="javascript:quota_changes('."'quota'".')" '. |
'/> Mb'; |
'/> Mb</span></td>'. |
|
&Apache::loncommon::end_data_table_row(). |
|
&Apache::loncommon::end_data_table(); |
return $output; |
return $output; |
} |
} |
|
|
Line 212 sub print_username_entry_form {
|
Line 225 sub print_username_entry_form {
|
'onload' => "javascript:setFormElements(document.$formtoset)", |
'onload' => "javascript:setFormElements(document.$formtoset)", |
); |
); |
my $start_page = |
my $start_page = |
&Apache::loncommon::start_page('Create Users, Change User Privileges', |
&Apache::loncommon::start_page('User Management', |
$jscript,{'add_entries' => \%loaditems,}); |
$jscript,{'add_entries' => \%loaditems,}); |
&Apache::lonhtmlcommon::add_breadcrumb |
if ($env{'form.action'} eq 'singleuser') { |
({href=>"javascript:backPage(document.crtuser)", |
&Apache::lonhtmlcommon::add_breadcrumb |
text=>"User modify/custom role edit", |
({href=>"javascript:backPage(document.crtuser)", |
faq=>282,bug=>'Instructor Interface',}); |
text=>"Single user search", |
|
faq=>282,bug=>'Instructor Interface',}); |
|
} elsif ($env{'form.action'} eq 'custom') { |
|
&Apache::lonhtmlcommon::add_breadcrumb |
|
({href=>"javascript:backPage(document.crtuser)", |
|
text=>"Pick custom role",}); |
|
} |
my $crumbs = &Apache::lonhtmlcommon::breadcrumbs('User Management'); |
my $crumbs = &Apache::lonhtmlcommon::breadcrumbs('User Management'); |
my %existingroles=&my_custom_roles(); |
my %existingroles=&Apache::lonuserutils::my_custom_roles(); |
my $choice=&Apache::loncommon::select_form('make new role','rolename', |
my $choice=&Apache::loncommon::select_form('make new role','rolename', |
('make new role' => 'Generate new role ...',%existingroles)); |
('make new role' => 'Generate new role ...',%existingroles)); |
my %lt=&Apache::lonlocal::texthash( |
my %lt=&Apache::lonlocal::texthash( |
'srch' => "User Search", |
'srch' => "User Search", |
or => "or", |
or => "or", |
'siur' => "Set Individual User Roles", |
|
'usr' => "Username", |
'usr' => "Username", |
'dom' => "Domain", |
'dom' => "Domain", |
'ecrp' => "Edit Custom Role Privileges", |
'ecrp' => "Edit Custom Role Privileges", |
Line 241 sub print_username_entry_form {
|
Line 258 sub print_username_entry_form {
|
if ($sellink) { |
if ($sellink) { |
$sellink = "$lt{'or'} ".$sellink; |
$sellink = "$lt{'or'} ".$sellink; |
} |
} |
$r->print(" |
$r->print($start_page."\n".$crumbs); |
$start_page |
if ($env{'form.action'} eq 'singleuser') { |
$crumbs |
$r->print(" |
<h2>$lt{siur}$helpsiur</h2> |
<h3>$lt{'srch'} $sellink $lt{'mod'}$helpsiur</h3> |
<h3>$lt{'srch'} $sellink $lt{'mod'}</h3> |
|
$response"); |
$response"); |
$r->print(&entry_form($defdom,$srch,$forcenewuser)); |
$r->print(&entry_form($defdom,$srch,$forcenewuser)); |
if (&Apache::lonnet::allowed('mcr','/')) { |
} elsif ($env{'form.action'} eq 'custom') { |
$r->print(<<ENDCUSTOM); |
if (&Apache::lonnet::allowed('mcr','/')) { |
|
$r->print(<<ENDCUSTOM); |
<form action="/adm/createuser" method="post" name="docustom"> |
<form action="/adm/createuser" method="post" name="docustom"> |
|
<input type="hidden" name="action" value="$env{'form.action'}" /> |
<input type="hidden" name="phase" value="selected_custom_edit" /> |
<input type="hidden" name="phase" value="selected_custom_edit" /> |
<h2>$lt{'ecrp'}$helpecpr</h2> |
<h3>$lt{'ecrp'}$helpecpr</h3> |
$lt{'nr'}: $choice <input type="text" size="15" name="newrolename" /><br /> |
$lt{'nr'}: $choice <input type="text" size="15" name="newrolename" /><br /> |
<input name="customeditor" type="submit" value="$lt{'cre'}" /> |
<input name="customeditor" type="submit" value="$lt{'cre'}" /> |
</form> |
</form> |
ENDCUSTOM |
ENDCUSTOM |
|
} |
} |
} |
$r->print(&Apache::loncommon::end_page()); |
$r->print(&Apache::loncommon::end_page()); |
} |
} |
Line 269 sub entry_form {
|
Line 288 sub entry_form {
|
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="action" value="$env{'form.action'}" /> |
<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(document.crtuser)" /> |
<input name="userrole" type="button" value="$srchbutton" onclick="javascript:validateEntry(document.crtuser)" /> |
Line 306 END
|
Line 326 END
|
|
|
# =================================================================== Phase two |
# =================================================================== Phase two |
sub print_user_selection_page { |
sub print_user_selection_page { |
my ($r,$response,$srch,$srch_results,$context,$srcharray) = @_; |
my ($r,$response,$srch,$srch_results,$operation,$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 340 ENDSCRIPT
|
Line 360 ENDSCRIPT
|
'firstname' => "first name", |
'firstname' => "first name", |
'permanentemail' => "permanent e-mail", |
'permanentemail' => "permanent e-mail", |
); |
); |
if ($context eq 'createuser') { |
if ($operation eq 'createuser') { |
$r->print(&Apache::loncommon::start_page('Create Users, Change User Privileges',$jscript)); |
$r->print(&Apache::loncommon::start_page('User Management',$jscript)); |
&Apache::lonhtmlcommon::add_breadcrumb |
&Apache::lonhtmlcommon::add_breadcrumb |
({href=>"javascript:backPage(document.usersrchform,'','')", |
({href=>"javascript:backPage(document.usersrchform,'','')", |
text=>"User modify/custom role edit", |
text=>"Create/modify user", |
faq=>282,bug=>'Instructor Interface',}, |
faq=>282,bug=>'Instructor Interface',}, |
{href=>"javascript:backPage(document.usersrchform,'get_user_info','select')", |
{href=>"javascript:backPage(document.usersrchform,'get_user_info','select')", |
text=>"Select User", |
text=>"Select User", |
Line 400 ENDSCRIPT
|
Line 420 ENDSCRIPT
|
' <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="currstate" 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". |
|
' <input type="hidden" name="action" value="singleuser" />'."\n"); |
$r->print($response); |
$r->print($response); |
if ($context eq 'createuser') { |
if ($operation eq 'createuser') { |
$r->print('</form>'.&Apache::loncommon::end_page()); |
$r->print('</form>'.&Apache::loncommon::end_page()); |
} else { |
} else { |
$r->print('<input type="hidden" name="action" value="enrollstudent" />'."\n". |
$r->print('<input type="hidden" name="action" value="enrollstudent" />'."\n". |
Line 420 sub print_user_query_page {
|
Line 441 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 %abv_auth = &auth_abbrev(); |
|
my ($curr_authtype,$instsrch,$rulematch,$rules,%inst_results, |
|
$curr_kerb_ver,$newuser); |
|
my $uhome=&Apache::lonnet::homeserver($ccuname,$ccdomain); |
|
if ($uhome eq 'no_host') { |
|
$newuser = 1; |
|
$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 { |
|
$newuser = 0; |
|
my $currentauth = |
|
&Apache::lonnet::queryauthenticate($ccuname,$ccdomain); |
|
if ($currentauth =~ /^(krb4|krb5|unix|internal|localauth):/) { |
|
$curr_authtype = $abv_auth{$1}; |
|
if ($currentauth =~ /^krb(4|5)/) { |
|
$curr_kerb_ver = $1; |
|
} |
|
} |
|
} |
if ($response) { |
if ($response) { |
$response = '<br />'.$response |
$response = '<br />'.$response |
} |
} |
Line 434 sub print_user_modification_page {
|
Line 487 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, |
|
curr_kerb_ver => $curr_kerb_ver, |
|
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 642 ENDSECCODE
|
Line 698 ENDSECCODE
|
$nondc_setsection_code,$groupslist); |
$nondc_setsection_code,$groupslist); |
|
|
my ($jsback,$elements) = &crumb_utilities(); |
my ($jsback,$elements) = &crumb_utilities(); |
|
my $javascript_validations; |
|
if ((&Apache::lonnet::allowed('mau',$ccdomain)) || ($uhome eq 'no_host')) { |
|
my ($krbdef,$krbdefdom) = |
|
&Apache::loncommon::get_kerberos_defaults($ccdomain); |
|
$javascript_validations = |
|
&Apache::lonuserutils::javascript_validations('auth',$krbdefdom,undef, |
|
undef,$ccdomain); |
|
} |
$js .= "\n". |
$js .= "\n". |
'<script type="text/javascript">'."\n".$jsback."\n".'</script>'; |
'<script type="text/javascript">'."\n".$jsback."\n". |
|
$javascript_validations.'</script>'; |
my $start_page = |
my $start_page = |
&Apache::loncommon::start_page('Create Users, Change User Privileges', |
&Apache::loncommon::start_page('User Management', |
$js,{'add_entries' => \%loaditem,}); |
$js,{'add_entries' => \%loaditem,}); |
&Apache::lonhtmlcommon::add_breadcrumb |
&Apache::lonhtmlcommon::add_breadcrumb |
({href=>"javascript:backPage(document.cu)", |
({href=>"javascript:backPage(document.cu)", |
text=>"User modify/custom role edit", |
text=>"Create/modify user", |
faq=>282,bug=>'Instructor Interface',}); |
faq=>282,bug=>'Instructor Interface',}); |
|
|
if ($env{'form.phase'} eq 'userpicked') { |
if ($env{'form.phase'} eq 'userpicked') { |
Line 668 ENDSECCODE
|
Line 731 ENDSECCODE
|
|
|
my $forminfo =<<"ENDFORMINFO"; |
my $forminfo =<<"ENDFORMINFO"; |
<form action="/adm/createuser" method="post" name="cu"> |
<form action="/adm/createuser" method="post" name="cu"> |
<input type="hidden" name="phase" value="update_user_data" /> |
<input type="hidden" name="phase" value="update_user_data" /> |
<input type="hidden" name="ccuname" value="$ccuname" /> |
<input type="hidden" name="ccuname" value="$ccuname" /> |
<input type="hidden" name="ccdomain" value="$ccdomain" /> |
<input type="hidden" name="ccdomain" value="$ccdomain" /> |
<input type="hidden" name="pres_value" value="" /> |
<input type="hidden" name="pres_value" value="" /> |
<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 683 ENDFORMINFO
|
Line 745 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,$dirsrchres); |
|
if ($newuser) { |
|
if (&directorysrch_check($instsrch) eq 'ok') { |
|
($dirsrchres,%dirsrch_results) = &Apache::lonnet::inst_directory_query($instsrch); |
|
if ($dirsrchres eq 'ok') { |
|
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( |
|
'cnu' => "Create New User", |
|
'nu' => "New User", |
|
'id' => "in domain", |
|
'pd' => "Personal Data", |
|
'fn' => "First Name", |
|
'mn' => "Middle Name", |
|
'ln' => "Last Name", |
|
'gen' => "Generation", |
|
'mail' => "Permanent e-mail address", |
|
'idsn' => "ID/Student Number", |
|
'hs' => "Home Server", |
|
'lg' => "Login Data" |
|
); |
|
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 = '<br />'.&portfolio_quota($ccuname,$ccdomain); |
} |
} |
my $genhelp=&Apache::loncommon::help_open_topic('Generation'); |
&initialize_authen_forms($ccdomain); |
&initialize_authen_forms(); |
my %lt=&Apache::lonlocal::texthash( |
$r->print(<<ENDNEWUSER); |
'cnu' => 'Create New User', |
|
'ind' => 'in domain', |
|
'lg' => 'Login Data', |
|
'hs' => "Home Server", |
|
); |
|
$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> |
|
<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{'cnu'} "$ccuname" $lt{'ind'} $ccdomain</h3> |
<p> |
ENDTITLE |
<table> |
$r->print('<div class="LC_left_float">'. |
<tr><td>$lt{'fn'} </td> |
&personal_data_display($ccuname,$ccdomain,$newuser, |
<td><input type="text" name="cfirst" size="15" value="$inst_results{'firstname'}" /></td></tr> |
%inst_results)); |
<tr><td>$lt{'mn'} </td> |
my ($home_server_pick,$numlib) = |
<td><input type="text" name="cmiddle" size="15" value="$inst_results{'middlename'}" /></td></tr> |
&Apache::loncommon::home_server_form_item($ccdomain,'hserver', |
<tr><td>$lt{'ln'} </td> |
'default','hide'); |
<td><input type="text" name="clast" size="15" value="$inst_results{'lastname'}" /></td></tr> |
if ($numlib > 1) { |
<tr><td>$lt{'gen'}$genhelp</td> |
$r->print(" |
<td><input type="text" name="cgen" size="5" value="$inst_results{'generation'}" /></td></tr> |
<br /> |
<tr><td>$lt{'mail'}</td> |
$lt{'hs'}: $home_server_pick |
<td><input type="text" name="cemail" size="20" value="$inst_results{'permanentemail'}" /></td></tr> |
<br />"); |
</table> |
} else { |
$lt{'idsn'} <input type="text" name="cstid" size="15" value="$inst_results{'id'}" /></p> |
$r->print($home_server_pick); |
$lt{'hs'}: <select name="hserver" size="1"> $home_server_list </select> |
} |
<hr /> |
$r->print('</div>'."\n".'<div class="LC_left_float"><h3>'. |
<h3>$lt{'lg'}</h3> |
$lt{'lg'}.'</h3>'); |
<p>$generalrule </p> |
my ($fixedauth,$varauth,$authmsg); |
<p>$authformkrb </p> |
if ($rulematch) { |
<p>$authformint </p> |
if (ref($rules) eq 'HASH') { |
<p>$authformfsys</p> |
if (ref($rules->{$rulematch}) eq 'HASH') { |
<p>$authformloc </p> |
my $authtype = $rules->{$rulematch}{'authtype'}; |
<hr /> |
if ($authtype !~ /^(krb4|krb5|int|fsys|loc)$/) { |
$portfolioform |
$r->print(&Apache::lonuserutils::set_login($ccdomain,$authformkrb,$authformint,$authformloc)); |
ENDNEWUSER |
} 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(&Apache::lonuserutils::set_login($ccdomain,$authformkrb,$authformint,$authformloc)); |
|
} |
|
} |
|
if ($authmsg) { |
|
$r->print(<<ENDAUTH); |
|
$fixedauth |
|
$authmsg |
|
$varauth |
|
ENDAUTH |
|
} |
|
} else { |
|
$r->print(&Apache::lonuserutils::set_login($ccdomain,$authformkrb,$authformint,$authformloc)); |
|
} |
|
$r->print(<<ENDPORT); |
|
$portfolioform |
|
</div><div class="LC_clear_float_footer"></div> |
|
ENDPORT |
} else { # user already exists |
} else { # user already exists |
my %lt=&Apache::lonlocal::texthash( |
my %lt=&Apache::lonlocal::texthash( |
'cup' => "Change User Privileges", |
'cup' => "Existing user ", |
'usr' => "User", |
|
'id' => "in domain", |
'id' => "in domain", |
'fn' => "first name", |
|
'mn' => "middle name", |
|
'ln' => "last name", |
|
'gen' => "generation", |
|
'email' => "permanent e-mail", |
|
); |
); |
$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> |
<h3>$lt{'cup'} "$ccuname" $lt{'id'} "$ccdomain"</h3> |
ENDCHANGEUSER |
ENDCHANGEUSER |
# Get the users information |
$r->print('<div class="LC_left_float">'. |
my %userenv = |
&personal_data_display($ccuname,$ccdomain,$newuser, |
&Apache::lonnet::get('environment', |
%inst_results). |
['firstname','middlename','lastname','generation', |
'</div>'); |
'permanentemail','portfolioquota'],$ccdomain,$ccuname); |
my $user_auth_text = |
my %rolesdump=&Apache::lonnet::dump('roles',$ccdomain,$ccuname); |
&user_authentication($ccuname,$ccdomain,$krbdefdom,\%abv_auth); |
$r->print(' |
my $user_quota_text; |
<hr />'. |
if (&Apache::lonnet::allowed('mpq',$ccdomain)) { |
&Apache::loncommon::start_data_table(). |
# Current user has quota modification privileges |
&Apache::loncommon::start_data_table_header_row(). |
$user_quota_text = &portfolio_quota($ccuname,$ccdomain); |
'<th>'.$lt{'fn'}.'</th><th>'.$lt{'mn'}.'</th><th>'.$lt{'ln'}.'</th><th>'.$lt{'gen'}.'</th><th>'.$lt{'email'}.'</th>'. |
} elsif (&Apache::lonnet::allowed('mpq',$env{'request.role.domain'})) { |
&Apache::loncommon::end_data_table_header_row(). |
# Get the user's portfolio information |
&Apache::loncommon::start_data_table_row()); |
my %portq = &Apache::lonnet::get('environment',['portfolioquota'], |
foreach my $item ('firstname','middlename','lastname','generation','permanentemail') { |
$ccdomain,$ccuname); |
if (&Apache::lonnet::allowed('mau',$ccdomain)) { |
|
$r->print(<<"END"); |
my %lt=&Apache::lonlocal::texthash( |
<td><input type="text" name="c$item" value="$userenv{$item}" size="15" /></td> |
'dska' => "Disk space allocated to user's portfolio files", |
END |
'youd' => "You do not have privileges to modify the portfolio quota for this user.", |
} else { |
'ichr' => "If a change is required, contact a domain coordinator for the domain", |
$r->print('<td>'.$userenv{$item}.'</td>'); |
); |
} |
$user_quota_text = <<ENDNOPORTPRIV; |
|
<h3>$lt{'dska'}</h3> |
|
$lt{'youd'} $lt{'ichr'}: $ccdomain |
|
ENDNOPORTPRIV |
|
} |
|
if ($user_auth_text ne '') { |
|
$r->print('<div class="LC_left_float">'.$user_auth_text); |
|
if ($user_quota_text ne '') { |
|
$r->print($user_quota_text); |
|
} |
|
$r->print('</div>'); |
|
|
|
} elsif ($user_quota_text ne '') { |
|
$r->print('<div class="LC_left_float">'.$user_quota_text.'</div>'); |
} |
} |
$r->print(&Apache::loncommon::end_data_table_row(). |
$r->print('<div class="LC_clear_float_footer"></div>'); |
&Apache::loncommon::end_data_table()); |
my %rolesdump=&Apache::lonnet::dump('roles',$ccdomain,$ccuname); |
# Build up table of user roles to allow revocation of a role. |
# Build up table of user roles to allow revocation of a role. |
my ($tmp) = keys(%rolesdump); |
my ($tmp) = keys(%rolesdump); |
unless ($tmp =~ /^(con_lost|error)/i) { |
unless ($tmp =~ /^(con_lost|error)/i) { |
Line 952 END
|
Line 1019 END
|
$plaintext=&Apache::lonnet::plaintext($role_code,$class) |
$plaintext=&Apache::lonnet::plaintext($role_code,$class) |
} else { |
} else { |
$plaintext= |
$plaintext= |
"Customrole '$croletitle' defined by $croleuname\@$croleudom"; |
"Customrole '$croletitle'<br />defined by $croleuname\@$croleudom"; |
} |
} |
$row.= '</td><td>'.$plaintext. |
$row.= '</td><td>'.$plaintext. |
'</td><td>'.$area. |
'</td><td>'.$area. |
Line 988 END
|
Line 1055 END
|
} |
} |
if ($rolesdisplay == 1) { |
if ($rolesdisplay == 1) { |
$r->print(' |
$r->print(' |
<hr /> |
|
<h3>'.$lt{'rer'}.'</h3>'. |
<h3>'.$lt{'rer'}.'</h3>'. |
&Apache::loncommon::start_data_table("LC_createuser"). |
&Apache::loncommon::start_data_table("LC_createuser"). |
&Apache::loncommon::start_data_table_header_row(). |
&Apache::loncommon::start_data_table_header_row(). |
Line 1004 END
|
Line 1070 END
|
$r->print(&Apache::loncommon::end_data_table()); |
$r->print(&Apache::loncommon::end_data_table()); |
} |
} |
} # End of unless |
} # End of unless |
my $currentauth=&Apache::lonnet::queryauthenticate($ccuname,$ccdomain); |
|
if ($currentauth=~/^krb(4|5):/) { |
|
$currentauth=~/^krb(4|5):(.*)/; |
|
my $krbdefdom=$2; |
|
my %param = ( formname => 'document.cu', |
|
kerb_def_dom => $krbdefdom |
|
); |
|
$loginscript = &Apache::loncommon::authform_header(%param); |
|
} |
|
# Check for a bad authentication type |
|
unless ($currentauth=~/^krb(4|5):/ or |
|
$currentauth=~/^unix:/ or |
|
$currentauth=~/^internal:/ or |
|
$currentauth=~/^localauth:/ |
|
) { # bad authentication scheme |
|
if (&Apache::lonnet::allowed('mau',$ccdomain)) { |
|
&initialize_authen_forms(); |
|
my %lt=&Apache::lonlocal::texthash( |
|
'err' => "ERROR", |
|
'uuas' => "This user has an unrecognized authentication scheme", |
|
'sldb' => "Please specify login data below", |
|
'ld' => "Login Data" |
|
); |
|
$r->print(<<ENDBADAUTH); |
|
<hr /> |
|
<script type="text/javascript" language="Javascript"> |
|
$loginscript |
|
</script> |
|
<font color='#ff0000'>$lt{'err'}:</font> |
|
$lt{'uuas'} ($currentauth). $lt{'sldb'}. |
|
<h3>$lt{'ld'}</h3> |
|
<p>$generalrule</p> |
|
<p>$authformkrb</p> |
|
<p>$authformint</p> |
|
<p>$authformfsys</p> |
|
<p>$authformloc</p> |
|
ENDBADAUTH |
|
} else { |
|
# This user is not allowed to modify the user's |
|
# authentication scheme, so just notify them of the problem |
|
my %lt=&Apache::lonlocal::texthash( |
|
'err' => "ERROR", |
|
'uuas' => "This user has an unrecognized authentication scheme", |
|
'adcs' => "Please alert a domain coordinator of this situation" |
|
); |
|
$r->print(<<ENDBADAUTH); |
|
<hr /> |
|
<font color="#ff0000"> $lt{'err'}: </font> |
|
$lt{'uuas'} ($currentauth). $lt{'adcs'}. |
|
<hr /> |
|
ENDBADAUTH |
|
} |
|
} else { # Authentication type is valid |
|
my $authformcurrent=''; |
|
my $authform_other=''; |
|
&initialize_authen_forms(); |
|
if ($currentauth=~/^krb(4|5):/) { |
|
$authformcurrent=$authformkrb; |
|
$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)) { |
|
# Current user has login modification privileges |
|
my %lt=&Apache::lonlocal::texthash( |
|
'ccld' => "Change Current Login Data", |
|
'enld' => "Enter New Login Data" |
|
); |
|
$r->print(<<ENDOTHERAUTHS); |
|
<hr /> |
|
<script type="text/javascript" language="Javascript"> |
|
$loginscript |
|
</script> |
|
<h3>$lt{'ccld'}</h3> |
|
<p>$generalrule</p> |
|
<p>$authformnop</p> |
|
<p>$authformcurrent</p> |
|
<h3>$lt{'enld'}</h3> |
|
$authform_other |
|
ENDOTHERAUTHS |
|
} else { |
|
if (&Apache::lonnet::allowed('mau',$env{'request.role.domain'})) { |
|
my %lt=&Apache::lonlocal::texthash( |
|
'ccld' => "Change Current Login Data", |
|
'yodo' => "You do not have privileges to modify the authentication configuration for this user.", |
|
'ifch' => "If a change is required, contact a domain coordinator for the domain", |
|
); |
|
$r->print(<<ENDNOPRIV); |
|
<hr /> |
|
<h3>$lt{'ccld'}</h3> |
|
$lt{'yodo'} $lt{'ifch'}: $ccdomain |
|
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 new user/old user logic |
} ## End of new user/old user logic |
$r->print('<hr /><h3>'.&mt('Add Roles').'</h3>'); |
my $addrolesdisplay = 0; |
|
$r->print('<h3>'.&mt('Add Roles').'</h3>'); |
# |
# |
# Co-Author |
# Co-Author |
# |
# |
if (&authorpriv($env{'user.name'},$env{'request.role.domain'}) && |
if (&authorpriv($env{'user.name'},$env{'request.role.domain'}) && |
($env{'user.name'} ne $ccuname || $env{'user.domain'} ne $ccdomain)) { |
($env{'user.name'} ne $ccuname || $env{'user.domain'} ne $ccdomain)) { |
# No sense in assigning co-author role to yourself |
# No sense in assigning co-author role to yourself |
|
$addrolesdisplay = 1; |
my $cuname=$env{'user.name'}; |
my $cuname=$env{'user.name'}; |
my $cudom=$env{'request.role.domain'}; |
my $cudom=$env{'request.role.domain'}; |
my %lt=&Apache::lonlocal::texthash( |
my %lt=&Apache::lonlocal::texthash( |
Line 1172 ENDNOPRIV
|
Line 1126 ENDNOPRIV
|
"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". |
&Apache::loncommon::end_data_table()); |
&Apache::loncommon::end_data_table()); |
|
} elsif ($env{'request.role'} =~ /^au\./) { |
|
if (!(&authorpriv($env{'user.name'},$env{'request.role.domain'}))) { |
|
$r->print('<span class="LC_error">'. |
|
&mt('You do not have privileges to assign co-author roles.'). |
|
'</span>'); |
|
} elsif (($env{'user.name'} eq $ccuname) && |
|
($env{'user.domain'} eq $ccdomain)) { |
|
$r->print(&mt('Assigning yourself a co-author or assistant co-author role in your own author area in Construction Space is not permitted')); |
|
} |
} |
} |
# |
# |
# Domain level |
# Domain level |
Line 1212 ENDNOPRIV
|
Line 1175 ENDNOPRIV
|
$domaintext.= &Apache::loncommon::end_data_table(); |
$domaintext.= &Apache::loncommon::end_data_table(); |
if ($num_domain_level > 0) { |
if ($num_domain_level > 0) { |
$r->print($domaintext); |
$r->print($domaintext); |
|
$addrolesdisplay = 1; |
} |
} |
# |
# |
# Course and group levels |
# Course level |
# |
# |
|
|
if ($env{'request.role'} =~ m{^dc\./($match_domain)/$}) { |
if ($env{'request.role'} =~ m{^dc\./($match_domain)/$}) { |
$r->print(&course_level_dc($1,'Course')); |
$r->print(&course_level_dc($1,'Course')); |
$r->print('<hr /><input type="button" value="'.&mt('Modify User').'" onClick="setCourse()" />'."\n"); |
$r->print('<br /><input type="button" value="'.&mt('Modify User').'" onClick="setCourse()" />'."\n"); |
|
} elsif ($env{'request.role'} =~ m{^au\./($match_domain)/$}) { |
|
if ($addrolesdisplay) { |
|
$r->print('<br /><input type="button" value="'.&mt('Modify User').'"'); |
|
if ($newuser) { |
|
$r->print(' onClick="verify_message(this.form)" \>'."\n"); |
|
} else { |
|
$r->print('onClick="this.form.submit()" \>'."\n"); |
|
} |
|
} else { |
|
$r->print('<br /><a href="javascript:backPage(document.cu)">'. |
|
&mt('Back to previous page').'</a>'); |
|
} |
} else { |
} else { |
$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('<br /><input type="button" value="'.&mt('Modify User').'" onClick="setSections()" />'."\n"); |
} |
} |
$r->print(&Apache::lonhtmlcommon::echo_form_input(['phase','userrole','ccdomain','prevphase','currstate'])); |
$r->print(&Apache::lonhtmlcommon::echo_form_input(['phase','userrole','ccdomain','prevphase','currstate','ccuname','ccdomain'])); |
$r->print('<input type="hidden" name="currstate" 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 user_authentication { |
|
my ($ccuname,$ccdomain,$krbdefdom,$abv_auth) = @_; |
|
my $currentauth=&Apache::lonnet::queryauthenticate($ccuname,$ccdomain); |
|
my ($loginscript,$outcome); |
|
if ($currentauth=~/^(krb)(4|5):(.*)/) { |
|
my $long_auth = $1.$2; |
|
my $curr_kerb_ver = $2; |
|
my $krbdefdom=$3; |
|
my $curr_authtype = $abv_auth->{$long_auth}; |
|
my %param = ( formname => 'document.cu', |
|
kerb_def_dom => $krbdefdom, |
|
domain => $ccdomain, |
|
curr_authtype => $curr_authtype, |
|
curr_kerb_ver => $curr_kerb_ver, |
|
); |
|
$loginscript = &Apache::loncommon::authform_header(%param); |
|
} |
|
# Check for a bad authentication type |
|
if ($currentauth !~ /^(krb4|krb5|unix|internal|localauth):/) { |
|
# bad authentication scheme |
|
my %lt=&Apache::lonlocal::texthash( |
|
'err' => "ERROR", |
|
'uuas' => "This user has an unrecognized authentication scheme", |
|
'adcs' => "Please alert a domain coordinator of this situation", |
|
'sldb' => "Please specify login data below", |
|
'ld' => "Login Data" |
|
); |
|
if (&Apache::lonnet::allowed('mau',$ccdomain)) { |
|
&initialize_authen_forms($ccdomain); |
|
my $choices = &Apache::lonuserutils::set_login($ccdomain,$authformkrb,$authformint,$authformloc); |
|
$outcome = <<ENDBADAUTH; |
|
<script type="text/javascript" language="Javascript"> |
|
$loginscript |
|
</script> |
|
<span class="LC_error">$lt{'err'}: |
|
$lt{'uuas'} ($currentauth). $lt{'sldb'}.</span> |
|
<h3>$lt{'ld'}</h3> |
|
$choices |
|
ENDBADAUTH |
|
} else { |
|
# This user is not allowed to modify the user's |
|
# authentication scheme, so just notify them of the problem |
|
$outcome = <<ENDBADAUTH; |
|
<span class="LC_error"> $lt{'err'}: |
|
$lt{'uuas'} ($currentauth). $lt{'adcs'}. |
|
</span> |
|
ENDBADAUTH |
|
} |
|
} else { # Authentication type is valid |
|
my $authformcurrent=''; |
|
my $authform_other=''; |
|
&initialize_authen_forms($ccdomain,$currentauth); |
|
my ($authformcurrent,$authform_other,$can_modify) = |
|
&modify_login_block($ccdomain,$currentauth); |
|
if (&Apache::lonnet::allowed('mau',$ccdomain)) { |
|
# Current user has login modification privileges |
|
my %lt=&Apache::lonlocal::texthash ( |
|
'ld' => "Login Data", |
|
'ccld' => "Change Current Login Data", |
|
'enld' => "Enter New Login Data" |
|
); |
|
$outcome = |
|
'<script type="text/javascript" language="Javascript">'."\n". |
|
$loginscript."\n". |
|
'</script>'."\n". |
|
'<h3>'.$lt{'ld'}.'</h3>'. |
|
&Apache::loncommon::start_data_table(). |
|
&Apache::loncommon::start_data_table_row(). |
|
'<td>'.$authformnop; |
|
if ($can_modify) { |
|
$outcome .= '</td>'."\n". |
|
&Apache::loncommon::end_data_table_row(). |
|
&Apache::loncommon::start_data_table_row(). |
|
'<td>'.$authformcurrent.'</td>'. |
|
&Apache::loncommon::end_data_table_row()."\n"; |
|
} else { |
|
$outcome .= ' ('.$authformcurrent.')</td>'; |
|
} |
|
if ($authform_other ne '') { |
|
$outcome .= $authform_other; |
|
} |
|
$outcome .= &Apache::loncommon::end_data_table_row(). |
|
&Apache::loncommon::end_data_table(); |
|
} else { |
|
if (&Apache::lonnet::allowed('mau',$env{'request.role.domain'})) { |
|
my %lt=&Apache::lonlocal::texthash( |
|
'ccld' => "Change Current Login Data", |
|
'yodo' => "You do not have privileges to modify the authentication configuration for this user.", |
|
'ifch' => "If a change is required, contact a domain coordinator for the domain", |
|
); |
|
$outcome .= <<ENDNOPRIV; |
|
<h3>$lt{'ccld'}</h3> |
|
$lt{'yodo'} $lt{'ifch'}: $ccdomain |
|
ENDNOPRIV |
|
} |
|
} |
|
} ## End of "check for bad authentication type" logic |
|
return $outcome; |
|
} |
|
|
|
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 = &Apache::loncommon::start_data_table_row(). |
|
'<td>'.$authformint.'</td>'. |
|
&Apache::loncommon::end_data_table_row()."\n" |
|
} |
|
if ($can_assign{'loc'}) { |
|
$authform_other .= &Apache::loncommon::start_data_table_row(). |
|
'<td>'.$authformloc.'</td>'. |
|
&Apache::loncommon::end_data_table_row()."\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 = &Apache::loncommon::start_data_table_row(). |
|
'<td>'.$authformkrb.'</td>'. |
|
&Apache::loncommon::end_data_table_row()."\n"; |
|
} |
|
if ($can_assign{'loc'}) { |
|
$authform_other .= &Apache::loncommon::start_data_table_row(). |
|
'<td>'.$authformloc.'</td>'. |
|
&Apache::loncommon::end_data_table_row()."\n"; |
|
} |
|
if ($can_assign{'int'}) { |
|
$show_override_msg = 1; |
|
} |
|
} elsif ($currentauth=~/^unix:/) { |
|
$authformcurrent=$authformfsys; |
|
if (($can_assign{'krb4'}) || ($can_assign{'krb5'})) { |
|
$authform_other = &Apache::loncommon::start_data_table_row(). |
|
'<td>'.$authformkrb.'</td>'. |
|
&Apache::loncommon::end_data_table_row()."\n"; |
|
} |
|
if ($can_assign{'int'}) { |
|
$authform_other .= &Apache::loncommon::start_data_table_row(). |
|
'<td>'.$authformint.'</td>'. |
|
&Apache::loncommon::end_data_table_row()."\n" |
|
} |
|
if ($can_assign{'loc'}) { |
|
$authform_other .= &Apache::loncommon::start_data_table_row(). |
|
'<td>'.$authformloc.'</td>'. |
|
&Apache::loncommon::end_data_table_row()."\n"; |
|
} |
|
if ($can_assign{'fsys'}) { |
|
$show_override_msg = 1; |
|
} |
|
} elsif ($currentauth=~/^localauth:/) { |
|
$authformcurrent=$authformloc; |
|
if (($can_assign{'krb4'}) || ($can_assign{'krb5'})) { |
|
$authform_other = &Apache::loncommon::start_data_table_row(). |
|
'<td>'.$authformkrb.'</td>'. |
|
&Apache::loncommon::end_data_table_row()."\n"; |
|
} |
|
if ($can_assign{'int'}) { |
|
$authform_other .= &Apache::loncommon::start_data_table_row(). |
|
'<td>'.$authformint.'</td>'. |
|
&Apache::loncommon::end_data_table_row()."\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); |
|
} |
|
|
|
sub personal_data_display { |
|
my ($ccuname,$ccdomain,$newuser,%inst_results) = @_; |
|
my ($output,%userenv); |
|
if (!$newuser) { |
|
# Get the users information |
|
%userenv = &Apache::lonnet::get('environment', |
|
['firstname','middlename','lastname','generation', |
|
'permanentemail','id'],$ccdomain,$ccuname); |
|
} |
|
my %lt=&Apache::lonlocal::texthash( |
|
'pd' => "Personal Data", |
|
'firstname' => "First Name", |
|
'middlename' => "Middle Name", |
|
'lastname' => "Last Name", |
|
'generation' => "Generation", |
|
'permanentemail' => "Permanent e-mail address", |
|
'id' => "ID/Student Number", |
|
'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 $genhelp=&Apache::loncommon::help_open_topic('Generation'); |
|
$output = '<h3>'.$lt{'pd'}.'</h3>'. |
|
&Apache::lonhtmlcommon::start_pick_box(); |
|
foreach my $item (@userinfo) { |
|
my $rowtitle = $lt{$item}; |
|
if ($item eq 'generation') { |
|
$rowtitle = $genhelp.$rowtitle; |
|
} |
|
$output .= &Apache::lonhtmlcommon::row_title($rowtitle,undef,'LC_oddrow_value')."\n"; |
|
if ($newuser) { |
|
if ($inst_results{$item} ne '') { |
|
$output .= '<input type="hidden" name="c'.$item.'" value="'.$inst_results{$item}.'" />'.$inst_results{$item}; |
|
} else { |
|
$output .= '<input type="text" name="c'.$item.'" size="'.$textboxsize{$item}.'" value="" />'; |
|
} |
|
} else { |
|
if (&Apache::lonnet::allowed('mau',$ccdomain)) { |
|
$output .= '<input type="text" name="c'.$item.'" size="'.$textboxsize{$item}.'" value="'.$userenv{$item}.'" />'; |
|
} else { |
|
$output .= $userenv{$item}; |
|
} |
|
} |
|
$output .= &Apache::lonhtmlcommon::row_closure(1); |
|
} |
|
$output .= &Apache::lonhtmlcommon::end_pick_box(); |
|
return $output; |
|
} |
|
|
# ================================================================= Phase Three |
# ================================================================= Phase Three |
sub update_user_data { |
sub update_user_data { |
my ($r) = @_; |
my ($r) = @_; |
my $uhome=&Apache::lonnet::homeserver($env{'form.ccuname'}, |
my $uhome=&Apache::lonnet::homeserver($env{'form.ccuname'}, |
$env{'form.ccdomain'}); |
$env{'form.ccdomain'}); |
# Error messages |
# Error messages |
my $error = '<font color="#ff0000">'.&mt('Error').':</font>'; |
my $error = '<span class="LC_error">'.&mt('Error').': '; |
my $end = &Apache::loncommon::end_page(); |
my $end = '</span><br /><br />'. |
|
'<a href="javascript:backPage(document.userupdate,'. |
|
"'$env{'form.prevphase'}','modify')".'" />'. |
|
&mt('Return to previous page').'</a>'.&Apache::loncommon::end_page(); |
my $title; |
my $title; |
if (exists($env{'form.makeuser'})) { |
if (exists($env{'form.makeuser'})) { |
$title='Set Privileges for New User'; |
$title='Set Privileges for New User'; |
Line 1253 sub update_user_data {
|
Line 1468 sub update_user_data {
|
$r->print(&Apache::loncommon::start_page($title,$jscript)); |
$r->print(&Apache::loncommon::start_page($title,$jscript)); |
&Apache::lonhtmlcommon::add_breadcrumb |
&Apache::lonhtmlcommon::add_breadcrumb |
({href=>"javascript:backPage(document.userupdate)", |
({href=>"javascript:backPage(document.userupdate)", |
text=>"User modify/custom role edit", |
text=>"Create/modify user", |
faq=>282,bug=>'Instructor Interface',}); |
faq=>282,bug=>'Instructor Interface',}); |
if ($env{'form.prevphase'} eq 'userpicked') { |
if ($env{'form.prevphase'} eq 'userpicked') { |
&Apache::lonhtmlcommon::add_breadcrumb |
&Apache::lonhtmlcommon::add_breadcrumb |
Line 1271 sub update_user_data {
|
Line 1486 sub update_user_data {
|
$r->print(&Apache::lonhtmlcommon::breadcrumbs('User Management')); |
$r->print(&Apache::lonhtmlcommon::breadcrumbs('User Management')); |
|
|
my %disallowed; |
my %disallowed; |
|
$r->print(&update_result_form($uhome)); |
# Check Inputs |
# Check Inputs |
if (! $env{'form.ccuname'} ) { |
if (! $env{'form.ccuname'} ) { |
$r->print($error.&mt('No login name specified').'.'.$end); |
$r->print($error.&mt('No login name specified').'.'.$end); |
Line 1332 sub update_user_data {
|
Line 1548 sub update_user_data {
|
} |
} |
|
|
|
|
$r->print('<h2>'.&mt('User [_1] in domain [_2]', |
$r->print('<h3>'.&mt('User [_1] in domain [_2]', |
$env{'form.ccuname'}, $env{'form.ccdomain'}).'</h2>'); |
$env{'form.ccuname'}, $env{'form.ccdomain'}).'</h3>'); |
|
|
if ($env{'form.makeuser'}) { |
if ($env{'form.makeuser'}) { |
$r->print('<h3>'.&mt('Creating new account.').'</h3>'); |
$r->print('<h3>'.&mt('Creating new account.').'</h3>'); |
Line 1357 sub update_user_data {
|
Line 1573 sub update_user_data {
|
# Call modifyuser |
# Call modifyuser |
my $result = &Apache::lonnet::modifyuser |
my $result = &Apache::lonnet::modifyuser |
($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.cfirstname'}, |
$env{'form.cmiddle'},$env{'form.clast'},$env{'form.cgen'}, |
$env{'form.cmiddlename'},$env{'form.clastname'}, |
undef,$desiredhost |
$env{'form.cgeneration'},undef,$desiredhost, |
); |
$env{'form.cpermanentemail'}); |
$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'}, |
$env{'form.ccdomain'}); |
$env{'form.ccdomain'}); |
Line 1519 END
|
Line 1735 END
|
&Apache::lonnet::appenv(%newenvhash); |
&Apache::lonnet::appenv(%newenvhash); |
} |
} |
} else { # error occurred |
} else { # error occurred |
$r->print("<h2>".&mt('Unable to successfully change environment for')." ". |
$r->print('<span class="LC_error">'.&mt('Unable to successfully change environment for').' '. |
$env{'form.ccuname'}." ".&mt('in domain')." ". |
$env{'form.ccuname'}.' '.&mt('in domain').' '. |
$env{'form.ccdomain'}."</h2>"); |
$env{'form.ccdomain'}.'</span>'); |
} |
} |
} else { # End of if ($env ... ) logic |
} else { # End of if ($env ... ) logic |
my $putresult; |
my $putresult; |
Line 1537 END
|
Line 1753 END
|
'disk' => "Disk space allocated to user's portfolio files", |
'disk' => "Disk space allocated to user's portfolio files", |
); |
); |
$r->print(<<"END"); |
$r->print(<<"END"); |
<h4>$userenv{'firstname'} $userenv{'middlename'} $userenv{'lastname'} $userenv{'generation'}</h4> |
<h4>$userenv{'firstname'} $userenv{'middlename'} $userenv{'lastname'} $userenv{'generation'} ($lt{'mail'}: $userenv{'permanentemail'})</h4> |
<h4>$lt{'mail'}: $userenv{'permanentemail'}</h4> |
|
END |
END |
if ($putresult eq 'ok') { |
if ($putresult eq 'ok') { |
if ($oldportfolioquota != $newportfolioquota) { |
if ($oldportfolioquota != $newportfolioquota) { |
Line 1554 END
|
Line 1769 END
|
$r->print('<h3>'.&mt('Modifying Roles').'</h3>'); |
$r->print('<h3>'.&mt('Modifying Roles').'</h3>'); |
foreach my $key (keys (%env)) { |
foreach my $key (keys (%env)) { |
next if (! $env{$key}); |
next if (! $env{$key}); |
|
next if ($key eq 'form.action'); |
# Revoke roles |
# Revoke roles |
if ($key=~/^form\.rev/) { |
if ($key=~/^form\.rev/) { |
if ($key=~/^form\.rev\:([^\_]+)\_([^\_\.]+)$/) { |
if ($key=~/^form\.rev\:([^\_]+)\_([^\_\.]+)$/) { |
Line 1745 END
|
Line 1961 END
|
} |
} |
} |
} |
} else { |
} else { |
$r->print('<p>'.&mt('ERROR').': '.&mt('Unknown command').' <tt>'.$key.'</tt></p><br />'); |
$r->print('<p><span class="LC_error">'.&mt('ERROR').': '.&mt('Unknown command').' <tt>'.$key.'</tt></span></p><br />'); |
} |
} |
foreach my $key (sort(keys(%disallowed))) { |
foreach my $key (sort(keys(%disallowed))) { |
if (($key eq 'none') || ($key eq 'all')) { |
if (($key eq 'none') || ($key eq 'all')) { |
Line 1759 END
|
Line 1975 END
|
} # End of foreach (keys(%env)) |
} # End of foreach (keys(%env)) |
# Flush the course logs so reverse user roles immediately updated |
# Flush the course logs so reverse user roles immediately updated |
&Apache::lonnet::flushcourselogs(); |
&Apache::lonnet::flushcourselogs(); |
$r->print('<p><a href="/adm/createuser">'.&mt('Create/Modify Another User').'</a></p>'); |
$r->print(&Apache::loncommon::end_page()); |
$r->print('<form name="userupdate" method="post" />'."\n"); |
} |
|
|
|
sub update_result_form { |
|
my ($uhome) = @_; |
|
my $outcome = |
|
'<form name="userupdate" method="post" />'."\n"; |
foreach my $item ('srchby','srchin','srchtype','srchterm','srchdomain','ccuname','ccdomain') { |
foreach my $item ('srchby','srchin','srchtype','srchterm','srchdomain','ccuname','ccdomain') { |
$r->print('<input type="hidden" name="'.$item.'" value="'.$env{'form.'.$item}.'" />'."\n"); |
$outcome .= '<input type="hidden" name="'.$item.'" value="'.$env{'form.'.$item}.'" />'."\n"; |
} |
} |
foreach my $item ('sortby','seluname','seludom') { |
foreach my $item ('sortby','seluname','seludom') { |
if (exists($env{'form.'.$item})) { |
if (exists($env{'form.'.$item})) { |
$r->print('<input type="hidden" name="'.$item.'" value="'.$env{'form.'.$item}.'" />'."\n"); |
$outcome .= '<input type="hidden" name="'.$item.'" value="'.$env{'form.'.$item}.'" />'."\n"; |
} |
} |
} |
} |
$r->print('<input type="hidden" name="phase" value="" />'."\n". |
if ($uhome eq 'no_host') { |
'<input type ="hidden" name="currstate" value="" />'."\n". |
$outcome .= '<input type="hidden" name="forcenewuser" value="1" />'."\n"; |
'</form>'); |
} |
$r->print(&Apache::loncommon::end_page()); |
$outcome .= '<input type="hidden" name="phase" value="" />'."\n". |
|
'<input type ="hidden" name="currstate" value="" />'."\n". |
|
'<input type ="hidden" name="action" value="singleuser" />'."\n". |
|
'</form>'; |
|
return $outcome; |
} |
} |
|
|
sub classlist_drop { |
sub classlist_drop { |
Line 1855 sub custom_role_editor {
|
Line 2080 sub custom_role_editor {
|
|
|
$rolename=~s/[^A-Za-z0-9]//gs; |
$rolename=~s/[^A-Za-z0-9]//gs; |
|
|
if (!$rolename) { |
if (!$rolename || $env{'form.phase'} eq 'pickrole') { |
&print_username_entry_form($r); |
&print_username_entry_form($r); |
return; |
return; |
} |
} |
Line 1924 sub custom_role_editor {
|
Line 2149 sub custom_role_editor {
|
$head_script .= "\n".$jsback."\n".'</script>'."\n"; |
$head_script .= "\n".$jsback."\n".'</script>'."\n"; |
$r->print(&Apache::loncommon::start_page('Custom Role Editor',$head_script)); |
$r->print(&Apache::loncommon::start_page('Custom Role Editor',$head_script)); |
&Apache::lonhtmlcommon::add_breadcrumb |
&Apache::lonhtmlcommon::add_breadcrumb |
({href=>"javascript:backPage(document.form1,'','')", |
({href=>"javascript:backPage(document.form1,'pickrole','')", |
text=>"User modify/custom role edit", |
text=>"Pick custom role", |
faq=>282,bug=>'Instructor Interface',}, |
faq=>282,bug=>'Instructor Interface',}, |
{href=>"javascript:backPage(document.form1,'','')", |
{href=>"javascript:backPage(document.form1,'','')", |
text=>"Edit custom role", |
text=>"Edit custom role", |
Line 1968 ENDCCF
|
Line 2193 ENDCCF
|
&Apache::loncommon::end_data_table_row()); |
&Apache::loncommon::end_data_table_row()); |
} |
} |
$r->print(&Apache::loncommon::end_data_table(). |
$r->print(&Apache::loncommon::end_data_table(). |
|
'<input type="hidden" name="action" value="'.$env{'form.action'}.'" />'. |
'<input type="hidden" name="startrolename" value="'.$env{'form.rolename'}. |
'<input type="hidden" name="startrolename" value="'.$env{'form.rolename'}. |
'" />'."\n".'<input type="hidden" name="currstate" value="" />'."\n". |
'" />'."\n".'<input type="hidden" name="currstate" value="" />'."\n". |
'<input type="reset" value="'.&mt("Reset").'" />'."\n". |
'<input type="reset" value="'.&mt("Reset").'" />'."\n". |
Line 2049 sub make_button_code {
|
Line 2275 sub make_button_code {
|
# ---------------------------------------------------------- Call to definerole |
# ---------------------------------------------------------- Call to definerole |
sub set_custom_role { |
sub set_custom_role { |
my ($r) = @_; |
my ($r) = @_; |
|
|
my $rolename=$env{'form.rolename'}; |
my $rolename=$env{'form.rolename'}; |
|
|
$rolename=~s/[^A-Za-z0-9]//gs; |
$rolename=~s/[^A-Za-z0-9]//gs; |
|
|
if (!$rolename) { |
if (!$rolename) { |
&print_username_entry_form($r); |
&custom_role_editor($r); |
return; |
return; |
} |
} |
|
|
my ($jsback,$elements) = &crumb_utilities(); |
my ($jsback,$elements) = &crumb_utilities(); |
my $jscript = '<script type="text/javascript">'.$jsback."\n".'</script>'; |
my $jscript = '<script type="text/javascript">'.$jsback."\n".'</script>'; |
|
|
$r->print(&Apache::loncommon::start_page('Save Custom Role'),$jscript); |
$r->print(&Apache::loncommon::start_page('Save Custom Role'),$jscript); |
&Apache::lonhtmlcommon::add_breadcrumb |
&Apache::lonhtmlcommon::add_breadcrumb |
({href=>"javascript:backPage(document.customresult,'','')", |
({href=>"javascript:backPage(document.customresult,'pickrole','')", |
text=>"User modify/custom role edit", |
text=>"Pick custom role", |
faq=>282,bug=>'Instructor Interface',}, |
faq=>282,bug=>'Instructor Interface',}, |
{href=>"javascript:backPage(document.customresult,'selected_custom_edit','')", |
{href=>"javascript:backPage(document.customresult,'selected_custom_edit','')", |
text=>"Edit custom role", |
text=>"Edit custom role", |
Line 2079 sub set_custom_role {
|
Line 2301 sub set_custom_role {
|
&Apache::lonnet::get('roles',["rolesdef_$rolename"]); |
&Apache::lonnet::get('roles',["rolesdef_$rolename"]); |
|
|
# ------------------------------------------------------- Does this role exist? |
# ------------------------------------------------------- Does this role exist? |
$r->print('<h2>'); |
$r->print('<h3>'); |
if (($rdummy ne 'con_lost') && ($roledef ne '')) { |
if (($rdummy ne 'con_lost') && ($roledef ne '')) { |
$r->print(&mt('Existing Role').' "'); |
$r->print(&mt('Existing Role').' "'); |
} else { |
} else { |
$r->print(&mt('New Role').' "'); |
$r->print(&mt('New Role').' "'); |
$roledef=''; |
$roledef=''; |
} |
} |
$r->print($rolename.'"</h2>'); |
$r->print($rolename.'"</h3>'); |
# ------------------------------------------------------- What can be assigned? |
# ------------------------------------------------------- What can be assigned? |
my $sysrole=''; |
my $sysrole=''; |
my $domrole=''; |
my $domrole=''; |
Line 2128 sub set_custom_role {
|
Line 2350 sub set_custom_role {
|
$env{'user.name'}, |
$env{'user.name'}, |
$rolename)); |
$rolename)); |
} |
} |
$r->print('<p><a href="/adm/createuser">Create another role, or Create/Modify a user.</a></p><form name="customresult" method="post">'); |
$r->print('<p><a href="javascript:backPage(document.customresult,'."'pickrole'".')">'.&mt('Create or edit another custom role').'</a></p><form name="customresult" method="post">'); |
$r->print(&Apache::lonhtmlcommon::echo_form_input([]).'</form>'); |
$r->print(&Apache::lonhtmlcommon::echo_form_input([]).'</form>'); |
$r->print(&Apache::loncommon::end_page()); |
$r->print(&Apache::loncommon::end_page()); |
} |
} |
Line 2136 sub set_custom_role {
|
Line 2358 sub set_custom_role {
|
# ================================================================ Main Handler |
# ================================================================ Main Handler |
sub handler { |
sub handler { |
my $r = shift; |
my $r = shift; |
|
|
if ($r->header_only) { |
if ($r->header_only) { |
&Apache::loncommon::content_type($r,'text/html'); |
&Apache::loncommon::content_type($r,'text/html'); |
$r->send_http_header; |
$r->send_http_header; |
return OK; |
return OK; |
} |
} |
|
my $context; |
|
if ($env{'request.course.id'}) { |
|
$context = 'course'; |
|
} elsif ($env{'request.role'} =~ /^au\./) { |
|
$context = 'construction_space'; |
|
} else { |
|
$context = 'domain'; |
|
} |
|
&Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'}, |
|
['action','state']); |
|
&Apache::lonhtmlcommon::clear_breadcrumbs(); |
|
&Apache::lonhtmlcommon::add_breadcrumb |
|
({href=>"/adm/createuser", |
|
text=>"User Management"}); |
|
my ($permission,$allowed) = &get_permission($context); |
|
if (!$allowed) { |
|
$env{'user.error.msg'}= |
|
"/adm/createuser:cst:0:0:Cannot create/modify user data ". |
|
"or view user status."; |
|
return HTTP_NOT_ACCEPTABLE; |
|
} |
|
|
|
&Apache::loncommon::content_type($r,'text/html'); |
|
$r->send_http_header; |
|
|
|
# Main switch on form.action and form.state, as appropriate |
|
if (! exists($env{'form.action'})) { |
|
$r->print(&header()); |
|
$r->print(&Apache::lonhtmlcommon::breadcrumbs('User Management')); |
|
$r->print(&print_main_menu($permission)); |
|
$r->print(&Apache::loncommon::end_page()); |
|
} elsif ($env{'form.action'} eq 'upload' && $permission->{'cusr'}) { |
|
$r->print(&header()); |
|
&Apache::lonhtmlcommon::add_breadcrumb |
|
({href=>'/adm/createuser?action=upload&state=', |
|
text=>"Upload Users List"}); |
|
$r->print(&Apache::lonhtmlcommon::breadcrumbs('Upload Users List', |
|
'User_Management_Upload')); |
|
$r->print('<form name="studentform" method="post" '. |
|
'enctype="multipart/form-data" '. |
|
' action="/adm/createuser">'."\n"); |
|
if (! exists($env{'form.state'})) { |
|
&Apache::lonuserutils::print_first_users_upload_form($r,$context); |
|
} elsif ($env{'form.state'} eq 'got_file') { |
|
&Apache::lonuserutils::print_upload_manager_form($r,$context); |
|
} elsif ($env{'form.state'} eq 'enrolling') { |
|
if ($env{'form.datatoken'}) { |
|
&Apache::lonuserutils::upfile_drop_add($r,$context); |
|
} |
|
} else { |
|
&Apache::lonuserutils::print_first_users_upload_form($r,$context); |
|
} |
|
$r->print('</form>'.&Apache::loncommon::end_page()); |
|
} elsif ($env{'form.action'} eq 'expire' && $permission->{'cusr'}) { |
|
$r->print(&header()); |
|
&Apache::lonhtmlcommon::add_breadcrumb |
|
({href=>'/adm/createuser?action=expire', |
|
text=>"Expire User Roles"}); |
|
$r->print(&Apache::lonhtmlcommon::breadcrumbs('Expire User Roles', |
|
'User_Management_Drops')); |
|
if (! exists($env{'form.state'})) { |
|
&Apache::lonuserutils::print_expire_menu($r,$context); |
|
} elsif ($env{'form.state'} eq 'done') { |
|
&Apache::lonuserutils::expire_user_list($r); |
|
} else { |
|
&Apache::lonuserutils::print_expire_menu($r,$context); |
|
} |
|
$r->print(&Apache::loncommon::end_page()); |
|
} elsif ($env{'form.action'} eq 'singleuser' && $permission->{'cusr'}) { |
|
my $phase = $env{'form.phase'}; |
|
my @search = ('srchterm','srchby','srchin','srchtype','srchdomain'); |
|
|
|
if (($phase eq 'get_user_info') || ($phase eq 'userpicked')) { |
|
my $srch; |
|
foreach my $item (@search) { |
|
$srch->{$item} = $env{'form.'.$item}; |
|
} |
|
if ($env{'form.phase'} eq 'get_user_info') { |
|
my ($currstate,$response,$forcenewuser,$results) = |
|
&user_search_result($srch); |
|
if ($env{'form.currstate'} eq 'modify') { |
|
$currstate = $env{'form.currstate'}; |
|
} |
|
if ($currstate eq 'select') { |
|
&print_user_selection_page($r,$response,$srch,$results, |
|
'createuser',\@search); |
|
} elsif ($currstate eq 'modify') { |
|
my ($ccuname,$ccdomain); |
|
if (($srch->{'srchby'} eq 'uname') && |
|
($srch->{'srchtype'} eq 'exact')) { |
|
$ccuname = $srch->{'srchterm'}; |
|
$ccdomain= $srch->{'srchdomain'}; |
|
} else { |
|
my @matchedunames = keys(%{$results}); |
|
($ccuname,$ccdomain) = split(/:/,$matchedunames[0]); |
|
} |
|
$ccuname =&LONCAPA::clean_username($ccuname); |
|
$ccdomain=&LONCAPA::clean_domain($ccdomain); |
|
if ($env{'form.forcenewuser'}) { |
|
$response = ''; |
|
} |
|
&print_user_modification_page($r,$ccuname,$ccdomain, |
|
$srch,$response); |
|
} elsif ($currstate eq 'query') { |
|
&print_user_query_page($r,'createuser'); |
|
} else { |
|
&print_username_entry_form($r,$response,$srch, |
|
$forcenewuser); |
|
} |
|
} elsif ($env{'form.phase'} eq 'userpicked') { |
|
my $ccuname = &LONCAPA::clean_username($env{'form.seluname'}); |
|
my $ccdomain = &LONCAPA::clean_domain($env{'form.seludom'}); |
|
&print_user_modification_page($r,$ccuname,$ccdomain,$srch); |
|
} |
|
} elsif ($env{'form.phase'} eq 'update_user_data') { |
|
&update_user_data($r); |
|
} else { |
|
&print_username_entry_form($r); |
|
} |
|
} elsif ($env{'form.action'} eq 'custom' && $permission->{'custom'}) { |
|
if ($env{'form.phase'} eq 'set_custom_roles') { |
|
&set_custom_role($r); |
|
} else { |
|
&custom_role_editor($r); |
|
} |
|
} elsif ($env{'form.action'} eq 'listusers' && $permission->{'view'}) { |
|
$r->print(&header()); |
|
&Apache::lonhtmlcommon::add_breadcrumb |
|
({href=>'/adm/createuser?action=listusers', |
|
text=>"List Users' Roles"}); |
|
$r->print(&Apache::lonhtmlcommon::breadcrumbs("List Users' Roles", |
|
'User_Management_List')); |
|
if (! exists($env{'form.state'})) { |
|
&Apache::lonuserutils::print_html_classlist($r,undef,$permission); |
|
} elsif ($env{'form.state'} eq 'csv') { |
|
&Apache::lonuserutils::print_html_classlist($r,'csv',$permission); |
|
} elsif ($env{'form.state'} eq 'excel') { |
|
&Apache::lonuserutils::print_html_classlist($r,'excel',$permission); |
|
} else { |
|
&Apache::lonuserutils::print_html_classlist($r,undef,$permission); |
|
} |
|
$r->print(&Apache::loncommon::end_page()); |
|
} elsif ($env{'form.action'} eq 'expire' && $permission->{'cusr'}) { |
|
$r->print(&header()); |
|
&Apache::lonhtmlcommon::add_breadcrumb |
|
({href=>'/adm/createuser?action=drop', |
|
text=>"Expire Users"}); |
|
$r->print(&Apache::lonhtmlcommon::breadcrumbs('Expire User Roles', |
|
'User_Management_Drops')); |
|
if (! exists($env{'form.state'})) { |
|
&Apache::lonuserutils::print_expire_menu($r,$context); |
|
} elsif ($env{'form.state'} eq 'done') { |
|
&Apache::lonuserutiles::expire_user_list($r); |
|
} else { |
|
&print_expire_menu($r,$context); |
|
} |
|
$r->print(&Apache::loncommon::end_page()); |
|
} else { |
|
$r->print(&header()); |
|
$r->print(&Apache::lonhtmlcommon::breadcrumbs('User Management')); $r->print(&print_main_menu($permission)); |
|
$r->print(&Apache::loncommon::end_page()); |
|
} |
|
return OK; |
|
} |
|
|
if ((&Apache::lonnet::allowed('cta',$env{'request.course.id'})) || |
sub header { |
(&Apache::lonnet::allowed('cin',$env{'request.course.id'})) || |
my ($jscript,$loaditems) = @_; |
(&Apache::lonnet::allowed('ccr',$env{'request.course.id'})) || |
my $start_page; |
(&Apache::lonnet::allowed('cep',$env{'request.course.id'})) || |
if (ref($loaditems) eq 'HASH') { |
(&authorpriv($env{'user.name'},$env{'request.role.domain'})) || |
$start_page=&Apache::loncommon::start_page('User Management',$jscript,{'add_entries' => $loaditems,}); |
(&Apache::lonnet::allowed('mau',$env{'request.role.domain'}))) { |
} else { |
&Apache::loncommon::content_type($r,'text/html'); |
$start_page=&Apache::loncommon::start_page('User Management',$jscript); |
$r->send_http_header; |
} |
&Apache::lonhtmlcommon::clear_breadcrumbs(); |
return $start_page; |
|
} |
my $phase = $env{'form.phase'}; |
|
my @search = ('srchterm','srchby','srchin','srchtype','srchdomain'); |
############################################################### |
|
############################################################### |
if (($phase eq 'get_user_info') || ($phase eq 'userpicked')) { |
# Menu Phase One |
my $srch; |
sub print_main_menu { |
foreach my $item (@search) { |
my ($permission) = @_; |
$srch->{$item} = $env{'form.'.$item}; |
my @menu = |
} |
( |
if ($env{'form.phase'} eq 'get_user_info') { |
{ text => 'Upload a File of Users to Set Roles', |
my ($currstate,$response,$forcenewuser,$results) = |
help => 'User_Management_Upload', |
&user_search_result($srch); |
action => 'upload', |
if ($currstate eq 'select') { |
permission => $permission->{'cusr'}, |
&print_user_selection_page($r,$response,$srch,$results,'createuser',\@search); |
}, |
} elsif ($currstate eq 'modify') { |
{ text => 'Set User Roles for an Individual User', |
my ($ccuname,$ccdomain); |
help => 'User_Management_Single_User', |
if (($srch->{'srchby'} eq 'uname') && |
action => 'singleuser', |
($srch->{'srchtype'} eq 'exact')) { |
permission => $permission->{'cusr'}, |
$ccuname = $srch->{'srchterm'}; |
}, |
$ccdomain= $srch->{'srchdomain'}; |
# { text => 'Display User Roles for Multiple Users', |
} else { |
# help => 'User_Management_List', |
my @matchedunames = keys(%{$results}); |
# action => 'listusers', |
($ccuname,$ccdomain) = split(/:/,$matchedunames[0]); |
# permission => $permission->{'view'}, |
} |
# }, |
$ccuname =&LONCAPA::clean_username($ccuname); |
# { text => 'Expire User Roles ', |
$ccdomain=&LONCAPA::clean_domain($ccdomain); |
# help => 'User_Management_Drops', |
&print_user_modification_page($r,$ccuname,$ccdomain,$srch, |
# action => 'expire', |
$response); |
# permission => $permission->{'cusr'}, |
} elsif ($currstate eq 'query') { |
# }, |
&print_user_query_page($r,'createuser'); |
{ text => 'Edit Custom Roles', |
} else { |
help => 'Custom_Role_Edit', |
&print_username_entry_form($r,$response,$srch,$forcenewuser); |
action => 'custom', |
} |
permission => $permission->{'custom'}, |
} elsif ($env{'form.phase'} eq 'userpicked') { |
}, |
my $ccuname = &LONCAPA::clean_username($env{'form.seluname'}); |
); |
my $ccdomain = &LONCAPA::clean_domain($env{'form.seludom'}); |
my $menu_html = ''; |
&print_user_modification_page($r,$ccuname,$ccdomain,$srch); |
foreach my $menu_item (@menu) { |
} |
next if (! $menu_item->{'permission'}); |
} elsif ($env{'form.phase'} eq 'update_user_data') { |
$menu_html.='<p>'; |
&update_user_data($r); |
$menu_html.='<font size="+1">'; |
} elsif ($env{'form.phase'} eq 'selected_custom_edit') { |
if (exists($menu_item->{'url'})) { |
&custom_role_editor($r); |
$menu_html.=qq{<a href="$menu_item->{'url'}">}; |
} elsif ($env{'form.phase'} eq 'set_custom_roles') { |
} else { |
&set_custom_role($r); |
$menu_html.= |
} else { |
qq{<a href="/adm/createuser?action=$menu_item->{'action'}">}; |
&print_username_entry_form($r); |
} |
} |
$menu_html.= &mt($menu_item->{'text'}).'</a></font>'; |
} else { |
if (exists($menu_item->{'help'})) { |
$env{'user.error.msg'}= |
$menu_html.= |
"/adm/createuser:mau:0:0:Cannot modify user data"; |
&Apache::loncommon::help_open_topic($menu_item->{'help'}); |
return HTTP_NOT_ACCEPTABLE; |
} |
} |
$menu_html.='</p>'; |
return OK; |
} |
|
return $menu_html; |
|
} |
|
|
|
sub get_permission { |
|
my ($context) = @_; |
|
my %permission; |
|
if ($context eq 'course') { |
|
if ((&Apache::lonnet::allowed('cta',$env{'request.course.id'})) || |
|
(&Apache::lonnet::allowed('cin',$env{'request.course.id'})) || |
|
(&Apache::lonnet::allowed('ccr',$env{'request.course.id'})) || |
|
(&Apache::lonnet::allowed('cep',$env{'request.course.id'})) || |
|
(&Apache::lonnet::allowed('cst',$env{'request.course.id'}))) { |
|
$permission{'cusr'} = 1; |
|
$permission{'view'} = |
|
&Apache::lonnet::allowed('vcl',$env{'request.course.id'}); |
|
|
|
} |
|
if (&Apache::lonnet::allowed('ccr',$env{'request.course.id'})) { |
|
$permission{'custom'} = 1; |
|
} |
|
if (&Apache::lonnet::allowed('vcl',$env{'request.course.id'})) { |
|
$permission{'view'} = 1; |
|
if (!$permission{'view'}) { |
|
my $scope = $env{'request.course.id'}.'/'.$env{'request.course.sec'}; |
|
$permission{'view'} = &Apache::lonnet::allowed('vcl',$scope); |
|
if ($permission{'view'}) { |
|
$permission{'view_section'} = $env{'request.course.sec'}; |
|
} |
|
} |
|
} |
|
} elsif ($context eq 'construction_space') { |
|
$permission{'cusr'} = &authorpriv($env{'user.name'},$env{'request.role.domain'}); |
|
$permission{'view'} = $permission{'cusr'}; |
|
} else { |
|
if ((&Apache::lonnet::allowed('cad',$env{'request.role.domain'})) || |
|
(&Apache::lonnet::allowed('cli',$env{'request.role.domain'})) || |
|
(&Apache::lonnet::allowed('cau',$env{'request.role.domain'})) || |
|
(&Apache::lonnet::allowed('csc',$env{'request.role.domain'})) || |
|
(&Apache::lonnet::allowed('cdg',$env{'request.role.domain'})) || |
|
(&Apache::lonnet::allowed('mau',$env{'request.role.domain'}))) { |
|
$permission{'cusr'} = 1; |
|
} |
|
if (&Apache::lonnet::allowed('ccr',$env{'request.role.domain'})) { |
|
$permission{'custom'} = 1; |
|
} |
|
$permission{'view'} = $permission{'cusr'}; |
|
} |
|
my $allowed = 0; |
|
foreach my $perm (values(%permission)) { |
|
if ($perm) { $allowed=1; last; } |
|
} |
|
return (\%permission,$allowed); |
|
} |
|
|
|
sub restore_prev_selections { |
|
my %saveable_parameters = ('srchby' => 'scalar', |
|
'srchin' => 'scalar', |
|
'srchtype' => 'scalar', |
|
); |
|
&Apache::loncommon::store_settings('user','user_picker', |
|
\%saveable_parameters); |
|
&Apache::loncommon::restore_settings('user','user_picker', |
|
\%saveable_parameters); |
} |
} |
|
|
#-------------------------------------------------- functions for &phase_two |
#-------------------------------------------------- functions for &phase_two |
Line 2214 sub user_search_result {
|
Line 2662 sub user_search_result {
|
my %inst_matches; |
my %inst_matches; |
my %srch_results; |
my %srch_results; |
my ($response,$currstate,$forcenewuser,$dirsrchres); |
my ($response,$currstate,$forcenewuser,$dirsrchres); |
$srch->{'srchterm'} =~ s/^\s+//; |
$srch->{'srchterm'} =~ s/\s+/ /g; |
$srch->{'srchterm'} =~ s/\s+$//; |
|
|
|
if ($srch->{'srchby'} !~ /^(uname|lastname|lastfirst)$/) { |
if ($srch->{'srchby'} !~ /^(uname|lastname|lastfirst)$/) { |
$response = &mt('Invalid search.'); |
$response = &mt('Invalid search.'); |
} |
} |
Line 2229 sub user_search_result {
|
Line 2675 sub user_search_result {
|
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 2493 sub directorysrch_check {
|
Line 2942 sub directorysrch_check {
|
} |
} |
} |
} |
|
|
|
|
sub get_courseusers { |
sub get_courseusers { |
my %advhash; |
my %advhash; |
my $classlist = &Apache::loncoursedata::get_classlist(); |
my $classlist = &Apache::loncoursedata::get_classlist(); |
Line 2568 sub build_search_response {
|
Line 3016 sub build_search_response {
|
} |
} |
} |
} |
if (!($srch->{'srchby'} eq 'uname' && $srch->{'srchin'} eq 'dom' && $srch->{'srchtype'} eq 'exact' && $srch->{'srchdomain'} eq $env{'request.role.domain'})) { |
if (!($srch->{'srchby'} eq 'uname' && $srch->{'srchin'} eq 'dom' && $srch->{'srchtype'} eq 'exact' && $srch->{'srchdomain'} eq $env{'request.role.domain'})) { |
$response .= '<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 '<span class=\"LC_cusr_emph\">Make new user if no match found</span>' to '<b>Yes</b>'").'</li><li>'.&mt('Provide the proposed username').'</li><li>'.&mt('Search').'</li></ul><br />'; |
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 />'; |
} |
} |
} |
} |
} |
} |
Line 2624 sub course_level_table {
|
Line 3073 sub course_level_table {
|
my $table = ''; |
my $table = ''; |
# Custom Roles? |
# Custom Roles? |
|
|
my %customroles=&my_custom_roles(); |
my %customroles=&Apache::lonuserutils::my_custom_roles(); |
my %lt=&Apache::lonlocal::texthash( |
my %lt=&Apache::lonlocal::texthash( |
'exs' => "Existing sections", |
'exs' => "Existing sections", |
'new' => "Define new section", |
'new' => "Define new section", |
Line 2705 ENDTIMEENTRY
|
Line 3154 ENDTIMEENTRY
|
if (%sections_count) { |
if (%sections_count) { |
my $currsec = &course_sections(\%sections_count,$customrole); |
my $currsec = &course_sections(\%sections_count,$customrole); |
$table.= |
$table.= |
'<td><table border="0" cellspacing="0" cellpadding="0">'. |
'<td><table class="LC_createuser">'. |
'<tr><td valign="top">'.$lt{'exs'}.'<br />'. |
'<tr class="LC_section_row"><td valign="top">'. |
$currsec.'</td>'. |
$lt{'exs'}.'<br />'.$currsec.'</td>'. |
'<td> </td>'. |
'<td> </td>'. |
'<td valign="top"> '.$lt{'new'}.'<br />'. |
'<td valign="top"> '.$lt{'new'}.'<br />'. |
'<input type="text" name="newsec_'.$customrole.'" value="" /></td>'. |
'<input type="text" name="newsec_'.$customrole.'" value="" /></td>'. |
Line 2732 ENDENTRY
|
Line 3181 ENDENTRY
|
} |
} |
return '' if ($table eq ''); # return nothing if there is nothing |
return '' if ($table eq ''); # return nothing if there is nothing |
# in the table |
# in the table |
my $result = ' |
my $result; |
<h4>'.$lt{'crl'}.'</h4>'. |
if (!$env{'request.course.id'}) { |
|
$result = '<h4>'.$lt{'crl'}.'</h4>'."\n"; |
|
} |
|
$result .= |
&Apache::loncommon::start_data_table(). |
&Apache::loncommon::start_data_table(). |
&Apache::loncommon::start_data_table_header_row(). |
&Apache::loncommon::start_data_table_header_row(). |
'<th>'.$lt{'act'}.'</th><th>'.$lt{'rol'}.'</th><th>'.$lt{'ext'}.'</th> |
'<th>'.$lt{'act'}.'</th><th>'.$lt{'rol'}.'</th><th>'.$lt{'ext'}.'</th> |
Line 2768 sub course_sections {
|
Line 3220 sub course_sections {
|
|
|
sub course_level_dc { |
sub course_level_dc { |
my ($dcdom) = @_; |
my ($dcdom) = @_; |
my %customroles=&my_custom_roles(); |
my %customroles=&Apache::lonuserutils::my_custom_roles(); |
my $hiddenitems = '<input type="hidden" name="dcdomain" value="'.$dcdom.'" />'. |
my $hiddenitems = '<input type="hidden" name="dcdomain" value="'.$dcdom.'" />'. |
'<input type="hidden" name="origdom" value="'.$dcdom.'" />'. |
'<input type="hidden" name="origdom" value="'.$dcdom.'" />'. |
'<input type="hidden" name="dccourse" value="" />'; |
'<input type="hidden" name="dccourse" value="" />'; |