--- loncom/interface/loncreateuser.pm 2007/10/03 13:45:58 1.184.2.1
+++ 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.184.2.1 2007/10/03 13:45:58 albertel 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);
@@ -420,10 +423,32 @@ sub print_user_query_page {
sub print_user_modification_page {
my ($r,$ccuname,$ccdomain,$srch,$response) = @_;
- unless (($ccuname) && ($ccdomain)) {
- &print_username_entry_form($r);
+ if (($ccuname eq '') || ($ccdomain eq '')) {
+ my $usermsg = &mt('No username and/or domain provided.');
+ &print_username_entry_form($r,$usermsg);
return;
}
+ my ($curr_authtype,$instsrch,$rulematch,$rules,%inst_results);
+ my $uhome=&Apache::lonnet::homeserver($ccuname,$ccdomain);
+ if ($uhome eq 'no_host') {
+ $instsrch =
+ {
+ srchin => 'instd',
+ srchby => 'uname',
+ srchtype => 'exact',
+ srchterm => $ccuname,
+ srchdomain => $ccdomain,
+ };
+ (my $usercheckmsg,$rulematch,$rules,%inst_results) =
+ &Apache::loncommon::username_rule_check($instsrch,'new');
+ if ($usercheckmsg) {
+ &print_username_entry_form($r,$usercheckmsg);
+ return;
+ }
+ } else {
+ $curr_authtype =
+ &Apache::lonnet::queryauthenticate($ccuname,$ccdomain);
+ }
if ($response) {
$response = '
-
'.$response
}
@@ -434,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);
@@ -675,7 +702,6 @@ ENDSECCODE
ENDFORMINFO
- my $uhome=&Apache::lonnet::homeserver($ccuname,$ccdomain);
my %inccourses;
foreach my $key (keys(%env)) {
if ($key=~/^user\.priv\.cm\.\/($match_domain)\/($match_username)/) {
@@ -683,99 +709,136 @@ ENDFORMINFO
}
}
if ($uhome eq 'no_host') {
- my $newuser;
- my $instsrch = {
- srchin => 'instd',
- srchby => 'uname',
- srchtype => 'exact',
- };
- if ($env{'form.phase'} eq 'userpicked') {
- $instsrch->{'srchterm'} = $env{'form.seluname'};
- $instsrch->{'srchdomain'} = $env{'form.seludom'};
- } else {
- $instsrch->{'srchterm'} = $ccuname;
- $instsrch->{'srchdomain'} = $ccdomain,
- }
- if (($instsrch->{'srchterm'} ne '') && ($instsrch->{'srchdomain'} ne '')) {
- $newuser = $instsrch->{'srchterm'}.':'.$instsrch->{'srchdomain'};
- }
- my (%dirsrch_results,%inst_results,$dirsrchres);
- if ($newuser) {
- if (&directorysrch_check($instsrch) eq 'ok') {
- ($dirsrchres,%dirsrch_results) = &Apache::lonnet::inst_directory_query($instsrch);
- if ($dirsrchres eq 'ok') {
- if (ref($dirsrch_results{$newuser}) eq 'HASH') {
- %inst_results = %{$dirsrch_results{$newuser}};
- }
- }
- }
- }
- my $home_server_list=
- ''."\n".
- &Apache::loncommon::home_server_option_list($ccdomain);
-
my %lt=&Apache::lonlocal::texthash(
- 'cnu' => "Create New User",
- 'nu' => "New User",
- 'id' => "in domain",
- 'pd' => "Personal Data",
- 'fn' => "First Name",
- 'mn' => "Middle Name",
- 'ln' => "Last Name",
- 'gen' => "Generation",
- 'mail' => "Permanent e-mail address",
- 'idsn' => "ID/Student Number",
- 'hs' => "Home Server",
- 'lg' => "Login Data"
+ '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;
if (&Apache::lonnet::allowed('mpq',$env{'request.role.domain'})) {
# Current user has quota modification privileges
$portfolioform = &portfolio_quota($ccuname,$ccdomain);
}
my $genhelp=&Apache::loncommon::help_open_topic('Generation');
- &initialize_authen_forms();
- $r->print(<$lt{'nu'} "$ccuname" $lt{'id'} $ccdomain
+$lt{'cnu'} "$ccuname" $lt{'ind'} $ccdomain
$lt{'pd'}
-
-$lt{'idsn'}
-$lt{'fn'}
-
-$lt{'mn'}
-
-$lt{'ln'}
-
-$lt{'gen'}$genhelp
-
-$lt{'mail'}
-
$generalrule
-$authformkrb
-$authformint
-$authformfsys
-$authformloc
+ENDTITLE + $r->print(&Apache::lonhtmlcommon::start_pick_box()); + foreach my $item (@userinfo) { + my $rowtitle = $lt{$item}; + 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(''.$inst_results{$item}); + } else { + $r->print(''); + } + $r->print(&Apache::lonhtmlcommon::row_closure(1)); + } + $r->print(&Apache::lonhtmlcommon::end_pick_box()); + my ($home_server_pick,$numlib) = + &Apache::loncommon::home_server_form_item($ccdomain,'hserver', + 'default','hide'); + if ($numlib > 1) { + $r->print(" +$generalrule
-$authformnop
-$authformcurrent
-$authformnop ENDOTHERAUTHS + if ($can_modify) { + $r->print('
'.$authformcurrent.'
'); + } else { + $r->print(' ('.$authformcurrent.')'); + } + if ($authform_other ne '') { + $r->print('$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'). + '