--- loncom/interface/loncreateuser.pm 2002/02/08 19:40:42 1.24 +++ loncom/interface/loncreateuser.pm 2002/02/11 21:25:07 1.26 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Create a user # -# $Id: loncreateuser.pm,v 1.24 2002/02/08 19:40:42 matthew Exp $ +# $Id: loncreateuser.pm,v 1.26 2002/02/11 21:25:07 matthew Exp $ # # Copyright Michigan State University Board of Trustees # @@ -45,8 +45,9 @@ # April Guy Albertelli # 05/10,10/16 Gerd Kortemeyer # 11/12,11/13,11/15 Scott Harrison +# 02/11/02 Matthew Hall # -# $Id: loncreateuser.pm,v 1.24 2002/02/08 19:40:42 matthew Exp $ +# $Id: loncreateuser.pm,v 1.26 2002/02/11 21:25:07 matthew Exp $ ### package Apache::loncreateuser; @@ -206,7 +207,6 @@ ENDDOCUMENT } # =================================================================== Phase two - sub phase_two { my $r=shift; my $ccuname=$ENV{'form.ccuname'}; @@ -220,7 +220,7 @@ sub phase_two { $ccuname=~s/\W//g; $ccdomain=~s/\W//g; - $r->print(< The LearningOnline Network with CAPA @@ -250,19 +250,19 @@ sub phase_two { - -

Create User, Change User Privileges

-
- - - - - - - - - -ENDENHEAD + +ENDDOCHEAD + my $forminfo =<<"ENDFORMINFO"; + + + + + + + + + +ENDFORMINFO my $uhome=&Apache::lonnet::homeserver($ccuname,$ccdomain); my %incdomains; my %inccourses; @@ -275,19 +275,28 @@ ENDENHEAD } } if ($uhome eq 'no_host') { - $r->print(<New user $ccuname at $ccdomain -ENDNUSER - $r->print(<print(<Create New User +$forminfo +

New user "$ccuname" in domain $ccdomain

$loginscript

Personal Data

-First Name:
-Middle Name:
-Last Name:
-Generation:

+

+ + + + + + + + + +
First Name
Middle Name
Last Name
Generation
+ID/Student Number

-ID/Student Number:

+

Login Data

$generalrule @@ -295,33 +304,38 @@ $authformkrb $authformint $authformfsys $authformloc -ENDNUSER - } else { - $r->print('

Existing user '.$ccuname.' at '.$ccdomain.'

'); - +ENDNEWUSER + } else { # user already exists + $r->print(<Change User Privileges +$forminfo +

User "$ccuname" in domain $ccdomain

+ENDCHANGEUSER my $rolesdump=&Apache::lonnet::reply( "dump:$ccdomain:$ccuname:roles",$uhome); - unless ($rolesdump eq 'con_lost') { + # Build up table of user roles to allow revocation of a role. + unless ($rolesdump eq 'con_lost' || $rolesdump =~ m/^error/i) { my $now=time; - $r->print('

Revoke Existing Roles

'. + $r->print('

Revoke Existing Roles

'. ''. - ''); + ''); foreach (split(/&/,$rolesdump)) { if ($_!~/^rolesdef\&/) { - my ($area,$role)=split(/=/,$_); my $thisrole=$area; $area=~s/\_\w\w$//; - my ($trole,$tend,$tstart)=split(/_/,$role); + 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'.$trole,$1.'/'.$2)) { + 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); @@ -331,34 +345,32 @@ ENDNUSER $area=$carea; } else { if ($area=~/^\/(\w+)\//) { - if (&Apache::lonnet::allowed('c'.$trole,$1)) { + if (&Apache::lonnet::allowed('c'.$role_code,$1)) { $allows=1; } } else { - if (&Apache::lonnet::allowed('c'.$trole,'/')) { + if (&Apache::lonnet::allowed('c'.$role_code,'/')) { $allows=1; } } } + $r->print('\n"); + ($role_start_time ? localtime($role_start_time) + : ' ' ) + .'\n"); } } $r->print('
RevokeRoleExtentStartEndStartEnd
'); my $active=1; - if (($tend) && ($now>$tend)) { $active=0; } - - $r->print('
'); - if ($active) { - if ($allows) { - $r->print( - ''); - } else { - $r->print(' '); - } + if (($role_end_time) && ($now>$role_end_time)) { $active=0; } + if (!($active) && ($allows)) { + $r->print(''); } else { $r->print(' '); } - $r->print(''.&Apache::lonnet::plaintext($trole). + $r->print(''.&Apache::lonnet::plaintext($role_code). ''.$area.''. - ($tstart?localtime($tstart):' ').''. - ($tend?localtime($tend):' ')."
'. + ($role_end_time ? localtime($role_end_time) + : ' ' ) + ."
'); @@ -369,18 +381,14 @@ ENDNUSER my $krbdefdom2=$1; $loginscript=~s/vf\.krbdom\.value='.*?';/vf.krbdom.value='$krbdefdom2';/; } - # minor script hack here -# $loginscript=~s/login\[3\]/login\[4\]/; # loc -# $loginscript=~s/login\[2\]/login\[3\]/; # fsys -# $loginscript=~s/login\[1\]/login\[2\]/; # int -# $loginscript=~s/login\[0\]/login\[1\]/; # krb4 - + # Check for a bad authentication type unless ($currentauth=~/^krb4:/ or $currentauth=~/^unix:/ or $currentauth=~/^internal:/ or $currentauth=~/^localauth:/ - ) { - $r->print(<print(< $loginscript ERROR: @@ -392,14 +400,25 @@ $authformkrb $authformint $authformfsys $authformloc -END - } - else { +ENDBADAUTH + } else { + # This user is not allowed to modify the users + # authentication scheme, so just notify them of the problem + $r->print(< +$loginscript + ERROR: +This user has an unrecognized authentication scheme ($currentauth). +Please alert a domain coordinator of this situation. +
+ENDBADAUTH + } + } else { # Authentication type is valid my $authformcurrent=''; - my $authformother=''; + my $authform_other=''; if ($currentauth=~/^krb4:/) { $authformcurrent=$authformkrb; - $authformother=$authformint.$authformfsys.$authformloc; + $authform_other=$authformint.$authformfsys.$authformloc; # embarrassing script hack here $loginscript=~s/login\[3\]/login\[4\]/; # loc $loginscript=~s/login\[2\]/login\[3\]/; # fsys @@ -408,7 +427,7 @@ END } elsif ($currentauth=~/^internal:/) { $authformcurrent=$authformint; - $authformother=$authformkrb.$authformfsys.$authformloc; + $authform_other=$authformkrb.$authformfsys.$authformloc; # embarrassing script hack here $loginscript=~s/login\[3\]/login\[4\]/; # loc $loginscript=~s/login\[2\]/login\[3\]/; # fsys @@ -417,7 +436,7 @@ END } elsif ($currentauth=~/^unix:/) { $authformcurrent=$authformfsys; - $authformother=$authformkrb.$authformint.$authformloc; + $authform_other=$authformkrb.$authformint.$authformloc; # embarrassing script hack here $loginscript=~s/login\[3\]/login\[4\]/; # loc $loginscript=~s/login\[1\]/login\[3\]/; # int @@ -426,7 +445,7 @@ END } elsif ($currentauth=~/^localauth:/) { $authformcurrent=$authformloc; - $authformother=$authformkrb.$authformint.$authformfsys; + $authform_other=$authformkrb.$authformint.$authformfsys; # embarrassing script hack here $loginscript=~s/login\[3\]/login\[loc\]/; # loc $loginscript=~s/login\[2\]/login\[4\]/; # fsys @@ -434,7 +453,7 @@ END $loginscript=~s/login\[0\]/login\[2\]/; # krb4 $loginscript=~s/login\[loc\]/login\[1\]/; # loc } - $authformcurrent=< * * * WARNING * * * @@ -443,8 +462,10 @@ END $authformcurrent Changing this value will overwrite existing authentication for the user; you should notify the user of this change. -END - $r->print(<print(< $loginscript

Change Current Login Data

@@ -452,10 +473,11 @@ $generalrule $authformnop $authformcurrent

Enter New Login Data

-$authformother -END - } - } +$authform_other +ENDOTHERAUTHS + } + } ## End of "check for bad authentication type" logic + } ## End of new user/old user logic $r->print('

