--- loncom/interface/loncreateuser.pm 2007/09/18 23:57:15 1.186 +++ loncom/interface/loncreateuser.pm 2007/09/19 06:24:26 1.187 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Create a user # -# $Id: loncreateuser.pm,v 1.186 2007/09/18 23:57:15 raeburn Exp $ +# $Id: loncreateuser.pm,v 1.187 2007/09/19 06:24:26 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -68,7 +68,6 @@ use Apache::longroup; use LONCAPA qw(:DEFAULT :match); my $loginscript; # piece of javascript used in two separate instances -my $generalrule; my $authformnop; my $authformkrb; my $authformint; @@ -76,14 +75,18 @@ my $authformfsys; my $authformloc; sub initialize_authen_forms { + my ($dom,$curr_authtype) = @_; my ($krbdefdom)=( $ENV{'SERVER_NAME'}=~/(\w+\.\w+)$/); $krbdefdom= uc($krbdefdom); my %param = ( formname => 'document.cu', - kerb_def_dom => $krbdefdom - ); + kerb_def_dom => $krbdefdom, + domain => $dom, + ); + if ($curr_authtype =~ /^(krb4|krb5|internal|localauth|unix):$/) { + $param{'curr_authtype'} = $curr_authtype; + } # no longer static due to configurable kerberos defaults # $loginscript = &Apache::loncommon::authform_header(%param); - $generalrule = &Apache::loncommon::authform_authorwarning(%param); $authformnop = &Apache::loncommon::authform_nochange(%param); # no longer static due to configurable kerberos defaults # $authformkrb = &Apache::loncommon::authform_kerberos(%param); @@ -425,7 +428,7 @@ sub print_user_modification_page { &print_username_entry_form($r,$usermsg); return; } - my ($instsrch,$rulematch,$rules,%inst_results); + my ($curr_authtype,$instsrch,$rulematch,$rules,%inst_results); my $uhome=&Apache::lonnet::homeserver($ccuname,$ccdomain); if ($uhome eq 'no_host') { $instsrch = @@ -442,6 +445,9 @@ sub print_user_modification_page { &print_username_entry_form($r,$usercheckmsg); return; } + } else { + $curr_authtype = + &Apache::lonnet::queryauthenticate($ccuname,$ccdomain); } if ($response) { $response = '
'.$response @@ -453,7 +459,9 @@ sub print_user_modification_page { my %param = ( formname => 'document.cu', kerb_def_dom => $krbdefdom, - kerb_def_auth => $krbdef + kerb_def_auth => $krbdef, + curr_authtype => $curr_authtype, + domain => $ccdomain, ); $loginscript = &Apache::loncommon::authform_header(%param); $authformkrb = &Apache::loncommon::authform_kerberos(%param); @@ -701,10 +709,6 @@ ENDFORMINFO } } if ($uhome eq 'no_host') { - my $home_server_list= - ''."\n". - &Apache::loncommon::home_server_option_list($ccdomain); - my %lt=&Apache::lonlocal::texthash( 'cnu' => "Create New User", 'nu' => "New User", @@ -742,14 +746,13 @@ ENDFORMINFO $portfolioform = &portfolio_quota($ccuname,$ccdomain); } my $genhelp=&Apache::loncommon::help_open_topic('Generation'); - &initialize_authen_forms(); + &initialize_authen_forms($ccdomain); $r->print(<$lt{'cnu'} $response $forminfo -

$lt{'nu'} "$ccuname" $lt{'ind'} $ccdomain

+

$lt{'cnu'} "$ccuname" $lt{'ind'} $ccdomain

