ENDNEWUSER
} else { # user already exists
$r->print(<print('
Revoke Existing Roles
'.
- '
Revoke
Role
Extent
'.
- '
Start
End
');
+ $r->print(<
+
Revoke Existing Roles
+
+
Revoke
Role
Extent
Start
End
+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('
');
- my $active=1;
- $active=0 if (($role_end_time) && ($now>$role_end_time));
- if (($active) && ($allows)) {
- $r->print('');
- } else {
- $r->print(' ');
- }
- $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{'request.role.domain'}\/$ENV{'user.name'}/) {
+ $allowed = 0;
+ }
+ }
+ }
+ my $row = '';
+ $row.='
\n";
+ $r->print($row);
} # end of foreach (table building loop)
$r->print('
');
} # 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;
- $loginscript=~s/vf\.krbdom\.value='.*?';/vf.krbdom.value='$krbdefdom2';/;
+ my %param = ( formname => 'document.cu',
+ kerb_def_dom => $krbdefdom
+ );
+ $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:/
) { # bad authentication scheme
- if (&Apache::lonnet::allowed('mau',$ENV{'user.domain'})) {
+ if (&Apache::lonnet::allowed('mau',$ENV{'request.role.domain'})) {
$r->print(<
+
ERROR:
This user has an unrecognized authentication scheme ($currentauth).
Please specify login data below.
ENDBADAUTH
} else {
# This user is not allowed to modify the users
# authentication scheme, so just notify them of the problem
$r->print(<
+
ERROR:
This user has an unrecognized authentication scheme ($currentauth).
Please alert a domain coordinator of this situation.
@@ -450,42 +375,25 @@ ENDBADAUTH
} else { # Authentication type is valid
my $authformcurrent='';
my $authform_other='';
- if ($currentauth=~/^krb4:/) {
+ if ($currentauth=~/^krb(4|5):/) {
$authformcurrent=$authformkrb;
- $authform_other=$authformint.$authformfsys.$authformloc;
- # embarrassing 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
+ $authform_other="
Changing this value will overwrite existing authentication for the user; you should notify the user of this change.
ENDCURRENTAUTH
- if (&Apache::lonnet::allowed('mau',$ENV{'user.domain'})) {
+ if (&Apache::lonnet::allowed('mau',$ENV{'request.role.domain'})) {
# Current user has login modification privileges
$r->print(<
+
Change Current Login Data
-$generalrule
-$authformnop
-$authformcurrent
+
$generalrule
+
$authformnop
+
$authformcurrent
Enter New Login Data
$authform_other
ENDOTHERAUTHS
@@ -516,10 +426,9 @@ ENDOTHERAUTHS
#
# Co-Author
#
-
- if (&Apache::lonnet::allowed('cca',$ENV{'user.domain'})) {
+ if (&Apache::lonnet::allowed('cca',$ENV{'request.role.domain'})) {
my $cuname=$ENV{'user.name'};
- my $cudom=$ENV{'user.domain'};
+ my $cudom=$ENV{'request.role.domain'};
$r->print(<Construction Space
Activate
Role
Extent
@@ -575,7 +484,7 @@ ENDDROW
}
# ================================================================= Phase Three
-sub phase_three {
+sub update_user_data {
my $r=shift;
my $uhome=&Apache::lonnet::homeserver($ENV{'form.ccuname'},
$ENV{'form.ccdomain'});
@@ -625,18 +534,28 @@ ENDTHREEHEAD
my $amode='';
my $genpwd='';
if ($ENV{'form.login'} eq 'krb') {
- $amode='krb4';
- $genpwd=$ENV{'form.krbdom'};
+ $amode='krb';
+ $amode.=$ENV{'form.krbver'};
+ $genpwd=$ENV{'form.krbarg'};
} elsif ($ENV{'form.login'} eq 'int') {
$amode='internal';
- $genpwd=$ENV{'form.intpwd'};
+ $genpwd=$ENV{'form.intarg'};
} elsif ($ENV{'form.login'} eq 'fsys') {
$amode='unix';
- $genpwd=$ENV{'form.fsyspwd'};
+ $genpwd=$ENV{'form.fsysarg'};
} elsif ($ENV{'form.login'} eq 'loc') {
$amode='localauth';
$genpwd=$ENV{'form.locarg'};
$genpwd=" " if (!$genpwd);
+ } elsif (($ENV{'form.login'} eq 'nochange') ||
+ ($ENV{'form.login'} eq '' )) {
+ # There is no need to tell the user we did not change what they
+ # did not ask us to change.
+ # If they are creating a new user but have not specified login
+ # information this will be caught below.
+ } else {
+ $r->print($error.'Invalid login mode or password'.$end);
+ return;
}
if ($ENV{'form.makeuser'}) {
# Create a new user
@@ -654,7 +573,8 @@ ENDNEWUSERHEAD
if (lc($desiredhost) eq 'default') {
$desiredhost = undef;
} else {
- my %home_servers = &get_home_servers($ENV{'form.ccdomain'});
+ my %home_servers = &Apache::loncommon::get_library_servers
+ ($ENV{'form.ccdomain'});
if (! exists($home_servers{$desiredhost})) {
$r->print($error.'Invalid home server specified');
return;
@@ -672,7 +592,8 @@ ENDNEWUSERHEAD
$ENV{'form.ccdomain'});
$r->print(' Home server: '.$home.' '.
$Apache::lonnet::libserv{$home});
- } elsif ($ENV{'form.login'} ne '') {
+ } elsif (($ENV{'form.login'} ne 'nochange') &&
+ ($ENV{'form.login'} ne '' )) {
# Modify user privileges
$r->print(<Change User Privileges
@@ -683,9 +604,9 @@ ENDMODIFYUSERHEAD
return;
}
# Only allow authentification modification if the person has authority
- if (&Apache::lonnet::allowed('mau',$ENV{'user.domain'})) {
+ if (&Apache::lonnet::allowed('mau',$ENV{'form.ccdomain'})) {
$r->print('Modifying authentication: '.
- &Apache::lonnet::modifyuserauth(
+ &Apache::lonnet::modifyuserauth(
$ENV{'form.ccdomain'},$ENV{'form.ccuname'},
$amode,$genpwd));
$r->print(' Home server: '.&Apache::lonnet::homeserver
@@ -857,17 +778,17 @@ sub handler {
(&Apache::lonnet::allowed('cin',$ENV{'request.course.id'})) ||
(&Apache::lonnet::allowed('ccr',$ENV{'request.course.id'})) ||
(&Apache::lonnet::allowed('cep',$ENV{'request.course.id'})) ||
- (&Apache::lonnet::allowed('cca',$ENV{'user.domain'})) ||
- (&Apache::lonnet::allowed('mau',$ENV{'user.domain'}))) {
+ (&Apache::lonnet::allowed('cca',$ENV{'request.role.domain'})) ||
+ (&Apache::lonnet::allowed('mau',$ENV{'request.role.domain'}))) {
$r->content_type('text/html');
$r->send_http_header;
unless ($ENV{'form.phase'}) {
- &phase_one($r);
+ &print_username_entry_form($r);
}
- if ($ENV{'form.phase'} eq 'two') {
- &phase_two($r);
- } elsif ($ENV{'form.phase'} eq 'three') {
- &phase_three($r);
+ if ($ENV{'form.phase'} eq 'get_user_info') {
+ &print_user_modification_page($r);
+ } elsif ($ENV{'form.phase'} eq 'update_user_data') {
+ &update_user_data($r);
}
} else {
$ENV{'user.error.msg'}=
@@ -934,16 +855,6 @@ ENDTABLE
#---------------------------------------------- end functions for &phase_two
#--------------------------------- functions for &phase_two and &phase_three
-sub get_home_servers {
- my $domain = shift;
- my %home_servers;
- foreach (keys(%Apache::lonnet::libserv)) {
- if ($Apache::lonnet::hostdom{$_} eq $domain) {
- $home_servers{$_} = $Apache::lonnet::hostname{$_};
- }
- }
- return %home_servers;
-}
#--------------------------end of functions for &phase_two and &phase_three