--- loncom/interface/loncreateuser.pm 2007/08/02 01:07:00 1.168
+++ loncom/interface/loncreateuser.pm 2007/08/10 23:01:51 1.170
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Create a user
#
-# $Id: loncreateuser.pm,v 1.168 2007/08/02 01:07:00 albertel Exp $
+# $Id: loncreateuser.pm,v 1.170 2007/08/10 23:01:51 albertel Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -1136,7 +1136,7 @@ ENDNOPRIV
'.$lt{'ssd'}.' |
-
+ |
'.$lt{'sed'}.' | '."\n".
&Apache::loncommon::end_data_table_row()."\n".
@@ -1144,10 +1144,10 @@ ENDNOPRIV
' |
'.$lt{'caa'}.' |
'.$cudom.'_'.$cuname.' |
-
+ |
'.$lt{'ssd'}.' |
-
+ |
'.$lt{'sed'}.' | '."\n".
&Apache::loncommon::end_data_table_row()."\n".
@@ -1179,10 +1179,10 @@ ENDNOPRIV
' |
'.$plrole.' |
'.$thisdomain.' |
-
+ |
'.$lt{'ssd'}.' |
-
+ |
'.$lt{'sed'}.' | '.
&Apache::loncommon::end_data_table_row();
@@ -1537,23 +1537,20 @@ END
if ($key=~/^form\.rev/) {
if ($key=~/^form\.rev\:([^\_]+)\_([^\_\.]+)$/) {
# Revoke standard role
- $r->print(&mt('Revoking').' '.$2.' in '.$1.': '.
- &Apache::lonnet::revokerole($env{'form.ccdomain'},
- $env{'form.ccuname'},$1,$2).'
');
- if ($2 eq 'st') {
- $1=~m{^/($match_domain)/($match_courseid)};
- my $cid=$1.'_'.$2;
- my $user = $env{'form.ccuname'}.':'.$env{'form.ccdomain'};
- my $result =
- &Apache::lonnet::cput('classlist',
- { $user => $now },
- $env{'course.'.$cid.'.domain'},
- $env{'course.'.$cid.'.num'});
- $r->print(&mt('Drop from classlist: [_1]',
- ''.$result.'').'
');
+ my ($scope,$role) = ($1,$2);
+ my $result =
+ &Apache::lonnet::revokerole($env{'form.ccdomain'},
+ $env{'form.ccuname'},
+ $scope,$role);
+ $r->print(&mt('Revoking [_1] in [_2]: [_3]',
+ $role,$scope,''.$result.'').'
');
+ if ($role eq 'st') {
+ my $result = &classlist_drop($scope,$env{'form.ccuname'},
+ $env{'form.ccdomain'},$now);
+ $r->print($result);
}
}
- if ($key=~m{^form\.rev\:([^_]+)_cr\.cr/($match_domain)/($match_username)/(\w+)$}) {
+ if ($key=~m{^form\.rev\:([^_]+)_cr\.cr/($match_domain)/($match_username)/(\w+)$ }s) {
# Revoke custom role
$r->print(&mt('Revoking custom role:').
' '.$4.' by '.$3.':'.$2.' in '.$1.': '.
@@ -1564,26 +1561,23 @@ END
} elsif ($key=~/^form\.del/) {
if ($key=~/^form\.del\:([^\_]+)\_([^\_\.]+)$/) {
# Delete standard role
- $r->print(&mt('Deleting').' '.$2.' in '.$1.': '.
- &Apache::lonnet::assignrole($env{'form.ccdomain'},
- $env{'form.ccuname'},$1,$2,$now,0,1).'
');
- if ($2 eq 'st') {
- $1=~m{^/($match_domain)/($match_courseid)};
- my $cid=$1.'_'.$2;
- my $user = $env{'form.ccuname'}.':'.$env{'form.ccdomain'};
- my $result =
- &Apache::lonnet::cput('classlist',
- { $user => $now },
- $env{'course.'.$cid.'.domain'},
- $env{'course.'.$cid.'.num'});
- $r->print(&mt('Drop from classlist: [_1]',
- ''.$result.'').'
');
+ my ($scope,$role) = ($1,$2);
+ my $result =
+ &Apache::lonnet::assignrole($env{'form.ccdomain'},
+ $env{'form.ccuname'},
+ $scope,$role,$now,0,1);
+ $r->print(&mt('Deleting [_1] in [_2]: [_3]',$role,$scope,
+ ''.$result.'').'
');
+ if ($role eq 'st') {
+ my $result = &classlist_drop($scope,$env{'form.ccuname'},
+ $env{'form.ccdomain'},$now);
+ $r->print($result);
}
}
if ($key=~m{^form\.del\:([^_]+)_cr\.cr/($match_domain)/($match_username)/(\w+)$}) {
my ($url,$rdom,$rnam,$rolename) = ($1,$2,$3,$4);
# Delete custom role
- $r->print(&mt('Deleting custom role [_1] by [_2]@[_3] in [_4]',
+ $r->print(&mt('Deleting custom role [_1] by [_2]:[_3] in [_4]',
$rolename,$rnam,$rdom,$url).': '.
&Apache::lonnet::assigncustomrole($env{'form.ccdomain'},
$env{'form.ccuname'},$url,$rdom,$rnam,$rolename,$now,
@@ -1760,6 +1754,30 @@ END
$r->print(&Apache::loncommon::end_page());
}
+sub classlist_drop {
+ my ($scope,$uname,$udom,$now) = @_;
+ my ($cdom,$cnum) = ($scope=~m{^/($match_domain)/($match_courseid)});
+ my $cid=$cdom.'_'.$cnum;
+ my $user = $uname.':'.$udom;
+ if (!&active_student_roles($cnum,$cdom,$uname,$udom)) {
+ my $result =
+ &Apache::lonnet::cput('classlist',
+ { $user => $now },
+ $env{'course.'.$cid.'.domain'},
+ $env{'course.'.$cid.'.num'});
+ return &mt('Drop from classlist: [_1]',
+ ''.$result.'').'
';
+ }
+}
+
+sub active_student_role {
+ my ($cnum,$cdom,$uname,$udom) = @_;
+ my %roles =
+ &Apache::lonnet::get_my_roles($uname,$udom,'userroles',
+ ['future','active'],['st']);
+ return exists($roles{"$cnum:$cdom:st"});
+}
+
sub quota_admin {
my ($setquota,$changeHash) = @_;
my $quotachanged;
@@ -2554,10 +2572,10 @@ sub course_level_table {
$table .= '  | ';
}
$table .= <
+
$lt{'ssd'} |
-
+ |
$lt{'sed'} |
ENDTIMEENTRY
@@ -2590,10 +2608,10 @@ ENDTIMEENTRY
'name="sec_'.$customrole.'" />';
}
$table .= <
+
$lt{'ssd'} |
-
+ |
$lt{'sed'} |
ENDENTRY
@@ -2685,10 +2703,10 @@ sub course_level_dc {
''.
'';
$otheritems .= <
+
$lt{'ssd'} |
-
+ |
$lt{'sed'} |
ENDTIMEENTRY