--- loncom/interface/loncreateuser.pm 2002/02/12 21:42:18 1.27 +++ loncom/interface/loncreateuser.pm 2002/03/22 22:23:23 1.28 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Create a user # -# $Id: loncreateuser.pm,v 1.27 2002/02/12 21:42:18 matthew Exp $ +# $Id: loncreateuser.pm,v 1.28 2002/03/22 22:23:23 matthew Exp $ # # Copyright Michigan State University Board of Trustees # @@ -47,7 +47,7 @@ # 11/12,11/13,11/15 Scott Harrison # 02/11/02 Matthew Hall # -# $Id: loncreateuser.pm,v 1.27 2002/02/12 21:42:18 matthew Exp $ +# $Id: loncreateuser.pm,v 1.28 2002/03/22 22:23:23 matthew Exp $ ### package Apache::loncreateuser; @@ -295,9 +295,7 @@ $loginscript ID/Student Number

-
-

Login Data

$generalrule $authformkrb @@ -312,71 +310,98 @@ $dochead $forminfo

User "$ccuname" in domain $ccdomain

ENDCHANGEUSER - my $rolesdump=&Apache::lonnet::reply( - "dump:$ccdomain:$ccuname:roles",$uhome); + # Get the users information + my %userenv = &Apache::lonnet::get('environment', + ['firstname','middlename','lastname','generation'], + $ccdomain,$ccuname); + my %rolesdump=&Apache::lonnet::dump('roles',$ccdomain,$ccuname); + $r->print(< + + + + + +END + foreach ('firstname','middlename','lastname','generation') { + if (&Apache::lonnet::allowed('mau',$ccdomain)) { + $r->print(<<"END"); + +END + } else { + $r->print(''); + } + } + $r->print(< +
first namemiddle namelast namegeneration
'.$userenv{$_}.'
+END # Build up table of user roles to allow revocation of a role. - unless ($rolesdump eq 'con_lost' || $rolesdump =~ m/^error/i) { + my ($tmp) = keys(%rolesdump); + unless ($tmp =~ /^(con_lost|error)/i) { my $now=time; $r->print('

Revoke Existing Roles

