version 1.218, 2007/12/21 16:23:54
|
version 1.228, 2008/01/02 09:16:59
|
Line 76 my $authformfsys;
|
Line 76 my $authformfsys;
|
my $authformloc; |
my $authformloc; |
|
|
sub initialize_authen_forms { |
sub initialize_authen_forms { |
my ($dom,$curr_authtype,$mode) = @_; |
my ($dom,$formname,$curr_authtype,$mode) = @_; |
my ($krbdefdom)=( $ENV{'SERVER_NAME'}=~/(\w+\.\w+)$/); |
my ($krbdef,$krbdefdom) = &Apache::loncommon::get_kerberos_defaults($dom); |
$krbdefdom= uc($krbdefdom); |
my %param = ( formname => $formname, |
my %param = ( formname => 'document.cu', |
|
kerb_def_dom => $krbdefdom, |
kerb_def_dom => $krbdefdom, |
|
kerb_def_auth => $krbdef, |
domain => $dom, |
domain => $dom, |
); |
); |
my %abv_auth = &auth_abbrev(); |
my %abv_auth = &auth_abbrev(); |
if ($curr_authtype =~ /^(krb4|krb5|internal|localauth|unix):$/) { |
if ($curr_authtype =~ /^(krb4|krb5|internal|localauth|unix):(.*)$/) { |
my $long_auth = $1; |
my $long_auth = $1; |
|
my $curr_autharg = $2; |
my %abv_auth = &auth_abbrev(); |
my %abv_auth = &auth_abbrev(); |
$param{'curr_authtype'} = $abv_auth{$long_auth}; |
$param{'curr_authtype'} = $abv_auth{$long_auth}; |
if ($long_auth =~ /^krb(4|5)$/) { |
if ($long_auth =~ /^krb(4|5)$/) { |
$param{'curr_kerb_ver'} = $1; |
$param{'curr_kerb_ver'} = $1; |
|
$param{'curr_autharg'} = $curr_autharg; |
} |
} |
if ($mode eq 'modifyuser') { |
if ($mode eq 'modifyuser') { |
$param{'mode'} = $mode; |
$param{'mode'} = $mode; |
} |
} |
} |
} |
# no longer static due to configurable kerberos defaults |
$loginscript = &Apache::loncommon::authform_header(%param); |
# $loginscript = &Apache::loncommon::authform_header(%param); |
$authformkrb = &Apache::loncommon::authform_kerberos(%param); |
$authformnop = &Apache::loncommon::authform_nochange(%param); |
$authformnop = &Apache::loncommon::authform_nochange(%param); |
# no longer static due to configurable kerberos defaults |
|
# $authformkrb = &Apache::loncommon::authform_kerberos(%param); |
|
$authformint = &Apache::loncommon::authform_internal(%param); |
$authformint = &Apache::loncommon::authform_internal(%param); |
$authformfsys = &Apache::loncommon::authform_filesystem(%param); |
$authformfsys = &Apache::loncommon::authform_filesystem(%param); |
$authformloc = &Apache::loncommon::authform_local(%param); |
$authformloc = &Apache::loncommon::authform_local(%param); |
Line 233 sub print_username_entry_form {
|
Line 233 sub print_username_entry_form {
|
text=>"Single user search", |
text=>"Single user search", |
faq=>282,bug=>'Instructor Interface',}); |
faq=>282,bug=>'Instructor Interface',}); |
} |
} |
my $crumbs = &Apache::lonhtmlcommon::breadcrumbs('User Management'); |
my $helpitem = 'Course_Change_Privileges'; |
|
if ($env{'form.action'} eq 'custom') { |
|
$helpitem = 'Course_Editing_Custom_Roles'; |
|
} elsif ($env{'form.action'} eq 'singlestudent') { |
|
$helpitem = 'Course_Add_Student'; |
|
} |
|
my $crumbs = &Apache::lonhtmlcommon::breadcrumbs('User Management', |
|
$helpitem); |
my %existingroles=&Apache::lonuserutils::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)); |
Line 249 sub print_username_entry_form {
|
Line 256 sub print_username_entry_form {
|
'enrl' => "to enroll one student", |
'enrl' => "to enroll one student", |
); |
); |
my $help = &Apache::loncommon::help_open_menu(undef,undef,282,'Instructor Interface'); |
my $help = &Apache::loncommon::help_open_menu(undef,undef,282,'Instructor Interface'); |
my $helpsiur=&Apache::loncommon::help_open_topic('Course_Change_Privileges'); |
|
my $helpsist=&Apache::loncommon::help_open_topic('Course_Add_Student'); |
|
my $helpecpr=&Apache::loncommon::help_open_topic('Course_Editing_Custom_Roles'); |
|
my $sellink=&Apache::loncommon::selectstudent_link('crtuser','srchterm','srchdomain'); |
my $sellink=&Apache::loncommon::selectstudent_link('crtuser','srchterm','srchdomain'); |
if ($sellink) { |
if ($sellink) { |
$sellink = "$lt{'or'} ".$sellink; |
$sellink = "$lt{'or'} ".$sellink; |
Line 263 sub print_username_entry_form {
|
Line 267 sub print_username_entry_form {
|
<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="action" value="$env{'form.action'}" /> |
<input type="hidden" name="phase" value="selected_custom_edit" /> |
<input type="hidden" name="phase" value="selected_custom_edit" /> |
<h3>$lt{'ecrp'}$helpecpr</h3> |
<h3>$lt{'ecrp'}</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 |
} |
} |
} else { |
} else { |
my $actiontext = $lt{'mod'}.$helpsiur; |
my $actiontext = $lt{'mod'}; |
if ($env{'form.action'} eq 'singlestudent') { |
if ($env{'form.action'} eq 'singlestudent') { |
$actiontext = $lt{'enrl'}.$helpsist; |
$actiontext = $lt{'enrl'}; |
} |
} |
$r->print(" |
$r->print(" |
<h3>$lt{'srch'} $sellink $actiontext</h3>"); |
<h3>$lt{'srch'} $sellink $actiontext</h3>"); |
Line 316 ENDBLOCK
|
Line 320 ENDBLOCK
|
if ($cancreate && $env{'form.phase'} eq '') { |
if ($cancreate && $env{'form.phase'} eq '') { |
my $defdom=$env{'request.role.domain'}; |
my $defdom=$env{'request.role.domain'}; |
my $domform = &Apache::loncommon::select_dom_form($defdom,'srchdomain'); |
my $domform = &Apache::loncommon::select_dom_form($defdom,'srchdomain'); |
my $helpcrt=&Apache::loncommon::help_open_topic('Course_Change_Privileges'); |
|
my %lt=&Apache::lonlocal::texthash( |
my %lt=&Apache::lonlocal::texthash( |
'crnu' => 'Create a new user', |
'crnu' => 'Create a new user', |
'usr' => 'Username', |
'usr' => 'Username', |
Line 332 ENDBLOCK
|
Line 335 ENDBLOCK
|
<input type="hidden" name="srchin" value="dom" /> |
<input type="hidden" name="srchin" value="dom" /> |
<input type="hidden" name="forcenewuser" value="1" /> |
<input type="hidden" name="forcenewuser" value="1" /> |
<input type="hidden" name="origform" value="crtusername" /> |
<input type="hidden" name="origform" value="crtusername" /> |
<h3>$lt{crnu}$helpcrt</h3> |
<h3>$lt{crnu}</h3> |
$responsemsg |
$responsemsg |
<table> |
<table> |
<tr> |
<tr> |
Line 420 ENDSCRIPT
|
Line 423 ENDSCRIPT
|
{href=>"javascript:backPage(document.usersrchform,'get_user_info','select')", |
{href=>"javascript:backPage(document.usersrchform,'get_user_info','select')", |
text=>"Select User", |
text=>"Select User", |
faq=>282,bug=>'Instructor Interface',}); |
faq=>282,bug=>'Instructor Interface',}); |
$r->print(&Apache::lonhtmlcommon::breadcrumbs('User Management')); |
$r->print(&Apache::lonhtmlcommon::breadcrumbs('User Management', |
|
'Course_Change_Privileges')); |
$r->print("<b>$lt{'usrch'}</b><br />"); |
$r->print("<b>$lt{'usrch'}</b><br />"); |
$r->print(&entry_form($srch->{'srchdomain'},$srch,undef,$context)); |
$r->print(&entry_form($srch->{'srchdomain'},$srch,undef,$context)); |
$r->print('<h3>'.$lt{'usel'}.'</h3>'); |
$r->print('<h3>'.$lt{'usel'}.'</h3>'); |
Line 432 ENDSCRIPT
|
Line 436 ENDSCRIPT
|
{href=>"javascript:backPage(document.usersrchform,'get_user_info','select')", |
{href=>"javascript:backPage(document.usersrchform,'get_user_info','select')", |
text=>"Select Student", |
text=>"Select Student", |
faq=>282,bug=>'Instructor Interface',}); |
faq=>282,bug=>'Instructor Interface',}); |
$r->print(&Apache::lonhtmlcommon::breadcrumbs('User Management')); |
$r->print(&Apache::lonhtmlcommon::breadcrumbs('User Management', |
|
'Course_Add_Student')); |
$r->print($jscript."<b>$lt{'stusrch'}</b><br />"); |
$r->print($jscript."<b>$lt{'stusrch'}</b><br />"); |
$r->print(&entry_form($srch->{'srchdomain'},$srch,undef,$context)); |
$r->print(&entry_form($srch->{'srchdomain'},$srch,undef,$context)); |
$r->print('</form><h3>'.$lt{'stusel'}.'</h3>'); |
$r->print('</form><h3>'.$lt{'stusel'}.'</h3>'); |
Line 509 sub print_user_modification_page {
|
Line 514 sub print_user_modification_page {
|
$formname = 'cu'; |
$formname = 'cu'; |
} |
} |
my %abv_auth = &auth_abbrev(); |
my %abv_auth = &auth_abbrev(); |
my ($curr_authtype,%rulematch,%inst_results,$curr_kerb_ver,$newuser, |
my (%rulematch,%inst_results,$newuser,%alerts,%curr_rules,%got_rules); |
%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') { |
my $usertype; |
my $usertype; |
Line 565 sub print_user_modification_page {
|
Line 569 sub print_user_modification_page {
|
} |
} |
} else { |
} else { |
$newuser = 0; |
$newuser = 0; |
my $currentauth = |
|
&Apache::lonnet::queryauthenticate($ccuname,$ccdomain); |
|
if ($currentauth =~ /^(krb4|krb5|unix|internal|localauth):/) { |
|
$curr_authtype = $abv_auth{$1}; |
|
if ($currentauth =~ /^krb(4|5)/) { |
|
$curr_kerb_ver = $1; |
|
} |
|
} |
|
} |
} |
if ($response) { |
if ($response) { |
$response = '<br />'.$response; |
$response = '<br />'.$response; |
} |
} |
my $defdom=$env{'request.role.domain'}; |
|
|
|
my ($krbdef,$krbdefdom) = |
|
&Apache::loncommon::get_kerberos_defaults($defdom); |
|
|
|
my %param = ( formname => 'document.cu', |
|
kerb_def_dom => $krbdefdom, |
|
kerb_def_auth => $krbdef, |
|
curr_authtype => $curr_authtype, |
|
curr_kerb_ver => $curr_kerb_ver, |
|
domain => $ccdomain, |
|
); |
|
$loginscript = &Apache::loncommon::authform_header(%param); |
|
$authformkrb = &Apache::loncommon::authform_kerberos(%param); |
|
|
|
my $pjump_def = &Apache::lonhtmlcommon::pjump_javascript_definition(); |
my $pjump_def = &Apache::lonhtmlcommon::pjump_javascript_definition(); |
my $dc_setcourse_code = ''; |
my $dc_setcourse_code = ''; |
Line 620 sub print_user_modification_page {
|
Line 602 sub print_user_modification_page {
|
({href=>"javascript:backPage($form,'$env{'form.phase'}','modify')", |
({href=>"javascript:backPage($form,'$env{'form.phase'}','modify')", |
text=>$breadcrumb_text{'modify'}, |
text=>$breadcrumb_text{'modify'}, |
faq=>282,bug=>'Instructor Interface',}); |
faq=>282,bug=>'Instructor Interface',}); |
my $crumbs = &Apache::lonhtmlcommon::breadcrumbs('User Management'); |
my $helpitem = 'Course_Change_Privileges'; |
|
if ($env{'form.action'} eq 'singlestudent') { |
|
$helpitem = 'Course_Add_Student'; |
|
} |
|
my $crumbs = &Apache::lonhtmlcommon::breadcrumbs('User Management', |
|
$helpitem); |
|
|
my $forminfo =<<"ENDFORMINFO"; |
my $forminfo =<<"ENDFORMINFO"; |
<form action="/adm/createuser" method="post" name="$formname"> |
<form action="/adm/createuser" method="post" name="$formname"> |
Line 643 ENDFORMINFO
|
Line 630 ENDFORMINFO
|
# Current user has quota modification privileges |
# Current user has quota modification privileges |
$portfolioform = '<br />'.&portfolio_quota($ccuname,$ccdomain); |
$portfolioform = '<br />'.&portfolio_quota($ccuname,$ccdomain); |
} |
} |
&initialize_authen_forms($ccdomain); |
&initialize_authen_forms($ccdomain,$formname); |
my %lt=&Apache::lonlocal::texthash( |
my %lt=&Apache::lonlocal::texthash( |
'cnu' => 'Create New User', |
'cnu' => 'Create New User', |
'ast' => 'as a student', |
'ast' => 'as a student', |
Line 764 ENDCHANGEUSER
|
Line 751 ENDCHANGEUSER
|
$r->print(&Apache::lonuserutils::forceid_change($context)); |
$r->print(&Apache::lonuserutils::forceid_change($context)); |
} |
} |
$r->print('</div>'); |
$r->print('</div>'); |
my $user_auth_text = |
my $user_auth_text = &user_authentication($ccuname,$ccdomain,$formname); |
&user_authentication($ccuname,$ccdomain,$krbdefdom,\%abv_auth); |
|
my $user_quota_text; |
my $user_quota_text; |
if (&Apache::lonnet::allowed('mpq',$ccdomain)) { |
if (&Apache::lonnet::allowed('mpq',$ccdomain)) { |
# Current user has quota modification privileges |
# Current user has quota modification privileges |
Line 829 ENDNOPORTPRIV
|
Line 815 ENDNOPORTPRIV
|
if ($addrolesdisplay) { |
if ($addrolesdisplay) { |
$r->print('<br /><input type="button" value="'.&mt('Modify User').'"'); |
$r->print('<br /><input type="button" value="'.&mt('Modify User').'"'); |
if ($newuser) { |
if ($newuser) { |
$r->print(' onClick="verify_message(this.form)" \>'."\n"); |
$r->print(' onClick="auth_check()" \>'."\n"); |
} else { |
} else { |
$r->print('onClick="this.form.submit()" \>'."\n"); |
$r->print('onClick="this.form.submit()" \>'."\n"); |
} |
} |
Line 886 sub validation_javascript {
|
Line 872 sub validation_javascript {
|
if ($context eq 'domain') { |
if ($context eq 'domain') { |
my $dcdom = $env{'request.role.domain'}; |
my $dcdom = $env{'request.role.domain'}; |
$loaditem->{'onload'} = "document.cu.coursedesc.value='';"; |
$loaditem->{'onload'} = "document.cu.coursedesc.value='';"; |
$dc_setcourse_code = &Apache::lonuserutils::dc_setcourse_js('cu','singleuser'); |
$dc_setcourse_code = |
|
&Apache::lonuserutils::dc_setcourse_js('cu','singleuser',$context); |
} else { |
} else { |
$nondc_setsection_code = |
my $checkauth; |
&Apache::lonuserutils::setsections_javascript($formname,$groupslist); |
if (($newuser) || (&Apache::lonnet::allowed('mau',$ccdomain))) { |
|
$checkauth = 1; |
|
} |
|
if ($context eq 'course') { |
|
$nondc_setsection_code = |
|
&Apache::lonuserutils::setsections_javascript($formname,$groupslist, |
|
undef,$checkauth); |
|
} |
|
if ($checkauth) { |
|
$nondc_setsection_code .= |
|
&Apache::lonuserutils::verify_authen($formname,$context); |
|
} |
} |
} |
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)) || ($newuser)) { |
|
my ($krbdef,$krbdefdom) = |
|
&Apache::loncommon::get_kerberos_defaults($ccdomain); |
|
$javascript_validations = |
|
&Apache::lonuserutils::javascript_validations('createuser',$krbdefdom,undef, |
|
undef,$ccdomain); |
|
} |
|
$js .= "\n". |
$js .= "\n". |
'<script type="text/javascript">'."\n".$jsback."\n". |
'<script type="text/javascript">'."\n".$jsback."\n".'</script>'; |
$javascript_validations.'</script>'; |
|
return $js; |
return $js; |
} |
} |
|
|
Line 1230 sub new_domain_roles {
|
Line 1218 sub new_domain_roles {
|
} |
} |
|
|
sub user_authentication { |
sub user_authentication { |
my ($ccuname,$ccdomain,$krbdefdom,$abv_auth) = @_; |
my ($ccuname,$ccdomain,$formname) = @_; |
my $currentauth=&Apache::lonnet::queryauthenticate($ccuname,$ccdomain); |
my $currentauth=&Apache::lonnet::queryauthenticate($ccuname,$ccdomain); |
my ($loginscript,$outcome); |
my $outcome; |
if ($currentauth=~/^(krb)(4|5):(.*)/) { |
|
my $long_auth = $1.$2; |
|
my $curr_kerb_ver = $2; |
|
my $krbdefdom=$3; |
|
my $curr_authtype = $abv_auth->{$long_auth}; |
|
my %param = ( formname => 'document.cu', |
|
kerb_def_dom => $krbdefdom, |
|
domain => $ccdomain, |
|
curr_authtype => $curr_authtype, |
|
curr_kerb_ver => $curr_kerb_ver, |
|
); |
|
$loginscript = &Apache::loncommon::authform_header(%param); |
|
} |
|
# Check for a bad authentication type |
# Check for a bad authentication type |
if ($currentauth !~ /^(krb4|krb5|unix|internal|localauth):/) { |
if ($currentauth !~ /^(krb4|krb5|unix|internal|localauth):/) { |
# bad authentication scheme |
# bad authentication scheme |
Line 1257 sub user_authentication {
|
Line 1232 sub user_authentication {
|
'ld' => "Login Data" |
'ld' => "Login Data" |
); |
); |
if (&Apache::lonnet::allowed('mau',$ccdomain)) { |
if (&Apache::lonnet::allowed('mau',$ccdomain)) { |
&initialize_authen_forms($ccdomain); |
&initialize_authen_forms($ccdomain,$formname); |
|
|
my $choices = &Apache::lonuserutils::set_login($ccdomain,$authformkrb,$authformint,$authformloc); |
my $choices = &Apache::lonuserutils::set_login($ccdomain,$authformkrb,$authformint,$authformloc); |
$outcome = <<ENDBADAUTH; |
$outcome = <<ENDBADAUTH; |
<script type="text/javascript" language="Javascript"> |
<script type="text/javascript" language="Javascript"> |
Line 1278 $lt{'uuas'} ($currentauth). $lt{'adcs'}.
|
Line 1254 $lt{'uuas'} ($currentauth). $lt{'adcs'}.
|
ENDBADAUTH |
ENDBADAUTH |
} |
} |
} else { # Authentication type is valid |
} else { # Authentication type is valid |
&initialize_authen_forms($ccdomain,$currentauth,'modifyuser'); |
&initialize_authen_forms($ccdomain,$formname,$currentauth,'modifyuser'); |
my ($authformcurrent,$can_modify,@authform_others) = |
my ($authformcurrent,$can_modify,@authform_others) = |
&modify_login_block($ccdomain,$currentauth); |
&modify_login_block($ccdomain,$currentauth); |
if (&Apache::lonnet::allowed('mau',$ccdomain)) { |
if (&Apache::lonnet::allowed('mau',$ccdomain)) { |
Line 1397 sub modify_login_block {
|
Line 1373 sub modify_login_block {
|
|
|
sub personal_data_display { |
sub personal_data_display { |
my ($ccuname,$ccdomain,$newuser,$context,$inst_results) = @_; |
my ($ccuname,$ccdomain,$newuser,$context,$inst_results) = @_; |
my ($output,$showforceid,%userenv,%domconfig); |
my ($output,$showforceid,%userenv,%canmodify); |
|
my @userinfo = ('firstname','middlename','lastname','generation', |
|
'permanentemail','id'); |
if (!$newuser) { |
if (!$newuser) { |
# Get the users information |
# Get the users information |
%userenv = &Apache::lonnet::get('environment', |
%userenv = &Apache::lonnet::get('environment', |
['firstname','middlename','lastname','generation', |
['firstname','middlename','lastname','generation', |
'permanentemail','id'],$ccdomain,$ccuname); |
'permanentemail','id'],$ccdomain,$ccuname); |
%domconfig = |
%canmodify = |
&Apache::lonnet::get_dom('configuration',['usermodification'], |
&Apache::lonuserutils::can_modify_userinfo($context,$ccdomain, |
$ccdomain); |
\@userinfo); |
} |
} |
my %lt=&Apache::lonlocal::texthash( |
my %lt=&Apache::lonlocal::texthash( |
'pd' => "Personal Data", |
'pd' => "Personal Data", |
Line 1417 sub personal_data_display {
|
Line 1395 sub personal_data_display {
|
'id' => "ID/Student Number", |
'id' => "ID/Student Number", |
'lg' => "Login Data" |
'lg' => "Login Data" |
); |
); |
my @userinfo = ('firstname','middlename','lastname','generation', |
|
'permanentemail','id'); |
|
my %textboxsize = ( |
my %textboxsize = ( |
firstname => '15', |
firstname => '15', |
middlename => '15', |
middlename => '15', |
Line 1447 sub personal_data_display {
|
Line 1423 sub personal_data_display {
|
$output .= '<input type="text" name="c'.$item.'" size="'.$textboxsize{$item}.'" value="" />'; |
$output .= '<input type="text" name="c'.$item.'" size="'.$textboxsize{$item}.'" value="" />'; |
} |
} |
} else { |
} else { |
my $canmodify = 0; |
if ($canmodify{$item}) { |
if (&Apache::lonnet::allowed('mau',$ccdomain)) { |
|
$canmodify = 1; |
|
} else { |
|
if (ref($domconfig{'usermodification'}) eq 'HASH') { |
|
if (ref($domconfig{'usermodification'}{$context}) eq 'HASH') { |
|
foreach my $key (keys(%{$domconfig{'usermodification'}{$context}})) { |
|
if (ref($domconfig{'usermodification'}{$context}{$key}) eq 'HASH') { |
|
if ($domconfig{'usermodification'}{$context}{$key}{$item}) { |
|
$canmodify = 1; |
|
last; |
|
} |
|
} |
|
} |
|
} |
|
} elsif ($context eq 'course') { |
|
$canmodify = 1; |
|
} |
|
} |
|
if ($canmodify) { |
|
$output .= '<input type="text" name="c'.$item.'" size="'.$textboxsize{$item}.'" value="'.$userenv{$item}.'" />'; |
$output .= '<input type="text" name="c'.$item.'" size="'.$textboxsize{$item}.'" value="'.$userenv{$item}.'" />'; |
} else { |
} else { |
$output .= $userenv{$item}; |
$output .= $userenv{$item}; |
} |
} |
if ($item eq 'id') { |
if ($item eq 'id') { |
$showforceid = $canmodify; |
$showforceid = $canmodify{$item}; |
} |
} |
} |
} |
$output .= &Apache::lonhtmlcommon::row_closure(1); |
$output .= &Apache::lonhtmlcommon::row_closure(1); |
} |
} |
Line 1495 sub update_user_data {
|
Line 1452 sub update_user_data {
|
my $end = '</span><br /><br />'; |
my $end = '</span><br /><br />'; |
my $rtnlink = '<a href="javascript:backPage(document.userupdate,'. |
my $rtnlink = '<a href="javascript:backPage(document.userupdate,'. |
"'$env{'form.prevphase'}','modify')".'" />'. |
"'$env{'form.prevphase'}','modify')".'" />'. |
&mt('Return to previous page').'</a>'.&Apache::loncommon::end_page(); |
&mt('Return to previous page').'</a>'. |
|
&Apache::loncommon::end_page(); |
|
my $now = time; |
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 1520 sub update_user_data {
|
Line 1479 sub update_user_data {
|
} |
} |
&Apache::lonhtmlcommon::add_breadcrumb |
&Apache::lonhtmlcommon::add_breadcrumb |
({href=>"javascript:backPage(document.userupdate,'$env{'form.prevphase'}','modify')", |
({href=>"javascript:backPage(document.userupdate,'$env{'form.prevphase'}','modify')", |
text=>"Set user role", |
text=>$breadcrumb_text{'modify'}, |
faq=>282,bug=>'Instructor Interface',}, |
faq=>282,bug=>'Instructor Interface',}, |
{href=>"/adm/createuser", |
{href=>"/adm/createuser", |
text=>"Result", |
text=>"Result", |
faq=>282,bug=>'Instructor Interface',}); |
faq=>282,bug=>'Instructor Interface',}); |
$r->print(&Apache::lonhtmlcommon::breadcrumbs('User Management')); |
my $helpitem = 'Course_Change_Privileges'; |
|
if ($env{'form.action'} eq 'singlestudent') { |
my %disallowed; |
$helpitem = 'Course_Add_Student'; |
|
} |
|
$r->print(&Apache::lonhtmlcommon::breadcrumbs('User Management', |
|
$helpitem)); |
$r->print(&update_result_form($uhome)); |
$r->print(&update_result_form($uhome)); |
# Check Inputs |
# Check Inputs |
if (! $env{'form.ccuname'} ) { |
if (! $env{'form.ccuname'} ) { |
Line 1552 sub update_user_data {
|
Line 1514 sub update_user_data {
|
$end.$rtnlink); |
$end.$rtnlink); |
return; |
return; |
} |
} |
|
if ($uhome eq 'no_host') { |
|
$newuser = 1; |
|
} |
if (! exists($env{'form.makeuser'})) { |
if (! exists($env{'form.makeuser'})) { |
# Modifying an existing user, so check the validity of the name |
# Modifying an existing user, so check the validity of the name |
if ($uhome eq 'no_host') { |
if ($uhome eq 'no_host') { |
Line 1589 sub update_user_data {
|
Line 1554 sub update_user_data {
|
return; |
return; |
} |
} |
|
|
|
|
$r->print('<h3>'.&mt('User [_1] in domain [_2]', |
$r->print('<h3>'.&mt('User [_1] in domain [_2]', |
$env{'form.ccuname'}, $env{'form.ccdomain'}).'</h3>'); |
$env{'form.ccuname'}, $env{'form.ccdomain'}).'</h3>'); |
my (%alerts,%rulematch,%inst_results,%curr_rules); |
my (%alerts,%rulematch,%inst_results,%curr_rules); |
Line 1616 sub update_user_data {
|
Line 1580 sub update_user_data {
|
my %checkhash; |
my %checkhash; |
my %checks = ('id' => 1); |
my %checks = ('id' => 1); |
%{$checkhash{$env{'form.ccuname'}.':'.$env{'form.ccdomain'}}} = ( |
%{$checkhash{$env{'form.ccuname'}.':'.$env{'form.ccdomain'}}} = ( |
'newuser' => 1, |
'newuser' => $newuser, |
'id' => $env{'form.cid'}, |
'id' => $env{'form.cid'}, |
); |
); |
if ($env{'form.cid'} ne '') { |
if ($env{'form.cid'} ne '') { |
Line 1650 sub update_user_data {
|
Line 1614 sub update_user_data {
|
$env{'form.cgeneration'},undef,$desiredhost, |
$env{'form.cgeneration'},undef,$desiredhost, |
$env{'form.cpermanentemail'}); |
$env{'form.cpermanentemail'}); |
$r->print(&mt('Generating user').': '.$result); |
$r->print(&mt('Generating user').': '.$result); |
my $home = &Apache::lonnet::homeserver($env{'form.ccuname'}, |
$uhome = &Apache::lonnet::homeserver($env{'form.ccuname'}, |
$env{'form.ccdomain'}); |
$env{'form.ccdomain'}); |
$r->print('<br />'.&mt('Home server').': '.$home.' '. |
$r->print('<br />'.&mt('Home server').': '.$uhome.' '. |
&Apache::lonnet::hostname($home)); |
&Apache::lonnet::hostname($uhome)); |
} elsif (($env{'form.login'} ne 'nochange') && |
} elsif (($env{'form.login'} ne 'nochange') && |
($env{'form.login'} ne '' )) { |
($env{'form.login'} ne '' )) { |
# Modify user privileges |
# Modify user privileges |
Line 1697 sub update_user_data {
|
Line 1661 sub update_user_data {
|
my @statuses = ('active','future'); |
my @statuses = ('active','future'); |
my %roles = &Apache::lonnet::get_my_roles($env{'form.ccuname'},$env{'form.ccdomain'},'userroles',\@statuses,undef,$env{'request.role.domain'}); |
my %roles = &Apache::lonnet::get_my_roles($env{'form.ccuname'},$env{'form.ccdomain'},'userroles',\@statuses,undef,$env{'request.role.domain'}); |
my ($auname,$audom); |
my ($auname,$audom); |
if ($context eq 'course') { |
if ($context eq 'author') { |
$cnum = $env{'course.'.$env{'request.course.id'}.'.num'}; |
|
$cdom = $env{'course.'.$env{'request.course.id'}.'.domain'}; |
|
if ($cnum eq '' || $cdom eq '') { |
|
my $cid = $env{'request.course.id'}; |
|
my %coursehash = |
|
&Apache::lonnet::coursedescription($cid,{'one_time' => 1}); |
|
$cdom = $coursehash{'domain'}; |
|
$cnum = $coursehash{'num'}; |
|
} |
|
} elsif ($context eq 'author') { |
|
$auname = $env{'user.name'}; |
$auname = $env{'user.name'}; |
$audom = $env{'user.domain'}; |
$audom = $env{'user.domain'}; |
} |
} |
foreach my $item (keys(%roles)) { |
foreach my $item (keys(%roles)) { |
my ($rolenum,$roledom,$role) = split(/:/,$item); |
my ($rolenum,$roledom,$role) = split(/:/,$item,-1); |
if ($context eq 'course') { |
if ($context eq 'course') { |
if ($cnum ne '' && $cdom ne '') { |
if ($cnum ne '' && $cdom ne '') { |
if ($rolenum eq $cnum && $roledom eq $cdom) { |
if ($rolenum eq $cnum && $roledom eq $cdom) { |
Line 1729 sub update_user_data {
|
Line 1683 sub update_user_data {
|
} |
} |
} |
} |
} |
} |
# Check for course or co-author roles being activated or re-enabled |
if ($env{'form.action'} eq 'singlestudent') { |
if ($context eq 'author' || $context eq 'course') { |
if (!grep(/^st$/,@userroles)) { |
foreach my $key (keys(%env)) { |
push(@userroles,'st'); |
if ($context eq 'author') { |
} |
if ($key=~/^form\.act_\Q$audom\E_\Q$auname\E_([^_]+)/) { |
} else { |
if (!grep(/^\Q$1\E$/,@userroles)) { |
# Check for course or co-author roles being activated or re-enabled |
push(@userroles,$1); |
if ($context eq 'author' || $context eq 'course') { |
} |
foreach my $key (keys(%env)) { |
} elsif ($key =~/^form\.ren\:\Q$audom\E\/\Q$auname\E_([^_]+)/) { |
if ($context eq 'author') { |
if (!grep(/^\Q$1\E$/,@userroles)) { |
if ($key=~/^form\.act_\Q$audom\E_\Q$auname\E_([^_]+)/) { |
push(@userroles,$1); |
if (!grep(/^\Q$1\E$/,@userroles)) { |
} |
push(@userroles,$1); |
} |
} |
} elsif ($context eq 'course') { |
} elsif ($key =~/^form\.ren\:\Q$audom\E\/\Q$auname\E_([^_]+)/) { |
if ($key=~/^form\.act_\Q$cdom\E_\Q$cnum\E_([^_]+)/) { |
if (!grep(/^\Q$1\E$/,@userroles)) { |
if (!grep(/^\Q$1\E$/,@userroles)) { |
push(@userroles,$1); |
push(@userroles,$1); |
} |
} |
} |
} elsif ($key =~/^form\.ren\:\Q$cdom\E\/\Q$cnum\E(\/?\w*)_([^_]+)/) { |
} elsif ($context eq 'course') { |
if (!grep(/^\Q$1\E$/,@userroles)) { |
if ($key=~/^form\.act_\Q$cdom\E_\Q$cnum\E_([^_]+)/) { |
push(@userroles,$1); |
if (!grep(/^\Q$1\E$/,@userroles)) { |
|
push(@userroles,$1); |
|
} |
|
} elsif ($key =~/^form\.ren\:\Q$cdom\E\/\Q$cnum\E(\/?\w*)_([^_]+)/) { |
|
if (!grep(/^\Q$1\E$/,@userroles)) { |
|
push(@userroles,$1); |
|
} |
} |
} |
} |
} |
} |
} |
Line 1764 sub update_user_data {
|
Line 1724 sub update_user_data {
|
push(@longroles,&Apache::lonnet::plaintext($role)); |
push(@longroles,&Apache::lonnet::plaintext($role)); |
} |
} |
} |
} |
foreach my $item ('firstname','middlename','lastname','generation','permanentemail','id') { |
my @userinfo = ('firstname','middlename','lastname','generation','permanentemail','id'); |
my $canmodify = 0; |
my %canmodify = &Apache::lonuserutils::can_modify_userinfo($context,$env{'form.ccdomain'},\@userinfo,\@userroles); |
if (&Apache::lonnet::allowed('mau',$env{'form.ccdomain'})) { |
foreach my $item (@userinfo) { |
$canmodify = 1; |
|
} else { |
|
if ($context eq 'course' || $context eq 'author') { |
|
if (ref($domconfig{'usermodification'}) eq 'HASH') { |
|
if (ref($domconfig{'usermodification'}{$context}) eq 'HASH') { |
|
foreach my $role (@userroles) { |
|
if (ref($domconfig{'usermodification'}{$context}{$role}) eq 'HASH') { |
|
if ($domconfig{'usermodification'}{$context}{$role}{$item}) { |
|
$canmodify = 1; |
|
last; |
|
} |
|
} |
|
} |
|
} |
|
} |
|
} elsif ($context eq 'course') { |
|
if (grep(/^st$/,@userroles)) { |
|
$canmodify = 1; |
|
} |
|
} |
|
} |
|
# 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; |
if (!$canmodify) { |
if (!$canmodify{$item}) { |
if (defined($env{'form.c'.$item})) { |
if (defined($env{'form.c'.$item})) { |
if ($env{'form.c'.$item} ne $userenv{$item}) { |
if ($env{'form.c'.$item} ne $userenv{$item}) { |
push(@mod_disallowed,$item); |
push(@mod_disallowed,$item); |
Line 1802 sub update_user_data {
|
Line 1741 sub update_user_data {
|
# Check to see if we can change the ID/student number |
# Check to see if we can change the ID/student number |
my $forceid = $env{'form.forceid'}; |
my $forceid = $env{'form.forceid'}; |
my $recurseid = $env{'form.recurseid'}; |
my $recurseid = $env{'form.recurseid'}; |
my $newuser = 0; |
|
my (%alerts,%rulematch,%idinst_results,%curr_rules,%got_rules); |
my (%alerts,%rulematch,%idinst_results,%curr_rules,%got_rules); |
my %uidhash = &Apache::lonnet::idrget($env{'form.ccdomain'}, |
my %uidhash = &Apache::lonnet::idrget($env{'form.ccdomain'}, |
$env{'form.ccuname'}); |
$env{'form.ccuname'}); |
Line 1834 sub update_user_data {
|
Line 1772 sub update_user_data {
|
$newdefquotatext); |
$newdefquotatext); |
my ($defquota,$settingstatus) = |
my ($defquota,$settingstatus) = |
&Apache::loncommon::default_quota($env{'form.ccdomain'},$inststatus); |
&Apache::loncommon::default_quota($env{'form.ccdomain'},$inststatus); |
|
my $showquota; |
|
if (&Apache::lonnet::allowed('mpq',$env{'form.ccdomain'})) { |
|
$showquota = 1; |
|
} |
my %changeHash; |
my %changeHash; |
$changeHash{'portfolioquota'} = $userenv{'portfolioquota'}; |
$changeHash{'portfolioquota'} = $userenv{'portfolioquota'}; |
if ($userenv{'portfolioquota'} ne '') { |
if ($userenv{'portfolioquota'} ne '') { |
Line 1904 sub update_user_data {
|
Line 1846 sub update_user_data {
|
$changeHash{'firstname'},$changeHash{'middlename'}, |
$changeHash{'firstname'},$changeHash{'middlename'}, |
$changeHash{'lastname'},$changeHash{'generation'}, |
$changeHash{'lastname'},$changeHash{'generation'}, |
$changeHash{'id'},undef,$changeHash{'permanentemail'}); |
$changeHash{'id'},undef,$changeHash{'permanentemail'}); |
|
%userupdate = ( |
|
lastname => $env{'form.clastname'}, |
|
middlename => $env{'form.cmiddlename'}, |
|
firstname => $env{'form.cfirstname'}, |
|
generation => $env{'form.cgeneration'}, |
|
id => $env{'form.cid'}, |
|
); |
} |
} |
if (($namechanged && $namechgresult eq 'ok') || |
if (($namechanged && $namechgresult eq 'ok') || |
($quotachanged && $quotachgresult eq 'ok')) { |
($quotachanged && $quotachgresult eq 'ok')) { |
Line 1931 sub update_user_data {
|
Line 1880 sub update_user_data {
|
<th>$lt{'gen'}</th> |
<th>$lt{'gen'}</th> |
<th>$lt{'id'}</th> |
<th>$lt{'id'}</th> |
<th>$lt{'mail'}</th> |
<th>$lt{'mail'}</th> |
<th>$lt{'disk'}</th> |
|
END |
END |
|
if ($showquota) { |
|
$r->print(" |
|
<th>$lt{'disk'}</th>\n"); |
|
} |
$r->print(&Apache::loncommon::end_data_table_header_row(). |
$r->print(&Apache::loncommon::end_data_table_header_row(). |
&Apache::loncommon::start_data_table_row()); |
&Apache::loncommon::start_data_table_row()); |
$r->print(<<"END"); |
$r->print(<<"END"); |
Line 1943 END
|
Line 1895 END
|
<td>$userenv{'generation'} </td> |
<td>$userenv{'generation'} </td> |
<td>$userenv{'id'}</td> |
<td>$userenv{'id'}</td> |
<td>$userenv{'permanentemail'} </td> |
<td>$userenv{'permanentemail'} </td> |
<td>$oldportfolioquota Mb $olddefquotatext </td> |
|
END |
END |
|
if ($showquota) { |
|
$r->print(" |
|
<td>$oldportfolioquota Mb $olddefquotatext </td>\n"); |
|
} |
$r->print(&Apache::loncommon::end_data_table_row(). |
$r->print(&Apache::loncommon::end_data_table_row(). |
&Apache::loncommon::start_data_table_row()); |
&Apache::loncommon::start_data_table_row()); |
$r->print(<<"END"); |
$r->print(<<"END"); |
Line 1955 END
|
Line 1910 END
|
<td>$env{'form.cgeneration'} </td> |
<td>$env{'form.cgeneration'} </td> |
<td>$env{'form.cid'} </td> |
<td>$env{'form.cid'} </td> |
<td>$env{'form.cpermanentemail'} </td> |
<td>$env{'form.cpermanentemail'} </td> |
<td>$newportfolioquota Mb $newdefquotatext </td> |
|
END |
END |
|
if ($showquota) { |
|
$r->print(" |
|
<td>$newportfolioquota Mb $newdefquotatext </td>\n"); |
|
} |
$r->print(&Apache::loncommon::end_data_table_row(). |
$r->print(&Apache::loncommon::end_data_table_row(). |
&Apache::loncommon::end_data_table().'<br />'); |
&Apache::loncommon::end_data_table().'<br />'); |
if ($env{'form.cid'} ne $userenv{'id'}) { |
if ($env{'form.cid'} ne $userenv{'id'}) { |
Line 1964 END
|
Line 1922 END
|
($env{'form.ccuname'} => $env{'form.cid'})); |
($env{'form.ccuname'} => $env{'form.cid'})); |
if (($recurseid) && |
if (($recurseid) && |
(&Apache::lonnet::allowed('mau',$env{'form.ccdomain'}))) { |
(&Apache::lonnet::allowed('mau',$env{'form.ccdomain'}))) { |
%userupdate = ( |
|
lastname => $env{'form.clasaname'}, |
|
middlename => $env{'form.cmiddlename'}, |
|
firstname => $env{'form.cfirstname'}, |
|
generation => $env{'fora.cgeneration'}, |
|
id => $env{'form.cid'}, |
|
); |
|
my $idresult = |
my $idresult = |
&Apache::lonuserutils::propagate_id_change( |
&Apache::lonuserutils::propagate_id_change( |
$env{'form.ccuname'},$env{'form.ccdomain'}, |
$env{'form.ccuname'},$env{'form.ccdomain'}, |
Line 2006 END
|
Line 1957 END
|
$r->print('<br />['.$lt{'mail'}.': '. |
$r->print('<br />['.$lt{'mail'}.': '. |
$userenv{'permanentemail'}.']'); |
$userenv{'permanentemail'}.']'); |
} |
} |
$r->print('<br />['.$lt{'disk'}.': '.$oldportfolioquota.' Mb '. |
if ($showquota) { |
$olddefquotatext.']</h4>'); |
$r->print('<br />['.$lt{'disk'}.': '.$oldportfolioquota.' Mb '. |
|
$olddefquotatext.']'); |
|
} |
|
$r->print('</h4>'); |
} |
} |
if (@mod_disallowed) { |
if (@mod_disallowed) { |
my ($rolestr,$contextname); |
my ($rolestr,$contextname); |
Line 2038 END
|
Line 1992 END
|
$r->print($no_forceid_alert. |
$r->print($no_forceid_alert. |
&Apache::lonuserutils::print_namespacing_alerts($env{'form.ccdomain'},\%alerts, \%curr_rules)); |
&Apache::lonuserutils::print_namespacing_alerts($env{'form.ccdomain'},\%alerts, \%curr_rules)); |
} |
} |
## |
if ($env{'form.action'} eq 'singlestudent') { |
|
&enroll_single_student($r,$uhome,$amode,$genpwd,$now,$newuser); |
|
$r->print('<p><a href="javascript:backPage(document.userupdate)">'. &mt('Enroll Another Student').'</a></p>'); |
|
} else { |
|
my @rolechanges = &update_roles($r); |
|
if ($namechanged) { |
|
if ($context eq 'course') { |
|
if (@userroles > 0) { |
|
if ((@rolechanges == 0) || |
|
(!(grep(/^st$/,@rolechanges)))) { |
|
if (grep(/^st$/,@userroles)) { |
|
my $classlistupdated = |
|
&Apache::lonuserutils::update_classlist($cdom, |
|
$cnum,$env{'form.ccdomain'}, |
|
$env{'form.ccuname'},\%userupdate); |
|
} |
|
} |
|
} |
|
} |
|
} |
|
my $userinfo = &Apache::loncommon::plainname($env{'form.ccuname'}, |
|
$env{'form.ccdomain'}); |
|
$r->print('<p><a href="javascript:backPage(document.userupdate,'."'$env{'form.prevphase'}','modify'".')">'.&mt('Modify this user: <span class="LC_cusr_emph">([_1])</span>',$userinfo).'</a>'.(' 'x5).'<a href="javascript:backPage(document.userupdate)">'.&mt('Create/Modify Another User').'</a></p>'); |
|
} |
|
$r->print(&Apache::loncommon::end_page()); |
|
} |
|
|
|
sub update_roles { |
|
my ($r) = @_; |
my $now=time; |
my $now=time; |
my $rolechanges = 0; |
my @rolechanges; |
|
my %disallowed; |
$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}); |
Line 2063 END
|
Line 2046 END
|
$now); |
$now); |
$r->print($result); |
$r->print($result); |
} |
} |
|
if (!grep(/^\Q$role\E$/,@rolechanges)) { |
|
push(@rolechanges,$role); |
|
} |
} |
} |
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 |
Line 2071 END
|
Line 2057 END
|
&Apache::lonnet::revokecustomrole($env{'form.ccdomain'}, |
&Apache::lonnet::revokecustomrole($env{'form.ccdomain'}, |
$env{'form.ccuname'},$1,$2,$3,$4). |
$env{'form.ccuname'},$1,$2,$3,$4). |
'</b><br />'); |
'</b><br />'); |
|
if (!grep(/^cr$/,@rolechanges)) { |
|
push(@rolechanges,'cr'); |
|
} |
} |
} |
$rolechanges ++; |
|
} elsif ($key=~/^form\.del/) { |
} elsif ($key=~/^form\.del/) { |
if ($key=~/^form\.del\:([^\_]+)\_([^\_\.]+)$/) { |
if ($key=~/^form\.del\:([^\_]+)\_([^\_\.]+)$/) { |
# Delete standard role |
# Delete standard role |
Line 2090 END
|
Line 2078 END
|
$now); |
$now); |
$r->print($result); |
$r->print($result); |
} |
} |
|
if (!grep(/^\Q$role\E$/,@rolechanges)) { |
|
push(@rolechanges,$role); |
|
} |
} |
} |
if ($key=~m{^form\.del\:([^_]+)_cr\.cr/($match_domain)/($match_username)/(\w+)$}) { |
if ($key=~m{^form\.del\:([^_]+)_cr\.cr/($match_domain)/($match_username)/(\w+)$}) { |
my ($url,$rdom,$rnam,$rolename) = ($1,$2,$3,$4); |
my ($url,$rdom,$rnam,$rolename) = ($1,$2,$3,$4); |
Line 2099 END
|
Line 2090 END
|
&Apache::lonnet::assigncustomrole($env{'form.ccdomain'}, |
&Apache::lonnet::assigncustomrole($env{'form.ccdomain'}, |
$env{'form.ccuname'},$url,$rdom,$rnam,$rolename,$now, |
$env{'form.ccuname'},$url,$rdom,$rnam,$rolename,$now, |
0,1).'</b><br />'); |
0,1).'</b><br />'); |
|
if (!grep(/^cr$/,@rolechanges)) { |
|
push(@rolechanges,'cr'); |
|
} |
} |
} |
$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 2113 END
|
Line 2106 END
|
if ($role eq 'st') { |
if ($role eq 'st') { |
if ($url =~ m-^/($match_domain)/($match_courseid)/?(\w*)$-) { |
if ($url =~ m-^/($match_domain)/($match_courseid)/?(\w*)$-) { |
my $result = &Apache::loncommon::commit_studentrole(\$logmsg,$udom,$uname,$url,$role,$now,0,$1,$2,$3); |
my $result = &Apache::loncommon::commit_studentrole(\$logmsg,$udom,$uname,$url,$role,$now,0,$1,$2,$3); |
if (($result =~ /^error/) || ($result eq 'not_in_class') || ($result eq 'unknown_course')) { |
if (($result =~ /^error/) || ($result eq 'not_in_class') || ($result eq 'unknown_course') || ($result eq 'refused')) { |
$output = "Error: $result\n"; |
if ($result eq 'refused' && $logmsg) { |
|
$output = $logmsg; |
|
} else { |
|
$output = "Error: $result\n"; |
|
} |
} else { |
} else { |
$output = &mt('Assigning').' '.$role.' in '.$url. |
$output = &mt('Assigning').' '.$role.' in '.$url. |
&mt('starting').' '.localtime($now). |
&mt('starting').' '.localtime($now). |
Line 2129 END
|
Line 2126 END
|
$role,$url,$result).'<br />'; |
$role,$url,$result).'<br />'; |
} |
} |
$r->print($output); |
$r->print($output); |
|
if (!grep(/^\Q$role\E$/,@rolechanges)) { |
|
push(@rolechanges,$role); |
|
} |
} |
} |
# Re-enable custom role |
# Re-enable custom role |
if ($key=~m{^form\.ren\:([^_]+)_cr\.cr/($match_domain)/($match_username)/(\w+)$}) { |
if ($key=~m{^form\.ren\:([^_]+)_cr\.cr/($match_domain)/($match_username)/(\w+)$}) { |
Line 2138 END
|
Line 2138 END
|
$url,$rdom,$rnam,$rolename,0,$now); |
$url,$rdom,$rnam,$rolename,0,$now); |
$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 />'); |
|
if (!grep(/^cr$/,@rolechanges)) { |
|
push(@rolechanges,'cr'); |
|
} |
} |
} |
$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 2174 END
|
Line 2176 END
|
$r->print(&Apache::loncommon::commit_customrole($udom,$uname,$securl,$three,$four,$five,$start,$end)); |
$r->print(&Apache::loncommon::commit_customrole($udom,$uname,$securl,$three,$four,$five,$start,$end)); |
} |
} |
} |
} |
|
if (!grep(/^cr$/,@rolechanges)) { |
|
push(@rolechanges,'cr'); |
|
} |
} elsif ($key=~/^form\.act\_($match_domain)\_($match_name)\_([^\_]+)$/) { |
} elsif ($key=~/^form\.act\_($match_domain)\_($match_name)\_([^\_]+)$/) { |
# Activate roles for sections with 3 id numbers |
# Activate roles for sections with 3 id numbers |
# set start, end times, and the url for the class |
# set start, end times, and the url for the class |
Line 2212 END
|
Line 2217 END
|
if ($emptysec) { |
if ($emptysec) { |
$r->print(&Apache::loncommon::commit_standardrole($udom,$uname,$url,$three,$start,$end,$one,$two,'')); |
$r->print(&Apache::loncommon::commit_standardrole($udom,$uname,$url,$three,$start,$end,$one,$two,'')); |
} |
} |
} |
} |
|
if (!grep(/^\Q$three\E$/,@rolechanges)) { |
|
push(@rolechanges,$three); |
|
} |
} elsif ($key=~/^form\.act\_([^\_]+)\_([^\_]+)$/) { |
} elsif ($key=~/^form\.act\_([^\_]+)\_([^\_]+)$/) { |
# Activate roles for sections with two id numbers |
# Activate roles for sections with two id numbers |
# set start, end times, and the url for the class |
# set start, end times, and the url for the class |
Line 2222 END
|
Line 2230 END
|
my $end = ( $env{'form.end_'.$1.'_'.$2} ? |
my $end = ( $env{'form.end_'.$1.'_'.$2} ? |
$env{'form.end_'.$1.'_'.$2} : |
$env{'form.end_'.$1.'_'.$2} : |
0 ); |
0 ); |
my $url='/'.$1.'/'; |
my $one = $1; |
|
my $two = $2; |
|
my $url='/'.$one.'/'; |
# split multiple sections |
# split multiple sections |
my %sections = (); |
my %sections = (); |
my $num_sections = &build_roles($env{'form.sec_'.$1.'_'.$2},\%sections,$2); |
my $num_sections = &build_roles($env{'form.sec_'.$one.'_'.$two},\%sections,$two); |
if ($num_sections == 0) { |
if ($num_sections == 0) { |
$r->print(&Apache::loncommon::commit_standardrole($udom,$uname,$url,$2,$start,$end,$1,undef,'')); |
$r->print(&Apache::loncommon::commit_standardrole($udom,$uname,$url,$two,$start,$end,$one,undef,'')); |
} else { |
} else { |
my $emptysec = 0; |
my $emptysec = 0; |
foreach my $sec (sort {$a cmp $b} keys %sections) { |
foreach my $sec (sort {$a cmp $b} keys %sections) { |
if ($sec ne '') { |
if ($sec ne '') { |
my $securl = $url.'/'.$sec; |
my $securl = $url.'/'.$sec; |
$r->print(&Apache::loncommon::commit_standardrole($udom,$uname,$securl,$2,$start,$end,$1,undef,$sec)); |
$r->print(&Apache::loncommon::commit_standardrole($udom,$uname,$securl,$two,$start,$end,$one,undef,$sec)); |
} else { |
} else { |
$emptysec = 1; |
$emptysec = 1; |
} |
} |
} |
} |
if ($emptysec) { |
if ($emptysec) { |
$r->print(&Apache::loncommon::commit_standardrole($udom,$uname,$url,$2,$start,$end,$1,undef,'')); |
$r->print(&Apache::loncommon::commit_standardrole($udom,$uname,$url,$two,$start,$end,$one,undef,'')); |
} |
} |
} |
} |
|
if (!grep(/^\Q$two\E$/,@rolechanges)) { |
|
push(@rolechanges,$two); |
|
} |
} else { |
} else { |
$r->print('<p><span class="LC_error">'.&mt('ERROR').': '.&mt('Unknown command').' <tt>'.$key.'</tt></span></p><br />'); |
$r->print('<p><span class="LC_error">'.&mt('ERROR').': '.&mt('Unknown command').' <tt>'.$key.'</tt></span></p><br />'); |
} |
} |
Line 2253 END
|
Line 2266 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(); |
if (!$rolechanges) { |
if (@rolechanges == 0) { |
$r->print(&mt('No roles to modify')); |
$r->print(&mt('No roles to modify')); |
} |
} |
$r->print(&Apache::loncommon::end_page()); |
return @rolechanges; |
|
} |
|
|
|
sub enroll_single_student { |
|
my ($r,$uhome,$amode,$genpwd,$now,$newuser) = @_; |
|
$r->print('<h3>'.&mt('Enrolling Student').'</h3>'); |
|
|
|
# Remove non alphanumeric values from section |
|
$env{'form.sections'}=~s/\W//g; |
|
|
|
# Clean out any old student roles the user has in this class. |
|
&Apache::lonuserutils::modifystudent($env{'form.ccdomain'}, |
|
$env{'form.ccuname'},$env{'request.course.id'},undef,$uhome); |
|
my ($startdate,$enddate) = &Apache::lonuserutils::get_dates_from_form(); |
|
my $enroll_result = |
|
&Apache::lonnet::modify_student_enrollment($env{'form.ccdomain'}, |
|
$env{'form.ccuname'},$env{'form.cid'},$env{'form.cfirstname'}, |
|
$env{'form.cmiddlename'},$env{'form.clastname'}, |
|
$env{'form.generation'},$env{'form.sections'},$enddate, |
|
$startdate,'manual',undef,$env{'request.course.id'}); |
|
if ($enroll_result =~ /^ok/) { |
|
$r->print(&mt('<b>[_1]</b> enrolled',$env{'form.ccuname'}.':'.$env{'form.ccdomain'})); |
|
if ($env{'form.sections'} ne '') { |
|
$r->print(' '.&mt('in section [_1]',$env{'form.sections'})); |
|
} |
|
my ($showstart,$showend); |
|
if ($startdate <= $now) { |
|
$showstart = &mt('Access starts immediately'); |
|
} else { |
|
$showstart = &mt('Access starts: ').&Apache::lonlocal::locallocaltime($startdate); |
|
} |
|
if ($enddate == 0) { |
|
$showend = &mt('ends: no ending date'); |
|
} else { |
|
$showend = &mt('ends: ').&Apache::lonlocal::locallocaltime($enddate); |
|
} |
|
$r->print('.<br />'.$showstart.'; '.$showend); |
|
if ($startdate <= $now && !$newuser) { |
|
$r->print("<p> ".&mt('If the student is currently logged-in to LON-CAPA, the new role will be available when the student next logs in.')."</p>"); |
|
} |
|
} else { |
|
$r->print(&mt('unable to enroll').": ".$enroll_result); |
|
} |
|
return; |
} |
} |
|
|
sub get_defaultquota_text { |
sub get_defaultquota_text { |
Line 2301 sub update_result_form {
|
Line 2356 sub update_result_form {
|
} |
} |
$outcome .= '<input type="hidden" name="phase" value="" />'."\n". |
$outcome .= '<input type="hidden" name="phase" value="" />'."\n". |
'<input type ="hidden" name="currstate" value="" />'."\n". |
'<input type ="hidden" name="currstate" value="" />'."\n". |
'<input type ="hidden" name="action" value="singleuser" />'."\n". |
'<input type ="hidden" name="action" value="'.$env{'form.action'}.'" />'."\n". |
'</form>'; |
'</form>'; |
return $outcome; |
return $outcome; |
} |
} |
Line 2437 sub custom_role_editor {
|
Line 2492 sub custom_role_editor {
|
{href=>"javascript:backPage(document.form1,'','')", |
{href=>"javascript:backPage(document.form1,'','')", |
text=>"Edit custom role", |
text=>"Edit custom role", |
faq=>282,bug=>'Instructor Interface',}); |
faq=>282,bug=>'Instructor Interface',}); |
$r->print(&Apache::lonhtmlcommon::breadcrumbs('User Management')); |
$r->print(&Apache::lonhtmlcommon::breadcrumbs('User Management', |
|
'Course_Editing_Custom_Roles')); |
|
|
$r->print($body_top); |
$r->print($body_top); |
my %lt=&Apache::lonlocal::texthash( |
my %lt=&Apache::lonlocal::texthash( |
Line 2577 sub set_custom_role {
|
Line 2633 sub set_custom_role {
|
{href=>"javascript:backPage(document.customresult,'set_custom_roles','')", |
{href=>"javascript:backPage(document.customresult,'set_custom_roles','')", |
text=>"Result", |
text=>"Result", |
faq=>282,bug=>'Instructor Interface',}); |
faq=>282,bug=>'Instructor Interface',}); |
$r->print(&Apache::lonhtmlcommon::breadcrumbs('User Management')); |
$r->print(&Apache::lonhtmlcommon::breadcrumbs('User Management', |
|
'Course_Editing_Custom_Roles')); |
|
|
my ($rdummy,$roledef)= |
my ($rdummy,$roledef)= |
&Apache::lonnet::get('roles',["rolesdef_$rolename"]); |
&Apache::lonnet::get('roles',["rolesdef_$rolename"]); |
Line 2685 sub handler {
|
Line 2742 sub handler {
|
({href=>'/adm/createuser?action=upload&state=', |
({href=>'/adm/createuser?action=upload&state=', |
text=>"Upload Users List"}); |
text=>"Upload Users List"}); |
$r->print(&Apache::lonhtmlcommon::breadcrumbs('Upload Users List', |
$r->print(&Apache::lonhtmlcommon::breadcrumbs('Upload Users List', |
'User_Management_Upload')); |
'Course_Create_Class_List')); |
$r->print('<form name="studentform" method="post" '. |
$r->print('<form name="studentform" method="post" '. |
'enctype="multipart/form-data" '. |
'enctype="multipart/form-data" '. |
' action="/adm/createuser">'."\n"); |
' action="/adm/createuser">'."\n"); |
if (! exists($env{'form.state'})) { |
if (! exists($env{'form.state'})) { |
&Apache::lonuserutils::print_first_users_upload_form($r,$context); |
&Apache::lonuserutils::print_first_users_upload_form($r,$context); |
} elsif ($env{'form.state'} eq 'got_file') { |
} elsif ($env{'form.state'} eq 'got_file') { |
&Apache::lonuserutils::print_upload_manager_form($r,$context); |
&Apache::lonuserutils::print_upload_manager_form($r,$context, |
|
$permission); |
} elsif ($env{'form.state'} eq 'enrolling') { |
} elsif ($env{'form.state'} eq 'enrolling') { |
if ($env{'form.datatoken'}) { |
if ($env{'form.datatoken'}) { |
&Apache::lonuserutils::upfile_drop_add($r,$context); |
&Apache::lonuserutils::upfile_drop_add($r,$context,$permission); |
} |
} |
} else { |
} else { |
&Apache::lonuserutils::print_first_users_upload_form($r,$context); |
&Apache::lonuserutils::print_first_users_upload_form($r,$context); |
Line 2717 sub handler {
|
Line 2775 sub handler {
|
my $response; |
my $response; |
if ($env{'form.srchterm'} !~ /^$match_username$/) { |
if ($env{'form.srchterm'} !~ /^$match_username$/) { |
my $response = &mt('You must specify a valid username. Only the following are allowed: letters numbers - . @'); |
my $response = &mt('You must specify a valid username. Only the following are allowed: letters numbers - . @'); |
|
$env{'form.phase'} = ''; |
&print_username_entry_form($r,$context,$response,$srch); |
&print_username_entry_form($r,$context,$response,$srch); |
} else { |
} else { |
my $ccuname =&LONCAPA::clean_username($srch->{'srchterm'}); |
my $ccuname =&LONCAPA::clean_username($srch->{'srchterm'}); |
my $ccdomain=&LONCAPA::clean_domain($srch->{'srchdomain'}); |
my $ccdomain=&LONCAPA::clean_domain($srch->{'srchdomain'}); |
&print_user_modification_page($r,$ccuname,$ccdomain, |
&print_user_modification_page($r,$ccuname,$ccdomain, |
$srch,$response,$context); |
$srch,$response,$context, |
|
$permission); |
} |
} |
} elsif ($env{'form.phase'} eq 'get_user_info') { |
} elsif ($env{'form.phase'} eq 'get_user_info') { |
my ($currstate,$response,$forcenewuser,$results) = |
my ($currstate,$response,$forcenewuser,$results) = |
&user_search_result($srch); |
&user_search_result($context,$srch); |
if ($env{'form.currstate'} eq 'modify') { |
if ($env{'form.currstate'} eq 'modify') { |
$currstate = $env{'form.currstate'}; |
$currstate = $env{'form.currstate'}; |
} |
} |
Line 2755 sub handler {
|
Line 2815 sub handler {
|
$response = ''; |
$response = ''; |
} |
} |
&print_user_modification_page($r,$ccuname,$ccdomain, |
&print_user_modification_page($r,$ccuname,$ccdomain, |
$srch,$response,$context); |
$srch,$response,$context, |
|
$permission); |
} elsif ($currstate eq 'query') { |
} elsif ($currstate eq 'query') { |
&print_user_query_page($r,'createuser'); |
&print_user_query_page($r,'createuser'); |
} else { |
} else { |
Line 2766 sub handler {
|
Line 2827 sub handler {
|
my $ccuname = &LONCAPA::clean_username($env{'form.seluname'}); |
my $ccuname = &LONCAPA::clean_username($env{'form.seluname'}); |
my $ccdomain = &LONCAPA::clean_domain($env{'form.seludom'}); |
my $ccdomain = &LONCAPA::clean_domain($env{'form.seludom'}); |
&print_user_modification_page($r,$ccuname,$ccdomain,$srch,'', |
&print_user_modification_page($r,$ccuname,$ccdomain,$srch,'', |
$context); |
$context,$permission); |
} |
} |
} elsif ($env{'form.phase'} eq 'update_user_data') { |
} elsif ($env{'form.phase'} eq 'update_user_data') { |
&update_user_data($r,$context); |
&update_user_data($r,$context); |
Line 2783 sub handler {
|
Line 2844 sub handler {
|
($permission->{'view'} || $permission->{'cusr'})) { |
($permission->{'view'} || $permission->{'cusr'})) { |
if ($env{'form.phase'} eq 'bulkchange') { |
if ($env{'form.phase'} eq 'bulkchange') { |
&Apache::lonhtmlcommon::add_breadcrumb |
&Apache::lonhtmlcommon::add_breadcrumb |
({href=>'backPage(document.studentform)', |
({href=>'/adm/createuser?action=listusers', |
text=>"List Users"}); |
text=>"List Users"}, |
|
{href=>"/adm/createuser", |
|
text=>"Result"}); |
my $setting = $env{'form.roletype'}; |
my $setting = $env{'form.roletype'}; |
my $choice = $env{'form.bulkaction'}; |
my $choice = $env{'form.bulkaction'}; |
$r->print(&header()); |
$r->print(&header()); |
$r->print(&Apache::lonhtmlcommon::breadcrumbs("List Users", |
$r->print(&Apache::lonhtmlcommon::breadcrumbs("Update Users", |
'User_Management_List')); |
'Course_View_Class_List')); |
if ($permission->{'cusr'}) { |
if ($permission->{'cusr'}) { |
&Apache::lonuserutils::update_user_list($r,$context,$setting,$choice); |
&Apache::lonuserutils::update_user_list($r,$context,$setting,$choice); |
|
$r->print(&Apache::loncommon::end_page()); |
|
} else { |
|
$r->print(&mt('You are not authorized to make bulk changes to user roles')); |
|
$r->print('<p><a href="/adm/createuser?action=listusers">'.&mt('Display User Lists').'</a>'); |
|
$r->print(&Apache::loncommon::end_page()); |
} |
} |
} else { |
} else { |
&Apache::lonhtmlcommon::add_breadcrumb |
&Apache::lonhtmlcommon::add_breadcrumb |
Line 2816 sub handler {
|
Line 2884 sub handler {
|
$r->print(&header(&add_script(&verify_user_display()))); |
$r->print(&header(&add_script(&verify_user_display()))); |
} |
} |
$r->print(&Apache::lonhtmlcommon::breadcrumbs("List Users", |
$r->print(&Apache::lonhtmlcommon::breadcrumbs("List Users", |
'User_Management_List')); |
'Course_View_Class_List')); |
&Apache::lonuserutils::print_userlist($r,undef,$permission,$context, |
&Apache::lonuserutils::print_userlist($r,undef,$permission,$context, |
$formname,$totcodes,$codetitles,$idlist,$idlist_titles); |
$formname,$totcodes,$codetitles,$idlist,$idlist_titles); |
$r->print(&Apache::loncommon::end_page()); |
$r->print(&Apache::loncommon::end_page()); |
Line 2844 sub handler {
|
Line 2912 sub handler {
|
} elsif ($env{'form.action'} eq 'dateselect') { |
} elsif ($env{'form.action'} eq 'dateselect') { |
if ($permission->{'cusr'}) { |
if ($permission->{'cusr'}) { |
$r->print(&header(undef,undef,{'no_nav_bar' => 1}). |
$r->print(&header(undef,undef,{'no_nav_bar' => 1}). |
&Apache::lonuserutils::date_section_selector($context). |
&Apache::lonuserutils::date_section_selector($context, |
|
$permission). |
&Apache::loncommon::end_page()); |
&Apache::loncommon::end_page()); |
} else { |
} else { |
$r->print(&header(). |
$r->print(&header(). |
Line 2898 sub print_main_menu {
|
Line 2967 sub print_main_menu {
|
my %links = ( |
my %links = ( |
domain => { |
domain => { |
upload => 'Upload a File of Users', |
upload => 'Upload a File of Users', |
singleuser => 'Add/Manage a Single User', |
singleuser => 'Add/Modify a Single User', |
listusers => 'Manage Multiple Users', |
listusers => 'Manage Multiple Users', |
}, |
}, |
author => { |
author => { |
upload => 'Upload a File of Co-authors', |
upload => 'Upload a File of Co-authors', |
singleuser => 'Add/Manage a Single Co-author', |
singleuser => 'Add/Modify a Single Co-author', |
listusers => 'Display Co-authors and Manage Multiple Users', |
listusers => 'Display Co-authors and Manage Multiple Users', |
}, |
}, |
course => { |
course => { |
upload => 'Upload a File of Course Users', |
upload => 'Upload a File of Course Users', |
singleuser => 'Add/Manage a Single Course User', |
singleuser => 'Add/Modify a Single Course User', |
listusers => 'Display Class Lists and Manage Multiple Users', |
listusers => 'Display Class Lists and Manage Multiple Users', |
}, |
}, |
); |
); |
my @menu = |
my @menu = |
( |
( |
{ text => $links{$context}{'upload'}, |
{ text => $links{$context}{'upload'}, |
help => 'User_Management_Upload', |
help => 'Course_Create_Class_List', |
action => 'upload', |
action => 'upload', |
permission => $permission->{'cusr'}, |
permission => $permission->{'cusr'}, |
}, |
}, |
{ text => $links{$context}{'singleuser'}, |
{ text => $links{$context}{'singleuser'}, |
help => 'User_Management_Single_User', |
help => 'Course_Change_Privileges', |
action => 'singleuser', |
action => 'singleuser', |
permission => $permission->{'cusr'}, |
permission => $permission->{'cusr'}, |
}, |
}, |
{ text => $links{$context}{'listusers'}, |
{ text => $links{$context}{'listusers'}, |
help => 'User_Management_List', |
help => 'Course_View_Class_List', |
action => 'listusers', |
action => 'listusers', |
permission => ($permission->{'view'} || $permission->{'cusr'}), |
permission => ($permission->{'view'} || $permission->{'cusr'}), |
}, |
}, |
); |
); |
if ($context eq 'domain' || $context eq 'course') { |
if ($context eq 'domain' || $context eq 'course') { |
my $customlink = { text => 'Edit Custom Roles', |
my $customlink = { text => 'Edit Custom Roles', |
help => 'Custom_Role_Edit', |
help => 'Course_Editing_Custom_Roles', |
action => 'custom', |
action => 'custom', |
permission => $permission->{'custom'}, |
permission => $permission->{'custom'}, |
}; |
}; |
Line 2943 sub print_main_menu {
|
Line 3012 sub print_main_menu {
|
my @courselinks = |
my @courselinks = |
( |
( |
{ text => 'Enroll a Single Student', |
{ text => 'Enroll a Single Student', |
help => 'Course_Single_Student', |
help => 'Course_Add_Student', |
action => 'singlestudent', |
action => 'singlestudent', |
permission => $permission->{'cusr'}, |
permission => $permission->{'cusr'}, |
}, |
}, |
Line 2955 sub print_main_menu {
|
Line 3024 sub print_main_menu {
|
if (!exists($permission->{'cusr_section'})) { |
if (!exists($permission->{'cusr_section'})) { |
push(@courselinks, |
push(@courselinks, |
{ text => 'Automated Student Enrollment Manager', |
{ text => 'Automated Student Enrollment Manager', |
|
help => 'Course_Automated_Enrollment', |
permission => (&Apache::lonnet::auto_run($cnum,$cdom) |
permission => (&Apache::lonnet::auto_run($cnum,$cdom) |
&& $permission->{'cusr'}), |
&& $permission->{'cusr'}), |
url => '/adm/populate', |
url => '/adm/populate', |
Line 3002 sub restore_prev_selections {
|
Line 3072 sub restore_prev_selections {
|
|
|
#-------------------------------------------------- functions for &phase_two |
#-------------------------------------------------- functions for &phase_two |
sub user_search_result { |
sub user_search_result { |
my ($srch) = @_; |
my ($context,$srch) = @_; |
my %allhomes; |
my %allhomes; |
my %inst_matches; |
my %inst_matches; |
my %srch_results; |
my %srch_results; |
Line 3071 sub user_search_result {
|
Line 3141 sub user_search_result {
|
my $uhome=&Apache::lonnet::homeserver($srch->{'srchterm'},$srch->{'srchdomain'}); |
my $uhome=&Apache::lonnet::homeserver($srch->{'srchterm'},$srch->{'srchdomain'}); |
if ($uhome eq 'no_host') { |
if ($uhome eq 'no_host') { |
($currstate,$response,$forcenewuser) = |
($currstate,$response,$forcenewuser) = |
&build_search_response($srch,%srch_results); |
&build_search_response($context,$srch,%srch_results); |
} else { |
} else { |
$currstate = 'modify'; |
$currstate = 'modify'; |
} |
} |
} else { |
} else { |
%srch_results = &Apache::lonnet::usersearch($srch); |
%srch_results = &Apache::lonnet::usersearch($srch); |
($currstate,$response,$forcenewuser) = |
($currstate,$response,$forcenewuser) = |
&build_search_response($srch,%srch_results); |
&build_search_response($context,$srch,%srch_results); |
} |
} |
} else { |
} else { |
my $courseusers = &get_courseusers(); |
my $courseusers = &get_courseusers(); |
Line 3087 sub user_search_result {
|
Line 3157 sub user_search_result {
|
$currstate = 'modify'; |
$currstate = 'modify'; |
} else { |
} else { |
($currstate,$response,$forcenewuser) = |
($currstate,$response,$forcenewuser) = |
&build_search_response($srch,%srch_results); |
&build_search_response($context,$srch,%srch_results); |
} |
} |
} else { |
} else { |
foreach my $user (keys(%$courseusers)) { |
foreach my $user (keys(%$courseusers)) { |
Line 3114 sub user_search_result {
|
Line 3184 sub user_search_result {
|
} |
} |
} |
} |
($currstate,$response,$forcenewuser) = |
($currstate,$response,$forcenewuser) = |
&build_search_response($srch,%srch_results); |
&build_search_response($context,$srch,%srch_results); |
} |
} |
} |
} |
} |
} |
Line 3124 sub user_search_result {
|
Line 3194 sub user_search_result {
|
($dirsrchres,%srch_results) = &Apache::lonnet::inst_directory_query($srch); |
($dirsrchres,%srch_results) = &Apache::lonnet::inst_directory_query($srch); |
if ($dirsrchres eq 'ok') { |
if ($dirsrchres eq 'ok') { |
($currstate,$response,$forcenewuser) = |
($currstate,$response,$forcenewuser) = |
&build_search_response($srch,%srch_results); |
&build_search_response($context,$srch,%srch_results); |
} else { |
} else { |
my $showdom = &display_domain_info($srch->{'srchdomain'}); |
my $showdom = &display_domain_info($srch->{'srchdomain'}); |
$response = '<span class="LC_warning">'. |
$response = '<span class="LC_warning">'. |
Line 3138 sub user_search_result {
|
Line 3208 sub user_search_result {
|
if ($srch->{'srchin'} eq 'dom') { |
if ($srch->{'srchin'} eq 'dom') { |
%srch_results = &Apache::lonnet::usersearch($srch); |
%srch_results = &Apache::lonnet::usersearch($srch); |
($currstate,$response,$forcenewuser) = |
($currstate,$response,$forcenewuser) = |
&build_search_response($srch,%srch_results); |
&build_search_response($context,$srch,%srch_results); |
} elsif ($srch->{'srchin'} eq 'crs') { |
} elsif ($srch->{'srchin'} eq 'crs') { |
my $courseusers = &get_courseusers(); |
my $courseusers = &get_courseusers(); |
foreach my $user (keys(%$courseusers)) { |
foreach my $user (keys(%$courseusers)) { |
Line 3190 sub user_search_result {
|
Line 3260 sub user_search_result {
|
} |
} |
} |
} |
($currstate,$response,$forcenewuser) = |
($currstate,$response,$forcenewuser) = |
&build_search_response($srch,%srch_results); |
&build_search_response($context,$srch,%srch_results); |
} elsif ($srch->{'srchin'} eq 'alc') { |
} elsif ($srch->{'srchin'} eq 'alc') { |
$currstate = 'query'; |
$currstate = 'query'; |
} elsif ($srch->{'srchin'} eq 'instd') { |
} elsif ($srch->{'srchin'} eq 'instd') { |
($dirsrchres,%srch_results) = &Apache::lonnet::inst_directory_query($srch); |
($dirsrchres,%srch_results) = &Apache::lonnet::inst_directory_query($srch); |
if ($dirsrchres eq 'ok') { |
if ($dirsrchres eq 'ok') { |
($currstate,$response,$forcenewuser) = |
($currstate,$response,$forcenewuser) = |
&build_search_response($srch,%srch_results); |
&build_search_response($context,$srch,%srch_results); |
} else { |
} else { |
my $showdom = &display_domain_info($srch->{'srchdomain'}); $response = '<span class="LC_warning">'. |
my $showdom = &display_domain_info($srch->{'srchdomain'}); $response = '<span class="LC_warning">'. |
&mt('Institutional directory search is not available in domain: [_1]',$showdom). |
&mt('Institutional directory search is not available in domain: [_1]',$showdom). |
Line 3303 sub get_courseusers {
|
Line 3373 sub get_courseusers {
|
} |
} |
|
|
sub build_search_response { |
sub build_search_response { |
my ($srch,%srch_results) = @_; |
my ($context,$srch,%srch_results) = @_; |
my ($currstate,$response,$forcenewuser); |
my ($currstate,$response,$forcenewuser); |
my %names = ( |
my %names = ( |
'uname' => 'username', |
'uname' => 'username', |
Line 3362 sub build_search_response {
|
Line 3432 sub build_search_response {
|
} |
} |
} |
} |
if (!($srch->{'srchby'} eq 'uname' && $srch->{'srchin'} eq 'dom' && $srch->{'srchtype'} eq 'exact' && $srch->{'srchdomain'} eq $env{'request.role.domain'})) { |
if (!($srch->{'srchby'} eq 'uname' && $srch->{'srchin'} eq 'dom' && $srch->{'srchtype'} eq 'exact' && $srch->{'srchdomain'} eq $env{'request.role.domain'})) { |
my $showdom = &display_domain_info($env{'request.role.domain'}); |
my $cancreate = |
|
&Apache::lonuserutils::can_create_user($env{'request.role.domain'},$context); |
|
if ($cancreate) { |
|
my $showdom = &display_domain_info($env{'request.role.domain'}); |
$response .= '<br /><br />'.&mt("<b>To add a new user</b> (you can only create new users in your current role's domain - <span class=\"LC_cusr_emph\">[_1]</span>):",$env{'request.role.domain'}).'<ul><li>'.&mt("Set 'Domain/institution to search' to: <span class=\"LC_cusr_emph\">[_1]</span>",$showdom).'<li>'.&mt("Set 'Search criteria' to: <span class=\"LC_cusr_emph\">'username is ...... in selected LON-CAPA domain'").'</span></li><li>'.&mt('Provide the proposed username').'</li><li>'.&mt('Search').'</li></ul><br />'; |
$response .= '<br /><br />'.&mt("<b>To add a new user</b> (you can only create new users in your current role's domain - <span class=\"LC_cusr_emph\">[_1]</span>):",$env{'request.role.domain'}).'<ul><li>'.&mt("Set 'Domain/institution to search' to: <span class=\"LC_cusr_emph\">[_1]</span>",$showdom).'<li>'.&mt("Set 'Search criteria' to: <span class=\"LC_cusr_emph\">'username is ...... in selected LON-CAPA domain'").'</span></li><li>'.&mt('Provide the proposed username').'</li><li>'.&mt('Search').'</li></ul><br />'; |
|
} else { |
|
my $helplink = ' href="javascript:helpMenu('."'display'".')"'; |
|
$response .= '<br /><br />'.&mt("You are not authorized to create new users in your current role's domain - <span class=\"LC_cusr_emph\">[_1]</span>.",$env{'request.role.domain'}).'<br />'.&mt('Contact the <a[_1]>helpdesk</a> if you need to create a new user.',$helplink).'<br /><br />'; |
|
} |
} |
} |
} |
} |
} |
} |
Line 3465 sub course_level_table {
|
Line 3542 sub course_level_table {
|
} |
} |
my @roles = &Apache::lonuserutils::roles_by_context('course'); |
my @roles = &Apache::lonuserutils::roles_by_context('course'); |
foreach my $role (@roles) { |
foreach my $role (@roles) { |
|
my $plrole=&Apache::lonnet::plaintext($role); |
if (&Apache::lonnet::allowed('c'.$role,$thiscourse)) { |
if (&Apache::lonnet::allowed('c'.$role,$thiscourse)) { |
my $plrole=&Apache::lonnet::plaintext($role); |
$table .= &course_level_row($protectedcourse,$role,$area,$domain, |
$table .= &Apache::loncommon::start_data_table_row(). |
$plrole,\%sections_count,\%lt); |
'<td><input type="checkbox" name="act_'.$protectedcourse.'_'.$role.'" /></td> |
} elsif ($env{'request.course.sec'} ne '') { |
<td>'.$plrole.'</td> |
if (&Apache::lonnet::allowed('c'.$role,$thiscourse.'/'. |
<td>'.$area.'<br />Domain: '.$domain.'</td>'."\n"; |
$env{'request.course.sec'})) { |
if ($role ne 'cc') { |
$table .= &course_level_row($protectedcourse,$role,$area,$domain, |
if (%sections_count) { |
$plrole,\%sections_count,\%lt); |
my $currsec = |
|
&Apache::lonuserutils::course_sections(\%sections_count, |
|
$protectedcourse.'_'.$role); |
|
$table .= |
|
'<td><table class="LC_createuser">'. |
|
'<tr class="LC_section_row"> |
|
<td valign="top">'.$lt{'exs'}.'<br />'. |
|
$currsec.'</td>'. |
|
'<td> </td>'. |
|
'<td valign="top"> '.$lt{'new'}.'<br />'. |
|
'<input type="text" name="newsec_'.$protectedcourse.'_'.$role.'" value="" />'. |
|
'<input type="hidden" '. |
|
'name="sec_'.$protectedcourse.'_'.$role.'" /></td>'. |
|
'</tr></table></td>'; |
|
} else { |
|
$table .= '<td><input type="text" size="10" '. |
|
'name="sec_'.$protectedcourse.'_'.$role.'" /></td>'; |
|
} |
|
} else { |
|
$table .= '<td> </td>'; |
|
} |
} |
$table .= <<ENDTIMEENTRY; |
|
<td><input type="hidden" name="start_$protectedcourse\_$role" value='' /> |
|
<a href= |
|
"javascript:pjump('date_start','Start Date $plrole',document.cu.start_$protectedcourse\_$role.value,'start_$protectedcourse\_$role','cu.pres','dateset')">$lt{'ssd'}</a></td> |
|
<td><input type="hidden" name="end_$protectedcourse\_$role" value='' /> |
|
<a href= |
|
"javascript:pjump('date_end','End Date $plrole',document.cu.end_$protectedcourse\_$role.value,'end_$protectedcourse\_$role','cu.pres','dateset')">$lt{'sed'}</a></td> |
|
ENDTIMEENTRY |
|
$table.= &Apache::loncommon::end_data_table_row(); |
|
} |
} |
} |
} |
foreach my $cust (sort keys %customroles) { |
if (&Apache::lonnet::allowed('ccr',$thiscourse)) { |
if (&Apache::lonnet::allowed('ccr',$thiscourse)) { |
foreach my $cust (sort keys %customroles) { |
my $plrole=$cust; |
my $role = 'cr_cr_'.$env{'user.domain'}.'_'.$env{'user.name'}.'_'.$cust; |
my $customrole=$protectedcourse.'_cr_cr_'.$env{'user.domain'}. |
$table .= &course_level_row($protectedcourse,$role,$area,$domain, |
'_'.$env{'user.name'}.'_'.$plrole; |
$cust,\%sections_count,\%lt); |
$table .= &Apache::loncommon::start_data_table_row(). |
} |
'<td><input type="checkbox" name="act_'.$customrole.'" /></td> |
|
<td>'.$plrole.'</td> |
|
<td>'.$area.'</td>'."\n"; |
|
if (%sections_count) { |
|
my $currsec = |
|
&Apache::lonuserutils::course_sections(\%sections_count, |
|
$customrole); |
|
$table.= |
|
'<td><table class="LC_createuser">'. |
|
'<tr class="LC_section_row"><td valign="top">'. |
|
$lt{'exs'}.'<br />'.$currsec.'</td>'. |
|
'<td> </td>'. |
|
'<td valign="top"> '.$lt{'new'}.'<br />'. |
|
'<input type="text" name="newsec_'.$customrole.'" value="" /></td>'. |
|
'<input type="hidden" '. |
|
'name="sec_'.$customrole.'" /></td>'. |
|
'</tr></table></td>'; |
|
} else { |
|
$table .= '<td><input type="text" size="10" '. |
|
'name="sec_'.$customrole.'" /></td>'; |
|
} |
|
$table .= <<ENDENTRY; |
|
<td><input type="hidden" name="start_$customrole" value='' /> |
|
<a href= |
|
"javascript:pjump('date_start','Start Date $plrole',document.cu.start_$customrole.value,'start_$customrole','cu.pres','dateset')">$lt{'ssd'}</a></td> |
|
<td><input type="hidden" name="end_$customrole" value='' /> |
|
<a href= |
|
"javascript:pjump('date_end','End Date $plrole',document.cu.end_$customrole.value,'end_$customrole','cu.pres','dateset')">$lt{'sed'}</a></td> |
|
ENDENTRY |
|
$table .= &Apache::loncommon::end_data_table_row(); |
|
} |
|
} |
} |
} |
} |
return '' if ($table eq ''); # return nothing if there is nothing |
return '' if ($table eq ''); # return nothing if there is nothing |
Line 3561 $table.
|
Line 3579 $table.
|
return $result; |
return $result; |
} |
} |
|
|
|
sub course_level_row { |
|
my ($protectedcourse,$role,$area,$domain,$plrole,$sections_count,$lt) = @_; |
|
my $row = &Apache::loncommon::start_data_table_row(). |
|
' <td><input type="checkbox" name="act_'. |
|
$protectedcourse.'_'.$role.'" /></td>'."\n". |
|
' <td>'.$plrole.'</td>'."\n". |
|
' <td>'.$area.'<br />Domain: '.$domain.'</td>'."\n"; |
|
if ($role eq 'cc') { |
|
$row .= '<td> </td>'; |
|
} elsif ($env{'request.course.sec'} ne '') { |
|
$row .= ' <td><input type="hidden" value="'. |
|
$env{'request.course.sec'}.'" '. |
|
'name="sec_'.$protectedcourse.'_'.$role.'" />'. |
|
$env{'request.course.sec'}.'</td>'; |
|
} else { |
|
if (ref($sections_count) eq 'HASH') { |
|
my $currsec = |
|
&Apache::lonuserutils::course_sections($sections_count, |
|
$protectedcourse.'_'.$role); |
|
$row .= '<td><table class="LC_createuser">'."\n". |
|
'<tr class="LC_section_row">'."\n". |
|
' <td valign="top">'.$lt->{'exs'}.'<br />'. |
|
$currsec.'</td>'."\n". |
|
' <td> </td>'."\n". |
|
' <td valign="top"> '.$lt->{'new'}.'<br />'. |
|
'<input type="text" name="newsec_'.$protectedcourse.'_'.$role. |
|
'" value="" />'. |
|
'<input type="hidden" '. |
|
'name="sec_'.$protectedcourse.'_'.$role.'" /></td>'."\n". |
|
'</tr></table></td>'."\n"; |
|
} else { |
|
$row .= '<td><input type="text" size="10" '. |
|
'name="sec_'.$protectedcourse.'_'.$role.'" /></td>'."\n"; |
|
} |
|
} |
|
$row .= <<ENDTIMEENTRY; |
|
<td><input type="hidden" name="start_$protectedcourse\_$role" value="" /> |
|
<a href= |
|
"javascript:pjump('date_start','Start Date $plrole',document.cu.start_$protectedcourse\_$role.value,'start_$protectedcourse\_$role','cu.pres','dateset')">$lt->{'ssd'}</a></td> |
|
<td><input type="hidden" name="end_$protectedcourse\_$role" value="" /> |
|
<a href= |
|
"javascript:pjump('date_end','End Date $plrole',document.cu.end_$protectedcourse\_$role.value,'end_$protectedcourse\_$role','cu.pres','dateset')">$lt->{'sed'}</a></td> |
|
ENDTIMEENTRY |
|
$row .= &Apache::loncommon::end_data_table_row(); |
|
return $row; |
|
} |
|
|
sub course_level_dc { |
sub course_level_dc { |
my ($dcdom) = @_; |
my ($dcdom) = @_; |
my %customroles=&Apache::lonuserutils::my_custom_roles(); |
my %customroles=&Apache::lonuserutils::my_custom_roles(); |
Line 3607 sub course_level_dc {
|
Line 3672 sub course_level_dc {
|
'<td> </td>'. |
'<td> </td>'. |
'<td valign="top"> <b>'.$lt{'new'}.'</b><br />'. |
'<td valign="top"> <b>'.$lt{'new'}.'</b><br />'. |
'<input type="text" name="newsec" value="" />'. |
'<input type="text" name="newsec" value="" />'. |
|
'<input type="hidden" name="sections" value="" />'. |
'<input type="hidden" name="groups" value="" /></td>'. |
'<input type="hidden" name="groups" value="" /></td>'. |
'</tr></table></td>'; |
'</tr></table></td>'; |
$otheritems .= <<ENDTIMEENTRY; |
$otheritems .= <<ENDTIMEENTRY; |