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
# 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
'.
'
Revoke
Role
Extent
'.
'
Start
End
');
- 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 {
- 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('
');
- 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('
\n");
- }
- }
+ } # end of foreach (table building loop)
$r->print('
');
- }
+ } # End of unless
my $currentauth=&Apache::lonnet::queryauthenticate($ccuname,$ccdomain);
if ($currentauth=~/^krb4:/) {
$currentauth=~/^krb4:(.*)/;
@@ -543,150 +570,245 @@ ENDDROW
# ================================================================= Phase Three
sub phase_three {
my $r=shift;
+ # Error messages
+ my $error = 'Error:';
+ my $end = '