[LON-CAPA-cvs] cvs: loncom /auth lonroles.pm
raeburn
raeburn at source.lon-capa.org
Sun Feb 23 15:50:37 EST 2014
raeburn Sun Feb 23 20:50:37 2014 EDT
Modified files:
/loncom/auth lonroles.pm
Log:
- Remove check_needs_switchserver() routine which is no longer used.
- Changes to regexps to support adhoc role switching to custom roles
created by a user with an e-mail address as username.
Index: loncom/auth/lonroles.pm
diff -u loncom/auth/lonroles.pm:1.296 loncom/auth/lonroles.pm:1.297
--- loncom/auth/lonroles.pm:1.296 Sun Feb 23 19:06:18 2014
+++ loncom/auth/lonroles.pm Sun Feb 23 20:50:37 2014
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# User Roles Screen
#
-# $Id: lonroles.pm,v 1.296 2014/02/23 19:06:18 raeburn Exp $
+# $Id: lonroles.pm,v 1.297 2014/02/23 20:50:37 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -591,13 +591,8 @@
} else {
# Check to see if the user is a CC entering a course
# for the first time
- my (undef, undef, $role, $courseid) = split(/\./, $envkey);
- if (substr($courseid, 0, 1) eq '/') {
- $courseid = substr($courseid, 1);
- }
- $courseid =~ s/\//_/;
if ((($role eq 'cc') || ($role eq 'co'))
- && ($env{'course.' . $courseid .'.course.helper.not.run'})) {
+ && ($env{'course.'.$cdom.'_'.$cnum.'.course.helper.not.run'})) {
$furl = "/adm/helper/course.initialization.helper";
# Send the user to the course they selected
} elsif ($env{'request.course.id'}) {
@@ -649,7 +644,7 @@
}
}
&redirect_user($r, &mt('Entering [_1]',
- $env{'course.'.$courseid.'.description'}),
+ $env{'course.'.$cdom.'_'.$cnum.'.description'}),
$dest, $msg);
return OK;
}
@@ -659,10 +654,10 @@
$env{'request.course.id'}.'/'
.$env{'request.course.sec'})
) {
- my $startpage = &courseloadpage($courseid);
+ my $startpage = &courseloadpage($env{'request.course.id'});
unless ($startpage eq 'firstres') {
$msg = &mt('Entering [_1] ...',
- $env{'course.'.$courseid.'.description'});
+ $env{'course.'.$env{'request.course.id'}.'.description'});
&redirect_user($r, &mt('New in course'),
'/adm/whatsnew?refpage=start', $msg);
return OK;
@@ -675,9 +670,9 @@
$furl=&Apache::lonpageflip::first_accessible_resource();
}
$msg = &mt('Entering [_1] ...',
- $env{'course.'.$courseid.'.description'});
+ $env{'course.'.$cdom.'_'.$cnum.'.description'});
&redirect_user($r, &mt('Entering [_1]',
- $env{'course.'.$courseid.'.description'}),
+ $env{'course.'.$cdom.'_'.$cnum.'.description'}),
$furl, $msg);
}
return OK;
@@ -1604,24 +1599,6 @@
return ($roletext,$roletext_end);
}
-sub check_needs_switchserver {
- my ($possiblerole) = @_;
- my $needs_switchserver;
- my ($role,$where) = split(/\./,$possiblerole,2);
- my (undef,$tdom,$twho) = split(/\//,$where);
- my ($server_status,$home);
- if (($role eq 'ca') || ($role eq 'aa')) {
- ($server_status,$home) = &check_author_homeserver($twho,$tdom);
- } else {
- ($server_status,$home) = &check_author_homeserver($env{'user.name'},
- $env{'user.domain'});
- }
- if ($server_status eq 'switchserver') {
- $needs_switchserver = 1;
- }
- return $needs_switchserver;
-}
-
sub check_author_homeserver {
my ($uname,$udom)=@_;
if (($uname eq '') || ($udom eq '')) {
@@ -1687,7 +1664,7 @@
}
}
if ($setprivs) {
- if ($env{'form.switchrole'} =~ m-^(in|ta|ep|ad|st|cr)([\w/]*)\./\Q$cdom\E/\Q$cnum\E/?(\w*)$-) {
+ if ($env{'form.switchrole'} =~ m-^(in|ta|ep|ad|st|cr)(.*?)\./\Q$cdom\E/\Q$cnum\E/?(\w*)$-) {
my $role = $1;
my $custom_role = $2;
my $usec = $3;
@@ -2233,7 +2210,8 @@
my $status_in_env =
&curr_role_status($currstart,$currend,$refresh,$update);
my ($rolekey) = ($envkey =~ /^user\.role\.(.+)$/);
- my ($role,$rest)=split(/\./,$rolekey,2);
+ my ($role,$rest)=split(m{\./},$rolekey,2);
+ $rest = '/'.$rest;
if (&Apache::lonnet::delenv($envkey,undef,[$role])) {
if ($status_in_env eq 'active') {
if ($role eq 'gr') {
@@ -2762,7 +2740,7 @@
$env{'user.name'},'^status:');
foreach my $key (keys(%statusinfo)) {
next unless (($statusinfo{$key} eq 'approval') || ($statusinfo{$key} eq 'pending'));
- (undef,my($cdom,$cnum)) = split(':',$key);
+ (undef,my($cdom,$cnum)) = split(/:/,$key);
my $requestkey = $cdom.'_'.$cnum;
if ($requestkey =~ /^($match_domain)_($match_courseid)$/) {
my %history = &Apache::lonnet::restore($requestkey,'courserequests',
More information about the LON-CAPA-cvs
mailing list