Add Roles

'); # # Co-Author @@ -513,49 +535,12 @@ ENDDROW # # Course level # - $r->print('

Course Level

'. - ''. - ''); - foreach (sort( keys(%inccourses))) { - my $thiscourse=$_; - my $protectedcourse=$_; - $thiscourse=~s:_:/:g; - my %coursedata=&Apache::lonnet::coursedescription($thiscourse); - my $area=$coursedata{'description'}; - my $bgcol=$thiscourse; - $bgcol=~s/[^8-9b-e]//g; - $bgcol=substr($bgcol.$bgcol.$bgcol.'ffffff',0,6); - foreach ('st','ta','ep','ad','in','cc') { - if (&Apache::lonnet::allowed('c'.$_,$thiscourse)) { - my $plrole=&Apache::lonnet::plaintext($_); - $r->print(" - - - - - - - -ENDROW - } - } - } - $r->print('
ActivateRoleExtentGroup/SectionStartEnd
$plrole$area"); - if ($_ ne 'cc') { - $r->print(""); - } else { $r->print(" "); } - $r->print(< -Set Start Date -Set End Date
'); - $r->print(''); - $r->print(''); + $r->print(&course_level_table(%inccourses)); + $r->print("
\n"); + $r->print(""); } # ================================================================= Phase Three - sub phase_three { my $r=shift; $r->print(< + +$plrole +$area +ENDEXTENT + if ($_ ne 'cc') { + $table .= < +ENDSECTION + } else { + $table .= <  +ENDSECTION + } + $table .= < +Set Start Date + +Set End Date +ENDTIMEENTRY + $table.= "\n"; + } + } + } + return '' if ($table eq ''); # return nothing if there is nothing + # in the table + my $result = <Course Level + + +$table +
ActivateRoleExtentGroup/SectionStartEnd
+ENDTABLE + return $result; +} + 1; __END__