--- loncom/interface/loncreateuser.pm 2007/12/31 01:58:17 1.225 +++ loncom/interface/loncreateuser.pm 2008/01/02 09:16:59 1.228 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Create a user # -# $Id: loncreateuser.pm,v 1.225 2007/12/31 01:58:17 raeburn Exp $ +# $Id: loncreateuser.pm,v 1.228 2008/01/02 09:16:59 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -76,30 +76,30 @@ my $authformfsys; my $authformloc; sub initialize_authen_forms { - my ($dom,$curr_authtype,$mode) = @_; - my ($krbdefdom)=( $ENV{'SERVER_NAME'}=~/(\w+\.\w+)$/); - $krbdefdom= uc($krbdefdom); - my %param = ( formname => 'document.cu', + my ($dom,$formname,$curr_authtype,$mode) = @_; + my ($krbdef,$krbdefdom) = &Apache::loncommon::get_kerberos_defaults($dom); + my %param = ( formname => $formname, kerb_def_dom => $krbdefdom, + kerb_def_auth => $krbdef, domain => $dom, ); 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 $curr_autharg = $2; my %abv_auth = &auth_abbrev(); $param{'curr_authtype'} = $abv_auth{$long_auth}; if ($long_auth =~ /^krb(4|5)$/) { $param{'curr_kerb_ver'} = $1; + $param{'curr_autharg'} = $curr_autharg; } if ($mode eq 'modifyuser') { $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); -# no longer static due to configurable kerberos defaults -# $authformkrb = &Apache::loncommon::authform_kerberos(%param); $authformint = &Apache::loncommon::authform_internal(%param); $authformfsys = &Apache::loncommon::authform_filesystem(%param); $authformloc = &Apache::loncommon::authform_local(%param); @@ -320,7 +320,6 @@ ENDBLOCK if ($cancreate && $env{'form.phase'} eq '') { my $defdom=$env{'request.role.domain'}; my $domform = &Apache::loncommon::select_dom_form($defdom,'srchdomain'); - my $helpcrt=&Apache::loncommon::help_open_topic('Course_Change_Privileges'); my %lt=&Apache::lonlocal::texthash( 'crnu' => 'Create a new user', 'usr' => 'Username', @@ -336,7 +335,7 @@ ENDBLOCK -

$lt{crnu}$helpcrt

+

$lt{crnu}

$responsemsg @@ -515,8 +514,7 @@ sub print_user_modification_page { $formname = 'cu'; } my %abv_auth = &auth_abbrev(); - my ($curr_authtype,%rulematch,%inst_results,$curr_kerb_ver,$newuser, - %alerts,%curr_rules,%got_rules); + my (%rulematch,%inst_results,$newuser,%alerts,%curr_rules,%got_rules); my $uhome=&Apache::lonnet::homeserver($ccuname,$ccdomain); if ($uhome eq 'no_host') { my $usertype; @@ -571,32 +569,10 @@ sub print_user_modification_page { } } else { $newuser = 0; - my $currentauth = - &Apache::lonnet::queryauthenticate($ccuname,$ccdomain); - if ($currentauth =~ /^(krb4|krb5|unix|internal|localauth):/) { - $curr_authtype = $abv_auth{$1}; - if ($currentauth =~ /^krb(4|5)/) { - $curr_kerb_ver = $1; - } - } } if ($response) { $response = '
'.$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 $dc_setcourse_code = ''; @@ -654,7 +630,7 @@ ENDFORMINFO # Current user has quota modification privileges $portfolioform = '
'.&portfolio_quota($ccuname,$ccdomain); } - &initialize_authen_forms($ccdomain); + &initialize_authen_forms($ccdomain,$formname); my %lt=&Apache::lonlocal::texthash( 'cnu' => 'Create New User', 'ast' => 'as a student', @@ -775,8 +751,7 @@ ENDCHANGEUSER $r->print(&Apache::lonuserutils::forceid_change($context)); } $r->print(''); - my $user_auth_text = - &user_authentication($ccuname,$ccdomain,$krbdefdom,\%abv_auth); + my $user_auth_text = &user_authentication($ccuname,$ccdomain,$formname); my $user_quota_text; if (&Apache::lonnet::allowed('mpq',$ccdomain)) { # Current user has quota modification privileges @@ -840,7 +815,7 @@ ENDNOPORTPRIV if ($addrolesdisplay) { $r->print('
print(' onClick="verify_message(this.form)" \>'."\n"); + $r->print(' onClick="auth_check()" \>'."\n"); } else { $r->print('onClick="this.form.submit()" \>'."\n"); } @@ -897,26 +872,28 @@ sub validation_javascript { if ($context eq 'domain') { my $dcdom = $env{'request.role.domain'}; $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 { - $nondc_setsection_code = - &Apache::lonuserutils::setsections_javascript($formname,$groupslist); + my $checkauth; + 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, $nondc_setsection_code,$groupslist); - 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". - ''; + ''; return $js; } @@ -1241,22 +1218,9 @@ sub new_domain_roles { } sub user_authentication { - my ($ccuname,$ccdomain,$krbdefdom,$abv_auth) = @_; + my ($ccuname,$ccdomain,$formname) = @_; my $currentauth=&Apache::lonnet::queryauthenticate($ccuname,$ccdomain); - my ($loginscript,$outcome); - if ($currentauth=~/^(krb)(4|5):(.*)/) { - my $long_auth = $1.$2; - my $curr_kerb_ver = $2; - my $krbdefdom=$3; - my $curr_authtype = $abv_auth->{$long_auth}; - my %param = ( formname => 'document.cu', - kerb_def_dom => $krbdefdom, - domain => $ccdomain, - curr_authtype => $curr_authtype, - curr_kerb_ver => $curr_kerb_ver, - ); - $loginscript = &Apache::loncommon::authform_header(%param); - } + my $outcome; # Check for a bad authentication type if ($currentauth !~ /^(krb4|krb5|unix|internal|localauth):/) { # bad authentication scheme @@ -1268,7 +1232,8 @@ sub user_authentication { 'ld' => "Login Data" ); 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); $outcome = < @@ -1289,7 +1254,7 @@ $lt{'uuas'} ($currentauth). $lt{'adcs'}. ENDBADAUTH } } else { # Authentication type is valid - &initialize_authen_forms($ccdomain,$currentauth,'modifyuser'); + &initialize_authen_forms($ccdomain,$formname,$currentauth,'modifyuser'); my ($authformcurrent,$can_modify,@authform_others) = &modify_login_block($ccdomain,$currentauth); if (&Apache::lonnet::allowed('mau',$ccdomain)) { @@ -2029,6 +1994,7 @@ END } if ($env{'form.action'} eq 'singlestudent') { &enroll_single_student($r,$uhome,$amode,$genpwd,$now,$newuser); + $r->print('

'. &mt('Enroll Another Student').'

'); } else { my @rolechanges = &update_roles($r); if ($namechanged) { @@ -2046,6 +2012,9 @@ END } } } + my $userinfo = &Apache::loncommon::plainname($env{'form.ccuname'}, + $env{'form.ccdomain'}); + $r->print('

'.&mt('Modify this user: ([_1])',$userinfo).''.(' 'x5).''.&mt('Create/Modify Another User').'

'); } $r->print(&Apache::loncommon::end_page()); } @@ -3055,6 +3024,7 @@ sub print_main_menu { if (!exists($permission->{'cusr_section'})) { push(@courselinks, { text => 'Automated Student Enrollment Manager', + help => 'Course_Automated_Enrollment', permission => (&Apache::lonnet::auto_run($cnum,$cdom) && $permission->{'cusr'}), url => '/adm/populate',