@@ -772,20 +775,25 @@ ENDTITLE $r->print(&Apache::lonhtmlcommon::row_closure(1)); } $r->print(&Apache::lonhtmlcommon::end_pick_box()); - $r->print(< -$lt{'hs'}: + my ($home_server_pick,$numlib) = + &Apache::loncommon::home_server_form_item($ccdomain,'hserver', + 'default','hide'); + if ($numlib > 1) { + $r->print("
-
-

$lt{'lg'}

-ENDNEWUSER +$lt{'hs'}: $home_server_pick +
"); + } else { + $r->print($home_server_pick); + } + $r->print("
\n".'

'.$lt{'lg'}.'

'); my ($fixedauth,$varauth,$authmsg); if ($rulematch) { if (ref($rules) eq 'HASH') { if (ref($rules->{$rulematch}) eq 'HASH') { my $authtype = $rules->{$rulematch}{'authtype'}; if ($authtype !~ /^(krb4|krb5|int|fsys|loc)$/) { - $r->print(&set_login()); + $r->print(&set_login($ccdomain)); } else { my $authparm = $rules->{$rulematch}{'authparm'}; if ($authtype =~ /^krb(4|5)$/) { @@ -811,7 +819,7 @@ KERB } } } else { - $r->print(&set_login()); + $r->print(&set_login($ccdomain)); } } if ($authmsg) { @@ -822,16 +830,15 @@ $varauth ENDAUTH } } else { - $r->print(&set_login()); - } - $r->print(<print(&set_login($ccdomain)); + } + $r->print(< $portfolioform ENDPORT } else { # user already exists my %lt=&Apache::lonlocal::texthash( - 'cup' => "Change User Privileges", - 'usr' => "User", + 'cup' => "Change User Privileges for", 'id' => "in domain", 'fn' => "first name", 'mn' => "middle name", @@ -842,9 +849,8 @@ ENDPORT $r->print(<$lt{'cup'} $forminfo -

$lt{'usr'} "$ccuname" $lt{'id'} "$ccdomain"

+

$lt{'cup'} "$ccuname" $lt{'id'} "$ccdomain"

ENDCHANGEUSER # Get the users information my %userenv = @@ -1065,21 +1071,24 @@ END $currentauth=~/^krb(4|5):(.*)/; my $krbdefdom=$2; my %param = ( formname => 'document.cu', - kerb_def_dom => $krbdefdom + 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 ($currentauth !~ /^(krb4|krb5|unix|internal|localauth):/) { + # bad authentication scheme if (&Apache::lonnet::allowed('mau',$ccdomain)) { - &initialize_authen_forms(); + &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(<

$lt{'ccld'}

-

$generalrule

-

$authformnop

-

$authformcurrent

-

$lt{'enld'}

-$authform_other +

$authformnop ENDOTHERAUTHS + if ($can_modify) { + $r->print('

'.$authformcurrent.'

'); + } else { + $r->print(' ('.$authformcurrent.')

'); + } + if ($authform_other ne '') { + $r->print('

'.$lt{'enld'}.'

'."\n". + $authform_other); + } } else { if (&Apache::lonnet::allowed('mau',$env{'request.role.domain'})) { my %lt=&Apache::lonlocal::texthash( @@ -1170,7 +1161,7 @@ ENDNOPRIV 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'})) { + } 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.", @@ -1295,16 +1286,85 @@ ENDNOPORTPRIV } sub set_login { - my $response = (<$generalrule

-

$authformkrb

-

$authformint

-

$authformfsys

-

$authformloc

-ENDAUTH + my ($dom) = @_; + my %domconfig = &Apache::lonnet::get_dom('configuration',['usercreation'],$dom); + my $response; + my ($authnum,%can_assign) = + &Apache::loncommon::get_assignable_auth($dom); + if (($can_assign{'krb4'}) || ($can_assign{'krb5'})) { + $response .= "

$authformkrb

\n"; + } + if ($can_assign{'int'}) { + $response .= "

$authformint

\n" + } + if ($can_assign{'loc'}) { + $response .= "

$authformloc

\n"; + } return $response; } +sub modify_login_block { + my ($dom,$currentauth) = @_; + my %domconfig = &Apache::lonnet::get_dom('configuration',['usercreation'],$dom); + my ($authnum,%can_assign) = + &Apache::loncommon::get_assignable_auth($dom); + my ($authformcurrent,$authform_other,$show_override_msg); + if ($currentauth=~/^krb(4|5):/) { + $authformcurrent=$authformkrb; + if ($can_assign{'int'}) { + $authform_other = "

$authformint

\n" + } + if ($can_assign{'loc'}) { + $authform_other .= "

$authformloc

\n"; + } + if (($can_assign{'krb4'}) || ($can_assign{'krb5'})) { + $show_override_msg = 1; + } + } elsif ($currentauth=~/^internal:/) { + $authformcurrent=$authformint; + if (($can_assign{'krb4'}) || ($can_assign{'krb5'})) { + $authform_other = "

$authformkrb

\n" + } + if ($can_assign{'loc'}) { + $authform_other .= "

$authformloc

\n"; + } + if ($can_assign{'int'}) { + $show_override_msg = 1; + } + } elsif ($currentauth=~/^unix:/) { + $authformcurrent=$authformfsys; + if (($can_assign{'krb4'}) || ($can_assign{'krb5'})) { + $authform_other = "

$authformkrb

\n" + } + if ($can_assign{'int'}) { + $authform_other .= "

$authformint

\n" + } + if ($can_assign{'loc'}) { + $authform_other .= "

$authformloc

\n"; + } + if ($can_assign{'fsys'}) { + $show_override_msg = 1; + } + } elsif ($currentauth=~/^localauth:/) { + $authformcurrent=$authformloc; + if (($can_assign{'krb4'}) || ($can_assign{'krb5'})) { + $authform_other = "

$authformkrb

\n" + } + if ($can_assign{'int'}) { + $authform_other .= "

$authformint

\n" + } + if ($can_assign{'loc'}) { + $show_override_msg = 1; + } + } + if ($show_override_msg) { + $authformcurrent.= ' '. + &mt('will override current values'). + '
'; + } + return ($authformcurrent,$authform_other,$show_override_msg); +} + # ================================================================= Phase Three sub update_user_data { my ($r) = @_;