--- loncom/interface/loncreateuser.pm 2007/12/05 21:23:14 1.202 +++ loncom/interface/loncreateuser.pm 2007/12/06 04:03:35 1.203 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Create a user # -# $Id: loncreateuser.pm,v 1.202 2007/12/05 21:23:14 raeburn Exp $ +# $Id: loncreateuser.pm,v 1.203 2007/12/06 04:03:35 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -787,7 +787,7 @@ ENDCHANGEUSER &personal_data_display($ccuname,$ccdomain,$newuser, %inst_results)); if ($context eq 'domain') { - $r->print(&Apache::lonuserutils::forceid_change()); + $r->print(&Apache::lonuserutils::forceid_change($context)); } $r->print(''); my $user_auth_text = @@ -1591,17 +1591,23 @@ sub update_user_data { # Check to see if we need to change user information foreach my $item ('firstname','middlename','lastname','generation','permanentemail','id') { # Strip leading and trailing whitespace - $env{'form.c'.$item} =~ s/(\s+$|^\s+)//g; + $env{'form.c'.$item} =~ s/(\s+$|^\s+)//g; } # Check to see if we can change the ID/student number my $forceid = $env{'form.forceid'}; my $recurseid = $env{'form.recurseid'}; my $newuser = 0; - my $disallowed_id = 0; my (%alerts,%rulematch,%idinst_results,%curr_rules,%got_rules); - if (!$forceid) { - $env{'form.cid'} = $userenv{'id'}; - } elsif ($env{'form.cid'} ne $userenv{'id'}) { + my %uidhash = &Apache::lonnet::idrget($env{'form.ccdomain'}, + $env{'form.ccuname'}); + if (($uidhash{$env{'form.ccuname'}}) && + ($uidhash{$env{'form.ccuname'}}!~/error\:/) && + (!$forceid)) { + if ($env{'form.cid'} ne $uidhash{$env{'form.ccuname'}}) { + $env{'form.cid'} = $userenv{'id'}; + } + } + if ($env{'form.cid'} ne $userenv{'id'}) { my $checkhash; my $checks = { 'id' => 1 }; $checkhash->{$env{'form.ccuname'}.':'.$env{'form.ccdomain'}} = @@ -1612,7 +1618,7 @@ sub update_user_data { \%alerts,\%rulematch,\%idinst_results,\%curr_rules,\%got_rules); if (ref($alerts{'id'}) eq 'HASH') { if (ref($alerts{'id'}{$env{'form.ccdomain'}}) eq 'HASH') { - $disallowed_id = 1; + $env{'form.cid'} = $userenv{'id'}; } } } @@ -1739,18 +1745,24 @@ END END $r->print(&Apache::loncommon::end_data_table_row(). &Apache::loncommon::end_data_table()); - if (($forceid) && ($recurseid) && (!$disallowed_id) && - (&Apache::lonnet::allowed('mau',$env{'form.ccdomain'}))) { - my %userupdate = ( + if ($env{'form.cid'} ne $userenv{'id'}) { + &Apache::lonnet::idput($env{'form.ccdomain'}, + ($env{'form.ccuname'} => $env{'form.cid'})); + if (($recurseid) && + (&Apache::lonnet::allowed('mau',$env{'form.ccdomain'}))) { + my %userupdate = ( lastname => $env{'form.clasaname'}, middlename => $env{'form.cmiddlename'}, firstname => $env{'form.cfirstname'}, generation => $env{'fora.cgeneration'}, id => $env{'form.cid'}, ); - my $idresult = &propagate_id_change($env{'form.ccname'}, - $env{'form.ccdomain'},\%userupdate); - $r->print('
'.$idresult.'
'); + my $idresult = + &Apache::lonuserutils::propagate_id_change( + $env{'form.ccuname'},$env{'form.ccdomain'}, + \%userupdate); + $r->print('
'.$idresult.'
'); + } } if (($env{'form.ccdomain'} eq $env{'user.domain'}) && ($env{'form.ccuname'} eq $env{'user.name'})) {