version 1.187, 2007/09/19 06:24:26
|
version 1.204, 2007/12/07 23:09:30
|
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 |
Line 82 sub initialize_authen_forms {
|
Line 83 sub initialize_authen_forms {
|
kerb_def_dom => $krbdefdom, |
kerb_def_dom => $krbdefdom, |
domain => $dom, |
domain => $dom, |
); |
); |
|
my %abv_auth = &auth_abbrev(); |
if ($curr_authtype =~ /^(krb4|krb5|internal|localauth|unix):$/) { |
if ($curr_authtype =~ /^(krb4|krb5|internal|localauth|unix):$/) { |
$param{'curr_authtype'} = $curr_authtype; |
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); |
Line 95 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 178 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 189 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 215 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 244 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 272 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 309 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 343 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 403 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 422 sub print_user_query_page {
|
Line 440 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,$context) = @_; |
if (($ccuname eq '') || ($ccdomain eq '')) { |
if (($ccuname eq '') || ($ccdomain eq '')) { |
my $usermsg = &mt('No username and/or domain provided.'); |
my $usermsg = &mt('No username and/or domain provided.'); |
&print_username_entry_form($r,$usermsg); |
&print_username_entry_form($r,$usermsg); |
return; |
return; |
} |
} |
my ($curr_authtype,$instsrch,$rulematch,$rules,%inst_results); |
my %abv_auth = &auth_abbrev(); |
|
my ($curr_authtype,%rulematch,%inst_results,$curr_kerb_ver,$newuser, |
|
%alerts,%curr_rules,%got_rules); |
my $uhome=&Apache::lonnet::homeserver($ccuname,$ccdomain); |
my $uhome=&Apache::lonnet::homeserver($ccuname,$ccdomain); |
if ($uhome eq 'no_host') { |
if ($uhome eq 'no_host') { |
$instsrch = |
$newuser = 1; |
{ |
my $checkhash; |
srchin => 'instd', |
my $checks = { 'username' => 1 }; |
srchby => 'uname', |
$checkhash->{$ccuname.':'.$ccdomain} = { 'newuser' => $newuser }; |
srchtype => 'exact', |
&Apache::loncommon::user_rule_check($checkhash,$checks, |
srchterm => $ccuname, |
\%alerts,\%rulematch,\%inst_results,\%curr_rules,\%got_rules); |
srchdomain => $ccdomain, |
if (ref($alerts{'username'}) eq 'HASH') { |
}; |
if (ref($alerts{'username'}{$ccdomain}) eq 'HASH') { |
(my $usercheckmsg,$rulematch,$rules,%inst_results) = |
my $domdesc = |
&Apache::loncommon::username_rule_check($instsrch,'new'); |
&Apache::lonnet::domain($ccdomain,'description'); |
if ($usercheckmsg) { |
if ($alerts{'username'}{$ccdomain}{$ccuname}) { |
&print_username_entry_form($r,$usercheckmsg); |
my $userchkmsg; |
return; |
if (ref($curr_rules{$ccdomain}) eq 'HASH') { |
|
$userchkmsg = |
|
&Apache::loncommon::instrule_disallow_msg('username', |
|
$domdesc,1). |
|
&Apache::loncommon::user_rule_formats($ccdomain, |
|
$domdesc,$curr_rules{$ccdomain}{'username'}, |
|
'username'); |
|
} |
|
&print_username_entry_form($r,$userchkmsg); |
|
return; |
|
} |
|
} |
} |
} |
} else { |
} else { |
$curr_authtype = |
$newuser = 0; |
|
my $currentauth = |
&Apache::lonnet::queryauthenticate($ccuname,$ccdomain); |
&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 461 sub print_user_modification_page {
|
Line 499 sub print_user_modification_page {
|
kerb_def_dom => $krbdefdom, |
kerb_def_dom => $krbdefdom, |
kerb_def_auth => $krbdef, |
kerb_def_auth => $krbdef, |
curr_authtype => $curr_authtype, |
curr_authtype => $curr_authtype, |
|
curr_kerb_ver => $curr_kerb_ver, |
domain => $ccdomain, |
domain => $ccdomain, |
); |
); |
$loginscript = &Apache::loncommon::authform_header(%param); |
$loginscript = &Apache::loncommon::authform_header(%param); |
Line 588 sub print_user_modification_page {
|
Line 627 sub print_user_modification_page {
|
} |
} |
ENDSCRIPT |
ENDSCRIPT |
} else { |
} else { |
$nondc_setsection_code = <<"ENDSECCODE"; |
$nondc_setsection_code = |
function setSections() { |
&Apache::lonuserutils::setsections_javascript('cu',$groupslist); |
var re1 = /^currsec_/; |
|
var groups = new Array($groupslist); |
|
for (var i=0;i<document.cu.elements.length;i++) { |
|
var str = document.cu.elements[i].name; |
|
var checkcurr = str.match(re1); |
|
if (checkcurr != null) { |
|
if (document.cu.elements[i-1].checked == true) { |
|
var match = str.split('_'); |
|
var role = match[3]; |
|
if (role == 'cc') { |
|
alert("Section designations do not apply to Course Coordinator roles.\\nA course coordinator role will be added with access to all sections."); |
|
} |
|
else { |
|
var sections = ''; |
|
var numsec = 0; |
|
var sections; |
|
for (var j=0; j<document.cu.elements[i].length; j++) { |
|
if (document.cu.elements[i].options[j].selected == true ) { |
|
if (document.cu.elements[i].options[j].value != "") { |
|
if (numsec == 0) { |
|
if (document.cu.elements[i].options[j].value != "") { |
|
sections = document.cu.elements[i].options[j].value; |
|
numsec ++; |
|
} |
|
} |
|
else { |
|
sections = sections + "," + document.cu.elements[i].options[j].value |
|
numsec ++; |
|
} |
|
} |
|
} |
|
} |
|
if (numsec > 0) { |
|
if (document.cu.elements[i+1].value != "" && document.cu.elements[i+1].value != null) { |
|
sections = sections + "," + document.cu.elements[i+1].value; |
|
} |
|
} |
|
else { |
|
sections = document.cu.elements[i+1].value; |
|
} |
|
var newsecs = document.cu.elements[i+1].value; |
|
var numsplit; |
|
if (newsecs != null && newsecs != "") { |
|
numsplit = newsecs.split(/,/g); |
|
numsec = numsec + numsplit.length; |
|
} |
|
|
|
if ((role == 'st') && (numsec > 1)) { |
|
alert("In each course, each user may only have one student role at a time. You had selected "+numsec+" sections.\\nPlease modify your selections so they include no more than one section.") |
|
return; |
|
} |
|
else if (numsplit != null) { |
|
for (var j=0; j<numsplit.length; j++) { |
|
if ((numsplit[j] == 'all') || |
|
(numsplit[j] == 'none')) { |
|
alert("'"+numsplit[j]+"' may not be used as the name for a section, as it is a reserved word.\\nPlease choose a different section name."); |
|
return; |
|
} |
|
for (var k=0; k<groups.length; k++) { |
|
if (numsplit[j] == groups[k]) { |
|
alert("'"+numsplit[j]+"' may not be used as a section name, as it is the name of a course group.\\nSection names and group names must be distinct. Please choose a different section name."); |
|
return; |
|
} |
|
} |
|
} |
|
} |
|
document.cu.elements[i+2].value = sections; |
|
} |
|
} |
|
} |
|
} |
|
document.cu.submit(); |
|
} |
|
ENDSECCODE |
|
} |
} |
my $js = &user_modification_js($pjump_def,$dc_setcourse_code, |
my $js = &user_modification_js($pjump_def,$dc_setcourse_code, |
$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 695 ENDSECCODE
|
Line 667 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="" /> |
Line 709 ENDFORMINFO
|
Line 681 ENDFORMINFO
|
} |
} |
} |
} |
if ($uhome eq 'no_host') { |
if ($uhome eq 'no_host') { |
my %lt=&Apache::lonlocal::texthash( |
|
'cnu' => "Create New User", |
|
'nu' => "New User", |
|
'ind' => "in domain", |
|
'pd' => "Personal Data", |
|
'firstname' => "First Name", |
|
'middlename' => "Middle Name", |
|
'lastname' => "Last Name", |
|
'generation' => "Generation", |
|
'permanentemail' => "Permanent e-mail address", |
|
'id' => "ID/Student Number", |
|
'hs' => "Home Server", |
|
'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 = '<br />'.&portfolio_quota($ccuname,$ccdomain); |
} |
} |
my $genhelp=&Apache::loncommon::help_open_topic('Generation'); |
|
&initialize_authen_forms($ccdomain); |
&initialize_authen_forms($ccdomain); |
|
my %lt=&Apache::lonlocal::texthash( |
|
'cnu' => 'Create New User', |
|
'ind' => 'in domain', |
|
'lg' => 'Login Data', |
|
'hs' => "Home Server", |
|
); |
$r->print(<<ENDTITLE); |
$r->print(<<ENDTITLE); |
$start_page |
$start_page |
$crumbs |
$crumbs |
$response |
$response |
$forminfo |
$forminfo |
<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> |
<h2>$lt{'cnu'} "$ccuname" $lt{'ind'} $ccdomain</h2> |
<p> |
|
ENDTITLE |
ENDTITLE |
$r->print(&Apache::lonhtmlcommon::start_pick_box()); |
$r->print('<div class="LC_left_float">'. |
foreach my $item (@userinfo) { |
&personal_data_display($ccuname,$ccdomain,$newuser, |
my $rowtitle = $lt{$item}; |
%inst_results)); |
if ($item eq 'generation') { |
|
$rowtitle = $genhelp.$rowtitle; |
|
} |
|
$r->print(&Apache::lonhtmlcommon::row_title($rowtitle,undef,'LC_oddrow_value')."\n"); |
|
if ($inst_results{$item} ne '') { |
|
$r->print('<input type="hidden" name="'.$element{$item}.'" value="'.$inst_results{$item}.'" />'.$inst_results{$item}); |
|
} else { |
|
$r->print('<input type="text" name="'.$element{$item}.'" size="'.$textboxsize{$item}.'" value="" />'); |
|
} |
|
$r->print(&Apache::lonhtmlcommon::row_closure(1)); |
|
} |
|
$r->print(&Apache::lonhtmlcommon::end_pick_box()); |
|
my ($home_server_pick,$numlib) = |
my ($home_server_pick,$numlib) = |
&Apache::loncommon::home_server_form_item($ccdomain,'hserver', |
&Apache::loncommon::home_server_form_item($ccdomain,'hserver', |
'default','hide'); |
'default','hide'); |
Line 786 $lt{'hs'}: $home_server_pick
|
Line 718 $lt{'hs'}: $home_server_pick
|
} else { |
} else { |
$r->print($home_server_pick); |
$r->print($home_server_pick); |
} |
} |
$r->print("<hr />\n".'<h3>'.$lt{'lg'}.'</h3>'); |
$r->print('</div>'."\n".'<div class="LC_left_float"><h3>'. |
|
$lt{'lg'}.'</h3>'); |
my ($fixedauth,$varauth,$authmsg); |
my ($fixedauth,$varauth,$authmsg); |
if ($rulematch) { |
if (ref($rulematch{$ccuname.':'.$ccdomain}) eq 'HASH') { |
|
my $matchedrule = $rulematch{$ccuname.':'.$ccdomain}{'username'}; |
|
my ($rules,$ruleorder) = |
|
&Apache::lonnet::inst_userrules($ccdomain,'username'); |
if (ref($rules) eq 'HASH') { |
if (ref($rules) eq 'HASH') { |
if (ref($rules->{$rulematch}) eq 'HASH') { |
if (ref($rules->{$matchedrule}) eq 'HASH') { |
my $authtype = $rules->{$rulematch}{'authtype'}; |
my $authtype = $rules->{$matchedrule}{'authtype'}; |
if ($authtype !~ /^(krb4|krb5|int|fsys|loc)$/) { |
if ($authtype !~ /^(krb4|krb5|int|fsys|loc)$/) { |
$r->print(&set_login($ccdomain)); |
$r->print(&Apache::lonuserutils::set_login($ccdomain,$authformkrb,$authformint,$authformloc)); |
} else { |
} else { |
my $authparm = $rules->{$rulematch}{'authparm'}; |
my $authparm = $rules->{$matchedrule}{'authparm'}; |
if ($authtype =~ /^krb(4|5)$/) { |
if ($authtype =~ /^krb(4|5)$/) { |
my $ver = $1; |
my $ver = $1; |
if ($authparm ne '') { |
if ($authparm ne '') { |
Line 804 $lt{'hs'}: $home_server_pick
|
Line 740 $lt{'hs'}: $home_server_pick
|
<input type="hidden" name="krbver" value="$ver" /> |
<input type="hidden" name="krbver" value="$ver" /> |
<input type="hidden" name="krbarg" value="$authparm" /> |
<input type="hidden" name="krbarg" value="$authparm" /> |
KERB |
KERB |
$authmsg = $rules->{$rulematch}{'authmsg'}; |
$authmsg = $rules->{$matchedrule}{'authmsg'}; |
} |
} |
} else { |
} else { |
$fixedauth = |
$fixedauth = |
'<input type="hidden" name="login" value="'.$authtype.'" />'."\n"; |
'<input type="hidden" name="login" value="'.$authtype.'" />'."\n"; |
if ($rules->{$rulematch}{'authparmfixed'}) { |
if ($rules->{$matchedrule}{'authparmfixed'}) { |
$fixedauth .= |
$fixedauth .= |
'<input type="hidden" name="'.$authtype.'arg" value="'.$authparm.'" />'."\n"; |
'<input type="hidden" name="'.$authtype.'arg" value="'.$authparm.'" />'."\n"; |
} else { |
} else { |
Line 819 KERB
|
Line 755 KERB
|
} |
} |
} |
} |
} else { |
} else { |
$r->print(&set_login($ccdomain)); |
$r->print(&Apache::lonuserutils::set_login($ccdomain,$authformkrb,$authformint,$authformloc)); |
} |
} |
} |
} |
if ($authmsg) { |
if ($authmsg) { |
Line 830 $varauth
|
Line 766 $varauth
|
ENDAUTH |
ENDAUTH |
} |
} |
} else { |
} else { |
$r->print(&set_login($ccdomain)); |
$r->print(&Apache::lonuserutils::set_login($ccdomain,$authformkrb,$authformint,$authformloc)); |
} |
} |
$r->print(<<ENDPORT); |
$r->print(<<ENDPORT); |
<hr /> |
$portfolioform |
$portfolioform |
</div><div class="LC_clear_float_footer"></div> |
ENDPORT |
ENDPORT |
} else { # user already exists |
} else { # user already exists |
my %lt=&Apache::lonlocal::texthash( |
my %lt=&Apache::lonlocal::texthash( |
'cup' => "Change User Privileges for", |
'cup' => "Modify existing 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 |
Line 852 $crumbs
|
Line 783 $crumbs
|
$forminfo |
$forminfo |
<h2>$lt{'cup'} "$ccuname" $lt{'id'} "$ccdomain"</h2> |
<h2>$lt{'cup'} "$ccuname" $lt{'id'} "$ccdomain"</h2> |
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', |
if ($context eq 'domain') { |
'permanentemail','portfolioquota'],$ccdomain,$ccuname); |
$r->print(&Apache::lonuserutils::forceid_change($context)); |
my %rolesdump=&Apache::lonnet::dump('roles',$ccdomain,$ccuname); |
} |
$r->print(' |
$r->print('</div>'); |
<hr />'. |
my $user_auth_text = |
&Apache::loncommon::start_data_table(). |
&user_authentication($ccuname,$ccdomain,$krbdefdom,\%abv_auth); |
&Apache::loncommon::start_data_table_header_row(). |
my $user_quota_text; |
'<th>'.$lt{'fn'}.'</th><th>'.$lt{'mn'}.'</th><th>'.$lt{'ln'}.'</th><th>'.$lt{'gen'}.'</th><th>'.$lt{'email'}.'</th>'. |
if (&Apache::lonnet::allowed('mpq',$ccdomain)) { |
&Apache::loncommon::end_data_table_header_row(). |
# Current user has quota modification privileges |
&Apache::loncommon::start_data_table_row()); |
$user_quota_text = &portfolio_quota($ccuname,$ccdomain); |
foreach my $item ('firstname','middlename','lastname','generation','permanentemail') { |
} elsif (&Apache::lonnet::allowed('mpq',$env{'request.role.domain'})) { |
if (&Apache::lonnet::allowed('mau',$ccdomain)) { |
# Get the user's portfolio information |
$r->print(<<"END"); |
my %portq = &Apache::lonnet::get('environment',['portfolioquota'], |
<td><input type="text" name="c$item" value="$userenv{$item}" size="15" /></td> |
$ccdomain,$ccuname); |
END |
|
} else { |
my %lt=&Apache::lonlocal::texthash( |
$r->print('<td>'.$userenv{$item}.'</td>'); |
'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", |
|
); |
|
$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) { |
my $now=time; |
my $now=time; |
my %lt=&Apache::lonlocal::texthash( |
my %lt=&Apache::lonlocal::texthash( |
'rer' => "Revoke Existing Roles", |
'rer' => "Existing Roles", |
'rev' => "Revoke", |
'rev' => "Revoke", |
'del' => "Delete", |
'del' => "Delete", |
'ren' => "Re-Enable", |
'ren' => "Re-Enable", |
Line 1014 END
|
Line 961 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 1050 END
|
Line 997 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 1066 END
|
Line 1012 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, |
|
domain => $ccdomain, |
|
curr_authtype => $currentauth, |
|
); |
|
$loginscript = &Apache::loncommon::authform_header(%param); |
|
} |
|
# Check for a bad authentication type |
|
if ($currentauth !~ /^(krb4|krb5|unix|internal|localauth):/) { |
|
# bad authentication scheme |
|
if (&Apache::lonnet::allowed('mau',$ccdomain)) { |
|
&initialize_authen_forms($ccdomain); |
|
my %lt=&Apache::lonlocal::texthash( |
|
'err' => "ERROR", |
|
'uuas' => "This user has an unrecognized authentication scheme", |
|
'sldb' => "Please specify login data below", |
|
'ld' => "Login Data" |
|
); |
|
my $choices = &set_login($ccdomain); |
|
$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> |
|
$choices |
|
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($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( |
|
'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>$authformnop |
|
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 { |
|
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 |
|
} |
|
} |
|
} ## 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>'); |
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 1227 ENDNOPORTPRIV
|
Line 1068 ENDNOPORTPRIV
|
"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 1267 ENDNOPORTPRIV
|
Line 1117 ENDNOPORTPRIV
|
$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(this.form)" />'."\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 set_login { |
sub user_authentication { |
my ($dom) = @_; |
my ($ccuname,$ccdomain,$krbdefdom,$abv_auth) = @_; |
my %domconfig = &Apache::lonnet::get_dom('configuration',['usercreation'],$dom); |
my $currentauth=&Apache::lonnet::queryauthenticate($ccuname,$ccdomain); |
my $response; |
my ($loginscript,$outcome); |
my ($authnum,%can_assign) = |
if ($currentauth=~/^(krb)(4|5):(.*)/) { |
&Apache::loncommon::get_assignable_auth($dom); |
my $long_auth = $1.$2; |
if (($can_assign{'krb4'}) || ($can_assign{'krb5'})) { |
my $curr_kerb_ver = $2; |
$response .= "<p>$authformkrb </p>\n"; |
my $krbdefdom=$3; |
} |
my $curr_authtype = $abv_auth->{$long_auth}; |
if ($can_assign{'int'}) { |
my %param = ( formname => 'document.cu', |
$response .= "<p>$authformint </p>\n" |
kerb_def_dom => $krbdefdom, |
} |
domain => $ccdomain, |
if ($can_assign{'loc'}) { |
curr_authtype => $curr_authtype, |
$response .= "<p>$authformloc </p>\n"; |
curr_kerb_ver => $curr_kerb_ver, |
|
); |
|
$loginscript = &Apache::loncommon::authform_header(%param); |
} |
} |
return $response; |
# 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 |
|
&initialize_authen_forms($ccdomain,$currentauth); |
|
my $authformnop_row; |
|
if (&Apache::lonnet::allowed('mau',$ccdomain)) { |
|
$authformnop_row = &Apache::loncommon::start_data_table_row(); |
|
} |
|
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(). |
|
$authformnop_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>'. |
|
&Apache::loncommon::end_data_table_row()."\n"; |
|
} |
|
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 { |
sub modify_login_block { |
Line 1312 sub modify_login_block {
|
Line 1260 sub modify_login_block {
|
if ($currentauth=~/^krb(4|5):/) { |
if ($currentauth=~/^krb(4|5):/) { |
$authformcurrent=$authformkrb; |
$authformcurrent=$authformkrb; |
if ($can_assign{'int'}) { |
if ($can_assign{'int'}) { |
$authform_other = "<p>$authformint </p>\n" |
$authform_other = &Apache::loncommon::start_data_table_row(). |
|
'<td>'.$authformint.'</td>'. |
|
&Apache::loncommon::end_data_table_row()."\n" |
} |
} |
if ($can_assign{'loc'}) { |
if ($can_assign{'loc'}) { |
$authform_other .= "<p>$authformloc </p>\n"; |
$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'})) { |
if (($can_assign{'krb4'}) || ($can_assign{'krb5'})) { |
$show_override_msg = 1; |
$show_override_msg = 1; |
Line 1323 sub modify_login_block {
|
Line 1275 sub modify_login_block {
|
} elsif ($currentauth=~/^internal:/) { |
} elsif ($currentauth=~/^internal:/) { |
$authformcurrent=$authformint; |
$authformcurrent=$authformint; |
if (($can_assign{'krb4'}) || ($can_assign{'krb5'})) { |
if (($can_assign{'krb4'}) || ($can_assign{'krb5'})) { |
$authform_other = "<p>$authformkrb </p>\n" |
$authform_other = &Apache::loncommon::start_data_table_row(). |
|
'<td>'.$authformkrb.'</td>'. |
|
&Apache::loncommon::end_data_table_row()."\n"; |
} |
} |
if ($can_assign{'loc'}) { |
if ($can_assign{'loc'}) { |
$authform_other .= "<p>$authformloc </p>\n"; |
$authform_other .= &Apache::loncommon::start_data_table_row(). |
|
'<td>'.$authformloc.'</td>'. |
|
&Apache::loncommon::end_data_table_row()."\n"; |
} |
} |
if ($can_assign{'int'}) { |
if ($can_assign{'int'}) { |
$show_override_msg = 1; |
$show_override_msg = 1; |
Line 1334 sub modify_login_block {
|
Line 1290 sub modify_login_block {
|
} elsif ($currentauth=~/^unix:/) { |
} elsif ($currentauth=~/^unix:/) { |
$authformcurrent=$authformfsys; |
$authformcurrent=$authformfsys; |
if (($can_assign{'krb4'}) || ($can_assign{'krb5'})) { |
if (($can_assign{'krb4'}) || ($can_assign{'krb5'})) { |
$authform_other = "<p>$authformkrb </p>\n" |
$authform_other = &Apache::loncommon::start_data_table_row(). |
|
'<td>'.$authformkrb.'</td>'. |
|
&Apache::loncommon::end_data_table_row()."\n"; |
} |
} |
if ($can_assign{'int'}) { |
if ($can_assign{'int'}) { |
$authform_other .= "<p>$authformint </p>\n" |
$authform_other .= &Apache::loncommon::start_data_table_row(). |
|
'<td>'.$authformint.'</td>'. |
|
&Apache::loncommon::end_data_table_row()."\n" |
} |
} |
if ($can_assign{'loc'}) { |
if ($can_assign{'loc'}) { |
$authform_other .= "<p>$authformloc </p>\n"; |
$authform_other .= &Apache::loncommon::start_data_table_row(). |
|
'<td>'.$authformloc.'</td>'. |
|
&Apache::loncommon::end_data_table_row()."\n"; |
} |
} |
if ($can_assign{'fsys'}) { |
if ($can_assign{'fsys'}) { |
$show_override_msg = 1; |
$show_override_msg = 1; |
Line 1348 sub modify_login_block {
|
Line 1310 sub modify_login_block {
|
} elsif ($currentauth=~/^localauth:/) { |
} elsif ($currentauth=~/^localauth:/) { |
$authformcurrent=$authformloc; |
$authformcurrent=$authformloc; |
if (($can_assign{'krb4'}) || ($can_assign{'krb5'})) { |
if (($can_assign{'krb4'}) || ($can_assign{'krb5'})) { |
$authform_other = "<p>$authformkrb </p>\n" |
$authform_other = &Apache::loncommon::start_data_table_row(). |
|
'<td>'.$authformkrb.'</td>'. |
|
&Apache::loncommon::end_data_table_row()."\n"; |
} |
} |
if ($can_assign{'int'}) { |
if ($can_assign{'int'}) { |
$authform_other .= "<p>$authformint </p>\n" |
$authform_other .= &Apache::loncommon::start_data_table_row(). |
|
'<td>'.$authformint.'</td>'. |
|
&Apache::loncommon::end_data_table_row()."\n" |
} |
} |
if ($can_assign{'loc'}) { |
if ($can_assign{'loc'}) { |
$show_override_msg = 1; |
$show_override_msg = 1; |
Line 1365 sub modify_login_block {
|
Line 1331 sub modify_login_block {
|
return ($authformcurrent,$authform_other,$show_override_msg); |
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 />'; |
|
my $rtnlink = '<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 1388 sub update_user_data {
|
Line 1413 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 1406 sub update_user_data {
|
Line 1431 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.$rtnlink); |
return; |
return; |
} |
} |
if ( $env{'form.ccuname'} ne |
if ( $env{'form.ccuname'} ne |
&LONCAPA::clean_username($env{'form.ccuname'}) ) { |
&LONCAPA::clean_username($env{'form.ccuname'}) ) { |
$r->print($error.&mt('Invalid login name').'. '. |
$r->print($error.&mt('Invalid login name').'. '. |
&mt('Only letters, numbers, periods, dashes, @, and underscores are valid').'.'. |
&mt('Only letters, numbers, periods, dashes, @, and underscores are valid').'.'. |
$end); |
$end.$rtnlink); |
return; |
return; |
} |
} |
if (! $env{'form.ccdomain'} ) { |
if (! $env{'form.ccdomain'} ) { |
$r->print($error.&mt('No domain specified').'.'.$end); |
$r->print($error.&mt('No domain specified').'.'.$end.$rtnlink); |
return; |
return; |
} |
} |
if ( $env{'form.ccdomain'} ne |
if ( $env{'form.ccdomain'} ne |
&LONCAPA::clean_domain($env{'form.ccdomain'}) ) { |
&LONCAPA::clean_domain($env{'form.ccdomain'}) ) { |
$r->print($error.&mt ('Invalid domain name').'. '. |
$r->print($error.&mt ('Invalid domain name').'. '. |
&mt('Only letters, numbers, periods, dashes, and underscores are valid').'.'. |
&mt('Only letters, numbers, periods, dashes, and underscores are valid').'.'. |
$end); |
$end.$rtnlink); |
return; |
return; |
} |
} |
if (! exists($env{'form.makeuser'})) { |
if (! exists($env{'form.makeuser'})) { |
Line 1462 sub update_user_data {
|
Line 1488 sub update_user_data {
|
# If they are creating a new user but have not specified login |
# If they are creating a new user but have not specified login |
# information this will be caught below. |
# information this will be caught below. |
} else { |
} else { |
$r->print($error.&mt('Invalid login mode or password').$end); |
$r->print($error.&mt('Invalid login mode or password').$end.$rtnlink); |
return; |
return; |
} |
} |
|
|
|
|
$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>'); |
|
my (%alerts,%rulematch,%inst_results,%curr_rules); |
if ($env{'form.makeuser'}) { |
if ($env{'form.makeuser'}) { |
$r->print('<h3>'.&mt('Creating new account.').'</h3>'); |
$r->print('<h3>'.&mt('Creating new account.').'</h3>'); |
# Check for the authentication mode and password |
# Check for the authentication mode and password |
if (! $amode || ! $genpwd) { |
if (! $amode || ! $genpwd) { |
$r->print($error.&mt('Invalid login mode or password').$end); |
$r->print($error.&mt('Invalid login mode or password').$end.$rtnlink); |
return; |
return; |
} |
} |
# Determine desired host |
# Determine desired host |
Line 1485 sub update_user_data {
|
Line 1511 sub update_user_data {
|
my %home_servers = |
my %home_servers = |
&Apache::lonnet::get_servers($env{'form.ccdomain'},'library'); |
&Apache::lonnet::get_servers($env{'form.ccdomain'},'library'); |
if (! exists($home_servers{$desiredhost})) { |
if (! exists($home_servers{$desiredhost})) { |
$r->print($error.&mt('Invalid home server specified')); |
$r->print($error.&mt('Invalid home server specified').$end.$rtnlink); |
return; |
return; |
} |
} |
} |
} |
|
# Check ID format |
|
my %checkhash; |
|
my %checks = ('id' => 1); |
|
%{$checkhash{$env{'form.ccuname'}.':'.$env{'form.ccdomain'}}} = ( |
|
'newuser' => 1, |
|
'id' => $env{'form.cid'}, |
|
); |
|
if ($env{'form.cid'} ne '') { |
|
&Apache::loncommon::user_rule_check(\%checkhash,\%checks,\%alerts, |
|
\%rulematch,\%inst_results,\%curr_rules); |
|
if (ref($alerts{'id'}) eq 'HASH') { |
|
if (ref($alerts{'id'}{$env{'form.ccdomain'}}) eq 'HASH') { |
|
my $domdesc = |
|
&Apache::lonnet::domain($env{'form.ccdomain'},'description'); |
|
if ($alerts{'id'}{$env{'form.ccdomain'}}{$env{'form.cid'}}) { |
|
my $userchkmsg; |
|
if (ref($curr_rules{$env{'form.ccdomain'}}) eq 'HASH') { |
|
$userchkmsg = |
|
&Apache::loncommon::instrule_disallow_msg('id', |
|
$domdesc,1). |
|
&Apache::loncommon::user_rule_formats($env{'form.ccdomain'}, |
|
$domdesc,$curr_rules{$env{'form.ccdomain'}}{'id'},'id'); |
|
} |
|
$r->print($error.&mt('Invalid ID format').$end. |
|
$userchkmsg.$rtnlink); |
|
return; |
|
} |
|
} |
|
} |
|
} |
# 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.cid'}, |
$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.cemail'} |
$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 1505 sub update_user_data {
|
Line 1561 sub update_user_data {
|
($env{'form.login'} ne '' )) { |
($env{'form.login'} ne '' )) { |
# Modify user privileges |
# Modify user privileges |
if (! $amode || ! $genpwd) { |
if (! $amode || ! $genpwd) { |
$r->print($error.'Invalid login mode or password'.$end); |
$r->print($error.'Invalid login mode or password'.$end.$rtnlink); |
return; |
return; |
} |
} |
# Only allow authentification modification if the person has authority |
# Only allow authentification modification if the person has authority |
Line 1518 sub update_user_data {
|
Line 1574 sub update_user_data {
|
($env{'form.ccuname'},$env{'form.ccdomain'})); |
($env{'form.ccuname'},$env{'form.ccdomain'})); |
} else { |
} else { |
# Okay, this is a non-fatal error. |
# Okay, this is a non-fatal error. |
$r->print($error.&mt('You do not have the authority to modify this users authentification information').'.'); |
$r->print($error.&mt('You do not have the authority to modify this users authentification information').'.'.$end); |
} |
} |
} |
} |
## |
## |
Line 1526 sub update_user_data {
|
Line 1582 sub update_user_data {
|
# Check for need to change |
# Check for need to change |
my %userenv = &Apache::lonnet::get |
my %userenv = &Apache::lonnet::get |
('environment',['firstname','middlename','lastname','generation', |
('environment',['firstname','middlename','lastname','generation', |
'permanentemail','portfolioquota','inststatus'], |
'id','permanentemail','portfolioquota','inststatus'], |
$env{'form.ccdomain'},$env{'form.ccuname'}); |
$env{'form.ccdomain'},$env{'form.ccuname'}); |
my ($tmp) = keys(%userenv); |
my ($tmp) = keys(%userenv); |
if ($tmp =~ /^(con_lost|error)/i) { |
if ($tmp =~ /^(con_lost|error)/i) { |
%userenv = (); |
%userenv = (); |
} |
} |
# Check to see if we need to change user information |
# Check to see if we need to change user information |
foreach my $item ('firstname','middlename','lastname','generation','permanentemail') { |
foreach my $item ('firstname','middlename','lastname','generation','permanentemail','id') { |
# Strip leading and trailing whitespace |
# Strip leading and trailing whitespace |
$env{'form.c'.$item} =~ s/(\s+$|^\s+)//g; |
$env{'form.c'.$item} =~ s/(\s+$|^\s+)//g; |
|
} |
|
# Check to see if we can change the ID/student number |
|
my $forceid = $env{'form.forceid'}; |
|
my $recurseid = $env{'form.recurseid'}; |
|
my $newuser = 0; |
|
my (%alerts,%rulematch,%idinst_results,%curr_rules,%got_rules); |
|
my %uidhash = &Apache::lonnet::idrget($env{'form.ccdomain'}, |
|
$env{'form.ccuname'}); |
|
if (($uidhash{$env{'form.ccuname'}}) && |
|
($uidhash{$env{'form.ccuname'}}!~/error\:/) && |
|
(!$forceid)) { |
|
if ($env{'form.cid'} ne $uidhash{$env{'form.ccuname'}}) { |
|
$env{'form.cid'} = $userenv{'id'}; |
|
} |
|
} |
|
if ($env{'form.cid'} ne $userenv{'id'}) { |
|
my $checkhash; |
|
my $checks = { 'id' => 1 }; |
|
$checkhash->{$env{'form.ccuname'}.':'.$env{'form.ccdomain'}} = |
|
{ 'newuser' => $newuser, |
|
'id' => $env{'form.cid'}, |
|
}; |
|
&Apache::loncommon::user_rule_check($checkhash,$checks, |
|
\%alerts,\%rulematch,\%idinst_results,\%curr_rules,\%got_rules); |
|
if (ref($alerts{'id'}) eq 'HASH') { |
|
if (ref($alerts{'id'}{$env{'form.ccdomain'}}) eq 'HASH') { |
|
$env{'form.cid'} = $userenv{'id'}; |
|
} |
|
} |
} |
} |
my ($quotachanged,$namechanged,$oldportfolioquota,$newportfolioquota, |
my ($quotachanged,$namechanged,$oldportfolioquota,$newportfolioquota, |
$inststatus,$isdefault,$defquotatext); |
$inststatus,$oldisdefault,$newisdefault,$olddefquotatext, |
|
$newdefquotatext); |
my ($defquota,$settingstatus) = |
my ($defquota,$settingstatus) = |
&Apache::loncommon::default_quota($env{'form.ccdomain'},$inststatus); |
&Apache::loncommon::default_quota($env{'form.ccdomain'},$inststatus); |
my %changeHash; |
my %changeHash; |
|
$changeHash{'portfolioquota'} = $userenv{'portfolioquota'}; |
if ($userenv{'portfolioquota'} ne '') { |
if ($userenv{'portfolioquota'} ne '') { |
$oldportfolioquota = $userenv{'portfolioquota'}; |
$oldportfolioquota = $userenv{'portfolioquota'}; |
if ($env{'form.customquota'} == 1) { |
if ($env{'form.customquota'} == 1) { |
Line 1551 sub update_user_data {
|
Line 1638 sub update_user_data {
|
$newportfolioquota = $env{'form.portfolioquota'}; |
$newportfolioquota = $env{'form.portfolioquota'}; |
$newportfolioquota =~ s/[^\d\.]//g; |
$newportfolioquota =~ s/[^\d\.]//g; |
} |
} |
if ($newportfolioquota != $userenv{'portfolioquota'}) { |
if ($newportfolioquota != $oldportfolioquota) { |
$quotachanged = "a_admin($newportfolioquota,\%changeHash); |
$quotachanged = "a_admin($newportfolioquota,\%changeHash); |
} |
} |
} else { |
} else { |
$quotachanged = "a_admin('',\%changeHash); |
$quotachanged = "a_admin('',\%changeHash); |
$newportfolioquota = $defquota; |
$newportfolioquota = $defquota; |
$isdefault = 1; |
$newisdefault = 1; |
} |
} |
} else { |
} else { |
|
$oldisdefault = 1; |
$oldportfolioquota = $defquota; |
$oldportfolioquota = $defquota; |
if ($env{'form.customquota'} == 1) { |
if ($env{'form.customquota'} == 1) { |
if ($env{'form.portfolioquota'} eq '') { |
if ($env{'form.portfolioquota'} eq '') { |
Line 1571 sub update_user_data {
|
Line 1659 sub update_user_data {
|
$quotachanged = "a_admin($newportfolioquota,\%changeHash); |
$quotachanged = "a_admin($newportfolioquota,\%changeHash); |
} else { |
} else { |
$newportfolioquota = $defquota; |
$newportfolioquota = $defquota; |
$isdefault = 1; |
$newisdefault = 1; |
} |
} |
} |
} |
if ($isdefault) { |
if ($oldisdefault) { |
if ($settingstatus eq '') { |
$olddefquotatext = &get_defaultquota_text($settingstatus); |
$defquotatext = &mt('(default)'); |
} |
} else { |
if ($newisdefault) { |
my ($usertypes,$order) = |
$newdefquotatext = &get_defaultquota_text($settingstatus); |
&Apache::lonnet::retrieve_inst_usertypes($env{'form.ccdomain'}); |
|
if ($usertypes->{$settingstatus} eq '') { |
|
$defquotatext = &mt('(default)'); |
|
} else { |
|
$defquotatext = &mt('(default for [_1])',$usertypes->{$settingstatus}); |
|
} |
|
} |
|
} |
} |
if (&Apache::lonnet::allowed('mau',$env{'form.ccdomain'}) && |
if (&Apache::lonnet::allowed('mau',$env{'form.ccdomain'}) && |
($env{'form.cfirstname'} ne $userenv{'firstname'} || |
($env{'form.cfirstname'} ne $userenv{'firstname'} || |
$env{'form.cmiddlename'} ne $userenv{'middlename'} || |
$env{'form.cmiddlename'} ne $userenv{'middlename'} || |
$env{'form.clastname'} ne $userenv{'lastname'} || |
$env{'form.clastname'} ne $userenv{'lastname'} || |
$env{'form.cgeneration'} ne $userenv{'generation'} || |
$env{'form.cgeneration'} ne $userenv{'generation'} || |
|
$env{'form.cid'} ne $userenv{'id'} || |
$env{'form.cpermanentemail'} ne $userenv{'permanentemail'} )) { |
$env{'form.cpermanentemail'} ne $userenv{'permanentemail'} )) { |
$namechanged = 1; |
$namechanged = 1; |
} |
} |
if ($namechanged) { |
if ($namechanged || $quotachanged) { |
# Make the change |
|
$changeHash{'firstname'} = $env{'form.cfirstname'}; |
$changeHash{'firstname'} = $env{'form.cfirstname'}; |
$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{'id'} = $env{'form.cid'}; |
$changeHash{'permanentemail'} = $env{'form.cpermanentemail'}; |
$changeHash{'permanentemail'} = $env{'form.cpermanentemail'}; |
my $putresult = &Apache::lonnet::put |
my ($quotachgresult,$namechgresult); |
('environment',\%changeHash, |
if ($quotachanged) { |
$env{'form.ccdomain'},$env{'form.ccuname'}); |
$quotachgresult = |
if ($putresult eq 'ok') { |
&Apache::lonnet::put('environment',\%changeHash, |
|
$env{'form.ccdomain'},$env{'form.ccuname'}); |
|
} |
|
if ($namechanged) { |
|
# Make the change |
|
$namechgresult = |
|
&Apache::lonnet::modifyuser($env{'form.ccdomain'}, |
|
$env{'form.ccuname'},$changeHash{'id'},undef,undef, |
|
$changeHash{'firstname'},$changeHash{'middlename'}, |
|
$changeHash{'lastname'},$changeHash{'generation'}, |
|
$changeHash{'id'},undef,$changeHash{'permanentemail'}); |
|
} |
|
if (($namechanged && $namechgresult eq 'ok') || |
|
($quotachanged && $quotachgresult eq 'ok')) { |
# Tell the user we changed the name |
# Tell the user we changed the name |
my %lt=&Apache::lonlocal::texthash( |
my %lt=&Apache::lonlocal::texthash( |
'uic' => "User Information Changed", |
'uic' => "User Information Changed", |
Line 1613 sub update_user_data {
|
Line 1708 sub update_user_data {
|
'mddl' => "middle", |
'mddl' => "middle", |
'lst' => "last", |
'lst' => "last", |
'gen' => "generation", |
'gen' => "generation", |
|
'id' => "ID/Student number", |
'mail' => "permanent e-mail", |
'mail' => "permanent e-mail", |
'disk' => "disk space allocated to portfolio files", |
'disk' => "disk space allocated to portfolio files", |
'prvs' => "Previous", |
'prvs' => "Previous", |
'chto' => "Changed To" |
'chto' => "Changed To" |
); |
); |
|
$r->print('<h4>'.$lt{'uic'}.'</h4>'. |
|
&Apache::loncommon::start_data_table(). |
|
&Apache::loncommon::start_data_table_header_row()); |
$r->print(<<"END"); |
$r->print(<<"END"); |
<table border="2"> |
<th> </th> |
<caption>$lt{'uic'}</caption> |
|
<tr><th> </th> |
|
<th>$lt{'frst'}</th> |
<th>$lt{'frst'}</th> |
<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{'id'}</th> |
<th>$lt{'mail'}</th> |
<th>$lt{'mail'}</th> |
<th>$lt{'disk'}</th></tr> |
<th>$lt{'disk'}</th> |
<tr><td>$lt{'prvs'}</td> |
END |
|
$r->print(&Apache::loncommon::end_data_table_header_row(). |
|
&Apache::loncommon::start_data_table_row()); |
|
$r->print(<<"END"); |
|
<td><b>$lt{'prvs'}</b></td> |
<td>$userenv{'firstname'} </td> |
<td>$userenv{'firstname'} </td> |
<td>$userenv{'middlename'} </td> |
<td>$userenv{'middlename'} </td> |
<td>$userenv{'lastname'} </td> |
<td>$userenv{'lastname'} </td> |
<td>$userenv{'generation'} </td> |
<td>$userenv{'generation'} </td> |
|
<td>$userenv{'id'}</td> |
<td>$userenv{'permanentemail'} </td> |
<td>$userenv{'permanentemail'} </td> |
<td>$oldportfolioquota Mb</td> |
<td>$oldportfolioquota Mb $olddefquotatext </td> |
</tr> |
END |
<tr><td>$lt{'chto'}</td> |
$r->print(&Apache::loncommon::end_data_table_row(). |
|
&Apache::loncommon::start_data_table_row()); |
|
$r->print(<<"END"); |
|
<td><b>$lt{'chto'}</b></td> |
<td>$env{'form.cfirstname'} </td> |
<td>$env{'form.cfirstname'} </td> |
<td>$env{'form.cmiddlename'} </td> |
<td>$env{'form.cmiddlename'} </td> |
<td>$env{'form.clastname'} </td> |
<td>$env{'form.clastname'} </td> |
<td>$env{'form.cgeneration'} </td> |
<td>$env{'form.cgeneration'} </td> |
|
<td>$env{'form.cid'} </td> |
<td>$env{'form.cpermanentemail'} </td> |
<td>$env{'form.cpermanentemail'} </td> |
<td>$newportfolioquota Mb $defquotatext </td></tr> |
<td>$newportfolioquota Mb $newdefquotatext </td> |
</table> |
|
END |
END |
|
$r->print(&Apache::loncommon::end_data_table_row(). |
|
&Apache::loncommon::end_data_table()); |
|
if ($env{'form.cid'} ne $userenv{'id'}) { |
|
&Apache::lonnet::idput($env{'form.ccdomain'}, |
|
($env{'form.ccuname'} => $env{'form.cid'})); |
|
if (($recurseid) && |
|
(&Apache::lonnet::allowed('mau',$env{'form.ccdomain'}))) { |
|
my %userupdate = ( |
|
lastname => $env{'form.clasaname'}, |
|
middlename => $env{'form.cmiddlename'}, |
|
firstname => $env{'form.cfirstname'}, |
|
generation => $env{'fora.cgeneration'}, |
|
id => $env{'form.cid'}, |
|
); |
|
my $idresult = |
|
&Apache::lonuserutils::propagate_id_change( |
|
$env{'form.ccuname'},$env{'form.ccdomain'}, |
|
\%userupdate); |
|
$r->print('<br />'.$idresult.'<br />'); |
|
} |
|
} |
if (($env{'form.ccdomain'} eq $env{'user.domain'}) && |
if (($env{'form.ccdomain'} eq $env{'user.domain'}) && |
($env{'form.ccuname'} eq $env{'user.name'})) { |
($env{'form.ccuname'} eq $env{'user.name'})) { |
my %newenvhash; |
my %newenvhash; |
Line 1654 END
|
Line 1781 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; |
# They did not want to change the users name or quota but we can |
if ($quotachanged) { |
# still tell them what the name and quota are |
$putresult = &Apache::lonnet::put |
|
('environment',\%changeHash, |
|
$env{'form.ccdomain'},$env{'form.ccuname'}); |
|
} |
|
# They did not want to change the users name but we can |
|
# still tell them what the name is |
|
my %lt=&Apache::lonlocal::texthash( |
my %lt=&Apache::lonlocal::texthash( |
|
'id' => "ID/Student number", |
'mail' => "Permanent e-mail", |
'mail' => "Permanent e-mail", |
'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'} |
<h4>$lt{'mail'}: $userenv{'permanentemail'}</h4> |
|
END |
END |
if ($putresult eq 'ok') { |
if ($userenv{'permanentemail'} ne '') { |
if ($oldportfolioquota != $newportfolioquota) { |
$r->print('<br />['.$lt{'mail'}.': '. |
$r->print('<h4>'.$lt{'disk'}.': '.$newportfolioquota.' Mb '. |
$userenv{'permanentemail'}.']'); |
$defquotatext.'</h4>'); |
|
&Apache::lonnet::appenv('environment.portfolioquota' => $changeHash{'portfolioquota'}); |
|
} |
|
} |
} |
|
$r->print('<br />['.$lt{'disk'}.': '.$oldportfolioquota.' Mb '. |
|
$olddefquotatext.']</h4>'); |
} |
} |
} |
} |
## |
## |
my $now=time; |
my $now=time; |
|
my $rolechanges = 0; |
$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 1701 END
|
Line 1823 END
|
$r->print(&mt('Revoking [_1] in [_2]: [_3]', |
$r->print(&mt('Revoking [_1] in [_2]: [_3]', |
$role,$scope,'<b>'.$result.'</b>').'<br />'); |
$role,$scope,'<b>'.$result.'</b>').'<br />'); |
if ($role eq 'st') { |
if ($role eq 'st') { |
my $result = &classlist_drop($scope,$env{'form.ccuname'}, |
my $result = |
$env{'form.ccdomain'},$now); |
&Apache::lonuserutils::classlist_drop($scope, |
|
$env{'form.ccuname'},$env{'form.ccdomain'}, |
|
$now); |
$r->print($result); |
$r->print($result); |
} |
} |
} |
} |
if ($key=~m{^form\.rev\:([^_]+)_cr\.cr/($match_domain)/($match_username)/(\w+)$ }s) { |
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 1714 END
|
Line 1838 END
|
$env{'form.ccuname'},$1,$2,$3,$4). |
$env{'form.ccuname'},$1,$2,$3,$4). |
'</b><br />'); |
'</b><br />'); |
} |
} |
|
$rolechanges ++; |
} elsif ($key=~/^form\.del/) { |
} elsif ($key=~/^form\.del/) { |
if ($key=~/^form\.del\:([^\_]+)\_([^\_\.]+)$/) { |
if ($key=~/^form\.del\:([^\_]+)\_([^\_\.]+)$/) { |
# Delete standard role |
# Delete standard role |
Line 1725 END
|
Line 1850 END
|
$r->print(&mt('Deleting [_1] in [_2]: [_3]',$role,$scope, |
$r->print(&mt('Deleting [_1] in [_2]: [_3]',$role,$scope, |
'<b>'.$result.'</b>').'<br />'); |
'<b>'.$result.'</b>').'<br />'); |
if ($role eq 'st') { |
if ($role eq 'st') { |
my $result = &classlist_drop($scope,$env{'form.ccuname'}, |
my $result = |
$env{'form.ccdomain'},$now); |
&Apache::lonuserutils::classlist_drop($scope, |
|
$env{'form.ccuname'},$env{'form.ccdomain'}, |
|
$now); |
$r->print($result); |
$r->print($result); |
} |
} |
} |
} |
Line 1739 END
|
Line 1866 END
|
$env{'form.ccuname'},$url,$rdom,$rnam,$rolename,$now, |
$env{'form.ccuname'},$url,$rdom,$rnam,$rolename,$now, |
0,1).'</b><br />'); |
0,1).'</b><br />'); |
} |
} |
|
$rolechanges ++; |
} elsif ($key=~/^form\.ren/) { |
} elsif ($key=~/^form\.ren/) { |
my $udom = $env{'form.ccdomain'}; |
my $udom = $env{'form.ccdomain'}; |
my $uname = $env{'form.ccuname'}; |
my $uname = $env{'form.ccuname'}; |
Line 1777 END
|
Line 1905 END
|
$r->print(&mt('Re-enabling custom role [_1] by [_2]@[_3] in [_4] : <b>[_5]</b>', |
$r->print(&mt('Re-enabling custom role [_1] by [_2]@[_3] in [_4] : <b>[_5]</b>', |
$rolename,$rnam,$rdom,$url,$result).'<br />'); |
$rolename,$rnam,$rdom,$url,$result).'<br />'); |
} |
} |
|
$rolechanges ++; |
} elsif ($key=~/^form\.act/) { |
} elsif ($key=~/^form\.act/) { |
my $udom = $env{'form.ccdomain'}; |
my $udom = $env{'form.ccdomain'}; |
my $uname = $env{'form.ccuname'}; |
my $uname = $env{'form.ccuname'}; |
Line 1880 END
|
Line 2009 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 1890 END
|
Line 2019 END
|
} |
} |
$r->print(' '.&mt('Please <a href="javascript:history.go(-1)">go back</a> and choose a different section name.').'</p><br />'); |
$r->print(' '.&mt('Please <a href="javascript:history.go(-1)">go back</a> and choose a different section name.').'</p><br />'); |
} |
} |
|
$rolechanges ++; |
} |
} |
} # 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>'); |
if (!$rolechanges) { |
$r->print('<form name="userupdate" method="post" />'."\n"); |
$r->print(&mt('No roles to modify')); |
foreach my $item ('srchby','srchin','srchtype','srchterm','srchdomain','ccuname','ccdomain') { |
|
$r->print('<input type="hidden" name="'.$item.'" value="'.$env{'form.'.$item}.'" />'."\n"); |
|
} |
} |
foreach my $item ('sortby','seluname','seludom') { |
|
if (exists($env{'form.'.$item})) { |
|
$r->print('<input type="hidden" name="'.$item.'" value="'.$env{'form.'.$item}.'" />'."\n"); |
|
} |
|
} |
|
$r->print('<input type="hidden" name="phase" value="" />'."\n". |
|
'<input type ="hidden" name="currstate" value="" />'."\n". |
|
'</form>'); |
|
$r->print(&Apache::loncommon::end_page()); |
$r->print(&Apache::loncommon::end_page()); |
} |
} |
|
|
sub classlist_drop { |
sub get_defaultquota_text { |
my ($scope,$uname,$udom,$now) = @_; |
my ($settingstatus) = @_; |
my ($cdom,$cnum) = ($scope=~m{^/($match_domain)/($match_courseid)}); |
my $defquotatext; |
my $cid=$cdom.'_'.$cnum; |
if ($settingstatus eq '') { |
my $user = $uname.':'.$udom; |
$defquotatext = &mt('(default)'); |
if (!&active_student_roles($cnum,$cdom,$uname,$udom)) { |
} else { |
my $result = |
my ($usertypes,$order) = |
&Apache::lonnet::cput('classlist', |
&Apache::lonnet::retrieve_inst_usertypes($env{'form.ccdomain'}); |
{ $user => $now }, |
if ($usertypes->{$settingstatus} eq '') { |
$env{'course.'.$cid.'.domain'}, |
$defquotatext = &mt('(default)'); |
$env{'course.'.$cid.'.num'}); |
} else { |
return &mt('Drop from classlist: [_1]', |
$defquotatext = &mt('(default for [_1])',$usertypes->{$settingstatus}); |
'<b>'.$result.'</b>').'<br />'; |
} |
} |
} |
|
return $defquotatext; |
} |
} |
|
|
sub active_student_roles { |
sub update_result_form { |
my ($cnum,$cdom,$uname,$udom) = @_; |
my ($uhome) = @_; |
my %roles = |
my $outcome = |
&Apache::lonnet::get_my_roles($uname,$udom,'userroles', |
'<form name="userupdate" method="post" />'."\n"; |
['future','active'],['st']); |
foreach my $item ('srchby','srchin','srchtype','srchterm','srchdomain','ccuname','ccdomain') { |
return exists($roles{"$cnum:$cdom:st"}); |
$outcome .= '<input type="hidden" name="'.$item.'" value="'.$env{'form.'.$item}.'" />'."\n"; |
|
} |
|
foreach my $item ('sortby','seluname','seludom') { |
|
if (exists($env{'form.'.$item})) { |
|
$outcome .= '<input type="hidden" name="'.$item.'" value="'.$env{'form.'.$item}.'" />'."\n"; |
|
} |
|
} |
|
if ($uhome eq 'no_host') { |
|
$outcome .= '<input type="hidden" name="forcenewuser" value="1" />'."\n"; |
|
} |
|
$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 quota_admin { |
sub quota_admin { |
Line 1990 sub custom_role_editor {
|
Line 2125 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 2059 sub custom_role_editor {
|
Line 2194 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 2103 ENDCCF
|
Line 2238 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 2184 sub make_button_code {
|
Line 2320 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 2214 sub set_custom_role {
|
Line 2346 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 2263 sub set_custom_role {
|
Line 2395 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 2271 sub set_custom_role {
|
Line 2403 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','callingform','roletype','showrole','bulkaction']); |
|
&Apache::lonhtmlcommon::clear_breadcrumbs(); |
|
if ($env{'form.action'} ne 'dateselect') { |
|
&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,$context); |
|
} 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'); |
|
&Apache::loncreateuser::restore_prev_selections(); |
|
my $srch; |
|
foreach my $item (@search) { |
|
$srch->{$item} = $env{'form.'.$item}; |
|
} |
|
|
|
if (($phase eq 'get_user_info') || ($phase eq 'userpicked')) { |
|
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,$context); |
|
} 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,'', |
|
$context); |
|
} |
|
} elsif ($env{'form.phase'} eq 'update_user_data') { |
|
&update_user_data($r); |
|
} else { |
|
&print_username_entry_form($r,undef,$srch); |
|
} |
|
} 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'}) { |
|
if ($env{'form.phase'} eq 'bulkchange') { |
|
&Apache::lonhtmlcommon::add_breadcrumb |
|
({href=>'backPage(document.studentform)', |
|
text=>"List Users"}); |
|
my $setting = $env{'form.roletype'}; |
|
my $choice = $env{'form.bulkaction'}; |
|
$r->print(&header()); |
|
$r->print(&Apache::lonhtmlcommon::breadcrumbs("List Users", |
|
'User_Management_List')); |
|
if ($permission->{'cusr'}) { |
|
&Apache::lonuserutils::update_user_list($r,$context,$setting,$choice); |
|
} |
|
} else { |
|
&Apache::lonhtmlcommon::add_breadcrumb |
|
({href=>'/adm/createuser?action=listusers', |
|
text=>"List Users"}); |
|
my ($cb_jscript,$jscript,$totcodes,$codetitles,$idlist,$idlist_titles); |
|
my $formname = 'studentform'; |
|
if ($context eq 'domain' && $env{'form.roletype'} eq 'course') { |
|
($cb_jscript,$jscript,$totcodes,$codetitles,$idlist,$idlist_titles) = |
|
&Apache::lonuserutils::courses_selector($env{'request.role.domain'}, |
|
$formname); |
|
$jscript .= &verify_user_display(); |
|
my $js = &add_script($jscript).$cb_jscript; |
|
my $loadcode = |
|
&Apache::lonuserutils::course_selector_loadcode($formname); |
|
if ($loadcode ne '') { |
|
$r->print(&header($js,{'onload' => $loadcode,})); |
|
} else { |
|
$r->print(&header($js)); |
|
} |
|
} else { |
|
$r->print(&header(&add_script(&verify_user_display()))); |
|
} |
|
$r->print(&Apache::lonhtmlcommon::breadcrumbs("List Users", |
|
'User_Management_List')); |
|
&Apache::lonuserutils::print_userlist($r,undef,$permission,$context, |
|
$formname,$totcodes,$codetitles,$idlist,$idlist_titles); |
|
$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,$context); |
|
} else { |
|
&print_expire_menu($r,$context); |
|
} |
|
$r->print(&Apache::loncommon::end_page()); |
|
} elsif ($env{'form.action'} eq 'dateselect') { |
|
if ($permission->{'cusr'}) { |
|
$r->print(&header(undef,undef,{'no_nav_bar' => 1}). |
|
&Apache::lonuserutils::date_section_selector($context). |
|
&Apache::loncommon::end_page()); |
|
} else { |
|
$r->print(&header(). |
|
'<span class="LC_error">'.&mt('You do not have permission to modify dates or sections for users').'</span>'. |
|
&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,$args) = @_; |
(&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,$args); |
$r->send_http_header; |
} |
&Apache::lonhtmlcommon::clear_breadcrumbs(); |
return $start_page; |
|
} |
my $phase = $env{'form.phase'}; |
|
my @search = ('srchterm','srchby','srchin','srchtype','srchdomain'); |
sub add_script { |
|
my ($js) = @_; |
if (($phase eq 'get_user_info') || ($phase eq 'userpicked')) { |
return '<script type="text/javascript">'."\n".$js."\n".'</script>'; |
my $srch; |
} |
foreach my $item (@search) { |
|
$srch->{$item} = $env{'form.'.$item}; |
sub verify_user_display { |
} |
my $output = <<"END"; |
if ($env{'form.phase'} eq 'get_user_info') { |
|
my ($currstate,$response,$forcenewuser,$results) = |
function display_update() { |
&user_search_result($srch); |
document.studentform.action.value = 'listusers'; |
if ($currstate eq 'select') { |
document.studentform.phase.value = 'display'; |
&print_user_selection_page($r,$response,$srch,$results,'createuser',\@search); |
document.studentform.submit(); |
} elsif ($currstate eq 'modify') { |
} |
my ($ccuname,$ccdomain); |
|
if (($srch->{'srchby'} eq 'uname') && |
END |
($srch->{'srchtype'} eq 'exact')) { |
return $output; |
$ccuname = $srch->{'srchterm'}; |
|
$ccdomain= $srch->{'srchdomain'}; |
} |
} else { |
|
my @matchedunames = keys(%{$results}); |
############################################################### |
($ccuname,$ccdomain) = split(/:/,$matchedunames[0]); |
############################################################### |
} |
# Menu Phase One |
$ccuname =&LONCAPA::clean_username($ccuname); |
sub print_main_menu { |
$ccdomain=&LONCAPA::clean_domain($ccdomain); |
my ($permission) = @_; |
&print_user_modification_page($r,$ccuname,$ccdomain,$srch, |
my @menu = |
$response); |
( |
} elsif ($currstate eq 'query') { |
{ text => 'Upload a File of Users to Modify/Create Users and/or Add roles', |
&print_user_query_page($r,'createuser'); |
help => 'User_Management_Upload', |
} else { |
action => 'upload', |
&print_username_entry_form($r,$response,$srch,$forcenewuser); |
permission => $permission->{'cusr'}, |
} |
}, |
} elsif ($env{'form.phase'} eq 'userpicked') { |
{ text => 'Create User/Set User Roles for a single user', |
my $ccuname = &LONCAPA::clean_username($env{'form.seluname'}); |
help => 'User_Management_Single_User', |
my $ccdomain = &LONCAPA::clean_domain($env{'form.seludom'}); |
action => 'singleuser', |
&print_user_modification_page($r,$ccuname,$ccdomain,$srch); |
permission => $permission->{'cusr'}, |
} |
}, |
} elsif ($env{'form.phase'} eq 'update_user_data') { |
{ text => 'Display Lists of Users', |
&update_user_data($r); |
help => 'User_Management_List', |
} elsif ($env{'form.phase'} eq 'selected_custom_edit') { |
action => 'listusers', |
&custom_role_editor($r); |
permission => $permission->{'view'}, |
} elsif ($env{'form.phase'} eq 'set_custom_roles') { |
}, |
&set_custom_role($r); |
# { text => 'Expire User Roles', |
} else { |
# help => 'User_Management_Drops', |
&print_username_entry_form($r); |
# action => 'expire', |
} |
# permission => $permission->{'cusr'}, |
} else { |
# }, |
$env{'user.error.msg'}= |
{ text => 'Edit Custom Roles', |
"/adm/createuser:mau:0:0:Cannot modify user data"; |
help => 'Custom_Role_Edit', |
return HTTP_NOT_ACCEPTABLE; |
action => 'custom', |
} |
permission => $permission->{'custom'}, |
return OK; |
}, |
|
); |
|
my $menu_html = ''; |
|
foreach my $menu_item (@menu) { |
|
next if (! $menu_item->{'permission'}); |
|
$menu_html.='<p>'; |
|
$menu_html.='<font size="+1">'; |
|
if (exists($menu_item->{'url'})) { |
|
$menu_html.=qq{<a href="$menu_item->{'url'}">}; |
|
} else { |
|
$menu_html.= |
|
qq{<a href="/adm/createuser?action=$menu_item->{'action'}">}; |
|
} |
|
$menu_html.= &mt($menu_item->{'text'}).'</a></font>'; |
|
if (exists($menu_item->{'help'})) { |
|
$menu_html.= |
|
&Apache::loncommon::help_open_topic($menu_item->{'help'}); |
|
} |
|
$menu_html.='</p>'; |
|
} |
|
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 2450 sub user_search_result {
|
Line 2866 sub user_search_result {
|
{&Apache::lonnet::get('environment', |
{&Apache::lonnet::get('environment', |
['firstname', |
['firstname', |
'lastname', |
'lastname', |
'permanentemail'])}; |
'permanentemail'], |
|
$cudomain,$cuname)}; |
} |
} |
} |
} |
} |
} |
Line 2760 sub course_level_table {
|
Line 3177 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 2799 sub course_level_table {
|
Line 3216 sub course_level_table {
|
<td>'.$area.'<br />Domain: '.$domain.'</td>'."\n"; |
<td>'.$area.'<br />Domain: '.$domain.'</td>'."\n"; |
if ($role ne 'cc') { |
if ($role ne 'cc') { |
if (%sections_count) { |
if (%sections_count) { |
my $currsec = &course_sections(\%sections_count,$protectedcourse.'_'.$role); |
my $currsec = |
|
&Apache::lonuserutils::course_sections(\%sections_count, |
|
$protectedcourse.'_'.$role); |
$table .= |
$table .= |
'<td><table class="LC_createuser">'. |
'<td><table class="LC_createuser">'. |
'<tr class="LC_section_row"> |
'<tr class="LC_section_row"> |
Line 2839 ENDTIMEENTRY
|
Line 3258 ENDTIMEENTRY
|
<td>'.$plrole.'</td> |
<td>'.$plrole.'</td> |
<td>'.$area.'</td>'."\n"; |
<td>'.$area.'</td>'."\n"; |
if (%sections_count) { |
if (%sections_count) { |
my $currsec = &course_sections(\%sections_count,$customrole); |
my $currsec = |
|
&Apache::lonuserutils::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 2868 ENDENTRY
|
Line 3289 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 2880 $table.
|
Line 3304 $table.
|
return $result; |
return $result; |
} |
} |
|
|
sub course_sections { |
|
my ($sections_count,$role) = @_; |
|
my $output = ''; |
|
my @sections = (sort {$a <=> $b} keys %{$sections_count}); |
|
if (scalar(@sections) == 1) { |
|
$output = '<select name="currsec_'.$role.'" >'."\n". |
|
' <option value="">Select</option>'."\n". |
|
' <option value="">No section</option>'."\n". |
|
' <option value="'.$sections[0].'" >'.$sections[0].'</option>'."\n"; |
|
} else { |
|
$output = '<select name="currsec_'.$role.'" '; |
|
my $multiple = 4; |
|
if (scalar(@sections) < 4) { $multiple = scalar(@sections); } |
|
$output .= 'multiple="multiple" size="'.$multiple.'">'."\n"; |
|
foreach my $sec (@sections) { |
|
$output .= '<option value="'.$sec.'">'.$sec."</option>\n"; |
|
} |
|
} |
|
$output .= '</select>'; |
|
return $output; |
|
} |
|
|
|
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="" />'; |