--- loncom/interface/loncreateuser.pm 2002/06/05 18:11:15 1.36 +++ loncom/interface/loncreateuser.pm 2002/08/22 21:05:25 1.41 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Create a user # -# $Id: loncreateuser.pm,v 1.36 2002/06/05 18:11:15 matthew Exp $ +# $Id: loncreateuser.pm,v 1.41 2002/08/22 21:05:25 albertel 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.36 2002/06/05 18:11:15 matthew Exp $ +# $Id: loncreateuser.pm,v 1.41 2002/08/22 21:05:25 albertel Exp $ ### package Apache::loncreateuser; @@ -87,13 +87,14 @@ sub phase_one { my $defdom=$ENV{'user.domain'}; my @domains = &Apache::loncommon::get_domains(); my $domform = &Apache::loncommon::select_dom_form($defdom,'ccdomain'); + my $bodytag =&Apache::loncommon::bodytag( + 'Create Users, Change User Privileges'); $r->print(<<"ENDDOCUMENT"); The LearningOnline Network with CAPA - -

Create User, Change User Privileges

+$bodytag

@@ -154,9 +155,9 @@ sub phase_two { - - ENDDOCHEAD + $r->print(&Apache::loncommon::bodytag( + 'Create Users, Change User Privileges')); my $forminfo =<<"ENDFORMINFO"; @@ -250,71 +251,86 @@ END my ($tmp) = keys(%rolesdump); unless ($tmp =~ /^(con_lost|error)/i) { my $now=time; - $r->print('


Revoke Existing Roles

'. - ''. - ''); + $r->print(< +

Revoke Existing Roles

+
RevokeRoleExtentStartEnd
+ +END 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+)/) { + next 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 $allowed=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)) { + $allowed=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; - } - } else { - if (&Apache::lonnet::allowed('c'.$role_code,'/')) { - $allows=1; - } - } - } - $r->print('\n"); - } + } + $area=$carea; + } else { + # Determine if current user is able to revoke privileges + if ($area=~ /^\/(\w+)\//) { + if (&Apache::lonnet::allowed('c'.$role_code,$1)) { + $allowed=1; + } + } else { + if (&Apache::lonnet::allowed('c'.$role_code,'/')) { + $allowed=1; + } + } + } + # I have no idea what the hell the above code does + # So the following is a check: + if ($allowed) { + # If we are looking at a co-author role, make sure it is + # for the current users construction space before we let + # them revoke it. + if (($role_code eq 'ca') && + ($ENV{'request.role'} !~ /^dc/)) { + if ($area !~ + /^\/$ENV{'user.domain'}\/$ENV{'user.name'}/) { + $allowed = 0; + } + } + } + my $row = ''; + $row.='\n"; + $r->print($row); } # end of foreach (table building loop) $r->print('
RevokeRoleExtentStartEnd
'); - 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) - : ' ' ) - ."
'; + my $active=1; + $active=0 if (($role_end_time) && ($now>$role_end_time)); + if (($active) && ($allowed)) { + $row.= ''; + } else { + $row.=' '; + } + $row.= ''.&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:(.*)/; + if ($currentauth=~/^krb(4|5):/) { + $currentauth=~/^krb(4|5):(.*)/; my $krbdefdom2=$1; my %param = ( formname => 'document.cu', kerb_def_dom => $krbdefdom @@ -322,7 +338,7 @@ END $loginscript = &Apache::loncommon::authform_header(%param); } # Check for a bad authentication type - unless ($currentauth=~/^krb4:/ or + unless ($currentauth=~/^krb(4|5):/ or $currentauth=~/^unix:/ or $currentauth=~/^internal:/ or $currentauth=~/^localauth:/ @@ -360,7 +376,7 @@ ENDBADAUTH } else { # Authentication type is valid my $authformcurrent=''; my $authform_other=''; - if ($currentauth=~/^krb4:/) { + if ($currentauth=~/^krb(4|5):/) { $authformcurrent=$authformkrb; $authform_other="

$authformint

\n". "

$authformfsys

$authformloc

"; @@ -483,9 +499,14 @@ sub phase_three { The LearningOnline Network with CAPA - - ENDTHREEHEAD + my $title; + if (exists($ENV{'form.makeuser'})) { + $title='Set Privileges for New User'; + } else { + $title='Modify User Privileges'; + } + $r->print(&Apache::loncommon::bodytag($title)); # Check Inputs if (! $ENV{'form.ccuname'} ) { $r->print($error.'No login name specified.'.$end); @@ -520,7 +541,8 @@ ENDTHREEHEAD my $amode=''; my $genpwd=''; if ($ENV{'form.login'} eq 'krb') { - $amode='krb4'; + $amode='krb'; + $amode.=$ENV{'form.krbver'}; $genpwd=$ENV{'form.krbarg'}; } elsif ($ENV{'form.login'} eq 'int') { $amode='internal'; @@ -545,7 +567,6 @@ ENDTHREEHEAD if ($ENV{'form.makeuser'}) { # Create a new user $r->print(<Create User

Creating user "$ENV{'form.ccuname'}" in domain "$ENV{'form.ccdomain'}"

ENDNEWUSERHEAD # Check for the authentication mode and password @@ -558,7 +579,7 @@ ENDNEWUSERHEAD if (lc($desiredhost) eq 'default') { $desiredhost = undef; } else { - my %home_servers = &Apache::loncommon::get_home_servers + my %home_servers = &Apache::loncommon::get_library_servers ($ENV{'form.ccdomain'}); if (! exists($home_servers{$desiredhost})) { $r->print($error.'Invalid home server specified'); @@ -581,7 +602,6 @@ ENDNEWUSERHEAD ($ENV{'form.login'} ne '' )) { # Modify user privileges $r->print(<Change User Privileges

User "$ENV{'form.ccuname'}" in domain "$ENV{'form.ccdomain'}"

ENDMODIFYUSERHEAD if (! $amode || ! $genpwd) {