--- loncom/interface/loncreateuser.pm 2002/04/23 21:05:45 1.33
+++ loncom/interface/loncreateuser.pm 2002/08/07 18:49:36 1.38
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Create a user
#
-# $Id: loncreateuser.pm,v 1.33 2002/04/23 21:05:45 matthew Exp $
+# $Id: loncreateuser.pm,v 1.38 2002/08/07 18:49:36 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.33 2002/04/23 21:05:45 matthew Exp $
+# $Id: loncreateuser.pm,v 1.38 2002/08/07 18:49:36 matthew Exp $
###
package Apache::loncreateuser;
@@ -250,65 +250,80 @@ END
my ($tmp) = keys(%rolesdump);
unless ($tmp =~ /^(con_lost|error)/i) {
my $now=time;
- $r->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{'user.domain'}\/$ENV{'user.name'}/) {
+ $allowed = 0;
+ }
+ }
+ }
+ my $row = '';
+ $row.='
\n";
+ $r->print($row);
} # end of foreach (table building loop)
$r->print('
');
} # End of unless
@@ -532,6 +547,12 @@ ENDTHREEHEAD
$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;
@@ -571,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
@@ -582,7 +604,7 @@ 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(
$ENV{'form.ccdomain'},$ENV{'form.ccuname'},