'. ''. ''); - foreach (split(/&/,$rolesdump)) { - if ($_!~/^rolesdef\&/) { - my ($area,$role)=split(/=/,$_); - my $thisrole=$area; - $area=~s/\_\w\w$//; - my ($role_code,$role_end_time,$role_start_time)=split(/_/,$role); - my $bgcol='ffffff'; - my $allows=0; - if ($area=~/^\/(\w+)\/(\d\w+)/) { - my %coursedata=&Apache::lonnet::coursedescription($1.'_'.$2); - my $carea='Course: '.$coursedata{'description'}; - $inccourses{$1.'_'.$2}=1; - if (&Apache::lonnet::allowed('c'.$role_code,$1.'/'.$2)) { - $allows=1; - } - # Compute the background color based on $area - $bgcol=$1.'_'.$2; - $bgcol=~s/[^8-9b-e]//g; - $bgcol=substr($bgcol.$bgcol.$bgcol.'ffffff',0,6); - if ($area=~/^\/(\w+)\/(\d\w+)\/(\w+)/) { - $carea.='
Section/Group: '.$3; - } - $area=$carea; - } else { - # Determine if current user is able to revoke privileges - if ($area=~/^\/(\w+)\//) { - if (&Apache::lonnet::allowed('c'.$role_code,$1)) { - $allows=1; - } + foreach my $area (keys(%rolesdump)) { + if ($area!~/^rolesdef/) { + my $role = $rolesdump{$area}; + my $thisrole=$area; + $area=~s/\_\w\w$//; + my ($role_code,$role_end_time,$role_start_time) = + split(/_/,$role); + my $bgcol='ffffff'; + my $allows=0; + if ($area=~/^\/(\w+)\/(\d\w+)/) { + my %coursedata= + &Apache::lonnet::coursedescription($1.'_'.$2); + my $carea='Course: '.$coursedata{'description'}; + $inccourses{$1.'_'.$2}=1; + if (&Apache::lonnet::allowed('c'.$role_code,$1.'/'.$2)) { + $allows=1; + } + # Compute the background color based on $area + $bgcol=$1.'_'.$2; + $bgcol=~s/[^8-9b-e]//g; + $bgcol=substr($bgcol.$bgcol.$bgcol.'ffffff',0,6); + if ($area=~/^\/(\w+)\/(\d\w+)\/(\w+)/) { + $carea.='
Section/Group: '.$3; + } + $area=$carea; } else { - if (&Apache::lonnet::allowed('c'.$role_code,'/')) { - $allows=1; + # Determine if current user is able to revoke privileges + if ($area=~/^\/(\w+)\//) { + if (&Apache::lonnet::allowed('c'.$role_code,$1)) { + $allows=1; + } + } else { + if (&Apache::lonnet::allowed('c'.$role_code,'/')) { + $allows=1; + } } } - } - - $r->print('\n"); } - $r->print('\n"); - } - } + } # end of foreach (table building loop) $r->print('
RevokeRoleExtentStartEnd
'); - my $active=1; - if (($role_end_time) && ($now>$role_end_time)) { $active=0; } - if (($active) && ($allows)) { - $r->print(''); - } else { - $r->print(' '); + $r->print('
'); + my $active=1; + $active=0 if (($role_end_time) && ($now>$role_end_time)); + if (($active) && ($allows)) { + $r->print(''); + } else { + $r->print(' '); + } + $r->print(''. + &Apache::lonnet::plaintext($role_code). + ''.$area.''. + ($role_start_time ? localtime($role_start_time) + : ' ' ) + .''. + ($role_end_time ? localtime($role_end_time) + : ' ' ) + ."
'.&Apache::lonnet::plaintext($role_code). - ''.$area.''. - ($role_start_time ? localtime($role_start_time) - : ' ' ) - .''. - ($role_end_time ? localtime($role_end_time) - : ' ' ) - ."
'); - } + } # End of unless my $currentauth=&Apache::lonnet::queryauthenticate($ccuname,$ccdomain); if ($currentauth=~/^krb4:/) { $currentauth=~/^krb4:(.*)/; @@ -641,6 +666,72 @@ ENDMODIFYUSERHEAD } } ## + if (! $ENV{'form.makeuser'} ) { + # Check for need to change + my %userenv = &Apache::lonnet::get + ('environment',['firstname','middlename','lastname','generation'], + $ENV{'form.cdomain'},$ENV{'form.cuname'}); + my ($tmp) = keys(%userenv); + if ($tmp =~ /^(con_lost|error)/i) { + %userenv = (); + } + # Check to see if we need to change user information + foreach ('firstname','middlename','lastname','generation') { + # Strip leading and trailing whitespace + $ENV{'form.c'.$_} =~ s/(\s+$|^\s+)//g; + } + if (&Apache::lonnet::allowed('mau',$ENV{'form.cdomain'}) && + ($ENV{'form.cfirstname'} ne $userenv{'firstname'} || + $ENV{'form.cmiddlename'} ne $userenv{'middlename'} || + $ENV{'form.clastname'} ne $userenv{'lastname'} || + $ENV{'form.cgeneration'} ne $userenv{'generation'} )) { + # Make the change + my %changeHash; + $changeHash{'firstname'} = $ENV{'form.cfirstname'}; + $changeHash{'middlename'} = $ENV{'form.cmiddlename'}; + $changeHash{'lastname'} = $ENV{'form.clastname'}; + $changeHash{'generation'} = $ENV{'form.cgeneration'}; + my $putresult = &Apache::lonnet::put + ('environment',\%changeHash, + $ENV{'form.cdomain'},$ENV{'form.cuname'}); + if ($putresult eq 'ok') { + # Tell the user we changed the name + $r->print(<<"END"); + + + + + + + + + + + + + + + + + +
User Information Changed
 firstmiddlelastgeneration
Previous$userenv{'firstname'} $userenv{'middlename'} $userenv{'lastname'} $userenv{'generation'}
Changed To$ENV{'form.cfirstname'} $ENV{'form.cmiddlename'} $ENV{'form.clastname'} $ENV{'form.cgeneration'}
+END + } else { # error occurred + $r->print("

Unable to successfully change environment for ". + $ENV{'form.cuname'}." in domain ". + $ENV{'form.cdomain'}."

"); + } + } else { # End of if ($ENV ... ) logic + # They did not want to change the users name but we can + # still tell them what the name is + $r->print(<<"END"); +

User "$ENV{'form.cuname'}" in domain "$ENV{'form.cdomain'}"

+

$userenv{'firstname'} $userenv{'middlename'} $userenv{'lastname'}

+

Generation: $userenv{'generation'}

+END + } + } + ## my $now=time; $r->print('

Modifying Roles

'); foreach (keys (%ENV)) {